@cuecue/osc 0.0.42 → 0.0.44
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/dist/index.js +5 -35
- package/package.json +9 -8
package/dist/index.js
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var nodeOsc = require('node-osc');
|
|
6
4
|
var createDebug = require('debug');
|
|
7
5
|
var core = require('@cuecue/core');
|
|
8
6
|
var isObject = require('lodash/isObject');
|
|
9
7
|
var isArray = require('lodash/isArray');
|
|
10
8
|
|
|
11
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
-
|
|
13
|
-
var createDebug__default = /*#__PURE__*/_interopDefaultLegacy(createDebug);
|
|
14
|
-
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
15
|
-
var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
|
|
16
|
-
|
|
17
9
|
class Base extends core.BasePlugin {
|
|
18
10
|
constructor(opts = {}) {
|
|
19
11
|
super({
|
|
@@ -22,9 +14,8 @@ class Base extends core.BasePlugin {
|
|
|
22
14
|
...opts
|
|
23
15
|
});
|
|
24
16
|
this.osc = null;
|
|
25
|
-
this.debug =
|
|
17
|
+
this.debug = createDebug('cuecue:osc');
|
|
26
18
|
}
|
|
27
|
-
|
|
28
19
|
async onInitialized() {
|
|
29
20
|
const {
|
|
30
21
|
host,
|
|
@@ -33,7 +24,6 @@ class Base extends core.BasePlugin {
|
|
|
33
24
|
this.debug('started on %s:%s', host, port);
|
|
34
25
|
await super.onInitialized();
|
|
35
26
|
}
|
|
36
|
-
|
|
37
27
|
async onDestroy() {
|
|
38
28
|
await super.onDestroy();
|
|
39
29
|
return new Promise(resolve => {
|
|
@@ -42,7 +32,6 @@ class Base extends core.BasePlugin {
|
|
|
42
32
|
});
|
|
43
33
|
});
|
|
44
34
|
}
|
|
45
|
-
|
|
46
35
|
}
|
|
47
36
|
|
|
48
37
|
class OscInput extends Base {
|
|
@@ -52,15 +41,13 @@ class OscInput extends Base {
|
|
|
52
41
|
} = {}) {
|
|
53
42
|
super(opts);
|
|
54
43
|
this.commands = commands;
|
|
55
|
-
this.debug =
|
|
44
|
+
this.debug = createDebug('cuecue:input:osc');
|
|
56
45
|
this.onMessage = this.onMessage.bind(this);
|
|
57
46
|
}
|
|
58
|
-
|
|
59
47
|
setInputCommands(commands) {
|
|
60
48
|
this.commands = commands;
|
|
61
49
|
return this;
|
|
62
50
|
}
|
|
63
|
-
|
|
64
51
|
async onInit() {
|
|
65
52
|
await super.onInit();
|
|
66
53
|
const {
|
|
@@ -74,12 +61,10 @@ class OscInput extends Base {
|
|
|
74
61
|
this.osc.on('message', this.onMessage);
|
|
75
62
|
});
|
|
76
63
|
}
|
|
77
|
-
|
|
78
64
|
async onDestroy() {
|
|
79
65
|
this.osc.off('message', this.onMessage);
|
|
80
66
|
await super.onDestroy();
|
|
81
67
|
}
|
|
82
|
-
|
|
83
68
|
async onMessage(message) {
|
|
84
69
|
const {
|
|
85
70
|
transformCommand = null
|
|
@@ -94,21 +79,18 @@ class OscInput extends Base {
|
|
|
94
79
|
command: finalCommand = command,
|
|
95
80
|
args: finalArgs = args
|
|
96
81
|
} = value || {};
|
|
97
|
-
|
|
98
82
|
if (this.commands === null || this.commands.indexOf(finalCommand) !== -1) {
|
|
99
83
|
this.debug('command: %s %o', finalCommand, finalArgs);
|
|
100
84
|
this.emit('command', finalCommand, ...finalArgs);
|
|
101
85
|
}
|
|
102
86
|
}
|
|
103
|
-
|
|
104
87
|
}
|
|
105
88
|
|
|
106
89
|
class OscOutput extends Base {
|
|
107
90
|
constructor(opts) {
|
|
108
91
|
super(opts);
|
|
109
|
-
this.debug =
|
|
92
|
+
this.debug = createDebug('cuecue:output:osc');
|
|
110
93
|
}
|
|
111
|
-
|
|
112
94
|
async onInit() {
|
|
113
95
|
await super.onInit();
|
|
114
96
|
const {
|
|
@@ -117,23 +99,18 @@ class OscOutput extends Base {
|
|
|
117
99
|
} = this.options;
|
|
118
100
|
this.osc = new nodeOsc.Client(host, port);
|
|
119
101
|
}
|
|
120
|
-
|
|
121
102
|
cue(cue, extraData = null) {
|
|
122
103
|
this.command('cue', cue, extraData);
|
|
123
104
|
}
|
|
124
|
-
|
|
125
105
|
cues(cues) {
|
|
126
106
|
this.command('cues', cues);
|
|
127
107
|
}
|
|
128
|
-
|
|
129
108
|
interaction(interaction) {
|
|
130
109
|
this.command('interaction', interaction);
|
|
131
110
|
}
|
|
132
|
-
|
|
133
111
|
interact(data, interactionId = null) {
|
|
134
112
|
this.command('interact', data, interactionId);
|
|
135
113
|
}
|
|
136
|
-
|
|
137
114
|
async command(command, ...args) {
|
|
138
115
|
const {
|
|
139
116
|
transformCommand = null,
|
|
@@ -143,31 +120,26 @@ class OscOutput extends Base {
|
|
|
143
120
|
command,
|
|
144
121
|
args
|
|
145
122
|
};
|
|
146
|
-
|
|
147
123
|
if (value === false) {
|
|
148
124
|
this.debug('command canceled: %s %o', command, args);
|
|
149
125
|
return Promise.resolve();
|
|
150
126
|
}
|
|
151
|
-
|
|
152
|
-
const values = isArray__default["default"](value) ? value : [value];
|
|
127
|
+
const values = isArray(value) ? value : [value];
|
|
153
128
|
return Promise.all(values.map(val => {
|
|
154
129
|
const {
|
|
155
130
|
command: finalCommand = command,
|
|
156
131
|
args: finalArgs = args
|
|
157
132
|
} = val || {};
|
|
158
|
-
|
|
159
133
|
if (acceptCommand !== null && !acceptCommand(finalCommand, finalArgs)) {
|
|
160
134
|
this.debug('command refused: %s %o', finalCommand, finalArgs);
|
|
161
135
|
return Promise.resolve();
|
|
162
136
|
}
|
|
163
|
-
|
|
164
137
|
this.debug('command: %s %o', finalCommand, finalArgs);
|
|
165
138
|
const path = finalCommand.replace(/^\/?/, '/');
|
|
166
|
-
const sendArgs = finalArgs.filter(it => it !== null && !
|
|
139
|
+
const sendArgs = finalArgs.filter(it => it !== null && !isObject(it) && !isArray(it));
|
|
167
140
|
return this.send(path, ...sendArgs);
|
|
168
141
|
}));
|
|
169
142
|
}
|
|
170
|
-
|
|
171
143
|
async send(path, ...args) {
|
|
172
144
|
return new Promise((resolve, reject) => {
|
|
173
145
|
this.osc.send(path, ...args, err => {
|
|
@@ -176,13 +148,11 @@ class OscOutput extends Base {
|
|
|
176
148
|
reject(err);
|
|
177
149
|
return;
|
|
178
150
|
}
|
|
179
|
-
|
|
180
151
|
this.debug('send success: %s %o', path, args);
|
|
181
152
|
resolve();
|
|
182
153
|
});
|
|
183
154
|
});
|
|
184
155
|
}
|
|
185
|
-
|
|
186
156
|
}
|
|
187
157
|
|
|
188
158
|
exports.Input = OscInput;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuecue/osc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.44",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -29,24 +29,25 @@
|
|
|
29
29
|
}
|
|
30
30
|
],
|
|
31
31
|
"license": "ISC",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=22"
|
|
34
|
+
},
|
|
32
35
|
"main": "dist/index.js",
|
|
33
36
|
"files": [
|
|
34
37
|
"dist"
|
|
35
38
|
],
|
|
36
39
|
"scripts": {
|
|
37
40
|
"clean": "rm -rf dist",
|
|
38
|
-
"build": "rollup --config ../../rollup.config.
|
|
39
|
-
"
|
|
41
|
+
"build": "rollup --config ../../rollup.config.mjs",
|
|
42
|
+
"prepack": "npm run clean && npm run build"
|
|
40
43
|
},
|
|
41
44
|
"dependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@cuecue/core": "^0.0.42",
|
|
45
|
+
"@cuecue/core": "^0.0.44",
|
|
44
46
|
"debug": "^4.3.1",
|
|
45
47
|
"lodash": "^4.17.21",
|
|
46
|
-
"node-osc": "^
|
|
48
|
+
"node-osc": "^9.1.3"
|
|
47
49
|
},
|
|
48
50
|
"publishConfig": {
|
|
49
51
|
"access": "public"
|
|
50
|
-
}
|
|
51
|
-
"gitHead": "ce63758c17a7b670e6684e3dee3091a07b132522"
|
|
52
|
+
}
|
|
52
53
|
}
|