Merge branch 'master' of github.com:jean-emmanuel/open-stage-control

This commit is contained in:
bordun 2020-03-27 23:46:01 +01:00
commit 18f1201c0f
42 changed files with 618 additions and 326 deletions

View file

@ -91,7 +91,7 @@
- always hidden except in project tree
- `script` property must not be wrapped in a JS{{}} block anymore
- added `stateGet` and `stateSet` functions
- added `storage` object, proxy to the document's sessionStorage object (allows storing data that persist after page refresh, but not closing)
- added `storage` object, proxy to the document's localStorage object (allows storing data that persist after refresh/close (cleared with the browser's cache)
- added `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` function proxies with an extra `id` argument (they clear automatically when called multiple times and upon widget removal. `id` is scoped to the widget)

View file

@ -60,6 +60,7 @@
"sanitize-html": "1.22.1",
"scope-css": "1.2.1",
"screenfull": "5.0.2",
"semver": "^7.1.3",
"send": "0.17.1",
"sortablejs": "1.10.2",
"source-map-support": "0.5.16",
@ -93,7 +94,7 @@
"watch-browser": "npm run build-client-js -- --watch",
"watch-css": "nodemon --watch src/scss -e scss -x \"npm run build-css -- --reload\"",
"watch-server": "nodemon --watch src/server/ -e js -x \"npm run build-server-js\"",
"watch-launcher": "nodemon --watch src/ -e js -x \"npm run build-launcher-js\"",
"watch-launcher": "nodemon --watch src/launcher/ -e js -x \"npm run build-launcher-js\"",
"build-docs": "node scripts/build-widgets-reference.js > resources/docs/docs/widgets-reference.md && cd resources && npm run build",
"test": "eslint src && npm run build && node tests/test.js"
},

39
resources/docs/support.md Normal file
View file

