From 55ea9f5f0b41e615dc59a5a8320032fe712cf83d Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Thu, 18 Sep 2025 00:11:33 +0200 Subject: [PATCH] client: use JSON5 as exported --- src/client/remote-control.mjs | 12 ++++++------ src/client/ui/ui-inspector.mjs | 4 ++-- src/client/widgets/common/osc-receiver.mjs | 5 +++-- src/client/widgets/common/widget.mjs | 4 ++-- src/client/widgets/graphs/plot.mjs | 4 ++-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/client/remote-control.mjs b/src/client/remote-control.mjs index bc656d7d..7bcc8c35 100644 --- a/src/client/remote-control.mjs +++ b/src/client/remote-control.mjs @@ -6,7 +6,7 @@ import stateManager from './managers/state.mjs' import sessionManager from './managers/session' import notifications from './ui/notifications.mjs' import uiConsole from './ui/ui-console.mjs' -import {READ_ONLY} from './globals.mjs' +import {READ_ONLY, JSON5} from './globals.mjs' var callbacks = { '/EDIT': function(args, custom_module) { @@ -14,8 +14,8 @@ var callbacks = { if (READ_ONLY && !custom_module) return var [id, json, opts] = args, - newdata = typeof json == 'string' ? JSON.parseFlex(json) : json, - options = typeof opts == 'string' ? JSON.parseFlex(opts) : {}, + newdata = typeof json == 'string' ? JSON5.parse(json) : json, + options = typeof opts == 'string' ? JSON5.parse(opts) : {}, widgets = widgetManager.getWidgetById(id) if (!widgets.length) return @@ -46,8 +46,8 @@ var callbacks = { if (READ_ONLY && !custom_module) return var [id, json, opts] = args, - newdata = typeof json == 'string' ? JSON.parseFlex(json) : json, - options = typeof opts == 'string' ? JSON.parseFlex(opts) : {}, + newdata = typeof json == 'string' ? JSON5.parse(json) : json, + options = typeof opts == 'string' ? JSON5.parse(opts) : {}, widgets = widgetManager.getWidgetById(id) if (!widgets.length) return @@ -210,7 +210,7 @@ var callbacks = { if (!Array.isArray(args)) args = [args] var json = args[0], - data = typeof json == 'string' ? JSON.parseFlex(json) : json, + data = typeof json == 'string' ? JSON5.parse(json) : json, send = !(args[1] === 0 || args[1] === false) stateManager.set(data, send) diff --git a/src/client/ui/ui-inspector.mjs b/src/client/ui/ui-inspector.mjs index 0d6943d0..05a71af2 100644 --- a/src/client/ui/ui-inspector.mjs +++ b/src/client/ui/ui-inspector.mjs @@ -11,7 +11,7 @@ import {icon} from './utils.mjs' import zoom from './zoom.mjs' import locales from '../locales/index.mjs' import getCodeEditor from './ui-code-editor.mjs' -import {DOM} from '../globals.mjs' +import {DOM, JSON5} from '../globals.mjs' var editor ;(async()=>{ @@ -313,7 +313,7 @@ class UiInspector extends UiWidget { v try { - v = JSON.parseFlex(str) + v = JSON5.parse(str) } catch(err) { v = str } diff --git a/src/client/widgets/common/osc-receiver.mjs b/src/client/widgets/common/osc-receiver.mjs index aa674598..7809355d 100644 --- a/src/client/widgets/common/osc-receiver.mjs +++ b/src/client/widgets/common/osc-receiver.mjs @@ -1,5 +1,6 @@ import osc from '../../osc.mjs' import {isJSON, isJSONObject} from '../../utils.mjs' +import {JSON5} from '../../globals.mjs' export default class OscReceiver { @@ -9,7 +10,7 @@ export default class OscReceiver { if (typeof value === 'string' && isJSON(value)) { try { - this.value = JSON.parseFlex(value) + this.value = JSON5.parse(value) } catch (err) { this.value = value } @@ -72,7 +73,7 @@ export default class OscReceiver { if (value.length < 2) value = value[0] if (typeof value === 'string' && isJSONObject(value)) { try { - this.value = JSON.parseFlex(value) + this.value = JSON5.parse(value) } catch (err) { this.value = value } diff --git a/src/client/widgets/common/widget.mjs b/src/client/widgets/common/widget.mjs index 22b61941..24a6cb58 100644 --- a/src/client/widgets/common/widget.mjs +++ b/src/client/widgets/common/widget.mjs @@ -11,7 +11,7 @@ import * as resize from '../../events/resize.mjs' import OscReceiver from './osc-receiver.mjs' import {deepCopy, deepEqual, isJSON} from '../../utils.mjs' import Script from '../scripts/script.mjs' -import {PXSCALE} from '../../globals.mjs' +import {PXSCALE, JSON5} from '../../globals.mjs' var updateWidget = ()=>{}, uiConsole, widgetTree, widgetDragResize, sessionManager @@ -712,7 +712,7 @@ class Widget extends EventEmitter { if (typeof value === 'string' && isJSON(value)) { try { - value = JSON.parseFlex(value) + value = JSON5.parse(value) } catch (err) {} } diff --git a/src/client/widgets/graphs/plot.mjs b/src/client/widgets/graphs/plot.mjs index 2db17eaa..21808f36 100644 --- a/src/client/widgets/graphs/plot.mjs +++ b/src/client/widgets/graphs/plot.mjs @@ -2,7 +2,7 @@ import html from 'nanohtml' import {mapToScale} from '../utils.mjs' import Canvas from '../common/canvas.mjs' import StaticProperties from '../mixins/static_properties.mjs' -import {PXSCALE} from '../../globals.mjs' +import {PXSCALE, JSON5} from '../../globals.mjs' export default class Plot extends StaticProperties(Canvas, {bypass: true}) { @@ -227,7 +227,7 @@ export default class Plot extends StaticProperties(Canvas, {bypass: true}) { if (typeof v == 'string') { try { - v = JSON.parseFlex(v) + v = JSON5.parse(v) } catch(err) {} }