Socket
Socket
Sign inDemoInstall

osc

Package Overview
Dependencies
177
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.3 to 1.1.4

4

bower.json
{
"name": "osc.js",
"version": "1.1.3",
"version": "1.1.4",
"main": "dist/osc.min.js",

@@ -14,3 +14,3 @@ "ignore": [

"dependencies": {
"slip.js": ">=1.0.1",
"slip.js": "1.0.2",
"eventEmitter": "4.2.11"

@@ -17,0 +17,0 @@ },

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

/*! osc.js 1.1.2, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */
/*! osc.js 1.1.4, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */

@@ -1776,3 +1776,2 @@ /*

// Unsupported, non-API function.

@@ -1783,2 +1782,3 @@ osc.stopRelaying = function (from, relaySpec) {

/**

@@ -1803,3 +1803,4 @@ * A Relay connects two sources of OSC data together,

p = osc.Relay.prototype;
p = osc.Relay.prototype = Object.create(EventEmitter.prototype);
p.constructor = osc.Relay;

@@ -1818,2 +1819,10 @@ p.open = function () {

this.port2Spec = osc.relayPorts(this.port2, this.port1, this.options);
// Bind port close listeners to ensure that the relay
// will stop forwarding messages if one of its ports close.
// Users are still responsible for closing the underlying ports
// if necessary.
var closeListener = this.close.bind(this);
this.port1.on("close", closeListener);
this.port2.on("close", closeListener);
};

@@ -1824,2 +1833,3 @@

osc.stopRelaying(this.port2, this.port2Spec);
this.emit("close", this.port1, this.port2);
};

@@ -1826,0 +1836,0 @@

@@ -1,3 +0,3 @@

/*! osc.js 1.1.2, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */
/*! osc.js 1.1.4, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */
var osc=osc||{};!function(){"use strict";var a;osc.SECS_70YRS=2208988800,osc.TWO_32=4294967296,osc.defaults={metadata:!1,unpackSingleArgs:!0},osc.isBufferEnv="undefined"!=typeof Buffer,osc.isArray=function(a){return a&&"[object Array]"===Object.prototype.toString.call(a)},osc.isTypedArrayView=function(a){return a.buffer&&a.buffer instanceof ArrayBuffer},osc.isBuffer=function(a){return osc.isBufferEnv&&a instanceof Buffer},osc.dataView=function(b){return b instanceof DataView?b:"undefined"!=typeof a&&b instanceof a?b:osc.isBufferEnv&&b instanceof Buffer?new a(b):b.buffer?new DataView(b.buffer):b instanceof ArrayBuffer?new DataView(b):new DataView(new Uint8Array(b))},osc.byteArray=function(a){if(a instanceof Uint8Array)return a;var b=a.buffer?a.buffer:a;if("undefined"==typeof a.length||"string"==typeof a)throw new Error("Can't wrap a non-array-like object as Uint8Array. Object was: "+JSON.stringify(a,null,2));return new Uint8Array(b)},osc.makeByteArray=function(a){return osc.isBufferEnv?new Buffer(a):new Uint8Array(a)},osc.copyByteArray=function(a,b,c){if(osc.isTypedArrayView(a)&&osc.isTypedArrayView(b))b.set(a,c);else if(osc.isBuffer(a)&&osc.isBuffer(b))a.copy(b,c);else for(var d=void 0===c?0:c,e=Math.min(b.length-c,a.length),f=0,g=d;e>f;f++,g++)b[g]=a[f];return b},osc.readString=function(a,b){for(var c=[],d=b.idx;d<a.byteLength;d++){var e=a.getUint8(d);if(0===e){d++;break}c.push(e)}return d=d+3&-4,b.idx=d,String.fromCharCode.apply(null,c)},osc.writeString=function(a){for(var b=a+"\x00",c=b.length,d=c+3&-4,e=new Uint8Array(d),f=0;f<b.length;f++){var g=b.charCodeAt(f);e[f]=g}return e},osc.readPrimitive=function(a,b,c,d){var e=a[b](d.idx,!1);return d.idx+=c,e},osc.writePrimitive=function(a,b,c,d,e){e=void 0===e?0:e;var f;return b?f=new Uint8Array(b.buffer):(f=new Uint8Array(d),b=new DataView(f.buffer)),b[c](e,a,!1),f},osc.readInt32=function(a,b){return osc.readPrimitive(a,"getInt32",4,b)},osc.writeInt32=function(a,b,c){return osc.writePrimitive(a,b,"setInt32",4,c)},osc.readFloat32=function(a,b){return osc.readPrimitive(a,"getFloat32",4,b)},osc.writeFloat32=function(a,b,c){return osc.writePrimitive(a,b,"setFloat32",4,c)},osc.readFloat64=function(a,b){return osc.readPrimitive(a,"getFloat64",8,b)},osc.writeFloat64=function(a,b,c){return osc.writePrimitive(a,b,"setFloat64",8,c)},osc.readChar32=function(a,b){var c=osc.readPrimitive(a,"getUint32",4,b);return String.fromCharCode(c)},osc.writeChar32=function(a,b,c){var d=a.charCodeAt(0);return void 0===d||-1>d?void 0:osc.writePrimitive(d,b,"setUint32",4,c)},osc.readBlob=function(a,b){var c=osc.readInt32(a,b),d=c+3&-4,e=new Uint8Array(a.buffer,b.idx,c);return b.idx+=d,e},osc.writeBlob=function(a){a=osc.byteArray(a);var b=a.byteLength,c=b+3&-4,d=4,e=c+d,f=new Uint8Array(e),g=new DataView(f.buffer);return osc.writeInt32(b,g),f.set(a,d),f},osc.readMIDIBytes=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4);return b.idx+=4,c},osc.writeMIDIBytes=function(a){a=osc.byteArray(a);var b=new Uint8Array(4);return b.set(a),b},osc.readColor=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4),d=c[3]/255;return b.idx+=4,{r:c[0],g:c[1],b:c[2],a:d}},osc.writeColor=function(a){var b=Math.round(255*a.a),c=new Uint8Array([a.r,a.g,a.b,b]);return c},osc.readTrue=function(){return!0},osc.readFalse=function(){return!1},osc.readNull=function(){return null},osc.readImpulse=function(){return 1},osc.readTimeTag=function(a,b){var c=osc.readPrimitive(a,"getUint32",4,b),d=osc.readPrimitive(a,"getUint32",4,b),e=0===c&&1===d?Date.now():osc.ntpToJSTime(c,d);return{raw:[c,d],"native":e}},osc.writeTimeTag=function(a){var b=a.raw?a.raw:osc.jsToNTPTime(a["native"]),c=new Uint8Array(8),d=new DataView(c.buffer);return osc.writeInt32(b[0],d,0),osc.writeInt32(b[1],d,4),c},osc.timeTag=function(a){a=a||0;var b=Date.now()/1e3,c=Math.floor(b),d=b-c,e=Math.floor(a),f=a-e,g=d+f;if(g>1){var h=Math.floor(g),i=g-h;e+=h,g=i}var j=c+e+osc.SECS_70YRS,k=Math.round(osc.TWO_32*g);return{raw:[j,k]}},osc.ntpToJSTime=function(a,b){var c=a-osc.SECS_70YRS,d=b/osc.TWO_32,e=1e3*(c+d);return e},osc.jsToNTPTime=function(a){var b=a/1e3,c=Math.floor(b),d=b-c,e=c+osc.SECS_70YRS,f=Math.round(osc.TWO_32*d);return[e,f]},osc.readArguments=function(a,b,c){var d=osc.readString(a,c);if(0!==d.indexOf(","))throw new Error("A malformed type tag string was found while reading the arguments of an OSC message. String was: "+d," at offset: "+c.idx);var e=d.substring(1).split(""),f=[];return osc.readArgumentsIntoArray(f,e,d,a,b,c),f},osc.readArgument=function(a,b,c,d,e){var f=osc.argumentTypes[a];if(!f)throw new Error("'"+a+"' is not a valid OSC type tag. Type tag string was: "+b);var g=f.reader,h=osc[g](c,e);return d.metadata&&(h={type:a,value:h}),h},osc.readArgumentsIntoArray=function(a,b,c,d,e,f){for(var g=0;g<b.length;){var h,i=b[g];if("["===i){var j=b.slice(g+1),k=j.indexOf("]");if(0>k)throw new Error("Invalid argument type tag: an open array type tag ('[') was found without a matching close array tag ('[]'). Type tag was: "+c);var l=j.slice(0,k);h=osc.readArgumentsIntoArray([],l,c,d,e,f),g+=k+2}else h=osc.readArgument(i,c,d,e,f),g++;a.push(h)}return a},osc.writeArguments=function(a,b){var c=osc.collectArguments(a,b);return osc.joinParts(c)},osc.joinParts=function(a){for(var b=osc.makeByteArray(a.byteLength),c=a.parts,d=0,e=0;e<c.length;e++){var f=c[e];osc.copyByteArray(f,b,d),d+=f.length}return b},osc.addDataPart=function(a,b){b.parts.push(a),b.byteLength+=a.length},osc.collectArguments=function(a,b,c){osc.isArray(a)||(a=[a]),c=c||{byteLength:0,parts:[]},b.metadata||(a=osc.annotateArguments(a));for(var d=",",e=c.parts.length,f=0;f<a.length;f++){var g=a[f],h=g.type,i=osc.argumentTypes[h].writer;if(d+=g.type,i){var j=osc[i](g.value);osc.addDataPart(j,c)}}var k=osc.writeString(d);return c.byteLength+=k.byteLength,c.parts.splice(e,0,k),c},osc.readMessage=function(a,b,c){b=b||osc.defaults;var d=osc.dataView(a);c=c||{idx:0};var e=osc.readString(d,c);return osc.readMessageContents(e,d,b,c)},osc.readMessageContents=function(a,b,c,d){if(0!==a.indexOf("/"))throw new Error("A malformed OSC address was found while reading an OSC message. String was: "+a);var e=osc.readArguments(b,c,d);return{address:a,args:1===e.length&&c.unpackSingleArgs?e[0]:e}},osc.collectMessageParts=function(a,b,c){return c=c||{byteLength:0,parts:[]},osc.addDataPart(osc.writeString(a.address),c),osc.collectArguments(a.args,b,c)},osc.writeMessage=function(a,b){b=b||osc.defaults;var c=osc.collectMessageParts(a,b);return osc.joinParts(c)},osc.readBundle=function(a,b,c){return osc.readPacket(a,b,c)},osc.collectBundlePackets=function(a,b,c){c=c||{byteLength:0,parts:[]},osc.addDataPart(osc.writeString("#bundle"),c),osc.addDataPart(osc.writeTimeTag(a.timeTag),c);for(var d=0;d<a.packets.length;d++){var e=a.packets[d],f=e.address?osc.collectMessageParts:osc.collectBundlePackets,g=f(e,b);c.byteLength+=g.byteLength,osc.addDataPart(osc.writeInt32(g.byteLength),c),c.parts=c.parts.concat(g.parts)}return c},osc.writeBundle=function(a,b){if(a.timeTag&&a.packets){b=b||osc.defaults;var c=osc.collectBundlePackets(a,b);return osc.joinParts(c)}},osc.readBundleContents=function(a,b,c,d){for(var e=osc.readTimeTag(a,c),f=[];c.idx<d;){var g=osc.readInt32(a,c),h=c.idx+g,i=osc.readPacket(a,b,c,h);f.push(i)}return{timeTag:e,packets:f}},osc.readPacket=function(a,b,c,d){var e=osc.dataView(a);d=void 0===d?e.byteLength:d,c=c||{idx:0};var f=osc.readString(e,c),g=f[0];if("#"===g)return osc.readBundleContents(e,b,c,d);if("/"===g)return osc.readMessageContents(f,e,b,c);throw new Error("The header of an OSC packet didn't contain an OSC address or a #bundle string. Header was: "+f)},osc.writePacket=function(a,b){var c=a.address?osc.writeMessage:osc.writeBundle;return c(a,b)},osc.argumentTypes={i:{reader:"readInt32",writer:"writeInt32"},f:{reader:"readFloat32",writer:"writeFloat32"},s:{reader:"readString",writer:"writeString"},S:{reader:"readString",writer:"writeString"},b:{reader:"readBlob",writer:"writeBlob"},t:{reader:"readTimeTag",writer:"writeTimeTag"},T:{reader:"readTrue"},F:{reader:"readFalse"},N:{reader:"readNull"},I:{reader:"readImpulse"},d:{reader:"readFloat64",writer:"writeFloat64"},c:{reader:"readChar32",writer:"writeChar32"},r:{reader:"readColor",writer:"writeColor"},m:{reader:"readMIDIBytes",writer:"writeMIDIBytes"}},osc.inferTypeForArgument=function(a){var b=typeof a;switch(b){case"boolean":return a?"T":"F";case"string":return"s";case"number":return"f";case"undefined":return"N";case"object":if(null===a)return"N";if(a instanceof Uint8Array||a instanceof ArrayBuffer||osc.isBufferEnv&&a instanceof Buffer)return"b"}throw new Error("Can't infer OSC argument type for value: "+JSON.stringify(a,null,2))},osc.annotateArguments=function(a){osc.isArray(a)||(a=[a]);for(var b=[],c=0;c<a.length;c++){var d,e=a[c];if("object"==typeof e&&e.type&&void 0!==e.value)d=e;else{var f=osc.inferTypeForArgument(e);d={type:f,value:e}}b.push(d)}return b},"undefined"!=typeof module&&module.exports&&(osc.isBufferEnv&&(a=require("buffer-dataview")),module.exports=osc)}(),function(a,b){"use strict";"object"==typeof exports?(a.slip=exports,b(exports)):"function"==typeof define&&define.amd?define(["exports"],function(c){return a.slip=c,a.slip,b(c)}):(a.slip={},b(a.slip))}(this,function(a){"use strict";var b=a;b.END=192,b.ESC=219,b.ESC_END=220,b.ESC_ESC=221,b.byteArray=function(a,b,c){return a instanceof ArrayBuffer?new Uint8Array(a,b,c):a},b.expandByteArray=function(a){var b=new Uint8Array(2*a.length);return b.set(a),b},b.sliceByteArray=function(a,b,c){var d=a.buffer.slice?a.buffer.slice(b,c):a.subarray(b,c);return new Uint8Array(d)},b.encode=function(a,c){c=c||{},c.bufferPadding=c.bufferPadding||4,a=b.byteArray(a,c.offset,c.byteLength);var d=a.length+c.bufferPadding+3&-4,e=new Uint8Array(d),f=1;e[0]=b.END;for(var g=0;g<a.length;g++){f>e.length-3&&(e=b.expandByteArray(e));var h=a[g];h===b.END?(e[f++]=b.ESC,h=b.ESC_END):h===b.ESC&&(e[f++]=b.ESC,h=b.ESC_ESC),e[f++]=h}return e[f]=b.END,b.sliceByteArray(e,0,f+1)},b.Decoder=function(a){a="function"!=typeof a?a||{}:{onMessage:a},this.maxMessageSize=a.maxMessageSize||10485760,this.bufferSize=a.bufferSize||1024,this.msgBuffer=new Uint8Array(this.bufferSize),this.msgBufferIdx=0,this.onMessage=a.onMessage,this.onError=a.onError,this.escape=!1};var c=b.Decoder.prototype;return c.decode=function(a){a=b.byteArray(a);for(var c,d=0;d<a.length;d++){var e=a[d];if(this.escape)e===b.ESC_ESC?e=b.ESC:e===b.ESC_END&&(e=b.END);else{if(e===b.ESC){this.escape=!0;continue}if(e===b.END){c=this.handleEnd();continue}}var f=this.addByte(e);f||this.handleMessageMaxError()}return c},c.handleMessageMaxError=function(){this.onError&&this.onError(this.msgBuffer.subarray(0),"The message is too large; the maximum message size is "+this.maxMessageSize/1024+"KB. Use a larger maxMessageSize if necessary."),this.msgBufferIdx=0,this.escape=!1},c.addByte=function(a){return this.msgBufferIdx>this.msgBuffer.length-1&&(this.msgBuffer=b.expandByteArray(this.msgBuffer)),this.msgBuffer[this.msgBufferIdx++]=a,this.escape=!1,this.msgBuffer.length<this.maxMessageSize},c.handleEnd=function(){if(0!==this.msgBufferIdx){var a=b.sliceByteArray(this.msgBuffer,0,this.msgBufferIdx);return this.onMessage&&this.onMessage(a),this.msgBufferIdx=0,a}},b}),function(){"use strict";function a(){}function b(a,b){for(var c=a.length;c--;)if(a[c].listener===b)return c;return-1}function c(a){return function(){return this[a].apply(this,arguments)}}var d=a.prototype,e=this,f=e.EventEmitter;d.getListeners=function(a){var b,c,d=this._getEvents();if(a instanceof RegExp){b={};for(c in d)d.hasOwnProperty(c)&&a.test(c)&&(b[c]=d[c])}else b=d[a]||(d[a]=[]);return b},d.flattenListeners=function(a){var b,c=[];for(b=0;b<a.length;b+=1)c.push(a[b].listener);return c},d.getListenersAsObject=function(a){var b,c=this.getListeners(a);return c instanceof Array&&(b={},b[a]=c),b||c},d.addListener=function(a,c){var d,e=this.getListenersAsObject(a),f="object"==typeof c;for(d in e)e.hasOwnProperty(d)&&-1===b(e[d],c)&&e[d].push(f?c:{listener:c,once:!1});return this},d.on=c("addListener"),d.addOnceListener=function(a,b){return this.addListener(a,{listener:b,once:!0})},d.once=c("addOnceListener"),d.defineEvent=function(a){return this.getListeners(a),this},d.defineEvents=function(a){for(var b=0;b<a.length;b+=1)this.defineEvent(a[b]);return this},d.removeListener=function(a,c){var d,e,f=this.getListenersAsObject(a);for(e in f)f.hasOwnProperty(e)&&(d=b(f[e],c),-1!==d&&f[e].splice(d,1));return this},d.off=c("removeListener"),d.addListeners=function(a,b){return this.manipulateListeners(!1,a,b)},d.removeListeners=function(a,b){return this.manipulateListeners(!0,a,b)},d.manipulateListeners=function(a,b,c){var d,e,f=a?this.removeListener:this.addListener,g=a?this.removeListeners:this.addListeners;if("object"!=typeof b||b instanceof RegExp)for(d=c.length;d--;)f.call(this,b,c[d]);else for(d in b)b.hasOwnProperty(d)&&(e=b[d])&&("function"==typeof e?f.call(this,d,e):g.call(this,d,e));return this},d.removeEvent=function(a){var b,c=typeof a,d=this._getEvents();if("string"===c)delete d[a];else if(a instanceof RegExp)for(b in d)d.hasOwnProperty(b)&&a.test(b)&&delete d[b];else delete this._events;return this},d.removeAllListeners=c("removeEvent"),d.emitEvent=function(a,b){var c,d,e,f,g=this.getListenersAsObject(a);for(e in g)if(g.hasOwnProperty(e))for(d=g[e].length;d--;)c=g[e][d],c.once===!0&&this.removeListener(a,c.listener),f=c.listener.apply(this,b||[]),f===this._getOnceReturnValue()&&this.removeListener(a,c.listener);return this},d.trigger=c("emitEvent"),d.emit=function(a){var b=Array.prototype.slice.call(arguments,1);return this.emitEvent(a,b)},d.setOnceReturnValue=function(a){return this._onceReturnValue=a,this},d._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},d._getEvents=function(){return this._events||(this._events={})},a.noConflict=function(){return e.EventEmitter=f,a},"function"==typeof define&&define.amd?define(function(){return a}):"object"==typeof module&&module.exports?module.exports=a:e.EventEmitter=a}.call(this);var osc=osc||require("./osc.js"),slip=slip||require("slip"),EventEmitter=EventEmitter||require("events").EventEmitter;!function(){"use strict";osc.firePacketEvents=function(a,b,c){b.address?a.emit("message",b,c):osc.fireBundleEvents(a,b,c)},osc.fireBundleEvents=function(a,b,c){a.emit("bundle",b,c);for(var d=0;d<b.packets.length;d++){var e=b.packets[d];osc.firePacketEvents(a,e,b.timeTag)}},osc.Port=function(a){this.options=a||{},this.on("data",this.decodeOSC.bind(this))};var a=osc.Port.prototype=Object.create(EventEmitter.prototype);a.constructor=osc.Port,a.send=function(a){var b=Array.prototype.slice.call(arguments),c=this.encodeOSC(a);b[0]=c,this.sendRaw.apply(this,b)},a.encodeOSC=function(a){a=a.buffer?a.buffer:a;var b=osc.writePacket(a,this.options);return b},a.decodeOSC=function(a){this.emit("raw",a);var b=osc.readPacket(a,this.options);this.emit("osc",b),osc.firePacketEvents(this,b)},osc.SLIPPort=function(a){var b=this,c=this.options=a||{};c.useSLIP=void 0===c.useSLIP?!0:c.useSLIP,this.decoder=new slip.Decoder({onMessage:this.decodeOSC.bind(this),onError:function(a){b.emit("error",a)}});var d=c.useSLIP?this.decodeSLIPData:this.decodeOSC;this.on("data",d.bind(this))},a=osc.SLIPPort.prototype=Object.create(osc.Port.prototype),a.constructor=osc.SLIPPort,a.encodeOSC=function(a){a=a.buffer?a.buffer:a;var b=osc.writePacket(a,this.options);return slip.encode(b)},a.decodeSLIPData=function(a){this.decoder.decode(a)},osc.relay=function(a,b,c,d,e,f){c=c||"message",d=d||"send",e=e||function(){},f=f?[null].concat(f):[];var g=function(a){f[0]=a,a=e(a),b[d].apply(b,f)};return a.on(c,g),{eventName:c,listener:g}},osc.relayPorts=function(a,b,c){var d=c.raw?"raw":"osc",e=c.raw?"sendRaw":"send";return osc.relay(a,b,d,e,c.transform)},osc.stopRelaying=function(a,b){a.removeListener(b.eventName,b.listener)},osc.Relay=function(a,b,c){var d=this.options=c||{};d.raw=!1,this.port1=a,this.port2=b,this.listen()},a=osc.Relay.prototype,a.open=function(){this.port1.open(),this.port2.open()},a.listen=function(){this.port1Spec&&this.port2Spec&&this.close(),this.port1Spec=osc.relayPorts(this.port1,this.port2,this.options),this.port2Spec=osc.relayPorts(this.port2,this.port1,this.options)},a.close=function(){osc.stopRelaying(this.port1,this.port1Spec),osc.stopRelaying(this.port2,this.port2Spec)},"undefined"!=typeof module&&module.exports&&(module.exports=osc)}();var osc=osc;!function(){"use strict";osc.WebSocketPort=function(a){osc.Port.call(this,a),this.on("open",this.listen.bind(this))};var a=osc.WebSocketPort.prototype=Object.create(osc.Port.prototype);a.constructor=osc.WebSocketPort,a.open=function(){this.socket=new WebSocket(this.options.url),this.socket.binaryType="arraybuffer";var a=this;this.socket.onopen=function(){a.emit("open",a.socket)}},a.listen=function(){var a=this;this.socket.onmessage=function(b){a.emit("data",b.data)},this.socket.onerror=function(b){a.emit("error",b)},this.socket.onclose=function(b){a.emit("close",b)},a.emit("ready")},a.sendRaw=function(a){this.socket&&this.socket.send(a.buffer)},a.close=function(a,b){this.socket.close(a,b)}}();
var osc=osc||{};!function(){"use strict";var a;osc.SECS_70YRS=2208988800,osc.TWO_32=4294967296,osc.defaults={metadata:!1,unpackSingleArgs:!0},osc.isBufferEnv="undefined"!=typeof Buffer,osc.isArray=function(a){return a&&"[object Array]"===Object.prototype.toString.call(a)},osc.isTypedArrayView=function(a){return a.buffer&&a.buffer instanceof ArrayBuffer},osc.isBuffer=function(a){return osc.isBufferEnv&&a instanceof Buffer},osc.dataView=function(b){return b instanceof DataView?b:"undefined"!=typeof a&&b instanceof a?b:osc.isBufferEnv&&b instanceof Buffer?new a(b):b.buffer?new DataView(b.buffer):b instanceof ArrayBuffer?new DataView(b):new DataView(new Uint8Array(b))},osc.byteArray=function(a){if(a instanceof Uint8Array)return a;var b=a.buffer?a.buffer:a;if("undefined"==typeof a.length||"string"==typeof a)throw new Error("Can't wrap a non-array-like object as Uint8Array. Object was: "+JSON.stringify(a,null,2));return new Uint8Array(b)},osc.makeByteArray=function(a){return osc.isBufferEnv?new Buffer(a):new Uint8Array(a)},osc.copyByteArray=function(a,b,c){if(osc.isTypedArrayView(a)&&osc.isTypedArrayView(b))b.set(a,c);else if(osc.isBuffer(a)&&osc.isBuffer(b))a.copy(b,c);else for(var d=void 0===c?0:c,e=Math.min(b.length-c,a.length),f=0,g=d;e>f;f++,g++)b[g]=a[f];return b},osc.readString=function(a,b){for(var c=[],d=b.idx;d<a.byteLength;d++){var e=a.getUint8(d);if(0===e){d++;break}c.push(e)}return d=d+3&-4,b.idx=d,String.fromCharCode.apply(null,c)},osc.writeString=function(a){for(var b=a+"\x00",c=b.length,d=c+3&-4,e=new Uint8Array(d),f=0;f<b.length;f++){var g=b.charCodeAt(f);e[f]=g}return e},osc.readPrimitive=function(a,b,c,d){var e=a[b](d.idx,!1);return d.idx+=c,e},osc.writePrimitive=function(a,b,c,d,e){e=void 0===e?0:e;var f;return b?f=new Uint8Array(b.buffer):(f=new Uint8Array(d),b=new DataView(f.buffer)),b[c](e,a,!1),f},osc.readInt32=function(a,b){return osc.readPrimitive(a,"getInt32",4,b)},osc.writeInt32=function(a,b,c){return osc.writePrimitive(a,b,"setInt32",4,c)},osc.readFloat32=function(a,b){return osc.readPrimitive(a,"getFloat32",4,b)},osc.writeFloat32=function(a,b,c){return osc.writePrimitive(a,b,"setFloat32",4,c)},osc.readFloat64=function(a,b){return osc.readPrimitive(a,"getFloat64",8,b)},osc.writeFloat64=function(a,b,c){return osc.writePrimitive(a,b,"setFloat64",8,c)},osc.readChar32=function(a,b){var c=osc.readPrimitive(a,"getUint32",4,b);return String.fromCharCode(c)},osc.writeChar32=function(a,b,c){var d=a.charCodeAt(0);return void 0===d||-1>d?void 0:osc.writePrimitive(d,b,"setUint32",4,c)},osc.readBlob=function(a,b){var c=osc.readInt32(a,b),d=c+3&-4,e=new Uint8Array(a.buffer,b.idx,c);return b.idx+=d,e},osc.writeBlob=function(a){a=osc.byteArray(a);var b=a.byteLength,c=b+3&-4,d=4,e=c+d,f=new Uint8Array(e),g=new DataView(f.buffer);return osc.writeInt32(b,g),f.set(a,d),f},osc.readMIDIBytes=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4);return b.idx+=4,c},osc.writeMIDIBytes=function(a){a=osc.byteArray(a);var b=new Uint8Array(4);return b.set(a),b},osc.readColor=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4),d=c[3]/255;return b.idx+=4,{r:c[0],g:c[1],b:c[2],a:d}},osc.writeColor=function(a){var b=Math.round(255*a.a),c=new Uint8Array([a.r,a.g,a.b,b]);return c},osc.readTrue=function(){return!0},osc.readFalse=function(){return!1},osc.readNull=function(){return null},osc.readImpulse=function(){return 1},osc.readTimeTag=function(a,b){var c=osc.readPrimitive(a,"getUint32",4,b),d=osc.readPrimitive(a,"getUint32",4,b),e=0===c&&1===d?Date.now():osc.ntpToJSTime(c,d);return{raw:[c,d],"native":e}},osc.writeTimeTag=function(a){var b=a.raw?a.raw:osc.jsToNTPTime(a["native"]),c=new Uint8Array(8),d=new DataView(c.buffer);return osc.writeInt32(b[0],d,0),osc.writeInt32(b[1],d,4),c},osc.timeTag=function(a){a=a||0;var b=Date.now()/1e3,c=Math.floor(b),d=b-c,e=Math.floor(a),f=a-e,g=d+f;if(g>1){var h=Math.floor(g),i=g-h;e+=h,g=i}var j=c+e+osc.SECS_70YRS,k=Math.round(osc.TWO_32*g);return{raw:[j,k]}},osc.ntpToJSTime=function(a,b){var c=a-osc.SECS_70YRS,d=b/osc.TWO_32,e=1e3*(c+d);return e},osc.jsToNTPTime=function(a){var b=a/1e3,c=Math.floor(b),d=b-c,e=c+osc.SECS_70YRS,f=Math.round(osc.TWO_32*d);return[e,f]},osc.readArguments=function(a,b,c){var d=osc.readString(a,c);if(0!==d.indexOf(","))throw new Error("A malformed type tag string was found while reading the arguments of an OSC message. String was: "+d," at offset: "+c.idx);var e=d.substring(1).split(""),f=[];return osc.readArgumentsIntoArray(f,e,d,a,b,c),f},osc.readArgument=function(a,b,c,d,e){var f=osc.argumentTypes[a];if(!f)throw new Error("'"+a+"' is not a valid OSC type tag. Type tag string was: "+b);var g=f.reader,h=osc[g](c,e);return d.metadata&&(h={type:a,value:h}),h},osc.readArgumentsIntoArray=function(a,b,c,d,e,f){for(var g=0;g<b.length;){var h,i=b[g];if("["===i){var j=b.slice(g+1),k=j.indexOf("]");if(0>k)throw new Error("Invalid argument type tag: an open array type tag ('[') was found without a matching close array tag ('[]'). Type tag was: "+c);var l=j.slice(0,k);h=osc.readArgumentsIntoArray([],l,c,d,e,f),g+=k+2}else h=osc.readArgument(i,c,d,e,f),g++;a.push(h)}return a},osc.writeArguments=function(a,b){var c=osc.collectArguments(a,b);return osc.joinParts(c)},osc.joinParts=function(a){for(var b=osc.makeByteArray(a.byteLength),c=a.parts,d=0,e=0;e<c.length;e++){var f=c[e];osc.copyByteArray(f,b,d),d+=f.length}return b},osc.addDataPart=function(a,b){b.parts.push(a),b.byteLength+=a.length},osc.collectArguments=function(a,b,c){osc.isArray(a)||(a=[a]),c=c||{byteLength:0,parts:[]},b.metadata||(a=osc.annotateArguments(a));for(var d=",",e=c.parts.length,f=0;f<a.length;f++){var g=a[f],h=g.type,i=osc.argumentTypes[h].writer;if(d+=g.type,i){var j=osc[i](g.value);osc.addDataPart(j,c)}}var k=osc.writeString(d);return c.byteLength+=k.byteLength,c.parts.splice(e,0,k),c},osc.readMessage=function(a,b,c){b=b||osc.defaults;var d=osc.dataView(a);c=c||{idx:0};var e=osc.readString(d,c);return osc.readMessageContents(e,d,b,c)},osc.readMessageContents=function(a,b,c,d){if(0!==a.indexOf("/"))throw new Error("A malformed OSC address was found while reading an OSC message. String was: "+a);var e=osc.readArguments(b,c,d);return{address:a,args:1===e.length&&c.unpackSingleArgs?e[0]:e}},osc.collectMessageParts=function(a,b,c){return c=c||{byteLength:0,parts:[]},osc.addDataPart(osc.writeString(a.address),c),osc.collectArguments(a.args,b,c)},osc.writeMessage=function(a,b){b=b||osc.defaults;var c=osc.collectMessageParts(a,b);return osc.joinParts(c)},osc.readBundle=function(a,b,c){return osc.readPacket(a,b,c)},osc.collectBundlePackets=function(a,b,c){c=c||{byteLength:0,parts:[]},osc.addDataPart(osc.writeString("#bundle"),c),osc.addDataPart(osc.writeTimeTag(a.timeTag),c);for(var d=0;d<a.packets.length;d++){var e=a.packets[d],f=e.address?osc.collectMessageParts:osc.collectBundlePackets,g=f(e,b);c.byteLength+=g.byteLength,osc.addDataPart(osc.writeInt32(g.byteLength),c),c.parts=c.parts.concat(g.parts)}return c},osc.writeBundle=function(a,b){if(a.timeTag&&a.packets){b=b||osc.defaults;var c=osc.collectBundlePackets(a,b);return osc.joinParts(c)}},osc.readBundleContents=function(a,b,c,d){for(var e=osc.readTimeTag(a,c),f=[];c.idx<d;){var g=osc.readInt32(a,c),h=c.idx+g,i=osc.readPacket(a,b,c,h);f.push(i)}return{timeTag:e,packets:f}},osc.readPacket=function(a,b,c,d){var e=osc.dataView(a);d=void 0===d?e.byteLength:d,c=c||{idx:0};var f=osc.readString(e,c),g=f[0];if("#"===g)return osc.readBundleContents(e,b,c,d);if("/"===g)return osc.readMessageContents(f,e,b,c);throw new Error("The header of an OSC packet didn't contain an OSC address or a #bundle string. Header was: "+f)},osc.writePacket=function(a,b){var c=a.address?osc.writeMessage:osc.writeBundle;return c(a,b)},osc.argumentTypes={i:{reader:"readInt32",writer:"writeInt32"},f:{reader:"readFloat32",writer:"writeFloat32"},s:{reader:"readString",writer:"writeString"},S:{reader:"readString",writer:"writeString"},b:{reader:"readBlob",writer:"writeBlob"},t:{reader:"readTimeTag",writer:"writeTimeTag"},T:{reader:"readTrue"},F:{reader:"readFalse"},N:{reader:"readNull"},I:{reader:"readImpulse"},d:{reader:"readFloat64",writer:"writeFloat64"},c:{reader:"readChar32",writer:"writeChar32"},r:{reader:"readColor",writer:"writeColor"},m:{reader:"readMIDIBytes",writer:"writeMIDIBytes"}},osc.inferTypeForArgument=function(a){var b=typeof a;switch(b){case"boolean":return a?"T":"F";case"string":return"s";case"number":return"f";case"undefined":return"N";case"object":if(null===a)return"N";if(a instanceof Uint8Array||a instanceof ArrayBuffer||osc.isBufferEnv&&a instanceof Buffer)return"b"}throw new Error("Can't infer OSC argument type for value: "+JSON.stringify(a,null,2))},osc.annotateArguments=function(a){osc.isArray(a)||(a=[a]);for(var b=[],c=0;c<a.length;c++){var d,e=a[c];if("object"==typeof e&&e.type&&void 0!==e.value)d=e;else{var f=osc.inferTypeForArgument(e);d={type:f,value:e}}b.push(d)}return b},"undefined"!=typeof module&&module.exports&&(osc.isBufferEnv&&(a=require("buffer-dataview")),module.exports=osc)}(),function(a,b){"use strict";"object"==typeof exports?(a.slip=exports,b(exports)):"function"==typeof define&&define.amd?define(["exports"],function(c){return a.slip=c,a.slip,b(c)}):(a.slip={},b(a.slip))}(this,function(a){"use strict";var b=a;b.END=192,b.ESC=219,b.ESC_END=220,b.ESC_ESC=221,b.byteArray=function(a,b,c){return a instanceof ArrayBuffer?new Uint8Array(a,b,c):a},b.expandByteArray=function(a){var b=new Uint8Array(2*a.length);return b.set(a),b},b.sliceByteArray=function(a,b,c){var d=a.buffer.slice?a.buffer.slice(b,c):a.subarray(b,c);return new Uint8Array(d)},b.encode=function(a,c){c=c||{},c.bufferPadding=c.bufferPadding||4,a=b.byteArray(a,c.offset,c.byteLength);var d=a.length+c.bufferPadding+3&-4,e=new Uint8Array(d),f=1;e[0]=b.END;for(var g=0;g<a.length;g++){f>e.length-3&&(e=b.expandByteArray(e));var h=a[g];h===b.END?(e[f++]=b.ESC,h=b.ESC_END):h===b.ESC&&(e[f++]=b.ESC,h=b.ESC_ESC),e[f++]=h}return e[f]=b.END,b.sliceByteArray(e,0,f+1)},b.Decoder=function(a){a="function"!=typeof a?a||{}:{onMessage:a},this.maxMessageSize=a.maxMessageSize||10485760,this.bufferSize=a.bufferSize||1024,this.msgBuffer=new Uint8Array(this.bufferSize),this.msgBufferIdx=0,this.onMessage=a.onMessage,this.onError=a.onError,this.escape=!1};var c=b.Decoder.prototype;return c.decode=function(a){a=b.byteArray(a);for(var c,d=0;d<a.length;d++){var e=a[d];if(this.escape)e===b.ESC_ESC?e=b.ESC:e===b.ESC_END&&(e=b.END);else{if(e===b.ESC){this.escape=!0;continue}if(e===b.END){c=this.handleEnd();continue}}var f=this.addByte(e);f||this.handleMessageMaxError()}return c},c.handleMessageMaxError=function(){this.onError&&this.onError(this.msgBuffer.subarray(0),"The message is too large; the maximum message size is "+this.maxMessageSize/1024+"KB. Use a larger maxMessageSize if necessary."),this.msgBufferIdx=0,this.escape=!1},c.addByte=function(a){return this.msgBufferIdx>this.msgBuffer.length-1&&(this.msgBuffer=b.expandByteArray(this.msgBuffer)),this.msgBuffer[this.msgBufferIdx++]=a,this.escape=!1,this.msgBuffer.length<this.maxMessageSize},c.handleEnd=function(){if(0!==this.msgBufferIdx){var a=b.sliceByteArray(this.msgBuffer,0,this.msgBufferIdx);return this.onMessage&&this.onMessage(a),this.msgBufferIdx=0,a}},b}),function(){"use strict";function a(){}function b(a,b){for(var c=a.length;c--;)if(a[c].listener===b)return c;return-1}function c(a){return function(){return this[a].apply(this,arguments)}}var d=a.prototype,e=this,f=e.EventEmitter;d.getListeners=function(a){var b,c,d=this._getEvents();if(a instanceof RegExp){b={};for(c in d)d.hasOwnProperty(c)&&a.test(c)&&(b[c]=d[c])}else b=d[a]||(d[a]=[]);return b},d.flattenListeners=function(a){var b,c=[];for(b=0;b<a.length;b+=1)c.push(a[b].listener);return c},d.getListenersAsObject=function(a){var b,c=this.getListeners(a);return c instanceof Array&&(b={},b[a]=c),b||c},d.addListener=function(a,c){var d,e=this.getListenersAsObject(a),f="object"==typeof c;for(d in e)e.hasOwnProperty(d)&&-1===b(e[d],c)&&e[d].push(f?c:{listener:c,once:!1});return this},d.on=c("addListener"),d.addOnceListener=function(a,b){return this.addListener(a,{listener:b,once:!0})},d.once=c("addOnceListener"),d.defineEvent=function(a){return this.getListeners(a),this},d.defineEvents=function(a){for(var b=0;b<a.length;b+=1)this.defineEvent(a[b]);return this},d.removeListener=function(a,c){var d,e,f=this.getListenersAsObject(a);for(e in f)f.hasOwnProperty(e)&&(d=b(f[e],c),-1!==d&&f[e].splice(d,1));return this},d.off=c("removeListener"),d.addListeners=function(a,b){return this.manipulateListeners(!1,a,b)},d.removeListeners=function(a,b){return this.manipulateListeners(!0,a,b)},d.manipulateListeners=function(a,b,c){var d,e,f=a?this.removeListener:this.addListener,g=a?this.removeListeners:this.addListeners;if("object"!=typeof b||b instanceof RegExp)for(d=c.length;d--;)f.call(this,b,c[d]);else for(d in b)b.hasOwnProperty(d)&&(e=b[d])&&("function"==typeof e?f.call(this,d,e):g.call(this,d,e));return this},d.removeEvent=function(a){var b,c=typeof a,d=this._getEvents();if("string"===c)delete d[a];else if(a instanceof RegExp)for(b in d)d.hasOwnProperty(b)&&a.test(b)&&delete d[b];else delete this._events;return this},d.removeAllListeners=c("removeEvent"),d.emitEvent=function(a,b){var c,d,e,f,g=this.getListenersAsObject(a);for(e in g)if(g.hasOwnProperty(e))for(d=g[e].length;d--;)c=g[e][d],c.once===!0&&this.removeListener(a,c.listener),f=c.listener.apply(this,b||[]),f===this._getOnceReturnValue()&&this.removeListener(a,c.listener);return this},d.trigger=c("emitEvent"),d.emit=function(a){var b=Array.prototype.slice.call(arguments,1);return this.emitEvent(a,b)},d.setOnceReturnValue=function(a){return this._onceReturnValue=a,this},d._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},d._getEvents=function(){return this._events||(this._events={})},a.noConflict=function(){return e.EventEmitter=f,a},"function"==typeof define&&define.amd?define(function(){return a}):"object"==typeof module&&module.exports?module.exports=a:e.EventEmitter=a}.call(this);var osc=osc||require("./osc.js"),slip=slip||require("slip"),EventEmitter=EventEmitter||require("events").EventEmitter;!function(){"use strict";osc.firePacketEvents=function(a,b,c){b.address?a.emit("message",b,c):osc.fireBundleEvents(a,b,c)},osc.fireBundleEvents=function(a,b,c){a.emit("bundle",b,c);for(var d=0;d<b.packets.length;d++){var e=b.packets[d];osc.firePacketEvents(a,e,b.timeTag)}},osc.Port=function(a){this.options=a||{},this.on("data",this.decodeOSC.bind(this))};var a=osc.Port.prototype=Object.create(EventEmitter.prototype);a.constructor=osc.Port,a.send=function(a){var b=Array.prototype.slice.call(arguments),c=this.encodeOSC(a);b[0]=c,this.sendRaw.apply(this,b)},a.encodeOSC=function(a){a=a.buffer?a.buffer:a;var b=osc.writePacket(a,this.options);return b},a.decodeOSC=function(a){this.emit("raw",a);var b=osc.readPacket(a,this.options);this.emit("osc",b),osc.firePacketEvents(this,b)},osc.SLIPPort=function(a){var b=this,c=this.options=a||{};c.useSLIP=void 0===c.useSLIP?!0:c.useSLIP,this.decoder=new slip.Decoder({onMessage:this.decodeOSC.bind(this),onError:function(a){b.emit("error",a)}});var d=c.useSLIP?this.decodeSLIPData:this.decodeOSC;this.on("data",d.bind(this))},a=osc.SLIPPort.prototype=Object.create(osc.Port.prototype),a.constructor=osc.SLIPPort,a.encodeOSC=function(a){a=a.buffer?a.buffer:a;var b=osc.writePacket(a,this.options);return slip.encode(b)},a.decodeSLIPData=function(a){this.decoder.decode(a)},osc.relay=function(a,b,c,d,e,f){c=c||"message",d=d||"send",e=e||function(){},f=f?[null].concat(f):[];var g=function(a){f[0]=a,a=e(a),b[d].apply(b,f)};return a.on(c,g),{eventName:c,listener:g}},osc.relayPorts=function(a,b,c){var d=c.raw?"raw":"osc",e=c.raw?"sendRaw":"send";return osc.relay(a,b,d,e,c.transform)},osc.stopRelaying=function(a,b){a.removeListener(b.eventName,b.listener)},osc.Relay=function(a,b,c){var d=this.options=c||{};d.raw=!1,this.port1=a,this.port2=b,this.listen()},a=osc.Relay.prototype=Object.create(EventEmitter.prototype),a.constructor=osc.Relay,a.open=function(){this.port1.open(),this.port2.open()},a.listen=function(){this.port1Spec&&this.port2Spec&&this.close(),this.port1Spec=osc.relayPorts(this.port1,this.port2,this.options),this.port2Spec=osc.relayPorts(this.port2,this.port1,this.options);var a=this.close.bind(this);this.port1.on("close",a),this.port2.on("close",a)},a.close=function(){osc.stopRelaying(this.port1,this.port1Spec),osc.stopRelaying(this.port2,this.port2Spec),this.emit("close",this.port1,this.port2)},"undefined"!=typeof module&&module.exports&&(module.exports=osc)}();var osc=osc;!function(){"use strict";osc.WebSocketPort=function(a){osc.Port.call(this,a),this.on("open",this.listen.bind(this))};var a=osc.WebSocketPort.prototype=Object.create(osc.Port.prototype);a.constructor=osc.WebSocketPort,a.open=function(){this.socket=new WebSocket(this.options.url),this.socket.binaryType="arraybuffer";var a=this;this.socket.onopen=function(){a.emit("open",a.socket)}},a.listen=function(){var a=this;this.socket.onmessage=function(b){a.emit("data",b.data)},this.socket.onerror=function(b){a.emit("error",b)},this.socket.onclose=function(b){a.emit("close",b)},a.emit("ready")},a.sendRaw=function(a){this.socket&&this.socket.send(a.buffer)},a.close=function(a,b){this.socket.close(a,b)}}();

