Socket
Socket
Sign inDemoInstall

osc-js

Package Overview
Dependencies
4
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.4.0 to 2.4.1

lib/atomic.d.ts

2

lib/osc.d.ts

@@ -152,3 +152,3 @@ import * as https from 'https';

*/
unpack(dataView: DataView, method: string, byteLength: number, initialOffset?: number): number;
unpackWithMethod(dataView: DataView, method: string, byteLength: number, initialOffset?: number): number;
}

@@ -155,0 +155,0 @@

@@ -12,28 +12,48 @@ (function (global, factory) {

function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
function _callSuper(t, o, e) {
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
}
function _isNativeReflectConstruct() {
try {
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
} catch (t) {}
return (_isNativeReflectConstruct = function () {
return !!t;
})();
}
function ownKeys(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function (r) {
return Object.getOwnPropertyDescriptor(e, r).enumerable;
})), t.push.apply(t, o);
}
return keys;
return t;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
function _objectSpread2(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
_defineProperty(e, r, t[r]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
});
}
return target;
return e;
}
function _toPrimitive(t, r) {
if ("object" != typeof t || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != typeof i) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == typeof i ? i : i + "";
}
function _classCallCheck(instance, Constructor) {

@@ -44,3 +64,2 @@ if (!(instance instanceof Constructor)) {

}
function _defineProperties(target, props) {

@@ -52,6 +71,5 @@ for (var i = 0; i < props.length; i++) {

if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {

@@ -65,4 +83,4 @@ if (protoProps) _defineProperties(Constructor.prototype, protoProps);

}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {

@@ -78,6 +96,4 @@ Object.defineProperty(obj, key, {

}
return obj;
}
function _inherits(subClass, superClass) {

@@ -87,3 +103,2 @@ if (typeof superClass !== "function" && superClass !== null) {

}
subClass.prototype = Object.create(superClass && superClass.prototype, {

@@ -101,3 +116,2 @@ constructor: {

}
function _getPrototypeOf(o) {

@@ -109,3 +123,2 @@ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {

}
function _setPrototypeOf(o, p) {

@@ -118,16 +131,2 @@ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {

}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _assertThisInitialized(self) {

@@ -137,6 +136,4 @@ if (self === void 0) {

}
return self;
}
function _possibleConstructorReturn(self, call) {

@@ -148,25 +145,4 @@ if (call && (typeof call === "object" || typeof call === "function")) {

}
return _assertThisInitialized(self);
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
function _superPropBase(object, property) {

@@ -177,6 +153,4 @@ while (!Object.prototype.hasOwnProperty.call(object, property)) {

}
return object;
}
function _get() {

@@ -188,14 +162,10 @@ if (typeof Reflect !== "undefined" && Reflect.get) {

var base = _superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(arguments.length < 3 ? target : receiver);
}
return desc.value;
};
}
return _get.apply(this, arguments);

@@ -315,3 +285,3 @@ }

}
_createClass(EncodeHelper, [{
return _createClass(EncodeHelper, [{
key: "add",

@@ -339,3 +309,2 @@ value: function add(item) {

}]);
return EncodeHelper;
}();

@@ -349,3 +318,3 @@

}
_createClass(Atomic, [{
return _createClass(Atomic, [{
key: "pack",

@@ -365,4 +334,4 @@ value: function pack(method, byteLength) {

}, {
key: "unpack",
value: function unpack(dataView, method, byteLength) {
key: "unpackWithMethod",
value: function unpackWithMethod(dataView, method, byteLength) {
var initialOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;

@@ -380,8 +349,5 @@ if (!(dataView && method && byteLength)) {

}]);
return Atomic;
}();
var AtomicInt32 = function (_Atomic) {
_inherits(AtomicInt32, _Atomic);
var _super = _createSuper(AtomicInt32);
function AtomicInt32(value) {

@@ -392,5 +358,6 @@ _classCallCheck(this, AtomicInt32);

}
return _super.call(this, value);
return _callSuper(this, AtomicInt32, [value]);
}
_createClass(AtomicInt32, [{
_inherits(AtomicInt32, _Atomic);
return _createClass(AtomicInt32, [{
key: "pack",

@@ -404,6 +371,5 @@ value: function pack() {

var initialOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
return _get(_getPrototypeOf(AtomicInt32.prototype), "unpack", this).call(this, dataView, 'getInt32', 4, initialOffset);
return _get(_getPrototypeOf(AtomicInt32.prototype), "unpackWithMethod", this).call(this, dataView, 'getInt32', 4, initialOffset);
}
}]);
return AtomicInt32;
}(Atomic);

@@ -427,4 +393,2 @@

var AtomicString = function (_Atomic) {
_inherits(AtomicString, _Atomic);
var _super = _createSuper(AtomicString);
function AtomicString(value) {

@@ -435,5 +399,6 @@ _classCallCheck(this, AtomicString);

}
return _super.call(this, value);
return _callSuper(this, AtomicString, [value]);
}
_createClass(AtomicString, [{
_inherits(AtomicString, _Atomic);
return _createClass(AtomicString, [{
key: "pack",

@@ -479,3 +444,2 @@ value: function pack() {

}]);
return AtomicString;
}(Atomic);

@@ -496,3 +460,3 @@

}
_createClass(Timetag, [{
return _createClass(Timetag, [{
key: "timestamp",

@@ -512,7 +476,4 @@ value: function timestamp(milliseconds) {

}]);
return Timetag;
}();
var AtomicTimetag = function (_Atomic) {
_inherits(AtomicTimetag, _Atomic);
var _super = _createSuper(AtomicTimetag);
function AtomicTimetag() {

@@ -529,5 +490,6 @@ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Date.now();

}
return _super.call(this, timetag);
return _callSuper(this, AtomicTimetag, [timetag]);
}
_createClass(AtomicTimetag, [{
_inherits(AtomicTimetag, _Atomic);
return _createClass(AtomicTimetag, [{
key: "pack",

@@ -539,4 +501,4 @@ value: function pack() {

var _this$value = this.value,
seconds = _this$value.seconds,
fractions = _this$value.fractions;
seconds = _this$value.seconds,
fractions = _this$value.fractions;
var data = new Uint8Array(8);

@@ -562,8 +524,5 @@ var dataView = new DataView(data.buffer);

}]);
return AtomicTimetag;
}(Atomic);
var AtomicBlob = function (_Atomic) {
_inherits(AtomicBlob, _Atomic);
var _super = _createSuper(AtomicBlob);
function AtomicBlob(value) {

@@ -574,5 +533,6 @@ _classCallCheck(this, AtomicBlob);

}
return _super.call(this, value);
return _callSuper(this, AtomicBlob, [value]);
}
_createClass(AtomicBlob, [{
_inherits(AtomicBlob, _Atomic);
return _createClass(AtomicBlob, [{
key: "pack",

@@ -603,8 +563,5 @@ value: function pack() {

}]);
return AtomicBlob;
}(Atomic);
var AtomicFloat32 = function (_Atomic) {
_inherits(AtomicFloat32, _Atomic);
var _super = _createSuper(AtomicFloat32);
function AtomicFloat32(value) {

@@ -615,5 +572,6 @@ _classCallCheck(this, AtomicFloat32);

}
return _super.call(this, value);
return _callSuper(this, AtomicFloat32, [value]);
}
_createClass(AtomicFloat32, [{
_inherits(AtomicFloat32, _Atomic);
return _createClass(AtomicFloat32, [{
key: "pack",

@@ -627,11 +585,8 @@ value: function pack() {

var initialOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
return _get(_getPrototypeOf(AtomicFloat32.prototype), "unpack", this).call(this, dataView, 'getFloat32', 4, initialOffset);
return _get(_getPrototypeOf(AtomicFloat32.prototype), "unpackWithMethod", this).call(this, dataView, 'getFloat32', 4, initialOffset);
}
}]);
return AtomicFloat32;
}(Atomic);
var AtomicFloat64 = function (_Atomic) {
_inherits(AtomicFloat64, _Atomic);
var _super = _createSuper(AtomicFloat64);
function AtomicFloat64(value) {

@@ -642,5 +597,6 @@ _classCallCheck(this, AtomicFloat64);

}
return _super.call(this, value);
return _callSuper(this, AtomicFloat64, [value]);
}
_createClass(AtomicFloat64, [{
_inherits(AtomicFloat64, _Atomic);
return _createClass(AtomicFloat64, [{
key: "pack",

@@ -654,6 +610,5 @@ value: function pack() {

var initialOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
return _get(_getPrototypeOf(AtomicFloat64.prototype), "unpack", this).call(this, dataView, 'getFloat64', 8, initialOffset);
return _get(_getPrototypeOf(AtomicFloat64.prototype), "unpackWithMethod", this).call(this, dataView, 'getFloat64', 8, initialOffset);
}
}]);
return AtomicFloat64;
}(Atomic);

@@ -664,4 +619,2 @@

var AtomicInt64 = function (_Atomic) {
_inherits(AtomicInt64, _Atomic);
var _super = _createSuper(AtomicInt64);
function AtomicInt64(value) {

@@ -679,5 +632,6 @@ _classCallCheck(this, AtomicInt64);

}
return _super.call(this, tmp);
return _callSuper(this, AtomicInt64, [tmp]);
}
_createClass(AtomicInt64, [{
_inherits(AtomicInt64, _Atomic);
return _createClass(AtomicInt64, [{
key: "pack",

@@ -691,6 +645,5 @@ value: function pack() {

var initialOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
return _get(_getPrototypeOf(AtomicInt64.prototype), "unpack", this).call(this, dataView, 'getBigInt64', 8, initialOffset);
return _get(_getPrototypeOf(AtomicInt64.prototype), "unpackWithMethod", this).call(this, dataView, 'getBigInt64', 8, initialOffset);
}
}]);
return AtomicInt64;
}(Atomic);

@@ -700,4 +653,2 @@

var AtomicUInt64 = function (_Atomic) {
_inherits(AtomicUInt64, _Atomic);
var _super = _createSuper(AtomicUInt64);
function AtomicUInt64(value) {

@@ -715,5 +666,6 @@ _classCallCheck(this, AtomicUInt64);

}
return _super.call(this, tmp);
return _callSuper(this, AtomicUInt64, [tmp]);
}
_createClass(AtomicUInt64, [{
_inherits(AtomicUInt64, _Atomic);
return _createClass(AtomicUInt64, [{
key: "pack",

@@ -727,6 +679,5 @@ value: function pack() {

var initialOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
return _get(_getPrototypeOf(AtomicUInt64.prototype), "unpack", this).call(this, dataView, 'getBigUint64', 8, initialOffset);
return _get(_getPrototypeOf(AtomicUInt64.prototype), "unpackWithMethod", this).call(this, dataView, 'getBigUint64', 8, initialOffset);
}
}]);
return AtomicUInt64;
}(Atomic);

@@ -762,3 +713,3 @@

}
_createClass(TypedMessage, [{
return _createClass(TypedMessage, [{
key: "add",

@@ -890,7 +841,4 @@ value: function add(type, item) {

}]);
return TypedMessage;
}();
var Message = function (_TypedMessage) {
_inherits(Message, _TypedMessage);
var _super = _createSuper(Message);
function Message(address) {

@@ -908,3 +856,3 @@ var _this3;

}
_this3 = _super.call(this, address, oscArgs);
_this3 = _callSuper(this, Message, [address, oscArgs]);
if (args.length > 0) {

@@ -918,3 +866,4 @@ _this3.types = args.map(function (item) {

}
_createClass(Message, [{
_inherits(Message, _TypedMessage);
return _createClass(Message, [{
key: "add",

@@ -925,3 +874,2 @@ value: function add(item) {

}]);
return Message;
}(TypedMessage);

@@ -957,3 +905,3 @@

}
_createClass(Bundle, [{
return _createClass(Bundle, [{
key: "timestamp",

@@ -1023,3 +971,2 @@ value: function timestamp(ms) {

}]);
return Bundle;
}();

@@ -1036,3 +983,3 @@

}
_createClass(Packet, [{
return _createClass(Packet, [{
key: "pack",

@@ -1069,3 +1016,2 @@ value: function pack() {

}]);
return Packet;
}();

@@ -1088,3 +1034,3 @@

}
_createClass(EventHandler, [{
return _createClass(EventHandler, [{
key: "dispatch",

@@ -1106,3 +1052,3 @@ value: function dispatch(packet, rinfo) {

}
return _this.dispatch(bundleItem);
return _this.dispatch(new Packet(bundleItem));
} else if (bundleItem instanceof Message) {

@@ -1165,44 +1111,49 @@ var message = bundleItem;

}
if (args[0] instanceof Packet) {
return this.dispatch(args[0], args[1]);
} else if (args[0] instanceof Bundle || args[0] instanceof Message) {
return this.dispatch(new Packet(args[0]), args[1]);
} else if (!isString(args[0])) {
var packet = new Packet();
packet.unpack(dataView(args[0]));
return this.dispatch(packet, args[1]);
}
var name = args[0];
var data = null;
if (args.length > 1) {
data = args[1];
}
var timestamp = null;
if (args.length > 2) {
if (isInt(args[2])) {
timestamp = args[2];
} else if (args[2] instanceof Date) {
timestamp = args[2].getTime();
} else {
throw new Error('OSC EventHandler timestamp has to be a number or Date');
try {
if (args[0] instanceof Packet) {
return this.dispatch(args[0], args[1]);
} else if (args[0] instanceof Bundle || args[0] instanceof Message) {
return this.dispatch(new Packet(args[0]), args[1]);
} else if (!isString(args[0])) {
var packet = new Packet();
packet.unpack(dataView(args[0]));
return this.dispatch(packet, args[1]);
}
}
var rinfo = null;
if (args.length >= 3) {
rinfo = args[3];
}
if (timestamp) {
var now = Date.now();
if (now > timestamp) {
if (!this.options.discardLateMessages) {
return this.call(name, data, rinfo);
var name = args[0];
var data = null;
if (args.length > 1) {
data = args[1];
}
var timestamp = null;
if (args.length > 2) {
if (isInt(args[2])) {
timestamp = args[2];
} else if (args[2] instanceof Date) {
timestamp = args[2].getTime();
} else {
throw new Error('OSC EventHandler timestamp has to be a number or Date');
}
}
var that = this;
setTimeout(function () {
that.call(name, data, rinfo);
}, timestamp - now);
return true;
var rinfo = null;
if (args.length >= 3) {
rinfo = args[3];
}
if (timestamp) {
var now = Date.now();
if (now > timestamp) {
if (!this.options.discardLateMessages) {
return this.call(name, data, rinfo);
}
}
var that = this;
setTimeout(function () {
that.call(name, data, rinfo);
}, timestamp - now);
return true;
}
return this.call(name, data, rinfo);
} catch (error) {
this.notify('error', error);
return false;
}
return this.call(name, data, rinfo);
}

@@ -1264,3 +1215,2 @@ }, {

}]);
return EventHandler;
}();

@@ -1275,3 +1225,3 @@

}
_createClass(Plugin, [{
return _createClass(Plugin, [{
key: "status",

@@ -1297,3 +1247,2 @@ value: function status() {

}]);
return Plugin;
}();

@@ -1329,4 +1278,2 @@

var DatagramPlugin = function (_Plugin) {
_inherits(DatagramPlugin, _Plugin);
var _super = _createSuper(DatagramPlugin);
function DatagramPlugin() {

@@ -1336,3 +1283,3 @@ var _this;

_classCallCheck(this, DatagramPlugin);
_this = _super.call(this);
_this = _callSuper(this, DatagramPlugin);
if (!dgram__default["default"]) {

@@ -1353,3 +1300,4 @@ throw new Error('DatagramPlugin can not be used in browser context');

}
_createClass(DatagramPlugin, [{
_inherits(DatagramPlugin, _Plugin);
return _createClass(DatagramPlugin, [{
key: "registerNotify",

@@ -1371,3 +1319,3 @@ value: function registerNotify(fn) {

var port = options.port,
exclusive = options.exclusive;
exclusive = options.exclusive;
this.socketStatus = STATUS$4.IS_CONNECTING;

@@ -1399,7 +1347,6 @@ this.socket.bind({

var port = options.port,
host = options.host;
host = options.host;
this.socket.send(Buffer.from(binary), 0, binary.byteLength, port, host);
}
}]);
return DatagramPlugin;
}(Plugin);

@@ -1438,4 +1385,2 @@

var BridgePlugin = function (_Plugin) {
_inherits(BridgePlugin, _Plugin);
var _super = _createSuper(BridgePlugin);
function BridgePlugin() {

@@ -1445,3 +1390,3 @@ var _this;

_classCallCheck(this, BridgePlugin);
_this = _super.call(this);
_this = _callSuper(this, BridgePlugin);
if (!dgram__default["default"] || !WebSocket.WebSocketServer) {

@@ -1466,3 +1411,4 @@ throw new Error('BridgePlugin can not be used in browser context');

}
_createClass(BridgePlugin, [{
_inherits(BridgePlugin, _Plugin);
return _createClass(BridgePlugin, [{
key: "registerNotify",

@@ -1546,3 +1492,2 @@ value: function registerNotify(fn) {

}]);
return BridgePlugin;
}(Plugin);

@@ -1564,8 +1509,6 @@

var WebsocketClientPlugin = function (_Plugin) {
_inherits(WebsocketClientPlugin, _Plugin);
var _super = _createSuper(WebsocketClientPlugin);
function WebsocketClientPlugin(options) {
var _this;
_classCallCheck(this, WebsocketClientPlugin);
_this = _super.call(this);
_this = _callSuper(this, WebsocketClientPlugin);
if (!WebSocket__default["default"]) {

@@ -1580,3 +1523,4 @@ throw new Error('WebsocketClientPlugin can\'t find a WebSocket class');

}
_createClass(WebsocketClientPlugin, [{
_inherits(WebsocketClientPlugin, _Plugin);
return _createClass(WebsocketClientPlugin, [{
key: "registerNotify",

@@ -1598,5 +1542,5 @@ value: function registerNotify(fn) {

var port = options.port,
host = options.host,
secure = options.secure,
protocol = options.protocol;
host = options.host,
secure = options.secure,
protocol = options.protocol;
if (this.socket) {

@@ -1642,3 +1586,2 @@ this.close();

}]);
return WebsocketClientPlugin;
}(Plugin);

@@ -1658,8 +1601,6 @@

var WebsocketServerPlugin = function (_Plugin) {
_inherits(WebsocketServerPlugin, _Plugin);
var _super = _createSuper(WebsocketServerPlugin);
function WebsocketServerPlugin(options) {
var _this;
_classCallCheck(this, WebsocketServerPlugin);
_this = _super.call(this);
_this = _callSuper(this, WebsocketServerPlugin);
if (!WebSocket.WebSocketServer) {

@@ -1674,3 +1615,4 @@ throw new Error('WebsocketServerPlugin can not be used in browser context');

}
_createClass(WebsocketServerPlugin, [{
_inherits(WebsocketServerPlugin, _Plugin);
return _createClass(WebsocketServerPlugin, [{
key: "registerNotify",

@@ -1692,3 +1634,3 @@ value: function registerNotify(fn) {

var port = options.port,
host = options.host;
host = options.host;
var rinfo = {

@@ -1748,8 +1690,6 @@ address: host,

}]);
return WebsocketServerPlugin;
}(Plugin);
var defaultOptions = {
discardLateMessages: false,
plugin: new WebsocketClientPlugin()
discardLateMessages: false
};

@@ -1770,2 +1710,5 @@ var STATUS = {

this.options = _objectSpread2(_objectSpread2({}, defaultOptions), options);
if (!this.options.plugin) {
this.options.plugin = new WebsocketClientPlugin();
}
this.eventHandler = new EventHandler({

@@ -1781,3 +1724,3 @@ discardLateMessages: this.options.discardLateMessages

}
_createClass(OSC, [{
return _createClass(OSC, [{
key: "on",

@@ -1840,3 +1783,2 @@ value: function on(eventName, callback) {

}]);
return OSC;
}();

@@ -1843,0 +1785,0 @@ OSC.STATUS = STATUS;

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).OSC=e()}(this,(function(){"use strict";function t(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function e(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function o(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&u(t,e)}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}function c(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=a(t);if(e){var o=a(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return c(this,n)}}function l(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=a(t)););return t}function h(){return h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=l(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},h.apply(this,arguments)}function p(t){return Number(t)===t&&t%1==0}function d(t){return Number(t)===t}function v(t){return"string"==typeof t}function w(t){return"boolean"==typeof t}function y(t){return t===1/0}function g(t){return"[object Array]"===Object.prototype.toString.call(t)}function k(t){return"[object Object]"===Object.prototype.toString.call(t)}function b(t){return"function"==typeof t}function m(t){return t instanceof Uint8Array}function S(t){return t instanceof Date}function E(t){return void 0===t}function O(t){return null===t}function C(t){return t+3&-4}function P(t){return Object.prototype.hasOwnProperty.call("undefined"!=typeof global?global:window,t)}function A(t){return t.buffer?new DataView(t.buffer):t instanceof ArrayBuffer?new DataView(t):new DataView(new Uint8Array(t))}function I(t){if(p(t))return"i";if(e=t,Number(e)===e&&e%1!=0)return"f";if(v(t))return"s";if(m(t))return"b";if(w(t))return t?"T":"F";if(O(t))return"N";if(y(t))return"I";var e;throw new Error("OSC typeTag() found unknown value type")}function D(t){var e="";if(g(t))return"/".concat(t.join("/"));if(v(t))return(e=t).length>1&&"/"===e[e.length-1]&&(e=e.slice(0,e.length-1)),e.length>1&&"/"!==e[0]&&(e="/".concat(e)),e;throw new Error("OSC prepareAddress() needs addresses of type array or string")}function j(t){if(!v(t))throw new Error("OSC prepareRegExPattern() needs strings");return t.replace(/\./g,"\\.").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!/g,"[^").replace(/\?/g,".").replace(/\*/g,".*")}var B=function(){function t(){n(this,t),this.data=[],this.byteLength=0}return o(t,[{key:"add",value:function(t){if(w(t)||y(t)||O(t))return this;var e=t.pack();return this.byteLength+=e.byteLength,this.data.push(e),this}},{key:"merge",value:function(){var t=new Uint8Array(this.byteLength),e=0;return this.data.forEach((function(n){t.set(n,e),e+=n.byteLength})),t}}]),t}(),x=function(){function t(e){n(this,t),this.value=e,this.offset=0}return o(t,[{key:"pack",value:function(t,e){if(!t||!e)throw new Error("OSC Atomic cant't be packed without given method or byteLength");var n=new Uint8Array(e),r=new DataView(n.buffer);if(E(this.value))throw new Error("OSC Atomic cant't be encoded with empty value");return r[t](this.offset,this.value,!1),n}},{key:"unpack",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!(t&&e&&n))throw new Error("OSC Atomic cant't be unpacked without given dataView, method or byteLength");if(!(t instanceof DataView))throw new Error("OSC Atomic expects an instance of type DataView");return this.value=t[e](r,!1),this.offset=r+n,this.offset}}]),t}(),H=function(t){s(r,t);var e=f(r);function r(t){if(n(this,r),t&&!p(t))throw new Error("OSC AtomicInt32 constructor expects value of type number");return e.call(this,t)}return o(r,[{key:"pack",value:function(){return h(a(r.prototype),"pack",this).call(this,"setInt32",4)}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return h(a(r.prototype),"unpack",this).call(this,t,"getInt32",4,e)}}]),r}(x),M="utf-8";function T(t){if(P("Buffer"))return Buffer.from(t).toString(M);if(P("TextDecoder"))return new TextDecoder(M).decode(new Int8Array(t));for(var e="",n=0;n<t.length;n+=65537)e+=String.fromCharCode.apply(null,t.slice(n,n+65537));return e}var L=function(t){s(r,t);var e=f(r);function r(t){if(n(this,r),t&&!v(t))throw new Error("OSC AtomicString constructor expects value of type string");return e.call(this,t)}return o(r,[{key:"pack",value:function(){if(E(this.value))throw new Error("OSC AtomicString can not be encoded with empty value");for(var t="".concat(this.value,"\0"),e=C(t.length),n=new Uint8Array(e),r=0;r<t.length;r+=1)n[r]=t.charCodeAt(r);return n}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!(t instanceof DataView))throw new Error("OSC AtomicString expects an instance of type DataView");for(var n,r=e,o=[];r<t.byteLength;r+=1){if(0===(n=t.getUint8(r))){r+=1;break}o.push(n)}if(r===t.length)throw new Error("OSC AtomicString found a malformed OSC string");return this.offset=C(r),this.value=T(o),this.offset}}]),r}(x),N=2208988800,V=4294967296,U=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(n(this,t),!p(e)||!p(r))throw new Error("OSC Timetag constructor expects values of type integer number");this.seconds=e,this.fractions=r}return o(t,[{key:"timestamp",value:function(t){var e;if("number"==typeof t){e=t/1e3;var n=Math.floor(e);return this.seconds=n+N,this.fractions=Math.round(V*(e-n)),t}return 1e3*((e=this.seconds-N)+Math.round(this.fractions/V))}}]),t}(),W=function(t){s(r,t);var e=f(r);function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now();n(this,r);var o=new U;return t instanceof U?o=t:p(t)?o.timestamp(t):S(t)&&o.timestamp(t.getTime()),e.call(this,o)}return o(r,[{key:"pack",value:function(){if(E(this.value))throw new Error("OSC AtomicTimetag can not be encoded with empty value");var t=this.value,e=t.seconds,n=t.fractions,r=new Uint8Array(8),o=new DataView(r.buffer);return o.setInt32(0,e,!1),o.setInt32(4,n,!1),r}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!(t instanceof DataView))throw new Error("OSC AtomicTimetag expects an instance of type DataView");var n=t.getUint32(e,!1),r=t.getUint32(e+4,!1);return this.value=new U(n,r),this.offset=e+8,this.offset}}]),r}(x),_=function(t){s(r,t);var e=f(r);function r(t){if(n(this,r),t&&!m(t))throw new Error("OSC AtomicBlob constructor expects value of type Uint8Array");return e.call(this,t)}return o(r,[{key:"pack",value:function(){if(E(this.value))throw new Error("OSC AtomicBlob can not be encoded with empty value");var t=C(this.value.byteLength),e=new Uint8Array(t+4);return new DataView(e.buffer).setInt32(0,this.value.byteLength,!1),e.set(this.value,4),e}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!(t instanceof DataView))throw new Error("OSC AtomicBlob expects an instance of type DataView");var n=t.getInt32(e,!1);return this.value=new Uint8Array(t.buffer,e+4,n),this.offset=C(e+4+n),this.offset}}]),r}(x),R=function(t){s(r,t);var e=f(r);function r(t){if(n(this,r),t&&!d(t))throw new Error("OSC AtomicFloat32 constructor expects value of type float");return e.call(this,t)}return o(r,[{key:"pack",value:function(){return h(a(r.prototype),"pack",this).call(this,"setFloat32",4)}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return h(a(r.prototype),"unpack",this).call(this,t,"getFloat32",4,e)}}]),r}(x),F=function(t){s(r,t);var e=f(r);function r(t){if(n(this,r),t&&!d(t))throw new Error("OSC AtomicFloat64 constructor expects value of type float");return e.call(this,t)}return o(r,[{key:"pack",value:function(){return h(a(r.prototype),"pack",this).call(this,"setFloat64",8)}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return h(a(r.prototype),"unpack",this).call(this,t,"getFloat64",8,e)}}]),r}(x),z=BigInt("9223372036854775807"),G=BigInt("-9223372036854775808"),Z=function(t){s(r,t);var e=f(r);function r(t){if(n(this,r),t&&"bigint"!=typeof t)throw new Error("OSC AtomicInt64 constructor expects value of type BigInt");if(t&&(t<G||t>z))throw new Error("OSC AtomicInt64 value is out of bounds");var o;return t&&(o=BigInt.asIntN(64,t)),e.call(this,o)}return o(r,[{key:"pack",value:function(){return h(a(r.prototype),"pack",this).call(this,"setBigInt64",8)}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return h(a(r.prototype),"unpack",this).call(this,t,"getBigInt64",8,e)}}]),r}(x),q=BigInt("18446744073709551615"),J=function(t){s(r,t);var e=f(r);function r(t){if(n(this,r),t&&"bigint"!=typeof t)throw new Error("OSC AtomicUInt64 constructor expects value of type BigInt");if(t&&(t<0||t>q))throw new Error("OSC AtomicUInt64 value is out of bounds");var o;return t&&(o=BigInt.asUintN(64,t)),e.call(this,o)}return o(r,[{key:"pack",value:function(){return h(a(r.prototype),"pack",this).call(this,"setBigUint64",8)}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return h(a(r.prototype),"unpack",this).call(this,t,"getBigUint64",8,e)}}]),r}(x),K=!0,Q=!1,X=null,Y=1/0,$=function(){function t(e,r){var o=this;if(n(this,t),this.offset=0,this.address="",this.types="",this.args=[],!E(e)){if(!v(e)&&!g(e))throw new Error("OSC Message constructor first argument (address) must be a string or array");this.address=D(e)}if(!E(r)){if(!g(r))throw new Error("OSC Message constructor second argument (args) must be an array");r.forEach((function(t){return o.add(t.type,t.value)}))}}return o(t,[{key:"add",value:function(t,e){if(E(t))throw new Error("OSC Message needs a valid OSC Atomic Data Type");"N"===t?this.args.push(X):"T"===t?this.args.push(K):"F"===t?this.args.push(Q):"I"===t?this.args.push(Y):this.args.push(e),this.types+=t}},{key:"pack",value:function(){var t=this;if(0===this.address.length||"/"!==this.address[0])throw new Error("OSC Message has an invalid address");var e=new B;if(e.add(new L(this.address)),e.add(new L(",".concat(this.types))),this.args.length>0){var n;if(this.args.length>this.types.length)throw new Error("OSC Message argument and type tag mismatch");this.args.forEach((function(r,o){var i=t.types[o];if("i"===i)n=new H(r);else if("h"===i)n=new Z(r);else if("t"===i)n=new J(r);else if("f"===i)n=new R(r);else if("d"===i)n=new F(r);else if("s"===i)n=new L(r);else if("b"===i)n=new _(r);else if("T"===i)n=K;else if("F"===i)n=Q;else if("N"===i)n=X;else{if("I"!==i)throw new Error("OSC Message found unknown argument type");n=Y}e.add(n)}))}return e.merge()}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!(t instanceof DataView))throw new Error("OSC Message expects an instance of type DataView.");var n=new L;n.unpack(t,e);var r=new L;if(r.unpack(t,n.offset),0===n.value.length||"/"!==n.value[0])throw new Error("OSC Message found malformed or missing address string");if(0===r.value.length&&","!==r.value[0])throw new Error("OSC Message found malformed or missing type string");for(var o,i,s=r.offset,a=[],u=1;u<r.value.length;u+=1){if(o=null,"i"===(i=r.value[u]))o=new H;else if("h"===i)o=new Z;else if("t"===i)o=new J;else if("f"===i)o=new R;else if("d"===i)o=new F;else if("s"===i)o=new L;else if("b"===i)o=new _;else if("T"===i)a.push(K);else if("F"===i)a.push(Q);else if("N"===i)a.push(X);else{if("I"!==i)throw new Error("OSC Message found unsupported argument type");a.push(Y)}o&&(s=o.unpack(t,s),a.push(o.value))}return this.offset=s,this.address=n.value,this.types=r.value,this.args=a,this.offset}}]),t}(),tt=function(t){s(r,t);var e=f(r);function r(t){var o,i;n(this,r);for(var s=arguments.length,a=new Array(s>1?s-1:0),u=1;u<s;u++)a[u-1]=arguments[u];return a.length>0&&a[0]instanceof Array&&(i=a.shift()),o=e.call(this,t,i),a.length>0&&(o.types=a.map((function(t){return I(t)})).join(""),o.args=a),o}return o(r,[{key:"add",value:function(t){h(a(r.prototype),"add",this).call(this,I(t),t)}}]),r}($),et="#bundle",nt=function(){function t(){var e=this;n(this,t),this.offset=0,this.timetag=new W,this.bundleElements=[];for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];o.length>0&&(o[0]instanceof Date||p(o[0])?this.timetag=new W(o[0]):g(o[0])?(o[0].forEach((function(t){e.add(t)})),o.length>1&&(o[1]instanceof Date||p(o[1]))&&(this.timetag=new W(o[1]))):o.forEach((function(t){e.add(t)})))}return o(t,[{key:"timestamp",value:function(t){if(!p(t))throw new Error("OSC Bundle needs an integer for setting the timestamp");this.timetag=new W(t)}},{key:"add",value:function(e){if(!(e instanceof tt||e instanceof t))throw new Error("OSC Bundle contains only Messages and Bundles");this.bundleElements.push(e)}},{key:"pack",value:function(){var t=new B;return t.add(new L(et)),this.timetag||(this.timetag=new W),t.add(this.timetag),this.bundleElements.forEach((function(e){t.add(new H(e.pack().byteLength)),t.add(e)})),t.merge()}},{key:"unpack",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!(e instanceof DataView))throw new Error("OSC Bundle expects an instance of type DataView");var r=new L;if(r.unpack(e,n),r.value!==et)throw new Error("OSC Bundle does not contain a valid #bundle head");var o=new W,i=o.unpack(e,r.offset);for(this.bundleElements=[];i<e.byteLength;){var s=new L,a=new H;i=a.unpack(e,i);var u=void 0;s.unpack(e,i),i=(u=s.value===et?new t:new tt).unpack(e,i),this.bundleElements.push(u)}return this.offset=i,this.timetag=o,this.offset}}]),t}(),rt=function(){function t(e){if(n(this,t),e&&!(e instanceof tt||e instanceof nt))throw new Error("OSC Packet value has to be Message or Bundle");this.value=e,this.offset=0}return o(t,[{key:"pack",value:function(){if(!this.value)throw new Error("OSC Packet can not be encoded with empty body");return this.value.pack()}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!(t instanceof DataView))throw new Error("OSC Packet expects an instance of type DataView");if(t.byteLength%4!=0)throw new Error("OSC Packet byteLength has to be a multiple of four");var n,r=new L;return r.unpack(t,e),(n=r.value===et?new nt:new tt).unpack(t,e),this.offset=n.offset,this.value=n,this.offset}}]),t}(),ot={discardLateMessages:!1},it=function(){function t(r){n(this,t),this.options=e(e({},ot),r),this.addressHandlers=[],this.eventHandlers={open:[],error:[],close:[]},this.uuid=0}return o(t,[{key:"dispatch",value:function(t,e){var n=this;if(!(t instanceof rt))throw new Error("OSC EventHander dispatch() accepts only arguments of type Packet");if(!t.value)throw new Error("OSC EventHander dispatch() can't read empty Packets");if(t.value instanceof nt){var r=t.value;return r.bundleElements.forEach((function(t){if(t instanceof nt){if(r.timetag.value.timestamp()<t.timetag.value.timestamp())throw new Error("OSC Bundle timestamp is older than the timestamp of enclosed Bundles");return n.dispatch(t)}if(t instanceof tt){var o=t;return n.notify(o.address,o,r.timetag.value.timestamp(),e)}throw new Error("OSC EventHander dispatch() can't dispatch unknown Packet value")}))}if(t.value instanceof tt){var o=t.value;return this.notify(o.address,o,0,e)}throw new Error("OSC EventHander dispatch() can't dispatch unknown Packet value")}},{key:"call",value:function(t,e,n){var r=!1;if(v(t)&&t in this.eventHandlers)return this.eventHandlers[t].forEach((function(t){t.callback(e,n),r=!0})),r;var o=Object.keys(this.addressHandlers),i=this.addressHandlers;return o.forEach((function(o){var s=!1,a=new RegExp(j(D(t)),"g");if(a.test(o)&&o.length===a.lastIndex&&(s=!0),!s){var u=new RegExp(j(D(o)),"g");u.test(t)&&t.length===u.lastIndex&&(s=!0)}s&&i[o].forEach((function(t){t.callback(e,n),r=!0}))})),r}},{key:"notify",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];if(0===e.length)throw new Error("OSC EventHandler can not be called without any argument");if(e[0]instanceof rt)return this.dispatch(e[0],e[1]);if(e[0]instanceof nt||e[0]instanceof tt)return this.dispatch(new rt(e[0]),e[1]);if(!v(e[0])){var r=new rt;return r.unpack(A(e[0])),this.dispatch(r,e[1])}var o=e[0],i=null;e.length>1&&(i=e[1]);var s=null;if(e.length>2)if(p(e[2]))s=e[2];else{if(!(e[2]instanceof Date))throw new Error("OSC EventHandler timestamp has to be a number or Date");s=e[2].getTime()}var a=null;if(e.length>=3&&(a=e[3]),s){var u=Date.now();if(u>s&&!this.options.discardLateMessages)return this.call(o,i,a);var c=this;return setTimeout((function(){c.call(o,i,a)}),s-u),!0}return this.call(o,i,a)}},{key:"on",value:function(t,e){if(!v(t)&&!g(t))throw new Error("OSC EventHandler accepts only strings or arrays for address patterns");if(!b(e))throw new Error("OSC EventHandler callback has to be a function");this.uuid+=1;var n={id:this.uuid,callback:e};if(v(t)&&t in this.eventHandlers)return this.eventHandlers[t].push(n),this.uuid;var r=D(t);return r in this.addressHandlers||(this.addressHandlers[r]=[]),this.addressHandlers[r].push(n),this.uuid}},{key:"off",value:function(t,e){if(!v(t)&&!g(t))throw new Error("OSC EventHandler accepts only strings or arrays for address patterns");if(!p(e))throw new Error("OSC EventHandler subscription id has to be a number");var n,r;return v(t)&&t in this.eventHandlers?(n=t,r=this.eventHandlers):(n=D(t),r=this.addressHandlers),n in r&&r[n].some((function(t,o){return t.id===e&&(r[n].splice(o,1),!0)}))}}]),t}(),st=function(){function t(){if(n(this,t),this.constructor===t)throw new Error("Plugin is an abstract class. Please create or use an implementation!")}return o(t,[{key:"status",value:function(){throw new Error("Abstract method!")}},{key:"open",value:function(){throw new Error("Abstract method!")}},{key:"close",value:function(){throw new Error("Abstract method!")}},{key:"send",value:function(t){throw new Error("Abstract method!")}}]),t}(),at=0,ut=1,ct=2,ft=3,lt=function(t){s(i,t);var r=f(i);function i(){throw n(this,i),r.call(this),new Error("DatagramPlugin can not be used in browser context")}return o(i,[{key:"registerNotify",value:function(t){this.notify=t}},{key:"status",value:function(){return this.socketStatus}},{key:"open",value:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e(e({},this.options.open),n),o=r.port,i=r.exclusive;this.socketStatus=at,this.socket.bind({address:r.host,port:o,exclusive:i},(function(){t.socketStatus=ut,t.notify("open")}))}},{key:"close",value:function(){var t=this;this.socketStatus=ct,this.socket.close((function(){t.socketStatus=ft,t.notify("close")}))}},{key:"send",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e(e({},this.options.send),n),o=r.port,i=r.host;this.socket.send(Buffer.from(t),0,t.byteLength,o,i)}}]),i}(st);var ht="undefined"!=typeof WebSocket?WebSocket:"undefined"!=typeof MozWebSocket?MozWebSocket:"undefined"!=typeof global?global.WebSocket||global.MozWebSocket:"undefined"!=typeof window?window.WebSocket||window.MozWebSocket:"undefined"!=typeof self?self.WebSocket||self.MozWebSocket:void 0,pt=void 0,dt=0,vt=1,wt=2,yt=3,gt={udpServer:{host:"localhost",port:41234,exclusive:!1},udpClient:{host:"localhost",port:41235},wsServer:{host:"localhost",port:8080},receiver:"ws"};function kt(t,n){return e(e(e(e({},gt),t),n),{},{udpServer:e(e(e({},gt.udpServer),t.udpServer),n.udpServer),udpClient:e(e(e({},gt.udpClient),t.udpClient),n.udpClient),wsServer:e(e(e({},gt.wsServer),t.wsServer),n.wsServer)})}var bt=function(t){s(r,t);var e=f(r);function r(){throw n(this,r),e.call(this),new Error("BridgePlugin can not be used in browser context")}return o(r,[{key:"registerNotify",value:function(t){this.notify=t}},{key:"status",value:function(){return this.socketStatus}},{key:"open",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=kt(this.options,e);this.socketStatus=dt,this.socket.bind({address:n.udpServer.host,port:n.udpServer.port,exclusive:n.udpServer.exclusive},(function(){var e={};n.wsServer.server?e.server=n.wsServer.server:e=n.wsServer,t.websocket=new pt(e),t.websocket.binaryType="arraybuffer",t.websocket.on("listening",(function(){t.socketStatus=vt,t.notify("open")})),t.websocket.on("error",(function(e){t.notify("error",e)})),t.websocket.on("connection",(function(e){e.on("message",(function(e,n){t.send(e,{receiver:"udp"}),t.notify(new Uint8Array(e),n)}))}))}))}},{key:"close",value:function(){var t=this;this.socketStatus=wt,this.socket.close((function(){t.websocket.close((function(){t.socketStatus=yt,t.notify("close")}))}))}},{key:"send",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=kt(this.options,e),r=n.receiver;if("udp"===r){var o=t instanceof Buffer?t:Buffer.from(t);this.socket.send(o,0,o.byteLength,n.udpClient.port,n.udpClient.host)}else{if("ws"!==r)throw new Error("BridgePlugin can not send message to unknown receiver");this.websocket.clients.forEach((function(e){e.send(t,{binary:!0})}))}}}]),r}(st),mt=-1,St=0,Et=1,Ot=2,Ct=3,Pt={host:"localhost",port:8080,secure:!1,protocol:[]},At=function(t){s(i,t);var r=f(i);function i(t){var o;if(n(this,i),o=r.call(this),!ht)throw new Error("WebsocketClientPlugin can't find a WebSocket class");return o.options=e(e({},Pt),t),o.socket=null,o.socketStatus=mt,o.notify=function(){},o}return o(i,[{key:"registerNotify",value:function(t){this.notify=t}},{key:"status",value:function(){return this.socketStatus}},{key:"open",value:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e(e({},this.options),n),o=r.port,i=r.host,s=r.secure,a=r.protocol;this.socket&&this.close();var u=s?"wss":"ws",c={address:i,family:u,port:o,size:0};this.socket=new ht("".concat(u,"://").concat(i,":").concat(o),a),this.socket.binaryType="arraybuffer",this.socketStatus=St,this.socket.onopen=function(){t.socketStatus=Et,t.notify("open")},this.socket.onclose=function(){t.socketStatus=Ct,t.notify("close")},this.socket.onerror=function(e){t.notify("error",e)},this.socket.onmessage=function(e){t.notify(e.data,c)}}},{key:"close",value:function(){this.socketStatus=Ot,this.socket.close()}},{key:"send",value:function(t){this.socket.send(t)}}]),i}(st),It=0,Dt=1,jt=2,Bt=3,xt=function(t){s(i,t);var r=f(i);function i(t){throw n(this,i),r.call(this),new Error("WebsocketServerPlugin can not be used in browser context")}return o(i,[{key:"registerNotify",value:function(t){this.notify=t}},{key:"status",value:function(){return this.socketStatus}},{key:"open",value:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e(e({},this.options),n),o=r.port,i=r.host,s={address:i,family:"wsserver",port:o,size:0};this.socket&&this.close(),r.server?this.socket=new pt({server:r.server}):this.socket=new pt({host:i,port:o}),this.socket.binaryType="arraybuffer",this.socketStatus=It,this.socket.on("listening",(function(){t.socketStatus=Dt,t.notify("open")})),this.socket.on("error",(function(e){t.notify("error",e)})),this.socket.on("connection",(function(e){e.on("message",(function(e){t.notify(new Uint8Array(e),s)}))}))}},{key:"close",value:function(){var t=this;this.socketStatus=jt,this.socket.close((function(){t.socketStatus=Bt,t.notify("close")}))}},{key:"send",value:function(t){this.socket.clients.forEach((function(e){e.send(t,{binary:!0})}))}}]),i}(st),Ht={discardLateMessages:!1,plugin:new At},Mt=function(){function t(r){if(n(this,t),r&&!k(r))throw new Error("OSC options argument has to be an object.");this.options=e(e({},Ht),r),this.eventHandler=new it({discardLateMessages:this.options.discardLateMessages});var o=this.eventHandler;this.options.plugin&&this.options.plugin.registerNotify&&this.options.plugin.registerNotify((function(){return o.notify.apply(o,arguments)}))}return o(t,[{key:"on",value:function(t,e){if(!v(t)||!b(e))throw new Error("OSC on() needs event- or address string and callback function");return this.eventHandler.on(t,e)}},{key:"off",value:function(t,e){if(!v(t)||!p(e))throw new Error("OSC off() needs string and number (subscriptionId) to unsubscribe");return this.eventHandler.off(t,e)}},{key:"open",value:function(t){if(t&&!k(t))throw new Error("OSC open() options argument needs to be an object");if(!this.options.plugin||!b(this.options.plugin.open))throw new Error("OSC Plugin API #open is not implemented!");return this.options.plugin.open(t)}},{key:"status",value:function(){if(!this.options.plugin||!b(this.options.plugin.status))throw new Error("OSC Plugin API #status is not implemented!");return this.options.plugin.status()}},{key:"close",value:function(){if(!this.options.plugin||!b(this.options.plugin.close))throw new Error("OSC Plugin API #close is not implemented!");return this.options.plugin.close()}},{key:"send",value:function(t,e){if(!this.options.plugin||!b(this.options.plugin.send))throw new Error("OSC Plugin API #send is not implemented!");if(!(t instanceof $||t instanceof tt||t instanceof nt||t instanceof rt))throw new Error("OSC send() needs Messages, Bundles or Packets");if(e&&!k(e))throw new Error("OSC send() options argument has to be an object");return this.options.plugin.send(t.pack(),e)}}]),t}();return Mt.STATUS={IS_NOT_INITIALIZED:-1,IS_CONNECTING:0,IS_OPEN:1,IS_CLOSING:2,IS_CLOSED:3},Mt.Packet=rt,Mt.Bundle=nt,Mt.Message=tt,Mt.TypedMessage=$,Mt.Plugin=st,Mt.DatagramPlugin=lt,Mt.WebsocketClientPlugin=At,Mt.WebsocketServerPlugin=xt,Mt.BridgePlugin=bt,Mt}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).OSC=e()}(this,(function(){"use strict";function t(t,n,r){return n=f(n),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,e()?Reflect.construct(n,r||[],f(t).constructor):n.apply(t,r))}function e(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(e=function(){return!!t})()}function n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function r(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){u(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,o(r.key),r)}}function a(t,e,n){return e&&s(t.prototype,e),n&&s(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(t,e,n){return(e=o(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&l(t,e)}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function l(t,e){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},l(t,e)}function h(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=f(t)););return t}function p(){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=h(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},p.apply(this,arguments)}function d(t){return Number(t)===t&&t%1==0}function v(t){return Number(t)===t}function w(t){return"string"==typeof t}function y(t){return"boolean"==typeof t}function g(t){return t===1/0}function k(t){return"[object Array]"===Object.prototype.toString.call(t)}function b(t){return"[object Object]"===Object.prototype.toString.call(t)}function m(t){return"function"==typeof t}function S(t){return t instanceof Uint8Array}function E(t){return t instanceof Date}function O(t){return void 0===t}function C(t){return null===t}function P(t){return t+3&-4}function A(t){return Object.prototype.hasOwnProperty.call("undefined"!=typeof global?global:window,t)}function I(t){return t.buffer?new DataView(t.buffer):t instanceof ArrayBuffer?new DataView(t):new DataView(new Uint8Array(t))}function j(t){if(d(t))return"i";if(e=t,Number(e)===e&&e%1!=0)return"f";if(w(t))return"s";if(S(t))return"b";if(y(t))return t?"T":"F";if(C(t))return"N";if(g(t))return"I";var e;throw new Error("OSC typeTag() found unknown value type")}function D(t){var e="";if(k(t))return"/".concat(t.join("/"));if(w(t))return(e=t).length>1&&"/"===e[e.length-1]&&(e=e.slice(0,e.length-1)),e.length>1&&"/"!==e[0]&&(e="/".concat(e)),e;throw new Error("OSC prepareAddress() needs addresses of type array or string")}function B(t){if(!w(t))throw new Error("OSC prepareRegExPattern() needs strings");return t.replace(/\./g,"\\.").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!/g,"[^").replace(/\?/g,".").replace(/\*/g,".*")}var M=a((function t(){i(this,t),this.data=[],this.byteLength=0}),[{key:"add",value:function(t){if(y(t)||g(t)||C(t))return this;var e=t.pack();return this.byteLength+=e.byteLength,this.data.push(e),this}},{key:"merge",value:function(){var t=new Uint8Array(this.byteLength),e=0;return this.data.forEach((function(n){t.set(n,e),e+=n.byteLength})),t}}]),x=a((function t(e){i(this,t),this.value=e,this.offset=0}),[{key:"pack",value:function(t,e){if(!t||!e)throw new Error("OSC Atomic cant't be packed without given method or byteLength");var n=new Uint8Array(e),r=new DataView(n.buffer);if(O(this.value))throw new Error("OSC Atomic cant't be encoded with empty value");return r[t](this.offset,this.value,!1),n}},{key:"unpackWithMethod",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!(t&&e&&n))throw new Error("OSC Atomic cant't be unpacked without given dataView, method or byteLength");if(!(t instanceof DataView))throw new Error("OSC Atomic expects an instance of type DataView");return this.value=t[e](r,!1),this.offset=r+n,this.offset}}]),T=function(e){function n(e){if(i(this,n),e&&!d(e))throw new Error("OSC AtomicInt32 constructor expects value of type number");return t(this,n,[e])}return c(n,e),a(n,[{key:"pack",value:function(){return p(f(n.prototype),"pack",this).call(this,"setInt32",4)}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return p(f(n.prototype),"unpackWithMethod",this).call(this,t,"getInt32",4,e)}}])}(x),H="utf-8";function L(t){if(A("Buffer"))return Buffer.from(t).toString(H);if(A("TextDecoder"))return new TextDecoder(H).decode(new Int8Array(t));for(var e="",n=0;n<t.length;n+=65537)e+=String.fromCharCode.apply(null,t.slice(n,n+65537));return e}var N=function(e){function n(e){if(i(this,n),e&&!w(e))throw new Error("OSC AtomicString constructor expects value of type string");return t(this,n,[e])}return c(n,e),a(n,[{key:"pack",value:function(){if(O(this.value))throw new Error("OSC AtomicString can not be encoded with empty value");for(var t="".concat(this.value,"\0"),e=P(t.length),n=new Uint8Array(e),r=0;r<t.length;r+=1)n[r]=t.charCodeAt(r);return n}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!(t instanceof DataView))throw new Error("OSC AtomicString expects an instance of type DataView");for(var n,r=e,o=[];r<t.byteLength;r+=1){if(0===(n=t.getUint8(r))){r+=1;break}o.push(n)}if(r===t.length)throw new Error("OSC AtomicString found a malformed OSC string");return this.offset=P(r),this.value=L(o),this.offset}}])}(x),V=2208988800,W=4294967296,U=a((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(i(this,t),!d(e)||!d(n))throw new Error("OSC Timetag constructor expects values of type integer number");this.seconds=e,this.fractions=n}),[{key:"timestamp",value:function(t){var e;if("number"==typeof t){e=t/1e3;var n=Math.floor(e);return this.seconds=n+V,this.fractions=Math.round(W*(e-n)),t}return 1e3*((e=this.seconds-V)+Math.round(this.fractions/W))}}]),_=function(e){function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now();i(this,n);var r=new U;return e instanceof U?r=e:d(e)?r.timestamp(e):E(e)&&r.timestamp(e.getTime()),t(this,n,[r])}return c(n,e),a(n,[{key:"pack",value:function(){if(O(this.value))throw new Error("OSC AtomicTimetag can not be encoded with empty value");var t=this.value,e=t.seconds,n=t.fractions,r=new Uint8Array(8),o=new DataView(r.buffer);return o.setInt32(0,e,!1),o.setInt32(4,n,!1),r}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!(t instanceof DataView))throw new Error("OSC AtomicTimetag expects an instance of type DataView");var n=t.getUint32(e,!1),r=t.getUint32(e+4,!1);return this.value=new U(n,r),this.offset=e+8,this.offset}}])}(x),F=function(e){function n(e){if(i(this,n),e&&!S(e))throw new Error("OSC AtomicBlob constructor expects value of type Uint8Array");return t(this,n,[e])}return c(n,e),a(n,[{key:"pack",value:function(){if(O(this.value))throw new Error("OSC AtomicBlob can not be encoded with empty value");var t=P(this.value.byteLength),e=new Uint8Array(t+4);return new DataView(e.buffer).setInt32(0,this.value.byteLength,!1),e.set(this.value,4),e}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!(t instanceof DataView))throw new Error("OSC AtomicBlob expects an instance of type DataView");var n=t.getInt32(e,!1);return this.value=new Uint8Array(t.buffer,e+4,n),this.offset=P(e+4+n),this.offset}}])}(x),R=function(e){function n(e){if(i(this,n),e&&!v(e))throw new Error("OSC AtomicFloat32 constructor expects value of type float");return t(this,n,[e])}return c(n,e),a(n,[{key:"pack",value:function(){return p(f(n.prototype),"pack",this).call(this,"setFloat32",4)}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return p(f(n.prototype),"unpackWithMethod",this).call(this,t,"getFloat32",4,e)}}])}(x),z=function(e){function n(e){if(i(this,n),e&&!v(e))throw new Error("OSC AtomicFloat64 constructor expects value of type float");return t(this,n,[e])}return c(n,e),a(n,[{key:"pack",value:function(){return p(f(n.prototype),"pack",this).call(this,"setFloat64",8)}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return p(f(n.prototype),"unpackWithMethod",this).call(this,t,"getFloat64",8,e)}}])}(x),G=BigInt("9223372036854775807"),Z=BigInt("-9223372036854775808"),q=function(e){function n(e){if(i(this,n),e&&"bigint"!=typeof e)throw new Error("OSC AtomicInt64 constructor expects value of type BigInt");if(e&&(e<Z||e>G))throw new Error("OSC AtomicInt64 value is out of bounds");var r;return e&&(r=BigInt.asIntN(64,e)),t(this,n,[r])}return c(n,e),a(n,[{key:"pack",value:function(){return p(f(n.prototype),"pack",this).call(this,"setBigInt64",8)}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return p(f(n.prototype),"unpackWithMethod",this).call(this,t,"getBigInt64",8,e)}}])}(x),J=BigInt("18446744073709551615"),K=function(e){function n(e){if(i(this,n),e&&"bigint"!=typeof e)throw new Error("OSC AtomicUInt64 constructor expects value of type BigInt");if(e&&(e<0||e>J))throw new Error("OSC AtomicUInt64 value is out of bounds");var r;return e&&(r=BigInt.asUintN(64,e)),t(this,n,[r])}return c(n,e),a(n,[{key:"pack",value:function(){return p(f(n.prototype),"pack",this).call(this,"setBigUint64",8)}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return p(f(n.prototype),"unpackWithMethod",this).call(this,t,"getBigUint64",8,e)}}])}(x),Q=!0,X=!1,Y=null,$=1/0,tt=a((function t(e,n){var r=this;if(i(this,t),this.offset=0,this.address="",this.types="",this.args=[],!O(e)){if(!w(e)&&!k(e))throw new Error("OSC Message constructor first argument (address) must be a string or array");this.address=D(e)}if(!O(n)){if(!k(n))throw new Error("OSC Message constructor second argument (args) must be an array");n.forEach((function(t){return r.add(t.type,t.value)}))}}),[{key:"add",value:function(t,e){if(O(t))throw new Error("OSC Message needs a valid OSC Atomic Data Type");"N"===t?this.args.push(Y):"T"===t?this.args.push(Q):"F"===t?this.args.push(X):"I"===t?this.args.push($):this.args.push(e),this.types+=t}},{key:"pack",value:function(){var t=this;if(0===this.address.length||"/"!==this.address[0])throw new Error("OSC Message has an invalid address");var e=new M;if(e.add(new N(this.address)),e.add(new N(",".concat(this.types))),this.args.length>0){var n;if(this.args.length>this.types.length)throw new Error("OSC Message argument and type tag mismatch");this.args.forEach((function(r,o){var i=t.types[o];if("i"===i)n=new T(r);else if("h"===i)n=new q(r);else if("t"===i)n=new K(r);else if("f"===i)n=new R(r);else if("d"===i)n=new z(r);else if("s"===i)n=new N(r);else if("b"===i)n=new F(r);else if("T"===i)n=Q;else if("F"===i)n=X;else if("N"===i)n=Y;else{if("I"!==i)throw new Error("OSC Message found unknown argument type");n=$}e.add(n)}))}return e.merge()}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!(t instanceof DataView))throw new Error("OSC Message expects an instance of type DataView.");var n=new N;n.unpack(t,e);var r=new N;if(r.unpack(t,n.offset),0===n.value.length||"/"!==n.value[0])throw new Error("OSC Message found malformed or missing address string");if(0===r.value.length&&","!==r.value[0])throw new Error("OSC Message found malformed or missing type string");for(var o,i,s=r.offset,a=[],u=1;u<r.value.length;u+=1){if(o=null,"i"===(i=r.value[u]))o=new T;else if("h"===i)o=new q;else if("t"===i)o=new K;else if("f"===i)o=new R;else if("d"===i)o=new z;else if("s"===i)o=new N;else if("b"===i)o=new F;else if("T"===i)a.push(Q);else if("F"===i)a.push(X);else if("N"===i)a.push(Y);else{if("I"!==i)throw new Error("OSC Message found unsupported argument type");a.push($)}o&&(s=o.unpack(t,s),a.push(o.value))}return this.offset=s,this.address=n.value,this.types=r.value,this.args=a,this.offset}}]),et=function(e){function n(e){var r,o;i(this,n);for(var s=arguments.length,a=new Array(s>1?s-1:0),u=1;u<s;u++)a[u-1]=arguments[u];return a.length>0&&a[0]instanceof Array&&(o=a.shift()),r=t(this,n,[e,o]),a.length>0&&(r.types=a.map((function(t){return j(t)})).join(""),r.args=a),r}return c(n,e),a(n,[{key:"add",value:function(t){p(f(n.prototype),"add",this).call(this,j(t),t)}}])}(tt),nt="#bundle",rt=function(){function t(){var e=this;i(this,t),this.offset=0,this.timetag=new _,this.bundleElements=[];for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];r.length>0&&(r[0]instanceof Date||d(r[0])?this.timetag=new _(r[0]):k(r[0])?(r[0].forEach((function(t){e.add(t)})),r.length>1&&(r[1]instanceof Date||d(r[1]))&&(this.timetag=new _(r[1]))):r.forEach((function(t){e.add(t)})))}return a(t,[{key:"timestamp",value:function(t){if(!d(t))throw new Error("OSC Bundle needs an integer for setting the timestamp");this.timetag=new _(t)}},{key:"add",value:function(e){if(!(e instanceof et||e instanceof t))throw new Error("OSC Bundle contains only Messages and Bundles");this.bundleElements.push(e)}},{key:"pack",value:function(){var t=new M;return t.add(new N(nt)),this.timetag||(this.timetag=new _),t.add(this.timetag),this.bundleElements.forEach((function(e){t.add(new T(e.pack().byteLength)),t.add(e)})),t.merge()}},{key:"unpack",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!(e instanceof DataView))throw new Error("OSC Bundle expects an instance of type DataView");var r=new N;if(r.unpack(e,n),r.value!==nt)throw new Error("OSC Bundle does not contain a valid #bundle head");var o=new _,i=o.unpack(e,r.offset);for(this.bundleElements=[];i<e.byteLength;){var s=new N,a=new T;i=a.unpack(e,i);var u=void 0;s.unpack(e,i),i=(u=s.value===nt?new t:new et).unpack(e,i),this.bundleElements.push(u)}return this.offset=i,this.timetag=o,this.offset}}])}(),ot=a((function t(e){if(i(this,t),e&&!(e instanceof et||e instanceof rt))throw new Error("OSC Packet value has to be Message or Bundle");this.value=e,this.offset=0}),[{key:"pack",value:function(){if(!this.value)throw new Error("OSC Packet can not be encoded with empty body");return this.value.pack()}},{key:"unpack",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!(t instanceof DataView))throw new Error("OSC Packet expects an instance of type DataView");if(t.byteLength%4!=0)throw new Error("OSC Packet byteLength has to be a multiple of four");var n,r=new N;return r.unpack(t,e),(n=r.value===nt?new rt:new et).unpack(t,e),this.offset=n.offset,this.value=n,this.offset}}]),it={discardLateMessages:!1},st=a((function t(e){i(this,t),this.options=r(r({},it),e),this.addressHandlers=[],this.eventHandlers={open:[],error:[],close:[]},this.uuid=0}),[{key:"dispatch",value:function(t,e){var n=this;if(!(t instanceof ot))throw new Error("OSC EventHander dispatch() accepts only arguments of type Packet");if(!t.value)throw new Error("OSC EventHander dispatch() can't read empty Packets");if(t.value instanceof rt){var r=t.value;return r.bundleElements.forEach((function(t){if(t instanceof rt){if(r.timetag.value.timestamp()<t.timetag.value.timestamp())throw new Error("OSC Bundle timestamp is older than the timestamp of enclosed Bundles");return n.dispatch(new ot(t))}if(t instanceof et){var o=t;return n.notify(o.address,o,r.timetag.value.timestamp(),e)}throw new Error("OSC EventHander dispatch() can't dispatch unknown Packet value")}))}if(t.value instanceof et){var o=t.value;return this.notify(o.address,o,0,e)}throw new Error("OSC EventHander dispatch() can't dispatch unknown Packet value")}},{key:"call",value:function(t,e,n){var r=!1;if(w(t)&&t in this.eventHandlers)return this.eventHandlers[t].forEach((function(t){t.callback(e,n),r=!0})),r;var o=Object.keys(this.addressHandlers),i=this.addressHandlers;return o.forEach((function(o){var s=!1,a=new RegExp(B(D(t)),"g");if(a.test(o)&&o.length===a.lastIndex&&(s=!0),!s){var u=new RegExp(B(D(o)),"g");u.test(t)&&t.length===u.lastIndex&&(s=!0)}s&&i[o].forEach((function(t){t.callback(e,n),r=!0}))})),r}},{key:"notify",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];if(0===e.length)throw new Error("OSC EventHandler can not be called without any argument");try{if(e[0]instanceof ot)return this.dispatch(e[0],e[1]);if(e[0]instanceof rt||e[0]instanceof et)return this.dispatch(new ot(e[0]),e[1]);if(!w(e[0])){var r=new ot;return r.unpack(I(e[0])),this.dispatch(r,e[1])}var o=e[0],i=null;e.length>1&&(i=e[1]);var s=null;if(e.length>2)if(d(e[2]))s=e[2];else{if(!(e[2]instanceof Date))throw new Error("OSC EventHandler timestamp has to be a number or Date");s=e[2].getTime()}var a=null;if(e.length>=3&&(a=e[3]),s){var u=Date.now();if(u>s&&!this.options.discardLateMessages)return this.call(o,i,a);var c=this;return setTimeout((function(){c.call(o,i,a)}),s-u),!0}return this.call(o,i,a)}catch(t){return this.notify("error",t),!1}}},{key:"on",value:function(t,e){if(!w(t)&&!k(t))throw new Error("OSC EventHandler accepts only strings or arrays for address patterns");if(!m(e))throw new Error("OSC EventHandler callback has to be a function");this.uuid+=1;var n={id:this.uuid,callback:e};if(w(t)&&t in this.eventHandlers)return this.eventHandlers[t].push(n),this.uuid;var r=D(t);return r in this.addressHandlers||(this.addressHandlers[r]=[]),this.addressHandlers[r].push(n),this.uuid}},{key:"off",value:function(t,e){if(!w(t)&&!k(t))throw new Error("OSC EventHandler accepts only strings or arrays for address patterns");if(!d(e))throw new Error("OSC EventHandler subscription id has to be a number");var n,r;return w(t)&&t in this.eventHandlers?(n=t,r=this.eventHandlers):(n=D(t),r=this.addressHandlers),n in r&&r[n].some((function(t,o){return t.id===e&&(r[n].splice(o,1),!0)}))}}]),at=a((function t(){if(i(this,t),this.constructor===t)throw new Error("Plugin is an abstract class. Please create or use an implementation!")}),[{key:"status",value:function(){throw new Error("Abstract method!")}},{key:"open",value:function(){throw new Error("Abstract method!")}},{key:"close",value:function(){throw new Error("Abstract method!")}},{key:"send",value:function(t){throw new Error("Abstract method!")}}]),ut=0,ct=1,ft=2,lt=3,ht=function(e){function n(){throw i(this,n),t(this,n),new Error("DatagramPlugin can not be used in browser context")}return c(n,e),a(n,[{key:"registerNotify",value:function(t){this.notify=t}},{key:"status",value:function(){return this.socketStatus}},{key:"open",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r(r({},this.options.open),e),o=n.port,i=n.exclusive;this.socketStatus=ut,this.socket.bind({address:n.host,port:o,exclusive:i},(function(){t.socketStatus=ct,t.notify("open")}))}},{key:"close",value:function(){var t=this;this.socketStatus=ft,this.socket.close((function(){t.socketStatus=lt,t.notify("close")}))}},{key:"send",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r(r({},this.options.send),e),o=n.port,i=n.host;this.socket.send(Buffer.from(t),0,t.byteLength,o,i)}}])}(at);var pt="undefined"!=typeof WebSocket?WebSocket:"undefined"!=typeof MozWebSocket?MozWebSocket:"undefined"!=typeof global?global.WebSocket||global.MozWebSocket:"undefined"!=typeof window?window.WebSocket||window.MozWebSocket:"undefined"!=typeof self?self.WebSocket||self.MozWebSocket:void 0,dt=void 0,vt=0,wt=1,yt=2,gt=3,kt={udpServer:{host:"localhost",port:41234,exclusive:!1},udpClient:{host:"localhost",port:41235},wsServer:{host:"localhost",port:8080},receiver:"ws"};function bt(t,e){return r(r(r(r({},kt),t),e),{},{udpServer:r(r(r({},kt.udpServer),t.udpServer),e.udpServer),udpClient:r(r(r({},kt.udpClient),t.udpClient),e.udpClient),wsServer:r(r(r({},kt.wsServer),t.wsServer),e.wsServer)})}var mt=function(e){function n(){throw i(this,n),t(this,n),new Error("BridgePlugin can not be used in browser context")}return c(n,e),a(n,[{key:"registerNotify",value:function(t){this.notify=t}},{key:"status",value:function(){return this.socketStatus}},{key:"open",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=bt(this.options,e);this.socketStatus=vt,this.socket.bind({address:n.udpServer.host,port:n.udpServer.port,exclusive:n.udpServer.exclusive},(function(){var e={};n.wsServer.server?e.server=n.wsServer.server:e=n.wsServer,t.websocket=new dt(e),t.websocket.binaryType="arraybuffer",t.websocket.on("listening",(function(){t.socketStatus=wt,t.notify("open")})),t.websocket.on("error",(function(e){t.notify("error",e)})),t.websocket.on("connection",(function(e){e.on("message",(function(e,n){t.send(e,{receiver:"udp"}),t.notify(new Uint8Array(e),n)}))}))}))}},{key:"close",value:function(){var t=this;this.socketStatus=yt,this.socket.close((function(){t.websocket.close((function(){t.socketStatus=gt,t.notify("close")}))}))}},{key:"send",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=bt(this.options,e),r=n.receiver;if("udp"===r){var o=t instanceof Buffer?t:Buffer.from(t);this.socket.send(o,0,o.byteLength,n.udpClient.port,n.udpClient.host)}else{if("ws"!==r)throw new Error("BridgePlugin can not send message to unknown receiver");this.websocket.clients.forEach((function(e){e.send(t,{binary:!0})}))}}}])}(at),St=-1,Et=0,Ot=1,Ct=2,Pt=3,At={host:"localhost",port:8080,secure:!1,protocol:[]},It=function(e){function n(e){var o;if(i(this,n),o=t(this,n),!pt)throw new Error("WebsocketClientPlugin can't find a WebSocket class");return o.options=r(r({},At),e),o.socket=null,o.socketStatus=St,o.notify=function(){},o}return c(n,e),a(n,[{key:"registerNotify",value:function(t){this.notify=t}},{key:"status",value:function(){return this.socketStatus}},{key:"open",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r(r({},this.options),e),o=n.port,i=n.host,s=n.secure,a=n.protocol;this.socket&&this.close();var u=s?"wss":"ws",c={address:i,family:u,port:o,size:0};this.socket=new pt("".concat(u,"://").concat(i,":").concat(o),a),this.socket.binaryType="arraybuffer",this.socketStatus=Et,this.socket.onopen=function(){t.socketStatus=Ot,t.notify("open")},this.socket.onclose=function(){t.socketStatus=Pt,t.notify("close")},this.socket.onerror=function(e){t.notify("error",e)},this.socket.onmessage=function(e){t.notify(e.data,c)}}},{key:"close",value:function(){this.socketStatus=Ct,this.socket.close()}},{key:"send",value:function(t){this.socket.send(t)}}])}(at),jt=0,Dt=1,Bt=2,Mt=3,xt=function(e){function n(e){throw i(this,n),t(this,n),new Error("WebsocketServerPlugin can not be used in browser context")}return c(n,e),a(n,[{key:"registerNotify",value:function(t){this.notify=t}},{key:"status",value:function(){return this.socketStatus}},{key:"open",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r(r({},this.options),e),o=n.port,i=n.host,s={address:i,family:"wsserver",port:o,size:0};this.socket&&this.close(),n.server?this.socket=new dt({server:n.server}):this.socket=new dt({host:i,port:o}),this.socket.binaryType="arraybuffer",this.socketStatus=jt,this.socket.on("listening",(function(){t.socketStatus=Dt,t.notify("open")})),this.socket.on("error",(function(e){t.notify("error",e)})),this.socket.on("connection",(function(e){e.on("message",(function(e){t.notify(new Uint8Array(e),s)}))}))}},{key:"close",value:function(){var t=this;this.socketStatus=Bt,this.socket.close((function(){t.socketStatus=Mt,t.notify("close")}))}},{key:"send",value:function(t){this.socket.clients.forEach((function(e){e.send(t,{binary:!0})}))}}])}(at),Tt={discardLateMessages:!1},Ht=a((function t(e){if(i(this,t),e&&!b(e))throw new Error("OSC options argument has to be an object.");this.options=r(r({},Tt),e),this.options.plugin||(this.options.plugin=new It),this.eventHandler=new st({discardLateMessages:this.options.discardLateMessages});var n=this.eventHandler;this.options.plugin&&this.options.plugin.registerNotify&&this.options.plugin.registerNotify((function(){return n.notify.apply(n,arguments)}))}),[{key:"on",value:function(t,e){if(!w(t)||!m(e))throw new Error("OSC on() needs event- or address string and callback function");return this.eventHandler.on(t,e)}},{key:"off",value:function(t,e){if(!w(t)||!d(e))throw new Error("OSC off() needs string and number (subscriptionId) to unsubscribe");return this.eventHandler.off(t,e)}},{key:"open",value:function(t){if(t&&!b(t))throw new Error("OSC open() options argument needs to be an object");if(!this.options.plugin||!m(this.options.plugin.open))throw new Error("OSC Plugin API #open is not implemented!");return this.options.plugin.open(t)}},{key:"status",value:function(){if(!this.options.plugin||!m(this.options.plugin.status))throw new Error("OSC Plugin API #status is not implemented!");return this.options.plugin.status()}},{key:"close",value:function(){if(!this.options.plugin||!m(this.options.plugin.close))throw new Error("OSC Plugin API #close is not implemented!");return this.options.plugin.close()}},{key:"send",value:function(t,e){if(!this.options.plugin||!m(this.options.plugin.send))throw new Error("OSC Plugin API #send is not implemented!");if(!(t instanceof tt||t instanceof et||t instanceof rt||t instanceof ot))throw new Error("OSC send() needs Messages, Bundles or Packets");if(e&&!b(e))throw new Error("OSC send() options argument has to be an object");return this.options.plugin.send(t.pack(),e)}}]);return Ht.STATUS={IS_NOT_INITIALIZED:-1,IS_CONNECTING:0,IS_OPEN:1,IS_CLOSING:2,IS_CLOSED:3},Ht.Packet=ot,Ht.Bundle=rt,Ht.Message=et,Ht.TypedMessage=tt,Ht.Plugin=at,Ht.DatagramPlugin=ht,Ht.WebsocketClientPlugin=It,Ht.WebsocketServerPlugin=xt,Ht.BridgePlugin=mt,Ht}));
//# sourceMappingURL=osc.min.js.map
{
"name": "osc-js",
"version": "2.4.0",
"version": "2.4.1",
"description": "OSC library for Node.js and the browser, with customizable Plugin API for WebSocket, UDP or bridge networking",

@@ -40,10 +40,10 @@ "main": "lib/osc.js",

"devDependencies": {
"@babel/core": "7.19.3",
"@babel/eslint-parser": "7.19.1",
"@babel/preset-env": "7.19.3",
"@babel/register": "7.18.9",
"@babel/core": "7.24.4",
"@babel/eslint-parser": "7.24.1",
"@babel/preset-env": "7.24.4",
"@babel/register": "7.23.7",
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-babel": "^5.3.1",
"@types/node": "^18.8.3",
"@types/ws": "^8.5.3",
"@types/ws": "^8.5.10",
"chai": "4.3.6",

@@ -56,4 +56,4 @@ "chai-spies-next": "0.9.3",

"eslint-config-airbnb-base": "15.0.0",
"eslint-plugin-import": "2.26.0",
"mocha": "10.0.0",
"eslint-plugin-import": "2.29.1",
"mocha": "10.4.0",
"rollup": "2.79.1",

@@ -66,4 +66,4 @@ "rollup-plugin-cleanup": "3.2.1",

"dependencies": {
"ws": "^8.9.0"
"ws": "^8.16.0"
}
}

@@ -200,2 +200,3 @@ osc-js

* [@yaxu](https://github.com/yaxu)
* [@yojeek](https://github.com/yojeek)

@@ -202,0 +203,0 @@ ### ESDocs

Sorry, the diff of this file is not supported yet

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