@ -0,0 +1,39 @@
## Support Open Stage Control
If you would like to show your appreciation, drop a line on the forums, it's always appreciated !
Donations are not possible per see, but you may buy some music made by [AMMD](http://ammd.bandcamp.com), a french nonprofit organization and independent music label that promotes free arts and free softwares.
If you wish to sponsor the project or hire me to build something with Open Stage Control, feel free to [contact me](mailto:jean-emmanuel@ammd.net) but please note that:
- Sponsoring is only possible in an "altruistic" way, that is with no guarantee whatsoever of prioritizing anyone's interests
- I'm not interested in developing dedicated features for proprietary softwares
- I'm not interested in developing closed-source contents
## Infrastructure Sponsors
----
<a href="https://ammd.net/" class="sp-logo">
<img src="/img/sponsors/ammd.png" width="140px"/>
</a>
AMMD hosts this website and made this project possible by funding its first 2 years of development.
----
<a href="https://discourse.org/" class="sp-logo">
<img src="/img/sponsors/discourse.png" width="140px"/>
</a>
Discourse provides the community forum.
----
<a href="https://browserstack.com/" class="sp-logo">
<img src="/img/sponsors/browserstack.png" width="140px"/>
</a>
BrowserStack provides a complete suite of browser emulators for Android, iOS and Windows.
----

View file

@ -0,0 +1 @@
.hljs{display:block;overflow-x:auto;padding:.5em;background:#F0F0F0}.hljs,.hljs-subst{color:#444}.hljs-comment{color:#888888}.hljs-keyword,.hljs-attribute,.hljs-selector-tag,.hljs-meta-keyword,.hljs-doctag,.hljs-name{font-weight:bold}.hljs-type,.hljs-string,.hljs-number,.hljs-selector-id,.hljs-selector-class,.hljs-quote,.hljs-template-tag,.hljs-deletion{color:#880000}.hljs-title,.hljs-section{color:#880000;font-weight:bold}.hljs-regexp,.hljs-symbol,.hljs-variable,.hljs-template-variable,.hljs-link,.hljs-selector-attr,.hljs-selector-pseudo{color:#BC6060}.hljs-literal{color:#78A960}.hljs-built_in,.hljs-bullet,.hljs-code,.hljs-addition{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold}

View file

@ -8,6 +8,7 @@ $font-size: 0.6rem;
@import "admonition";
@import "codehilite";
@import "discourse";
@import "highlight.min.scss";
body {

View file

@ -11,7 +11,6 @@
<link rel="stylesheet" href="{{ "/fonts/roboto.css"|url }}">
<link rel="stylesheet" href="{{ "/styles.css"|url }}">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/default.min.css">
{% block extrahead %}
{% endblock %}
</head>

58
src/client/backup.js Normal file
View file

@ -0,0 +1,58 @@
var localBackup = sessionStorage.getItem('osc.backup')
module.exports = {
exists: localBackup !== null,
save: ()=>{
var session = require('./managers/session/'),
state = require('./managers/state'),
editor = require('./editor/')
if (session.session) {
sessionStorage.setItem('osc.backup', JSON.stringify({
session: session.session.data,
sessionPath: session.sessionPath,
state: state.get(),
history: editor.history,
historyState: editor.historyState,
editorEnabled: editor.enabled
}))
}
},
load: ()=>{
var session = require('./managers/session/'),
state = require('./managers/state'),
editor = require('./editor/'),
ipc = require('./ipc/')
if (localBackup) {
var data = JSON.parse(localBackup)
sessionStorage.removeItem('osc.backup')
session.load(data.session, ()=>{
state.set(data.state, false)
editor.clearHistory()
editor.history = data.history
editor.historyState = data.historyState
if (data.editorEnabled) editor.enable()
ipc.send('sessionSetPath', {path: data.sessionPath})
session.setSessionPath(data.sessionPath)
})
}
}
}

View file

@ -704,7 +704,7 @@ class Editor {
this.historyState = -1
}
var d = diff.diff(this.historySession, sessionManager.session)
var d = diff.diff(this.historySession, sessionManager.session.getRoot())
if (d) {
diff.patch(this.historySession, deepCopy(d))
@ -718,7 +718,7 @@ class Editor {
this.history = []
this.historyState = -1
this.historySession = deepCopy(sessionManager.session)
this.historySession = deepCopy(sessionManager.session.getRoot())
}
@ -733,7 +733,7 @@ class Editor {
d2 = deepCopy(patch)
diff.unpatch(this.historySession, d1)
diff.unpatch(sessionManager.session, d2)
diff.unpatch(sessionManager.session.getRoot(), d2)
this.updateWidgetFromPatch(patch, indexes ? {
addedIndexes: deepCopy(indexes.removedIndexes),
@ -751,7 +751,7 @@ class Editor {
d2 = deepCopy(patch)
diff.patch(this.historySession, d1)
diff.patch(sessionManager.session, d2)
diff.patch(sessionManager.session.getRoot(), d2)
this.updateWidgetFromPatch(patch, indexes ? {
addedIndexes: deepCopy(indexes.addedIndexes),
@ -796,4 +796,4 @@ var editor = new Editor()
module.exports = editor
require('./context-menu')
sessionManager = require('../managers/session')
sessionManager = require('../managers/session/')

View file

@ -16,7 +16,9 @@ document.addEventListener('DOMContentLoaded', function(event) {
setTimeout(()=>{
var ipc = require('./ipc/')
var ipc = require('./ipc/'),
backup = require('./backup')
ipc.init()
@ -24,7 +26,9 @@ document.addEventListener('DOMContentLoaded', function(event) {
document.title = TITLE
ipc.send('ready', {backupId: ENV.backupId})
ipc.send('ready', {hotReload: backup.exists})
backup.load()
}, 100)

View file

@ -1,17 +1,15 @@
var utils = require('../ui/utils'),
osc = require('../osc'),
session = require('../managers/session'),
session = require('../managers/session/'),
widgetManager = require('../managers/widgets'),
state = require('../managers/state'),
editor = require('../editor/'),
locales = require('../locales'),
{deepCopy} = require('../utils'),
UiModal = require('../ui/ui-modal'),
uiLoading = require('../ui/ui-loading'),
notifications = require('../ui/notifications'),
{TRAVERSING_SAMEWIDGET} = require('../events/utils'),
raw = require('nanohtml/raw'),
ipc = require('./')
backup = require('../backup')
module.exports = {
@ -96,75 +94,9 @@ module.exports = {
reload: function(){
var id = Math.random(),
search = location.search,
query = 'backupId=' + id
// disable editor's warning
backup.save()
window.onbeforeunload = null
if (!session.session) {
window.location.href = window.location.href
return
}
try {
// store session & state backup
ipc.send('storeBackup', {
backupId: id,
session: session.session || {},
sessionPath: session.sessionPath,
state: state.get(),
history: editor.history,
historyState: editor.historyState,
editorEnabled: editor.enabled,
})
// reload page and hold backup id
if (search) {
if (search.includes('backupId=')) {
search = search.replace(/backupId=[^&]*/, query)
} else {
search += '&' + query
}
} else {
search += '?' + query
}
window.location.search = search
} catch(e) {
window.location.href = window.location.href
}
},
loadBackup: function(data) {
session.load(data.session, ()=>{
state.set(data.state, false)
editor.historySession = deepCopy(data.session)
editor.history = data.history
editor.historyState = data.historyState
if (data.editorEnabled) editor.enable()
if (data.traversing === TRAVERSING_SAMEWIDGET) {
DOM.get('.traversingSmart')[0].click()
} else if (data.traversing) {
DOM.get('.traversingEnable')[0].click()
}
ipc.send('sessionSetPath', {path: data.sessionPath})
session.setSessionPath(data.sessionPath)
ipc.send('deleteBackup', data.backupId)
})
window.location.href = window.location.href
},

View file

@ -63,6 +63,8 @@ module.exports = {
session_parsingerror: 'Parsing error.',
session_uploaderror: 'Failed to upload session file.',
session_unsaved: 'Your changes will be lost if you close this session without saving, continue ?',
session_oldversion_title: 'Warning',
session_oldversion: 'This session was created with an older version, an automatic conversion has been done.',
// state
state: 'State',

View file

@ -63,6 +63,8 @@ module.exports = {
session_parsingerror: 'Erreur à l\'ouverture de la session.',
session_uploaderror: 'Échec à l\'envoi du fichier de session.',
session_unsaved: 'Vos modifications seront perdues si vous fermez la session actuelle sans sauvegarder, continuer ?',
session_oldversion_title: 'Attention',
session_oldversion: 'Cette session a été créée avec une ancienne version, une conversion automatique a été appliquée.',
// state
state: 'État',

View file

@ -1,13 +1,14 @@
var ipc = require('../ipc/'),
parser = require('../parser'),
editor = require('../editor/'),
uiFilebrowser = require('../ui/ui-filebrowser'),
uiFileupload = require('../ui/ui-fileupload'),
UiModal = require('../ui/ui-modal'),
uiLoading = require('../ui/ui-loading'),
var ipc = require('../../ipc/'),
parser = require('../../parser'),
editor = require('../../editor/'),
uiFilebrowser = require('../../ui/ui-filebrowser'),
uiFileupload = require('../../ui/ui-fileupload'),
UiModal = require('../../ui/ui-modal'),
uiLoading = require('../../ui/ui-loading'),
{saveAs} = require('file-saver'),
widgetManager = require('./widgets'),
locales = require('../locales')
widgetManager = require('../widgets'),
locales = require('../../locales'),
Session = require('./session')
var SessionManager = class SessionManager {
@ -38,18 +39,12 @@ var SessionManager = class SessionManager {
setTimeout(()=>{
try {
// backward compat
if (Array.isArray(session)) session = session[0]
// session object must be a root widget
if (session.type !== 'root') throw new Error(locales('session_malformed'))
// ok
this.session = session
this.session = new Session(session)
console.log(this.session)
container.innerHTML = ''
parser.reset()
parser.parse({
data: this.session,
data: this.session.getRoot(),
parentNode: DOM.get('#osc-container')[0]
})
editor.clearHistory()
@ -99,7 +94,7 @@ var SessionManager = class SessionManager {
if (!this.sessionPath) return this.saveAs()
ipc.send('sessionSave', {
session: JSON.stringify(this.session, null, ' '),
session: this.session.toJSON(),
path: this.sessionPath
})
@ -118,7 +113,7 @@ var SessionManager = class SessionManager {
export() {
var sessionfile = JSON.stringify(this.session,null,' '),
var sessionfile = this.session.toJSON(),
blob = new Blob([sessionfile],{type : 'application/json'})
saveAs(blob, new Date().toJSON().slice(0,10)+'_'+new Date().toJSON().slice(11,16) + '.json')
@ -164,7 +159,7 @@ var SessionManager = class SessionManager {
try {
session = JSON.parse(result)
} catch (err) {
new UiModal({title: locales('session_parsingerror'), content: err, icon: 'exclamation-triangle', closable:true})
new UiModal({title: locales('session_parsingerror'), content: err.message, icon: 'exclamation-triangle', closable:true})
}
if (editor.unsavedSession && !confirm(locales('session_unsaved'))) return
if (session) sessionManager.load(session, ()=>{
@ -181,7 +176,7 @@ var SessionManager = class SessionManager {
if (editor.unsavedSession && !confirm(locales('session_unsaved'))) return
this.load({type: 'root'},function(){
this.load(null, function(){
editor.enable()
editor.select(widgetManager.getWidgetById('root'))
})

View file

@ -0,0 +1,196 @@
var semver = require('semver'),
UiModal = require('../../ui/ui-modal'),
locales = require('../../locales')
module.exports = class Session {
constructor(data) {
if (data === null) {
data = {
session: {type: 'root'}
}
} else {
var version = data.version || '0.0.0',
warning = false
for (var converter of converters) {
if (semver.lte(version, converter.version)) {
if (converter.global) data = converter.global(data)
if (converter.widget) this.applyConvert(data.session, converter.widget)
if (converter.warning) warning = true
}
}
if (warning) {
new UiModal({title: locales('session_oldversion_title'), content: locales('session_oldversion'), icon: 'exclamation-triangle', closable:true})
}
}
data.version = PACKAGE.version
data.type = PACKAGE.productName + ' ' + 'session'
this.data = data
}
applyConvert(data, convert) {
convert(data)
if (data.widgets) {
for (let c of data.widgets) {
this.applyConvert(c, convert)
}
}
if (data.tabs) {
for (let c of data.tabs) {
this.applyConvert(c, convert)
}
}
}
getRoot() {
return this.data.session
}
toJSON() {
return JSON.stringify(this.data, null, ' ')
}
}
var converters = [
{
version: '0.49.12',
warning: true,
global: (data)=>{
return {
session: data
}
},
widget: (data)=>{
data.decimals = data.precision
if (data.precision === 0) {
data.typeTags = 'i'
data.decimals = 0
}
if (data.color !== 'auto') data.colorWidget = data.color
switch (data.type) {
case 'toggle':
data.type = 'button'
data.mode = 'toggle'
break
case 'push':
data.type = 'button'
data.mode = data.norelease ? 'tap' : 'push'
break
case 'fader':
data.design = data.compact ? 'compact' : 'default'
break
case 'meter':
data.type = 'fader'
data.design = 'compact'
data.interaction = false
break
case 'strip':
data.type = 'panel'
data.layout = data.horizontal ? 'horizontal' : 'vertical'
break
case 'matrix':
data.layout = 'grid'
if (Array.isArray(data.matrix) && data.matrix.every(x=>typeof x === 'number')) {
data.quantity = data.matrix[0] * data.matrix[1]
data.gridTemplate = data.matrix[0]
}
var oprops = typeof data.props === 'object' && data.props !== null
switch (data.widgetType) {
case 'toggle':
data.widgetType = 'button'
if (oprops) data.props.mode = 'toggle'
break
case 'push':
data.widgetType = 'button'
if (oprops) data.props.mode = data.props.norelease ? 'tap' : 'push'
break
case 'fader':
if (oprops) data.props.design = data.props.compact ? 'compact' : 'default'
break
case 'meter':
data.widgetType = 'fader'
if (oprops) {
data.props.design = 'compact'
data.props.interaction = false
}
break
case 'strip':
data.widgetType = 'panel'
if (oprops) data.props.layout = data.props.horizontal ? 'horizontal' : 'vertical'
break
}
break
case 'eq':
data.filter = data.value
data.value = ''
break
case 'keys':
data.type = 'script'
data.event = 'keyboard'
data.keyRepeat = data.repeat
data.keyBinding = data.binding
data.keyType = data.keyDown && data.keyUp ? 'both' : data.keyUp ? 'keyup' : 'keydown'
data.script = `
// converted from keys widget data
if (type === 'keyup') {
${String(data.keyUp).replace(/^JS{{(.*)}}$/, '$1')}
} else if (type === 'keydown') {
${String(data.keyDown).replace(/^JS{{(.*)}}$/, '$1')}
}
`
break
}
}
}
]

View file

@ -17,6 +17,7 @@ module.exports = function UiFilebrowser(options, callback) {
var popup = new UiModal({
height: 360,
closable: true,
html: true,
title: locales(save ? 'remotesave_save' : 'remotesave_open'),
hide: true
})

View file

@ -264,15 +264,20 @@ class UiInspector extends UiWidget {
computedValue = JSON.stringify(computedValue, null, ' ')
}
new UiModal({closable: true, title: html`<span class="editor-help-title">${name}</span>`, content: html`
new UiModal({closable: true, title: html`<span class="editor-help-title">${name}</span>`, html: true, content: html`
<div class="inspector-help">
<p>Type: <code>${defaultValue.type}</code></p>
<p>Default: <code>${JSON.stringify(defaultValue.value)}</code></p>
<p>Dynamic: <code>${dynamic ? 'true' : 'false'}</code></p>
<p>Computed: <code class="pre">${computedValue}</code></p>
${htmlHelp}
<div class="header">
<p>Type: <code>${defaultValue.type}</code></p>
<p>Default: <code>${JSON.stringify(defaultValue.value)}</code></p>
<p>Dynamic: <code>${dynamic ? 'true' : 'false'}</code></p>
</div>
<div class="description">
${htmlHelp}
</div>
<div class="computed">
<p>Computed value: <code class="pre">${computedValue || 'empty'}</code></p>
</div>
</div>
`})

View file

@ -34,7 +34,7 @@ class UiModal extends UiWidget {
</span>
${options.closable? html`<span class="closer">${raw(icon('times'))}</span>` : ''}
</div>
<div class="popup-content">
<div class="popup-content ${options.html ? 'html' : 'message'}">
${options.content}
</div>
</div>

View file

@ -5,7 +5,7 @@ var UiWidget = require('./ui-widget'),
notifications = require('./notifications'),
fullscreen = require('./fullscreen'),
editor = require('../editor'),
sessionManager = require('../managers/session'),
sessionManager = require('../managers/session/'),
stateManager = require('../managers/state'),
{leftUiSidePanel, rightUiSidePanel} = require('../ui/')

View file

@ -174,6 +174,7 @@ class UiTree extends UiWidget {
if (this.expanded[widget.hash]) node.classList.add('expanded')
if (!init && widget instanceof Root) {
node.classList.add('expanded')
this.expanded[widget.hash] = true
init = true
}
var sublist = node.appendChild(html`<ol style="--depth:${++depth};"></ol>`)

View file

@ -31,7 +31,7 @@ class Button extends Widget {
'- `tap` (no release)'
]},
doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the button require a double tap to be pushed instead of a single tap'},
colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s text color when active.'},
})

View file

@ -29,7 +29,7 @@ class Switch extends MenuBase {
'- `slide`: same as `tap` but allows sliding between values',
'- `click`: activates upon click only and allows further scrolling',
]},
colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s text color when active.'},
})

View file

@ -76,15 +76,15 @@ class Widget extends EventEmitter {
_style:'style',
colorText: {type: 'string', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
colorWidget: {type: 'string', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
colorStroke: {type: 'string', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
colorFill: {type: 'string', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
alphaStroke: {type: 'number', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
alphaFillOff: {type: 'number', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
alphaFillOn: {type: 'number', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
colorText: {type: 'string', value: 'auto', help: 'Text color. Set to "auto" to inherit from parent widget.'},
colorWidget: {type: 'string', value: 'auto', help: 'Widget\'s default accent color. Set to "auto" to inherit from parent widget.'},
colorStroke: {type: 'string', value: 'auto', help: 'Stroke color. Set to "auto" to use `colorWidget`.'},
colorFill: {type: 'string', value: 'auto', help: 'Fill color. Set to "auto" to use `colorWidget`.'},
alphaStroke: {type: 'number', value: 'auto', help: 'Stroke color opacity.'},
alphaFillOff: {type: 'number', value: 'auto', help: 'Fill color opacity (off).'},
alphaFillOn: {type: 'number', value: 'auto', help: 'Fill color opacity (on).'},
padding: {type: 'number', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
padding: {type: 'number', value: 'auto', help: 'Inner spacing.'},
@ -99,14 +99,13 @@ class Widget extends EventEmitter {
'When prefixed with >>, the `linkId` will make the widget act as a master (sending but not receiving)',
'When prefixed with <<, the `linkId` will make the widget act as a slave (receiving but not sending)'
]},
script: {type: 'script', value: '', help: ''},
script: {type: 'script', value: '', help: 'Script executed whenever the widget\'s value is set.'},
_osc: 'osc',
address: {type: 'string', value: 'auto', help: 'OSC address for sending messages, it must start with a /'},
preArgs: {type: '*|array', value: '', help: [
'A value or array of values that will be prepended to the OSC messages.',
'Values can be defined as objects if the osc type tag needs to be specified: `{type: "i", value: 1}`'
]},
typeTags: {type: 'string', value: '', help: [
'Defines the osc argument types, one letter per argument (including preArgs)',

View file

@ -6,7 +6,7 @@ var Container = require('../common/container'),
{diff, diffToWidget} = require('../../editor/diff'),
html = require('nanohtml')
var excludedCloneClasses = ['widget', 'absolute-position', 'not-editable', 'editing', 'flex-expand']
var excludedCloneClasses = ['widget', 'absolute-position', 'not-editable', 'editing', 'flex-expand', 'no-interaction']
class Clone extends Container() {

View file

@ -20,7 +20,8 @@ class Matrix extends StaticProperties(Panel, {scroll: false}) {
_matrix: 'matrix',
widgetType: {type: 'string', value: 'button', help: 'Defines the type of the widgets in the matrix'},
layout: {type: 'string', value: 'horizontal', choices: ['horizontal', 'vertical', 'grid'], help:''},
colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'},
layout: {type: 'string', value: 'horizontal', choices: ['horizontal', 'vertical', 'grid'], help: 'Defines how children are laid out.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
quantity: {type: 'number', value: 4, help: 'Defines the number of widgets in the matrix'},
start: {type: 'integer', value: 0, help: 'First widget\'s index'},

View file

@ -26,8 +26,8 @@ class Modal extends Panel {
popupHeight: {type: 'number|percentage', value: '80%', help: 'Modal popup\'s size'},
popupLeft: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'},
popupTop: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'},
colorPanel: {type: 'string', value: 'auto', help:''},
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''},
colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'},
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help: 'Defines how children are laid out.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
traversing: {type: 'boolean', value: false, help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget'},
scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},

View file

@ -19,8 +19,8 @@ class Panel extends Container() {
_panel:'panel',
colorPanel: {type: 'string', value: 'auto', help:''},
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''},
colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'},
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:'Defines how children are laid out.'},
justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},

View file

@ -17,8 +17,8 @@ class Root extends StaticProperties(Panel, {visible: true, label: false, id: 'ro
_panel:'panel',
colorPanel: {type: 'string', value: 'auto', help:''},
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''},
colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'},
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:'Defines how children are laid out.'},
justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},
@ -47,6 +47,7 @@ class Root extends StaticProperties(Panel, {visible: true, label: false, id: 'ro
constructor(options) {
options.root = true
options.props.id = 'root'
super(options)

View file

@ -17,7 +17,8 @@ module.exports = class Tab extends Panel {
_tab:'tab',
// detached: {type: 'boolean', value: true, help: 'Set to `false` if the tab contains `frame` widgets that should not be reloaded when the tab opens'},
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''},
colorPanel: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'},
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:'Defines how children are laid out.'},
justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},

View file

@ -19,11 +19,11 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo
filters: {type: 'array', value: '', help: [
'Each item must be an object with the following properties',
'- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak", "bandpass" or "notch")',
'- `freq`: number (filter\'s resonant frequency)',
'- `q`: number (Q factor)',
'- `gain`: number',
'- `on`: boolean',
'- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak", "bandpass" or "notch", default: "peak")',
'- `freq`: number (filter\'s resonant frequency, default: 1000)',
'- `q`: number (Q factor, default: 1)',
'- `gain`: number (default: 0)',
'- `on`: boolean (default: true)',
'See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode'
]},
@ -40,9 +40,7 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo
super(options)
setTimeout(()=>{
this.calcResponse()
})
this.calcResponse()
}
@ -58,23 +56,33 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo
for (let filter of this.getProp('filters')) {
if (filter.on === false) continue
if (filter.on !== undefined && !filter.on) continue
biquadResponse({
type: filter.type,
gain: filter.gain,
frequency: filter.freq,
q: filter.q
type: filter.type || 'peak',
gain: filter.gain || 0,
frequency: filter.freq || 1000,
q: filter.q || 1
}, frequencyHz, filterResponse)
}
this.value = filterResponse
this.batchDraw()
this.setValue(filterResponse, {sync: true})
}
setValue() {}
setValue(v, options={}) {
if (!(v instanceof Float32Array) && !(Array.isArray(v)) || v.length !== this.width) return
this.value = v
this.batchDraw()
if (options.sync) this.changed(options)
}
resizeHandle(event){

View file

@ -1,4 +1,4 @@
var {mapToScale, clip} = require('../utils'),
var {mapToScale} = require('../utils'),
Widget = require('../common/widget'),
html = require('nanohtml'),
StaticProperties = require('../mixins/static_properties')
@ -17,19 +17,20 @@ module.exports = class Led extends StaticProperties(Widget, {bypass: true, inter
_led:'led',
mode: {type: 'string', value: 'intensity', choices: ['intensity', 'color'], help: [
''
]},
range: {type: 'object', value: {min:0,max:1}, help: 'Value to led intensity mapping range'},
logScale: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale (base 10). Set to a `number` to define the logarithm\'s base.'},
mode: {type: 'string', value: 'intensity', choices: ['intensity', 'color'], help: 'Defines how value is interpreted (see `value`)'},
range: {type: 'object', value: {min:0, max:1}, help: 'Value range'},
alphaRange: {type: 'object', value: {min:0, max:1}, help: 'Alpha range (if `mode` is `color`)'},
logScale: {type: 'boolean', value: false, help: 'If `mode` is `intensity`, set to `true` to use logarithmic scale.'},
borderRadius: {type: 'string', value: '', help: 'Css border-radius property.'},
}, ['interaction', 'decimals', 'bypass'], {
value: {type: 'number|array|string', value: '', help: [
'- `Number`: if `mode` is set to `intensity`',
'- `Array`: `[r, g, b]` (`r`, `g` and `b` between `0` and `255`)',
'- `Array`: `[r, g, b, alpha]` (`alpha` between `0` and `255`)',
'If `mode` is `intensity`:',
'- `Number`: `intensity` between `range.min` and `range.max`',
'If `mode` is `color`:',
'- `Array`: `[r, g, b]` (`r`, `g` and `b` between `range.min` and `range.max`)',
'- `Array`: `[r, g, b, alpha]` (`alpha` between `alphaRange.min` and `alphaRange.max`)',
'- `String`: CSS color',
]}
@ -75,11 +76,11 @@ module.exports = class Led extends StaticProperties(Widget, {bypass: true, inter
if (Array.isArray(v) && v.length >= 3) {
for (let i in [0,1,2]) {
v[i] = parseInt(clip(v[i],[0,255]))
for (let i in [0, 1, 2]) {
v[i] = parseInt(mapToScale(v[i], [this.getProp('range').min, this.getProp('range').max], [0, 255]))
}
v[3] = clip(v[3] != undefined ? v[3] : 1,[0,1])
v[3] = v[3] === undefined ? 1 : mapToScale(v[3], [this.getProp('alphaRange').min, this.getProp('alphaRange').max], [0, 1], -1)
c = `rgba(${v[0]}, ${v[1]}, ${v[2]}, ${v[3]})`

View file

@ -189,6 +189,16 @@ module.exports = class MultiXy extends Pad {
}
cacheCanvasStyle(style) {
super.cacheCanvasStyle(style)
for (var k in this.pads) {
this.pads[k].cacheCanvasStyle()
this.pads[k].batchDraw()
}
}
updateHandlesPosition() {
for (var i=0;i<this.npoints;i++) {

View file

@ -18,7 +18,7 @@ class Script extends Widget {
_script: 'script',
event: {type: 'string', value: 'value', choices: ['value', 'keyboard']},
event: {type: 'string', value: 'value', choices: ['value', 'keyboard'], help: 'Define which events trigger the script\'s execution.'},
script: {type: 'string', value: '', help: [
'This property is evaluated each time the widget receives a value*. Formulas are given extras variables in this context:',
@ -65,10 +65,17 @@ class Script extends Widget {
if (this.getProp('event') === 'value') {
this.script = scriptVm.compile(this.getProp('script'), {
id: '',
value: 0
})
try {
this.script = scriptVm.compile(this.getProp('script'), {
id: '',
value: 0
})
} catch(err) {
let stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '',
line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : ''
console.log((this.getProp('id') || this.props.id) + '.script error:\n' + err + line)
this.script = ()=>{}
}
} else if (this.getProp('event') === 'keyboard' && this.getProp('keyBinding')) {
@ -91,7 +98,7 @@ class Script extends Widget {
meta: false,
})
} catch(err) {
var stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '',
let stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '',
line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : ''
console.log((this.getProp('id') || this.props.id) + '.script error:\n' + err + line)
this.script = ()=>{}

View file

@ -219,6 +219,12 @@ module.exports = class Encoder extends StaticProperties(Knob, {angle: 360, range
this.clear()
if (this.minDimension < 40) {
minRadius /= 2
gaugeWidth = maxRadius - minRadius
gaugeRadius = maxRadius - gaugeWidth / 2
}
// fill
this.ctx.globalAlpha = this.cssVars.alphaFill
this.ctx.strokeStyle = this.cssVars.colorFill
@ -244,10 +250,12 @@ module.exports = class Encoder extends StaticProperties(Knob, {angle: 360, range
this.ctx.strokeStyle = this.cssVars.colorStroke
this.ctx.lineWidth = PXSCALE
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, minRadius, 0, 2 * Math.PI)
this.ctx.stroke()
if (this.minDimension > 40) {
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, minRadius, 0, 2 * Math.PI)
this.ctx.stroke()
}
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI)
this.ctx.stroke()

View file

@ -15,7 +15,6 @@ module.exports = class Knob extends Slider {
_knob:'knob',
design: {type: 'string', value: 'default', choices: ['default', 'classic'], help: 'Design style'},
mode: {type: 'string', value: 'vertical', choices: ['vertical', 'circular', 'snap'], help: [
'- `circular`: relative move in circular motion',
'- `snap`: snap to touch position and move in vertical motion',
@ -182,117 +181,126 @@ module.exports = class Knob extends Slider {
this.clear()
if (this.getProp('design') === 'default') {
// if (this.getProp('design') === 'default') {
// fill
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = gaugeWidth - this.gaugePadding * 2
if (this.minDimension < 40) {
minRadius /= 2
gaugeWidth = maxRadius - minRadius
gaugeRadius = maxRadius - gaugeWidth / 2
}
if (this.cssVars.alphaFillOff) {
this.ctx.globalAlpha = this.cssVars.alphaFillOff
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, min, max)
this.ctx.stroke()
}
// fill
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = gaugeWidth - this.gaugePadding * 2
if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE])
if (this.cssVars.alphaFillOff) {
this.ctx.globalAlpha = this.cssVars.alphaFillOff
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, min, max)
this.ctx.stroke()
}
if (this.cssVars.alphaFillOn) {
this.ctx.globalAlpha = this.cssVars.alphaFillOn
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, o, d, o > d)
this.ctx.stroke()
}
if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE])
if (dashed) this.ctx.setLineDash([])
if (this.cssVars.alphaFillOn) {
this.ctx.globalAlpha = this.cssVars.alphaFillOn
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, o, d, o > d)
this.ctx.stroke()
}
if (dashed) this.ctx.setLineDash([])
// stroke
// stroke
this.ctx.globalAlpha = this.cssVars.alphaStroke
this.ctx.strokeStyle = this.cssVars.colorStroke
this.ctx.lineWidth = PXSCALE
this.ctx.globalAlpha = this.cssVars.alphaStroke
this.ctx.strokeStyle = this.cssVars.colorStroke
this.ctx.lineWidth = PXSCALE
if (this.minDimension > 40) {
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, minRadius, 0, 2 * Math.PI)
this.ctx.stroke()
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI)
this.ctx.stroke()
// knob
this.ctx.globalAlpha = 1
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = 1.5 * PXSCALE
let r1 = minRadius + this.gaugePadding,
r2 = maxRadius - this.gaugePadding,
a = 2 * Math.PI - d
this.ctx.beginPath()
this.ctx.moveTo(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a))
this.ctx.lineTo(r2 * Math.cos(a) + this.width / 2, this.height / 2 - r2 * Math.sin(a))
this.ctx.stroke()
} else {
// fill
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = 2 * PXSCALE
if (this.cssVars.alphaFillOff) {
this.ctx.globalAlpha = this.cssVars.alphaFillOff
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, min, max)
this.ctx.stroke()
}
if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE])
if (this.cssVars.alphaFillOn) {
this.ctx.globalAlpha = this.cssVars.alphaFillOn
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, o, d, o > d)
this.ctx.stroke()
}
if (dashed) this.ctx.setLineDash([])
// center
this.ctx.fillStyle = this.cssVars.colorPanel
this.ctx.strokeStyle = this.cssVars.colorStroke
this.ctx.lineWidth = 1 * PXSCALE
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius - (2 + this.cssVars.padding) * PXSCALE, 0, 2 * Math.PI)
this.ctx.globalAlpha = this.cssVars.alphaStroke
this.ctx.stroke()
this.ctx.globalAlpha = 1
// this.ctx.fill()
// knob
this.ctx.globalAlpha = 1
this.ctx.fillStyle = this.cssVars.colorFill
this.ctx.lineWidth = 1.5 * PXSCALE
let r1 = maxRadius - (8 + this.cssVars.padding) * PXSCALE,
a = 2 * Math.PI - d
this.ctx.beginPath()
this.ctx.arc(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a), 1.5 * PXSCALE, 0, 2*Math.PI)
this.ctx.fill()
}
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI)
this.ctx.stroke()
// knob
this.ctx.globalAlpha = 1
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = 1.5 * PXSCALE
let r1 = minRadius + this.gaugePadding,
r2 = maxRadius - this.gaugePadding,
a = 2 * Math.PI - d
this.ctx.beginPath()
this.ctx.moveTo(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a))
this.ctx.lineTo(r2 * Math.cos(a) + this.width / 2, this.height / 2 - r2 * Math.sin(a))
this.ctx.stroke()
// } else {
//
// // fill
// this.ctx.strokeStyle = this.cssVars.colorFill
// this.ctx.lineWidth = 2 * PXSCALE
//
// if (this.cssVars.alphaFillOff) {
// this.ctx.globalAlpha = this.cssVars.alphaFillOff
// this.ctx.beginPath()
// this.ctx.arc(this.width / 2, this.height / 2, maxRadius, min, max)
// this.ctx.stroke()
// }
//
// if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE])
//
// if (this.cssVars.alphaFillOn) {
// this.ctx.globalAlpha = this.cssVars.alphaFillOn
// this.ctx.beginPath()
// this.ctx.arc(this.width / 2, this.height / 2, maxRadius, o, d, o > d)
// this.ctx.stroke()
// }
//
// if (dashed) this.ctx.setLineDash([])
//
//
//
// // center
// this.ctx.fillStyle = this.cssVars.colorPanel
// this.ctx.strokeStyle = this.cssVars.colorStroke
// this.ctx.lineWidth = 1 * PXSCALE
//
// this.ctx.beginPath()
// this.ctx.arc(this.width / 2, this.height / 2, maxRadius - (2 + this.cssVars.padding) * PXSCALE, 0, 2 * Math.PI)
// this.ctx.globalAlpha = this.cssVars.alphaStroke
// this.ctx.stroke()
// this.ctx.globalAlpha = 1
// // this.ctx.fill()
//
//
//
// // knob
// this.ctx.globalAlpha = 1
// this.ctx.fillStyle = this.cssVars.colorFill
// this.ctx.lineWidth = 1.5 * PXSCALE
//
// let r1 = maxRadius - (8 + this.cssVars.padding) * PXSCALE,
// a = 2 * Math.PI - d
//
// this.ctx.beginPath()
// this.ctx.arc(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a), 1.5 * PXSCALE, 0, 2*Math.PI)
// this.ctx.fill()
//
//
// }
// pips

View file

@ -269,6 +269,8 @@ osc-inspector-color {
padding: 8rem;
background: var(--color-background);
p {
}
.error {
color: red;
margin-top: 10rem;
@ -278,7 +280,7 @@ osc-inspector-color {
}
code {
color: var(--color-accent);
padding: 1rem 3rem;
padding: 4rem;
background: rgba(black, 0.2);
display: inline-block;
user-select: auto;
@ -292,9 +294,30 @@ osc-inspector-color {
.pre {
white-space: pre;
vertical-align: text-top;
margin-top: -4rem;
position: relative;
padding: 5rem;
user-select: text;
}
.help {
.header p {
margin-bottom: 2rem;
user-select: text;
}
.description {
border-top: 2rem solid var(--color-ui-background);
margin-top: 10rem;
padding-top: 10rem;
white-space: normal;
* {
user-select: text;
}
}
.computed {
border-top: 2rem solid var(--color-ui-background);
margin-top: 10rem;
padding-top: 10rem;
}
}

View file

@ -96,5 +96,13 @@ $padding: 8rem;
min-height: 0;
display: flex;
}
.message {
white-space: normal;
line-height: 150%;
background: var(--color-background);
padding-top:8rem;
overflow-x: auto;
}
}
}

View file

@ -1,4 +1,4 @@
.buttons-container,
.button-container,
.menu-container,
.dropdown-container,
.input-container,

View file

@ -23,3 +23,9 @@
}
}
.frame-container {
iframe[src=""] {
pointer-events: none;
}
}

View file

@ -43,7 +43,7 @@
padding: var(--widget-padding);
display: flex;
width: 100%;
}
@ -51,7 +51,7 @@
color: var(--color-fill);
opacity: var(--alpha-fill-on);
flex: 1;
height: 100%;
height: auto;
display: flex;
justify-content: center;
align-items: center;

View file

@ -7,12 +7,11 @@ var path = require('path'),
theme = require('./theme')
var widgetHashTable = {},
sessionBackups = {},
clipboard = {clipboard: null, idClipboard: null}
module.exports = {
ready: function(data,clientId) {
ready(data,clientId) {
ipc.send('connected')
@ -20,26 +19,13 @@ module.exports = {
ipc.send('sessionList', recentSessions, clientId)
ipc.send('clipboard', clipboard, clientId)
if (data.backupId && sessionBackups[data.backupId]) {
ipc.send('loadBackup', sessionBackups[data.backupId])
return
}
if (settings.read('load')) return this.sessionOpen({path:settings.read('load')},clientId)
if (settings.read('examples')) {
var dir = path.resolve(__dirname + '/../examples')
recentSessions = fs.readdirSync(dir)
recentSessions = recentSessions.map(function(file){return dir + '/' + file})
}
ipc.send('serverTargets', settings.read('send'), clientId)
if (settings.read('load') && !data.hotReload) return this.sessionOpen({path: settings.read('load')}, clientId)
},
sessionAddToHistory: function(data) {
sessionAddToHistory(data) {
var recentSessions = settings.read('recentSessions')
@ -65,7 +51,7 @@ module.exports = {
})
},
sessionRemoveFromHistory: function(data) {
sessionRemoveFromHistory(data) {
var recentSessions = settings.read('recentSessions')
if (recentSessions.indexOf(data) > -1) {
@ -76,7 +62,7 @@ module.exports = {
},
sessionSetPath: function(data, clientId) {
sessionSetPath(data, clientId) {
if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
@ -90,7 +76,7 @@ module.exports = {
},
sessionOpen: function(data, clientId) {
sessionOpen(data, clientId) {
if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
@ -103,7 +89,7 @@ module.exports = {
},
sessionOpened: function(data, clientId) {
sessionOpened(data, clientId) {
if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
@ -128,7 +114,7 @@ module.exports = {
},
fileRead: function(data, clientId, ok, callback) {
fileRead(data, clientId, ok, callback) {
if (!ok) return
@ -155,7 +141,7 @@ module.exports = {
},
fileSave: function(data, clientId, ok, callback) {
fileSave(data, clientId, ok, callback) {
if (!ok) return
@ -212,7 +198,7 @@ module.exports = {
},
stateOpen: function(data, clientId) {
stateOpen(data, clientId) {
if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
@ -224,7 +210,7 @@ module.exports = {
},
sessionSave: function(data, clientId) {
sessionSave(data, clientId) {
if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
@ -249,7 +235,7 @@ module.exports = {
},
stateSave: function(data, clientId) {
stateSave(data, clientId) {
if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
@ -263,7 +249,7 @@ module.exports = {
},
syncOsc: function(shortdata, clientId) {
syncOsc(shortdata, clientId) {
if (!(widgetHashTable[clientId] && widgetHashTable[clientId][shortdata.h])) return
@ -285,7 +271,7 @@ module.exports = {
},
sendOsc: function(shortdata, clientId) {
sendOsc(shortdata, clientId) {
if (!(widgetHashTable[clientId] && widgetHashTable[clientId][shortdata.h])) return
@ -376,50 +362,38 @@ module.exports = {
},
fullscreen: function(data) {
fullscreen(data) {
window.setFullScreen(!window.isFullScreen())
},
reload: function(data) {
reload(data) {
ipc.send('reload')
},
storeBackup: function(data, clientId) {
sessionBackups[data.backupId] = data
},
deleteBackup: function(data) {
delete sessionBackups[data]
},
reloadCss:function(){
reloadCss() {
theme.load()
ipc.send('reloadCss')
},
log: function(data) {
log(data) {
console.log(data)
},
error: function(data) {
error(data) {
console.error(data)
},
errorLog: function(data) {
errorLog(data) {
console.error(data)
},
errorPopup: function(data) {
errorPopup(data) {
ipc.send('error', data)
},
listDir: function(data, clientId) {
listDir(data, clientId) {
var p = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']
@ -455,7 +429,7 @@ module.exports = {
},
clipboard: function(data, clientId) {
clipboard(data, clientId) {
clipboard = data
ipc.send('clipboard', data, null, clientId)

View file

@ -79,7 +79,7 @@ module.exports = function(options={}) {
window.webContents.on('before-input-event', (e, input)=>{
// using before-input-event because electron-localshortcut
// gets azerty keyboards wrong (ctrl + z would also be catched)
if ((input.key === 'w' || input.key === 'W') && input.control) {
if ((input.key === 'w' || input.key === 'W') && input.control && input.type === 'keyDown') {
window.close()
}
})

View file

@ -25,7 +25,7 @@ module.exports = {
},
'c': {alias: 'custom-module', type: 'array', file: {name: 'OSC Custom module (.js)', extensions: ['js']}, describe: 'custom module file to load (custom options can be passed after the filename)',
check: (arg)=>{
return fs.lstatSync(arg) ? true : 'Custom module file not found: ' + arg
return fs.lstatSync(arg[0]) ? true : 'Custom module file not found: ' + arg
},
},
'p': {alias: 'port', type: 'number', describe: 'http port of the server (default to 8080)',