@@ -1,3 +0,3 @@

/*! osc.js 1.1.2, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */
/*! osc.js 1.1.4, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */
var osc=osc||{};!function(){"use strict";var a;osc.SECS_70YRS=2208988800,osc.TWO_32=4294967296,osc.defaults={metadata:!1,unpackSingleArgs:!0},osc.isBufferEnv="undefined"!=typeof Buffer,osc.isArray=function(a){return a&&"[object Array]"===Object.prototype.toString.call(a)},osc.isTypedArrayView=function(a){return a.buffer&&a.buffer instanceof ArrayBuffer},osc.isBuffer=function(a){return osc.isBufferEnv&&a instanceof Buffer},osc.dataView=function(b){return b instanceof DataView?b:"undefined"!=typeof a&&b instanceof a?b:osc.isBufferEnv&&b instanceof Buffer?new a(b):b.buffer?new DataView(b.buffer):b instanceof ArrayBuffer?new DataView(b):new DataView(new Uint8Array(b))},osc.byteArray=function(a){if(a instanceof Uint8Array)return a;var b=a.buffer?a.buffer:a;if("undefined"==typeof a.length||"string"==typeof a)throw new Error("Can't wrap a non-array-like object as Uint8Array. Object was: "+JSON.stringify(a,null,2));return new Uint8Array(b)},osc.makeByteArray=function(a){return osc.isBufferEnv?new Buffer(a):new Uint8Array(a)},osc.copyByteArray=function(a,b,c){if(osc.isTypedArrayView(a)&&osc.isTypedArrayView(b))b.set(a,c);else if(osc.isBuffer(a)&&osc.isBuffer(b))a.copy(b,c);else for(var d=void 0===c?0:c,e=Math.min(b.length-c,a.length),f=0,g=d;e>f;f++,g++)b[g]=a[f];return b},osc.readString=function(a,b){for(var c=[],d=b.idx;d<a.byteLength;d++){var e=a.getUint8(d);if(0===e){d++;break}c.push(e)}return d=d+3&-4,b.idx=d,String.fromCharCode.apply(null,c)},osc.writeString=function(a){for(var b=a+"\x00",c=b.length,d=c+3&-4,e=new Uint8Array(d),f=0;f<b.length;f++){var g=b.charCodeAt(f);e[f]=g}return e},osc.readPrimitive=function(a,b,c,d){var e=a[b](d.idx,!1);return d.idx+=c,e},osc.writePrimitive=function(a,b,c,d,e){e=void 0===e?0:e;var f;return b?f=new Uint8Array(b.buffer):(f=new Uint8Array(d),b=new DataView(f.buffer)),b[c](e,a,!1),f},osc.readInt32=function(a,b){return osc.readPrimitive(a,"getInt32",4,b)},osc.writeInt32=function(a,b,c){return osc.writePrimitive(a,b,"setInt32",4,c)},osc.readFloat32=function(a,b){return osc.readPrimitive(a,"getFloat32",4,b)},osc.writeFloat32=function(a,b,c){return osc.writePrimitive(a,b,"setFloat32",4,c)},osc.readFloat64=function(a,b){return osc.readPrimitive(a,"getFloat64",8,b)},osc.writeFloat64=function(a,b,c){return osc.writePrimitive(a,b,"setFloat64",8,c)},osc.readChar32=function(a,b){var c=osc.readPrimitive(a,"getUint32",4,b);return String.fromCharCode(c)},osc.writeChar32=function(a,b,c){var d=a.charCodeAt(0);return void 0===d||-1>d?void 0:osc.writePrimitive(d,b,"setUint32",4,c)},osc.readBlob=function(a,b){var c=osc.readInt32(a,b),d=c+3&-4,e=new Uint8Array(a.buffer,b.idx,c);return b.idx+=d,e},osc.writeBlob=function(a){a=osc.byteArray(a);var b=a.byteLength,c=b+3&-4,d=4,e=c+d,f=new Uint8Array(e),g=new DataView(f.buffer);return osc.writeInt32(b,g),f.set(a,d),f},osc.readMIDIBytes=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4);return b.idx+=4,c},osc.writeMIDIBytes=function(a){a=osc.byteArray(a);var b=new Uint8Array(4);return b.set(a),b},osc.readColor=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4),d=c[3]/255;return b.idx+=4,{r:c[0],g:c[1],b:c[2],a:d}},osc.writeColor=function(a){var b=Math.round(255*a.a),c=new Uint8Array([a.r,a.g,a.b,b]);return c},osc.readTrue=function(){return!0},osc.readFalse=function(){return!1},osc.readNull=function(){return null},osc.readImpulse=function(){return 1},osc.readTimeTag=function(a,b){var c=osc.readPrimitive(a,"getUint32",4,b),d=osc.readPrimitive(a,"getUint32",4,b),e=0===c&&1===d?Date.now():osc.ntpToJSTime(c,d);return{raw:[c,d],"native":e}},osc.writeTimeTag=function(a){var b=a.raw?a.raw:osc.jsToNTPTime(a["native"]),c=new Uint8Array(8),d=new DataView(c.buffer);return osc.writeInt32(b[0],d,0),osc.writeInt32(b[1],d,4),c},osc.timeTag=function(a){a=a||0;var b=Date.now()/1e3,c=Math.floor(b),d=b-c,e=Math.floor(a),f=a-e,g=d+f;if(g>1){var h=Math.floor(g),i=g-h;e+=h,g=i}var j=c+e+osc.SECS_70YRS,k=Math.round(osc.TWO_32*g);return{raw:[j,k]}},osc.ntpToJSTime=function(a,b){var c=a-osc.SECS_70YRS,d=b/osc.TWO_32,e=1e3*(c+d);return e},osc.jsToNTPTime=function(a){var b=a/1e3,c=Math.floor(b),d=b-c,e=c+osc.SECS_70YRS,f=Math.round(osc.TWO_32*d);return[e,f]},osc.readArguments=function(a,b,c){var d=osc.readString(a,c);if(0!==d.indexOf(","))throw new Error("A malformed type tag string was found while reading the arguments of an OSC message. String was: "+d," at offset: "+c.idx);var e=d.substring(1).split(""),f=[];return osc.readArgumentsIntoArray(f,e,d,a,b,c),f},osc.readArgument=function(a,b,c,d,e){var f=osc.argumentTypes[a];if(!f)throw new Error("'"+a+"' is not a valid OSC type tag. Type tag string was: "+b);var g=f.reader,h=osc[g](c,e);return d.metadata&&(h={type:a,value:h}),h},osc.readArgumentsIntoArray=function(a,b,c,d,e,f){for(var g=0;g<b.length;){var h,i=b[g];if("["===i){var j=b.slice(g+1),k=j.indexOf("]");if(0>k)throw new Error("Invalid argument type tag: an open array type tag ('[') was found without a matching close array tag ('[]'). Type tag was: "+c);var l=j.slice(0,k);h=osc.readArgumentsIntoArray([],l,c,d,e,f),g+=k+2}else h=osc.readArgument(i,c,d,e,f),g++;a.push(h)}return a},osc.writeArguments=function(a,b){var c=osc.collectArguments(a,b);return osc.joinParts(c)},osc.joinParts=function(a){for(var b=osc.makeByteArray(a.byteLength),c=a.parts,d=0,e=0;e<c.length;e++){var f=c[e];osc.copyByteArray(f,b,d),d+=f.length}return b},osc.addDataPart=function(a,b){b.parts.push(a),b.byteLength+=a.length},osc.collectArguments=function(a,b,c){osc.isArray(a)||(a=[a]),c=c||{byteLength:0,parts:[]},b.metadata||(a=osc.annotateArguments(a));for(var d=",",e=c.parts.length,f=0;f<a.length;f++){var g=a[f],h=g.type,i=osc.argumentTypes[h].writer;if(d+=g.type,i){var j=osc[i](g.value);osc.addDataPart(j,c)}}var k=osc.writeString(d);return c.byteLength+=k.byteLength,c.parts.splice(e,0,k),c},osc.readMessage=function(a,b,c){b=b||osc.defaults;var d=osc.dataView(a);c=c||{idx:0};var e=osc.readString(d,c);return osc.readMessageContents(e,d,b,c)},osc.readMessageContents=function(a,b,c,d){if(0!==a.indexOf("/"))throw new Error("A malformed OSC address was found while reading an OSC message. String was: "+a);var e=osc.readArguments(b,c,d);return{address:a,args:1===e.length&&c.unpackSingleArgs?e[0]:e}},osc.collectMessageParts=function(a,b,c){return c=c||{byteLength:0,parts:[]},osc.addDataPart(osc.writeString(a.address),c),osc.collectArguments(a.args,b,c)},osc.writeMessage=function(a,b){b=b||osc.defaults;var c=osc.collectMessageParts(a,b);return osc.joinParts(c)},osc.readBundle=function(a,b,c){return osc.readPacket(a,b,c)},osc.collectBundlePackets=function(a,b,c){c=c||{byteLength:0,parts:[]},osc.addDataPart(osc.writeString("#bundle"),c),osc.addDataPart(osc.writeTimeTag(a.timeTag),c);for(var d=0;d<a.packets.length;d++){var e=a.packets[d],f=e.address?osc.collectMessageParts:osc.collectBundlePackets,g=f(e,b);c.byteLength+=g.byteLength,osc.addDataPart(osc.writeInt32(g.byteLength),c),c.parts=c.parts.concat(g.parts)}return c},osc.writeBundle=function(a,b){if(a.timeTag&&a.packets){b=b||osc.defaults;var c=osc.collectBundlePackets(a,b);return osc.joinParts(c)}},osc.readBundleContents=function(a,b,c,d){for(var e=osc.readTimeTag(a,c),f=[];c.idx<d;){var g=osc.readInt32(a,c),h=c.idx+g,i=osc.readPacket(a,b,c,h);f.push(i)}return{timeTag:e,packets:f}},osc.readPacket=function(a,b,c,d){var e=osc.dataView(a);d=void 0===d?e.byteLength:d,c=c||{idx:0};var f=osc.readString(e,c),g=f[0];if("#"===g)return osc.readBundleContents(e,b,c,d);if("/"===g)return osc.readMessageContents(f,e,b,c);throw new Error("The header of an OSC packet didn't contain an OSC address or a #bundle string. Header was: "+f)},osc.writePacket=function(a,b){var c=a.address?osc.writeMessage:osc.writeBundle;return c(a,b)},osc.argumentTypes={i:{reader:"readInt32",writer:"writeInt32"},f:{reader:"readFloat32",writer:"writeFloat32"},s:{reader:"readString",writer:"writeString"},S:{reader:"readString",writer:"writeString"},b:{reader:"readBlob",writer:"writeBlob"},t:{reader:"readTimeTag",writer:"writeTimeTag"},T:{reader:"readTrue"},F:{reader:"readFalse"},N:{reader:"readNull"},I:{reader:"readImpulse"},d:{reader:"readFloat64",writer:"writeFloat64"},c:{reader:"readChar32",writer:"writeChar32"},r:{reader:"readColor",writer:"writeColor"},m:{reader:"readMIDIBytes",writer:"writeMIDIBytes"}},osc.inferTypeForArgument=function(a){var b=typeof a;switch(b){case"boolean":return a?"T":"F";case"string":return"s";case"number":return"f";case"undefined":return"N";case"object":if(null===a)return"N";if(a instanceof Uint8Array||a instanceof ArrayBuffer||osc.isBufferEnv&&a instanceof Buffer)return"b"}throw new Error("Can't infer OSC argument type for value: "+JSON.stringify(a,null,2))},osc.annotateArguments=function(a){osc.isArray(a)||(a=[a]);for(var b=[],c=0;c<a.length;c++){var d,e=a[c];if("object"==typeof e&&e.type&&void 0!==e.value)d=e;else{var f=osc.inferTypeForArgument(e);d={type:f,value:e}}b.push(d)}return b},"undefined"!=typeof module&&module.exports&&(osc.isBufferEnv&&(a=require("buffer-dataview")),module.exports=osc)}(),function(a,b){"use strict";"object"==typeof exports?(a.slip=exports,b(exports)):"function"==typeof define&&define.amd?define(["exports"],function(c){return a.slip=c,a.slip,b(c)}):(a.slip={},b(a.slip))}(this,function(a){"use strict";var b=a;b.END=192,b.ESC=219,b.ESC_END=220,b.ESC_ESC=221,b.byteArray=function(a,b,c){return a instanceof ArrayBuffer?new Uint8Array(a,b,c):a},b.expandByteArray=function(a){var b=new Uint8Array(2*a.length);return b.set(a),b},b.sliceByteArray=function(a,b,c){var d=a.buffer.slice?a.buffer.slice(b,c):a.subarray(b,c);return new Uint8Array(d)},b.encode=function(a,c){c=c||{},c.bufferPadding=c.bufferPadding||4,a=b.byteArray(a,c.offset,c.byteLength);var d=a.length+c.bufferPadding+3&-4,e=new Uint8Array(d),f=1;e[0]=b.END;for(var g=0;g<a.length;g++){f>e.length-3&&(e=b.expandByteArray(e));var h=a[g];h===b.END?(e[f++]=b.ESC,h=b.ESC_END):h===b.ESC&&(e[f++]=b.ESC,h=b.ESC_ESC),e[f++]=h}return e[f]=b.END,b.sliceByteArray(e,0,f+1)},b.Decoder=function(a){a="function"!=typeof a?a||{}:{onMessage:a},this.maxMessageSize=a.maxMessageSize||10485760,this.bufferSize=a.bufferSize||1024,this.msgBuffer=new Uint8Array(this.bufferSize),this.msgBufferIdx=0,this.onMessage=a.onMessage,this.onError=a.onError,this.escape=!1};var c=b.Decoder.prototype;return c.decode=function(a){a=b.byteArray(a);for(var c,d=0;d<a.length;d++){var e=a[d];if(this.escape)e===b.ESC_ESC?e=b.ESC:e===b.ESC_END&&(e=b.END);else{if(e===b.ESC){this.escape=!0;continue}if(e===b.END){c=this.handleEnd();continue}}var f=this.addByte(e);f||this.handleMessageMaxError()}return c},c.handleMessageMaxError=function(){this.onError&&this.onError(this.msgBuffer.subarray(0),"The message is too large; the maximum message size is "+this.maxMessageSize/1024+"KB. Use a larger maxMessageSize if necessary."),this.msgBufferIdx=0,this.escape=!1},c.addByte=function(a){return this.msgBufferIdx>this.msgBuffer.length-1&&(this.msgBuffer=b.expandByteArray(this.msgBuffer)),this.msgBuffer[this.msgBufferIdx++]=a,this.escape=!1,this.msgBuffer.length<this.maxMessageSize},c.handleEnd=function(){if(0!==this.msgBufferIdx){var a=b.sliceByteArray(this.msgBuffer,0,this.msgBufferIdx);return this.onMessage&&this.onMessage(a),this.msgBufferIdx=0,a}},b}),function(){"use strict";function a(){}function b(a,b){for(var c=a.length;c--;)if(a[c].listener===b)return c;return-1}function c(a){return function(){return this[a].apply(this,arguments)}}var d=a.prototype,e=this,f=e.EventEmitter;d.getListeners=function(a){var b,c,d=this._getEvents();if(a instanceof RegExp){b={};for(c in d)d.hasOwnProperty(c)&&a.test(c)&&(b[c]=d[c])}else b=d[a]||(d[a]=[]);return b},d.flattenListeners=function(a){var b,c=[];for(b=0;b<a.length;b+=1)c.push(a[b].listener);return c},d.getListenersAsObject=function(a){var b,c=this.getListeners(a);return c instanceof Array&&(b={},b[a]=c),b||c},d.addListener=function(a,c){var d,e=this.getListenersAsObject(a),f="object"==typeof c;for(d in e)e.hasOwnProperty(d)&&-1===b(e[d],c)&&e[d].push(f?c:{listener:c,once:!1});return this},d.on=c("addListener"),d.addOnceListener=function(a,b){return this.addListener(a,{listener:b,once:!0})},d.once=c("addOnceListener"),d.defineEvent=function(a){return this.getListeners(a),this},d.defineEvents=function(a){for(var b=0;b<a.length;b+=1)this.defineEvent(a[b]);return this},d.removeListener=function(a,c){var d,e,f=this.getListenersAsObject(a);for(e in f)f.hasOwnProperty(e)&&(d=b(f[e],c),-1!==d&&f[e].splice(d,1));return this},d.off=c("removeListener"),d.addListeners=function(a,b){return this.manipulateListeners(!1,a,b)},d.removeListeners=function(a,b){return this.manipulateListeners(!0,a,b)},d.manipulateListeners=function(a,b,c){var d,e,f=a?this.removeListener:this.addListener,g=a?this.removeListeners:this.addListeners;if("object"!=typeof b||b instanceof RegExp)for(d=c.length;d--;)f.call(this,b,c[d]);else for(d in b)b.hasOwnProperty(d)&&(e=b[d])&&("function"==typeof e?f.call(this,d,e):g.call(this,d,e));return this},d.removeEvent=function(a){var b,c=typeof a,d=this._getEvents();if("string"===c)delete d[a];else if(a instanceof RegExp)for(b in d)d.hasOwnProperty(b)&&a.test(b)&&delete d[b];else delete this._events;return this},d.removeAllListeners=c("removeEvent"),d.emitEvent=function(a,b){var c,d,e,f,g=this.getListenersAsObject(a);for(e in g)if(g.hasOwnProperty(e))for(d=g[e].length;d--;)c=g[e][d],c.once===!0&&this.removeListener(a,c.listener),f=c.listener.apply(this,b||[]),f===this._getOnceReturnValue()&&this.removeListener(a,c.listener);return this},d.trigger=c("emitEvent"),d.emit=function(a){var b=Array.prototype.slice.call(arguments,1);return this.emitEvent(a,b)},d.setOnceReturnValue=function(a){return this._onceReturnValue=a,this},d._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},d._getEvents=function(){return this._events||(this._events={})},a.noConflict=function(){return e.EventEmitter=f,a},"function"==typeof define&&define.amd?define(function(){return a}):"object"==typeof module&&module.exports?module.exports=a:e.EventEmitter=a}.call(this);var osc=osc||require("./osc.js"),slip=slip||require("slip"),EventEmitter=EventEmitter||require("events").EventEmitter;!function(){"use strict";osc.firePacketEvents=function(a,b,c){b.address?a.emit("message",b,c):osc.fireBundleEvents(a,b,c)},osc.fireBundleEvents=function(a,b,c){a.emit("bundle",b,c);for(var d=0;d<b.packets.length;d++){var e=b.packets[d];osc.firePacketEvents(a,e,b.timeTag)}},osc.Port=function(a){this.options=a||{},this.on("data",this.decodeOSC.bind(this))};var a=osc.Port.prototype=Object.create(EventEmitter.prototype);a.constructor=osc.Port,a.send=function(a){var b=Array.prototype.slice.call(arguments),c=this.encodeOSC(a);b[0]=c,this.sendRaw.apply(this,b)},a.encodeOSC=function(a){a=a.buffer?a.buffer:a;var b=osc.writePacket(a,this.options);return b},a.decodeOSC=function(a){this.emit("raw",a);var b=osc.readPacket(a,this.options);this.emit("osc",b),osc.firePacketEvents(this,b)},osc.SLIPPort=function(a){var b=this,c=this.options=a||{};c.useSLIP=void 0===c.useSLIP?!0:c.useSLIP,this.decoder=new slip.Decoder({onMessage:this.decodeOSC.bind(this),onError:function(a){b.emit("error",a)}});var d=c.useSLIP?this.decodeSLIPData:this.decodeOSC;this.on("data",d.bind(this))},a=osc.SLIPPort.prototype=Object.create(osc.Port.prototype),a.constructor=osc.SLIPPort,a.encodeOSC=function(a){a=a.buffer?a.buffer:a;var b=osc.writePacket(a,this.options);return slip.encode(b)},a.decodeSLIPData=function(a){this.decoder.decode(a)},osc.relay=function(a,b,c,d,e,f){c=c||"message",d=d||"send",e=e||function(){},f=f?[null].concat(f):[];var g=function(a){f[0]=a,a=e(a),b[d].apply(b,f)};return a.on(c,g),{eventName:c,listener:g}},osc.relayPorts=function(a,b,c){var d=c.raw?"raw":"osc",e=c.raw?"sendRaw":"send";return osc.relay(a,b,d,e,c.transform)},osc.stopRelaying=function(a,b){a.removeListener(b.eventName,b.listener)},osc.Relay=function(a,b,c){var d=this.options=c||{};d.raw=!1,this.port1=a,this.port2=b,this.listen()},a=osc.Relay.prototype,a.open=function(){this.port1.open(),this.port2.open()},a.listen=function(){this.port1Spec&&this.port2Spec&&this.close(),this.port1Spec=osc.relayPorts(this.port1,this.port2,this.options),this.port2Spec=osc.relayPorts(this.port2,this.port1,this.options)},a.close=function(){osc.stopRelaying(this.port1,this.port1Spec),osc.stopRelaying(this.port2,this.port2Spec)},"undefined"!=typeof module&&module.exports&&(module.exports=osc)}();var osc=osc;!function(){"use strict";osc.WebSocketPort=function(a){osc.Port.call(this,a),this.on("open",this.listen.bind(this))};var a=osc.WebSocketPort.prototype=Object.create(osc.Port.prototype);a.constructor=osc.WebSocketPort,a.open=function(){this.socket=new WebSocket(this.options.url),this.socket.binaryType="arraybuffer";var a=this;this.socket.onopen=function(){a.emit("open",a.socket)}},a.listen=function(){var a=this;this.socket.onmessage=function(b){a.emit("data",b.data)},this.socket.onerror=function(b){a.emit("error",b)},this.socket.onclose=function(b){a.emit("close",b)},a.emit("ready")},a.sendRaw=function(a){this.socket&&this.socket.send(a.buffer)},a.close=function(a,b){this.socket.close(a,b)}}();var osc=osc||{};!function(){"use strict";osc.listenToTransport=function(a,b,c){b.onReceive.addListener(function(b){b[c]===a[c]&&a.emit("data",b.data)}),b.onReceiveError.addListener(function(b){a.emit("error",b)}),a.emit("ready")},osc.emitNetworkError=function(a,b){a.emit("error","There was an error while opening the UDP socket connection. Result code: "+b)},osc.SerialPort=function(a){this.on("open",this.listen.bind(this)),osc.SLIPPort.call(this,a)};var a=osc.SerialPort.prototype=Object.create(osc.SLIPPort.prototype);a.constructor=osc.SerialPort,a.open=function(){var a=this,b={bitrate:a.options.bitrate};chrome.serial.connect(this.options.devicePath,b,function(b){a.connectionId=b.connectionId,a.emit("open",b)})},a.listen=function(){osc.listenToTransport(this,chrome.serial,"connectionId")},a.sendRaw=function(a){if(this.connectionId){var b=this;chrome.serial.send(this.connectionId,a.buffer,function(a,c){c&&b.emit("error",c+". Total bytes sent: "+a)})}},a.close=function(){if(this.connectionId){var a=this;chrome.serial.disconnect(this.connectionId,function(b){b&&a.emit("close")})}},osc.UDPPort=function(a){osc.Port.call(this,a);var b=this.options;b.localAddress=b.localAddress||"127.0.0.1",b.localPort=void 0!==b.localPort?b.localPort:57121,this.on("open",this.listen.bind(this))},a=osc.UDPPort.prototype=Object.create(osc.Port.prototype),a.constructor=osc.UDPPort,a.open=function(){var a=this.options,b={persistent:a.persistent,name:a.name,bufferSize:a.bufferSize},c=this;chrome.sockets.udp.create(b,function(a){c.socketId=a.socketId,c.bindSocket()})},a.bindSocket=function(){var a=this,b=this.options;chrome.sockets.udp.bind(this.socketId,b.localAddress,b.localPort,function(b){return b>0?void osc.emitNetworkError(a,b):void a.emit("open",b)})},a.listen=function(){osc.listenToTransport(this,chrome.sockets.udp,"socketId")},a.sendRaw=function(a,b,c){if(this.socketId){var d=this.options,e=this;b=b||d.remoteAddress,c=void 0!==c?c:d.remotePort,chrome.sockets.udp.send(this.socketId,a.buffer,b,c,function(a){a||e.emit("error","There was an unknown error while trying to send a UDP message. Have you declared the appropriate udp send permissions in your application's manifest file?"),a.resultCode>0&&osc.emitNetworkError(e,a.resultCode)})}},a.close=function(){if(this.socketId){var a=this;chrome.sockets.udp.close(this.socketId,function(){a.emit("close")})}}}();
var osc=osc||{};!function(){"use strict";var a;osc.SECS_70YRS=2208988800,osc.TWO_32=4294967296,osc.defaults={metadata:!1,unpackSingleArgs:!0},osc.isBufferEnv="undefined"!=typeof Buffer,osc.isArray=function(a){return a&&"[object Array]"===Object.prototype.toString.call(a)},osc.isTypedArrayView=function(a){return a.buffer&&a.buffer instanceof ArrayBuffer},osc.isBuffer=function(a){return osc.isBufferEnv&&a instanceof Buffer},osc.dataView=function(b){return b instanceof DataView?b:"undefined"!=typeof a&&b instanceof a?b:osc.isBufferEnv&&b instanceof Buffer?new a(b):b.buffer?new DataView(b.buffer):b instanceof ArrayBuffer?new DataView(b):new DataView(new Uint8Array(b))},osc.byteArray=function(a){if(a instanceof Uint8Array)return a;var b=a.buffer?a.buffer:a;if("undefined"==typeof a.length||"string"==typeof a)throw new Error("Can't wrap a non-array-like object as Uint8Array. Object was: "+JSON.stringify(a,null,2));return new Uint8Array(b)},osc.makeByteArray=function(a){return osc.isBufferEnv?new Buffer(a):new Uint8Array(a)},osc.copyByteArray=function(a,b,c){if(osc.isTypedArrayView(a)&&osc.isTypedArrayView(b))b.set(a,c);else if(osc.isBuffer(a)&&osc.isBuffer(b))a.copy(b,c);else for(var d=void 0===c?0:c,e=Math.min(b.length-c,a.length),f=0,g=d;e>f;f++,g++)b[g]=a[f];return b},osc.readString=function(a,b){for(var c=[],d=b.idx;d<a.byteLength;d++){var e=a.getUint8(d);if(0===e){d++;break}c.push(e)}return d=d+3&-4,b.idx=d,String.fromCharCode.apply(null,c)},osc.writeString=function(a){for(var b=a+"\x00",c=b.length,d=c+3&-4,e=new Uint8Array(d),f=0;f<b.length;f++){var g=b.charCodeAt(f);e[f]=g}return e},osc.readPrimitive=function(a,b,c,d){var e=a[b](d.idx,!1);return d.idx+=c,e},osc.writePrimitive=function(a,b,c,d,e){e=void 0===e?0:e;var f;return b?f=new Uint8Array(b.buffer):(f=new Uint8Array(d),b=new DataView(f.buffer)),b[c](e,a,!1),f},osc.readInt32=function(a,b){return osc.readPrimitive(a,"getInt32",4,b)},osc.writeInt32=function(a,b,c){return osc.writePrimitive(a,b,"setInt32",4,c)},osc.readFloat32=function(a,b){return osc.readPrimitive(a,"getFloat32",4,b)},osc.writeFloat32=function(a,b,c){return osc.writePrimitive(a,b,"setFloat32",4,c)},osc.readFloat64=function(a,b){return osc.readPrimitive(a,"getFloat64",8,b)},osc.writeFloat64=function(a,b,c){return osc.writePrimitive(a,b,"setFloat64",8,c)},osc.readChar32=function(a,b){var c=osc.readPrimitive(a,"getUint32",4,b);return String.fromCharCode(c)},osc.writeChar32=function(a,b,c){var d=a.charCodeAt(0);return void 0===d||-1>d?void 0:osc.writePrimitive(d,b,"setUint32",4,c)},osc.readBlob=function(a,b){var c=osc.readInt32(a,b),d=c+3&-4,e=new Uint8Array(a.buffer,b.idx,c);return b.idx+=d,e},osc.writeBlob=function(a){a=osc.byteArray(a);var b=a.byteLength,c=b+3&-4,d=4,e=c+d,f=new Uint8Array(e),g=new DataView(f.buffer);return osc.writeInt32(b,g),f.set(a,d),f},osc.readMIDIBytes=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4);return b.idx+=4,c},osc.writeMIDIBytes=function(a){a=osc.byteArray(a);var b=new Uint8Array(4);return b.set(a),b},osc.readColor=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4),d=c[3]/255;return b.idx+=4,{r:c[0],g:c[1],b:c[2],a:d}},osc.writeColor=function(a){var b=Math.round(255*a.a),c=new Uint8Array([a.r,a.g,a.b,b]);return c},osc.readTrue=function(){return!0},osc.readFalse=function(){return!1},osc.readNull=function(){return null},osc.readImpulse=function(){return 1},osc.readTimeTag=function(a,b){var c=osc.readPrimitive(a,"getUint32",4,b),d=osc.readPrimitive(a,"getUint32",4,b),e=0===c&&1===d?Date.now():osc.ntpToJSTime(c,d);return{raw:[c,d],"native":e}},osc.writeTimeTag=function(a){var b=a.raw?a.raw:osc.jsToNTPTime(a["native"]),c=new Uint8Array(8),d=new DataView(c.buffer);return osc.writeInt32(b[0],d,0),osc.writeInt32(b[1],d,4),c},osc.timeTag=function(a){a=a||0;var b=Date.now()/1e3,c=Math.floor(b),d=b-c,e=Math.floor(a),f=a-e,g=d+f;if(g>1){var h=Math.floor(g),i=g-h;e+=h,g=i}var j=c+e+osc.SECS_70YRS,k=Math.round(osc.TWO_32*g);return{raw:[j,k]}},osc.ntpToJSTime=function(a,b){var c=a-osc.SECS_70YRS,d=b/osc.TWO_32,e=1e3*(c+d);return e},osc.jsToNTPTime=function(a){var b=a/1e3,c=Math.floor(b),d=b-c,e=c+osc.SECS_70YRS,f=Math.round(osc.TWO_32*d);return[e,f]},osc.readArguments=function(a,b,c){var d=osc.readString(a,c);if(0!==d.indexOf(","))throw new Error("A malformed type tag string was found while reading the arguments of an OSC message. String was: "+d," at offset: "+c.idx);var e=d.substring(1).split(""),f=[];return osc.readArgumentsIntoArray(f,e,d,a,b,c),f},osc.readArgument=function(a,b,c,d,e){var f=osc.argumentTypes[a];if(!f)throw new Error("'"+a+"' is not a valid OSC type tag. Type tag string was: "+b);var g=f.reader,h=osc[g](c,e);return d.metadata&&(h={type:a,value:h}),h},osc.readArgumentsIntoArray=function(a,b,c,d,e,f){for(var g=0;g<b.length;){var h,i=b[g];if("["===i){var j=b.slice(g+1),k=j.indexOf("]");if(0>k)throw new Error("Invalid argument type tag: an open array type tag ('[') was found without a matching close array tag ('[]'). Type tag was: "+c);var l=j.slice(0,k);h=osc.readArgumentsIntoArray([],l,c,d,e,f),g+=k+2}else h=osc.readArgument(i,c,d,e,f),g++;a.push(h)}return a},osc.writeArguments=function(a,b){var c=osc.collectArguments(a,b);return osc.joinParts(c)},osc.joinParts=function(a){for(var b=osc.makeByteArray(a.byteLength),c=a.parts,d=0,e=0;e<c.length;e++){var f=c[e];osc.copyByteArray(f,b,d),d+=f.length}return b},osc.addDataPart=function(a,b){b.parts.push(a),b.byteLength+=a.length},osc.collectArguments=function(a,b,c){osc.isArray(a)||(a=[a]),c=c||{byteLength:0,parts:[]},b.metadata||(a=osc.annotateArguments(a));for(var d=",",e=c.parts.length,f=0;f<a.length;f++){var g=a[f],h=g.type,i=osc.argumentTypes[h].writer;if(d+=g.type,i){var j=osc[i](g.value);osc.addDataPart(j,c)}}var k=osc.writeString(d);return c.byteLength+=k.byteLength,c.parts.splice(e,0,k),c},osc.readMessage=function(a,b,c){b=b||osc.defaults;var d=osc.dataView(a);c=c||{idx:0};var e=osc.readString(d,c);return osc.readMessageContents(e,d,b,c)},osc.readMessageContents=function(a,b,c,d){if(0!==a.indexOf("/"))throw new Error("A malformed OSC address was found while reading an OSC message. String was: "+a);var e=osc.readArguments(b,c,d);return{address:a,args:1===e.length&&c.unpackSingleArgs?e[0]:e}},osc.collectMessageParts=function(a,b,c){return c=c||{byteLength:0,parts:[]},osc.addDataPart(osc.writeString(a.address),c),osc.collectArguments(a.args,b,c)},osc.writeMessage=function(a,b){b=b||osc.defaults;var c=osc.collectMessageParts(a,b);return osc.joinParts(c)},osc.readBundle=function(a,b,c){return osc.readPacket(a,b,c)},osc.collectBundlePackets=function(a,b,c){c=c||{byteLength:0,parts:[]},osc.addDataPart(osc.writeString("#bundle"),c),osc.addDataPart(osc.writeTimeTag(a.timeTag),c);for(var d=0;d<a.packets.length;d++){var e=a.packets[d],f=e.address?osc.collectMessageParts:osc.collectBundlePackets,g=f(e,b);c.byteLength+=g.byteLength,osc.addDataPart(osc.writeInt32(g.byteLength),c),c.parts=c.parts.concat(g.parts)}return c},osc.writeBundle=function(a,b){if(a.timeTag&&a.packets){b=b||osc.defaults;var c=osc.collectBundlePackets(a,b);return osc.joinParts(c)}},osc.readBundleContents=function(a,b,c,d){for(var e=osc.readTimeTag(a,c),f=[];c.idx<d;){var g=osc.readInt32(a,c),h=c.idx+g,i=osc.readPacket(a,b,c,h);f.push(i)}return{timeTag:e,packets:f}},osc.readPacket=function(a,b,c,d){var e=osc.dataView(a);d=void 0===d?e.byteLength:d,c=c||{idx:0};var f=osc.readString(e,c),g=f[0];if("#"===g)return osc.readBundleContents(e,b,c,d);if("/"===g)return osc.readMessageContents(f,e,b,c);throw new Error("The header of an OSC packet didn't contain an OSC address or a #bundle string. Header was: "+f)},osc.writePacket=function(a,b){var c=a.address?osc.writeMessage:osc.writeBundle;return c(a,b)},osc.argumentTypes={i:{reader:"readInt32",writer:"writeInt32"},f:{reader:"readFloat32",writer:"writeFloat32"},s:{reader:"readString",writer:"writeString"},S:{reader:"readString",writer:"writeString"},b:{reader:"readBlob",writer:"writeBlob"},t:{reader:"readTimeTag",writer:"writeTimeTag"},T:{reader:"readTrue"},F:{reader:"readFalse"},N:{reader:"readNull"},I:{reader:"readImpulse"},d:{reader:"readFloat64",writer:"writeFloat64"},c:{reader:"readChar32",writer:"writeChar32"},r:{reader:"readColor",writer:"writeColor"},m:{reader:"readMIDIBytes",writer:"writeMIDIBytes"}},osc.inferTypeForArgument=function(a){var b=typeof a;switch(b){case"boolean":return a?"T":"F";case"string":return"s";case"number":return"f";case"undefined":return"N";case"object":if(null===a)return"N";if(a instanceof Uint8Array||a instanceof ArrayBuffer||osc.isBufferEnv&&a instanceof Buffer)return"b"}throw new Error("Can't infer OSC argument type for value: "+JSON.stringify(a,null,2))},osc.annotateArguments=function(a){osc.isArray(a)||(a=[a]);for(var b=[],c=0;c<a.length;c++){var d,e=a[c];if("object"==typeof e&&e.type&&void 0!==e.value)d=e;else{var f=osc.inferTypeForArgument(e);d={type:f,value:e}}b.push(d)}return b},"undefined"!=typeof module&&module.exports&&(osc.isBufferEnv&&(a=require("buffer-dataview")),module.exports=osc)}(),function(a,b){"use strict";"object"==typeof exports?(a.slip=exports,b(exports)):"function"==typeof define&&define.amd?define(["exports"],function(c){return a.slip=c,a.slip,b(c)}):(a.slip={},b(a.slip))}(this,function(a){"use strict";var b=a;b.END=192,b.ESC=219,b.ESC_END=220,b.ESC_ESC=221,b.byteArray=function(a,b,c){return a instanceof ArrayBuffer?new Uint8Array(a,b,c):a},b.expandByteArray=function(a){var b=new Uint8Array(2*a.length);return b.set(a),b},b.sliceByteArray=function(a,b,c){var d=a.buffer.slice?a.buffer.slice(b,c):a.subarray(b,c);return new Uint8Array(d)},b.encode=function(a,c){c=c||{},c.bufferPadding=c.bufferPadding||4,a=b.byteArray(a,c.offset,c.byteLength);var d=a.length+c.bufferPadding+3&-4,e=new Uint8Array(d),f=1;e[0]=b.END;for(var g=0;g<a.length;g++){f>e.length-3&&(e=b.expandByteArray(e));var h=a[g];h===b.END?(e[f++]=b.ESC,h=b.ESC_END):h===b.ESC&&(e[f++]=b.ESC,h=b.ESC_ESC),e[f++]=h}return e[f]=b.END,b.sliceByteArray(e,0,f+1)},b.Decoder=function(a){a="function"!=typeof a?a||{}:{onMessage:a},this.maxMessageSize=a.maxMessageSize||10485760,this.bufferSize=a.bufferSize||1024,this.msgBuffer=new Uint8Array(this.bufferSize),this.msgBufferIdx=0,this.onMessage=a.onMessage,this.onError=a.onError,this.escape=!1};var c=b.Decoder.prototype;return c.decode=function(a){a=b.byteArray(a);for(var c,d=0;d<a.length;d++){var e=a[d];if(this.escape)e===b.ESC_ESC?e=b.ESC:e===b.ESC_END&&(e=b.END);else{if(e===b.ESC){this.escape=!0;continue}if(e===b.END){c=this.handleEnd();continue}}var f=this.addByte(e);f||this.handleMessageMaxError()}return c},c.handleMessageMaxError=function(){this.onError&&this.onError(this.msgBuffer.subarray(0),"The message is too large; the maximum message size is "+this.maxMessageSize/1024+"KB. Use a larger maxMessageSize if necessary."),this.msgBufferIdx=0,this.escape=!1},c.addByte=function(a){return this.msgBufferIdx>this.msgBuffer.length-1&&(this.msgBuffer=b.expandByteArray(this.msgBuffer)),this.msgBuffer[this.msgBufferIdx++]=a,this.escape=!1,this.msgBuffer.length<this.maxMessageSize},c.handleEnd=function(){if(0!==this.msgBufferIdx){var a=b.sliceByteArray(this.msgBuffer,0,this.msgBufferIdx);return this.onMessage&&this.onMessage(a),this.msgBufferIdx=0,a}},b}),function(){"use strict";function a(){}function b(a,b){for(var c=a.length;c--;)if(a[c].listener===b)return c;return-1}function c(a){return function(){return this[a].apply(this,arguments)}}var d=a.prototype,e=this,f=e.EventEmitter;d.getListeners=function(a){var b,c,d=this._getEvents();if(a instanceof RegExp){b={};for(c in d)d.hasOwnProperty(c)&&a.test(c)&&(b[c]=d[c])}else b=d[a]||(d[a]=[]);return b},d.flattenListeners=function(a){var b,c=[];for(b=0;b<a.length;b+=1)c.push(a[b].listener);return c},d.getListenersAsObject=function(a){var b,c=this.getListeners(a);return c instanceof Array&&(b={},b[a]=c),b||c},d.addListener=function(a,c){var d,e=this.getListenersAsObject(a),f="object"==typeof c;for(d in e)e.hasOwnProperty(d)&&-1===b(e[d],c)&&e[d].push(f?c:{listener:c,once:!1});return this},d.on=c("addListener"),d.addOnceListener=function(a,b){return this.addListener(a,{listener:b,once:!0})},d.once=c("addOnceListener"),d.defineEvent=function(a){return this.getListeners(a),this},d.defineEvents=function(a){for(var b=0;b<a.length;b+=1)this.defineEvent(a[b]);return this},d.removeListener=function(a,c){var d,e,f=this.getListenersAsObject(a);for(e in f)f.hasOwnProperty(e)&&(d=b(f[e],c),-1!==d&&f[e].splice(d,1));return this},d.off=c("removeListener"),d.addListeners=function(a,b){return this.manipulateListeners(!1,a,b)},d.removeListeners=function(a,b){return this.manipulateListeners(!0,a,b)},d.manipulateListeners=function(a,b,c){var d,e,f=a?this.removeListener:this.addListener,g=a?this.removeListeners:this.addListeners;if("object"!=typeof b||b instanceof RegExp)for(d=c.length;d--;)f.call(this,b,c[d]);else for(d in b)b.hasOwnProperty(d)&&(e=b[d])&&("function"==typeof e?f.call(this,d,e):g.call(this,d,e));return this},d.removeEvent=function(a){var b,c=typeof a,d=this._getEvents();if("string"===c)delete d[a];else if(a instanceof RegExp)for(b in d)d.hasOwnProperty(b)&&a.test(b)&&delete d[b];else delete this._events;return this},d.removeAllListeners=c("removeEvent"),d.emitEvent=function(a,b){var c,d,e,f,g=this.getListenersAsObject(a);for(e in g)if(g.hasOwnProperty(e))for(d=g[e].length;d--;)c=g[e][d],c.once===!0&&this.removeListener(a,c.listener),f=c.listener.apply(this,b||[]),f===this._getOnceReturnValue()&&this.removeListener(a,c.listener);return this},d.trigger=c("emitEvent"),d.emit=function(a){var b=Array.prototype.slice.call(arguments,1);return this.emitEvent(a,b)},d.setOnceReturnValue=function(a){return this._onceReturnValue=a,this},d._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},d._getEvents=function(){return this._events||(this._events={})},a.noConflict=function(){return e.EventEmitter=f,a},"function"==typeof define&&define.amd?define(function(){return a}):"object"==typeof module&&module.exports?module.exports=a:e.EventEmitter=a}.call(this);var osc=osc||require("./osc.js"),slip=slip||require("slip"),EventEmitter=EventEmitter||require("events").EventEmitter;!function(){"use strict";osc.firePacketEvents=function(a,b,c){b.address?a.emit("message",b,c):osc.fireBundleEvents(a,b,c)},osc.fireBundleEvents=function(a,b,c){a.emit("bundle",b,c);for(var d=0;d<b.packets.length;d++){var e=b.packets[d];osc.firePacketEvents(a,e,b.timeTag)}},osc.Port=function(a){this.options=a||{},this.on("data",this.decodeOSC.bind(this))};var a=osc.Port.prototype=Object.create(EventEmitter.prototype);a.constructor=osc.Port,a.send=function(a){var b=Array.prototype.slice.call(arguments),c=this.encodeOSC(a);b[0]=c,this.sendRaw.apply(this,b)},a.encodeOSC=function(a){a=a.buffer?a.buffer:a;var b=osc.writePacket(a,this.options);return b},a.decodeOSC=function(a){this.emit("raw",a);var b=osc.readPacket(a,this.options);this.emit("osc",b),osc.firePacketEvents(this,b)},osc.SLIPPort=function(a){var b=this,c=this.options=a||{};c.useSLIP=void 0===c.useSLIP?!0:c.useSLIP,this.decoder=new slip.Decoder({onMessage:this.decodeOSC.bind(this),onError:function(a){b.emit("error",a)}});var d=c.useSLIP?this.decodeSLIPData:this.decodeOSC;this.on("data",d.bind(this))},a=osc.SLIPPort.prototype=Object.create(osc.Port.prototype),a.constructor=osc.SLIPPort,a.encodeOSC=function(a){a=a.buffer?a.buffer:a;var b=osc.writePacket(a,this.options);return slip.encode(b)},a.decodeSLIPData=function(a){this.decoder.decode(a)},osc.relay=function(a,b,c,d,e,f){c=c||"message",d=d||"send",e=e||function(){},f=f?[null].concat(f):[];var g=function(a){f[0]=a,a=e(a),b[d].apply(b,f)};return a.on(c,g),{eventName:c,listener:g}},osc.relayPorts=function(a,b,c){var d=c.raw?"raw":"osc",e=c.raw?"sendRaw":"send";return osc.relay(a,b,d,e,c.transform)},osc.stopRelaying=function(a,b){a.removeListener(b.eventName,b.listener)},osc.Relay=function(a,b,c){var d=this.options=c||{};d.raw=!1,this.port1=a,this.port2=b,this.listen()},a=osc.Relay.prototype=Object.create(EventEmitter.prototype),a.constructor=osc.Relay,a.open=function(){this.port1.open(),this.port2.open()},a.listen=function(){this.port1Spec&&this.port2Spec&&this.close(),this.port1Spec=osc.relayPorts(this.port1,this.port2,this.options),this.port2Spec=osc.relayPorts(this.port2,this.port1,this.options);var a=this.close.bind(this);this.port1.on("close",a),this.port2.on("close",a)},a.close=function(){osc.stopRelaying(this.port1,this.port1Spec),osc.stopRelaying(this.port2,this.port2Spec),this.emit("close",this.port1,this.port2)},"undefined"!=typeof module&&module.exports&&(module.exports=osc)}();var osc=osc;!function(){"use strict";osc.WebSocketPort=function(a){osc.Port.call(this,a),this.on("open",this.listen.bind(this))};var a=osc.WebSocketPort.prototype=Object.create(osc.Port.prototype);a.constructor=osc.WebSocketPort,a.open=function(){this.socket=new WebSocket(this.options.url),this.socket.binaryType="arraybuffer";var a=this;this.socket.onopen=function(){a.emit("open",a.socket)}},a.listen=function(){var a=this;this.socket.onmessage=function(b){a.emit("data",b.data)},this.socket.onerror=function(b){a.emit("error",b)},this.socket.onclose=function(b){a.emit("close",b)},a.emit("ready")},a.sendRaw=function(a){this.socket&&this.socket.send(a.buffer)},a.close=function(a,b){this.socket.close(a,b)}}();var osc=osc||{};!function(){"use strict";osc.listenToTransport=function(a,b,c){b.onReceive.addListener(function(b){b[c]===a[c]&&a.emit("data",b.data)}),b.onReceiveError.addListener(function(b){a.emit("error",b)}),a.emit("ready")},osc.emitNetworkError=function(a,b){a.emit("error","There was an error while opening the UDP socket connection. Result code: "+b)},osc.SerialPort=function(a){this.on("open",this.listen.bind(this)),osc.SLIPPort.call(this,a)};var a=osc.SerialPort.prototype=Object.create(osc.SLIPPort.prototype);a.constructor=osc.SerialPort,a.open=function(){var a=this,b={bitrate:a.options.bitrate};chrome.serial.connect(this.options.devicePath,b,function(b){a.connectionId=b.connectionId,a.emit("open",b)})},a.listen=function(){osc.listenToTransport(this,chrome.serial,"connectionId")},a.sendRaw=function(a){if(this.connectionId){var b=this;chrome.serial.send(this.connectionId,a.buffer,function(a,c){c&&b.emit("error",c+". Total bytes sent: "+a)})}},a.close=function(){if(this.connectionId){var a=this;chrome.serial.disconnect(this.connectionId,function(b){b&&a.emit("close")})}},osc.UDPPort=function(a){osc.Port.call(this,a);var b=this.options;b.localAddress=b.localAddress||"127.0.0.1",b.localPort=void 0!==b.localPort?b.localPort:57121,this.on("open",this.listen.bind(this))},a=osc.UDPPort.prototype=Object.create(osc.Port.prototype),a.constructor=osc.UDPPort,a.open=function(){var a=this.options,b={persistent:a.persistent,name:a.name,bufferSize:a.bufferSize},c=this;chrome.sockets.udp.create(b,function(a){c.socketId=a.socketId,c.bindSocket()})},a.bindSocket=function(){var a=this,b=this.options;chrome.sockets.udp.bind(this.socketId,b.localAddress,b.localPort,function(b){return b>0?void osc.emitNetworkError(a,b):void a.emit("open",b)})},a.listen=function(){osc.listenToTransport(this,chrome.sockets.udp,"socketId")},a.sendRaw=function(a,b,c){if(this.socketId){var d=this.options,e=this;b=b||d.remoteAddress,c=void 0!==c?c:d.remotePort,chrome.sockets.udp.send(this.socketId,a.buffer,b,c,function(a){a||e.emit("error","There was an unknown error while trying to send a UDP message. Have you declared the appropriate udp send permissions in your application's manifest file?"),a.resultCode>0&&osc.emitNetworkError(e,a.resultCode)})}},a.close=function(){if(this.socketId){var a=this;chrome.sockets.udp.close(this.socketId,function(){a.emit("close")})}}}();

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

