From 9181c2a3aadc7a5630740358cd09e5416b9ee4c9 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 17 Jan 2024 16:05:03 +0100 Subject: [PATCH] remote control: `/EDIT*` commands sent by a custom module are not affected by the server's `read-only` option anymore --- CHANGELOG.md | 3 +++ resources/docs/docs/remote-control.md | 3 +-- src/client/osc.js | 2 +- src/client/remote-control.js | 20 ++++++++++---------- src/server/osc/index.js | 2 +- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79e65b1b..d24ba64c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ - bug fixes - rare issue that made the last widget(s) in a container disappear when other widgets in the same container had a specific property dependency pattern +- remote control + - `/EDIT*` commands sent by a custom module are not affected by the server's `read-only` option anymore + ## 1.25.6 - bug fixes diff --git a/resources/docs/docs/remote-control.md b/resources/docs/docs/remote-control.md index 09f450ad..98ea8c63 100644 --- a/resources/docs/docs/remote-control.md +++ b/resources/docs/docs/remote-control.md @@ -11,8 +11,7 @@ When osc messages are received, the default behavior is to update the value of a #### `/EDIT id properties options` -Apply a set of options to an existing widget by replacing the old ones with the new ones. This ignores the widget's `lock` property. - +Apply a set of options to an existing widget by replacing the old ones with the new ones. This ignores the widget's `lock` property. If sent by a custom module using `receive()`, this command will not be prevented by the server's `read-only` option. - `id`: `string`, widget's `id` - `properties`: `string`, [JSON5](https://github.com/json5/json5) stringified object defining the new properties to merge diff --git a/src/client/osc.js b/src/client/osc.js index dded16a4..5271404c 100644 --- a/src/client/osc.js +++ b/src/client/osc.js @@ -69,7 +69,7 @@ var Osc = class Osc extends EventEmitter { if (data._rawTarget && !CLIENT_SYNC) return - if (typeof this.remoteControl.exists === 'function' && this.remoteControl.exists(data.address)) this.remoteControl.exec(data.address, data.args) + if (typeof this.remoteControl.exists === 'function' && this.remoteControl.exists(data.address)) this.remoteControl.exec(data.address, data.args, data.cm) var [widgets, restArgs] = widgetManager.getWidgetByAddressAndArgs(data.address, data.args) diff --git a/src/client/remote-control.js b/src/client/remote-control.js index 64253209..1f0380c8 100644 --- a/src/client/remote-control.js +++ b/src/client/remote-control.js @@ -8,9 +8,9 @@ var {updateWidget} = require('./editor/data-workers'), uiConsole = require('./ui/ui-console') var callbacks = { - '/EDIT': function(args) { + '/EDIT': function(args, custom_module) { - if (READ_ONLY) return + if (READ_ONLY && !custom_module) return var [id, json, opts] = args, newdata = typeof json == 'string' ? JSON.parseFlex(json) : json, @@ -40,9 +40,9 @@ var callbacks = { if (options.noWarning) editor.unsavedSession = false }, - '/EDIT/MERGE': function(args) { + '/EDIT/MERGE': function(args, custom_module) { - if (READ_ONLY) return + if (READ_ONLY && !custom_module) return var [id, json, opts] = args, newdata = typeof json == 'string' ? JSON.parseFlex(json) : json, @@ -70,16 +70,16 @@ var callbacks = { if (options.noWarning) editor.unsavedSession = false }, - '/EDIT/UNDO': function(args) { + '/EDIT/UNDO': function(args, custom_module) { - if (READ_ONLY) return + if (READ_ONLY && !custom_module) return editor.undo() }, - '/EDIT/REDO': function(args) { + '/EDIT/REDO': function(args, custom_module) { - if (READ_ONLY) return + if (READ_ONLY && !custom_module) return editor.redo() @@ -307,9 +307,9 @@ var callbacks = { } module.exports = { - exec: function(name, args){ + exec: function(name, args, custom_module){ if (callbacks[name]) { - callbacks[name](args) + callbacks[name](args, custom_module) } }, exists: function(name){ diff --git a/src/server/osc/index.js b/src/server/osc/index.js index 715e69ca..d72562b7 100644 --- a/src/server/osc/index.js +++ b/src/server/osc/index.js @@ -36,7 +36,7 @@ class OscServer { if (typeof lastArg === 'object' && lastArg !== null && lastArg.clientId !== undefined) { options = args.pop() } - this.receiveOsc({host, port, address, args:args.map(x=>this.parseArg(x))}, options.clientId) + this.receiveOsc({host, port, address, args:args.map(x=>this.parseArg(x)), cm: 1}, options.clientId) }, }) : {}