Comparing version 5.2.3 to 6.0.0-rc.0
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var dgram = require('dgram'); | ||
var oscMin = require('osc-min'); | ||
var Message = require('./Message.js'); | ||
var dgram = require('dgram'); | ||
var oscMin = _interopDefault(require('osc-min')); | ||
const { toBuffer } = oscMin; | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var oscMin__default = /*#__PURE__*/_interopDefaultLegacy(oscMin); | ||
const { toBuffer } = oscMin__default['default']; | ||
class Client { | ||
@@ -12,0 +14,0 @@ constructor(host, port) { |
@@ -5,4 +5,8 @@ 'use strict'; | ||
var events = require('events'); | ||
var decode = require('./decode.js'); | ||
var decode = require('#internal/decode'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var decode__default = /*#__PURE__*/_interopDefaultLegacy(decode); | ||
class Server extends events.EventEmitter { | ||
@@ -26,4 +30,3 @@ constructor(port, host, cb) { | ||
try { | ||
decoded = decode(msg); | ||
// [<address>, <typetags>, <values>*] | ||
decoded = decode__default['default'](msg); | ||
} | ||
@@ -34,4 +37,6 @@ catch (e) { | ||
} | ||
if (decoded) { | ||
if (decoded.elements) { | ||
this.emit('bundle', decoded, rinfo); | ||
} | ||
else if (decoded) { | ||
this.emit('message', decoded, rinfo); | ||
@@ -38,0 +43,0 @@ this.emit(decoded[0], decoded, rinfo); |
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var tap = _interopDefault(require('tap')); | ||
var tap = require('tap'); | ||
var util = require('./util.js'); | ||
var nodeOsc = require('node-osc'); | ||
tap.beforeEach(util.beforeEach); | ||
tap.beforeEach(util.bootstrap); | ||
util.test('client: with array', (t) => { | ||
tap.test('client: with array', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
@@ -19,3 +17,3 @@ const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
oscServer.close(); | ||
t.deepEqual(msg, ['/test', 0, 1, 'testing', true], 'We should receive expected payload'); | ||
t.same(msg, ['/test', 0, 1, 'testing', true], 'We should receive expected payload'); | ||
}); | ||
@@ -29,3 +27,3 @@ | ||
util.test('client: with string', (t) => { | ||
tap.test('client: with string', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
@@ -38,3 +36,3 @@ const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
oscServer.close(); | ||
t.deepEqual(msg, ['/test'], `We should receive expected payload: ${msg}`); | ||
t.same(msg, ['/test'], `We should receive expected payload: ${msg}`); | ||
}); | ||
@@ -48,3 +46,3 @@ | ||
util.test('client: with object', (t) => { | ||
tap.test('client: with object', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
@@ -57,3 +55,3 @@ const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
oscServer.close(); | ||
t.deepEqual(msg, ['/test', 1, 2, 3, 'lol', false], `we received the payload: ${msg}`); | ||
t.same(msg, ['/test', 1, 2, 3, 'lol', false], `we received the payload: ${msg}`); | ||
}); | ||
@@ -76,3 +74,3 @@ | ||
util.test('client: failure', (t) => { | ||
tap.test('client: failure', (t) => { | ||
const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
@@ -89,4 +87,4 @@ | ||
client.send('/boom', (err) => { | ||
t.equals(err.code, 'ERR_SOCKET_DGRAM_NOT_RUNNING'); | ||
t.equal(err.code, 'ERR_SOCKET_DGRAM_NOT_RUNNING'); | ||
}); | ||
}); |
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var tap = require('tap'); | ||
var decode = require('#internal/decode'); | ||
var util = require('./util.js'); | ||
var decode = _interopDefault(require('node-osc/decode')); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
util.test('decode: empty', (t) => { | ||
const buf = Buffer.from('/test\0'); | ||
t.deepEquals(decode(buf), [], 'should be empty array'); | ||
t.done(); | ||
}); | ||
var decode__default = /*#__PURE__*/_interopDefaultLegacy(decode); | ||
util.test('decode: valid', (t) => { | ||
tap.test('decode: valid', (t) => { | ||
const buf = Buffer.from('/test\0\0\0,s\0,testing\0'); | ||
t.deepEquals(decode(buf), ['/test', 'testing'], 'should be empty array'); | ||
t.done(); | ||
t.same(decode__default['default'](buf), ['/test', 'testing'], 'should be empty array'); | ||
t.end(); | ||
}); | ||
util.test('decode: invalid typetags', (t) => { | ||
t.throws(() => { | ||
const buf = Buffer.from('/test\0iii\0'); | ||
decode(buf); | ||
}, /invalid type tag in incoming OSC message, must start with comma/); | ||
t.throws(() => { | ||
const buf = Buffer.from('/test\0\0\0,R\0'); | ||
decode(buf); | ||
}, /Unsupported OSC type tag/); | ||
t.done(); | ||
}); | ||
util.test('decode: valid', (t) => { | ||
tap.test('decode: valid', (t) => { | ||
const buf = Buffer.from('/test\0\0\0,s\0,testing\0'); | ||
t.deepEquals(decode(buf), ['/test', 'testing'], 'should be empty array'); | ||
t.done(); | ||
t.same(decode__default['default'](buf), ['/test', 'testing'], 'should be empty array'); | ||
t.end(); | ||
}); | ||
util.test('decode: invalid typetags', (t) => { | ||
tap.test('decode: invalid typetags', (t) => { | ||
t.throws(() => { | ||
const buf = Buffer.from('/test\0iii\0'); | ||
decode(buf); | ||
}, /invalid type tag in incoming OSC message, must start with comma/); | ||
t.throws(() => { | ||
const buf = Buffer.from('/test\0\0\0,R\0'); | ||
decode(buf); | ||
}, /Unsupported OSC type tag/); | ||
t.done(); | ||
decode__default['default'](buf); | ||
}, /I don't understand the argument code R/); | ||
t.end(); | ||
}); |
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var tap = _interopDefault(require('tap')); | ||
var tap = require('tap'); | ||
var util = require('./util.js'); | ||
var nodeOsc = require('node-osc'); | ||
tap.beforeEach(util.beforeEach); | ||
tap.beforeEach(util.bootstrap); | ||
@@ -17,6 +15,6 @@ function flaky() { | ||
t.skip(`flaky ~ ${t.name}`); | ||
t.done(); | ||
t.end(); | ||
} | ||
util.test('osc: argument message no callback', (t) => { | ||
tap.test('osc: argument message no callback', (t) => { | ||
if (flaky()) return skip(t); | ||
@@ -32,3 +30,3 @@ | ||
client.close(); | ||
t.deepEqual(msg, ['/test', 1, 2, 'testing'], 'We should receive expected payload'); | ||
t.same(msg, ['/test', 1, 2, 'testing'], 'We should receive expected payload'); | ||
}); | ||
@@ -39,3 +37,3 @@ | ||
util.test('osc: client with callback and message as arguments', (t) => { | ||
tap.test('osc: client with callback and message as arguments', (t) => { | ||
if (flaky()) return skip(t); | ||
@@ -50,3 +48,3 @@ | ||
oscServer.close(); | ||
t.deepEqual(msg, ['/test', 1, 2, 'testing'], 'We should receive expected payload'); | ||
t.same(msg, ['/test', 1, 2, 'testing'], 'We should receive expected payload'); | ||
}); | ||
@@ -53,0 +51,0 @@ |
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var tap = _interopDefault(require('tap')); | ||
var tap = require('tap'); | ||
var util = require('./util.js'); | ||
var nodeOsc = require('node-osc'); | ||
tap.beforeEach(util.beforeEach); | ||
tap.beforeEach(util.bootstrap); | ||
util.test('message: basic usage', (t) => { | ||
tap.test('message: basic usage', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
@@ -21,3 +19,3 @@ const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
const expected = ['/address', 'testing', 123, 456, 789]; | ||
t.deepEqual(msg, expected, `We reveived the payload: ${msg}`); | ||
t.same(msg, expected, `We reveived the payload: ${msg}`); | ||
oscServer.close(); | ||
@@ -32,3 +30,3 @@ t.end(); | ||
util.test('message: multiple args', (t) => { | ||
tap.test('message: multiple args', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
@@ -40,3 +38,3 @@ const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
const expected = ['/address', 'testing', 123, true]; | ||
t.deepEqual(msg, expected, `We reveived the payload: ${msg}`); | ||
t.same(msg, expected, `We reveived the payload: ${msg}`); | ||
oscServer.close(); | ||
@@ -51,3 +49,3 @@ t.end(); | ||
util.test('message: object', (t) => { | ||
tap.test('message: object', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
@@ -67,3 +65,3 @@ const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
const expected = ['/address', 'test', 100]; | ||
t.deepEqual(msg, expected, `We reveived the payload: ${msg}`); | ||
t.same(msg, expected, `We reveived the payload: ${msg}`); | ||
oscServer.close(); | ||
@@ -78,3 +76,3 @@ t.end(); | ||
util.test('message: float', (t) => { | ||
tap.test('message: float', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
@@ -90,4 +88,4 @@ const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
]; | ||
t.equals(msg[0], expected[0], `We reveived the payload: ${msg}`); | ||
t.equals(msg[1][0], expected[1][0], 'pie please'); | ||
t.equal(msg[0], expected[0], `We reveived the payload: ${msg}`); | ||
t.equal(msg[1][0], expected[1][0], 'pie please'); | ||
oscServer.close(); | ||
@@ -102,3 +100,3 @@ t.end(); | ||
util.test('message: boolean', (t) => { | ||
tap.test('message: boolean', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
@@ -124,3 +122,3 @@ const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
util.test('message: blob', (t) => { | ||
tap.test('message: blob', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
@@ -169,3 +167,3 @@ const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
util.test('message: error', (t) => { | ||
tap.test('message: error', (t) => { | ||
const m = new nodeOsc.Message('/address'); | ||
@@ -172,0 +170,0 @@ t.plan(2); |
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var tap = _interopDefault(require('tap')); | ||
var tap = require('tap'); | ||
var util = require('./util.js'); | ||
var nodeOsc = require('node-osc'); | ||
tap.beforeEach(util.beforeEach); | ||
tap.beforeEach(util.bootstrap); | ||
util.test('server: create and close', (t) => { | ||
tap.test('server: create and close', (t) => { | ||
t.plan(1); | ||
@@ -19,3 +17,3 @@ const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
util.test('client: listen to message', (t) => { | ||
tap.test('client: listen to message', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
@@ -26,3 +24,3 @@ const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
t.tearDown(() => { | ||
t.teardown(() => { | ||
oscServer.close(); | ||
@@ -33,7 +31,7 @@ client.close(); | ||
oscServer.on('message', (msg) => { | ||
t.deepEqual(msg, ['/test'], 'We should receive expected payload'); | ||
t.same(msg, ['/test'], 'We should receive expected payload'); | ||
}); | ||
oscServer.on('/test', (msg) => { | ||
t.deepEqual(msg, ['/test'], 'We should receive expected payload'); | ||
t.same(msg, ['/test'], 'We should receive expected payload'); | ||
}); | ||
@@ -46,3 +44,3 @@ | ||
util.test('server: bad message', (t) => { | ||
tap.test('server: bad message', (t) => { | ||
t.plan(2); | ||
@@ -49,0 +47,0 @@ const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); |
@@ -5,17 +5,14 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var getPort = require('get-port'); | ||
var tap = _interopDefault(require('tap')); | ||
var getPort = _interopDefault(require('get-port')); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
const { test } = tap; | ||
var getPort__default = /*#__PURE__*/_interopDefaultLegacy(getPort); | ||
async function beforeEach(done, t) { | ||
t.context.port = await getPort({ | ||
port: getPort.makeRange(3000, 3500) | ||
async function bootstrap(t) { | ||
t.context.port = await getPort__default['default']({ | ||
port: getPort__default['default'].makeRange(3000, 3500) | ||
}); | ||
} | ||
exports.tap = tap; | ||
exports.beforeEach = beforeEach; | ||
exports.test = test; | ||
exports.bootstrap = bootstrap; |
{ | ||
"name": "node-osc", | ||
"description": "pyOSC inspired library", | ||
"version": "5.2.3", | ||
"main": "./dist/lib/index.js", | ||
"exports": { | ||
".": { | ||
"require": "./dist/lib/index.js", | ||
"default": "./lib/index.mjs" | ||
}, | ||
"./decode": { | ||
"require": "./dist/lib/decode.js", | ||
"default": "./lib/decode.mjs" | ||
}, | ||
"./types": { | ||
"require": "./dist/lib/types.js", | ||
"default": "./lib/types.mjs" | ||
"version": "6.0.0-rc.0", | ||
"imports": { | ||
"#internal/*": { | ||
"require": "./dist/lib/internal/*.js", | ||
"default": "./lib/internal/*.mjs" | ||
} | ||
}, | ||
"exports": { | ||
"require": "./dist/lib/index.js", | ||
"default": "./lib/index.mjs" | ||
}, | ||
"author": { | ||
@@ -25,13 +20,13 @@ "name": "Myles Borins", | ||
"engines": { | ||
"node": ">=10" | ||
"node": "^12.22 || ^14.13 || >16" | ||
}, | ||
"license": "LGPL-2.1", | ||
"scripts": { | ||
"build": "rollup --config rollup.config.mjs", | ||
"clean": "rm -rf dist/", | ||
"build": "npm run clean && rollup --config rollup.config.mjs", | ||
"prepublishOnly": "npm run build", | ||
"lint": "eslint lib/* test/* examples/*", | ||
"lint": "eslint \"lib/**/*.mjs\" test/* examples/*", | ||
"test": "npm run lint && npm run build && npm run test:esm && npm run test:cjs", | ||
"test:esm": "c8 tap --no-coverage --no-esm -j1 test/test-*.mjs", | ||
"test:cjs": "tap --no-esm -j1 dist/test/test-*.js", | ||
"test:legacy": "npm run lint && npm run build && node scripts/rewrite-exports.js && tap --no-esm -j1 dist/test/test-*.js" | ||
"test:esm": "c8 tap --no-coverage -j1 test/test-*.mjs", | ||
"test:cjs": "tap --no-coverage -j1 dist/test/test-*.js" | ||
}, | ||
@@ -52,3 +47,2 @@ "contributors": [ | ||
"dependencies": { | ||
"jspack": "0.0.4", | ||
"osc-min": "^1.1.1" | ||
@@ -61,4 +55,4 @@ }, | ||
"rollup": "^2.23.0", | ||
"tap": "^14.10.7" | ||
"tap": "^15.0.4" | ||
} | ||
} |
@@ -43,2 +43,22 @@ # node-osc | ||
### Listening for OSC bundles: | ||
**WARNING**: Bundle support is Experimental and subject to change at any point. | ||
```js | ||
import { Server } from 'node-osc'; | ||
var oscServer = new Server(3333, '0.0.0.0', () => { | ||
console.log('OSC Server is listening'); | ||
}); | ||
oscServer.on('bundle', function (bundle) { | ||
bundle.elements.forEach((element, i) => { | ||
console.log(`Timestamp: ${bundle.timetag[i]}`); | ||
console.log(`Message: ${element}`); | ||
}); | ||
oscServer.close(); | ||
}); | ||
``` | ||
### CJS API | ||
@@ -45,0 +65,0 @@ |
@@ -29,3 +29,2 @@ const { | ||
.replace('\'node-osc\'', '\'../lib/index.js\'') | ||
.replace('\'node-osc\/types\'', '\'../lib/types.js\'') | ||
.replace('\'node-osc\/decode\'', '\'../lib/decode.js\'') | ||
@@ -32,0 +31,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
91
66458
34
1279
2
6
- Removedjspack@0.0.4
- Removedjspack@0.0.4(transitive)