/*! osc.js 1.1.2, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */
/*! osc.js 1.1.4, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */

@@ -1122,3 +1122,2 @@ (function (root, factory) {

// Unsupported, non-API function.

@@ -1129,2 +1128,3 @@ osc.stopRelaying = function (from, relaySpec) {

/**

@@ -1149,3 +1149,4 @@ * A Relay connects two sources of OSC data together,

p = osc.Relay.prototype;
p = osc.Relay.prototype = Object.create(EventEmitter.prototype);
p.constructor = osc.Relay;

@@ -1164,2 +1165,10 @@ p.open = function () {

this.port2Spec = osc.relayPorts(this.port2, this.port1, this.options);
// Bind port close listeners to ensure that the relay
// will stop forwarding messages if one of its ports close.
// Users are still responsible for closing the underlying ports
// if necessary.
var closeListener = this.close.bind(this);
this.port1.on("close", closeListener);
this.port2.on("close", closeListener);
};

@@ -1170,2 +1179,3 @@

osc.stopRelaying(this.port2, this.port2Spec);
this.emit("close", this.port1, this.port2);
};

@@ -1172,0 +1182,0 @@

@@ -1,3 +0,3 @@

/*! osc.js 1.1.2, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */
/*! osc.js 1.1.4, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */
!function(a,b){"object"==typeof exports?(a.osc=exports,b(exports,require("slip"),require("EventEmitter"))):"function"==typeof define&&define.amd?define(["exports","slip","EventEmitter"],function(c,d,e){return a.osc=c,a.osc,b(c,d,e)}):(a.osc={},b(a.osc,slip,EventEmitter))}(this,function(a,b,c){var d=d||{};!function(){"use strict";var a;d.SECS_70YRS=2208988800,d.TWO_32=4294967296,d.defaults={metadata:!1,unpackSingleArgs:!0},d.isBufferEnv="undefined"!=typeof Buffer,d.isArray=function(a){return a&&"[object Array]"===Object.prototype.toString.call(a)},d.isTypedArrayView=function(a){return a.buffer&&a.buffer instanceof ArrayBuffer},d.isBuffer=function(a){return d.isBufferEnv&&a instanceof Buffer},d.dataView=function(b){return b instanceof DataView?b:"undefined"!=typeof a&&b instanceof a?b:d.isBufferEnv&&b instanceof Buffer?new a(b):b.buffer?new DataView(b.buffer):b instanceof ArrayBuffer?new DataView(b):new DataView(new Uint8Array(b))},d.byteArray=function(a){if(a instanceof Uint8Array)return a;var b=a.buffer?a.buffer:a;if("undefined"==typeof a.length||"string"==typeof a)throw new Error("Can't wrap a non-array-like object as Uint8Array. Object was: "+JSON.stringify(a,null,2));return new Uint8Array(b)},d.makeByteArray=function(a){return d.isBufferEnv?new Buffer(a):new Uint8Array(a)},d.copyByteArray=function(a,b,c){if(d.isTypedArrayView(a)&&d.isTypedArrayView(b))b.set(a,c);else if(d.isBuffer(a)&&d.isBuffer(b))a.copy(b,c);else for(var e=void 0===c?0:c,f=Math.min(b.length-c,a.length),g=0,h=e;f>g;g++,h++)b[h]=a[g];return b},d.readString=function(a,b){for(var c=[],d=b.idx;d<a.byteLength;d++){var e=a.getUint8(d);if(0===e){d++;break}c.push(e)}return d=d+3&-4,b.idx=d,String.fromCharCode.apply(null,c)},d.writeString=function(a){for(var b=a+"\x00",c=b.length,d=c+3&-4,e=new Uint8Array(d),f=0;f<b.length;f++){var g=b.charCodeAt(f);e[f]=g}return e},d.readPrimitive=function(a,b,c,d){var e=a[b](d.idx,!1);return d.idx+=c,e},d.writePrimitive=function(a,b,c,d,e){e=void 0===e?0:e;var f;return b?f=new Uint8Array(b.buffer):(f=new Uint8Array(d),b=new DataView(f.buffer)),b[c](e,a,!1),f},d.readInt32=function(a,b){return d.readPrimitive(a,"getInt32",4,b)},d.writeInt32=function(a,b,c){return d.writePrimitive(a,b,"setInt32",4,c)},d.readFloat32=function(a,b){return d.readPrimitive(a,"getFloat32",4,b)},d.writeFloat32=function(a,b,c){return d.writePrimitive(a,b,"setFloat32",4,c)},d.readFloat64=function(a,b){return d.readPrimitive(a,"getFloat64",8,b)},d.writeFloat64=function(a,b,c){return d.writePrimitive(a,b,"setFloat64",8,c)},d.readChar32=function(a,b){var c=d.readPrimitive(a,"getUint32",4,b);return String.fromCharCode(c)},d.writeChar32=function(a,b,c){var e=a.charCodeAt(0);return void 0===e||-1>e?void 0:d.writePrimitive(e,b,"setUint32",4,c)},d.readBlob=function(a,b){var c=d.readInt32(a,b),e=c+3&-4,f=new Uint8Array(a.buffer,b.idx,c);return b.idx+=e,f},d.writeBlob=function(a){a=d.byteArray(a);var b=a.byteLength,c=b+3&-4,e=4,f=c+e,g=new Uint8Array(f),h=new DataView(g.buffer);return d.writeInt32(b,h),g.set(a,e),g},d.readMIDIBytes=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4);return b.idx+=4,c},d.writeMIDIBytes=function(a){a=d.byteArray(a);var b=new Uint8Array(4);return b.set(a),b},d.readColor=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4),d=c[3]/255;return b.idx+=4,{r:c[0],g:c[1],b:c[2],a:d}},d.writeColor=function(a){var b=Math.round(255*a.a),c=new Uint8Array([a.r,a.g,a.b,b]);return c},d.readTrue=function(){return!0},d.readFalse=function(){return!1},d.readNull=function(){return null},d.readImpulse=function(){return 1},d.readTimeTag=function(a,b){var c=d.readPrimitive(a,"getUint32",4,b),e=d.readPrimitive(a,"getUint32",4,b),f=0===c&&1===e?Date.now():d.ntpToJSTime(c,e);return{raw:[c,e],"native":f}},d.writeTimeTag=function(a){var b=a.raw?a.raw:d.jsToNTPTime(a["native"]),c=new Uint8Array(8),e=new DataView(c.buffer);return d.writeInt32(b[0],e,0),d.writeInt32(b[1],e,4),c},d.timeTag=function(a){a=a||0;var b=Date.now()/1e3,c=Math.floor(b),e=b-c,f=Math.floor(a),g=a-f,h=e+g;if(h>1){var i=Math.floor(h),j=h-i;f+=i,h=j}var k=c+f+d.SECS_70YRS,l=Math.round(d.TWO_32*h);return{raw:[k,l]}},d.ntpToJSTime=function(a,b){var c=a-d.SECS_70YRS,e=b/d.TWO_32,f=1e3*(c+e);return f},d.jsToNTPTime=function(a){var b=a/1e3,c=Math.floor(b),e=b-c,f=c+d.SECS_70YRS,g=Math.round(d.TWO_32*e);return[f,g]},d.readArguments=function(a,b,c){var e=d.readString(a,c);if(0!==e.indexOf(","))throw new Error("A malformed type tag string was found while reading the arguments of an OSC message. String was: "+e," at offset: "+c.idx);var f=e.substring(1).split(""),g=[];return d.readArgumentsIntoArray(g,f,e,a,b,c),g},d.readArgument=function(a,b,c,e,f){var g=d.argumentTypes[a];if(!g)throw new Error("'"+a+"' is not a valid OSC type tag. Type tag string was: "+b);var h=g.reader,i=d[h](c,f);return e.metadata&&(i={type:a,value:i}),i},d.readArgumentsIntoArray=function(a,b,c,e,f,g){for(var h=0;h<b.length;){var i,j=b[h];if("["===j){var k=b.slice(h+1),l=k.indexOf("]");if(0>l)throw new Error("Invalid argument type tag: an open array type tag ('[') was found without a matching close array tag ('[]'). Type tag was: "+c);var m=k.slice(0,l);i=d.readArgumentsIntoArray([],m,c,e,f,g),h+=l+2}else i=d.readArgument(j,c,e,f,g),h++;a.push(i)}return a},d.writeArguments=function(a,b){var c=d.collectArguments(a,b);return d.joinParts(c)},d.joinParts=function(a){for(var b=d.makeByteArray(a.byteLength),c=a.parts,e=0,f=0;f<c.length;f++){var g=c[f];d.copyByteArray(g,b,e),e+=g.length}return b},d.addDataPart=function(a,b){b.parts.push(a),b.byteLength+=a.length},d.collectArguments=function(a,b,c){d.isArray(a)||(a=[a]),c=c||{byteLength:0,parts:[]},b.metadata||(a=d.annotateArguments(a));for(var e=",",f=c.parts.length,g=0;g<a.length;g++){var h=a[g],i=h.type,j=d.argumentTypes[i].writer;if(e+=h.type,j){var k=d[j](h.value);d.addDataPart(k,c)}}var l=d.writeString(e);return c.byteLength+=l.byteLength,c.parts.splice(f,0,l),c},d.readMessage=function(a,b,c){b=b||d.defaults;var e=d.dataView(a);c=c||{idx:0};var f=d.readString(e,c);return d.readMessageContents(f,e,b,c)},d.readMessageContents=function(a,b,c,e){if(0!==a.indexOf("/"))throw new Error("A malformed OSC address was found while reading an OSC message. String was: "+a);var f=d.readArguments(b,c,e);return{address:a,args:1===f.length&&c.unpackSingleArgs?f[0]:f}},d.collectMessageParts=function(a,b,c){return c=c||{byteLength:0,parts:[]},d.addDataPart(d.writeString(a.address),c),d.collectArguments(a.args,b,c)},d.writeMessage=function(a,b){b=b||d.defaults;var c=d.collectMessageParts(a,b);return d.joinParts(c)},d.readBundle=function(a,b,c){return d.readPacket(a,b,c)},d.collectBundlePackets=function(a,b,c){c=c||{byteLength:0,parts:[]},d.addDataPart(d.writeString("#bundle"),c),d.addDataPart(d.writeTimeTag(a.timeTag),c);for(var e=0;e<a.packets.length;e++){var f=a.packets[e],g=f.address?d.collectMessageParts:d.collectBundlePackets,h=g(f,b);c.byteLength+=h.byteLength,d.addDataPart(d.writeInt32(h.byteLength),c),c.parts=c.parts.concat(h.parts)}return c},d.writeBundle=function(a,b){if(a.timeTag&&a.packets){b=b||d.defaults;var c=d.collectBundlePackets(a,b);return d.joinParts(c)}},d.readBundleContents=function(a,b,c,e){for(var f=d.readTimeTag(a,c),g=[];c.idx<e;){var h=d.readInt32(a,c),i=c.idx+h,j=d.readPacket(a,b,c,i);g.push(j)}return{timeTag:f,packets:g}},d.readPacket=function(a,b,c,e){var f=d.dataView(a);e=void 0===e?f.byteLength:e,c=c||{idx:0};var g=d.readString(f,c),h=g[0];if("#"===h)return d.readBundleContents(f,b,c,e);if("/"===h)return d.readMessageContents(g,f,b,c);throw new Error("The header of an OSC packet didn't contain an OSC address or a #bundle string. Header was: "+g)},d.writePacket=function(a,b){var c=a.address?d.writeMessage:d.writeBundle;return c(a,b)},d.argumentTypes={i:{reader:"readInt32",writer:"writeInt32"},f:{reader:"readFloat32",writer:"writeFloat32"},s:{reader:"readString",writer:"writeString"},S:{reader:"readString",writer:"writeString"},b:{reader:"readBlob",writer:"writeBlob"},t:{reader:"readTimeTag",writer:"writeTimeTag"},T:{reader:"readTrue"},F:{reader:"readFalse"},N:{reader:"readNull"},I:{reader:"readImpulse"},d:{reader:"readFloat64",writer:"writeFloat64"},c:{reader:"readChar32",writer:"writeChar32"},r:{reader:"readColor",writer:"writeColor"},m:{reader:"readMIDIBytes",writer:"writeMIDIBytes"}},d.inferTypeForArgument=function(a){var b=typeof a;switch(b){case"boolean":return a?"T":"F";case"string":return"s";case"number":return"f";case"undefined":return"N";case"object":if(null===a)return"N";if(a instanceof Uint8Array||a instanceof ArrayBuffer||d.isBufferEnv&&a instanceof Buffer)return"b"}throw new Error("Can't infer OSC argument type for value: "+JSON.stringify(a,null,2))},d.annotateArguments=function(a){d.isArray(a)||(a=[a]);for(var b=[],c=0;c<a.length;c++){var e,f=a[c];if("object"==typeof f&&f.type&&void 0!==f.value)e=f;else{var g=d.inferTypeForArgument(f);e={type:g,value:f}}b.push(e)}return b},"undefined"!=typeof module&&module.exports&&(d.isBufferEnv&&(a=require("buffer-dataview")),module.exports=d)}();var d=d||require("./osc.js"),b=b||require("slip"),c=c||require("events").EventEmitter;!function(){"use strict";d.firePacketEvents=function(a,b,c){b.address?a.emit("message",b,c):d.fireBundleEvents(a,b,c)},d.fireBundleEvents=function(a,b,c){a.emit("bundle",b,c);for(var e=0;e<b.packets.length;e++){var f=b.packets[e];d.firePacketEvents(a,f,b.timeTag)}},d.Port=function(a){this.options=a||{},this.on("data",this.decodeOSC.bind(this))};var a=d.Port.prototype=Object.create(c.prototype);a.constructor=d.Port,a.send=function(a){var b=Array.prototype.slice.call(arguments),c=this.encodeOSC(a);b[0]=c,this.sendRaw.apply(this,b)},a.encodeOSC=function(a){a=a.buffer?a.buffer:a;var b=d.writePacket(a,this.options);return b},a.decodeOSC=function(a){this.emit("raw",a);var b=d.readPacket(a,this.options);this.emit("osc",b),d.firePacketEvents(this,b)},d.SLIPPort=function(a){var c=this,d=this.options=a||{};d.useSLIP=void 0===d.useSLIP?!0:d.useSLIP,this.decoder=new b.Decoder({onMessage:this.decodeOSC.bind(this),onError:function(a){c.emit("error",a)}});var e=d.useSLIP?this.decodeSLIPData:this.decodeOSC;this.on("data",e.bind(this))},a=d.SLIPPort.prototype=Object.create(d.Port.prototype),a.constructor=d.SLIPPort,a.encodeOSC=function(a){a=a.buffer?a.buffer:a;var c=d.writePacket(a,this.options);return b.encode(c)},a.decodeSLIPData=function(a){this.decoder.decode(a)},d.relay=function(a,b,c,d,e,f){c=c||"message",d=d||"send",e=e||function(){},f=f?[null].concat(f):[];var g=function(a){f[0]=a,a=e(a),b[d].apply(b,f)};return a.on(c,g),{eventName:c,listener:g}},d.relayPorts=function(a,b,c){var e=c.raw?"raw":"osc",f=c.raw?"sendRaw":"send";return d.relay(a,b,e,f,c.transform)},d.stopRelaying=function(a,b){a.removeListener(b.eventName,b.listener)},d.Relay=function(a,b,c){var d=this.options=c||{};d.raw=!1,this.port1=a,this.port2=b,this.listen()},a=d.Relay.prototype,a.open=function(){this.port1.open(),this.port2.open()},a.listen=function(){this.port1Spec&&this.port2Spec&&this.close(),this.port1Spec=d.relayPorts(this.port1,this.port2,this.options),this.port2Spec=d.relayPorts(this.port2,this.port1,this.options)},a.close=function(){d.stopRelaying(this.port1,this.port1Spec),d.stopRelaying(this.port2,this.port2Spec)},"undefined"!=typeof module&&module.exports&&(module.exports=d)}();var d=d;return function(){"use strict";d.WebSocketPort=function(a){d.Port.call(this,a),this.on("open",this.listen.bind(this))};var a=d.WebSocketPort.prototype=Object.create(d.Port.prototype);a.constructor=d.WebSocketPort,a.open=function(){this.socket=new WebSocket(this.options.url),this.socket.binaryType="arraybuffer";var a=this;this.socket.onopen=function(){a.emit("open",a.socket)}},a.listen=function(){var a=this;this.socket.onmessage=function(b){a.emit("data",b.data)},this.socket.onerror=function(b){a.emit("error",b)},this.socket.onclose=function(b){a.emit("close",b)},a.emit("ready")},a.sendRaw=function(a){this.socket&&this.socket.send(a.buffer)},a.close=function(a,b){this.socket.close(a,b)}}(),d});
!function(a,b){"object"==typeof exports?(a.osc=exports,b(exports,require("slip"),require("EventEmitter"))):"function"==typeof define&&define.amd?define(["exports","slip","EventEmitter"],function(c,d,e){return a.osc=c,a.osc,b(c,d,e)}):(a.osc={},b(a.osc,slip,EventEmitter))}(this,function(a,b,c){var d=d||{};!function(){"use strict";var a;d.SECS_70YRS=2208988800,d.TWO_32=4294967296,d.defaults={metadata:!1,unpackSingleArgs:!0},d.isBufferEnv="undefined"!=typeof Buffer,d.isArray=function(a){return a&&"[object Array]"===Object.prototype.toString.call(a)},d.isTypedArrayView=function(a){return a.buffer&&a.buffer instanceof ArrayBuffer},d.isBuffer=function(a){return d.isBufferEnv&&a instanceof Buffer},d.dataView=function(b){return b instanceof DataView?b:"undefined"!=typeof a&&b instanceof a?b:d.isBufferEnv&&b instanceof Buffer?new a(b):b.buffer?new DataView(b.buffer):b instanceof ArrayBuffer?new DataView(b):new DataView(new Uint8Array(b))},d.byteArray=function(a){if(a instanceof Uint8Array)return a;var b=a.buffer?a.buffer:a;if("undefined"==typeof a.length||"string"==typeof a)throw new Error("Can't wrap a non-array-like object as Uint8Array. Object was: "+JSON.stringify(a,null,2));return new Uint8Array(b)},d.makeByteArray=function(a){return d.isBufferEnv?new Buffer(a):new Uint8Array(a)},d.copyByteArray=function(a,b,c){if(d.isTypedArrayView(a)&&d.isTypedArrayView(b))b.set(a,c);else if(d.isBuffer(a)&&d.isBuffer(b))a.copy(b,c);else for(var e=void 0===c?0:c,f=Math.min(b.length-c,a.length),g=0,h=e;f>g;g++,h++)b[h]=a[g];return b},d.readString=function(a,b){for(var c=[],d=b.idx;d<a.byteLength;d++){var e=a.getUint8(d);if(0===e){d++;break}c.push(e)}return d=d+3&-4,b.idx=d,String.fromCharCode.apply(null,c)},d.writeString=function(a){for(var b=a+"\x00",c=b.length,d=c+3&-4,e=new Uint8Array(d),f=0;f<b.length;f++){var g=b.charCodeAt(f);e[f]=g}return e},d.readPrimitive=function(a,b,c,d){var e=a[b](d.idx,!1);return d.idx+=c,e},d.writePrimitive=function(a,b,c,d,e){e=void 0===e?0:e;var f;return b?f=new Uint8Array(b.buffer):(f=new Uint8Array(d),b=new DataView(f.buffer)),b[c](e,a,!1),f},d.readInt32=function(a,b){return d.readPrimitive(a,"getInt32",4,b)},d.writeInt32=function(a,b,c){return d.writePrimitive(a,b,"setInt32",4,c)},d.readFloat32=function(a,b){return d.readPrimitive(a,"getFloat32",4,b)},d.writeFloat32=function(a,b,c){return d.writePrimitive(a,b,"setFloat32",4,c)},d.readFloat64=function(a,b){return d.readPrimitive(a,"getFloat64",8,b)},d.writeFloat64=function(a,b,c){return d.writePrimitive(a,b,"setFloat64",8,c)},d.readChar32=function(a,b){var c=d.readPrimitive(a,"getUint32",4,b);return String.fromCharCode(c)},d.writeChar32=function(a,b,c){var e=a.charCodeAt(0);return void 0===e||-1>e?void 0:d.writePrimitive(e,b,"setUint32",4,c)},d.readBlob=function(a,b){var c=d.readInt32(a,b),e=c+3&-4,f=new Uint8Array(a.buffer,b.idx,c);return b.idx+=e,f},d.writeBlob=function(a){a=d.byteArray(a);var b=a.byteLength,c=b+3&-4,e=4,f=c+e,g=new Uint8Array(f),h=new DataView(g.buffer);return d.writeInt32(b,h),g.set(a,e),g},d.readMIDIBytes=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4);return b.idx+=4,c},d.writeMIDIBytes=function(a){a=d.byteArray(a);var b=new Uint8Array(4);return b.set(a),b},d.readColor=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4),d=c[3]/255;return b.idx+=4,{r:c[0],g:c[1],b:c[2],a:d}},d.writeColor=function(a){var b=Math.round(255*a.a),c=new Uint8Array([a.r,a.g,a.b,b]);return c},d.readTrue=function(){return!0},d.readFalse=function(){return!1},d.readNull=function(){return null},d.readImpulse=function(){return 1},d.readTimeTag=function(a,b){var c=d.readPrimitive(a,"getUint32",4,b),e=d.readPrimitive(a,"getUint32",4,b),f=0===c&&1===e?Date.now():d.ntpToJSTime(c,e);return{raw:[c,e],"native":f}},d.writeTimeTag=function(a){var b=a.raw?a.raw:d.jsToNTPTime(a["native"]),c=new Uint8Array(8),e=new DataView(c.buffer);return d.writeInt32(b[0],e,0),d.writeInt32(b[1],e,4),c},d.timeTag=function(a){a=a||0;var b=Date.now()/1e3,c=Math.floor(b),e=b-c,f=Math.floor(a),g=a-f,h=e+g;if(h>1){var i=Math.floor(h),j=h-i;f+=i,h=j}var k=c+f+d.SECS_70YRS,l=Math.round(d.TWO_32*h);return{raw:[k,l]}},d.ntpToJSTime=function(a,b){var c=a-d.SECS_70YRS,e=b/d.TWO_32,f=1e3*(c+e);return f},d.jsToNTPTime=function(a){var b=a/1e3,c=Math.floor(b),e=b-c,f=c+d.SECS_70YRS,g=Math.round(d.TWO_32*e);return[f,g]},d.readArguments=function(a,b,c){var e=d.readString(a,c);if(0!==e.indexOf(","))throw new Error("A malformed type tag string was found while reading the arguments of an OSC message. String was: "+e," at offset: "+c.idx);var f=e.substring(1).split(""),g=[];return d.readArgumentsIntoArray(g,f,e,a,b,c),g},d.readArgument=function(a,b,c,e,f){var g=d.argumentTypes[a];if(!g)throw new Error("'"+a+"' is not a valid OSC type tag. Type tag string was: "+b);var h=g.reader,i=d[h](c,f);return e.metadata&&(i={type:a,value:i}),i},d.readArgumentsIntoArray=function(a,b,c,e,f,g){for(var h=0;h<b.length;){var i,j=b[h];if("["===j){var k=b.slice(h+1),l=k.indexOf("]");if(0>l)throw new Error("Invalid argument type tag: an open array type tag ('[') was found without a matching close array tag ('[]'). Type tag was: "+c);var m=k.slice(0,l);i=d.readArgumentsIntoArray([],m,c,e,f,g),h+=l+2}else i=d.readArgument(j,c,e,f,g),h++;a.push(i)}return a},d.writeArguments=function(a,b){var c=d.collectArguments(a,b);return d.joinParts(c)},d.joinParts=function(a){for(var b=d.makeByteArray(a.byteLength),c=a.parts,e=0,f=0;f<c.length;f++){var g=c[f];d.copyByteArray(g,b,e),e+=g.length}return b},d.addDataPart=function(a,b){b.parts.push(a),b.byteLength+=a.length},d.collectArguments=function(a,b,c){d.isArray(a)||(a=[a]),c=c||{byteLength:0,parts:[]},b.metadata||(a=d.annotateArguments(a));for(var e=",",f=c.parts.length,g=0;g<a.length;g++){var h=a[g],i=h.type,j=d.argumentTypes[i].writer;if(e+=h.type,j){var k=d[j](h.value);d.addDataPart(k,c)}}var l=d.writeString(e);return c.byteLength+=l.byteLength,c.parts.splice(f,0,l),c},d.readMessage=function(a,b,c){b=b||d.defaults;var e=d.dataView(a);c=c||{idx:0};var f=d.readString(e,c);return d.readMessageContents(f,e,b,c)},d.readMessageContents=function(a,b,c,e){if(0!==a.indexOf("/"))throw new Error("A malformed OSC address was found while reading an OSC message. String was: "+a);var f=d.readArguments(b,c,e);return{address:a,args:1===f.length&&c.unpackSingleArgs?f[0]:f}},d.collectMessageParts=function(a,b,c){return c=c||{byteLength:0,parts:[]},d.addDataPart(d.writeString(a.address),c),d.collectArguments(a.args,b,c)},d.writeMessage=function(a,b){b=b||d.defaults;var c=d.collectMessageParts(a,b);return d.joinParts(c)},d.readBundle=function(a,b,c){return d.readPacket(a,b,c)},d.collectBundlePackets=function(a,b,c){c=c||{byteLength:0,parts:[]},d.addDataPart(d.writeString("#bundle"),c),d.addDataPart(d.writeTimeTag(a.timeTag),c);for(var e=0;e<a.packets.length;e++){var f=a.packets[e],g=f.address?d.collectMessageParts:d.collectBundlePackets,h=g(f,b);c.byteLength+=h.byteLength,d.addDataPart(d.writeInt32(h.byteLength),c),c.parts=c.parts.concat(h.parts)}return c},d.writeBundle=function(a,b){if(a.timeTag&&a.packets){b=b||d.defaults;var c=d.collectBundlePackets(a,b);return d.joinParts(c)}},d.readBundleContents=function(a,b,c,e){for(var f=d.readTimeTag(a,c),g=[];c.idx<e;){var h=d.readInt32(a,c),i=c.idx+h,j=d.readPacket(a,b,c,i);g.push(j)}return{timeTag:f,packets:g}},d.readPacket=function(a,b,c,e){var f=d.dataView(a);e=void 0===e?f.byteLength:e,c=c||{idx:0};var g=d.readString(f,c),h=g[0];if("#"===h)return d.readBundleContents(f,b,c,e);if("/"===h)return d.readMessageContents(g,f,b,c);throw new Error("The header of an OSC packet didn't contain an OSC address or a #bundle string. Header was: "+g)},d.writePacket=function(a,b){var c=a.address?d.writeMessage:d.writeBundle;return c(a,b)},d.argumentTypes={i:{reader:"readInt32",writer:"writeInt32"},f:{reader:"readFloat32",writer:"writeFloat32"},s:{reader:"readString",writer:"writeString"},S:{reader:"readString",writer:"writeString"},b:{reader:"readBlob",writer:"writeBlob"},t:{reader:"readTimeTag",writer:"writeTimeTag"},T:{reader:"readTrue"},F:{reader:"readFalse"},N:{reader:"readNull"},I:{reader:"readImpulse"},d:{reader:"readFloat64",writer:"writeFloat64"},c:{reader:"readChar32",writer:"writeChar32"},r:{reader:"readColor",writer:"writeColor"},m:{reader:"readMIDIBytes",writer:"writeMIDIBytes"}},d.inferTypeForArgument=function(a){var b=typeof a;switch(b){case"boolean":return a?"T":"F";case"string":return"s";case"number":return"f";case"undefined":return"N";case"object":if(null===a)return"N";if(a instanceof Uint8Array||a instanceof ArrayBuffer||d.isBufferEnv&&a instanceof Buffer)return"b"}throw new Error("Can't infer OSC argument type for value: "+JSON.stringify(a,null,2))},d.annotateArguments=function(a){d.isArray(a)||(a=[a]);for(var b=[],c=0;c<a.length;c++){var e,f=a[c];if("object"==typeof f&&f.type&&void 0!==f.value)e=f;else{var g=d.inferTypeForArgument(f);e={type:g,value:f}}b.push(e)}return b},"undefined"!=typeof module&&module.exports&&(d.isBufferEnv&&(a=require("buffer-dataview")),module.exports=d)}();var d=d||require("./osc.js"),b=b||require("slip"),c=c||require("events").EventEmitter;!function(){"use strict";d.firePacketEvents=function(a,b,c){b.address?a.emit("message",b,c):d.fireBundleEvents(a,b,c)},d.fireBundleEvents=function(a,b,c){a.emit("bundle",b,c);for(var e=0;e<b.packets.length;e++){var f=b.packets[e];d.firePacketEvents(a,f,b.timeTag)}},d.Port=function(a){this.options=a||{},this.on("data",this.decodeOSC.bind(this))};var a=d.Port.prototype=Object.create(c.prototype);a.constructor=d.Port,a.send=function(a){var b=Array.prototype.slice.call(arguments),c=this.encodeOSC(a);b[0]=c,this.sendRaw.apply(this,b)},a.encodeOSC=function(a){a=a.buffer?a.buffer:a;var b=d.writePacket(a,this.options);return b},a.decodeOSC=function(a){this.emit("raw",a);var b=d.readPacket(a,this.options);this.emit("osc",b),d.firePacketEvents(this,b)},d.SLIPPort=function(a){var c=this,d=this.options=a||{};d.useSLIP=void 0===d.useSLIP?!0:d.useSLIP,this.decoder=new b.Decoder({onMessage:this.decodeOSC.bind(this),onError:function(a){c.emit("error",a)}});var e=d.useSLIP?this.decodeSLIPData:this.decodeOSC;this.on("data",e.bind(this))},a=d.SLIPPort.prototype=Object.create(d.Port.prototype),a.constructor=d.SLIPPort,a.encodeOSC=function(a){a=a.buffer?a.buffer:a;var c=d.writePacket(a,this.options);return b.encode(c)},a.decodeSLIPData=function(a){this.decoder.decode(a)},d.relay=function(a,b,c,d,e,f){c=c||"message",d=d||"send",e=e||function(){},f=f?[null].concat(f):[];var g=function(a){f[0]=a,a=e(a),b[d].apply(b,f)};return a.on(c,g),{eventName:c,listener:g}},d.relayPorts=function(a,b,c){var e=c.raw?"raw":"osc",f=c.raw?"sendRaw":"send";return d.relay(a,b,e,f,c.transform)},d.stopRelaying=function(a,b){a.removeListener(b.eventName,b.listener)},d.Relay=function(a,b,c){var d=this.options=c||{};d.raw=!1,this.port1=a,this.port2=b,this.listen()},a=d.Relay.prototype=Object.create(c.prototype),a.constructor=d.Relay,a.open=function(){this.port1.open(),this.port2.open()},a.listen=function(){this.port1Spec&&this.port2Spec&&this.close(),this.port1Spec=d.relayPorts(this.port1,this.port2,this.options),this.port2Spec=d.relayPorts(this.port2,this.port1,this.options);var a=this.close.bind(this);this.port1.on("close",a),this.port2.on("close",a)},a.close=function(){d.stopRelaying(this.port1,this.port1Spec),d.stopRelaying(this.port2,this.port2Spec),this.emit("close",this.port1,this.port2)},"undefined"!=typeof module&&module.exports&&(module.exports=d)}();var d=d;return function(){"use strict";d.WebSocketPort=function(a){d.Port.call(this,a),this.on("open",this.listen.bind(this))};var a=d.WebSocketPort.prototype=Object.create(d.Port.prototype);a.constructor=d.WebSocketPort,a.open=function(){this.socket=new WebSocket(this.options.url),this.socket.binaryType="arraybuffer";var a=this;this.socket.onopen=function(){a.emit("open",a.socket)}},a.listen=function(){var a=this;this.socket.onmessage=function(b){a.emit("data",b.data)},this.socket.onerror=function(b){a.emit("error",b)},this.socket.onclose=function(b){a.emit("close",b)},a.emit("ready")},a.sendRaw=function(a){this.socket&&this.socket.send(a.buffer)},a.close=function(a,b){this.socket.close(a,b)}}(),d});

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

