widget props: don't coerce "target" and "preArgs" to array and accept single string values (#211)
This commit is contained in:
parent
4ff64ac46d
commit
04fafb15ee
7 changed files with 22 additions and 12 deletions
|
|
@ -61,6 +61,8 @@ var WidgetManager = class WidgetManager extends EventEmitter {
|
|||
var preArgs = widget ? widget.getProp('preArgs') : preArgs,
|
||||
address = widget ? widget.getProp('address') : address
|
||||
|
||||
if (!Array.isArray(preArgs) && preArgs !== '') preArgs = [preArgs]
|
||||
|
||||
return preArgs && preArgs.length ?
|
||||
address + this.preArgsSeparator + preArgs.join(this.preArgsSeparator)
|
||||
: address
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ var Osc = class Osc extends EventEmitter {
|
|||
let widgetTarget = widgets[i].getProp('target')
|
||||
// if the message target is provided (when message comes from another client connected to the same server)
|
||||
// then we only update the widgets that have the same target
|
||||
// compare arrays using > and < operators (both false = equality)
|
||||
if (!data.target || !widgetTarget || !(widgetTarget < data.target || widgetTarget > data.target || widgetTarget.length !== data.target.length)) {
|
||||
if (!data.target || !widgetTarget || String(widgetTarget) === String(data.target)) {
|
||||
// update matching widgets
|
||||
if (widgets[i] && widgets[i].setValue) widgets[i].setValue(restArgs,{send:false,sync:true,fromExternal:!data.target})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ module.exports = class OscReceiver {
|
|||
|
||||
if (typeof args !== 'object') args = [args]
|
||||
var preArgs = this.parent.getProp('preArgs') || []
|
||||
if (!isArray(preArgs) && preArgs !== '') preArgs = [preArgs]
|
||||
if (args.length >= preArgs.length) {
|
||||
for (var i in preArgs) {
|
||||
if (preArgs[i] !== args[i]) return
|
||||
|
|
|
|||
|
|
@ -54,11 +54,6 @@ class Widget extends EventEmitter {
|
|||
this.props.preArgs = [this.props.preArgs]
|
||||
}
|
||||
|
||||
// Turn preArgs into array
|
||||
if (this.props.target !== undefined && !Array.isArray(this.resolveProp('target', undefined, false))) {
|
||||
this.props.target = [this.props.target]
|
||||
}
|
||||
|
||||
// strip parent ? no position
|
||||
if (this.parent && this.parent.props && this.parent.props.type == 'strip') {
|
||||
delete this.props.top
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue