From f9579f1a0266edad3e338bfa615170c4cf7e613f Mon Sep 17 00:00:00 2001 From: Patryk Wegrzyn
node_modules
osc.Ports implement the [Event Emitter API](https://nodejs.org/
-
-Examples
---------
+## Examples
In-depth example osc.js applications for the browser, Node.js, and Chrome OS are available in the [osc.js examples repository](https://github.com/colinbdclark/osc.js-examples).
-
### Web Sockets in the Browser
The osc.WebSocketPort
object supports sending and receiving
@@ -227,110 +217,152 @@ OSC messages over Web Sockets.
_More code examples showing how osc.js can be used in browser-based, Node.js, and Chrome App applications can be found in the [osc.js examples repository](https://github.com/colinbdclark/osc.js-examples)._
##### Including osc.js in your HTML page:
+
```html
-
- osc-browser.js
package in their code:
```javascript
@@ -370,31 +402,31 @@ OSC messages over Web Sockets.
```javascript
var osc = require("osc"),
- http = require("http"),
- WebSocket = require("ws");
+ http = require("http"),
+ WebSocket = require("ws");
// Create an Express server app
// and serve up a directory of static files.
var app = require("express").express(),
- server = app.listen(8081);
+ server = app.listen(8081);
app.use("/", express.static(__dirname + "/static"));
// Listen for Web Socket requests.
var wss = new WebSocket.Server({
- server: server
+ server: server,
});
// Listen for Web Socket connections.
wss.on("connection", function (socket) {
- var socketPort = new osc.WebSocketPort({
- socket: socket,
- metadata: true
- });
-
- socketPort.on("message", function (oscMsg) {
- console.log("An OSC Message was received!", oscMsg);
- });
+ var socketPort = new osc.WebSocketPort({
+ socket: socket,
+ metadata: true,
+ });
+
+ socketPort.on("message", function (oscMsg) {
+ console.log("An OSC Message was received!", oscMsg);
+ });
});
```
@@ -458,75 +490,79 @@ OSC messages over Node.js's UDP sockets. It also supports broadcast and multicas
```javascript
// Create an osc.js UDP Port listening on port 57121.
var udpPort = new osc.UDPPort({
- localAddress: "0.0.0.0",
- localPort: 57121,
- metadata: true
+ localAddress: "0.0.0.0",
+ localPort: 57121,
+ metadata: true,
});
// Listen for incoming OSC messages.
udpPort.on("message", function (oscMsg, timeTag, info) {
- console.log("An OSC message just arrived!", oscMsg);
- console.log("Remote info is: ", info);
+ console.log("An OSC message just arrived!", oscMsg);
+ console.log("Remote info is: ", info);
});
// Open the socket.
udpPort.open();
-
// When the port is read, send an OSC message to, say, SuperCollider
udpPort.on("ready", function () {
- udpPort.send({
- address: "/s_new",
- args: [
- {
- type: "s",
- value: "default"
- },
- {
- type: "i",
- value: 100
- }
- ]
- }, "127.0.0.1", 57110);
+ udpPort.send(
+ {
+ address: "/s_new",
+ args: [
+ {
+ type: "s",
+ value: "default",
+ },
+ {
+ type: "i",
+ value: 100,
+ },
+ ],
+ },
+ "127.0.0.1",
+ 57110
+ );
});
```
### Serial in a Chrome App
#### Including osc.js in your Chrome App page
+
```html
```
#### Defining the appropriate permissions in manifest.json
+
```json
{
- "name": "OSC.js Chrome App Demo",
- "version": "1",
- "manifest_version": 2,
- "permissions": [
- "serial"
- ],
- "app": {
- "background": {
- "scripts": ["js/launch.js"],
- "transient": true
- }
+ "name": "OSC.js Chrome App Demo",
+ "version": "1",
+ "manifest_version": 2,
+ "permissions": ["serial"],
+ "app": {
+ "background": {
+ "scripts": ["js/launch.js"],
+ "transient": true
}
+ }
}
```
#### Connecting to the serial port and listening for OSC messages
+
```javascript
// Instantiate a new OSC Serial Port.
var serialPort = new osc.SerialPort({
- devicePath: "/dev/cu.usbmodem22131",
- metadata: true
+ devicePath: "/dev/cu.usbmodem22131",
+ metadata: true,
});
// Listen for the message event and map the OSC message to the synth.
serialPort.on("message", function (oscMsg) {
- console.log("An OSC message was received!", oscMsg);
+ console.log("An OSC message was received!", oscMsg);
});
// Open the port.
@@ -588,9 +624,7 @@ OSC messages over a chrome.sockets.udp
socket. It also supports bro
-
-Handling Errors
----------------
+## Handling Errors
All osc.js Transport objects emit "error"
messages whenever an error occurs,
such as when a malformed message is received. You should always listen for errors and
@@ -599,7 +633,7 @@ handle them in an appropriate manner for your application.
```javascript
var port = osc.UDPPort();
port.on("error", function (error) {
- console.log("An error occurred: ", error.message);
+ console.log("An error occurred: ", error.message);
});
```
@@ -611,20 +645,20 @@ they should be caught and handled using
var msg;
try {
- msg = osc.readPacket(rawPacket);
+ msg = osc.readPacket(rawPacket);
} catch (error) {
- console.log("An error occurred: ", error.message);
+ console.log("An error occurred: ", error.message);
}
```
-The osc.js Low-Level API
-------------------------
+## The osc.js Low-Level API
### OSC Bundle and Message Objects
osc.js represents bundles and messages as (mostly) JSON-compatible objects. Here's how they are structured:
#### Messages
+
OSC Message objects consist of two properties, `address`, which contains the URL-style address path and `args` which is an array of either raw argument values or type-annotated Argument objects (depending on the value of the metadata
option used when reading the message).
```javascript
@@ -653,7 +687,7 @@ OSC bundle objects consist of a time tag and an array of `packets`. Packets can
#### Argument Objects with Type Metadata
-Type-annotated argument objects contain two properties: `type`, which contains the OSC type tag character (e.g. `"i"`, `"f"`, `"t"`, etc.) and the raw `value`.
+Type-annotated argument objects contain two properties: `type`, which contains the OSC type tag character (e.g. `"i"`, `"f"`, `"t"`, etc.) and the raw `value`.
```javascript
{
@@ -664,8 +698,8 @@ Type-annotated argument objects contain two properties: `type`, which contains
If you are using type-annotated arguments, you should also set the metadata
option to true
when you instantiate your OSCPort
instance (or in the options
argument to osc.writeMessage
if you're using the low-level API).
-
#### Time Tags
+
Time tag objects contain two different representations: the raw NTP time and the equivalent (though less precise) native JavaScript timestamp. NTP times consist of a pair of values in an array. The first value represents the number of seconds since January 1, 1900. The second value is a Uint32 value (i.e. between 0 and 4294967296) that represents fractions of a second.
JavaScript timestamps are represented as milliseconds since January 1, 1970, which is the same unit as is returned by calls to `Date.now()`.
@@ -679,7 +713,9 @@ JavaScript timestamps are represented as milliseconds since January 1, 1970, whi
native: Number // Milliseconds since January 1, 1970
}
```
+
#### Colours
+
Colours are automatically normalized to CSS 3 rgba values (i.e. the alpha channel is represented as a float from `0.0` to `1.0`).
```javascript
@@ -728,12 +764,10 @@ There are two primary functions in osc.js used to read and write OSC data:
Many osc.js functions take an options
object that can be used to customize its behaviour. These options are also supported by all osc.Port
objects, and can be included as a parameter in the options
arguments passed to any Port
constructor. The supported fields in an options object are:
-* metadata
: specifies if the OSC type metadata should be included. By default, type metadata isn't included when reading packets, and is inferred automatically when writing packets. If you need greater precision in regards to the arguments in an OSC message, set the metadata
argument to true. Defaults to false
.
-* unpackSingleArgs
: specifies if osc.js should automatically unpack single-argument messages so that their args
property isn't wrapped in an array. Defaults to true
.
-
+- metadata
: specifies if the OSC type metadata should be included. By default, type metadata isn't included when reading packets, and is inferred automatically when writing packets. If you need greater precision in regards to the arguments in an OSC message, set the metadata
argument to true. Defaults to false
.
+- unpackSingleArgs
: specifies if osc.js should automatically unpack single-argument messages so that their args
property isn't wrapped in an array. Defaults to true
.
-Mapping OSC to JS
-------------------
+## Mapping OSC to JS
Here are a few examples showing how OSC packets are mapped to plain JavaScript objects by osc.js.
@@ -829,13 +863,11 @@ Here are a few examples showing how OSC packets are mapped to plain JavaScript o
}
-License
--------
+## License
osc.js is maintained by Colin Clark and distributed under the MIT and GPL 3 licenses.
-Supported Environments
-----------------------
+## Supported Environments
osc.js releases are tested and supported on a best-effort basis in the following environments:
@@ -853,8 +885,7 @@ osc.js releases are tested and supported on a best-effort basis in the following
-Contributing to osc.js
-----------------------
+## Contributing to osc.js
Contributions and pull requests to osc.js are hugely appreciated. Wherever possible, all fixes and new features should be accompanied by unit tests to help verify that they work and avoid regressions. When new features are introduced, a pull request to the [osc.js-examples repository](https://github.com/colinbdclark/osc.js-examples) with an example of how to use it is also appreciated.
@@ -877,13 +908,12 @@ Running the unit tests:
1. To run the fully automated tests, run "npm test"
2. To run the electron tests, run "npm run electron-test"
-Contributors
-------------
+## Contributors
- * @colinbdclark wrote osc.js.
- * @jacoscaz and @xseignard fixed bugs.
- * @drart made and helped test some examples.
- * @egasimus added support for 64-bit integers.
- * @heisters contributed fixes for broadcast and multicast UDP on Node.js and improved time tag support.
- * @tambien fixed error handling bugs in the transports layer.
- * @janslow added support for passing remote information to all Port data events.
+- @colinbdclark wrote osc.js.
+- @jacoscaz and @xseignard fixed bugs.
+- @drart made and helped test some examples.
+- @egasimus added support for 64-bit integers.
+- @heisters contributed fixes for broadcast and multicast UDP on Node.js and improved time tag support.
+- @tambien fixed error handling bugs in the transports layer.
+- @janslow added support for passing remote information to all Port data events.
diff --git a/dist/osc-browser.js b/dist/osc-browser.js
index 3e6faa4..5caba4b 100644
--- a/dist/osc-browser.js
+++ b/dist/osc-browser.js
@@ -2116,3 +2116,114 @@ var osc = osc || require("./osc.js");
};
}());
+;
+/*
+ * osc.js: An Open Sound Control library for JavaScript that works in both the browser and Node.js
+ *
+ * WebSerial serial transport for osc.js
+ *
+ * Licensed under the MIT and GPL 3 licenses.
+ */
+
+/*global WebSerial, require*/
+var osc = osc || require("./osc.js");
+
+osc.supportsSerial = true;
+
+(function () {
+ "use strict";
+
+ osc.SerialPort = function (options) {
+ if ("serial" in navigator) {
+ this.on("open", this.listen.bind(this));
+ osc.SLIPPort.call(this, options);
+ this.options.bitrate = this.options.bitrate || 9600;
+
+ this.serialPort = options.serialPort;
+ if (this.serialPort) {
+ this.emit("open", this.serialPort);
+ }
+ } else {
+ throw Error(
+ "Web serial not supported in your browser. Check https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API#browser_compatibility for more info."
+ );
+ }
+ };
+
+ var p = (osc.SerialPort.prototype = Object.create(osc.SLIPPort.prototype));
+ p.constructor = osc.SerialPort;
+
+ p.open = async function () {
+ if (this.serialPort) {
+ // If we already have a serial port, close it and open a new one.
+ this.once("close", this.open.bind(this));
+ this.close();
+ return;
+ }
+
+ try {
+ this.serialPort = await navigator.serial.requestPort();
+ await this.serialPort.open(this.options);
+ this.serialPort.isOpen = true;
+ this.emit("open", this.serialPort);
+ } catch (error) {
+ this.serialPort.isOpen = false;
+ this.emit("error", error);
+ }
+ };
+
+ p.listen = async function () {
+ while (this.serialPort.readable) {
+ const reader = this.serialPort.readable.getReader();
+ try {
+ while (true) {
+ const { value, done } = await reader.read();
+ if (done) {
+ break;
+ }
+ this.emit("data", value, undefined);
+ }
+ } catch (error) {
+ this.emit("error", error);
+ } finally {
+ reader.releaseLock();
+ }
+ }
+ this.emit("ready");
+ };
+
+ p.messageQueue = [];
+ p.isWriting = false;
+
+ p.sendRaw = async function (encoded) {
+ if (!this.serialPort || !this.serialPort.isOpen) {
+ osc.fireClosedPortSendError(this);
+ return;
+ }
+
+ this.messageQueue.push(encoded);
+
+ if (!this.isWriting) {
+ this.isWriting = true;
+ const writer = this.serialPort.writable.getWriter();
+ while (this.messageQueue.length > 0) {
+ const nextMessage = this.messageQueue.shift();
+ try {
+ await writer.write(nextMessage);
+ } catch (error) {
+ console.error(error);
+ this.emit("error", error);
+ }
+ }
+ writer.releaseLock();
+ this.isWriting = false;
+ }
+ };
+
+ p.close = function () {
+ if (this.serialPort) {
+ this.serialPort.close();
+ this.serialPort.isOpen = false;
+ }
+ };
+})();
diff --git a/dist/osc-browser.min.js b/dist/osc-browser.min.js
index ec165d8..e3a4eba 100644
--- a/dist/osc-browser.min.js
+++ b/dist/osc-browser.min.js
@@ -25,19 +25,19 @@ var osc = osc || {}, osc = (!function() {
}, osc.nativeBuffer = function(e) {
return osc.isBufferEnv ? osc.isBuffer(e) ? e : Buffer.from(e.buffer ? e : new Uint8Array(e)) : osc.isTypedArrayView(e) ? e : new Uint8Array(e);
}, osc.copyByteArray = function(e, t, r) {
- if (osc.isTypedArrayView(e) && osc.isTypedArrayView(t)) t.set(e, r); else for (var n = void 0 === r ? 0 : r, i = Math.min(t.length - r, e.length), s = 0, o = n; s < i; s++,
+ if (osc.isTypedArrayView(e) && osc.isTypedArrayView(t)) t.set(e, r); else for (var i = void 0 === r ? 0 : r, n = Math.min(t.length - r, e.length), s = 0, o = i; s < n; s++,
o++) t[o] = e[s];
return t;
}, osc.readString = function(e, t) {
- for (var r = [], n = t.idx; n < e.byteLength; n++) {
- var i = e.getUint8(n);
- if (0 === i) {
- n++;
+ for (var r = [], i = t.idx; i < e.byteLength; i++) {
+ var n = e.getUint8(i);
+ if (0 === n) {
+ i++;
break;
}
- r.push(i);
+ r.push(n);
}
- return t.idx = n = n + 3 & -4, (osc.isBufferEnv ? osc.readString.withBuffer : osc.TextDecoder ? osc.readString.withTextDecoder : osc.readString.raw)(r);
+ return t.idx = i = i + 3 & -4, (osc.isBufferEnv ? osc.readString.withBuffer : osc.TextDecoder ? osc.readString.withTextDecoder : osc.readString.raw)(r);
}, osc.readString.raw = function(e) {
for (var t = "", r = 0; r < e.length; r += 1e4) t += String.fromCharCode.apply(null, e.slice(r, r + 1e4));
return t;
@@ -47,9 +47,9 @@ var osc = osc || {}, osc = (!function() {
}, osc.readString.withBuffer = function(e) {
return Buffer.from(e).toString("utf-8");
}, osc.writeString = function(e) {
- for (var t, r = osc.isBufferEnv ? osc.writeString.withBuffer : osc.TextEncoder ? osc.writeString.withTextEncoder : null, n = e + "\0", i = (r && (t = r(n)),
- (r ? t : n).length), s = new Uint8Array(i + 3 & -4), o = 0; o < i - 1; o++) {
- var a = r ? t[o] : n.charCodeAt(o);
+ for (var t, r = osc.isBufferEnv ? osc.writeString.withBuffer : osc.TextEncoder ? osc.writeString.withTextEncoder : null, i = e + "\0", n = (r && (t = r(i)),
+ (r ? t : i).length), s = new Uint8Array(n + 3 & -4), o = 0; o < n - 1; o++) {
+ var a = r ? t[o] : i.charCodeAt(o);
s[o] = a;
}
return s;
@@ -57,13 +57,13 @@ var osc = osc || {}, osc = (!function() {
return osc.TextEncoder.encode(e);
}, osc.writeString.withBuffer = function(e) {
return Buffer.from(e);
- }, osc.readPrimitive = function(e, t, r, n) {
- e = e[t](n.idx, !1);
- return n.idx += r, e;
- }, osc.writePrimitive = function(e, t, r, n, i) {
+ }, osc.readPrimitive = function(e, t, r, i) {
+ e = e[t](i.idx, !1);
+ return i.idx += r, e;
+ }, osc.writePrimitive = function(e, t, r, i, n) {
var s;
- return i = void 0 === i ? 0 : i, t ? s = new Uint8Array(t.buffer) : (s = new Uint8Array(n),
- t = new DataView(s.buffer)), t[r](i, e, !1), s;
+ return n = void 0 === n ? 0 : n, t ? s = new Uint8Array(t.buffer) : (s = new Uint8Array(i),
+ t = new DataView(s.buffer)), t[r](n, e, !1), s;
}, osc.readInt32 = function(e, t) {
return osc.readPrimitive(e, "getInt32", 4, t);
}, osc.writeInt32 = function(e, t, r) {
@@ -76,9 +76,9 @@ var osc = osc || {}, osc = (!function() {
unsigned: !1
};
}, osc.writeInt64 = function(e, t, r) {
- var n = new Uint8Array(8);
- return n.set(osc.writePrimitive(e.high, t, "setInt32", 4, r), 0), n.set(osc.writePrimitive(e.low, t, "setInt32", 4, r + 4), 4),
- n;
+ var i = new Uint8Array(8);
+ return i.set(osc.writePrimitive(e.high, t, "setInt32", 4, r), 0), i.set(osc.writePrimitive(e.low, t, "setInt32", 4, r + 4), 4),
+ i;
}, osc.readFloat32 = function(e, t) {
return osc.readPrimitive(e, "getFloat32", 4, t);
}, osc.writeFloat32 = function(e, t, r) {
@@ -94,11 +94,11 @@ var osc = osc || {}, osc = (!function() {
e = e.charCodeAt(0);
if (!(void 0 === e || e < -1)) return osc.writePrimitive(e, t, "setUint32", 4, r);
}, osc.readBlob = function(e, t) {
- var r = osc.readInt32(e, t), n = r + 3 & -4, e = new Uint8Array(e.buffer, t.idx, r);
- return t.idx += n, e;
+ var r = osc.readInt32(e, t), i = r + 3 & -4, e = new Uint8Array(e.buffer, t.idx, r);
+ return t.idx += i, e;
}, osc.writeBlob = function(e) {
- var t = (e = osc.byteArray(e)).byteLength, r = new Uint8Array(4 + (t + 3 & -4)), n = new DataView(r.buffer);
- return osc.writeInt32(t, n), r.set(e, 4), r;
+ var t = (e = osc.byteArray(e)).byteLength, r = new Uint8Array(4 + (t + 3 & -4)), i = new DataView(r.buffer);
+ return osc.writeInt32(t, i), r.set(e, 4), r;
}, osc.readMIDIBytes = function(e, t) {
e = new Uint8Array(e.buffer, t.idx, 4);
return t.idx += 4, e;
@@ -136,9 +136,9 @@ var osc = osc || {}, osc = (!function() {
return osc.writeInt32(e[0], r, 0), osc.writeInt32(e[1], r, 4), t;
}, osc.timeTag = function(e, t) {
e = e || 0;
- var t = (t = t || Date.now()) / 1e3, r = Math.floor(t), t = t - r, n = Math.floor(e), t = t + (e - n);
- return 1 < t && (n += e = Math.floor(t), t = t - e), {
- raw: [ r + n + osc.SECS_70YRS, Math.round(osc.TWO_32 * t) ]
+ var t = (t = t || Date.now()) / 1e3, r = Math.floor(t), t = t - r, i = Math.floor(e), t = t + (e - i);
+ return 1 < t && (i += e = Math.floor(t), t = t - e), {
+ raw: [ r + i + osc.SECS_70YRS, Math.round(osc.TWO_32 * t) ]
};
}, osc.ntpToJSTime = function(e, t) {
return 1e3 * (e - osc.SECS_70YRS + t / osc.TWO_32);
@@ -146,26 +146,26 @@ var osc = osc || {}, osc = (!function() {
var e = e / 1e3, t = Math.floor(e);
return [ t + osc.SECS_70YRS, Math.round(osc.TWO_32 * (e - t)) ];
}, osc.readArguments = function(e, t, r) {
- var n = osc.readString(e, r);
- if (0 !== n.indexOf(",")) throw new Error("A malformed type tag string was found while reading the arguments of an OSC message. String was: " + n, " at offset: " + r.idx);
- var i = n.substring(1).split(""), s = [];
- return osc.readArgumentsIntoArray(s, i, n, e, t, r), s;
- }, osc.readArgument = function(e, t, r, n, i) {
+ var i = osc.readString(e, r);
+ if (0 !== i.indexOf(",")) throw new Error("A malformed type tag string was found while reading the arguments of an OSC message. String was: " + i, " at offset: " + r.idx);
+ var n = i.substring(1).split(""), s = [];
+ return osc.readArgumentsIntoArray(s, n, i, e, t, r), s;
+ }, osc.readArgument = function(e, t, r, i, n) {
var s = osc.argumentTypes[e];
- if (s) return s = s.reader, s = osc[s](r, i), n.metadata ? {
+ if (s) return s = s.reader, s = osc[s](r, n), i.metadata ? {
type: e,
value: s
} : s;
throw new Error("'" + e + "' is not a valid OSC type tag. Type tag string was: " + t);
- }, osc.readArgumentsIntoArray = function(e, t, r, n, i, s) {
+ }, osc.readArgumentsIntoArray = function(e, t, r, i, n, s) {
for (var o = 0; o < t.length; ) {
var a = t[o];
if ("[" === a) {
var c = t.slice(o + 1), u = c.indexOf("]");
if (u < 0) throw new Error("Invalid argument type tag: an open array type tag ('[') was found without a matching close array tag ('[]'). Type tag was: " + r);
- c = c.slice(0, u), c = osc.readArgumentsIntoArray([], c, r, n, i, s);
+ c = c.slice(0, u), c = osc.readArgumentsIntoArray([], c, r, i, n, s);
o += u + 2;
- } else c = osc.readArgument(a, r, n, i, s), o++;
+ } else c = osc.readArgument(a, r, i, n, s), o++;
e.push(c);
}
return e;
@@ -173,17 +173,17 @@ var osc = osc || {}, osc = (!function() {
e = osc.collectArguments(e, t);
return osc.joinParts(e);
}, osc.joinParts = function(e) {
- for (var t = new Uint8Array(e.byteLength), r = e.parts, n = 0, i = 0; i < r.length; i++) {
- var s = r[i];
- osc.copyByteArray(s, t, n), n += s.length;
+ for (var t = new Uint8Array(e.byteLength), r = e.parts, i = 0, n = 0; n < r.length; n++) {
+ var s = r[n];
+ osc.copyByteArray(s, t, i), i += s.length;
}
return t;
}, osc.addDataPart = function(e, t) {
t.parts.push(e), t.byteLength += e.length;
}, osc.writeArrayArguments = function(e, t) {
- for (var r = "[", n = 0; n < e.length; n++) {
- var i = e[n];
- r += osc.writeArgument(i, t);
+ for (var r = "[", i = 0; i < e.length; i++) {
+ var n = e[i];
+ r += osc.writeArgument(n, t);
}
return r += "]";
}, osc.writeArgument = function(e, t) {
@@ -195,21 +195,21 @@ var osc = osc || {}, osc = (!function() {
byteLength: 0,
parts: []
}, t.metadata || (e = osc.annotateArguments(e));
- for (var n = ",", t = r.parts.length, i = 0; i < e.length; i++) {
- var s = e[i];
- n += osc.writeArgument(s, r);
+ for (var i = ",", t = r.parts.length, n = 0; n < e.length; n++) {
+ var s = e[n];
+ i += osc.writeArgument(s, r);
}
- var o = osc.writeString(n);
+ var o = osc.writeString(i);
return r.byteLength += o.byteLength, r.parts.splice(t, 0, o), r;
}, osc.readMessage = function(e, t, r) {
t = t || osc.defaults;
- var e = osc.dataView(e, e.byteOffset, e.byteLength), n = osc.readString(e, r = r || {
+ var e = osc.dataView(e, e.byteOffset, e.byteLength), i = osc.readString(e, r = r || {
idx: 0
});
- return osc.readMessageContents(n, e, t, r);
- }, osc.readMessageContents = function(e, t, r, n) {
+ return osc.readMessageContents(i, e, t, r);
+ }, osc.readMessageContents = function(e, t, r, i) {
if (0 !== e.indexOf("/")) throw new Error("A malformed OSC address was found while reading an OSC message. String was: " + e);
- t = osc.readArguments(t, r, n);
+ t = osc.readArguments(t, r, i);
return {
address: e,
args: 1 === t.length && r.unpackSingleArgs ? t[0] : t
@@ -232,10 +232,10 @@ var osc = osc || {}, osc = (!function() {
byteLength: 0,
parts: []
}, osc.addDataPart(osc.writeString("#bundle"), r), osc.addDataPart(osc.writeTimeTag(e.timeTag), r);
- for (var n = 0; n < e.packets.length; n++) {
- var i = e.packets[n], i = (i.address ? osc.collectMessageParts : osc.collectBundlePackets)(i, t);
- r.byteLength += i.byteLength, osc.addDataPart(osc.writeInt32(i.byteLength), r),
- r.parts = r.parts.concat(i.parts);
+ for (var i = 0; i < e.packets.length; i++) {
+ var n = e.packets[i], n = (n.address ? osc.collectMessageParts : osc.collectBundlePackets)(n, t);
+ r.byteLength += n.byteLength, osc.addDataPart(osc.writeInt32(n.byteLength), r),
+ r.parts = r.parts.concat(n.parts);
}
return r;
}, osc.writeBundle = function(e, t) {
@@ -245,23 +245,23 @@ var osc = osc || {}, osc = (!function() {
return osc.joinParts(e);
}, osc.isValidBundle = function(e) {
return void 0 !== e.timeTag && void 0 !== e.packets;
- }, osc.readBundleContents = function(e, t, r, n) {
- for (var i = osc.readTimeTag(e, r), s = []; r.idx < n; ) {
+ }, osc.readBundleContents = function(e, t, r, i) {
+ for (var n = osc.readTimeTag(e, r), s = []; r.idx < i; ) {
var o = osc.readInt32(e, r), o = r.idx + o, o = osc.readPacket(e, t, r, o);
s.push(o);
}
return {
- timeTag: i,
+ timeTag: n,
packets: s
};
- }, osc.readPacket = function(e, t, r, n) {
- var e = osc.dataView(e, e.byteOffset, e.byteLength), i = (n = void 0 === n ? e.byteLength : n,
+ }, osc.readPacket = function(e, t, r, i) {
+ var e = osc.dataView(e, e.byteOffset, e.byteLength), n = (i = void 0 === i ? e.byteLength : i,
osc.readString(e, r = r || {
idx: 0
- })), s = i[0];
- if ("#" === s) return osc.readBundleContents(e, t, r, n);
- if ("/" === s) return osc.readMessageContents(i, e, t, r);
- throw new Error("The header of an OSC packet didn't contain an OSC address or a #bundle string. Header was: " + i);
+ })), s = n[0];
+ if ("#" === s) return osc.readBundleContents(e, t, r, i);
+ if ("/" === s) return osc.readMessageContents(n, e, t, r);
+ throw new Error("The header of an OSC packet didn't contain an OSC address or a #bundle string. Header was: " + n);
}, osc.writePacket = function(e, t) {
if (osc.isValidMessage(e)) return osc.writeMessage(e, t);
if (osc.isValidBundle(e)) return osc.writeBundle(e, t);
@@ -345,11 +345,11 @@ var osc = osc || {}, osc = (!function() {
throw new Error("Can't infer OSC argument type for value: " + JSON.stringify(e, null, 2));
}, osc.annotateArguments = function(e) {
for (var t = [], r = 0; r < e.length; r++) {
- var n = e[r];
- n = "object" == typeof n && n.type && void 0 !== n.value ? n : osc.isArray(n) ? osc.annotateArguments(n) : {
- type: osc.inferTypeForArgument(n),
- value: n
- }, t.push(n);
+ var i = e[r];
+ i = "object" == typeof i && i.type && void 0 !== i.value ? i : osc.isArray(i) ? osc.annotateArguments(i) : {
+ type: osc.inferTypeForArgument(i),
+ value: i
+ }, t.push(i);
}
return t;
}, osc.isCommonJS && (module.exports = osc);
@@ -357,134 +357,134 @@ var osc = osc || {}, osc = (!function() {
"object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.Long = t() : e.Long = t();
}("undefined" != typeof self ? self : this, function() {
return r = [ function(e, t) {
- function n(e, t, r) {
+ function i(e, t, r) {
this.low = 0 | e, this.high = 0 | t, this.unsigned = !!r;
}
function d(e) {
return !0 === (e && e.__isLong__);
}
function r(e, t) {
- var r, n, i;
- return t ? (i = 0 <= (e >>>= 0) && e < 256) && (n = o[e]) ? n : (r = l(e, (0 | e) < 0 ? -1 : 0, !0),
- i && (o[e] = r), r) : (i = -128 <= (e |= 0) && e < 128) && (n = s[e]) ? n : (r = l(e, e < 0 ? -1 : 0, !1),
- i && (s[e] = r), r);
+ var r, i, n;
+ return t ? (n = 0 <= (e >>>= 0) && e < 256) && (i = o[e]) ? i : (r = g(e, (0 | e) < 0 ? -1 : 0, !0),
+ n && (o[e] = r), r) : (n = -128 <= (e |= 0) && e < 128) && (i = s[e]) ? i : (r = g(e, e < 0 ? -1 : 0, !1),
+ n && (s[e] = r), r);
}
- function g(e, t) {
+ function l(e, t) {
if (isNaN(e)) return t ? f : m;
if (t) {
if (e < 0) return f;
- if (a <= e) return A;
+ if (a <= e) return P;
} else {
- if (e <= -c) return B;
- if (c <= e + 1) return S;
+ if (e <= -c) return A;
+ if (c <= e + 1) return E;
}
- return e < 0 ? g(-e, t).neg() : l(e % i | 0, e / i | 0, t);
+ return e < 0 ? l(-e, t).neg() : g(e % n | 0, e / n | 0, t);
}
- function l(e, t, r) {
- return new n(e, t, r);
+ function g(e, t, r) {
+ return new i(e, t, r);
}
function u(e, t, r) {
if (0 === e.length) throw Error("empty string");
if ("NaN" === e || "Infinity" === e || "+Infinity" === e || "-Infinity" === e) return m;
if (t = "number" == typeof t ? (r = t, !1) : !!t, (r = r || 10) < 2 || 36 < r) throw RangeError("radix");
- var n;
- if (0 < (n = e.indexOf("-"))) throw Error("interior hyphen");
- if (0 === n) return u(e.substring(1), t, r).neg();
- for (var i = g(h(r, 8)), s = m, o = 0; o < e.length; o += 8) {
+ var i;
+ if (0 < (i = e.indexOf("-"))) throw Error("interior hyphen");
+ if (0 === i) return u(e.substring(1), t, r).neg();
+ for (var n = l(h(r, 8)), s = m, o = 0; o < e.length; o += 8) {
var a = Math.min(8, e.length - o), c = parseInt(e.substring(o, o + a), r);
- s = (a < 8 ? (a = g(h(r, a)), s.mul(a)) : s = s.mul(i)).add(g(c));
+ s = (a < 8 ? (a = l(h(r, a)), s.mul(a)) : s = s.mul(n)).add(l(c));
}
return s.unsigned = t, s;
}
function p(e, t) {
- return "number" == typeof e ? g(e, t) : "string" == typeof e ? u(e, t) : l(e.low, e.high, "boolean" == typeof t ? t : e.unsigned);
+ return "number" == typeof e ? l(e, t) : "string" == typeof e ? u(e, t) : g(e.low, e.high, "boolean" == typeof t ? t : e.unsigned);
}
- e.exports = n;
+ e.exports = i;
var w = null;
try {
w = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([ 0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11 ])), {}).exports;
} catch (e) {}
- Object.defineProperty(n.prototype, "__isLong__", {
+ Object.defineProperty(i.prototype, "__isLong__", {
value: !0
- }), n.isLong = d;
- var s = {}, o = {}, h = (n.fromInt = r, n.fromNumber = g, n.fromBits = l,
- Math.pow), i = (n.fromString = u, n.fromValue = p, 4294967296), a = i * i, c = a / 2, y = r(1 << 24), m = r(0), f = (n.ZERO = m,
- r(0, !0)), v = (n.UZERO = f, r(1)), b = (n.ONE = v, r(1, !0)), E = (n.UONE = b,
- r(-1)), S = (n.NEG_ONE = E, l(-1, 2147483647, !1)), A = (n.MAX_VALUE = S,
- l(-1, -1, !0)), B = (n.MAX_UNSIGNED_VALUE = A, l(0, -2147483648, !1)), P = (n.MIN_VALUE = B,
- n.prototype);
- P.toInt = function() {
+ }), i.isLong = d;
+ var s = {}, o = {}, h = (i.fromInt = r, i.fromNumber = l, i.fromBits = g,
+ Math.pow), n = (i.fromString = u, i.fromValue = p, 4294967296), a = n * n, c = a / 2, y = r(1 << 24), m = r(0), f = (i.ZERO = m,
+ r(0, !0)), v = (i.UZERO = f, r(1)), b = (i.ONE = v, r(1, !0)), S = (i.UONE = b,
+ r(-1)), E = (i.NEG_ONE = S, g(-1, 2147483647, !1)), P = (i.MAX_VALUE = E,
+ g(-1, -1, !0)), A = (i.MAX_UNSIGNED_VALUE = P, g(0, -2147483648, !1)), B = (i.MIN_VALUE = A,
+ i.prototype);
+ B.toInt = function() {
return this.unsigned ? this.low >>> 0 : this.low;
- }, P.toNumber = function() {
- return this.unsigned ? (this.high >>> 0) * i + (this.low >>> 0) : this.high * i + (this.low >>> 0);
- }, P.toString = function(e) {
+ }, B.toNumber = function() {
+ return this.unsigned ? (this.high >>> 0) * n + (this.low >>> 0) : this.high * n + (this.low >>> 0);
+ }, B.toString = function(e) {
if ((e = e || 10) < 2 || 36 < e) throw RangeError("radix");
if (this.isZero()) return "0";
var t, r;
- if (this.isNegative()) return this.eq(B) ? (r = g(e), r = (t = this.div(r)).mul(r).sub(this),
+ if (this.isNegative()) return this.eq(A) ? (r = l(e), r = (t = this.div(r)).mul(r).sub(this),
t.toString(e) + r.toInt().toString(e)) : "-" + this.neg().toString(e);
- for (var n = g(h(e, 6), this.unsigned), i = this, s = ""; ;) {
- var o = i.div(n), a = (i.sub(o.mul(n)).toInt() >>> 0).toString(e);
- if ((i = o).isZero()) return a + s;
+ for (var i = l(h(e, 6), this.unsigned), n = this, s = ""; ;) {
+ var o = n.div(i), a = (n.sub(o.mul(i)).toInt() >>> 0).toString(e);
+ if ((n = o).isZero()) return a + s;
for (;a.length < 6; ) a = "0" + a;
s = "" + a + s;
}
- }, P.getHighBits = function() {
+ }, B.getHighBits = function() {
return this.high;
- }, P.getHighBitsUnsigned = function() {
+ }, B.getHighBitsUnsigned = function() {
return this.high >>> 0;
- }, P.getLowBits = function() {
+ }, B.getLowBits = function() {
return this.low;
- }, P.getLowBitsUnsigned = function() {
+ }, B.getLowBitsUnsigned = function() {
return this.low >>> 0;
- }, P.getNumBitsAbs = function() {
- if (this.isNegative()) return this.eq(B) ? 64 : this.neg().getNumBitsAbs();
+ }, B.getNumBitsAbs = function() {
+ if (this.isNegative()) return this.eq(A) ? 64 : this.neg().getNumBitsAbs();
for (var e = 0 != this.high ? this.high : this.low, t = 31; 0 < t && 0 == (e & 1 << t); t--);
return 0 != this.high ? t + 33 : t + 1;
- }, P.isZero = function() {
+ }, B.isZero = function() {
return 0 === this.high && 0 === this.low;
- }, P.eqz = P.isZero, P.isNegative = function() {
+ }, B.eqz = B.isZero, B.isNegative = function() {
return !this.unsigned && this.high < 0;
- }, P.isPositive = function() {
+ }, B.isPositive = function() {
return this.unsigned || 0 <= this.high;
- }, P.isOdd = function() {
+ }, B.isOdd = function() {
return 1 == (1 & this.low);
- }, P.isEven = function() {
+ }, B.isEven = function() {
return 0 == (1 & this.low);
- }, P.equals = function(e) {
+ }, B.equals = function(e) {
return d(e) || (e = p(e)), (this.unsigned === e.unsigned || this.high >>> 31 != 1 || e.high >>> 31 != 1) && this.high === e.high && this.low === e.low;
- }, P.eq = P.equals, P.notEquals = function(e) {
+ }, B.eq = B.equals, B.notEquals = function(e) {
return !this.eq(e);
- }, P.neq = P.notEquals, P.ne = P.notEquals, P.lessThan = function(e) {
+ }, B.neq = B.notEquals, B.ne = B.notEquals, B.lessThan = function(e) {
return this.comp(e) < 0;
- }, P.lt = P.lessThan, P.lessThanOrEqual = function(e) {
+ }, B.lt = B.lessThan, B.lessThanOrEqual = function(e) {
return this.comp(e) <= 0;
- }, P.lte = P.lessThanOrEqual, P.le = P.lessThanOrEqual, P.greaterThan = function(e) {
+ }, B.lte = B.lessThanOrEqual, B.le = B.lessThanOrEqual, B.greaterThan = function(e) {
return 0 < this.comp(e);
- }, P.gt = P.greaterThan, P.greaterThanOrEqual = function(e) {
+ }, B.gt = B.greaterThan, B.greaterThanOrEqual = function(e) {
return 0 <= this.comp(e);
- }, P.gte = P.greaterThanOrEqual, P.ge = P.greaterThanOrEqual, P.compare = function(e) {
+ }, B.gte = B.greaterThanOrEqual, B.ge = B.greaterThanOrEqual, B.compare = function(e) {
var t, r;
return d(e) || (e = p(e)), this.eq(e) ? 0 : (t = this.isNegative(),
r = e.isNegative(), t && !r ? -1 : !t && r ? 1 : this.unsigned ? e.high >>> 0 > this.high >>> 0 || e.high === this.high && e.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(e).isNegative() ? -1 : 1);
- }, P.comp = P.compare, P.negate = function() {
- return !this.unsigned && this.eq(B) ? B : this.not().add(v);
- }, P.neg = P.negate, P.add = function(e) {
+ }, B.comp = B.compare, B.negate = function() {
+ return !this.unsigned && this.eq(A) ? A : this.not().add(v);
+ }, B.neg = B.negate, B.add = function(e) {
d(e) || (e = p(e));
- var t = this.high >>> 16, r = 65535 & this.high, n = this.low >>> 16, i = 65535 & this.low, s = e.high >>> 16, o = 65535 & e.high, a = e.low >>> 16, c = 0, u = 0, h = 0, f = 0;
- return u += (h = h + ((f += i + (65535 & e.low)) >>> 16) + (n + a)) >>> 16,
- l((h &= 65535) << 16 | (f &= 65535), ((c += (u += r + o) >>> 16) + (t + s) & 65535) << 16 | (u &= 65535), this.unsigned);
- }, P.subtract = function(e) {
+ var t = this.high >>> 16, r = 65535 & this.high, i = this.low >>> 16, n = 65535 & this.low, s = e.high >>> 16, o = 65535 & e.high, a = e.low >>> 16, c = 0, u = 0, h = 0, f = 0;
+ return u += (h = h + ((f += n + (65535 & e.low)) >>> 16) + (i + a)) >>> 16,
+ g((h &= 65535) << 16 | (f &= 65535), ((c += (u += r + o) >>> 16) + (t + s) & 65535) << 16 | (u &= 65535), this.unsigned);
+ }, B.subtract = function(e) {
return d(e) || (e = p(e)), this.add(e.neg());
- }, P.sub = P.subtract, P.multiply = function(e) {
- var t, r, n, i, s, o, a, c, u, h, f;
- return this.isZero() ? m : (d(e) || (e = p(e)), w ? l(w.mul(this.low, this.high, e.low, e.high), w.get_high(), this.unsigned) : e.isZero() ? m : this.eq(B) ? e.isOdd() ? B : m : e.eq(B) ? this.isOdd() ? B : m : this.isNegative() ? e.isNegative() ? this.neg().mul(e.neg()) : this.neg().mul(e).neg() : e.isNegative() ? this.mul(e.neg()).neg() : this.lt(y) && e.lt(y) ? g(this.toNumber() * e.toNumber(), this.unsigned) : (t = this.high >>> 16,
- r = 65535 & this.high, n = this.low >>> 16, i = 65535 & this.low, s = e.high >>> 16,
- o = 65535 & e.high, a = e.low >>> 16, f = (f = h = u = c = 0) + ((u = u + ((h += i * (e = 65535 & e.low)) >>> 16) + n * e) >>> 16) + ((u = (u & 65535) + i * a) >>> 16),
- l((u &= 65535) << 16 | (h &= 65535), (c = (c = (c += (f += r * e) >>> 16) + ((f = (f & 65535) + n * a) >>> 16) + ((f = (f & 65535) + i * o) >>> 16)) + (t * e + r * a + n * o + i * s) & 65535) << 16 | (f &= 65535), this.unsigned)));
- }, P.mul = P.multiply, P.divide = function(e) {
+ }, B.sub = B.subtract, B.multiply = function(e) {
+ var t, r, i, n, s, o, a, c, u, h, f;
+ return this.isZero() ? m : (d(e) || (e = p(e)), w ? g(w.mul(this.low, this.high, e.low, e.high), w.get_high(), this.unsigned) : e.isZero() ? m : this.eq(A) ? e.isOdd() ? A : m : e.eq(A) ? this.isOdd() ? A : m : this.isNegative() ? e.isNegative() ? this.neg().mul(e.neg()) : this.neg().mul(e).neg() : e.isNegative() ? this.mul(e.neg()).neg() : this.lt(y) && e.lt(y) ? l(this.toNumber() * e.toNumber(), this.unsigned) : (t = this.high >>> 16,
+ r = 65535 & this.high, i = this.low >>> 16, n = 65535 & this.low, s = e.high >>> 16,
+ o = 65535 & e.high, a = e.low >>> 16, f = (f = h = u = c = 0) + ((u = u + ((h += n * (e = 65535 & e.low)) >>> 16) + i * e) >>> 16) + ((u = (u & 65535) + n * a) >>> 16),
+ g((u &= 65535) << 16 | (h &= 65535), (c = (c = (c += (f += r * e) >>> 16) + ((f = (f & 65535) + i * a) >>> 16) + ((f = (f & 65535) + n * o) >>> 16)) + (t * e + r * a + i * o + n * s) & 65535) << 16 | (f &= 65535), this.unsigned)));
+ }, B.mul = B.multiply, B.divide = function(e) {
if ((e = d(e) ? e : p(e)).isZero()) throw Error("division by zero");
- if (w) return this.unsigned || -2147483648 !== this.high || -1 !== e.low || -1 !== e.high ? l((this.unsigned ? w.div_u : w.div_s)(this.low, this.high, e.low, e.high), w.get_high(), this.unsigned) : this;
+ if (w) return this.unsigned || -2147483648 !== this.high || -1 !== e.low || -1 !== e.high ? g((this.unsigned ? w.div_u : w.div_s)(this.low, this.high, e.low, e.high), w.get_high(), this.unsigned) : this;
if (this.isZero()) return this.unsigned ? f : m;
var t, r;
if (this.unsigned) {
@@ -492,80 +492,80 @@ var osc = osc || {}, osc = (!function() {
if (e.gt(this.shru(1))) return b;
r = f;
} else {
- if (this.eq(B)) return e.eq(v) || e.eq(E) ? B : e.eq(B) ? v : (n = this.shr(1).div(e).shl(1)).eq(m) ? e.isNegative() ? v : E : (t = this.sub(e.mul(n)),
- n.add(t.div(e)));
- if (e.eq(B)) return this.unsigned ? f : m;
+ if (this.eq(A)) return e.eq(v) || e.eq(S) ? A : e.eq(A) ? v : (i = this.shr(1).div(e).shl(1)).eq(m) ? e.isNegative() ? v : S : (t = this.sub(e.mul(i)),
+ i.add(t.div(e)));
+ if (e.eq(A)) return this.unsigned ? f : m;
if (this.isNegative()) return e.isNegative() ? this.neg().div(e.neg()) : this.neg().div(e).neg();
if (e.isNegative()) return this.div(e.neg()).neg();
r = m;
}
for (t = this; t.gte(e); ) {
- for (var n = Math.max(1, Math.floor(t.toNumber() / e.toNumber())), i = Math.ceil(Math.log(n) / Math.LN2), s = i <= 48 ? 1 : h(2, i - 48), o = g(n), a = o.mul(e); a.isNegative() || a.gt(t); ) a = (o = g(n -= s, this.unsigned)).mul(e);
+ for (var i = Math.max(1, Math.floor(t.toNumber() / e.toNumber())), n = Math.ceil(Math.log(i) / Math.LN2), s = n <= 48 ? 1 : h(2, n - 48), o = l(i), a = o.mul(e); a.isNegative() || a.gt(t); ) a = (o = l(i -= s, this.unsigned)).mul(e);
o.isZero() && (o = v), r = r.add(o), t = t.sub(a);
}
return r;
- }, P.div = P.divide, P.modulo = function(e) {
- return d(e) || (e = p(e)), w ? l((this.unsigned ? w.rem_u : w.rem_s)(this.low, this.high, e.low, e.high), w.get_high(), this.unsigned) : this.sub(this.div(e).mul(e));
- }, P.mod = P.modulo, P.rem = P.modulo, P.not = function() {
- return l(~this.low, ~this.high, this.unsigned);
- }, P.and = function(e) {
- return d(e) || (e = p(e)), l(this.low & e.low, this.high & e.high, this.unsigned);
- }, P.or = function(e) {
- return d(e) || (e = p(e)), l(this.low | e.low, this.high | e.high, this.unsigned);
- }, P.xor = function(e) {
- return d(e) || (e = p(e)), l(this.low ^ e.low, this.high ^ e.high, this.unsigned);
- }, P.shiftLeft = function(e) {
- return d(e) && (e = e.toInt()), 0 == (e &= 63) ? this : e < 32 ? l(this.low << e, this.high << e | this.low >>> 32 - e, this.unsigned) : l(0, this.low << e - 32, this.unsigned);
- }, P.shl = P.shiftLeft, P.shiftRight = function(e) {
- return d(e) && (e = e.toInt()), 0 == (e &= 63) ? this : e < 32 ? l(this.low >>> e | this.high << 32 - e, this.high >> e, this.unsigned) : l(this.high >> e - 32, 0 <= this.high ? 0 : -1, this.unsigned);
- }, P.shr = P.shiftRight, P.shiftRightUnsigned = function(e) {
+ }, B.div = B.divide, B.modulo = function(e) {
+ return d(e) || (e = p(e)), w ? g((this.unsigned ? w.rem_u : w.rem_s)(this.low, this.high, e.low, e.high), w.get_high(), this.unsigned) : this.sub(this.div(e).mul(e));
+ }, B.mod = B.modulo, B.rem = B.modulo, B.not = function() {
+ return g(~this.low, ~this.high, this.unsigned);
+ }, B.and = function(e) {
+ return d(e) || (e = p(e)), g(this.low & e.low, this.high & e.high, this.unsigned);
+ }, B.or = function(e) {
+ return d(e) || (e = p(e)), g(this.low | e.low, this.high | e.high, this.unsigned);
+ }, B.xor = function(e) {
+ return d(e) || (e = p(e)), g(this.low ^ e.low, this.high ^ e.high, this.unsigned);
+ }, B.shiftLeft = function(e) {
+ return d(e) && (e = e.toInt()), 0 == (e &= 63) ? this : e < 32 ? g(this.low << e, this.high << e | this.low >>> 32 - e, this.unsigned) : g(0, this.low << e - 32, this.unsigned);
+ }, B.shl = B.shiftLeft, B.shiftRight = function(e) {
+ return d(e) && (e = e.toInt()), 0 == (e &= 63) ? this : e < 32 ? g(this.low >>> e | this.high << 32 - e, this.high >> e, this.unsigned) : g(this.high >> e - 32, 0 <= this.high ? 0 : -1, this.unsigned);
+ }, B.shr = B.shiftRight, B.shiftRightUnsigned = function(e) {
var t;
return d(e) && (e = e.toInt()), 0 == (e &= 63) ? this : (t = this.high,
- e < 32 ? l(this.low >>> e | t << 32 - e, t >>> e, this.unsigned) : l(32 === e ? t : t >>> e - 32, 0, this.unsigned));
- }, P.shru = P.shiftRightUnsigned, P.shr_u = P.shiftRightUnsigned, P.toSigned = function() {
- return this.unsigned ? l(this.low, this.high, !1) : this;
- }, P.toUnsigned = function() {
- return this.unsigned ? this : l(this.low, this.high, !0);
- }, P.toBytes = function(e) {
+ e < 32 ? g(this.low >>> e | t << 32 - e, t >>> e, this.unsigned) : g(32 === e ? t : t >>> e - 32, 0, this.unsigned));
+ }, B.shru = B.shiftRightUnsigned, B.shr_u = B.shiftRightUnsigned, B.toSigned = function() {
+ return this.unsigned ? g(this.low, this.high, !1) : this;
+ }, B.toUnsigned = function() {
+ return this.unsigned ? this : g(this.low, this.high, !0);
+ }, B.toBytes = function(e) {
return e ? this.toBytesLE() : this.toBytesBE();
- }, P.toBytesLE = function() {
+ }, B.toBytesLE = function() {
var e = this.high, t = this.low;
return [ 255 & t, t >>> 8 & 255, t >>> 16 & 255, t >>> 24, 255 & e, e >>> 8 & 255, e >>> 16 & 255, e >>> 24 ];
- }, P.toBytesBE = function() {
+ }, B.toBytesBE = function() {
var e = this.high, t = this.low;
return [ e >>> 24, e >>> 16 & 255, e >>> 8 & 255, 255 & e, t >>> 24, t >>> 16 & 255, t >>> 8 & 255, 255 & t ];
- }, n.fromBytes = function(e, t, r) {
- return r ? n.fromBytesLE(e, t) : n.fromBytesBE(e, t);
- }, n.fromBytesLE = function(e, t) {
- return new n(e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24, e[4] | e[5] << 8 | e[6] << 16 | e[7] << 24, t);
- }, n.fromBytesBE = function(e, t) {
- return new n(e[4] << 24 | e[5] << 16 | e[6] << 8 | e[7], e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3], t);
+ }, i.fromBytes = function(e, t, r) {
+ return r ? i.fromBytesLE(e, t) : i.fromBytesBE(e, t);
+ }, i.fromBytesLE = function(e, t) {
+ return new i(e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24, e[4] | e[5] << 8 | e[6] << 16 | e[7] << 24, t);
+ }, i.fromBytesBE = function(e, t) {
+ return new i(e[4] << 24 | e[5] << 16 | e[6] << 8 | e[7], e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3], t);
};
- } ], i = {}, n.m = r, n.c = i, n.d = function(e, t, r) {
- n.o(e, t) || Object.defineProperty(e, t, {
+ } ], n = {}, i.m = r, i.c = n, i.d = function(e, t, r) {
+ i.o(e, t) || Object.defineProperty(e, t, {
configurable: !1,
enumerable: !0,
get: r
});
- }, n.n = function(e) {
+ }, i.n = function(e) {
var t = e && e.__esModule ? function() {
return e.default;
} : function() {
return e;
};
- return n.d(t, "a", t), t;
- }, n.o = function(e, t) {
+ return i.d(t, "a", t), t;
+ }, i.o = function(e, t) {
return Object.prototype.hasOwnProperty.call(e, t);
- }, n.p = "", n(n.s = 0);
- function n(e) {
+ }, i.p = "", i(i.s = 0);
+ function i(e) {
var t;
- return (i[e] || (t = i[e] = {
+ return (n[e] || (t = n[e] = {
i: e,
l: !1,
exports: {}
- }, r[e].call(t.exports, t, t.exports, n), t.l = !0, t)).exports;
+ }, r[e].call(t.exports, t, t.exports, i), t.l = !0, t)).exports;
}
- var r, i;
+ var r, n;
}), !function(t, r) {
"use strict";
"object" == typeof exports ? (t.slip = exports, r(exports)) : "function" == typeof define && define.amd ? define([ "exports" ], function(e) {
@@ -584,15 +584,15 @@ var osc = osc || {}, osc = (!function() {
return new Uint8Array(e);
}, o.encode = function(e, t) {
(t = t || {}).bufferPadding = t.bufferPadding || 4;
- var t = (e = o.byteArray(e, t.offset, t.byteLength)).length + t.bufferPadding + 3 & -4, r = new Uint8Array(t), n = 1;
+ var t = (e = o.byteArray(e, t.offset, t.byteLength)).length + t.bufferPadding + 3 & -4, r = new Uint8Array(t), i = 1;
r[0] = o.END;
- for (var i = 0; i < e.length; i++) {
- n > r.length - 3 && (r = o.expandByteArray(r));
- var s = e[i];
- s === o.END ? (r[n++] = o.ESC, s = o.ESC_END) : s === o.ESC && (r[n++] = o.ESC,
- s = o.ESC_ESC), r[n++] = s;
+ for (var n = 0; n < e.length; n++) {
+ i > r.length - 3 && (r = o.expandByteArray(r));
+ var s = e[n];
+ s === o.END ? (r[i++] = o.ESC, s = o.ESC_END) : s === o.ESC && (r[i++] = o.ESC,
+ s = o.ESC_ESC), r[i++] = s;
}
- return r[n] = o.END, o.sliceByteArray(r, 0, n + 1);
+ return r[i] = o.END, o.sliceByteArray(r, 0, i + 1);
}, o.Decoder = function(e) {
this.maxMessageSize = (e = "function" != typeof e ? e || {} : {
onMessage: e
@@ -604,18 +604,18 @@ var osc = osc || {}, osc = (!function() {
var t;
e = o.byteArray(e);
for (var r = 0; r < e.length; r++) {
- var n = e[r];
- if (this.escape) n === o.ESC_ESC ? n = o.ESC : n === o.ESC_END && (n = o.END); else {
- if (n === o.ESC) {
+ var i = e[r];
+ if (this.escape) i === o.ESC_ESC ? i = o.ESC : i === o.ESC_END && (i = o.END); else {
+ if (i === o.ESC) {
this.escape = !0;
continue;
}
- if (n === o.END) {
+ if (i === o.END) {
t = this.handleEnd();
continue;
}
}
- this.addByte(n) || this.handleMessageMaxError();
+ this.addByte(i) || this.handleMessageMaxError();
}
return t;
}, e.handleMessageMaxError = function() {
@@ -632,19 +632,19 @@ var osc = osc || {}, osc = (!function() {
}), !function(e) {
"use strict";
function t() {}
- var r = t.prototype, n = e.EventEmitter;
+ var r = t.prototype, i = e.EventEmitter;
function s(e, t) {
for (var r = e.length; r--; ) if (e[r].listener === t) return r;
return -1;
}
- function i(e) {
+ function n(e) {
return function() {
return this[e].apply(this, arguments);
};
}
r.getListeners = function(e) {
- var t, r, n = this._getEvents();
- if (e instanceof RegExp) for (r in t = {}, n) n.hasOwnProperty(r) && e.test(r) && (t[r] = n[r]); else t = n[e] || (n[e] = []);
+ var t, r, i = this._getEvents();
+ if (e instanceof RegExp) for (r in t = {}, i) i.hasOwnProperty(r) && e.test(r) && (t[r] = i[r]); else t = i[e] || (i[e] = []);
return t;
}, r.flattenListeners = function(e) {
for (var t = [], r = 0; r < e.length; r += 1) t.push(e[r].listener);
@@ -656,44 +656,44 @@ var osc = osc || {}, osc = (!function() {
if (!function e(t) {
return "function" == typeof t || t instanceof RegExp || !(!t || "object" != typeof t) && e(t.listener);
}(t)) throw new TypeError("listener must be a function");
- var r, n = this.getListenersAsObject(e), i = "object" == typeof t;
- for (r in n) n.hasOwnProperty(r) && -1 === s(n[r], t) && n[r].push(i ? t : {
+ var r, i = this.getListenersAsObject(e), n = "object" == typeof t;
+ for (r in i) i.hasOwnProperty(r) && -1 === s(i[r], t) && i[r].push(n ? t : {
listener: t,
once: !1
});
return this;
- }, r.on = i("addListener"), r.addOnceListener = function(e, t) {
+ }, r.on = n("addListener"), r.addOnceListener = function(e, t) {
return this.addListener(e, {
listener: t,
once: !0
});
- }, r.once = i("addOnceListener"), r.defineEvent = function(e) {
+ }, r.once = n("addOnceListener"), r.defineEvent = function(e) {
return this.getListeners(e), this;
}, r.defineEvents = function(e) {
for (var t = 0; t < e.length; t += 1) this.defineEvent(e[t]);
return this;
}, r.removeListener = function(e, t) {
- var r, n, i = this.getListenersAsObject(e);
- for (n in i) i.hasOwnProperty(n) && -1 !== (r = s(i[n], t)) && i[n].splice(r, 1);
+ var r, i, n = this.getListenersAsObject(e);
+ for (i in n) n.hasOwnProperty(i) && -1 !== (r = s(n[i], t)) && n[i].splice(r, 1);
return this;
- }, r.off = i("removeListener"), r.addListeners = function(e, t) {
+ }, r.off = n("removeListener"), r.addListeners = function(e, t) {
return this.manipulateListeners(!1, e, t);
}, r.removeListeners = function(e, t) {
return this.manipulateListeners(!0, e, t);
}, r.manipulateListeners = function(e, t, r) {
- var n, i, s = e ? this.removeListener : this.addListener, o = e ? this.removeListeners : this.addListeners;
- if ("object" != typeof t || t instanceof RegExp) for (n = r.length; n--; ) s.call(this, t, r[n]); else for (n in t) t.hasOwnProperty(n) && (i = t[n]) && ("function" == typeof i ? s : o).call(this, n, i);
+ var i, n, s = e ? this.removeListener : this.addListener, o = e ? this.removeListeners : this.addListeners;
+ if ("object" != typeof t || t instanceof RegExp) for (i = r.length; i--; ) s.call(this, t, r[i]); else for (i in t) t.hasOwnProperty(i) && (n = t[i]) && ("function" == typeof n ? s : o).call(this, i, n);
return this;
}, r.removeEvent = function(e) {
- var t, r = typeof e, n = this._getEvents();
- if ("string" == r) delete n[e]; else if (e instanceof RegExp) for (t in n) n.hasOwnProperty(t) && e.test(t) && delete n[t]; else delete this._events;
+ var t, r = typeof e, i = this._getEvents();
+ if ("string" == r) delete i[e]; else if (e instanceof RegExp) for (t in i) i.hasOwnProperty(t) && e.test(t) && delete i[t]; else delete this._events;
return this;
- }, r.removeAllListeners = i("removeEvent"), r.emitEvent = function(e, t) {
- var r, n, i, s, o = this.getListenersAsObject(e);
- for (s in o) if (o.hasOwnProperty(s)) for (r = o[s].slice(0), i = 0; i < r.length; i++) !0 === (n = r[i]).once && this.removeListener(e, n.listener),
- n.listener.apply(this, t || []) === this._getOnceReturnValue() && this.removeListener(e, n.listener);
+ }, r.removeAllListeners = n("removeEvent"), r.emitEvent = function(e, t) {
+ var r, i, n, s, o = this.getListenersAsObject(e);
+ for (s in o) if (o.hasOwnProperty(s)) for (r = o[s].slice(0), n = 0; n < r.length; n++) !0 === (i = r[n]).once && this.removeListener(e, i.listener),
+ i.listener.apply(this, t || []) === this._getOnceReturnValue() && this.removeListener(e, i.listener);
return this;
- }, r.trigger = i("emitEvent"), r.emit = function(e) {
+ }, r.trigger = n("emitEvent"), r.emit = function(e) {
var t = Array.prototype.slice.call(arguments, 1);
return this.emitEvent(e, t);
}, r.setOnceReturnValue = function(e) {
@@ -703,19 +703,19 @@ var osc = osc || {}, osc = (!function() {
}, r._getEvents = function() {
return this._events || (this._events = {});
}, t.noConflict = function() {
- return e.EventEmitter = n, t;
+ return e.EventEmitter = i, t;
}, "function" == typeof define && define.amd ? define(function() {
return t;
}) : "object" == typeof module && module.exports ? module.exports = t : e.EventEmitter = t;
}("undefined" != typeof window ? window : this || {}), osc || require("./osc.js")), slip = slip || require("slip"), EventEmitter = EventEmitter || require("events").EventEmitter, osc = (!function() {
"use strict";
- osc.supportsSerial = !1, osc.firePacketEvents = function(e, t, r, n) {
- t.address ? e.emit("message", t, r, n) : osc.fireBundleEvents(e, t, r, n);
- }, osc.fireBundleEvents = function(e, t, r, n) {
- e.emit("bundle", t, r, n);
- for (var i = 0; i < t.packets.length; i++) {
- var s = t.packets[i];
- osc.firePacketEvents(e, s, t.timeTag, n);
+ osc.supportsSerial = !1, osc.firePacketEvents = function(e, t, r, i) {
+ t.address ? e.emit("message", t, r, i) : osc.fireBundleEvents(e, t, r, i);
+ }, osc.fireBundleEvents = function(e, t, r, i) {
+ e.emit("bundle", t, r, i);
+ for (var n = 0; n < t.packets.length; n++) {
+ var s = t.packets[n];
+ osc.firePacketEvents(e, s, t.timeTag, i);
}
}, osc.fireClosedPortSendError = function(e, t) {
e.emit("error", t = t || "Can't send packets on a closed osc.Port object. Please open (or reopen) this Port by calling open().");
@@ -763,18 +763,18 @@ var osc = osc || {}, osc = (!function() {
return r;
}, e.decodeSLIPData = function(e, t) {
this.decoder.decode(e, t);
- }, osc.relay = function(e, t, r, n, i, s) {
- r = r || "message", n = n || "send", i = i || function() {}, s = s ? [ null ].concat(s) : [];
+ }, osc.relay = function(e, t, r, i, n, s) {
+ r = r || "message", i = i || "send", n = n || function() {}, s = s ? [ null ].concat(s) : [];
function o(e) {
- s[0] = e, e = i(e), t[n].apply(t, s);
+ s[0] = e, e = n(e), t[i].apply(t, s);
}
return e.on(r, o), {
eventName: r,
listener: o
};
}, osc.relayPorts = function(e, t, r) {
- var n = r.raw ? "raw" : "osc", i = r.raw ? "sendRaw" : "send";
- return osc.relay(e, t, n, i, r.transform);
+ var i = r.raw ? "raw" : "osc", n = r.raw ? "sendRaw" : "send";
+ return osc.relay(e, t, i, n, r.transform);
}, osc.stopRelaying = function(e, t) {
e.removeListener(t.eventName, t.listener);
}, osc.Relay = function(e, t, r) {
@@ -825,4 +825,56 @@ var osc = osc || {}, osc = (!function() {
}, osc.WebSocketPort.setupSocketForBinary = function(e) {
e.binaryType = osc.isNode ? "nodebuffer" : "arraybuffer";
};
+}(), (osc = osc || require("./osc.js")).supportsSerial = !0, function() {
+ "use strict";
+ osc.SerialPort = function(e) {
+ if (!("serial" in navigator)) throw Error("Web serial not supported in your browser. Check https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API#browser_compatibility for more info.");
+ this.on("open", this.listen.bind(this)), osc.SLIPPort.call(this, e), this.options.bitrate = this.options.bitrate || 9600,
+ this.serialPort = e.serialPort, this.serialPort && this.emit("open", this.serialPort);
+ };
+ var e = osc.SerialPort.prototype = Object.create(osc.SLIPPort.prototype);
+ e.constructor = osc.SerialPort, e.open = async function() {
+ if (this.serialPort) this.once("close", this.open.bind(this)), this.close(); else try {
+ this.serialPort = await navigator.serial.requestPort(), await this.serialPort.open(this.options),
+ this.serialPort.isOpen = !0, this.emit("open", this.serialPort);
+ } catch (e) {
+ this.serialPort.isOpen = !1, this.emit("error", e);
+ }
+ }, e.listen = async function() {
+ for (;this.serialPort.readable; ) {
+ var e = this.serialPort.readable.getReader();
+ try {
+ for (;;) {
+ var {
+ value: t,
+ done: r
+ } = await e.read();
+ if (r) break;
+ this.emit("data", t, void 0);
+ }
+ } catch (e) {
+ this.emit("error", e);
+ } finally {
+ e.releaseLock();
+ }
+ }
+ this.emit("ready");
+ }, e.messageQueue = [], e.isWriting = !1, e.sendRaw = async function(e) {
+ if (this.serialPort && this.serialPort.isOpen) {
+ if (this.messageQueue.push(e), !this.isWriting) {
+ this.isWriting = !0;
+ for (var t = this.serialPort.writable.getWriter(); 0 < this.messageQueue.length; ) {
+ var r = this.messageQueue.shift();
+ try {
+ await t.write(r);
+ } catch (e) {
+ console.error(e), this.emit("error", e);
+ }
+ }
+ t.releaseLock(), this.isWriting = !1;
+ }
+ } else osc.fireClosedPortSendError(this);
+ }, e.close = function() {
+ this.serialPort && (this.serialPort.close(), this.serialPort.isOpen = !1);
+ };
}();
\ No newline at end of file
diff --git a/dist/osc-chromeapp.js b/dist/osc-chromeapp.js
index 979e0f5..e87987f 100644
--- a/dist/osc-chromeapp.js
+++ b/dist/osc-chromeapp.js
@@ -2117,6 +2117,117 @@ var osc = osc || require("./osc.js");
}());
;
+/*
+ * osc.js: An Open Sound Control library for JavaScript that works in both the browser and Node.js
+ *
+ * WebSerial serial transport for osc.js
+ *
+ * Licensed under the MIT and GPL 3 licenses.
+ */
+
+/*global WebSerial, require*/
+var osc = osc || require("./osc.js");
+
+osc.supportsSerial = true;
+
+(function () {
+ "use strict";
+
+ osc.SerialPort = function (options) {
+ if ("serial" in navigator) {
+ this.on("open", this.listen.bind(this));
+ osc.SLIPPort.call(this, options);
+ this.options.bitrate = this.options.bitrate || 9600;
+
+ this.serialPort = options.serialPort;
+ if (this.serialPort) {
+ this.emit("open", this.serialPort);
+ }
+ } else {
+ throw Error(
+ "Web serial not supported in your browser. Check https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API#browser_compatibility for more info."
+ );
+ }
+ };
+
+ var p = (osc.SerialPort.prototype = Object.create(osc.SLIPPort.prototype));
+ p.constructor = osc.SerialPort;
+
+ p.open = async function () {
+ if (this.serialPort) {
+ // If we already have a serial port, close it and open a new one.
+ this.once("close", this.open.bind(this));
+ this.close();
+ return;
+ }
+
+ try {
+ this.serialPort = await navigator.serial.requestPort();
+ await this.serialPort.open(this.options);
+ this.serialPort.isOpen = true;
+ this.emit("open", this.serialPort);
+ } catch (error) {
+ this.serialPort.isOpen = false;
+ this.emit("error", error);
+ }
+ };
+
+ p.listen = async function () {
+ while (this.serialPort.readable) {
+ const reader = this.serialPort.readable.getReader();
+ try {
+ while (true) {
+ const { value, done } = await reader.read();
+ if (done) {
+ break;
+ }
+ this.emit("data", value, undefined);
+ }
+ } catch (error) {
+ this.emit("error", error);
+ } finally {
+ reader.releaseLock();
+ }
+ }
+ this.emit("ready");
+ };
+
+ p.messageQueue = [];
+ p.isWriting = false;
+
+ p.sendRaw = async function (encoded) {
+ if (!this.serialPort || !this.serialPort.isOpen) {
+ osc.fireClosedPortSendError(this);
+ return;
+ }
+
+ this.messageQueue.push(encoded);
+
+ if (!this.isWriting) {
+ this.isWriting = true;
+ const writer = this.serialPort.writable.getWriter();
+ while (this.messageQueue.length > 0) {
+ const nextMessage = this.messageQueue.shift();
+ try {
+ await writer.write(nextMessage);
+ } catch (error) {
+ console.error(error);
+ this.emit("error", error);
+ }
+ }
+ writer.releaseLock();
+ this.isWriting = false;
+ }
+ };
+
+ p.close = function () {
+ if (this.serialPort) {
+ this.serialPort.close();
+ this.serialPort.isOpen = false;
+ }
+ };
+})();
+;
/*
* osc.js: An Open Sound Control library for JavaScript that works in both the browser and Node.js
*
diff --git a/dist/osc-chromeapp.min.js b/dist/osc-chromeapp.min.js
index c17a871..c0eff64 100644
--- a/dist/osc-chromeapp.min.js
+++ b/dist/osc-chromeapp.min.js
@@ -6,117 +6,117 @@ var osc = osc || {}, osc = (!function() {
unpackSingleArgs: !0
}, osc.isCommonJS = !("undefined" == typeof module || !module.exports), osc.isNode = osc.isCommonJS && "undefined" == typeof window,
osc.isElectron = !("undefined" == typeof process || !process.versions || !process.versions.electron),
- osc.isBufferEnv = osc.isNode || osc.isElectron, osc.isArray = function(e) {
- return e && "[object Array]" === Object.prototype.toString.call(e);
- }, osc.isTypedArrayView = function(e) {
- return e.buffer && e.buffer instanceof ArrayBuffer;
- }, osc.isBuffer = function(e) {
- return osc.isBufferEnv && e instanceof Buffer;
+ osc.isBufferEnv = osc.isNode || osc.isElectron, osc.isArray = function(t) {
+ return t && "[object Array]" === Object.prototype.toString.call(t);
+ }, osc.isTypedArrayView = function(t) {
+ return t.buffer && t.buffer instanceof ArrayBuffer;
+ }, osc.isBuffer = function(t) {
+ return osc.isBufferEnv && t instanceof Buffer;
}, osc.Long = "undefined" != typeof Long ? Long : osc.isNode ? require("long") : void 0,
osc.TextDecoder = "undefined" != typeof TextDecoder ? new TextDecoder("utf-8") : "undefined" != typeof util && (util.TextDecoder,
1) ? new util.TextDecoder("utf-8") : void 0, osc.TextEncoder = "undefined" != typeof TextEncoder ? new TextEncoder("utf-8") : "undefined" != typeof util && (util.TextEncoder,
- 1) ? new util.TextEncoder("utf-8") : void 0, osc.dataView = function(e, t, r) {
- return e.buffer ? new DataView(e.buffer, t, r) : e instanceof ArrayBuffer ? new DataView(e, t, r) : new DataView(new Uint8Array(e), t, r);
- }, osc.byteArray = function(e) {
- if (e instanceof Uint8Array) return e;
- var t = e.buffer || e;
- if (t instanceof ArrayBuffer || void 0 !== t.length && "string" != typeof t) return new Uint8Array(t);
- throw new Error("Can't wrap a non-array-like object as Uint8Array. Object was: " + JSON.stringify(e, null, 2));
- }, osc.nativeBuffer = function(e) {
- return osc.isBufferEnv ? osc.isBuffer(e) ? e : Buffer.from(e.buffer ? e : new Uint8Array(e)) : osc.isTypedArrayView(e) ? e : new Uint8Array(e);
- }, osc.copyByteArray = function(e, t, r) {
- if (osc.isTypedArrayView(e) && osc.isTypedArrayView(t)) t.set(e, r); else for (var n = void 0 === r ? 0 : r, i = Math.min(t.length - r, e.length), s = 0, o = n; s < i; s++,
- o++) t[o] = e[s];
- return t;
- }, osc.readString = function(e, t) {
- for (var r = [], n = t.idx; n < e.byteLength; n++) {
- var i = e.getUint8(n);
- if (0 === i) {
- n++;
+ 1) ? new util.TextEncoder("utf-8") : void 0, osc.dataView = function(t, e, r) {
+ return t.buffer ? new DataView(t.buffer, e, r) : t instanceof ArrayBuffer ? new DataView(t, e, r) : new DataView(new Uint8Array(t), e, r);
+ }, osc.byteArray = function(t) {
+ if (t instanceof Uint8Array) return t;
+ var e = t.buffer || t;
+ if (e instanceof ArrayBuffer || void 0 !== e.length && "string" != typeof e) return new Uint8Array(e);
+ throw new Error("Can't wrap a non-array-like object as Uint8Array. Object was: " + JSON.stringify(t, null, 2));
+ }, osc.nativeBuffer = function(t) {
+ return osc.isBufferEnv ? osc.isBuffer(t) ? t : Buffer.from(t.buffer ? t : new Uint8Array(t)) : osc.isTypedArrayView(t) ? t : new Uint8Array(t);
+ }, osc.copyByteArray = function(t, e, r) {
+ if (osc.isTypedArrayView(t) && osc.isTypedArrayView(e)) e.set(t, r); else for (var i = void 0 === r ? 0 : r, n = Math.min(e.length - r, t.length), s = 0, o = i; s < n; s++,
+ o++) e[o] = t[s];
+ return e;
+ }, osc.readString = function(t, e) {
+ for (var r = [], i = e.idx; i < t.byteLength; i++) {
+ var n = t.getUint8(i);
+ if (0 === n) {
+ i++;
break;
}
- r.push(i);
+ r.push(n);
}
- return t.idx = n = n + 3 & -4, (osc.isBufferEnv ? osc.readString.withBuffer : osc.TextDecoder ? osc.readString.withTextDecoder : osc.readString.raw)(r);
- }, osc.readString.raw = function(e) {
- for (var t = "", r = 0; r < e.length; r += 1e4) t += String.fromCharCode.apply(null, e.slice(r, r + 1e4));
- return t;
- }, osc.readString.withTextDecoder = function(e) {
- e = new Int8Array(e);
- return osc.TextDecoder.decode(e);
- }, osc.readString.withBuffer = function(e) {
- return Buffer.from(e).toString("utf-8");
- }, osc.writeString = function(e) {
- for (var t, r = osc.isBufferEnv ? osc.writeString.withBuffer : osc.TextEncoder ? osc.writeString.withTextEncoder : null, n = e + "\0", i = (r && (t = r(n)),
- (r ? t : n).length), s = new Uint8Array(i + 3 & -4), o = 0; o < i - 1; o++) {
- var c = r ? t[o] : n.charCodeAt(o);
+ return e.idx = i = i + 3 & -4, (osc.isBufferEnv ? osc.readString.withBuffer : osc.TextDecoder ? osc.readString.withTextDecoder : osc.readString.raw)(r);
+ }, osc.readString.raw = function(t) {
+ for (var e = "", r = 0; r < t.length; r += 1e4) e += String.fromCharCode.apply(null, t.slice(r, r + 1e4));
+ return e;
+ }, osc.readString.withTextDecoder = function(t) {
+ t = new Int8Array(t);
+ return osc.TextDecoder.decode(t);
+ }, osc.readString.withBuffer = function(t) {
+ return Buffer.from(t).toString("utf-8");
+ }, osc.writeString = function(t) {
+ for (var e, r = osc.isBufferEnv ? osc.writeString.withBuffer : osc.TextEncoder ? osc.writeString.withTextEncoder : null, i = t + "\0", n = (r && (e = r(i)),
+ (r ? e : i).length), s = new Uint8Array(n + 3 & -4), o = 0; o < n - 1; o++) {
+ var c = r ? e[o] : i.charCodeAt(o);
s[o] = c;
}
return s;
- }, osc.writeString.withTextEncoder = function(e) {
- return osc.TextEncoder.encode(e);
- }, osc.writeString.withBuffer = function(e) {
- return Buffer.from(e);
- }, osc.readPrimitive = function(e, t, r, n) {
- e = e[t](n.idx, !1);
- return n.idx += r, e;
- }, osc.writePrimitive = function(e, t, r, n, i) {
+ }, osc.writeString.withTextEncoder = function(t) {
+ return osc.TextEncoder.encode(t);
+ }, osc.writeString.withBuffer = function(t) {
+ return Buffer.from(t);
+ }, osc.readPrimitive = function(t, e, r, i) {
+ t = t[e](i.idx, !1);
+ return i.idx += r, t;
+ }, osc.writePrimitive = function(t, e, r, i, n) {
var s;
- return i = void 0 === i ? 0 : i, t ? s = new Uint8Array(t.buffer) : (s = new Uint8Array(n),
- t = new DataView(s.buffer)), t[r](i, e, !1), s;
- }, osc.readInt32 = function(e, t) {
- return osc.readPrimitive(e, "getInt32", 4, t);
- }, osc.writeInt32 = function(e, t, r) {
- return osc.writePrimitive(e, t, "setInt32", 4, r);
- }, osc.readInt64 = function(e, t) {
- var r = osc.readPrimitive(e, "getInt32", 4, t), e = osc.readPrimitive(e, "getInt32", 4, t);
- return osc.Long ? new osc.Long(e, r) : {
+ return n = void 0 === n ? 0 : n, e ? s = new Uint8Array(e.buffer) : (s = new Uint8Array(i),
+ e = new DataView(s.buffer)), e[r](n, t, !1), s;
+ }, osc.readInt32 = function(t, e) {
+ return osc.readPrimitive(t, "getInt32", 4, e);
+ }, osc.writeInt32 = function(t, e, r) {
+ return osc.writePrimitive(t, e, "setInt32", 4, r);
+ }, osc.readInt64 = function(t, e) {
+ var r = osc.readPrimitive(t, "getInt32", 4, e), t = osc.readPrimitive(t, "getInt32", 4, e);
+ return osc.Long ? new osc.Long(t, r) : {
high: r,
- low: e,
+ low: t,
unsigned: !1
};
- }, osc.writeInt64 = function(e, t, r) {
- var n = new Uint8Array(8);
- return n.set(osc.writePrimitive(e.high, t, "setInt32", 4, r), 0), n.set(osc.writePrimitive(e.low, t, "setInt32", 4, r + 4), 4),
- n;
- }, osc.readFloat32 = function(e, t) {
- return osc.readPrimitive(e, "getFloat32", 4, t);
- }, osc.writeFloat32 = function(e, t, r) {
- return osc.writePrimitive(e, t, "setFloat32", 4, r);
- }, osc.readFloat64 = function(e, t) {
- return osc.readPrimitive(e, "getFloat64", 8, t);
- }, osc.writeFloat64 = function(e, t, r) {
- return osc.writePrimitive(e, t, "setFloat64", 8, r);
- }, osc.readChar32 = function(e, t) {
- e = osc.readPrimitive(e, "getUint32", 4, t);
- return String.fromCharCode(e);
- }, osc.writeChar32 = function(e, t, r) {
- e = e.charCodeAt(0);
- if (!(void 0 === e || e < -1)) return osc.writePrimitive(e, t, "setUint32", 4, r);
- }, osc.readBlob = function(e, t) {
- var r = osc.readInt32(e, t), n = r + 3 & -4, e = new Uint8Array(e.buffer, t.idx, r);
- return t.idx += n, e;
- }, osc.writeBlob = function(e) {
- var t = (e = osc.byteArray(e)).byteLength, r = new Uint8Array(4 + (t + 3 & -4)), n = new DataView(r.buffer);
- return osc.writeInt32(t, n), r.set(e, 4), r;
- }, osc.readMIDIBytes = function(e, t) {
- e = new Uint8Array(e.buffer, t.idx, 4);
- return t.idx += 4, e;
- }, osc.writeMIDIBytes = function(e) {
- e = osc.byteArray(e);
- var t = new Uint8Array(4);
- return t.set(e), t;
- }, osc.readColor = function(e, t) {
- var e = new Uint8Array(e.buffer, t.idx, 4), r = e[3] / 255;
- return t.idx += 4, {
- r: e[0],
- g: e[1],
- b: e[2],
+ }, osc.writeInt64 = function(t, e, r) {
+ var i = new Uint8Array(8);
+ return i.set(osc.writePrimitive(t.high, e, "setInt32", 4, r), 0), i.set(osc.writePrimitive(t.low, e, "setInt32", 4, r + 4), 4),
+ i;
+ }, osc.readFloat32 = function(t, e) {
+ return osc.readPrimitive(t, "getFloat32", 4, e);
+ }, osc.writeFloat32 = function(t, e, r) {
+ return osc.writePrimitive(t, e, "setFloat32", 4, r);
+ }, osc.readFloat64 = function(t, e) {
+ return osc.readPrimitive(t, "getFloat64", 8, e);
+ }, osc.writeFloat64 = function(t, e, r) {
+ return osc.writePrimitive(t, e, "setFloat64", 8, r);
+ }, osc.readChar32 = function(t, e) {
+ t = osc.readPrimitive(t, "getUint32", 4, e);
+ return String.fromCharCode(t);
+ }, osc.writeChar32 = function(t, e, r) {
+ t = t.charCodeAt(0);
+ if (!(void 0 === t || t < -1)) return osc.writePrimitive(t, e, "setUint32", 4, r);
+ }, osc.readBlob = function(t, e) {
+ var r = osc.readInt32(t, e), i = r + 3 & -4, t = new Uint8Array(t.buffer, e.idx, r);
+ return e.idx += i, t;
+ }, osc.writeBlob = function(t) {
+ var e = (t = osc.byteArray(t)).byteLength, r = new Uint8Array(4 + (e + 3 & -4)), i = new DataView(r.buffer);
+ return osc.writeInt32(e, i), r.set(t, 4), r;
+ }, osc.readMIDIBytes = function(t, e) {
+ t = new Uint8Array(t.buffer, e.idx, 4);
+ return e.idx += 4, t;
+ }, osc.writeMIDIBytes = function(t) {
+ t = osc.byteArray(t);
+ var e = new Uint8Array(4);
+ return e.set(t), e;
+ }, osc.readColor = function(t, e) {
+ var t = new Uint8Array(t.buffer, e.idx, 4), r = t[3] / 255;
+ return e.idx += 4, {
+ r: t[0],
+ g: t[1],
+ b: t[2],
a: r
};
- }, osc.writeColor = function(e) {
- var t = Math.round(255 * e.a);
- return new Uint8Array([ e.r, e.g, e.b, t ]);
+ }, osc.writeColor = function(t) {
+ var e = Math.round(255 * t.a);
+ return new Uint8Array([ t.r, t.g, t.b, e ]);
}, osc.readTrue = function() {
return !0;
}, osc.readFalse = function() {
@@ -125,147 +125,147 @@ var osc = osc || {}, osc = (!function() {
return null;
}, osc.readImpulse = function() {
return 1;
- }, osc.readTimeTag = function(e, t) {
- var r = osc.readPrimitive(e, "getUint32", 4, t), e = osc.readPrimitive(e, "getUint32", 4, t);
+ }, osc.readTimeTag = function(t, e) {
+ var r = osc.readPrimitive(t, "getUint32", 4, e), t = osc.readPrimitive(t, "getUint32", 4, e);
return {
- raw: [ r, e ],
- native: 0 === r && 1 === e ? Date.now() : osc.ntpToJSTime(r, e)
+ raw: [ r, t ],
+ native: 0 === r && 1 === t ? Date.now() : osc.ntpToJSTime(r, t)
};
- }, osc.writeTimeTag = function(e) {
- var e = e.raw || osc.jsToNTPTime(e.native), t = new Uint8Array(8), r = new DataView(t.buffer);
- return osc.writeInt32(e[0], r, 0), osc.writeInt32(e[1], r, 4), t;
- }, osc.timeTag = function(e, t) {
- e = e || 0;
- var t = (t = t || Date.now()) / 1e3, r = Math.floor(t), t = t - r, n = Math.floor(e), t = t + (e - n);
- return 1 < t && (n += e = Math.floor(t), t = t - e), {
- raw: [ r + n + osc.SECS_70YRS, Math.round(osc.TWO_32 * t) ]
+ }, osc.writeTimeTag = function(t) {
+ var t = t.raw || osc.jsToNTPTime(t.native), e = new Uint8Array(8), r = new DataView(e.buffer);
+ return osc.writeInt32(t[0], r, 0), osc.writeInt32(t[1], r, 4), e;
+ }, osc.timeTag = function(t, e) {
+ t = t || 0;
+ var e = (e = e || Date.now()) / 1e3, r = Math.floor(e), e = e - r, i = Math.floor(t), e = e + (t - i);
+ return 1 < e && (i += t = Math.floor(e), e = e - t), {
+ raw: [ r + i + osc.SECS_70YRS, Math.round(osc.TWO_32 * e) ]
};
- }, osc.ntpToJSTime = function(e, t) {
- return 1e3 * (e - osc.SECS_70YRS + t / osc.TWO_32);
- }, osc.jsToNTPTime = function(e) {
- var e = e / 1e3, t = Math.floor(e);
- return [ t + osc.SECS_70YRS, Math.round(osc.TWO_32 * (e - t)) ];
- }, osc.readArguments = function(e, t, r) {
- var n = osc.readString(e, r);
- if (0 !== n.indexOf(",")) throw new Error("A malformed type tag string was found while reading the arguments of an OSC message. String was: " + n, " at offset: " + r.idx);
- var i = n.substring(1).split(""), s = [];
- return osc.readArgumentsIntoArray(s, i, n, e, t, r), s;
- }, osc.readArgument = function(e, t, r, n, i) {
- var s = osc.argumentTypes[e];
- if (s) return s = s.reader, s = osc[s](r, i), n.metadata ? {
- type: e,
+ }, osc.ntpToJSTime = function(t, e) {
+ return 1e3 * (t - osc.SECS_70YRS + e / osc.TWO_32);
+ }, osc.jsToNTPTime = function(t) {
+ var t = t / 1e3, e = Math.floor(t);
+ return [ e + osc.SECS_70YRS, Math.round(osc.TWO_32 * (t - e)) ];
+ }, osc.readArguments = function(t, e, r) {
+ var i = osc.readString(t, r);
+ if (0 !== i.indexOf(",")) throw new Error("A malformed type tag string was found while reading the arguments of an OSC message. String was: " + i, " at offset: " + r.idx);
+ var n = i.substring(1).split(""), s = [];
+ return osc.readArgumentsIntoArray(s, n, i, t, e, r), s;
+ }, osc.readArgument = function(t, e, r, i, n) {
+ var s = osc.argumentTypes[t];
+ if (s) return s = s.reader, s = osc[s](r, n), i.metadata ? {
+ type: t,
value: s
} : s;
- throw new Error("'" + e + "' is not a valid OSC type tag. Type tag string was: " + t);
- }, osc.readArgumentsIntoArray = function(e, t, r, n, i, s) {
- for (var o = 0; o < t.length; ) {
- var c = t[o];
+ throw new Error("'" + t + "' is not a valid OSC type tag. Type tag string was: " + e);
+ }, osc.readArgumentsIntoArray = function(t, e, r, i, n, s) {
+ for (var o = 0; o < e.length; ) {
+ var c = e[o];
if ("[" === c) {
- var a = t.slice(o + 1), u = a.indexOf("]");
+ var a = e.slice(o + 1), u = a.indexOf("]");
if (u < 0) throw new Error("Invalid argument type tag: an open array type tag ('[') was found without a matching close array tag ('[]'). Type tag was: " + r);
- a = a.slice(0, u), a = osc.readArgumentsIntoArray([], a, r, n, i, s);
+ a = a.slice(0, u), a = osc.readArgumentsIntoArray([], a, r, i, n, s);
o += u + 2;
- } else a = osc.readArgument(c, r, n, i, s), o++;
- e.push(a);
- }
- return e;
- }, osc.writeArguments = function(e, t) {
- e = osc.collectArguments(e, t);
- return osc.joinParts(e);
- }, osc.joinParts = function(e) {
- for (var t = new Uint8Array(e.byteLength), r = e.parts, n = 0, i = 0; i < r.length; i++) {
- var s = r[i];
- osc.copyByteArray(s, t, n), n += s.length;
+ } else a = osc.readArgument(c, r, i, n, s), o++;
+ t.push(a);
}
return t;
- }, osc.addDataPart = function(e, t) {
- t.parts.push(e), t.byteLength += e.length;
- }, osc.writeArrayArguments = function(e, t) {
- for (var r = "[", n = 0; n < e.length; n++) {
- var i = e[n];
- r += osc.writeArgument(i, t);
+ }, osc.writeArguments = function(t, e) {
+ t = osc.collectArguments(t, e);
+ return osc.joinParts(t);
+ }, osc.joinParts = function(t) {
+ for (var e = new Uint8Array(t.byteLength), r = t.parts, i = 0, n = 0; n < r.length; n++) {
+ var s = r[n];
+ osc.copyByteArray(s, e, i), i += s.length;
+ }
+ return e;
+ }, osc.addDataPart = function(t, e) {
+ e.parts.push(t), e.byteLength += t.length;
+ }, osc.writeArrayArguments = function(t, e) {
+ for (var r = "[", i = 0; i < t.length; i++) {
+ var n = t[i];
+ r += osc.writeArgument(n, e);
}
return r += "]";
- }, osc.writeArgument = function(e, t) {
+ }, osc.writeArgument = function(t, e) {
var r;
- return osc.isArray(e) ? osc.writeArrayArguments(e, t) : (r = e.type, (r = osc.argumentTypes[r].writer) && (r = osc[r](e.value),
- osc.addDataPart(r, t)), e.type);
- }, osc.collectArguments = function(e, t, r) {
- osc.isArray(e) || (e = void 0 === e ? [] : [ e ]), r = r || {
+ return osc.isArray(t) ? osc.writeArrayArguments(t, e) : (r = t.type, (r = osc.argumentTypes[r].writer) && (r = osc[r](t.value),
+ osc.addDataPart(r, e)), t.type);
+ }, osc.collectArguments = function(t, e, r) {
+ osc.isArray(t) || (t = void 0 === t ? [] : [ t ]), r = r || {
byteLength: 0,
parts: []
- }, t.metadata || (e = osc.annotateArguments(e));
- for (var n = ",", t = r.parts.length, i = 0; i < e.length; i++) {
- var s = e[i];
- n += osc.writeArgument(s, r);
+ }, e.metadata || (t = osc.annotateArguments(t));
+ for (var i = ",", e = r.parts.length, n = 0; n < t.length; n++) {
+ var s = t[n];
+ i += osc.writeArgument(s, r);
}
- var o = osc.writeString(n);
- return r.byteLength += o.byteLength, r.parts.splice(t, 0, o), r;
- }, osc.readMessage = function(e, t, r) {
- t = t || osc.defaults;
- var e = osc.dataView(e, e.byteOffset, e.byteLength), n = osc.readString(e, r = r || {
+ var o = osc.writeString(i);
+ return r.byteLength += o.byteLength, r.parts.splice(e, 0, o), r;
+ }, osc.readMessage = function(t, e, r) {
+ e = e || osc.defaults;
+ var t = osc.dataView(t, t.byteOffset, t.byteLength), i = osc.readString(t, r = r || {
idx: 0
});
- return osc.readMessageContents(n, e, t, r);
- }, osc.readMessageContents = function(e, t, r, n) {
- if (0 !== e.indexOf("/")) throw new Error("A malformed OSC address was found while reading an OSC message. String was: " + e);
- t = osc.readArguments(t, r, n);
+ return osc.readMessageContents(i, t, e, r);
+ }, osc.readMessageContents = function(t, e, r, i) {
+ if (0 !== t.indexOf("/")) throw new Error("A malformed OSC address was found while reading an OSC message. String was: " + t);
+ e = osc.readArguments(e, r, i);
return {
- address: e,
- args: 1 === t.length && r.unpackSingleArgs ? t[0] : t
+ address: t,
+ args: 1 === e.length && r.unpackSingleArgs ? e[0] : e
};
- }, osc.collectMessageParts = function(e, t, r) {
+ }, osc.collectMessageParts = function(t, e, r) {
return r = r || {
byteLength: 0,
parts: []
- }, osc.addDataPart(osc.writeString(e.address), r), osc.collectArguments(e.args, t, r);
- }, osc.writeMessage = function(e, t) {
- if (t = t || osc.defaults, osc.isValidMessage(e)) return t = osc.collectMessageParts(e, t),
- osc.joinParts(t);
- throw new Error("An OSC message must contain a valid address. Message was: " + JSON.stringify(e, null, 2));
- }, osc.isValidMessage = function(e) {
- return e.address && 0 === e.address.indexOf("/");
- }, osc.readBundle = function(e, t, r) {
- return osc.readPacket(e, t, r);
- }, osc.collectBundlePackets = function(e, t, r) {
+ }, osc.addDataPart(osc.writeString(t.address), r), osc.collectArguments(t.args, e, r);
+ }, osc.writeMessage = function(t, e) {
+ if (e = e || osc.defaults, osc.isValidMessage(t)) return e = osc.collectMessageParts(t, e),
+ osc.joinParts(e);
+ throw new Error("An OSC message must contain a valid address. Message was: " + JSON.stringify(t, null, 2));
+ }, osc.isValidMessage = function(t) {
+ return t.address && 0 === t.address.indexOf("/");
+ }, osc.readBundle = function(t, e, r) {
+ return osc.readPacket(t, e, r);
+ }, osc.collectBundlePackets = function(t, e, r) {
r = r || {
byteLength: 0,
parts: []
- }, osc.addDataPart(osc.writeString("#bundle"), r), osc.addDataPart(osc.writeTimeTag(e.timeTag), r);
- for (var n = 0; n < e.packets.length; n++) {
- var i = e.packets[n], i = (i.address ? osc.collectMessageParts : osc.collectBundlePackets)(i, t);
- r.byteLength += i.byteLength, osc.addDataPart(osc.writeInt32(i.byteLength), r),
- r.parts = r.parts.concat(i.parts);
+ }, osc.addDataPart(osc.writeString("#bundle"), r), osc.addDataPart(osc.writeTimeTag(t.timeTag), r);
+ for (var i = 0; i < t.packets.length; i++) {
+ var n = t.packets[i], n = (n.address ? osc.collectMessageParts : osc.collectBundlePackets)(n, e);
+ r.byteLength += n.byteLength, osc.addDataPart(osc.writeInt32(n.byteLength), r),
+ r.parts = r.parts.concat(n.parts);
}
return r;
- }, osc.writeBundle = function(e, t) {
- if (!osc.isValidBundle(e)) throw new Error("An OSC bundle must contain 'timeTag' and 'packets' properties. Bundle was: " + JSON.stringify(e, null, 2));
- t = t || osc.defaults;
- e = osc.collectBundlePackets(e, t);
- return osc.joinParts(e);
- }, osc.isValidBundle = function(e) {
- return void 0 !== e.timeTag && void 0 !== e.packets;
- }, osc.readBundleContents = function(e, t, r, n) {
- for (var i = osc.readTimeTag(e, r), s = []; r.idx < n; ) {
- var o = osc.readInt32(e, r), o = r.idx + o, o = osc.readPacket(e, t, r, o);
+ }, osc.writeBundle = function(t, e) {
+ if (!osc.isValidBundle(t)) throw new Error("An OSC bundle must contain 'timeTag' and 'packets' properties. Bundle was: " + JSON.stringify(t, null, 2));
+ e = e || osc.defaults;
+ t = osc.collectBundlePackets(t, e);
+ return osc.joinParts(t);
+ }, osc.isValidBundle = function(t) {
+ return void 0 !== t.timeTag && void 0 !== t.packets;
+ }, osc.readBundleContents = function(t, e, r, i) {
+ for (var n = osc.readTimeTag(t, r), s = []; r.idx < i; ) {
+ var o = osc.readInt32(t, r), o = r.idx + o, o = osc.readPacket(t, e, r, o);
s.push(o);
}
return {
- timeTag: i,
+ timeTag: n,
packets: s
};
- }, osc.readPacket = function(e, t, r, n) {
- var e = osc.dataView(e, e.byteOffset, e.byteLength), i = (n = void 0 === n ? e.byteLength : n,
- osc.readString(e, r = r || {
+ }, osc.readPacket = function(t, e, r, i) {
+ var t = osc.dataView(t, t.byteOffset, t.byteLength), n = (i = void 0 === i ? t.byteLength : i,
+ osc.readString(t, r = r || {
idx: 0
- })), s = i[0];
- if ("#" === s) return osc.readBundleContents(e, t, r, n);
- if ("/" === s) return osc.readMessageContents(i, e, t, r);
- throw new Error("The header of an OSC packet didn't contain an OSC address or a #bundle string. Header was: " + i);
- }, osc.writePacket = function(e, t) {
- if (osc.isValidMessage(e)) return osc.writeMessage(e, t);
- if (osc.isValidBundle(e)) return osc.writeBundle(e, t);
- throw new Error("The specified packet was not recognized as a valid OSC message or bundle. Packet was: " + JSON.stringify(e, null, 2));
+ })), s = n[0];
+ if ("#" === s) return osc.readBundleContents(t, e, r, i);
+ if ("/" === s) return osc.readMessageContents(n, t, e, r);
+ throw new Error("The header of an OSC packet didn't contain an OSC address or a #bundle string. Header was: " + n);
+ }, osc.writePacket = function(t, e) {
+ if (osc.isValidMessage(t)) return osc.writeMessage(t, e);
+ if (osc.isValidBundle(t)) return osc.writeBundle(t, e);
+ throw new Error("The specified packet was not recognized as a valid OSC message or bundle. Packet was: " + JSON.stringify(t, null, 2));
}, osc.argumentTypes = {
i: {
reader: "readInt32",
@@ -323,10 +323,10 @@ var osc = osc || {}, osc = (!function() {
reader: "readMIDIBytes",
writer: "writeMIDIBytes"
}
- }, osc.inferTypeForArgument = function(e) {
- switch (typeof e) {
+ }, osc.inferTypeForArgument = function(t) {
+ switch (typeof t) {
case "boolean":
- return e ? "T" : "F";
+ return t ? "T" : "F";
case "string":
return "s";
@@ -338,570 +338,626 @@ var osc = osc || {}, osc = (!function() {
return "N";
case "object":
- if (null === e) return "N";
- if (e instanceof Uint8Array || e instanceof ArrayBuffer) return "b";
- if ("number" == typeof e.high && "number" == typeof e.low) return "h";
+ if (null === t) return "N";
+ if (t instanceof Uint8Array || t instanceof ArrayBuffer) return "b";
+ if ("number" == typeof t.high && "number" == typeof t.low) return "h";
}
- throw new Error("Can't infer OSC argument type for value: " + JSON.stringify(e, null, 2));
- }, osc.annotateArguments = function(e) {
- for (var t = [], r = 0; r < e.length; r++) {
- var n = e[r];
- n = "object" == typeof n && n.type && void 0 !== n.value ? n : osc.isArray(n) ? osc.annotateArguments(n) : {
- type: osc.inferTypeForArgument(n),
- value: n
- }, t.push(n);
+ throw new Error("Can't infer OSC argument type for value: " + JSON.stringify(t, null, 2));
+ }, osc.annotateArguments = function(t) {
+ for (var e = [], r = 0; r < t.length; r++) {
+ var i = t[r];
+ i = "object" == typeof i && i.type && void 0 !== i.value ? i : osc.isArray(i) ? osc.annotateArguments(i) : {
+ type: osc.inferTypeForArgument(i),
+ value: i
+ }, e.push(i);
}
- return t;
+ return e;
}, osc.isCommonJS && (module.exports = osc);
-}(), !function(e, t) {
- "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.Long = t() : e.Long = t();
+}(), !function(t, e) {
+ "object" == typeof exports && "object" == typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define([], e) : "object" == typeof exports ? exports.Long = e() : t.Long = e();
}("undefined" != typeof self ? self : this, function() {
- return r = [ function(e, t) {
- function n(e, t, r) {
- this.low = 0 | e, this.high = 0 | t, this.unsigned = !!r;
+ return r = [ function(t, e) {
+ function i(t, e, r) {
+ this.low = 0 | t, this.high = 0 | e, this.unsigned = !!r;
}
- function d(e) {
- return !0 === (e && e.__isLong__);
+ function d(t) {
+ return !0 === (t && t.__isLong__);
}
- function r(e, t) {
- var r, n, i;
- return t ? (i = 0 <= (e >>>= 0) && e < 256) && (n = o[e]) ? n : (r = g(e, (0 | e) < 0 ? -1 : 0, !0),
- i && (o[e] = r), r) : (i = -128 <= (e |= 0) && e < 128) && (n = s[e]) ? n : (r = g(e, e < 0 ? -1 : 0, !1),
- i && (s[e] = r), r);
+ function r(t, e) {
+ var r, i, n;
+ return e ? (n = 0 <= (t >>>= 0) && t < 256) && (i = o[t]) ? i : (r = g(t, (0 | t) < 0 ? -1 : 0, !0),
+ n && (o[t] = r), r) : (n = -128 <= (t |= 0) && t < 128) && (i = s[t]) ? i : (r = g(t, t < 0 ? -1 : 0, !1),
+ n && (s[t] = r), r);
}
- function l(e, t) {
- if (isNaN(e)) return t ? f : y;
- if (t) {
- if (e < 0) return f;
- if (c <= e) return P;
+ function l(t, e) {
+ if (isNaN(t)) return e ? f : y;
+ if (e) {
+ if (t < 0) return f;
+ if (c <= t) return P;
} else {
- if (e <= -a) return A;
- if (a <= e + 1) return E;
+ if (t <= -a) return A;
+ if (a <= t + 1) return E;
}
- return e < 0 ? l(-e, t).neg() : g(e % i | 0, e / i | 0, t);
+ return t < 0 ? l(-t, e).neg() : g(t % n | 0, t / n | 0, e);
}
- function g(e, t, r) {
- return new n(e, t, r);
+ function g(t, e, r) {
+ return new i(t, e, r);
}
- function u(e, t, r) {
- if (0 === e.length) throw Error("empty string");
- if ("NaN" === e || "Infinity" === e || "+Infinity" === e || "-Infinity" === e) return y;
- if (t = "number" == typeof t ? (r = t, !1) : !!t, (r = r || 10) < 2 || 36 < r) throw RangeError("radix");
- var n;
- if (0 < (n = e.indexOf("-"))) throw Error("interior hyphen");
- if (0 === n) return u(e.substring(1), t, r).neg();
- for (var i = l(h(r, 8)), s = y, o = 0; o < e.length; o += 8) {
- var c = Math.min(8, e.length - o), a = parseInt(e.substring(o, o + c), r);
- s = (c < 8 ? (c = l(h(r, c)), s.mul(c)) : s = s.mul(i)).add(l(a));
+ function u(t, e, r) {
+ if (0 === t.length) throw Error("empty string");
+ if ("NaN" === t || "Infinity" === t || "+Infinity" === t || "-Infinity" === t) return y;
+ if (e = "number" == typeof e ? (r = e, !1) : !!e, (r = r || 10) < 2 || 36 < r) throw RangeError("radix");
+ var i;
+ if (0 < (i = t.indexOf("-"))) throw Error("interior hyphen");
+ if (0 === i) return u(t.substring(1), e, r).neg();
+ for (var n = l(h(r, 8)), s = y, o = 0; o < t.length; o += 8) {
+ var c = Math.min(8, t.length - o), a = parseInt(t.substring(o, o + c), r);
+ s = (c < 8 ? (c = l(h(r, c)), s.mul(c)) : s = s.mul(n)).add(l(a));
}
- return s.unsigned = t, s;
+ return s.unsigned = e, s;
}
- function p(e, t) {
- return "number" == typeof e ? l(e, t) : "string" == typeof e ? u(e, t) : g(e.low, e.high, "boolean" == typeof t ? t : e.unsigned);
+ function p(t, e) {
+ return "number" == typeof t ? l(t, e) : "string" == typeof t ? u(t, e) : g(t.low, t.high, "boolean" == typeof e ? e : t.unsigned);
}
- e.exports = n;
+ t.exports = i;
var m = null;
try {
m = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([ 0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11 ])), {}).exports;
- } catch (e) {}
- Object.defineProperty(n.prototype, "__isLong__", {
+ } catch (t) {}
+ Object.defineProperty(i.prototype, "__isLong__", {
value: !0
- }), n.isLong = d;
- var s = {}, o = {}, h = (n.fromInt = r, n.fromNumber = l, n.fromBits = g,
- Math.pow), i = (n.fromString = u, n.fromValue = p, 4294967296), c = i * i, a = c / 2, w = r(1 << 24), y = r(0), f = (n.ZERO = y,
- r(0, !0)), v = (n.UZERO = f, r(1)), b = (n.ONE = v, r(1, !0)), S = (n.UONE = b,
- r(-1)), E = (n.NEG_ONE = S, g(-1, 2147483647, !1)), P = (n.MAX_VALUE = E,
- g(-1, -1, !0)), A = (n.MAX_UNSIGNED_VALUE = P, g(0, -2147483648, !1)), T = (n.MIN_VALUE = A,
- n.prototype);
- T.toInt = function() {
+ }), i.isLong = d;
+ var s = {}, o = {}, h = (i.fromInt = r, i.fromNumber = l, i.fromBits = g,
+ Math.pow), n = (i.fromString = u, i.fromValue = p, 4294967296), c = n * n, a = c / 2, w = r(1 << 24), y = r(0), f = (i.ZERO = y,
+ r(0, !0)), v = (i.UZERO = f, r(1)), b = (i.ONE = v, r(1, !0)), S = (i.UONE = b,
+ r(-1)), E = (i.NEG_ONE = S, g(-1, 2147483647, !1)), P = (i.MAX_VALUE = E,
+ g(-1, -1, !0)), A = (i.MAX_UNSIGNED_VALUE = P, g(0, -2147483648, !1)), I = (i.MIN_VALUE = A,
+ i.prototype);
+ I.toInt = function() {
return this.unsigned ? this.low >>> 0 : this.low;
- }, T.toNumber = function() {
- return this.unsigned ? (this.high >>> 0) * i + (this.low >>> 0) : this.high * i + (this.low >>> 0);
- }, T.toString = function(e) {
- if ((e = e || 10) < 2 || 36 < e) throw RangeError("radix");
+ }, I.toNumber = function() {
+ return this.unsigned ? (this.high >>> 0) * n + (this.low >>> 0) : this.high * n + (this.low >>> 0);
+ }, I.toString = function(t) {
+ if ((t = t || 10) < 2 || 36 < t) throw RangeError("radix");
if (this.isZero()) return "0";
- var t, r;
- if (this.isNegative()) return this.eq(A) ? (r = l(e), r = (t = this.div(r)).mul(r).sub(this),
- t.toString(e) + r.toInt().toString(e)) : "-" + this.neg().toString(e);
- for (var n = l(h(e, 6), this.unsigned), i = this, s = ""; ;) {
- var o = i.div(n), c = (i.sub(o.mul(n)).toInt() >>> 0).toString(e);
- if ((i = o).isZero()) return c + s;
+ var e, r;
+ if (this.isNegative()) return this.eq(A) ? (r = l(t), r = (e = this.div(r)).mul(r).sub(this),
+ e.toString(t) + r.toInt().toString(t)) : "-" + this.neg().toString(t);
+ for (var i = l(h(t, 6), this.unsigned), n = this, s = ""; ;) {
+ var o = n.div(i), c = (n.sub(o.mul(i)).toInt() >>> 0).toString(t);
+ if ((n = o).isZero()) return c + s;
for (;c.length < 6; ) c = "0" + c;
s = "" + c + s;
}
- }, T.getHighBits = function() {
+ }, I.getHighBits = function() {
return this.high;
- }, T.getHighBitsUnsigned = function() {
+ }, I.getHighBitsUnsigned = function() {
return this.high >>> 0;
- }, T.getLowBits = function() {
+ }, I.getLowBits = function() {
return this.low;
- }, T.getLowBitsUnsigned = function() {
+ }, I.getLowBitsUnsigned = function() {
return this.low >>> 0;
- }, T.getNumBitsAbs = function() {
+ }, I.getNumBitsAbs = function() {
if (this.isNegative()) return this.eq(A) ? 64 : this.neg().getNumBitsAbs();
- for (var e = 0 != this.high ? this.high : this.low, t = 31; 0 < t && 0 == (e & 1 << t); t--);
- return 0 != this.high ? t + 33 : t + 1;
- }, T.isZero = function() {
+ for (var t = 0 != this.high ? this.high : this.low, e = 31; 0 < e && 0 == (t & 1 << e); e--);
+ return 0 != this.high ? e + 33 : e + 1;
+ }, I.isZero = function() {
return 0 === this.high && 0 === this.low;
- }, T.eqz = T.isZero, T.isNegative = function() {
+ }, I.eqz = I.isZero, I.isNegative = function() {
return !this.unsigned && this.high < 0;
- }, T.isPositive = function() {
+ }, I.isPositive = function() {
return this.unsigned || 0 <= this.high;
- }, T.isOdd = function() {
+ }, I.isOdd = function() {
return 1 == (1 & this.low);
- }, T.isEven = function() {
+ }, I.isEven = function() {
return 0 == (1 & this.low);
- }, T.equals = function(e) {
- return d(e) || (e = p(e)), (this.unsigned === e.unsigned || this.high >>> 31 != 1 || e.high >>> 31 != 1) && this.high === e.high && this.low === e.low;
- }, T.eq = T.equals, T.notEquals = function(e) {
- return !this.eq(e);
- }, T.neq = T.notEquals, T.ne = T.notEquals, T.lessThan = function(e) {
- return this.comp(e) < 0;
- }, T.lt = T.lessThan, T.lessThanOrEqual = function(e) {
- return this.comp(e) <= 0;
- }, T.lte = T.lessThanOrEqual, T.le = T.lessThanOrEqual, T.greaterThan = function(e) {
- return 0 < this.comp(e);
- }, T.gt = T.greaterThan, T.greaterThanOrEqual = function(e) {
- return 0 <= this.comp(e);
- }, T.gte = T.greaterThanOrEqual, T.ge = T.greaterThanOrEqual, T.compare = function(e) {
- var t, r;
- return d(e) || (e = p(e)), this.eq(e) ? 0 : (t = this.isNegative(),
- r = e.isNegative(), t && !r ? -1 : !t && r ? 1 : this.unsigned ? e.high >>> 0 > this.high >>> 0 || e.high === this.high && e.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(e).isNegative() ? -1 : 1);
- }, T.comp = T.compare, T.negate = function() {
+ }, I.equals = function(t) {
+ return d(t) || (t = p(t)), (this.unsigned === t.unsigned || this.high >>> 31 != 1 || t.high >>> 31 != 1) && this.high === t.high && this.low === t.low;
+ }, I.eq = I.equals, I.notEquals = function(t) {
+ return !this.eq(t);
+ }, I.neq = I.notEquals, I.ne = I.notEquals, I.lessThan = function(t) {
+ return this.comp(t) < 0;
+ }, I.lt = I.lessThan, I.lessThanOrEqual = function(t) {
+ return this.comp(t) <= 0;
+ }, I.lte = I.lessThanOrEqual, I.le = I.lessThanOrEqual, I.greaterThan = function(t) {
+ return 0 < this.comp(t);
+ }, I.gt = I.greaterThan, I.greaterThanOrEqual = function(t) {
+ return 0 <= this.comp(t);
+ }, I.gte = I.greaterThanOrEqual, I.ge = I.greaterThanOrEqual, I.compare = function(t) {
+ var e, r;
+ return d(t) || (t = p(t)), this.eq(t) ? 0 : (e = this.isNegative(),
+ r = t.isNegative(), e && !r ? -1 : !e && r ? 1 : this.unsigned ? t.high >>> 0 > this.high >>> 0 || t.high === this.high && t.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(t).isNegative() ? -1 : 1);
+ }, I.comp = I.compare, I.negate = function() {
return !this.unsigned && this.eq(A) ? A : this.not().add(v);
- }, T.neg = T.negate, T.add = function(e) {
- d(e) || (e = p(e));
- var t = this.high >>> 16, r = 65535 & this.high, n = this.low >>> 16, i = 65535 & this.low, s = e.high >>> 16, o = 65535 & e.high, c = e.low >>> 16, a = 0, u = 0, h = 0, f = 0;
- return u += (h = h + ((f += i + (65535 & e.low)) >>> 16) + (n + c)) >>> 16,
- g((h &= 65535) << 16 | (f &= 65535), ((a += (u += r + o) >>> 16) + (t + s) & 65535) << 16 | (u &= 65535), this.unsigned);
- }, T.subtract = function(e) {
- return d(e) || (e = p(e)), this.add(e.neg());
- }, T.sub = T.subtract, T.multiply = function(e) {
- var t, r, n, i, s, o, c, a, u, h, f;
- return this.isZero() ? y : (d(e) || (e = p(e)), m ? g(m.mul(this.low, this.high, e.low, e.high), m.get_high(), this.unsigned) : e.isZero() ? y : this.eq(A) ? e.isOdd() ? A : y : e.eq(A) ? this.isOdd() ? A : y : this.isNegative() ? e.isNegative() ? this.neg().mul(e.neg()) : this.neg().mul(e).neg() : e.isNegative() ? this.mul(e.neg()).neg() : this.lt(w) && e.lt(w) ? l(this.toNumber() * e.toNumber(), this.unsigned) : (t = this.high >>> 16,
- r = 65535 & this.high, n = this.low >>> 16, i = 65535 & this.low, s = e.high >>> 16,
- o = 65535 & e.high, c = e.low >>> 16, f = (f = h = u = a = 0) + ((u = u + ((h += i * (e = 65535 & e.low)) >>> 16) + n * e) >>> 16) + ((u = (u & 65535) + i * c) >>> 16),
- g((u &= 65535) << 16 | (h &= 65535), (a = (a = (a += (f += r * e) >>> 16) + ((f = (f & 65535) + n * c) >>> 16) + ((f = (f & 65535) + i * o) >>> 16)) + (t * e + r * c + n * o + i * s) & 65535) << 16 | (f &= 65535), this.unsigned)));
- }, T.mul = T.multiply, T.divide = function(e) {
- if ((e = d(e) ? e : p(e)).isZero()) throw Error("division by zero");
- if (m) return this.unsigned || -2147483648 !== this.high || -1 !== e.low || -1 !== e.high ? g((this.unsigned ? m.div_u : m.div_s)(this.low, this.high, e.low, e.high), m.get_high(), this.unsigned) : this;
+ }, I.neg = I.negate, I.add = function(t) {
+ d(t) || (t = p(t));
+ var e = this.high >>> 16, r = 65535 & this.high, i = this.low >>> 16, n = 65535 & this.low, s = t.high >>> 16, o = 65535 & t.high, c = t.low >>> 16, a = 0, u = 0, h = 0, f = 0;
+ return u += (h = h + ((f += n + (65535 & t.low)) >>> 16) + (i + c)) >>> 16,
+ g((h &= 65535) << 16 | (f &= 65535), ((a += (u += r + o) >>> 16) + (e + s) & 65535) << 16 | (u &= 65535), this.unsigned);
+ }, I.subtract = function(t) {
+ return d(t) || (t = p(t)), this.add(t.neg());
+ }, I.sub = I.subtract, I.multiply = function(t) {
+ var e, r, i, n, s, o, c, a, u, h, f;
+ return this.isZero() ? y : (d(t) || (t = p(t)), m ? g(m.mul(this.low, this.high, t.low, t.high), m.get_high(), this.unsigned) : t.isZero() ? y : this.eq(A) ? t.isOdd() ? A : y : t.eq(A) ? this.isOdd() ? A : y : this.isNegative() ? t.isNegative() ? this.neg().mul(t.neg()) : this.neg().mul(t).neg() : t.isNegative() ? this.mul(t.neg()).neg() : this.lt(w) && t.lt(w) ? l(this.toNumber() * t.toNumber(), this.unsigned) : (e = this.high >>> 16,
+ r = 65535 & this.high, i = this.low >>> 16, n = 65535 & this.low, s = t.high >>> 16,
+ o = 65535 & t.high, c = t.low >>> 16, f = (f = h = u = a = 0) + ((u = u + ((h += n * (t = 65535 & t.low)) >>> 16) + i * t) >>> 16) + ((u = (u & 65535) + n * c) >>> 16),
+ g((u &= 65535) << 16 | (h &= 65535), (a = (a = (a += (f += r * t) >>> 16) + ((f = (f & 65535) + i * c) >>> 16) + ((f = (f & 65535) + n * o) >>> 16)) + (e * t + r * c + i * o + n * s) & 65535) << 16 | (f &= 65535), this.unsigned)));
+ }, I.mul = I.multiply, I.divide = function(t) {
+ if ((t = d(t) ? t : p(t)).isZero()) throw Error("division by zero");
+ if (m) return this.unsigned || -2147483648 !== this.high || -1 !== t.low || -1 !== t.high ? g((this.unsigned ? m.div_u : m.div_s)(this.low, this.high, t.low, t.high), m.get_high(), this.unsigned) : this;
if (this.isZero()) return this.unsigned ? f : y;
- var t, r;
+ var e, r;
if (this.unsigned) {
- if ((e = e.unsigned ? e : e.toUnsigned()).gt(this)) return f;
- if (e.gt(this.shru(1))) return b;
+ if ((t = t.unsigned ? t : t.toUnsigned()).gt(this)) return f;
+ if (t.gt(this.shru(1))) return b;
r = f;
} else {
- if (this.eq(A)) return e.eq(v) || e.eq(S) ? A : e.eq(A) ? v : (n = this.shr(1).div(e).shl(1)).eq(y) ? e.isNegative() ? v : S : (t = this.sub(e.mul(n)),
- n.add(t.div(e)));
- if (e.eq(A)) return this.unsigned ? f : y;
- if (this.isNegative()) return e.isNegative() ? this.neg().div(e.neg()) : this.neg().div(e).neg();
- if (e.isNegative()) return this.div(e.neg()).neg();
+ if (this.eq(A)) return t.eq(v) || t.eq(S) ? A : t.eq(A) ? v : (i = this.shr(1).div(t).shl(1)).eq(y) ? t.isNegative() ? v : S : (e = this.sub(t.mul(i)),
+ i.add(e.div(t)));
+ if (t.eq(A)) return this.unsigned ? f : y;
+ if (this.isNegative()) return t.isNegative() ? this.neg().div(t.neg()) : this.neg().div(t).neg();
+ if (t.isNegative()) return this.div(t.neg()).neg();
r = y;
}
- for (t = this; t.gte(e); ) {
- for (var n = Math.max(1, Math.floor(t.toNumber() / e.toNumber())), i = Math.ceil(Math.log(n) / Math.LN2), s = i <= 48 ? 1 : h(2, i - 48), o = l(n), c = o.mul(e); c.isNegative() || c.gt(t); ) c = (o = l(n -= s, this.unsigned)).mul(e);
- o.isZero() && (o = v), r = r.add(o), t = t.sub(c);
+ for (e = this; e.gte(t); ) {
+ for (var i = Math.max(1, Math.floor(e.toNumber() / t.toNumber())), n = Math.ceil(Math.log(i) / Math.LN2), s = n <= 48 ? 1 : h(2, n - 48), o = l(i), c = o.mul(t); c.isNegative() || c.gt(e); ) c = (o = l(i -= s, this.unsigned)).mul(t);
+ o.isZero() && (o = v), r = r.add(o), e = e.sub(c);
}
return r;
- }, T.div = T.divide, T.modulo = function(e) {
- return d(e) || (e = p(e)), m ? g((this.unsigned ? m.rem_u : m.rem_s)(this.low, this.high, e.low, e.high), m.get_high(), this.unsigned) : this.sub(this.div(e).mul(e));
- }, T.mod = T.modulo, T.rem = T.modulo, T.not = function() {
+ }, I.div = I.divide, I.modulo = function(t) {
+ return d(t) || (t = p(t)), m ? g((this.unsigned ? m.rem_u : m.rem_s)(this.low, this.high, t.low, t.high), m.get_high(), this.unsigned) : this.sub(this.div(t).mul(t));
+ }, I.mod = I.modulo, I.rem = I.modulo, I.not = function() {
return g(~this.low, ~this.high, this.unsigned);
- }, T.and = function(e) {
- return d(e) || (e = p(e)), g(this.low & e.low, this.high & e.high, this.unsigned);
- }, T.or = function(e) {
- return d(e) || (e = p(e)), g(this.low | e.low, this.high | e.high, this.unsigned);
- }, T.xor = function(e) {
- return d(e) || (e = p(e)), g(this.low ^ e.low, this.high ^ e.high, this.unsigned);
- }, T.shiftLeft = function(e) {
- return d(e) && (e = e.toInt()), 0 == (e &= 63) ? this : e < 32 ? g(this.low << e, this.high << e | this.low >>> 32 - e, this.unsigned) : g(0, this.low << e - 32, this.unsigned);
- }, T.shl = T.shiftLeft, T.shiftRight = function(e) {
- return d(e) && (e = e.toInt()), 0 == (e &= 63) ? this : e < 32 ? g(this.low >>> e | this.high << 32 - e, this.high >> e, this.unsigned) : g(this.high >> e - 32, 0 <= this.high ? 0 : -1, this.unsigned);
- }, T.shr = T.shiftRight, T.shiftRightUnsigned = function(e) {
- var t;
- return d(e) && (e = e.toInt()), 0 == (e &= 63) ? this : (t = this.high,
- e < 32 ? g(this.low >>> e | t << 32 - e, t >>> e, this.unsigned) : g(32 === e ? t : t >>> e - 32, 0, this.unsigned));
- }, T.shru = T.shiftRightUnsigned, T.shr_u = T.shiftRightUnsigned, T.toSigned = function() {
+ }, I.and = function(t) {
+ return d(t) || (t = p(t)), g(this.low & t.low, this.high & t.high, this.unsigned);
+ }, I.or = function(t) {
+ return d(t) || (t = p(t)), g(this.low | t.low, this.high | t.high, this.unsigned);
+ }, I.xor = function(t) {
+ return d(t) || (t = p(t)), g(this.low ^ t.low, this.high ^ t.high, this.unsigned);
+ }, I.shiftLeft = function(t) {
+ return d(t) && (t = t.toInt()), 0 == (t &= 63) ? this : t < 32 ? g(this.low << t, this.high << t | this.low >>> 32 - t, this.unsigned) : g(0, this.low << t - 32, this.unsigned);
+ }, I.shl = I.shiftLeft, I.shiftRight = function(t) {
+ return d(t) && (t = t.toInt()), 0 == (t &= 63) ? this : t < 32 ? g(this.low >>> t | this.high << 32 - t, this.high >> t, this.unsigned) : g(this.high >> t - 32, 0 <= this.high ? 0 : -1, this.unsigned);
+ }, I.shr = I.shiftRight, I.shiftRightUnsigned = function(t) {
+ var e;
+ return d(t) && (t = t.toInt()), 0 == (t &= 63) ? this : (e = this.high,
+ t < 32 ? g(this.low >>> t | e << 32 - t, e >>> t, this.unsigned) : g(32 === t ? e : e >>> t - 32, 0, this.unsigned));
+ }, I.shru = I.shiftRightUnsigned, I.shr_u = I.shiftRightUnsigned, I.toSigned = function() {
return this.unsigned ? g(this.low, this.high, !1) : this;
- }, T.toUnsigned = function() {
+ }, I.toUnsigned = function() {
return this.unsigned ? this : g(this.low, this.high, !0);
- }, T.toBytes = function(e) {
- return e ? this.toBytesLE() : this.toBytesBE();
- }, T.toBytesLE = function() {
- var e = this.high, t = this.low;
- return [ 255 & t, t >>> 8 & 255, t >>> 16 & 255, t >>> 24, 255 & e, e >>> 8 & 255, e >>> 16 & 255, e >>> 24 ];
- }, T.toBytesBE = function() {
- var e = this.high, t = this.low;
- return [ e >>> 24, e >>> 16 & 255, e >>> 8 & 255, 255 & e, t >>> 24, t >>> 16 & 255, t >>> 8 & 255, 255 & t ];
- }, n.fromBytes = function(e, t, r) {
- return r ? n.fromBytesLE(e, t) : n.fromBytesBE(e, t);
- }, n.fromBytesLE = function(e, t) {
- return new n(e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24, e[4] | e[5] << 8 | e[6] << 16 | e[7] << 24, t);
- }, n.fromBytesBE = function(e, t) {
- return new n(e[4] << 24 | e[5] << 16 | e[6] << 8 | e[7], e[0] << 24 | e[1] << 16 | e[2] << 8 | e[3], t);
+ }, I.toBytes = function(t) {
+ return t ? this.toBytesLE() : this.toBytesBE();
+ }, I.toBytesLE = function() {
+ var t = this.high, e = this.low;
+ return [ 255 & e, e >>> 8 & 255, e >>> 16 & 255, e >>> 24, 255 & t, t >>> 8 & 255, t >>> 16 & 255, t >>> 24 ];
+ }, I.toBytesBE = function() {
+ var t = this.high, e = this.low;
+ return [ t >>> 24, t >>> 16 & 255, t >>> 8 & 255, 255 & t, e >>> 24, e >>> 16 & 255, e >>> 8 & 255, 255 & e ];
+ }, i.fromBytes = function(t, e, r) {
+ return r ? i.fromBytesLE(t, e) : i.fromBytesBE(t, e);
+ }, i.fromBytesLE = function(t, e) {
+ return new i(t[0] | t[1] << 8 | t[2] << 16 | t[3] << 24, t[4] | t[5] << 8 | t[6] << 16 | t[7] << 24, e);
+ }, i.fromBytesBE = function(t, e) {
+ return new i(t[4] << 24 | t[5] << 16 | t[6] << 8 | t[7], t[0] << 24 | t[1] << 16 | t[2] << 8 | t[3], e);
};
- } ], i = {}, n.m = r, n.c = i, n.d = function(e, t, r) {
- n.o(e, t) || Object.defineProperty(e, t, {
+ } ], n = {}, i.m = r, i.c = n, i.d = function(t, e, r) {
+ i.o(t, e) || Object.defineProperty(t, e, {
configurable: !1,
enumerable: !0,
get: r
});
- }, n.n = function(e) {
- var t = e && e.__esModule ? function() {
- return e.default;
+ }, i.n = function(t) {
+ var e = t && t.__esModule ? function() {
+ return t.default;
} : function() {
- return e;
+ return t;
};
- return n.d(t, "a", t), t;
- }, n.o = function(e, t) {
- return Object.prototype.hasOwnProperty.call(e, t);
- }, n.p = "", n(n.s = 0);
- function n(e) {
- var t;
- return (i[e] || (t = i[e] = {
- i: e,
+ return i.d(e, "a", e), e;
+ }, i.o = function(t, e) {
+ return Object.prototype.hasOwnProperty.call(t, e);
+ }, i.p = "", i(i.s = 0);
+ function i(t) {
+ var e;
+ return (n[t] || (e = n[t] = {
+ i: t,
l: !1,
exports: {}
- }, r[e].call(t.exports, t, t.exports, n), t.l = !0, t)).exports;
+ }, r[t].call(e.exports, e, e.exports, i), e.l = !0, e)).exports;
}
- var r, i;
-}), !function(t, r) {
+ var r, n;
+}), !function(e, r) {
"use strict";
- "object" == typeof exports ? (t.slip = exports, r(exports)) : "function" == typeof define && define.amd ? define([ "exports" ], function(e) {
- return t.slip = e, t.slip, r(e);
- }) : (t.slip = {}, r(t.slip));
-}(this, function(e) {
+ "object" == typeof exports ? (e.slip = exports, r(exports)) : "function" == typeof define && define.amd ? define([ "exports" ], function(t) {
+ return e.slip = t, e.slip, r(t);
+ }) : (e.slip = {}, r(e.slip));
+}(this, function(t) {
"use strict";
- var o = e, e = (o.END = 192, o.ESC = 219, o.ESC_END = 220, o.ESC_ESC = 221,
- o.byteArray = function(e, t, r) {
- return e instanceof ArrayBuffer ? new Uint8Array(e, t, r) : e;
- }, o.expandByteArray = function(e) {
- var t = new Uint8Array(2 * e.length);
- return t.set(e), t;
- }, o.sliceByteArray = function(e, t, r) {
- e = e.buffer.slice ? e.buffer.slice(t, r) : e.subarray(t, r);
- return new Uint8Array(e);
- }, o.encode = function(e, t) {
- (t = t || {}).bufferPadding = t.bufferPadding || 4;
- var t = (e = o.byteArray(e, t.offset, t.byteLength)).length + t.bufferPadding + 3 & -4, r = new Uint8Array(t), n = 1;
+ var o = t, t = (o.END = 192, o.ESC = 219, o.ESC_END = 220, o.ESC_ESC = 221,
+ o.byteArray = function(t, e, r) {
+ return t instanceof ArrayBuffer ? new Uint8Array(t, e, r) : t;
+ }, o.expandByteArray = function(t) {
+ var e = new Uint8Array(2 * t.length);
+ return e.set(t), e;
+ }, o.sliceByteArray = function(t, e, r) {
+ t = t.buffer.slice ? t.buffer.slice(e, r) : t.subarray(e, r);
+ return new Uint8Array(t);
+ }, o.encode = function(t, e) {
+ (e = e || {}).bufferPadding = e.bufferPadding || 4;
+ var e = (t = o.byteArray(t, e.offset, e.byteLength)).length + e.bufferPadding + 3 & -4, r = new Uint8Array(e), i = 1;
r[0] = o.END;
- for (var i = 0; i < e.length; i++) {
- n > r.length - 3 && (r = o.expandByteArray(r));
- var s = e[i];
- s === o.END ? (r[n++] = o.ESC, s = o.ESC_END) : s === o.ESC && (r[n++] = o.ESC,
- s = o.ESC_ESC), r[n++] = s;
+ for (var n = 0; n < t.length; n++) {
+ i > r.length - 3 && (r = o.expandByteArray(r));
+ var s = t[n];
+ s === o.END ? (r[i++] = o.ESC, s = o.ESC_END) : s === o.ESC && (r[i++] = o.ESC,
+ s = o.ESC_ESC), r[i++] = s;
}
- return r[n] = o.END, o.sliceByteArray(r, 0, n + 1);
- }, o.Decoder = function(e) {
- this.maxMessageSize = (e = "function" != typeof e ? e || {} : {
- onMessage: e
- }).maxMessageSize || 10485760, this.bufferSize = e.bufferSize || 1024, this.msgBuffer = new Uint8Array(this.bufferSize),
- this.msgBufferIdx = 0, this.onMessage = e.onMessage, this.onError = e.onError,
+ return r[i] = o.END, o.sliceByteArray(r, 0, i + 1);
+ }, o.Decoder = function(t) {
+ this.maxMessageSize = (t = "function" != typeof t ? t || {} : {
+ onMessage: t
+ }).maxMessageSize || 10485760, this.bufferSize = t.bufferSize || 1024, this.msgBuffer = new Uint8Array(this.bufferSize),
+ this.msgBufferIdx = 0, this.onMessage = t.onMessage, this.onError = t.onError,
this.escape = !1;
}, o.Decoder.prototype);
- return e.decode = function(e) {
- var t;
- e = o.byteArray(e);
- for (var r = 0; r < e.length; r++) {
- var n = e[r];
- if (this.escape) n === o.ESC_ESC ? n = o.ESC : n === o.ESC_END && (n = o.END); else {
- if (n === o.ESC) {
+ return t.decode = function(t) {
+ var e;
+ t = o.byteArray(t);
+ for (var r = 0; r < t.length; r++) {
+ var i = t[r];
+ if (this.escape) i === o.ESC_ESC ? i = o.ESC : i === o.ESC_END && (i = o.END); else {
+ if (i === o.ESC) {
this.escape = !0;
continue;
}
- if (n === o.END) {
- t = this.handleEnd();
+ if (i === o.END) {
+ e = this.handleEnd();
continue;
}
}
- this.addByte(n) || this.handleMessageMaxError();
+ this.addByte(i) || this.handleMessageMaxError();
}
- return t;
- }, e.handleMessageMaxError = function() {
+ return e;
+ }, t.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;
- }, e.addByte = function(e) {
+ }, t.addByte = function(t) {
return this.msgBufferIdx > this.msgBuffer.length - 1 && (this.msgBuffer = o.expandByteArray(this.msgBuffer)),
- this.msgBuffer[this.msgBufferIdx++] = e, this.escape = !1, this.msgBuffer.length < this.maxMessageSize;
- }, e.handleEnd = function() {
- var e;
- if (0 !== this.msgBufferIdx) return e = o.sliceByteArray(this.msgBuffer, 0, this.msgBufferIdx),
- this.onMessage && this.onMessage(e), this.msgBufferIdx = 0, e;
+ this.msgBuffer[this.msgBufferIdx++] = t, this.escape = !1, this.msgBuffer.length < this.maxMessageSize;
+ }, t.handleEnd = function() {
+ var t;
+ if (0 !== this.msgBufferIdx) return t = o.sliceByteArray(this.msgBuffer, 0, this.msgBufferIdx),
+ this.onMessage && this.onMessage(t), this.msgBufferIdx = 0, t;
}, o;
-}), !function(e) {
+}), !function(t) {
"use strict";
- function t() {}
- var r = t.prototype, n = e.EventEmitter;
- function s(e, t) {
- for (var r = e.length; r--; ) if (e[r].listener === t) return r;
+ function e() {}
+ var r = e.prototype, i = t.EventEmitter;
+ function s(t, e) {
+ for (var r = t.length; r--; ) if (t[r].listener === e) return r;
return -1;
}
- function i(e) {
+ function n(t) {
return function() {
- return this[e].apply(this, arguments);
+ return this[t].apply(this, arguments);
};
}
- r.getListeners = function(e) {
- var t, r, n = this._getEvents();
- if (e instanceof RegExp) for (r in t = {}, n) n.hasOwnProperty(r) && e.test(r) && (t[r] = n[r]); else t = n[e] || (n[e] = []);
- return t;
- }, r.flattenListeners = function(e) {
- for (var t = [], r = 0; r < e.length; r += 1) t.push(e[r].listener);
- return t;
- }, r.getListenersAsObject = function(e) {
- var t, r = this.getListeners(e);
- return r instanceof Array && ((t = {})[e] = r), t || r;
- }, r.addListener = function(e, t) {
- if (!function e(t) {
- return "function" == typeof t || t instanceof RegExp || !(!t || "object" != typeof t) && e(t.listener);
- }(t)) throw new TypeError("listener must be a function");
- var r, n = this.getListenersAsObject(e), i = "object" == typeof t;
- for (r in n) n.hasOwnProperty(r) && -1 === s(n[r], t) && n[r].push(i ? t : {
- listener: t,
+ r.getListeners = function(t) {
+ var e, r, i = this._getEvents();
+ if (t instanceof RegExp) for (r in e = {}, i) i.hasOwnProperty(r) && t.test(r) && (e[r] = i[r]); else e = i[t] || (i[t] = []);
+ return e;
+ }, r.flattenListeners = function(t) {
+ for (var e = [], r = 0; r < t.length; r += 1) e.push(t[r].listener);
+ return e;
+ }, r.getListenersAsObject = function(t) {
+ var e, r = this.getListeners(t);
+ return r instanceof Array && ((e = {})[t] = r), e || r;
+ }, r.addListener = function(t, e) {
+ if (!function t(e) {
+ return "function" == typeof e || e instanceof RegExp || !(!e || "object" != typeof e) && t(e.listener);
+ }(e)) throw new TypeError("listener must be a function");
+ var r, i = this.getListenersAsObject(t), n = "object" == typeof e;
+ for (r in i) i.hasOwnProperty(r) && -1 === s(i[r], e) && i[r].push(n ? e : {
+ listener: e,
once: !1
});
return this;
- }, r.on = i("addListener"), r.addOnceListener = function(e, t) {
- return this.addListener(e, {
- listener: t,
+ }, r.on = n("addListener"), r.addOnceListener = function(t, e) {
+ return this.addListener(t, {
+ listener: e,
once: !0
});
- }, r.once = i("addOnceListener"), r.defineEvent = function(e) {
- return this.getListeners(e), this;
- }, r.defineEvents = function(e) {
- for (var t = 0; t < e.length; t += 1) this.defineEvent(e[t]);
+ }, r.once = n("addOnceListener"), r.defineEvent = function(t) {
+ return this.getListeners(t), this;
+ }, r.defineEvents = function(t) {
+ for (var e = 0; e < t.length; e += 1) this.defineEvent(t[e]);
return this;
- }, r.removeListener = function(e, t) {
- var r, n, i = this.getListenersAsObject(e);
- for (n in i) i.hasOwnProperty(n) && -1 !== (r = s(i[n], t)) && i[n].splice(r, 1);
+ }, r.removeListener = function(t, e) {
+ var r, i, n = this.getListenersAsObject(t);
+ for (i in n) n.hasOwnProperty(i) && -1 !== (r = s(n[i], e)) && n[i].splice(r, 1);
return this;
- }, r.off = i("removeListener"), r.addListeners = function(e, t) {
- return this.manipulateListeners(!1, e, t);
- }, r.removeListeners = function(e, t) {
- return this.manipulateListeners(!0, e, t);
- }, r.manipulateListeners = function(e, t, r) {
- var n, i, s = e ? this.removeListener : this.addListener, o = e ? this.removeListeners : this.addListeners;
- if ("object" != typeof t || t instanceof RegExp) for (n = r.length; n--; ) s.call(this, t, r[n]); else for (n in t) t.hasOwnProperty(n) && (i = t[n]) && ("function" == typeof i ? s : o).call(this, n, i);
+ }, r.off = n("removeListener"), r.addListeners = function(t, e) {
+ return this.manipulateListeners(!1, t, e);
+ }, r.removeListeners = function(t, e) {
+ return this.manipulateListeners(!0, t, e);
+ }, r.manipulateListeners = function(t, e, r) {
+ var i, n, s = t ? this.removeListener : this.addListener, o = t ? this.removeListeners : this.addListeners;
+ if ("object" != typeof e || e instanceof RegExp) for (i = r.length; i--; ) s.call(this, e, r[i]); else for (i in e) e.hasOwnProperty(i) && (n = e[i]) && ("function" == typeof n ? s : o).call(this, i, n);
return this;
- }, r.removeEvent = function(e) {
- var t, r = typeof e, n = this._getEvents();
- if ("string" == r) delete n[e]; else if (e instanceof RegExp) for (t in n) n.hasOwnProperty(t) && e.test(t) && delete n[t]; else delete this._events;
+ }, r.removeEvent = function(t) {
+ var e, r = typeof t, i = this._getEvents();
+ if ("string" == r) delete i[t]; else if (t instanceof RegExp) for (e in i) i.hasOwnProperty(e) && t.test(e) && delete i[e]; else delete this._events;
return this;
- }, r.removeAllListeners = i("removeEvent"), r.emitEvent = function(e, t) {
- var r, n, i, s, o = this.getListenersAsObject(e);
- for (s in o) if (o.hasOwnProperty(s)) for (r = o[s].slice(0), i = 0; i < r.length; i++) !0 === (n = r[i]).once && this.removeListener(e, n.listener),
- n.listener.apply(this, t || []) === this._getOnceReturnValue() && this.removeListener(e, n.listener);
+ }, r.removeAllListeners = n("removeEvent"), r.emitEvent = function(t, e) {
+ var r, i, n, s, o = this.getListenersAsObject(t);
+ for (s in o) if (o.hasOwnProperty(s)) for (r = o[s].slice(0), n = 0; n < r.length; n++) !0 === (i = r[n]).once && this.removeListener(t, i.listener),
+ i.listener.apply(this, e || []) === this._getOnceReturnValue() && this.removeListener(t, i.listener);
return this;
- }, r.trigger = i("emitEvent"), r.emit = function(e) {
- var t = Array.prototype.slice.call(arguments, 1);
- return this.emitEvent(e, t);
- }, r.setOnceReturnValue = function(e) {
- return this._onceReturnValue = e, this;
+ }, r.trigger = n("emitEvent"), r.emit = function(t) {
+ var e = Array.prototype.slice.call(arguments, 1);
+ return this.emitEvent(t, e);
+ }, r.setOnceReturnValue = function(t) {
+ return this._onceReturnValue = t, this;
}, r._getOnceReturnValue = function() {
return !this.hasOwnProperty("_onceReturnValue") || this._onceReturnValue;
}, r._getEvents = function() {
return this._events || (this._events = {});
- }, t.noConflict = function() {
- return e.EventEmitter = n, t;
+ }, e.noConflict = function() {
+ return t.EventEmitter = i, e;
}, "function" == typeof define && define.amd ? define(function() {
- return t;
- }) : "object" == typeof module && module.exports ? module.exports = t : e.EventEmitter = t;
+ return e;
+ }) : "object" == typeof module && module.exports ? module.exports = e : t.EventEmitter = e;
}("undefined" != typeof window ? window : this || {}), osc || require("./osc.js")), slip = slip || require("slip"), EventEmitter = EventEmitter || require("events").EventEmitter, osc = (!function() {
"use strict";
- osc.supportsSerial = !1, osc.firePacketEvents = function(e, t, r, n) {
- t.address ? e.emit("message", t, r, n) : osc.fireBundleEvents(e, t, r, n);
- }, osc.fireBundleEvents = function(e, t, r, n) {
- e.emit("bundle", t, r, n);
- for (var i = 0; i < t.packets.length; i++) {
- var s = t.packets[i];
- osc.firePacketEvents(e, s, t.timeTag, n);
+ osc.supportsSerial = !1, osc.firePacketEvents = function(t, e, r, i) {
+ e.address ? t.emit("message", e, r, i) : osc.fireBundleEvents(t, e, r, i);
+ }, osc.fireBundleEvents = function(t, e, r, i) {
+ t.emit("bundle", e, r, i);
+ for (var n = 0; n < e.packets.length; n++) {
+ var s = e.packets[n];
+ osc.firePacketEvents(t, s, e.timeTag, i);
}
- }, osc.fireClosedPortSendError = function(e, t) {
- e.emit("error", t = t || "Can't send packets on a closed osc.Port object. Please open (or reopen) this Port by calling open().");
- }, osc.Port = function(e) {
- this.options = e || {}, this.on("data", this.decodeOSC.bind(this));
+ }, osc.fireClosedPortSendError = function(t, e) {
+ t.emit("error", e = e || "Can't send packets on a closed osc.Port object. Please open (or reopen) this Port by calling open().");
+ }, osc.Port = function(t) {
+ this.options = t || {}, this.on("data", this.decodeOSC.bind(this));
};
- var e = osc.Port.prototype = Object.create(EventEmitter.prototype);
- e.constructor = osc.Port, e.send = function(e) {
- var t = Array.prototype.slice.call(arguments), e = this.encodeOSC(e), e = osc.nativeBuffer(e);
- t[0] = e, this.sendRaw.apply(this, t);
- }, e.encodeOSC = function(e) {
- var t;
- e = e.buffer || e;
+ var t = osc.Port.prototype = Object.create(EventEmitter.prototype);
+ t.constructor = osc.Port, t.send = function(t) {
+ var e = Array.prototype.slice.call(arguments), t = this.encodeOSC(t), t = osc.nativeBuffer(t);
+ e[0] = t, this.sendRaw.apply(this, e);
+ }, t.encodeOSC = function(t) {
+ var e;
+ t = t.buffer || t;
try {
- t = osc.writePacket(e, this.options);
- } catch (e) {
- this.emit("error", e);
+ e = osc.writePacket(t, this.options);
+ } catch (t) {
+ this.emit("error", t);
}
- return t;
- }, e.decodeOSC = function(e, t) {
- e = osc.byteArray(e), this.emit("raw", e, t);
+ return e;
+ }, t.decodeOSC = function(t, e) {
+ t = osc.byteArray(t), this.emit("raw", t, e);
try {
- var r = osc.readPacket(e, this.options);
- this.emit("osc", r, t), osc.firePacketEvents(this, r, void 0, t);
- } catch (e) {
- this.emit("error", e);
+ var r = osc.readPacket(t, this.options);
+ this.emit("osc", r, e), osc.firePacketEvents(this, r, void 0, e);
+ } catch (t) {
+ this.emit("error", t);
}
- }, osc.SLIPPort = function(e) {
- var t = this, e = this.options = e || {}, e = (e.useSLIP = void 0 === e.useSLIP || e.useSLIP,
+ }, osc.SLIPPort = function(t) {
+ var e = this, t = this.options = t || {}, t = (t.useSLIP = void 0 === t.useSLIP || t.useSLIP,
this.decoder = new slip.Decoder({
onMessage: this.decodeOSC.bind(this),
- onError: function(e) {
- t.emit("error", e);
+ onError: function(t) {
+ e.emit("error", t);
}
- }), e.useSLIP ? this.decodeSLIPData : this.decodeOSC);
- this.on("data", e.bind(this));
- }, (e = osc.SLIPPort.prototype = Object.create(osc.Port.prototype)).constructor = osc.SLIPPort,
- e.encodeOSC = function(e) {
- e = e.buffer || e;
+ }), t.useSLIP ? this.decodeSLIPData : this.decodeOSC);
+ this.on("data", t.bind(this));
+ }, (t = osc.SLIPPort.prototype = Object.create(osc.Port.prototype)).constructor = osc.SLIPPort,
+ t.encodeOSC = function(t) {
+ t = t.buffer || t;
try {
- var t = osc.writePacket(e, this.options), r = slip.encode(t);
- } catch (e) {
- this.emit("error", e);
+ var e = osc.writePacket(t, this.options), r = slip.encode(e);
+ } catch (t) {
+ this.emit("error", t);
}
return r;
- }, e.decodeSLIPData = function(e, t) {
- this.decoder.decode(e, t);
- }, osc.relay = function(e, t, r, n, i, s) {
- r = r || "message", n = n || "send", i = i || function() {}, s = s ? [ null ].concat(s) : [];
- function o(e) {
- s[0] = e, e = i(e), t[n].apply(t, s);
+ }, t.decodeSLIPData = function(t, e) {
+ this.decoder.decode(t, e);
+ }, osc.relay = function(t, e, r, i, n, s) {
+ r = r || "message", i = i || "send", n = n || function() {}, s = s ? [ null ].concat(s) : [];
+ function o(t) {
+ s[0] = t, t = n(t), e[i].apply(e, s);
}
- return e.on(r, o), {
+ return t.on(r, o), {
eventName: r,
listener: o
};
- }, osc.relayPorts = function(e, t, r) {
- var n = r.raw ? "raw" : "osc", i = r.raw ? "sendRaw" : "send";
- return osc.relay(e, t, n, i, r.transform);
- }, osc.stopRelaying = function(e, t) {
- e.removeListener(t.eventName, t.listener);
- }, osc.Relay = function(e, t, r) {
- (this.options = r || {}).raw = !1, this.port1 = e, this.port2 = t, this.listen();
- }, (e = osc.Relay.prototype = Object.create(EventEmitter.prototype)).constructor = osc.Relay,
- e.open = function() {
+ }, osc.relayPorts = function(t, e, r) {
+ var i = r.raw ? "raw" : "osc", n = r.raw ? "sendRaw" : "send";
+ return osc.relay(t, e, i, n, r.transform);
+ }, osc.stopRelaying = function(t, e) {
+ t.removeListener(e.eventName, e.listener);
+ }, osc.Relay = function(t, e, r) {
+ (this.options = r || {}).raw = !1, this.port1 = t, this.port2 = e, this.listen();
+ }, (t = osc.Relay.prototype = Object.create(EventEmitter.prototype)).constructor = osc.Relay,
+ t.open = function() {
this.port1.open(), this.port2.open();
- }, e.listen = function() {
+ }, t.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 e = this.close.bind(this);
- this.port1.on("close", e), this.port2.on("close", e);
- }, e.close = function() {
+ var t = this.close.bind(this);
+ this.port1.on("close", t), this.port2.on("close", t);
+ }, t.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);
-}(), osc || require("./osc.js")), osc = (!function() {
+}(), osc || require("./osc.js"));
+
+!function() {
"use strict";
osc.WebSocket = "undefined" != typeof WebSocket ? WebSocket : require("ws"),
- osc.WebSocketPort = function(e) {
- osc.Port.call(this, e), this.on("open", this.listen.bind(this)), this.socket = e.socket,
+ osc.WebSocketPort = function(t) {
+ osc.Port.call(this, t), this.on("open", this.listen.bind(this)), this.socket = t.socket,
this.socket && (1 === this.socket.readyState ? (osc.WebSocketPort.setupSocketForBinary(this.socket),
this.emit("open", this.socket)) : this.open());
};
- var e = osc.WebSocketPort.prototype = Object.create(osc.Port.prototype);
- e.constructor = osc.WebSocketPort, e.open = function() {
+ var t = osc.WebSocketPort.prototype = Object.create(osc.Port.prototype);
+ t.constructor = osc.WebSocketPort, t.open = function() {
(!this.socket || 1 < this.socket.readyState) && (this.socket = new osc.WebSocket(this.options.url)),
osc.WebSocketPort.setupSocketForBinary(this.socket);
- var t = this;
+ var e = this;
this.socket.onopen = function() {
- t.emit("open", t.socket);
- }, this.socket.onerror = function(e) {
- t.emit("error", e);
+ e.emit("open", e.socket);
+ }, this.socket.onerror = function(t) {
+ e.emit("error", t);
};
- }, e.listen = function() {
- var t = this;
- this.socket.onmessage = function(e) {
- t.emit("data", e.data, e);
- }, this.socket.onclose = function(e) {
- t.emit("close", e);
- }, t.emit("ready");
- }, e.sendRaw = function(e) {
- this.socket && 1 === this.socket.readyState ? this.socket.send(e) : osc.fireClosedPortSendError(this);
- }, e.close = function(e, t) {
- this.socket.close(e, t);
- }, osc.WebSocketPort.setupSocketForBinary = function(e) {
- e.binaryType = osc.isNode ? "nodebuffer" : "arraybuffer";
+ }, t.listen = function() {
+ var e = this;
+ this.socket.onmessage = function(t) {
+ e.emit("data", t.data, t);
+ }, this.socket.onclose = function(t) {
+ e.emit("close", t);
+ }, e.emit("ready");
+ }, t.sendRaw = function(t) {
+ this.socket && 1 === this.socket.readyState ? this.socket.send(t) : osc.fireClosedPortSendError(this);
+ }, t.close = function(t, e) {
+ this.socket.close(t, e);
+ }, osc.WebSocketPort.setupSocketForBinary = function(t) {
+ t.binaryType = osc.isNode ? "nodebuffer" : "arraybuffer";
+ };
+}();
+
+(osc = osc || require("./osc.js")).supportsSerial = !0, function() {
+ "use strict";
+ osc.SerialPort = function(t) {
+ if (!("serial" in navigator)) throw Error("Web serial not supported in your browser. Check https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API#browser_compatibility for more info.");
+ this.on("open", this.listen.bind(this)), osc.SLIPPort.call(this, t), this.options.bitrate = this.options.bitrate || 9600,
+ this.serialPort = t.serialPort, this.serialPort && this.emit("open", this.serialPort);
+ };
+ var t = osc.SerialPort.prototype = Object.create(osc.SLIPPort.prototype);
+ t.constructor = osc.SerialPort, t.open = async function() {
+ if (this.serialPort) this.once("close", this.open.bind(this)), this.close(); else try {
+ this.serialPort = await navigator.serial.requestPort(), await this.serialPort.open(this.options),
+ this.serialPort.isOpen = !0, this.emit("open", this.serialPort);
+ } catch (t) {
+ this.serialPort.isOpen = !1, this.emit("error", t);
+ }
+ }, t.listen = async function() {
+ for (;this.serialPort.readable; ) {
+ var t = this.serialPort.readable.getReader();
+ try {
+ for (;;) {
+ var {
+ value: e,
+ done: r
+ } = await t.read();
+ if (r) break;
+ this.emit("data", e, void 0);
+ }
+ } catch (t) {
+ this.emit("error", t);
+ } finally {
+ t.releaseLock();
+ }
+ }
+ this.emit("ready");
+ }, t.messageQueue = [], t.isWriting = !1, t.sendRaw = async function(t) {
+ if (this.serialPort && this.serialPort.isOpen) {
+ if (this.messageQueue.push(t), !this.isWriting) {
+ this.isWriting = !0;
+ for (var e = this.serialPort.writable.getWriter(); 0 < this.messageQueue.length; ) {
+ var r = this.messageQueue.shift();
+ try {
+ await e.write(r);
+ } catch (t) {
+ console.error(t), this.emit("error", t);
+ }
+ }
+ e.releaseLock(), this.isWriting = !1;
+ }
+ } else osc.fireClosedPortSendError(this);
+ }, t.close = function() {
+ this.serialPort && (this.serialPort.close(), this.serialPort.isOpen = !1);
};
-}(), osc || {});
+}(), osc = osc || {};
!function() {
"use strict";
- osc.listenToTransport = function(t, e, r) {
- e.onReceive.addListener(function(e) {
- e[r] === t[r] && t.emit("data", e.data, e);
- }), e.onReceiveError.addListener(function(e) {
- t.emit("error", e);
- }), t.emit("ready");
- }, osc.emitNetworkError = function(e, t) {
- e.emit("error", "There was an error while opening the UDP socket connection. Result code: " + t);
- }, osc.SerialPort = function(e) {
- this.on("open", this.listen.bind(this)), osc.SLIPPort.call(this, e), this.connectionId = this.options.connectionId,
+ osc.listenToTransport = function(e, t, r) {
+ t.onReceive.addListener(function(t) {
+ t[r] === e[r] && e.emit("data", t.data, t);
+ }), t.onReceiveError.addListener(function(t) {
+ e.emit("error", t);
+ }), e.emit("ready");
+ }, osc.emitNetworkError = function(t, e) {
+ t.emit("error", "There was an error while opening the UDP socket connection. Result code: " + e);
+ }, osc.SerialPort = function(t) {
+ this.on("open", this.listen.bind(this)), osc.SLIPPort.call(this, t), this.connectionId = this.options.connectionId,
this.connectionId && this.emit("open", this.connectionId);
};
- var e = osc.SerialPort.prototype = Object.create(osc.SLIPPort.prototype);
- e.constructor = osc.SerialPort, osc.supportsSerial = !0, e.open = function() {
- var t = this, e = {
- bitrate: t.options.bitrate
+ var t = osc.SerialPort.prototype = Object.create(osc.SLIPPort.prototype);
+ t.constructor = osc.SerialPort, osc.supportsSerial = !0, t.open = function() {
+ var e = this, t = {
+ bitrate: e.options.bitrate
};
- chrome.serial.connect(this.options.devicePath, e, function(e) {
- t.connectionId = e.connectionId, t.emit("open", e);
+ chrome.serial.connect(this.options.devicePath, t, function(t) {
+ e.connectionId = t.connectionId, e.emit("open", t);
});
- }, e.listen = function() {
+ }, t.listen = function() {
osc.listenToTransport(this, chrome.serial, "connectionId");
- }, e.sendRaw = function(e) {
+ }, t.sendRaw = function(t) {
var r;
- this.connectionId ? (r = this, chrome.serial.send(this.connectionId, e.buffer, function(e, t) {
- t && r.emit("error", t + ". Total bytes sent: " + e);
+ this.connectionId ? (r = this, chrome.serial.send(this.connectionId, t.buffer, function(t, e) {
+ e && r.emit("error", e + ". Total bytes sent: " + t);
})) : osc.fireClosedPortSendError(this);
- }, e.close = function() {
- var t;
- this.connectionId && (t = this, chrome.serial.disconnect(this.connectionId, function(e) {
- e && t.emit("close");
+ }, t.close = function() {
+ var e;
+ this.connectionId && (e = this, chrome.serial.disconnect(this.connectionId, function(t) {
+ t && e.emit("close");
}));
- }, osc.UDPPort = function(e) {
- osc.Port.call(this, e);
- e = this.options;
- e.localAddress = e.localAddress || "127.0.0.1", e.localPort = void 0 !== e.localPort ? e.localPort : 57121,
- this.on("open", this.listen.bind(this)), this.socketId = e.socketId, this.socketId && this.emit("open", 0);
- }, (e = osc.UDPPort.prototype = Object.create(osc.Port.prototype)).constructor = osc.UDPPort,
- e.open = function() {
- var e, t;
- this.socketId || (e = {
- persistent: (e = this.options).persistent,
- name: e.name,
- bufferSize: e.bufferSize
- }, t = this, chrome.sockets.udp.create(e, function(e) {
- t.socketId = e.socketId, t.bindSocket();
+ }, osc.UDPPort = function(t) {
+ osc.Port.call(this, t);
+ t = this.options;
+ t.localAddress = t.localAddress || "127.0.0.1", t.localPort = void 0 !== t.localPort ? t.localPort : 57121,
+ this.on("open", this.listen.bind(this)), this.socketId = t.socketId, this.socketId && this.emit("open", 0);
+ }, (t = osc.UDPPort.prototype = Object.create(osc.Port.prototype)).constructor = osc.UDPPort,
+ t.open = function() {
+ var t, e;
+ this.socketId || (t = {
+ persistent: (t = this.options).persistent,
+ name: t.name,
+ bufferSize: t.bufferSize
+ }, e = this, chrome.sockets.udp.create(t, function(t) {
+ e.socketId = t.socketId, e.bindSocket();
}));
- }, e.bindSocket = function() {
- var t = this, e = this.options;
- void 0 !== e.broadcast && chrome.sockets.udp.setBroadcast(this.socketId, e.broadcast, function(e) {
- e < 0 && t.emit("error", new Error("An error occurred while setting the socket's broadcast flag. Result code: " + e));
- }), void 0 !== e.multicastTTL && chrome.sockets.udp.setMulticastTimeToLive(this.socketId, e.multicastTTL, function(e) {
- e < 0 && t.emit("error", new Error("An error occurred while setting the socket's multicast time to live flag. Result code: " + e));
- }), chrome.sockets.udp.bind(this.socketId, e.localAddress, e.localPort, function(e) {
- 0 < e ? osc.emitNetworkError(t, e) : t.emit("open", e);
+ }, t.bindSocket = function() {
+ var e = this, t = this.options;
+ void 0 !== t.broadcast && chrome.sockets.udp.setBroadcast(this.socketId, t.broadcast, function(t) {
+ t < 0 && e.emit("error", new Error("An error occurred while setting the socket's broadcast flag. Result code: " + t));
+ }), void 0 !== t.multicastTTL && chrome.sockets.udp.setMulticastTimeToLive(this.socketId, t.multicastTTL, function(t) {
+ t < 0 && e.emit("error", new Error("An error occurred while setting the socket's multicast time to live flag. Result code: " + t));
+ }), chrome.sockets.udp.bind(this.socketId, t.localAddress, t.localPort, function(t) {
+ 0 < t ? osc.emitNetworkError(e, t) : e.emit("open", t);
});
- }, e.listen = function() {
- var e = this.options;
- osc.listenToTransport(this, chrome.sockets.udp, "socketId"), e.multicastMembership && ("string" == typeof e.multicastMembership && (e.multicastMembership = [ e.multicastMembership ]),
- e.multicastMembership.forEach(function(t) {
- chrome.sockets.udp.joinGroup(this.socketId, t, function(e) {
- e < 0 && this.emit("error", new Error("There was an error while trying to join the multicast group " + t + ". Result code: " + e));
+ }, t.listen = function() {
+ var t = this.options;
+ osc.listenToTransport(this, chrome.sockets.udp, "socketId"), t.multicastMembership && ("string" == typeof t.multicastMembership && (t.multicastMembership = [ t.multicastMembership ]),
+ t.multicastMembership.forEach(function(e) {
+ chrome.sockets.udp.joinGroup(this.socketId, e, function(t) {
+ t < 0 && this.emit("error", new Error("There was an error while trying to join the multicast group " + e + ". Result code: " + t));
});
}));
- }, e.sendRaw = function(e, t, r) {
- var n, i;
- this.socketId ? (n = this.options, i = this, t = t || n.remoteAddress, r = void 0 !== r ? r : n.remotePort,
- chrome.sockets.udp.send(this.socketId, e.buffer, t, r, function(e) {
- e || i.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?"),
- 0 < e.resultCode && osc.emitNetworkError(i, e.resultCode);
+ }, t.sendRaw = function(t, e, r) {
+ var i, n;
+ this.socketId ? (i = this.options, n = this, e = e || i.remoteAddress, r = void 0 !== r ? r : i.remotePort,
+ chrome.sockets.udp.send(this.socketId, t.buffer, e, r, function(t) {
+ t || n.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?"),
+ 0 < t.resultCode && osc.emitNetworkError(n, t.resultCode);
})) : osc.fireClosedPortSendError(this);
- }, e.close = function() {
- var e;
- this.socketId && (e = this, chrome.sockets.udp.close(this.socketId, function() {
- e.emit("close");
+ }, t.close = function() {
+ var t;
+ this.socketId && (t = this, chrome.sockets.udp.close(this.socketId, function() {
+ t.emit("close");
}));
};
}();
\ No newline at end of file
diff --git a/dist/osc-module.js b/dist/osc-module.js
index 634cfdc..8998d71 100644
--- a/dist/osc-module.js
+++ b/dist/osc-module.js
@@ -1445,6 +1445,117 @@ var osc = osc || require("./osc.js");
};
}());
+;
+/*
+ * osc.js: An Open Sound Control library for JavaScript that works in both the browser and Node.js
+ *
+ * WebSerial serial transport for osc.js
+ *
+ * Licensed under the MIT and GPL 3 licenses.
+ */
+
+/*global WebSerial, require*/
+var osc = osc || require("./osc.js");
+
+osc.supportsSerial = true;
+
+(function () {
+ "use strict";
+
+ osc.SerialPort = function (options) {
+ if ("serial" in navigator) {
+ this.on("open", this.listen.bind(this));
+ osc.SLIPPort.call(this, options);
+ this.options.bitrate = this.options.bitrate || 9600;
+
+ this.serialPort = options.serialPort;
+ if (this.serialPort) {
+ this.emit("open", this.serialPort);
+ }
+ } else {
+ throw Error(
+ "Web serial not supported in your browser. Check https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API#browser_compatibility for more info."
+ );
+ }
+ };
+
+ var p = (osc.SerialPort.prototype = Object.create(osc.SLIPPort.prototype));
+ p.constructor = osc.SerialPort;
+
+ p.open = async function () {
+ if (this.serialPort) {
+ // If we already have a serial port, close it and open a new one.
+ this.once("close", this.open.bind(this));
+ this.close();
+ return;
+ }
+
+ try {
+ this.serialPort = await navigator.serial.requestPort();
+ await this.serialPort.open(this.options);
+ this.serialPort.isOpen = true;
+ this.emit("open", this.serialPort);
+ } catch (error) {
+ this.serialPort.isOpen = false;
+ this.emit("error", error);
+ }
+ };
+
+ p.listen = async function () {
+ while (this.serialPort.readable) {
+ const reader = this.serialPort.readable.getReader();
+ try {
+ while (true) {
+ const { value, done } = await reader.read();
+ if (done) {
+ break;
+ }
+ this.emit("data", value, undefined);
+ }
+ } catch (error) {
+ this.emit("error", error);
+ } finally {
+ reader.releaseLock();
+ }
+ }
+ this.emit("ready");
+ };
+
+ p.messageQueue = [];
+ p.isWriting = false;
+
+ p.sendRaw = async function (encoded) {
+ if (!this.serialPort || !this.serialPort.isOpen) {
+ osc.fireClosedPortSendError(this);
+ return;
+ }
+
+ this.messageQueue.push(encoded);
+
+ if (!this.isWriting) {
+ this.isWriting = true;
+ const writer = this.serialPort.writable.getWriter();
+ while (this.messageQueue.length > 0) {
+ const nextMessage = this.messageQueue.shift();
+ try {
+ await writer.write(nextMessage);
+ } catch (error) {
+ console.error(error);
+ this.emit("error", error);
+ }
+ }
+ writer.releaseLock();
+ this.isWriting = false;
+ }
+ };
+
+ p.close = function () {
+ if (this.serialPort) {
+ this.serialPort.close();
+ this.serialPort.isOpen = false;
+ }
+ };
+})();
;
return osc;
diff --git a/dist/osc-module.min.js b/dist/osc-module.min.js
index 90c1dcf..803de25 100644
--- a/dist/osc-module.min.js
+++ b/dist/osc-module.min.js
@@ -4,35 +4,35 @@
return i.osc = e, i.osc, o(0, t, r, n);
}) : (i.osc = {}, o(i.osc, slip, EventEmitter));
}(this, function(e, n, t, r) {
- var c = c || {}, c = (!function() {
+ var d = d || {}, d = (!function() {
"use strict";
- c.SECS_70YRS = 2208988800, c.TWO_32 = 4294967296, c.defaults = {
+ d.SECS_70YRS = 2208988800, d.TWO_32 = 4294967296, d.defaults = {
metadata: !1,
unpackSingleArgs: !0
- }, c.isCommonJS = !("undefined" == typeof module || !module.exports), c.isNode = c.isCommonJS && "undefined" == typeof window,
- c.isElectron = !("undefined" == typeof process || !process.versions || !process.versions.electron),
- c.isBufferEnv = c.isNode || c.isElectron, c.isArray = function(e) {
+ }, d.isCommonJS = !("undefined" == typeof module || !module.exports), d.isNode = d.isCommonJS && "undefined" == typeof window,
+ d.isElectron = !("undefined" == typeof process || !process.versions || !process.versions.electron),
+ d.isBufferEnv = d.isNode || d.isElectron, d.isArray = function(e) {
return e && "[object Array]" === Object.prototype.toString.call(e);
- }, c.isTypedArrayView = function(e) {
+ }, d.isTypedArrayView = function(e) {
return e.buffer && e.buffer instanceof ArrayBuffer;
- }, c.isBuffer = function(e) {
- return c.isBufferEnv && e instanceof Buffer;
- }, c.Long = void 0 !== r ? r : c.isNode ? require("long") : void 0, c.TextDecoder = "undefined" != typeof TextDecoder ? new TextDecoder("utf-8") : "undefined" != typeof util && (util.TextDecoder,
- 1) ? new util.TextDecoder("utf-8") : void 0, c.TextEncoder = "undefined" != typeof TextEncoder ? new TextEncoder("utf-8") : "undefined" != typeof util && (util.TextEncoder,
- 1) ? new util.TextEncoder("utf-8") : void 0, c.dataView = function(e, t, r) {
+ }, d.isBuffer = function(e) {
+ return d.isBufferEnv && e instanceof Buffer;
+ }, d.Long = void 0 !== r ? r : d.isNode ? require("long") : void 0, d.TextDecoder = "undefined" != typeof TextDecoder ? new TextDecoder("utf-8") : "undefined" != typeof util && (util.TextDecoder,
+ 1) ? new util.TextDecoder("utf-8") : void 0, d.TextEncoder = "undefined" != typeof TextEncoder ? new TextEncoder("utf-8") : "undefined" != typeof util && (util.TextEncoder,
+ 1) ? new util.TextEncoder("utf-8") : void 0, d.dataView = function(e, t, r) {
return e.buffer ? new DataView(e.buffer, t, r) : e instanceof ArrayBuffer ? new DataView(e, t, r) : new DataView(new Uint8Array(e), t, r);
- }, c.byteArray = function(e) {
+ }, d.byteArray = function(e) {
if (e instanceof Uint8Array) return e;
var t = e.buffer || e;
if (t instanceof ArrayBuffer || void 0 !== t.length && "string" != typeof t) return new Uint8Array(t);
throw new Error("Can't wrap a non-array-like object as Uint8Array. Object was: " + JSON.stringify(e, null, 2));
- }, c.nativeBuffer = function(e) {
- return c.isBufferEnv ? c.isBuffer(e) ? e : Buffer.from(e.buffer ? e : new Uint8Array(e)) : c.isTypedArrayView(e) ? e : new Uint8Array(e);
- }, c.copyByteArray = function(e, t, r) {
- if (c.isTypedArrayView(e) && c.isTypedArrayView(t)) t.set(e, r); else for (var n = void 0 === r ? 0 : r, i = Math.min(t.length - r, e.length), o = 0, a = n; o < i; o++,
+ }, d.nativeBuffer = function(e) {
+ return d.isBufferEnv ? d.isBuffer(e) ? e : Buffer.from(e.buffer ? e : new Uint8Array(e)) : d.isTypedArrayView(e) ? e : new Uint8Array(e);
+ }, d.copyByteArray = function(e, t, r) {
+ if (d.isTypedArrayView(e) && d.isTypedArrayView(t)) t.set(e, r); else for (var n = void 0 === r ? 0 : r, i = Math.min(t.length - r, e.length), o = 0, a = n; o < i; o++,
a++) t[a] = e[o];
return t;
- }, c.readString = function(e, t) {
+ }, d.readString = function(e, t) {
for (var r = [], n = t.idx; n < e.byteLength; n++) {
var i = e.getUint8(n);
if (0 === i) {
@@ -41,76 +41,76 @@
}
r.push(i);
}
- return t.idx = n = n + 3 & -4, (c.isBufferEnv ? c.readString.withBuffer : c.TextDecoder ? c.readString.withTextDecoder : c.readString.raw)(r);
- }, c.readString.raw = function(e) {
+ return t.idx = n = n + 3 & -4, (d.isBufferEnv ? d.readString.withBuffer : d.TextDecoder ? d.readString.withTextDecoder : d.readString.raw)(r);
+ }, d.readString.raw = function(e) {
for (var t = "", r = 0; r < e.length; r += 1e4) t += String.fromCharCode.apply(null, e.slice(r, r + 1e4));
return t;
- }, c.readString.withTextDecoder = function(e) {
+ }, d.readString.withTextDecoder = function(e) {
e = new Int8Array(e);
- return c.TextDecoder.decode(e);
- }, c.readString.withBuffer = function(e) {
+ return d.TextDecoder.decode(e);
+ }, d.readString.withBuffer = function(e) {
return Buffer.from(e).toString("utf-8");
- }, c.writeString = function(e) {
- for (var t, r = c.isBufferEnv ? c.writeString.withBuffer : c.TextEncoder ? c.writeString.withTextEncoder : null, n = e + "\0", i = (r && (t = r(n)),
+ }, d.writeString = function(e) {
+ for (var t, r = d.isBufferEnv ? d.writeString.withBuffer : d.TextEncoder ? d.writeString.withTextEncoder : null, n = e + "\0", i = (r && (t = r(n)),
(r ? t : n).length), o = new Uint8Array(i + 3 & -4), a = 0; a < i - 1; a++) {
var s = r ? t[a] : n.charCodeAt(a);
o[a] = s;
}
return o;
- }, c.writeString.withTextEncoder = function(e) {
- return c.TextEncoder.encode(e);
- }, c.writeString.withBuffer = function(e) {
+ }, d.writeString.withTextEncoder = function(e) {
+ return d.TextEncoder.encode(e);
+ }, d.writeString.withBuffer = function(e) {
return Buffer.from(e);
- }, c.readPrimitive = function(e, t, r, n) {
+ }, d.readPrimitive = function(e, t, r, n) {
e = e[t](n.idx, !1);
return n.idx += r, e;
- }, c.writePrimitive = function(e, t, r, n, i) {
+ }, d.writePrimitive = function(e, t, r, n, i) {
var o;
return i = void 0 === i ? 0 : i, t ? o = new Uint8Array(t.buffer) : (o = new Uint8Array(n),
t = new DataView(o.buffer)), t[r](i, e, !1), o;
- }, c.readInt32 = function(e, t) {
- return c.readPrimitive(e, "getInt32", 4, t);
- }, c.writeInt32 = function(e, t, r) {
- return c.writePrimitive(e, t, "setInt32", 4, r);
- }, c.readInt64 = function(e, t) {
- var r = c.readPrimitive(e, "getInt32", 4, t), e = c.readPrimitive(e, "getInt32", 4, t);
- return c.Long ? new c.Long(e, r) : {
+ }, d.readInt32 = function(e, t) {
+ return d.readPrimitive(e, "getInt32", 4, t);
+ }, d.writeInt32 = function(e, t, r) {
+ return d.writePrimitive(e, t, "setInt32", 4, r);
+ }, d.readInt64 = function(e, t) {
+ var r = d.readPrimitive(e, "getInt32", 4, t), e = d.readPrimitive(e, "getInt32", 4, t);
+ return d.Long ? new d.Long(e, r) : {
high: r,
low: e,
unsigned: !1
};
- }, c.writeInt64 = function(e, t, r) {
+ }, d.writeInt64 = function(e, t, r) {
var n = new Uint8Array(8);
- return n.set(c.writePrimitive(e.high, t, "setInt32", 4, r), 0), n.set(c.writePrimitive(e.low, t, "setInt32", 4, r + 4), 4),
+ return n.set(d.writePrimitive(e.high, t, "setInt32", 4, r), 0), n.set(d.writePrimitive(e.low, t, "setInt32", 4, r + 4), 4),
n;
- }, c.readFloat32 = function(e, t) {
- return c.readPrimitive(e, "getFloat32", 4, t);
- }, c.writeFloat32 = function(e, t, r) {
- return c.writePrimitive(e, t, "setFloat32", 4, r);
- }, c.readFloat64 = function(e, t) {
- return c.readPrimitive(e, "getFloat64", 8, t);
- }, c.writeFloat64 = function(e, t, r) {
- return c.writePrimitive(e, t, "setFloat64", 8, r);
- }, c.readChar32 = function(e, t) {
- e = c.readPrimitive(e, "getUint32", 4, t);
+ }, d.readFloat32 = function(e, t) {
+ return d.readPrimitive(e, "getFloat32", 4, t);
+ }, d.writeFloat32 = function(e, t, r) {
+ return d.writePrimitive(e, t, "setFloat32", 4, r);
+ }, d.readFloat64 = function(e, t) {
+ return d.readPrimitive(e, "getFloat64", 8, t);
+ }, d.writeFloat64 = function(e, t, r) {
+ return d.writePrimitive(e, t, "setFloat64", 8, r);
+ }, d.readChar32 = function(e, t) {
+ e = d.readPrimitive(e, "getUint32", 4, t);
return String.fromCharCode(e);
- }, c.writeChar32 = function(e, t, r) {
+ }, d.writeChar32 = function(e, t, r) {
e = e.charCodeAt(0);
- if (!(void 0 === e || e < -1)) return c.writePrimitive(e, t, "setUint32", 4, r);
- }, c.readBlob = function(e, t) {
- var r = c.readInt32(e, t), n = r + 3 & -4, e = new Uint8Array(e.buffer, t.idx, r);
+ if (!(void 0 === e || e < -1)) return d.writePrimitive(e, t, "setUint32", 4, r);
+ }, d.readBlob = function(e, t) {
+ var r = d.readInt32(e, t), n = r + 3 & -4, e = new Uint8Array(e.buffer, t.idx, r);
return t.idx += n, e;
- }, c.writeBlob = function(e) {
- var t = (e = c.byteArray(e)).byteLength, r = new Uint8Array(4 + (t + 3 & -4)), n = new DataView(r.buffer);
- return c.writeInt32(t, n), r.set(e, 4), r;
- }, c.readMIDIBytes = function(e, t) {
+ }, d.writeBlob = function(e) {
+ var t = (e = d.byteArray(e)).byteLength, r = new Uint8Array(4 + (t + 3 & -4)), n = new DataView(r.buffer);
+ return d.writeInt32(t, n), r.set(e, 4), r;
+ }, d.readMIDIBytes = function(e, t) {
e = new Uint8Array(e.buffer, t.idx, 4);
return t.idx += 4, e;
- }, c.writeMIDIBytes = function(e) {
- e = c.byteArray(e);
+ }, d.writeMIDIBytes = function(e) {
+ e = d.byteArray(e);
var t = new Uint8Array(4);
return t.set(e), t;
- }, c.readColor = function(e, t) {
+ }, d.readColor = function(e, t) {
var e = new Uint8Array(e.buffer, t.idx, 4), r = e[3] / 255;
return t.idx += 4, {
r: e[0],
@@ -118,159 +118,159 @@
b: e[2],
a: r
};
- }, c.writeColor = function(e) {
+ }, d.writeColor = function(e) {
var t = Math.round(255 * e.a);
return new Uint8Array([ e.r, e.g, e.b, t ]);
- }, c.readTrue = function() {
+ }, d.readTrue = function() {
return !0;
- }, c.readFalse = function() {
+ }, d.readFalse = function() {
return !1;
- }, c.readNull = function() {
+ }, d.readNull = function() {
return null;
- }, c.readImpulse = function() {
+ }, d.readImpulse = function() {
return 1;
- }, c.readTimeTag = function(e, t) {
- var r = c.readPrimitive(e, "getUint32", 4, t), e = c.readPrimitive(e, "getUint32", 4, t);
+ }, d.readTimeTag = function(e, t) {
+ var r = d.readPrimitive(e, "getUint32", 4, t), e = d.readPrimitive(e, "getUint32", 4, t);
return {
raw: [ r, e ],
- native: 0 === r && 1 === e ? Date.now() : c.ntpToJSTime(r, e)
+ native: 0 === r && 1 === e ? Date.now() : d.ntpToJSTime(r, e)
};
- }, c.writeTimeTag = function(e) {
- var e = e.raw || c.jsToNTPTime(e.native), t = new Uint8Array(8), r = new DataView(t.buffer);
- return c.writeInt32(e[0], r, 0), c.writeInt32(e[1], r, 4), t;
- }, c.timeTag = function(e, t) {
+ }, d.writeTimeTag = function(e) {
+ var e = e.raw || d.jsToNTPTime(e.native), t = new Uint8Array(8), r = new DataView(t.buffer);
+ return d.writeInt32(e[0], r, 0), d.writeInt32(e[1], r, 4), t;
+ }, d.timeTag = function(e, t) {
e = e || 0;
var t = (t = t || Date.now()) / 1e3, r = Math.floor(t), t = t - r, n = Math.floor(e), t = t + (e - n);
return 1 < t && (n += e = Math.floor(t), t = t - e), {
- raw: [ r + n + c.SECS_70YRS, Math.round(c.TWO_32 * t) ]
+ raw: [ r + n + d.SECS_70YRS, Math.round(d.TWO_32 * t) ]
};
- }, c.ntpToJSTime = function(e, t) {
- return 1e3 * (e - c.SECS_70YRS + t / c.TWO_32);
- }, c.jsToNTPTime = function(e) {
+ }, d.ntpToJSTime = function(e, t) {
+ return 1e3 * (e - d.SECS_70YRS + t / d.TWO_32);
+ }, d.jsToNTPTime = function(e) {
var e = e / 1e3, t = Math.floor(e);
- return [ t + c.SECS_70YRS, Math.round(c.TWO_32 * (e - t)) ];
- }, c.readArguments = function(e, t, r) {
- var n = c.readString(e, r);
+ return [ t + d.SECS_70YRS, Math.round(d.TWO_32 * (e - t)) ];
+ }, d.readArguments = function(e, t, r) {
+ var n = d.readString(e, r);
if (0 !== n.indexOf(",")) throw new Error("A malformed type tag string was found while reading the arguments of an OSC message. String was: " + n, " at offset: " + r.idx);
var i = n.substring(1).split(""), o = [];
- return c.readArgumentsIntoArray(o, i, n, e, t, r), o;
- }, c.readArgument = function(e, t, r, n, i) {
- var o = c.argumentTypes[e];
- if (o) return o = o.reader, o = c[o](r, i), n.metadata ? {
+ return d.readArgumentsIntoArray(o, i, n, e, t, r), o;
+ }, d.readArgument = function(e, t, r, n, i) {
+ var o = d.argumentTypes[e];
+ if (o) return o = o.reader, o = d[o](r, i), n.metadata ? {
type: e,
value: o
} : o;
throw new Error("'" + e + "' is not a valid OSC type tag. Type tag string was: " + t);
- }, c.readArgumentsIntoArray = function(e, t, r, n, i, o) {
+ }, d.readArgumentsIntoArray = function(e, t, r, n, i, o) {
for (var a = 0; a < t.length; ) {
var s = t[a];
if ("[" === s) {
- var u = t.slice(a + 1), d = u.indexOf("]");
- if (d < 0) throw new Error("Invalid argument type tag: an open array type tag ('[') was found without a matching close array tag ('[]'). Type tag was: " + r);
- u = u.slice(0, d), u = c.readArgumentsIntoArray([], u, r, n, i, o);
- a += d + 2;
- } else u = c.readArgument(s, r, n, i, o), a++;
+ var u = t.slice(a + 1), c = u.indexOf("]");
+ if (c < 0) throw new Error("Invalid argument type tag: an open array type tag ('[') was found without a matching close array tag ('[]'). Type tag was: " + r);
+ u = u.slice(0, c), u = d.readArgumentsIntoArray([], u, r, n, i, o);
+ a += c + 2;
+ } else u = d.readArgument(s, r, n, i, o), a++;
e.push(u);
}
return e;
- }, c.writeArguments = function(e, t) {
- e = c.collectArguments(e, t);
- return c.joinParts(e);
- }, c.joinParts = function(e) {
+ }, d.writeArguments = function(e, t) {
+ e = d.collectArguments(e, t);
+ return d.joinParts(e);
+ }, d.joinParts = function(e) {
for (var t = new Uint8Array(e.byteLength), r = e.parts, n = 0, i = 0; i < r.length; i++) {
var o = r[i];
- c.copyByteArray(o, t, n), n += o.length;
+ d.copyByteArray(o, t, n), n += o.length;
}
return t;
- }, c.addDataPart = function(e, t) {
+ }, d.addDataPart = function(e, t) {
t.parts.push(e), t.byteLength += e.length;
- }, c.writeArrayArguments = function(e, t) {
+ }, d.writeArrayArguments = function(e, t) {
for (var r = "[", n = 0; n < e.length; n++) {
var i = e[n];
- r += c.writeArgument(i, t);
+ r += d.writeArgument(i, t);
}
return r += "]";
- }, c.writeArgument = function(e, t) {
+ }, d.writeArgument = function(e, t) {
var r;
- return c.isArray(e) ? c.writeArrayArguments(e, t) : (r = e.type, (r = c.argumentTypes[r].writer) && (r = c[r](e.value),
- c.addDataPart(r, t)), e.type);
- }, c.collectArguments = function(e, t, r) {
- c.isArray(e) || (e = void 0 === e ? [] : [ e ]), r = r || {
+ return d.isArray(e) ? d.writeArrayArguments(e, t) : (r = e.type, (r = d.argumentTypes[r].writer) && (r = d[r](e.value),
+ d.addDataPart(r, t)), e.type);
+ }, d.collectArguments = function(e, t, r) {
+ d.isArray(e) || (e = void 0 === e ? [] : [ e ]), r = r || {
byteLength: 0,
parts: []
- }, t.metadata || (e = c.annotateArguments(e));
+ }, t.metadata || (e = d.annotateArguments(e));
for (var n = ",", t = r.parts.length, i = 0; i < e.length; i++) {
var o = e[i];
- n += c.writeArgument(o, r);
+ n += d.writeArgument(o, r);
}
- var a = c.writeString(n);
+ var a = d.writeString(n);
return r.byteLength += a.byteLength, r.parts.splice(t, 0, a), r;
- }, c.readMessage = function(e, t, r) {
- t = t || c.defaults;
- var e = c.dataView(e, e.byteOffset, e.byteLength), n = c.readString(e, r = r || {
+ }, d.readMessage = function(e, t, r) {
+ t = t || d.defaults;
+ var e = d.dataView(e, e.byteOffset, e.byteLength), n = d.readString(e, r = r || {
idx: 0
});
- return c.readMessageContents(n, e, t, r);
- }, c.readMessageContents = function(e, t, r, n) {
+ return d.readMessageContents(n, e, t, r);
+ }, d.readMessageContents = function(e, t, r, n) {
if (0 !== e.indexOf("/")) throw new Error("A malformed OSC address was found while reading an OSC message. String was: " + e);
- t = c.readArguments(t, r, n);
+ t = d.readArguments(t, r, n);
return {
address: e,
args: 1 === t.length && r.unpackSingleArgs ? t[0] : t
};
- }, c.collectMessageParts = function(e, t, r) {
+ }, d.collectMessageParts = function(e, t, r) {
return r = r || {
byteLength: 0,
parts: []
- }, c.addDataPart(c.writeString(e.address), r), c.collectArguments(e.args, t, r);
- }, c.writeMessage = function(e, t) {
- if (t = t || c.defaults, c.isValidMessage(e)) return t = c.collectMessageParts(e, t),
- c.joinParts(t);
+ }, d.addDataPart(d.writeString(e.address), r), d.collectArguments(e.args, t, r);
+ }, d.writeMessage = function(e, t) {
+ if (t = t || d.defaults, d.isValidMessage(e)) return t = d.collectMessageParts(e, t),
+ d.joinParts(t);
throw new Error("An OSC message must contain a valid address. Message was: " + JSON.stringify(e, null, 2));
- }, c.isValidMessage = function(e) {
+ }, d.isValidMessage = function(e) {
return e.address && 0 === e.address.indexOf("/");
- }, c.readBundle = function(e, t, r) {
- return c.readPacket(e, t, r);
- }, c.collectBundlePackets = function(e, t, r) {
+ }, d.readBundle = function(e, t, r) {
+ return d.readPacket(e, t, r);
+ }, d.collectBundlePackets = function(e, t, r) {
r = r || {
byteLength: 0,
parts: []
- }, c.addDataPart(c.writeString("#bundle"), r), c.addDataPart(c.writeTimeTag(e.timeTag), r);
+ }, d.addDataPart(d.writeString("#bundle"), r), d.addDataPart(d.writeTimeTag(e.timeTag), r);
for (var n = 0; n < e.packets.length; n++) {
- var i = e.packets[n], i = (i.address ? c.collectMessageParts : c.collectBundlePackets)(i, t);
- r.byteLength += i.byteLength, c.addDataPart(c.writeInt32(i.byteLength), r),
+ var i = e.packets[n], i = (i.address ? d.collectMessageParts : d.collectBundlePackets)(i, t);
+ r.byteLength += i.byteLength, d.addDataPart(d.writeInt32(i.byteLength), r),
r.parts = r.parts.concat(i.parts);
}
return r;
- }, c.writeBundle = function(e, t) {
- if (!c.isValidBundle(e)) throw new Error("An OSC bundle must contain 'timeTag' and 'packets' properties. Bundle was: " + JSON.stringify(e, null, 2));
- t = t || c.defaults;
- e = c.collectBundlePackets(e, t);
- return c.joinParts(e);
- }, c.isValidBundle = function(e) {
+ }, d.writeBundle = function(e, t) {
+ if (!d.isValidBundle(e)) throw new Error("An OSC bundle must contain 'timeTag' and 'packets' properties. Bundle was: " + JSON.stringify(e, null, 2));
+ t = t || d.defaults;
+ e = d.collectBundlePackets(e, t);
+ return d.joinParts(e);
+ }, d.isValidBundle = function(e) {
return void 0 !== e.timeTag && void 0 !== e.packets;
- }, c.readBundleContents = function(e, t, r, n) {
- for (var i = c.readTimeTag(e, r), o = []; r.idx < n; ) {
- var a = c.readInt32(e, r), a = r.idx + a, a = c.readPacket(e, t, r, a);
+ }, d.readBundleContents = function(e, t, r, n) {
+ for (var i = d.readTimeTag(e, r), o = []; r.idx < n; ) {
+ var a = d.readInt32(e, r), a = r.idx + a, a = d.readPacket(e, t, r, a);
o.push(a);
}
return {
timeTag: i,
packets: o
};
- }, c.readPacket = function(e, t, r, n) {
- var e = c.dataView(e, e.byteOffset, e.byteLength), i = (n = void 0 === n ? e.byteLength : n,
- c.readString(e, r = r || {
+ }, d.readPacket = function(e, t, r, n) {
+ var e = d.dataView(e, e.byteOffset, e.byteLength), i = (n = void 0 === n ? e.byteLength : n,
+ d.readString(e, r = r || {
idx: 0
})), o = i[0];
- if ("#" === o) return c.readBundleContents(e, t, r, n);
- if ("/" === o) return c.readMessageContents(i, e, t, r);
+ if ("#" === o) return d.readBundleContents(e, t, r, n);
+ if ("/" === o) return d.readMessageContents(i, e, t, r);
throw new Error("The header of an OSC packet didn't contain an OSC address or a #bundle string. Header was: " + i);
- }, c.writePacket = function(e, t) {
- if (c.isValidMessage(e)) return c.writeMessage(e, t);
- if (c.isValidBundle(e)) return c.writeBundle(e, t);
+ }, d.writePacket = function(e, t) {
+ if (d.isValidMessage(e)) return d.writeMessage(e, t);
+ if (d.isValidBundle(e)) return d.writeBundle(e, t);
throw new Error("The specified packet was not recognized as a valid OSC message or bundle. Packet was: " + JSON.stringify(e, null, 2));
- }, c.argumentTypes = {
+ }, d.argumentTypes = {
i: {
reader: "readInt32",
writer: "writeInt32"
@@ -327,7 +327,7 @@
reader: "readMIDIBytes",
writer: "writeMIDIBytes"
}
- }, c.inferTypeForArgument = function(e) {
+ }, d.inferTypeForArgument = function(e) {
switch (typeof e) {
case "boolean":
return e ? "T" : "F";
@@ -347,53 +347,53 @@
if ("number" == typeof e.high && "number" == typeof e.low) return "h";
}
throw new Error("Can't infer OSC argument type for value: " + JSON.stringify(e, null, 2));
- }, c.annotateArguments = function(e) {
+ }, d.annotateArguments = function(e) {
for (var t = [], r = 0; r < e.length; r++) {
var n = e[r];
- n = "object" == typeof n && n.type && void 0 !== n.value ? n : c.isArray(n) ? c.annotateArguments(n) : {
- type: c.inferTypeForArgument(n),
+ n = "object" == typeof n && n.type && void 0 !== n.value ? n : d.isArray(n) ? d.annotateArguments(n) : {
+ type: d.inferTypeForArgument(n),
value: n
}, t.push(n);
}
return t;
- }, c.isCommonJS && (module.exports = c);
- }(), c || require("./osc.js")), n = n || require("slip"), t = t || require("events").EventEmitter, c = (!function() {
+ }, d.isCommonJS && (module.exports = d);
+ }(), d || require("./osc.js")), n = n || require("slip"), t = t || require("events").EventEmitter, d = (!function() {
"use strict";
- c.supportsSerial = !1, c.firePacketEvents = function(e, t, r, n) {
- t.address ? e.emit("message", t, r, n) : c.fireBundleEvents(e, t, r, n);
- }, c.fireBundleEvents = function(e, t, r, n) {
+ d.supportsSerial = !1, d.firePacketEvents = function(e, t, r, n) {
+ t.address ? e.emit("message", t, r, n) : d.fireBundleEvents(e, t, r, n);
+ }, d.fireBundleEvents = function(e, t, r, n) {
e.emit("bundle", t, r, n);
for (var i = 0; i < t.packets.length; i++) {
var o = t.packets[i];
- c.firePacketEvents(e, o, t.timeTag, n);
+ d.firePacketEvents(e, o, t.timeTag, n);
}
- }, c.fireClosedPortSendError = function(e, t) {
+ }, d.fireClosedPortSendError = function(e, t) {
e.emit("error", t = t || "Can't send packets on a closed osc.Port object. Please open (or reopen) this Port by calling open().");
- }, c.Port = function(e) {
+ }, d.Port = function(e) {
this.options = e || {}, this.on("data", this.decodeOSC.bind(this));
};
- var e = c.Port.prototype = Object.create(t.prototype);
- e.constructor = c.Port, e.send = function(e) {
- var t = Array.prototype.slice.call(arguments), e = this.encodeOSC(e), e = c.nativeBuffer(e);
+ var e = d.Port.prototype = Object.create(t.prototype);
+ e.constructor = d.Port, e.send = function(e) {
+ var t = Array.prototype.slice.call(arguments), e = this.encodeOSC(e), e = d.nativeBuffer(e);
t[0] = e, this.sendRaw.apply(this, t);
}, e.encodeOSC = function(e) {
var t;
e = e.buffer || e;
try {
- t = c.writePacket(e, this.options);
+ t = d.writePacket(e, this.options);
} catch (e) {
this.emit("error", e);
}
return t;
}, e.decodeOSC = function(e, t) {
- e = c.byteArray(e), this.emit("raw", e, t);
+ e = d.byteArray(e), this.emit("raw", e, t);
try {
- var r = c.readPacket(e, this.options);
- this.emit("osc", r, t), c.firePacketEvents(this, r, void 0, t);
+ var r = d.readPacket(e, this.options);
+ this.emit("osc", r, t), d.firePacketEvents(this, r, void 0, t);
} catch (e) {
this.emit("error", e);
}
- }, c.SLIPPort = function(e) {
+ }, d.SLIPPort = function(e) {
var t = this, e = this.options = e || {}, e = (e.useSLIP = void 0 === e.useSLIP || e.useSLIP,
this.decoder = new n.Decoder({
onMessage: this.decodeOSC.bind(this),
@@ -402,18 +402,18 @@
}
}), e.useSLIP ? this.decodeSLIPData : this.decodeOSC);
this.on("data", e.bind(this));
- }, (e = c.SLIPPort.prototype = Object.create(c.Port.prototype)).constructor = c.SLIPPort,
+ }, (e = d.SLIPPort.prototype = Object.create(d.Port.prototype)).constructor = d.SLIPPort,
e.encodeOSC = function(e) {
e = e.buffer || e;
try {
- var t = c.writePacket(e, this.options), r = n.encode(t);
+ var t = d.writePacket(e, this.options), r = n.encode(t);
} catch (e) {
this.emit("error", e);
}
return r;
}, e.decodeSLIPData = function(e, t) {
this.decoder.decode(e, t);
- }, c.relay = function(e, t, r, n, i, o) {
+ }, d.relay = function(e, t, r, n, i, o) {
r = r || "message", n = n || "send", i = i || function() {}, o = o ? [ null ].concat(o) : [];
function a(e) {
o[0] = e, e = i(e), t[n].apply(t, o);
@@ -422,38 +422,38 @@
eventName: r,
listener: a
};
- }, c.relayPorts = function(e, t, r) {
+ }, d.relayPorts = function(e, t, r) {
var n = r.raw ? "raw" : "osc", i = r.raw ? "sendRaw" : "send";
- return c.relay(e, t, n, i, r.transform);
- }, c.stopRelaying = function(e, t) {
+ return d.relay(e, t, n, i, r.transform);
+ }, d.stopRelaying = function(e, t) {
e.removeListener(t.eventName, t.listener);
- }, c.Relay = function(e, t, r) {
+ }, d.Relay = function(e, t, r) {
(this.options = r || {}).raw = !1, this.port1 = e, this.port2 = t, this.listen();
- }, (e = c.Relay.prototype = Object.create(t.prototype)).constructor = c.Relay,
+ }, (e = d.Relay.prototype = Object.create(t.prototype)).constructor = d.Relay,
e.open = function() {
this.port1.open(), this.port2.open();
}, e.listen = function() {
- this.port1Spec && this.port2Spec && this.close(), this.port1Spec = c.relayPorts(this.port1, this.port2, this.options),
- this.port2Spec = c.relayPorts(this.port2, this.port1, this.options);
+ 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 e = this.close.bind(this);
this.port1.on("close", e), this.port2.on("close", e);
}, e.close = function() {
- c.stopRelaying(this.port1, this.port1Spec), c.stopRelaying(this.port2, this.port2Spec),
+ 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 = c);
- }(), c || require("./osc.js"));
+ }, "undefined" != typeof module && module.exports && (module.exports = d);
+ }(), d || require("./osc.js"));
return function() {
"use strict";
- c.WebSocket = "undefined" != typeof WebSocket ? WebSocket : require("ws"),
- c.WebSocketPort = function(e) {
- c.Port.call(this, e), this.on("open", this.listen.bind(this)), this.socket = e.socket,
- this.socket && (1 === this.socket.readyState ? (c.WebSocketPort.setupSocketForBinary(this.socket),
+ d.WebSocket = "undefined" != typeof WebSocket ? WebSocket : require("ws"),
+ d.WebSocketPort = function(e) {
+ d.Port.call(this, e), this.on("open", this.listen.bind(this)), this.socket = e.socket,
+ this.socket && (1 === this.socket.readyState ? (d.WebSocketPort.setupSocketForBinary(this.socket),
this.emit("open", this.socket)) : this.open());
};
- var e = c.WebSocketPort.prototype = Object.create(c.Port.prototype);
- e.constructor = c.WebSocketPort, e.open = function() {
- (!this.socket || 1 < this.socket.readyState) && (this.socket = new c.WebSocket(this.options.url)),
- c.WebSocketPort.setupSocketForBinary(this.socket);
+ var e = d.WebSocketPort.prototype = Object.create(d.Port.prototype);
+ e.constructor = d.WebSocketPort, e.open = function() {
+ (!this.socket || 1 < this.socket.readyState) && (this.socket = new d.WebSocket(this.options.url)),
+ d.WebSocketPort.setupSocketForBinary(this.socket);
var t = this;
this.socket.onopen = function() {
t.emit("open", t.socket);
@@ -468,11 +468,63 @@
t.emit("close", e);
}, t.emit("ready");
}, e.sendRaw = function(e) {
- this.socket && 1 === this.socket.readyState ? this.socket.send(e) : c.fireClosedPortSendError(this);
+ this.socket && 1 === this.socket.readyState ? this.socket.send(e) : d.fireClosedPortSendError(this);
}, e.close = function(e, t) {
this.socket.close(e, t);
- }, c.WebSocketPort.setupSocketForBinary = function(e) {
- e.binaryType = c.isNode ? "nodebuffer" : "arraybuffer";
+ }, d.WebSocketPort.setupSocketForBinary = function(e) {
+ e.binaryType = d.isNode ? "nodebuffer" : "arraybuffer";
};
- }(), c;
+ }(), (d = d || require("./osc.js")).supportsSerial = !0, function() {
+ "use strict";
+ d.SerialPort = function(e) {
+ if (!("serial" in navigator)) throw Error("Web serial not supported in your browser. Check https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API#browser_compatibility for more info.");
+ this.on("open", this.listen.bind(this)), d.SLIPPort.call(this, e), this.options.bitrate = this.options.bitrate || 9600,
+ this.serialPort = e.serialPort, this.serialPort && this.emit("open", this.serialPort);
+ };
+ var e = d.SerialPort.prototype = Object.create(d.SLIPPort.prototype);
+ e.constructor = d.SerialPort, e.open = async function() {
+ if (this.serialPort) this.once("close", this.open.bind(this)), this.close(); else try {
+ this.serialPort = await navigator.serial.requestPort(), await this.serialPort.open(this.options),
+ this.serialPort.isOpen = !0, this.emit("open", this.serialPort);
+ } catch (e) {
+ this.serialPort.isOpen = !1, this.emit("error", e);
+ }
+ }, e.listen = async function() {
+ for (;this.serialPort.readable; ) {
+ var e = this.serialPort.readable.getReader();
+ try {
+ for (;;) {
+ var {
+ value: t,
+ done: r
+ } = await e.read();
+ if (r) break;
+ this.emit("data", t, void 0);
+ }
+ } catch (e) {
+ this.emit("error", e);
+ } finally {
+ e.releaseLock();
+ }
+ }
+ this.emit("ready");
+ }, e.messageQueue = [], e.isWriting = !1, e.sendRaw = async function(e) {
+ if (this.serialPort && this.serialPort.isOpen) {
+ if (this.messageQueue.push(e), !this.isWriting) {
+ this.isWriting = !0;
+ for (var t = this.serialPort.writable.getWriter(); 0 < this.messageQueue.length; ) {
+ var r = this.messageQueue.shift();
+ try {
+ await t.write(r);
+ } catch (e) {
+ console.error(e), this.emit("error", e);
+ }
+ }
+ t.releaseLock(), this.isWriting = !1;
+ }
+ } else d.fireClosedPortSendError(this);
+ }, e.close = function() {
+ this.serialPort && (this.serialPort.close(), this.serialPort.isOpen = !1);
+ };
+ }(), d;
});
\ No newline at end of file
diff --git a/src/platforms/osc-web-serialport.js b/src/platforms/osc-web-serialport.js
new file mode 100644
index 0000000..42fc553
--- /dev/null
+++ b/src/platforms/osc-web-serialport.js
@@ -0,0 +1,110 @@
+/*
+ * osc.js: An Open Sound Control library for JavaScript that works in both the browser and Node.js
+ *
+ * WebSerial serial transport for osc.js
+ *
+ * Licensed under the MIT and GPL 3 licenses.
+ */
+
+/*global WebSerial, require*/
+var osc = osc || require("../osc.js");
+
+osc.supportsSerial = true;
+
+(function () {
+ "use strict";
+
+ osc.SerialPort = function (options) {
+ if ("serial" in navigator) {
+ this.on("open", this.listen.bind(this));
+ osc.SLIPPort.call(this, options);
+ this.options.bitrate = this.options.bitrate || 9600;
+
+ this.serialPort = options.serialPort;
+ if (this.serialPort) {
+ this.emit("open", this.serialPort);
+ }
+ } else {
+ throw Error(
+ "Web serial not supported in your browser. Check https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API#browser_compatibility for more info."
+ );
+ }
+ };
+
+ var p = (osc.SerialPort.prototype = Object.create(osc.SLIPPort.prototype));
+ p.constructor = osc.SerialPort;
+
+ p.open = async function () {
+ if (this.serialPort) {
+ // If we already have a serial port, close it and open a new one.
+ this.once("close", this.open.bind(this));
+ this.close();
+ return;
+ }
+
+ try {
+ this.serialPort = await navigator.serial.requestPort();
+ await this.serialPort.open(this.options);
+ this.serialPort.isOpen = true;
+ this.emit("open", this.serialPort);
+ } catch (error) {
+ this.serialPort.isOpen = false;
+ this.emit("error", error);
+ }
+ };
+
+ p.listen = async function () {
+ while (this.serialPort.readable) {
+ const reader = this.serialPort.readable.getReader();
+ try {
+ while (true) {
+ const { value, done } = await reader.read();
+ if (done) {
+ break;
+ }
+ this.emit("data", value, undefined);
+ }
+ } catch (error) {
+ this.emit("error", error);
+ } finally {
+ reader.releaseLock();
+ }
+ }
+ this.emit("ready");
+ };
+
+ p.messageQueue = [];
+ p.isWriting = false;
+
+ p.sendRaw = async function (encoded) {
+ if (!this.serialPort || !this.serialPort.isOpen) {
+ osc.fireClosedPortSendError(this);
+ return;
+ }
+
+ this.messageQueue.push(encoded);
+
+ if (!this.isWriting) {
+ this.isWriting = true;
+ const writer = this.serialPort.writable.getWriter();
+ while (this.messageQueue.length > 0) {
+ const nextMessage = this.messageQueue.shift();
+ try {
+ await writer.write(nextMessage);
+ } catch (error) {
+ console.error(error);
+ this.emit("error", error);
+ }
+ }
+ writer.releaseLock();
+ this.isWriting = false;
+ }
+ };
+
+ p.close = function () {
+ if (this.serialPort) {
+ this.serialPort.close();
+ this.serialPort.isOpen = false;
+ }
+ };
+})();
diff --git a/tests/osc-web-tests.js b/tests/osc-web-tests.js
index ece3f65..d1d1026 100644
--- a/tests/osc-web-tests.js
+++ b/tests/osc-web-tests.js
@@ -10,12 +10,12 @@
/*global osc, QUnit*/
(function () {
- "use strict";
+ "use strict";
- QUnit.module("osc.js Web Tests");
+ QUnit.module("osc.js Web Tests");
- QUnit.test("Serial port support is not loaded", function () {
- QUnit.expect(1);
- QUnit.ok(!osc.supportsSerial);
- });
-}());
+ QUnit.test("Serial port support is not loaded", function () {
+ QUnit.expect(1);
+ QUnit.ok(osc.supportsSerial);
+ });
+})();