/*! osc.js 1.1.2, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */
/*! osc.js 1.1.4, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */

@@ -3,0 +3,0 @@ /*

@@ -1,3 +0,3 @@

/*! osc.js 1.1.2, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */
/*! osc.js 1.1.4, Copyright 2015 Colin Clark | github.com/colinbdclark/osc.js */
var osc=osc||{};!function(){"use strict";var a;osc.SECS_70YRS=2208988800,osc.TWO_32=4294967296,osc.defaults={metadata:!1,unpackSingleArgs:!0},osc.isBufferEnv="undefined"!=typeof Buffer,osc.isArray=function(a){return a&&"[object Array]"===Object.prototype.toString.call(a)},osc.isTypedArrayView=function(a){return a.buffer&&a.buffer instanceof ArrayBuffer},osc.isBuffer=function(a){return osc.isBufferEnv&&a instanceof Buffer},osc.dataView=function(b){return b instanceof DataView?b:"undefined"!=typeof a&&b instanceof a?b:osc.isBufferEnv&&b instanceof Buffer?new a(b):b.buffer?new DataView(b.buffer):b instanceof ArrayBuffer?new DataView(b):new DataView(new Uint8Array(b))},osc.byteArray=function(a){if(a instanceof Uint8Array)return a;var b=a.buffer?a.buffer:a;if("undefined"==typeof a.length||"string"==typeof a)throw new Error("Can't wrap a non-array-like object as Uint8Array. Object was: "+JSON.stringify(a,null,2));return new Uint8Array(b)},osc.makeByteArray=function(a){return osc.isBufferEnv?new Buffer(a):new Uint8Array(a)},osc.copyByteArray=function(a,b,c){if(osc.isTypedArrayView(a)&&osc.isTypedArrayView(b))b.set(a,c);else if(osc.isBuffer(a)&&osc.isBuffer(b))a.copy(b,c);else for(var d=void 0===c?0:c,e=Math.min(b.length-c,a.length),f=0,g=d;e>f;f++,g++)b[g]=a[f];return b},osc.readString=function(a,b){for(var c=[],d=b.idx;d<a.byteLength;d++){var e=a.getUint8(d);if(0===e){d++;break}c.push(e)}return d=d+3&-4,b.idx=d,String.fromCharCode.apply(null,c)},osc.writeString=function(a){for(var b=a+"\x00",c=b.length,d=c+3&-4,e=new Uint8Array(d),f=0;f<b.length;f++){var g=b.charCodeAt(f);e[f]=g}return e},osc.readPrimitive=function(a,b,c,d){var e=a[b](d.idx,!1);return d.idx+=c,e},osc.writePrimitive=function(a,b,c,d,e){e=void 0===e?0:e;var f;return b?f=new Uint8Array(b.buffer):(f=new Uint8Array(d),b=new DataView(f.buffer)),b[c](e,a,!1),f},osc.readInt32=function(a,b){return osc.readPrimitive(a,"getInt32",4,b)},osc.writeInt32=function(a,b,c){return osc.writePrimitive(a,b,"setInt32",4,c)},osc.readFloat32=function(a,b){return osc.readPrimitive(a,"getFloat32",4,b)},osc.writeFloat32=function(a,b,c){return osc.writePrimitive(a,b,"setFloat32",4,c)},osc.readFloat64=function(a,b){return osc.readPrimitive(a,"getFloat64",8,b)},osc.writeFloat64=function(a,b,c){return osc.writePrimitive(a,b,"setFloat64",8,c)},osc.readChar32=function(a,b){var c=osc.readPrimitive(a,"getUint32",4,b);return String.fromCharCode(c)},osc.writeChar32=function(a,b,c){var d=a.charCodeAt(0);return void 0===d||-1>d?void 0:osc.writePrimitive(d,b,"setUint32",4,c)},osc.readBlob=function(a,b){var c=osc.readInt32(a,b),d=c+3&-4,e=new Uint8Array(a.buffer,b.idx,c);return b.idx+=d,e},osc.writeBlob=function(a){a=osc.byteArray(a);var b=a.byteLength,c=b+3&-4,d=4,e=c+d,f=new Uint8Array(e),g=new DataView(f.buffer);return osc.writeInt32(b,g),f.set(a,d),f},osc.readMIDIBytes=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4);return b.idx+=4,c},osc.writeMIDIBytes=function(a){a=osc.byteArray(a);var b=new Uint8Array(4);return b.set(a),b},osc.readColor=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4),d=c[3]/255;return b.idx+=4,{r:c[0],g:c[1],b:c[2],a:d}},osc.writeColor=function(a){var b=Math.round(255*a.a),c=new Uint8Array([a.r,a.g,a.b,b]);return c},osc.readTrue=function(){return!0},osc.readFalse=function(){return!1},osc.readNull=function(){return null},osc.readImpulse=function(){return 1},osc.readTimeTag=function(a,b){var c=osc.readPrimitive(a,"getUint32",4,b),d=osc.readPrimitive(a,"getUint32",4,b),e=0===c&&1===d?Date.now():osc.ntpToJSTime(c,d);return{raw:[c,d],"native":e}},osc.writeTimeTag=function(a){var b=a.raw?a.raw:osc.jsToNTPTime(a["native"]),c=new Uint8Array(8),d=new DataView(c.buffer);return osc.writeInt32(b[0],d,0),osc.writeInt32(b[1],d,4),c},osc.timeTag=function(a){a=a||0;var b=Date.now()/1e3,c=Math.floor(b),d=b-c,e=Math.floor(a),f=a-e,g=d+f;if(g>1){var h=Math.floor(g),i=g-h;e+=h,g=i}var j=c+e+osc.SECS_70YRS,k=Math.round(osc.TWO_32*g);return{raw:[j,k]}},osc.ntpToJSTime=function(a,b){var c=a-osc.SECS_70YRS,d=b/osc.TWO_32,e=1e3*(c+d);return e},osc.jsToNTPTime=function(a){var b=a/1e3,c=Math.floor(b),d=b-c,e=c+osc.SECS_70YRS,f=Math.round(osc.TWO_32*d);return[e,f]},osc.readArguments=function(a,b,c){var d=osc.readString(a,c);if(0!==d.indexOf(","))throw new Error("A malformed type tag string was found while reading the arguments of an OSC message. String was: "+d," at offset: "+c.idx);var e=d.substring(1).split(""),f=[];return osc.readArgumentsIntoArray(f,e,d,a,b,c),f},osc.readArgument=function(a,b,c,d,e){var f=osc.argumentTypes[a];if(!f)throw new Error("'"+a+"' is not a valid OSC type tag. Type tag string was: "+b);var g=f.reader,h=osc[g](c,e);return d.metadata&&(h={type:a,value:h}),h},osc.readArgumentsIntoArray=function(a,b,c,d,e,f){for(var g=0;g<b.length;){var h,i=b[g];if("["===i){var j=b.slice(g+1),k=j.indexOf("]");if(0>k)throw new Error("Invalid argument type tag: an open array type tag ('[') was found without a matching close array tag ('[]'). Type tag was: "+c);var l=j.slice(0,k);h=osc.readArgumentsIntoArray([],l,c,d,e,f),g+=k+2}else h=osc.readArgument(i,c,d,e,f),g++;a.push(h)}return a},osc.writeArguments=function(a,b){var c=osc.collectArguments(a,b);return osc.joinParts(c)},osc.joinParts=function(a){for(var b=osc.makeByteArray(a.byteLength),c=a.parts,d=0,e=0;e<c.length;e++){var f=c[e];osc.copyByteArray(f,b,d),d+=f.length}return b},osc.addDataPart=function(a,b){b.parts.push(a),b.byteLength+=a.length},osc.collectArguments=function(a,b,c){osc.isArray(a)||(a=[a]),c=c||{byteLength:0,parts:[]},b.metadata||(a=osc.annotateArguments(a));for(var d=",",e=c.parts.length,f=0;f<a.length;f++){var g=a[f],h=g.type,i=osc.argumentTypes[h].writer;if(d+=g.type,i){var j=osc[i](g.value);osc.addDataPart(j,c)}}var k=osc.writeString(d);return c.byteLength+=k.byteLength,c.parts.splice(e,0,k),c},osc.readMessage=function(a,b,c){b=b||osc.defaults;var d=osc.dataView(a);c=c||{idx:0};var e=osc.readString(d,c);return osc.readMessageContents(e,d,b,c)},osc.readMessageContents=function(a,b,c,d){if(0!==a.indexOf("/"))throw new Error("A malformed OSC address was found while reading an OSC message. String was: "+a);var e=osc.readArguments(b,c,d);return{address:a,args:1===e.length&&c.unpackSingleArgs?e[0]:e}},osc.collectMessageParts=function(a,b,c){return c=c||{byteLength:0,parts:[]},osc.addDataPart(osc.writeString(a.address),c),osc.collectArguments(a.args,b,c)},osc.writeMessage=function(a,b){b=b||osc.defaults;var c=osc.collectMessageParts(a,b);return osc.joinParts(c)},osc.readBundle=function(a,b,c){return osc.readPacket(a,b,c)},osc.collectBundlePackets=function(a,b,c){c=c||{byteLength:0,parts:[]},osc.addDataPart(osc.writeString("#bundle"),c),osc.addDataPart(osc.writeTimeTag(a.timeTag),c);for(var d=0;d<a.packets.length;d++){var e=a.packets[d],f=e.address?osc.collectMessageParts:osc.collectBundlePackets,g=f(e,b);c.byteLength+=g.byteLength,osc.addDataPart(osc.writeInt32(g.byteLength),c),c.parts=c.parts.concat(g.parts)}return c},osc.writeBundle=function(a,b){if(a.timeTag&&a.packets){b=b||osc.defaults;var c=osc.collectBundlePackets(a,b);return osc.joinParts(c)}},osc.readBundleContents=function(a,b,c,d){for(var e=osc.readTimeTag(a,c),f=[];c.idx<d;){var g=osc.readInt32(a,c),h=c.idx+g,i=osc.readPacket(a,b,c,h);f.push(i)}return{timeTag:e,packets:f}},osc.readPacket=function(a,b,c,d){var e=osc.dataView(a);d=void 0===d?e.byteLength:d,c=c||{idx:0};var f=osc.readString(e,c),g=f[0];if("#"===g)return osc.readBundleContents(e,b,c,d);if("/"===g)return osc.readMessageContents(f,e,b,c);throw new Error("The header of an OSC packet didn't contain an OSC address or a #bundle string. Header was: "+f)},osc.writePacket=function(a,b){var c=a.address?osc.writeMessage:osc.writeBundle;return c(a,b)},osc.argumentTypes={i:{reader:"readInt32",writer:"writeInt32"},f:{reader:"readFloat32",writer:"writeFloat32"},s:{reader:"readString",writer:"writeString"},S:{reader:"readString",writer:"writeString"},b:{reader:"readBlob",writer:"writeBlob"},t:{reader:"readTimeTag",writer:"writeTimeTag"},T:{reader:"readTrue"},F:{reader:"readFalse"},N:{reader:"readNull"},I:{reader:"readImpulse"},d:{reader:"readFloat64",writer:"writeFloat64"},c:{reader:"readChar32",writer:"writeChar32"},r:{reader:"readColor",writer:"writeColor"},m:{reader:"readMIDIBytes",writer:"writeMIDIBytes"}},osc.inferTypeForArgument=function(a){var b=typeof a;switch(b){case"boolean":return a?"T":"F";case"string":return"s";case"number":return"f";case"undefined":return"N";case"object":if(null===a)return"N";if(a instanceof Uint8Array||a instanceof ArrayBuffer||osc.isBufferEnv&&a instanceof Buffer)return"b"}throw new Error("Can't infer OSC argument type for value: "+JSON.stringify(a,null,2))},osc.annotateArguments=function(a){osc.isArray(a)||(a=[a]);for(var b=[],c=0;c<a.length;c++){var d,e=a[c];if("object"==typeof e&&e.type&&void 0!==e.value)d=e;else{var f=osc.inferTypeForArgument(e);d={type:f,value:e}}b.push(d)}return b},"undefined"!=typeof module&&module.exports&&(osc.isBufferEnv&&(a=require("buffer-dataview")),module.exports=osc)}();
{
"name": "osc",
"main": "src/platforms/osc-node.js",
"version": "1.1.3",
"version": "1.1.4",
"description": "A JavaScript Open Sound Control (OSC) library that works in Node.js and the browser.",

@@ -38,5 +38,5 @@ "author": "Colin Clark",

"serialport": "1.7.4",
"slip": ">=1.0.1",
"slip": "1.0.2",
"ws": "0.7.2"
}
}

