client: use JSON5 as exported
This commit is contained in:
parent
ca2fce8d05
commit
55ea9f5f0b
5 changed files with 15 additions and 14 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue