From c59c4a8065d198bf95f1b6316a7410cb80423b59 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 20 Jan 2026 09:51:35 +0100 Subject: [PATCH] widgets: resolveProp: preserve numbers and booleans as strings in object values --- CHANGELOG.md | 5 +++++ package.json | 2 +- src/client/widgets/common/widget.mjs | 13 ++++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 500f666f..434b6057 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.30.2 + +- bug fixes + - when using objects in properties, numbers-as-strings and booleans-as-strings values are now preserved instead of being converted to their litteral counterparts + ## 1.30.1 - bug fixes diff --git a/package.json b/package.json index 8c7d19ae..f446937a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "open-stage-control", "productName": "Open Stage Control", "description": "Libre and modular OSC / MIDI controller", - "version": "1.30.1", + "version": "1.30.2", "author": { "name": "Jean-Emmanuel Doucet", "email": "jean-emmanuel@ammd.net" diff --git a/src/client/widgets/common/widget.mjs b/src/client/widgets/common/widget.mjs index a2493fa6..28accfe9 100644 --- a/src/client/widgets/common/widget.mjs +++ b/src/client/widgets/common/widget.mjs @@ -567,7 +567,7 @@ class Widget extends EventEmitter { } - resolveProp(propName, propValue, storeLinks=true, originalWidget, originalPropName, context) { + resolveProp(propName, propValue, storeLinks=true, originalWidget, originalPropName, context, recursive) { propValue = propValue !== undefined ? propValue : deepCopy(this.props[propName]) originalWidget = originalWidget || this @@ -886,7 +886,14 @@ class Widget extends EventEmitter { propValue = propValue.replace(new RegExp(k, 'g'), v) } - if (isJSON(propValue) && (propName !== 'label' || propValue === 'false')) { + if ( + // json heuristic + isJSON(propValue) && + // allow "false" string in label + (propName !== 'label' || propValue === 'false') && + // don't coerce booleans and numbers as strings in objects + (!recursive || (isNaN(propValue) && propValue != 'true' && propValue != 'false')) + ) { try { propValue = JSON.parse(propValue) } catch (err) {} @@ -894,7 +901,7 @@ class Widget extends EventEmitter { } else if (propValue != null && typeof propValue == 'object') { for (let k in propValue) { - propValue[k] = this.resolveProp(propName, propValue[k], storeLinks, originalWidget, originalPropName, context) + propValue[k] = this.resolveProp(propName, propValue[k], storeLinks, originalWidget, originalPropName, context, true) } }