@@ -139,2 +139,21 @@ osc.js

##### Using osc.js with Require.js
```javascript
// Define your module paths, including osc.js' dependencies.
// Note: these paths must resolve to wherever you have placed
// osc.js, slip.js, and eventEmitter in your project.
require.config({
paths: {
slip: "../bower_components/slip.js/dist/slip.min",
EventEmitter: "../bower_components/eventEmitter/EventEmitter.min",
osc: "../bower_components/osc.js/osc-module.min"
}
});
// Load it asynchronously.
require(["osc"], function (osc) {
// Do something with osc.js when it has fully loaded.
});
```
### Web Sockets in Node.js

@@ -141,0 +160,0 @@

@@ -127,3 +127,2 @@ /*

// Unsupported, non-API function.

@@ -134,2 +133,3 @@ osc.stopRelaying = function (from, relaySpec) {

/**

@@ -154,3 +154,4 @@ * A Relay connects two sources of OSC data together,

p = osc.Relay.prototype;
p = osc.Relay.prototype = Object.create(EventEmitter.prototype);
p.constructor = osc.Relay;

@@ -169,2 +170,10 @@ p.open = function () {

this.port2Spec = osc.relayPorts(this.port2, this.port1, this.options);
// Bind port close listeners to ensure that the relay
// will stop forwarding messages if one of its ports close.
// Users are still responsible for closing the underlying ports
// if necessary.
var closeListener = this.close.bind(this);
this.port1.on("close", closeListener);
this.port2.on("close", closeListener);
};

@@ -175,2 +184,3 @@

osc.stopRelaying(this.port2, this.port2Spec);
this.emit("close", this.port1, this.port2);
};

@@ -177,0 +187,0 @@

@@ -173,2 +173,6 @@ /*

this.socket.on("close", function () {
that.emit("close");
});
that.emit("ready");

@@ -175,0 +179,0 @@ };

@@ -133,4 +133,2 @@ /*global require*/

