node-osc 9.0.2 → 9.1.1
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 +5 -5
- package/.github/workflows/create-release.yml +3 -3
- package/.github/workflows/nodejs.yml +3 -3
- package/dist/lib/Message.js +8 -0
- package/dist/test/test-message.js +39 -2
- package/dist/test/util.js +4 -1
- package/lib/Message.mjs +8 -0
- package/package.json +4 -4
- package/rollup.config.mjs +1 -2
- package/test/test-message.mjs +39 -2
- package/test/util.mjs +4 -1
- package/.github/workflows/codeql-analysis.yml +0 -51
|
@@ -33,12 +33,12 @@ jobs:
|
|
|
33
33
|
# run that runs on: tag. (Using the GitHub token would
|
|
34
34
|
# not run the workflow to prevent infinite recursion.)
|
|
35
35
|
- name: Check out source
|
|
36
|
-
uses: actions/checkout@
|
|
36
|
+
uses: actions/checkout@v4
|
|
37
37
|
with:
|
|
38
38
|
ssh-key: ${{ secrets.DEPLOY_KEY }}
|
|
39
39
|
|
|
40
40
|
- name: Setup Node.js
|
|
41
|
-
uses: actions/setup-node@
|
|
41
|
+
uses: actions/setup-node@v4
|
|
42
42
|
with:
|
|
43
43
|
node-version: 20
|
|
44
44
|
cache: 'npm'
|
|
@@ -50,11 +50,11 @@ jobs:
|
|
|
50
50
|
run: |
|
|
51
51
|
git config user.name 'Myles Borins'
|
|
52
52
|
git config user.email 'myles.borins@gmail.com'
|
|
53
|
-
git config gpg.format ssh
|
|
54
|
-
git config user.signingKey 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFtQmrz647zOGumjiqGirj1G9brj/QbwJQ5S3gHRmcfl myles.borins@gmail.com'
|
|
53
|
+
# git config gpg.format ssh
|
|
54
|
+
# git config user.signingKey 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFtQmrz647zOGumjiqGirj1G9brj/QbwJQ5S3gHRmcfl myles.borins@gmail.com'
|
|
55
55
|
|
|
56
56
|
- name: bump version
|
|
57
|
-
run: npm version ${{ github.event.inputs.version }} --sign-git-tag
|
|
57
|
+
run: npm version ${{ github.event.inputs.version }} # --sign-git-tag
|
|
58
58
|
|
|
59
59
|
- name: Push latest version
|
|
60
60
|
run: git push origin main --follow-tags
|
|
@@ -13,9 +13,9 @@ jobs:
|
|
|
13
13
|
id-token: write
|
|
14
14
|
steps:
|
|
15
15
|
- name: Checkout source
|
|
16
|
-
uses: actions/checkout@
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
17
|
- name: Setup node
|
|
18
|
-
uses: actions/setup-node@
|
|
18
|
+
uses: actions/setup-node@v4
|
|
19
19
|
with:
|
|
20
20
|
node-version: 20
|
|
21
21
|
registry-url: 'https://registry.npmjs.org'
|
|
@@ -37,7 +37,7 @@ jobs:
|
|
|
37
37
|
contents: write
|
|
38
38
|
steps:
|
|
39
39
|
- name: Checkout code
|
|
40
|
-
uses: actions/checkout@
|
|
40
|
+
uses: actions/checkout@v4
|
|
41
41
|
- name: Create Release
|
|
42
42
|
run: gh release create ${{ github.ref }} --generate-notes
|
|
43
43
|
env:
|
|
@@ -11,16 +11,16 @@ jobs:
|
|
|
11
11
|
run-tests:
|
|
12
12
|
strategy:
|
|
13
13
|
matrix:
|
|
14
|
-
node-version: ['20', '18']
|
|
14
|
+
node-version: ['21', '20', '18']
|
|
15
15
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
16
16
|
|
|
17
17
|
runs-on: ${{ matrix.os }}
|
|
18
18
|
|
|
19
19
|
steps:
|
|
20
|
-
- uses: actions/checkout@
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
21
|
|
|
22
22
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
23
|
-
uses: actions/setup-node@
|
|
23
|
+
uses: actions/setup-node@v4
|
|
24
24
|
with:
|
|
25
25
|
node-version: ${{ matrix.node-version }}
|
|
26
26
|
cache: 'npm'
|
package/dist/lib/Message.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const typeTags = {
|
|
4
|
+
s: 'string',
|
|
5
|
+
f: 'float',
|
|
6
|
+
i: 'integer',
|
|
7
|
+
b: 'blob'
|
|
8
|
+
};
|
|
9
|
+
|
|
3
10
|
class Argument {
|
|
4
11
|
constructor(type, value) {
|
|
5
12
|
this.type = type;
|
|
@@ -21,6 +28,7 @@ class Message {
|
|
|
21
28
|
if (arg instanceof Array) {
|
|
22
29
|
arg.forEach(a => this.append(a));
|
|
23
30
|
} else if (arg.type) {
|
|
31
|
+
if (typeTags[arg.type]) arg.type = typeTags[arg.type];
|
|
24
32
|
this.args.push(arg);
|
|
25
33
|
} else {
|
|
26
34
|
throw new Error(`don't know how to encode object ${arg}`);
|
|
@@ -4,6 +4,10 @@ var tap = require('tap');
|
|
|
4
4
|
var util = require('./util.js');
|
|
5
5
|
var nodeOsc = require('node-osc');
|
|
6
6
|
|
|
7
|
+
function round(num) {
|
|
8
|
+
return Math.round(num * 100) / 100;
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
tap.beforeEach(util.bootstrap);
|
|
8
12
|
|
|
9
13
|
tap.test('message: basic usage', (t) => {
|
|
@@ -80,7 +84,40 @@ tap.test('message: float', (t) => {
|
|
|
80
84
|
3.14
|
|
81
85
|
];
|
|
82
86
|
t.equal(msg[0], expected[0], `We reveived the payload: ${msg}`);
|
|
83
|
-
t.equal(msg[1]
|
|
87
|
+
t.equal(round(msg[1]), expected[1], 'pie please');
|
|
88
|
+
oscServer.close();
|
|
89
|
+
t.end();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
client.send(m, () => {
|
|
93
|
+
client.close();
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
tap.test('message: alias messages', (t) => {
|
|
98
|
+
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1');
|
|
99
|
+
const client = new nodeOsc.Client('127.0.0.1', t.context.port);
|
|
100
|
+
const m = new nodeOsc.Message('/address');
|
|
101
|
+
m.append({
|
|
102
|
+
type: 'i',
|
|
103
|
+
value: 123
|
|
104
|
+
});
|
|
105
|
+
m.append({
|
|
106
|
+
type: 'f',
|
|
107
|
+
value: 3.14
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
oscServer.on('message', (msg) => {
|
|
111
|
+
const expected = [
|
|
112
|
+
'/address',
|
|
113
|
+
123,
|
|
114
|
+
3.14
|
|
115
|
+
];
|
|
116
|
+
t.equal(msg[0], expected[0], `We reveived the payload: ${msg}`);
|
|
117
|
+
t.equal(msg[1], expected[1], 'easy as abc');
|
|
118
|
+
t.ok(Number.isInteger(msg[1]), 'the first value is an int');
|
|
119
|
+
t.equal(round(msg[2]), expected[2], 'pie please');
|
|
120
|
+
t.ok(msg[2] % 1 !== 0, 'the second value is a float');
|
|
84
121
|
oscServer.close();
|
|
85
122
|
t.end();
|
|
86
123
|
});
|
|
@@ -139,7 +176,7 @@ tap.test('message: blob', (t) => {
|
|
|
139
176
|
// test('message: timetag', (t) => {
|
|
140
177
|
// const oscServer = new osc.Server(3333, '127.0.0.1');
|
|
141
178
|
// const client = new osc.Client('127.0.0.1', 3333);
|
|
142
|
-
// const m = new osc.Message('/address');
|
|
179
|
+
// const m = new osc.Message('/address');
|
|
143
180
|
//
|
|
144
181
|
// oscServer.on('message', (msg) => {
|
|
145
182
|
// const expected = [
|
package/dist/test/util.js
CHANGED
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
async function bootstrap(t) {
|
|
4
4
|
const {default: getPorts, portNumbers} = await import('get-port');
|
|
5
|
-
|
|
5
|
+
const port = await getPorts({
|
|
6
6
|
port: portNumbers(3000, 3500)
|
|
7
7
|
});
|
|
8
|
+
t.context = {
|
|
9
|
+
port
|
|
10
|
+
};
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
exports.bootstrap = bootstrap;
|
package/lib/Message.mjs
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
const typeTags = {
|
|
2
|
+
s: 'string',
|
|
3
|
+
f: 'float',
|
|
4
|
+
i: 'integer',
|
|
5
|
+
b: 'blob'
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
class Argument {
|
|
2
9
|
constructor(type, value) {
|
|
3
10
|
this.type = type;
|
|
@@ -19,6 +26,7 @@ class Message {
|
|
|
19
26
|
if (arg instanceof Array) {
|
|
20
27
|
arg.forEach(a => this.append(a));
|
|
21
28
|
} else if (arg.type) {
|
|
29
|
+
if (typeTags[arg.type]) arg.type = typeTags[arg.type];
|
|
22
30
|
this.args.push(arg);
|
|
23
31
|
} else {
|
|
24
32
|
throw new Error(`don't know how to encode object ${arg}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-osc",
|
|
3
3
|
"description": "pyOSC inspired library for sending and receiving OSC messages",
|
|
4
|
-
"version": "9.
|
|
4
|
+
"version": "9.1.1",
|
|
5
5
|
"exports": {
|
|
6
6
|
"require": "./dist/lib/index.js",
|
|
7
7
|
"default": "./lib/index.mjs"
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"clean": "rm -rf dist/",
|
|
25
25
|
"build": "npm run clean && rollup --config rollup.config.mjs",
|
|
26
26
|
"prepublishOnly": "npm run build",
|
|
27
|
-
"lint": "eslint \"lib/**/*.mjs\" test/* examples/*",
|
|
27
|
+
"lint": "eslint \"lib/**/*.mjs\" test/* examples/* rollup.config.mjs",
|
|
28
28
|
"test": "npm run lint && npm run build && npm run test:esm && npm run test:cjs",
|
|
29
|
-
"test:esm": "tap
|
|
29
|
+
"test:esm": "tap -j1 test/test-*.mjs",
|
|
30
30
|
"test:cjs": "tap -j1 dist/test/test-*.js"
|
|
31
31
|
},
|
|
32
32
|
"contributors": [
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"eslint": "^8.36.0",
|
|
50
50
|
"get-port": "^6.1.2",
|
|
51
|
-
"rollup": "^
|
|
51
|
+
"rollup": "^4.9.5",
|
|
52
52
|
"tap": "^18.4.2"
|
|
53
53
|
}
|
|
54
54
|
}
|
package/rollup.config.mjs
CHANGED
|
@@ -64,7 +64,6 @@ function walkLib(config) {
|
|
|
64
64
|
|
|
65
65
|
function walkTest(config) {
|
|
66
66
|
const tests = walk('./test/');
|
|
67
|
-
console.log(tests)
|
|
68
67
|
tests.forEach(({input, dir}) => {
|
|
69
68
|
config.push({
|
|
70
69
|
input,
|
|
@@ -84,7 +83,7 @@ function walkTest(config) {
|
|
|
84
83
|
'tap',
|
|
85
84
|
'#decode'
|
|
86
85
|
]
|
|
87
|
-
})
|
|
86
|
+
});
|
|
88
87
|
});
|
|
89
88
|
}
|
|
90
89
|
|
package/test/test-message.mjs
CHANGED
|
@@ -3,6 +3,10 @@ import { bootstrap } from './util.mjs';
|
|
|
3
3
|
|
|
4
4
|
import { Server, Client, Message } from 'node-osc';
|
|
5
5
|
|
|
6
|
+
function round(num) {
|
|
7
|
+
return Math.round(num * 100) / 100;
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
beforeEach(bootstrap);
|
|
7
11
|
|
|
8
12
|
test('message: basic usage', (t) => {
|
|
@@ -79,7 +83,40 @@ test('message: float', (t) => {
|
|
|
79
83
|
3.14
|
|
80
84
|
];
|
|
81
85
|
t.equal(msg[0], expected[0], `We reveived the payload: ${msg}`);
|
|
82
|
-
t.equal(msg[1]
|
|
86
|
+
t.equal(round(msg[1]), expected[1], 'pie please');
|
|
87
|
+
oscServer.close();
|
|
88
|
+
t.end();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
client.send(m, () => {
|
|
92
|
+
client.close();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('message: alias messages', (t) => {
|
|
97
|
+
const oscServer = new Server(t.context.port, '127.0.0.1');
|
|
98
|
+
const client = new Client('127.0.0.1', t.context.port);
|
|
99
|
+
const m = new Message('/address');
|
|
100
|
+
m.append({
|
|
101
|
+
type: 'i',
|
|
102
|
+
value: 123
|
|
103
|
+
});
|
|
104
|
+
m.append({
|
|
105
|
+
type: 'f',
|
|
106
|
+
value: 3.14
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
oscServer.on('message', (msg) => {
|
|
110
|
+
const expected = [
|
|
111
|
+
'/address',
|
|
112
|
+
123,
|
|
113
|
+
3.14
|
|
114
|
+
];
|
|
115
|
+
t.equal(msg[0], expected[0], `We reveived the payload: ${msg}`);
|
|
116
|
+
t.equal(msg[1], expected[1], 'easy as abc');
|
|
117
|
+
t.ok(Number.isInteger(msg[1]), 'the first value is an int');
|
|
118
|
+
t.equal(round(msg[2]), expected[2], 'pie please');
|
|
119
|
+
t.ok(msg[2] % 1 !== 0, 'the second value is a float');
|
|
83
120
|
oscServer.close();
|
|
84
121
|
t.end();
|
|
85
122
|
});
|
|
@@ -138,7 +175,7 @@ test('message: blob', (t) => {
|
|
|
138
175
|
// test('message: timetag', (t) => {
|
|
139
176
|
// const oscServer = new osc.Server(3333, '127.0.0.1');
|
|
140
177
|
// const client = new osc.Client('127.0.0.1', 3333);
|
|
141
|
-
// const m = new osc.Message('/address');
|
|
178
|
+
// const m = new osc.Message('/address');
|
|
142
179
|
//
|
|
143
180
|
// oscServer.on('message', (msg) => {
|
|
144
181
|
// const expected = [
|
package/test/util.mjs
CHANGED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
-
# to commit it to your repository.
|
|
3
|
-
#
|
|
4
|
-
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
-
# or to provide custom queries or build logic.
|
|
6
|
-
#
|
|
7
|
-
# ******** NOTE ********
|
|
8
|
-
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
-
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
-
# supported CodeQL languages.
|
|
11
|
-
#
|
|
12
|
-
name: "CodeQL"
|
|
13
|
-
|
|
14
|
-
on:
|
|
15
|
-
push:
|
|
16
|
-
branches: [ main ]
|
|
17
|
-
pull_request:
|
|
18
|
-
# The branches below must be a subset of the branches above
|
|
19
|
-
branches: [ main ]
|
|
20
|
-
schedule:
|
|
21
|
-
- cron: '44 5 * * 1'
|
|
22
|
-
|
|
23
|
-
jobs:
|
|
24
|
-
analyze:
|
|
25
|
-
name: Analyze
|
|
26
|
-
runs-on: ubuntu-latest
|
|
27
|
-
permissions:
|
|
28
|
-
actions: read
|
|
29
|
-
contents: read
|
|
30
|
-
security-events: write
|
|
31
|
-
|
|
32
|
-
strategy:
|
|
33
|
-
fail-fast: false
|
|
34
|
-
matrix:
|
|
35
|
-
language: [ 'javascript' ]
|
|
36
|
-
|
|
37
|
-
steps:
|
|
38
|
-
- name: Checkout repository
|
|
39
|
-
uses: actions/checkout@v2
|
|
40
|
-
|
|
41
|
-
# Initializes the CodeQL tools for scanning.
|
|
42
|
-
- name: Initialize CodeQL
|
|
43
|
-
uses: github/codeql-action/init@v1
|
|
44
|
-
with:
|
|
45
|
-
languages: ${{ matrix.language }}
|
|
46
|
-
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
47
|
-
# By default, queries listed here will override any specified in a config file.
|
|
48
|
-
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
49
|
-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
|
50
|
-
- name: Perform CodeQL Analysis
|
|
51
|
-
uses: github/codeql-action/analyze@v1
|