node-osc 11.2.0 → 11.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/bump-version.yml +3 -3
- package/.github/workflows/create-release.yml +4 -4
- package/.github/workflows/nodejs.yml +4 -4
- package/README.md +3 -2
- package/agent.md +330 -0
- package/dist/lib/Client.js +1 -1
- package/dist/lib/Message.js +3 -1
- package/dist/lib/Server.js +7 -12
- package/dist/lib/internal/decode.js +3 -1
- package/dist/lib/osc.js +32 -3
- package/dist/test/lib/osc.js +32 -3
- package/dist/test/test-bundle.js +13 -12
- package/dist/test/test-client.js +68 -37
- package/dist/test/test-decode.js +35 -0
- package/dist/test/test-e2e.js +9 -9
- package/dist/test/test-encode-decode.js +455 -0
- package/dist/test/test-error-handling.js +14 -13
- package/dist/test/test-message.js +261 -64
- package/dist/test/test-osc-internal.js +151 -0
- package/dist/test/test-promises.js +90 -26
- package/dist/test/test-server.js +19 -16
- package/docs/README.md +81 -0
- package/examples/README.md +3 -1
- package/lib/Client.mjs +1 -1
- package/lib/Message.mjs +3 -1
- package/lib/Server.mjs +7 -12
- package/lib/internal/decode.mjs +3 -1
- package/lib/osc.mjs +32 -3
- package/package.json +2 -2
- package/rollup.config.mjs +1 -0
- package/test/test-bundle.mjs +14 -13
- package/test/test-client.mjs +69 -38
- package/test/test-decode.mjs +35 -0
- package/test/test-e2e.mjs +10 -10
- package/test/test-encode-decode.mjs +455 -0
- package/test/test-error-handling.mjs +15 -14
- package/test/test-message.mjs +262 -66
- package/test/test-osc-internal.mjs +151 -0
- package/test/test-promises.mjs +91 -27
- package/test/test-server.mjs +20 -17
- package/types/Message.d.mts.map +1 -1
- package/types/Server.d.mts.map +1 -1
- package/types/internal/decode.d.mts.map +1 -1
- package/types/osc.d.mts.map +1 -1
- package/dist/test/test-getPort.js +0 -20
- package/dist/test/util.js +0 -34
- package/test/test-getPort.mjs +0 -18
- package/test/util.mjs +0 -34
package/dist/test/test-bundle.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var node_events = require('node:events');
|
|
3
4
|
var tap = require('tap');
|
|
4
5
|
var nodeOsc = require('node-osc');
|
|
5
|
-
var util = require('./util.js');
|
|
6
6
|
|
|
7
|
-
tap.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const client = new nodeOsc.Client('127.0.0.1', t.context.port);
|
|
7
|
+
tap.test('bundle: verbose bundle', async (t) => {
|
|
8
|
+
const server = new nodeOsc.Server(0, '127.0.0.1');
|
|
9
|
+
await node_events.once(server, 'listening');
|
|
10
|
+
const client = new nodeOsc.Client('127.0.0.1', server.port);
|
|
12
11
|
|
|
13
12
|
t.plan(2);
|
|
14
13
|
|
|
@@ -35,9 +34,10 @@ tap.test('bundle: verbose bundle', (t) => {
|
|
|
35
34
|
}));
|
|
36
35
|
});
|
|
37
36
|
|
|
38
|
-
tap.test('bundle: array syntax', (t) => {
|
|
39
|
-
const server = new nodeOsc.Server(
|
|
40
|
-
|
|
37
|
+
tap.test('bundle: array syntax', async (t) => {
|
|
38
|
+
const server = new nodeOsc.Server(0, '127.0.0.1');
|
|
39
|
+
await node_events.once(server, 'listening');
|
|
40
|
+
const client = new nodeOsc.Client('127.0.0.1', server.port);
|
|
41
41
|
|
|
42
42
|
t.plan(2);
|
|
43
43
|
|
|
@@ -57,9 +57,10 @@ tap.test('bundle: array syntax', (t) => {
|
|
|
57
57
|
));
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
tap.test('bundle: nested bundle', (t) => {
|
|
61
|
-
const server = new nodeOsc.Server(
|
|
62
|
-
|
|
60
|
+
tap.test('bundle: nested bundle', async (t) => {
|
|
61
|
+
const server = new nodeOsc.Server(0, '127.0.0.1');
|
|
62
|
+
await node_events.once(server, 'listening');
|
|
63
|
+
const client = new nodeOsc.Client('127.0.0.1', server.port);
|
|
63
64
|
|
|
64
65
|
t.plan(4);
|
|
65
66
|
|
package/dist/test/test-client.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var node_events = require('node:events');
|
|
3
4
|
var tap = require('tap');
|
|
4
|
-
var util = require('./util.js');
|
|
5
5
|
var nodeOsc = require('node-osc');
|
|
6
6
|
|
|
7
|
-
tap.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const client = new nodeOsc.Client('127.0.0.1', t.context.port);
|
|
7
|
+
tap.test('client: with array', async (t) => {
|
|
8
|
+
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
9
|
+
await node_events.once(oscServer, 'listening');
|
|
10
|
+
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
12
11
|
|
|
13
12
|
t.plan(2);
|
|
14
13
|
|
|
@@ -23,9 +22,33 @@ tap.test('client: with array', (t) => {
|
|
|
23
22
|
});
|
|
24
23
|
});
|
|
25
24
|
|
|
26
|
-
tap.test('client:
|
|
27
|
-
const oscServer = new nodeOsc.Server(
|
|
28
|
-
|
|
25
|
+
tap.test('client: array is not mutated when sent', async (t) => {
|
|
26
|
+
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
27
|
+
await node_events.once(oscServer, 'listening');
|
|
28
|
+
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
29
|
+
|
|
30
|
+
t.plan(3);
|
|
31
|
+
|
|
32
|
+
const originalArray = ['/test', 0, 1, 'testing', true];
|
|
33
|
+
const expectedArray = ['/test', 0, 1, 'testing', true];
|
|
34
|
+
|
|
35
|
+
oscServer.on('message', (msg) => {
|
|
36
|
+
oscServer.close();
|
|
37
|
+
t.same(msg, ['/test', 0, 1, 'testing', true], 'We should receive expected payload');
|
|
38
|
+
// Verify the original array was not mutated
|
|
39
|
+
t.same(originalArray, expectedArray, 'Original array should not be mutated');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
client.send(originalArray, (err) => {
|
|
43
|
+
t.error(err, 'there should be no error');
|
|
44
|
+
client.close();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
tap.test('client: with string', async (t) => {
|
|
49
|
+
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
50
|
+
await node_events.once(oscServer, 'listening');
|
|
51
|
+
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
29
52
|
|
|
30
53
|
t.plan(2);
|
|
31
54
|
|
|
@@ -40,9 +63,10 @@ tap.test('client: with string', (t) => {
|
|
|
40
63
|
});
|
|
41
64
|
});
|
|
42
65
|
|
|
43
|
-
tap.test('client: with Message object', (t) => {
|
|
44
|
-
const oscServer = new nodeOsc.Server(
|
|
45
|
-
|
|
66
|
+
tap.test('client: with Message object', async (t) => {
|
|
67
|
+
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
68
|
+
await node_events.once(oscServer, 'listening');
|
|
69
|
+
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
46
70
|
|
|
47
71
|
t.plan(2);
|
|
48
72
|
|
|
@@ -66,9 +90,10 @@ tap.test('client: with Message object', (t) => {
|
|
|
66
90
|
});
|
|
67
91
|
});
|
|
68
92
|
|
|
69
|
-
tap.test('client: with Bundle object', (t) => {
|
|
70
|
-
const oscServer = new nodeOsc.Server(
|
|
71
|
-
|
|
93
|
+
tap.test('client: with Bundle object', async (t) => {
|
|
94
|
+
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
95
|
+
await node_events.once(oscServer, 'listening');
|
|
96
|
+
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
72
97
|
|
|
73
98
|
t.plan(2);
|
|
74
99
|
|
|
@@ -92,8 +117,8 @@ tap.test('client: with Bundle object', (t) => {
|
|
|
92
117
|
});
|
|
93
118
|
});
|
|
94
119
|
|
|
95
|
-
tap.test('client: failure', (t) => {
|
|
96
|
-
const client = new nodeOsc.Client('127.0.0.1',
|
|
120
|
+
tap.test('client: failure', async (t) => {
|
|
121
|
+
const client = new nodeOsc.Client('127.0.0.1', 9999);
|
|
97
122
|
|
|
98
123
|
t.plan(2);
|
|
99
124
|
|
|
@@ -108,8 +133,8 @@ tap.test('client: failure', (t) => {
|
|
|
108
133
|
});
|
|
109
134
|
});
|
|
110
135
|
|
|
111
|
-
tap.test('client: close with callback', (t) => {
|
|
112
|
-
const client = new nodeOsc.Client('127.0.0.1',
|
|
136
|
+
tap.test('client: close with callback', async (t) => {
|
|
137
|
+
const client = new nodeOsc.Client('127.0.0.1', 9999);
|
|
113
138
|
|
|
114
139
|
t.plan(1);
|
|
115
140
|
|
|
@@ -118,9 +143,10 @@ tap.test('client: close with callback', (t) => {
|
|
|
118
143
|
});
|
|
119
144
|
});
|
|
120
145
|
|
|
121
|
-
tap.test('client: send bundle with non-numeric timetag', (t) => {
|
|
122
|
-
const oscServer = new nodeOsc.Server(
|
|
123
|
-
|
|
146
|
+
tap.test('client: send bundle with non-numeric timetag', async (t) => {
|
|
147
|
+
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
148
|
+
await node_events.once(oscServer, 'listening');
|
|
149
|
+
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
124
150
|
|
|
125
151
|
t.plan(2);
|
|
126
152
|
|
|
@@ -147,9 +173,10 @@ tap.test('client: send bundle with non-numeric timetag', (t) => {
|
|
|
147
173
|
client.send(bundle);
|
|
148
174
|
});
|
|
149
175
|
|
|
150
|
-
tap.test('client: send bundle with null timetag', (t) => {
|
|
151
|
-
const oscServer = new nodeOsc.Server(
|
|
152
|
-
|
|
176
|
+
tap.test('client: send bundle with null timetag', async (t) => {
|
|
177
|
+
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
178
|
+
await node_events.once(oscServer, 'listening');
|
|
179
|
+
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
153
180
|
|
|
154
181
|
t.plan(2);
|
|
155
182
|
|
|
@@ -176,9 +203,10 @@ tap.test('client: send bundle with null timetag', (t) => {
|
|
|
176
203
|
client.send(bundle);
|
|
177
204
|
});
|
|
178
205
|
|
|
179
|
-
tap.test('client: send message with float type arg', (t) => {
|
|
180
|
-
const oscServer = new nodeOsc.Server(
|
|
181
|
-
|
|
206
|
+
tap.test('client: send message with float type arg', async (t) => {
|
|
207
|
+
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
208
|
+
await node_events.once(oscServer, 'listening');
|
|
209
|
+
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
182
210
|
|
|
183
211
|
t.plan(2);
|
|
184
212
|
|
|
@@ -197,9 +225,10 @@ tap.test('client: send message with float type arg', (t) => {
|
|
|
197
225
|
});
|
|
198
226
|
});
|
|
199
227
|
|
|
200
|
-
tap.test('client: send message with blob type arg', (t) => {
|
|
201
|
-
const oscServer = new nodeOsc.Server(
|
|
202
|
-
|
|
228
|
+
tap.test('client: send message with blob type arg', async (t) => {
|
|
229
|
+
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
230
|
+
await node_events.once(oscServer, 'listening');
|
|
231
|
+
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
203
232
|
|
|
204
233
|
t.plan(2);
|
|
205
234
|
|
|
@@ -218,9 +247,10 @@ tap.test('client: send message with blob type arg', (t) => {
|
|
|
218
247
|
});
|
|
219
248
|
});
|
|
220
249
|
|
|
221
|
-
tap.test('client: send message with double type arg', (t) => {
|
|
222
|
-
const oscServer = new nodeOsc.Server(
|
|
223
|
-
|
|
250
|
+
tap.test('client: send message with double type arg', async (t) => {
|
|
251
|
+
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
252
|
+
await node_events.once(oscServer, 'listening');
|
|
253
|
+
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
224
254
|
|
|
225
255
|
t.plan(2);
|
|
226
256
|
|
|
@@ -239,9 +269,10 @@ tap.test('client: send message with double type arg', (t) => {
|
|
|
239
269
|
});
|
|
240
270
|
});
|
|
241
271
|
|
|
242
|
-
tap.test('client: send message with midi type arg', (t) => {
|
|
243
|
-
const oscServer = new nodeOsc.Server(
|
|
244
|
-
|
|
272
|
+
tap.test('client: send message with midi type arg', async (t) => {
|
|
273
|
+
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
274
|
+
await node_events.once(oscServer, 'listening');
|
|
275
|
+
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
245
276
|
|
|
246
277
|
t.plan(2);
|
|
247
278
|
|
package/dist/test/test-decode.js
CHANGED
|
@@ -107,3 +107,38 @@ tap.test('decode: malformed structure with unexpected oscType', async (t) => {
|
|
|
107
107
|
|
|
108
108
|
t.end();
|
|
109
109
|
});
|
|
110
|
+
|
|
111
|
+
tap.test('decode: message without args defaults to empty array', (t) => {
|
|
112
|
+
const mockFromBuffer = () => ({
|
|
113
|
+
oscType: 'message',
|
|
114
|
+
address: '/test'
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
t.same(
|
|
118
|
+
decode(Buffer.from('test'), mockFromBuffer),
|
|
119
|
+
['/test'],
|
|
120
|
+
'should default args to empty array'
|
|
121
|
+
);
|
|
122
|
+
t.end();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
tap.test('decode: bundle element must be message or bundle', (t) => {
|
|
126
|
+
const mockFromBuffer = () => ({
|
|
127
|
+
oscType: 'bundle',
|
|
128
|
+
elements: [
|
|
129
|
+
{
|
|
130
|
+
oscType: 'message',
|
|
131
|
+
address: '/ok',
|
|
132
|
+
args: []
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
oscType: 'nope'
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
t.throws(() => {
|
|
141
|
+
decode(Buffer.from('test'), mockFromBuffer);
|
|
142
|
+
}, /Malformed Packet/, 'should throw for invalid bundle element');
|
|
143
|
+
t.end();
|
|
144
|
+
});
|
package/dist/test/test-e2e.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var node_events = require('node:events');
|
|
3
4
|
var tap = require('tap');
|
|
4
|
-
var util = require('./util.js');
|
|
5
5
|
var nodeOsc = require('node-osc');
|
|
6
6
|
|
|
7
|
-
tap.beforeEach(util.bootstrap);
|
|
8
|
-
|
|
9
7
|
function flaky() {
|
|
10
8
|
return process.release.lts === 'Dubnium' && process.platform === 'win32';
|
|
11
9
|
}
|
|
@@ -15,11 +13,12 @@ function skip(t) {
|
|
|
15
13
|
t.end();
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
tap.test('osc: argument message no callback', (t) => {
|
|
16
|
+
tap.test('osc: argument message no callback', async (t) => {
|
|
19
17
|
if (flaky()) return skip(t);
|
|
20
18
|
|
|
21
|
-
const oscServer = new nodeOsc.Server(
|
|
22
|
-
|
|
19
|
+
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
20
|
+
await node_events.once(oscServer, 'listening');
|
|
21
|
+
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
23
22
|
|
|
24
23
|
t.plan(1);
|
|
25
24
|
|
|
@@ -35,11 +34,12 @@ tap.test('osc: argument message no callback', (t) => {
|
|
|
35
34
|
client.send('/test', 1, 2, 'testing');
|
|
36
35
|
});
|
|
37
36
|
|
|
38
|
-
tap.test('osc: client with callback and message as arguments', (t) => {
|
|
37
|
+
tap.test('osc: client with callback and message as arguments', async (t) => {
|
|
39
38
|
if (flaky()) return skip(t);
|
|
40
39
|
|
|
41
|
-
const oscServer = new nodeOsc.Server(
|
|
42
|
-
|
|
40
|
+
const oscServer = new nodeOsc.Server(0, '127.0.0.1');
|
|
41
|
+
await node_events.once(oscServer, 'listening');
|
|
42
|
+
const client = new nodeOsc.Client('127.0.0.1', oscServer.port);
|
|
43
43
|
|
|
44
44
|
t.plan(2);
|
|
45
45
|
|