wsc.close();
jqUnit.start();
}

@@ -150,2 +148,3 @@

"The message should have been sent to the web socket client.");
jqUnit.start();
});

@@ -175,2 +174,3 @@

udpPort.close();
jqUnit.start();
});

@@ -188,3 +188,28 @@ });

jqUnit.asyncTest("Relay closes when first port closes", function () {
var firstPort = new osc.UDPPort({
localPort: 57121
});
var secondPort = new osc.UDPPort({
localPort: 57122
});
var relay = new osc.Relay(firstPort, secondPort);
relay.on("close", function () {
QUnit.ok(true, "The relay emitted its close event as a result of the first port closing.");
jqUnit.start();
});
firstPort.on("ready", function () {
secondPort.on("ready", function () {
firstPort.close();
});
});
firstPort.open();
secondPort.open();
});
/*************

@@ -191,0 +216,0 @@ * TCP Tests *

@@ -6,20 +6,14 @@ /*global require, QUnit*/

// Simulate a full-on require environment.
window.module = {
exports: {}
};
require.config({
paths: {
slip: "../bower_components/slip.js/dist/slip.min",
EventEmitter: "../bower_components/eventEmitter/EventEmitter.min"
EventEmitter: "../bower_components/eventEmitter/EventEmitter.min",
osc: "../dist/osc-module.min"
}
});
var oscModulePath = "../dist/osc-module.js";
QUnit.module("Require.js AMD tests");
QUnit.asyncTest("osc is defined and populated using the AMD style", function () {
require([oscModulePath], function (osc) {
require(["osc"], function (osc) {
QUnit.ok(osc, "The 'osc' variable should be defined");

@@ -26,0 +20,0 @@ QUnit.ok(osc.WebSocketPort, "The osc browser transports should also be available.");

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc