diff --git a/.travis.yml b/.travis.yml index 9e7dd66e..95ad0b73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,28 +24,23 @@ before_deploy: - npm run build-docs - npm run package -- --all - npm run package-node - - npm run deb32 + - cd $TRAVIS_BUILD_DIR/dist/open-stage-control-linux-x64/resources/app/server/ + - wget https://github.com/jean-emmanuel/open-stage-control-midi/releases/latest/download/osc-midi-linux && chmod +x osc-midi-linux + - cd $TRAVIS_BUILD_DIR/dist/open-stage-control-win32-x64/resources/app/server/ + - wget https://github.com/jean-emmanuel/open-stage-control-midi/releases/latest/download/osc-midi-windows.exe && chmod +x osc-midi-windows.exe + - cd $TRAVIS_BUILD_DIR/dist/open-stage-control-darwin-x64/open-stage-control.app/Contents/Resources/app/server + - wget https://github.com/jean-emmanuel/open-stage-control-midi/releases/latest/download/osc-midi-osx && chmod +x osc-midi-osx + - cd $TRAVIS_BUILD_DIR - npm run deb64 - - npm run debarm - cd dist - mkdir packages - - mv open-stage-control-linux-ia32/*.deb packages/open-stage-control-${VERSION}-i386.deb - mv open-stage-control-linux-x64/*.deb packages/open-stage-control-${VERSION}-amd64.deb - - mv open-stage-control-linux-armv7l/*.deb packages/open-stage-control-${VERSION}-armv7l.deb - mv open-stage-control-node open-stage-control-${VERSION}-node - - mv open-stage-control-win32-ia32 open-stage-control-${VERSION}-win32-ia32 - mv open-stage-control-win32-x64 open-stage-control-${VERSION}-win32-x64 - - mv open-stage-control-linux-ia32 open-stage-control-${VERSION}-linux-ia32 - mv open-stage-control-linux-x64 open-stage-control-${VERSION}-linux-x64 - - mv open-stage-control-linux-armv7l open-stage-control-${VERSION}-linux-armv7l - - mv open-stage-control-linux-arm64 open-stage-control-${VERSION}-linux-arm64 - zip -q -r --symlinks packages/open-stage-control-${VERSION}-osx.zip open-stage-control-darwin-x64/open-stage-control.app - zip -q -r packages/open-stage-control-${VERSION}-node.zip open-stage-control-${VERSION}-node - - zip -q -r packages/open-stage-control-${VERSION}-win32-ia32.zip open-stage-control-${VERSION}-win32-ia32 - zip -q -r packages/open-stage-control-${VERSION}-win32-x64.zip open-stage-control-${VERSION}-win32-x64 - - zip -q -r packages/open-stage-control-${VERSION}-linux-ia32.zip open-stage-control-${VERSION}-linux-ia32 - zip -q -r packages/open-stage-control-${VERSION}-linux-x64.zip open-stage-control-${VERSION}-linux-x64 - - zip -q -r packages/open-stage-control-${VERSION}-linux-armv7l.zip open-stage-control-${VERSION}-linux-armv7l - - zip -q -r packages/open-stage-control-${VERSION}-linux-arm64.zip open-stage-control-${VERSION}-linux-arm64 - ls packages - cd .. diff --git a/CHANGELOG.md b/CHANGELOG.md index 825eabbc..239fa1e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,33 @@ # Changelog -## 1.6.3 +## 1.7.0 + +**Important change** + +Prebuilt binaries are now supplied only for 64bit Linux/MacOs/Windows. Other platforms should use the `node` package or build it from sources. + +**MIDI support** + +As of this version, packages except the `node` package are bundled with a midi binary that will be used whenever midi's `path` option is not set. It is no longer necessary to install `python` and `python-rtmidi`. + +**Changelog** + - bug fixes - missing context menu (copy, paste) in inspector inputs - osc listeners not resolving "auto" address - `ELECTRON_RUN_AS_NODE` headless mode not working without `--no-gui` option + - ios: clone widget not laid out properly in horizontal panels -- editor - - add console panel under the inspector to ease debugging +- ui + - add console bottom panel with a simple script interpreter - widgets - keyboard: add `velocity` property (allows mapping the touch coordinates between `off` (top) and `on` (bottom)) - - input: add `validation` property (allows defining a regular expression that the valud must match) + - input: add `validation` property (allows defining a regular expression that the value must match) - midi - accept sending sysex strings without spaces between the bytes + - load prebuilt midi binary on 64bit linux/windows/osx - misc - sessions converted from v0 will use the widget's html property to display the former label property diff --git a/package.json b/package.json index 35bdd1e8..e63fcceb 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.6.2", + "version": "1.7.0-beta2", "author": { "name": "Jean-Emmanuel Doucet", "email": "jean-emmanuel@ammd.net" @@ -83,11 +83,8 @@ "start": "electron app/", "build": "npm run build-css && npm run build-js && node scripts/copy-assets.js && echo '\\033[36m=> JS and CSS assets built successfully. Run \"npm run package\" to build an executable or \"npm start\" to run the app.\\033[0m\n'", "package": "node scripts/package.js", - "package-rpi": "node scripts/package.js --old-rpi", "package-node": "node scripts/package-node.js", - "deb32": "electron-installer-debian --src dist/open-stage-control-linux-ia32/ --arch i386 --dest dist/open-stage-control-linux-ia32/ --icon resources/images/logo.png", "deb64": "electron-installer-debian --src dist/open-stage-control-linux-x64/ --arch amd64 --dest dist/open-stage-control-linux-x64/ --icon resources/images/logo.png", - "debarm": "electron-installer-debian --src dist/open-stage-control-linux-armv7l/ --arch armv7l --dest dist/open-stage-control-linux-armv7l/ --icon resources/images/logo.png", "build-css": "node scripts/build-css.js", "build-js": "npm run build-launcher-js && npm run build-client-js && npm run build-server-js", "build-client-js": "node scripts/build-client.js", diff --git a/resources/docs/docs/getting-started/introduction.md b/resources/docs/docs/getting-started/introduction.md index 8cf22a1a..314a3cec 100644 --- a/resources/docs/docs/getting-started/introduction.md +++ b/resources/docs/docs/getting-started/introduction.md @@ -28,11 +28,11 @@ iOS devices must be of version `10.3` or higher. ## Installation -??? example "Linux" +??? example "Linux 64bit" **Ubuntu / Debian** - - [Download](/download) `open-stage-control-VERSION-ARCH.deb` + - [Download](/download) `open-stage-control-VERSION-amd64.deb` - Install it by running this as root in a terminal: ```bash dpkg -i path/to/open-stage-control-VERSION-ARCH.deb @@ -40,18 +40,25 @@ iOS devices must be of version `10.3` or higher. **Other linux distributions** - - [Download](/download) `open-stage-control-VERSION-linux-ARCH.zip` + - [Download](/download) `open-stage-control-VERSION-linux-x64.zip` - Extract it in the location of your choice - The file inside it named `open-stage-control` is the app's main executable -??? example "Mac" +??? example "Mac 64bit" - [Download](/download) `open-stage-control-VERSION-osx.zip` - Extract it in the location of your choice - Drag `open-stage-control.app` in your `Application` folder -??? example "Windows" +??? example "Windows 64bit" - - [Download](/download) `open-stage-control-VERSION-win32-ARCH.zip` + - [Download](/download) `open-stage-control-VERSION-win32-x64.zip` - Extract it in the location of your choice - The file inside it named `open-stage-control.exe` is the app's main executable + +??? example "Other systems" + + - Install [Node.js](https://nodejs.org/en/download/package-manager/) + - Download `open-stage-control-VERSION-node.zip` + - Extract it in the location of your choice + - In a terminal, run `node /path/to/open-stage-control-VERSION-node --help` diff --git a/resources/docs/docs/getting-started/running-from-sources.md b/resources/docs/docs/getting-started/running-from-sources.md index 8071bd0d..58c19463 100644 --- a/resources/docs/docs/getting-started/running-from-sources.md +++ b/resources/docs/docs/getting-started/running-from-sources.md @@ -21,6 +21,13 @@ npm install npm run build ``` +!!! tip "Raspberry systems" + Run this instead of `npm install` if the architecture is `armv7l` + ``` + npm install --arch=armv7l + ``` + + !!! info "Updating from sources" ```bash git pull @@ -51,12 +58,9 @@ npm run build-docs ## Package from sources +Follow the "Run from sources" instructions, then: + ```bash -git clone https://github.com/jean-emmanuel/open-stage-control -cd open-stage-control/ -# uncomment next line if you want the latest release -# instead of the current development version -# git checkout $(git describe --tags `git rev-list --tags --max-count=1`) # TARGET_PLATFORM can be linux, win32 (windows) or darwin (os x) export PLATFORM=TARGET_PLATFORM @@ -64,21 +68,8 @@ export PLATFORM=TARGET_PLATFORM export ARCH=TARGET_ARCH -npm install - -# run this instead if ARCH is armv7l -# npm install --arch=armv7l - - -npm run build - npm run package -# Do one of the following if you want a deb package for debian/ubuntu -npm run deb32 -npm run deb64 -npm run debarm - # The node-only package can be built with npm run package-node @@ -89,3 +80,10 @@ This will build the app in `dist/open-stage-control-PLATFORM-ARCH`. !!! info "" Building the app for windows from a linux system requires wine to be installed. + + +## Debian/Ubuntu installer + +``` +npm run deb64 +``` diff --git a/resources/docs/docs/midi/midi-configuration.md b/resources/docs/docs/midi/midi-configuration.md index e03558d6..a1eee906 100644 --- a/resources/docs/docs/midi/midi-configuration.md +++ b/resources/docs/docs/midi/midi-configuration.md @@ -1,46 +1,55 @@ ## Installation -Enabling MIDI support in Open Stage Control requires additional softwares to be installed on the server's system: -- [python 3](https://www.python.org/downloads/) -- python package [python-rtmidi](https://spotlightkid.github.io/python-rtmidi/installation.html#from-pypi) +=== "Linux / Windows / OSX" -??? example "Linux" + Since version `1.7.0`, Open Stage Control comes bundled with built-in MIDI support if you're using the 64bit package for Linux, OSX or Windows. - - Install `python3` and `python3-pip` from your distribution's package repository - - Install `python-rtmidi` from a terminal by executing this command - ```bash - python3 -m pip install python-rtmidi --upgrade - ``` -??? example "Mac" +=== "Other systems" - - Download and install [Python 3 for Mac OS](https://www.python.org/downloads/mac-osx/) - - Open a terminal - - Install `pip` (package installer for python) by executing these commands - ``` - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - python get-pip.py - ``` - - Install `python-rtmidi` by executing this command - ```bash - python -m pip install python-rtmidi --upgrade - ``` + Enabling MIDI support on other systems or when building Open Stage Control from sources requires additional softwares to be installed on the server's system: -??? example "Windows" + - [python 3](https://www.python.org/downloads/) + - python package [python-rtmidi](https://spotlightkid.github.io/python-rtmidi/installation.html#from-pypi) - - Download and install [Python 3 for Windows](https://www.python.org/downloads/windows/) - - **make sure to check the option** "Add Python 3.x to PATH" - - Open a terminal (++win+r++) - - Install `pip` (package installer for python) by executing these commands - ``` - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - python get-pip.py - ``` - - Install `python-rtmidi` by executing this command - ```bash - python -m pip install python-rtmidi --upgrade - ``` + + ??? example "Linux" + + - Install `python3` and `python3-pip` from your distribution's package repository + - Install `python-rtmidi` from a terminal by executing this command + ```bash + python3 -m pip install python-rtmidi --upgrade + ``` + + ??? example "Mac" + + - Download and install [Python 3 for Mac OS](https://www.python.org/downloads/mac-osx/) + - Open a terminal + - Install `pip` (package installer for python) by executing these commands + ``` + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python get-pip.py + ``` + - Install `python-rtmidi` by executing this command + ```bash + python -m pip install python-rtmidi --upgrade + ``` + + ??? example "Windows" + + - Download and install [Python 3 for Windows](https://www.python.org/downloads/windows/) + - **make sure to check the option** "Add Python 3.x to PATH" + - Open a terminal (++win+r++) + - Install `pip` (package installer for python) by executing these commands + ``` + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python get-pip.py + ``` + - Install `python-rtmidi` by executing this command + ```bash + python -m pip install python-rtmidi --upgrade + ``` ## Configuration @@ -73,17 +82,17 @@ Enable parsing of midi time code messages (disabled by default). These will be r Send program changes with a `-1` offset to match some software/hardware implementations -**`path=/path/to/python`** - -Indicates where to find python binary in case open stage control doesn't (`Error: spawn python3 ENOENT`). - - **`device_name:virtual`** (*Linux / Mac only*): creates a virtual midi device with one input port and one output port **`jack`** (*Linux only*): use JACK MIDI instead of ALSA. `python-rtmidi` must be compiled with [jack support](https://spotlightkid.github.io/python-rtmidi/installation.html#linux) for this to work. +**`path=/path/to/python`** + +Indicates where to find python binary in case open stage control doesn't (`Error: spawn python3 ENOENT`). *Only use this if you know what you are doing.* + + ## Widget setup In order to send MIDI messages, a widget must have at least one `target` formatted as follows: diff --git a/resources/docs/download.md b/resources/docs/download.md index d0d27d44..ff9ebb29 100644 --- a/resources/docs/download.md +++ b/resources/docs/download.md @@ -1,5 +1,8 @@ # Download the latest release +!!! tip "" + [*Click here*](/docs/getting-started/introduction/#installation) to read the installation guide. + Open Stage Control
Loading assets...
diff --git a/scripts/package.js b/scripts/package.js index 6fceea4c..40049303 100644 --- a/scripts/package.js +++ b/scripts/package.js @@ -5,16 +5,14 @@ const packager = require('electron-packager'), licensePath = path.resolve(__dirname + '/../LICENSE'), fs = require('fs') -var rpi = process.argv.includes('--old-rpi'), - all = process.argv.includes('--all') +var all = process.argv.includes('--all') packager({ dir: path.resolve(__dirname + '/../app'), name: appData.name, - all: all ? true : undefined, - platform: rpi ? 'linux' : process.env.PLATFORM, - arch: rpi ? 'armv7l' : process.env.ARCH, - electronVersion: rpi ? '1.7.11' : require('../package.json').optionalDependencies.electron, + platform: all ? ['linux', 'win32', 'darwin'] : process.env.PLATFORM, + arch: process.env.ARCH || 'x64', + electronVersion: process.env.ARCH === 'armv7l' ? '1.7.11' : require('../package.json').optionalDependencies.electron, overwrite: true, out: path.resolve(__dirname + '/../dist'), icon: path.resolve(__dirname + '/../resources/images/logo'), diff --git a/src/client/editor/index.js b/src/client/editor/index.js index 600b057e..a4bce9f9 100644 --- a/src/client/editor/index.js +++ b/src/client/editor/index.js @@ -52,7 +52,7 @@ class Editor { w.props[propName] = previousValue updateWidget(w, {changedProps: [propName], preventSelect: this.selectedWidgets.length > 1}) - if (uiConsole.minimized || rightUiSidePanel.minimized) notifications.add({ + if (uiConsole.minimized) notifications.add({ class: 'error', message: locales('inspector_error'), duration: 7000 diff --git a/src/client/ipc/index.js b/src/client/ipc/index.js index 12c91bc5..62afd88a 100644 --- a/src/client/ipc/index.js +++ b/src/client/ipc/index.js @@ -44,7 +44,7 @@ class Ipc extends EventEmitter { this.socket.send('["pong"]') }) - document.cookie = 'client_id=' + uuid + document.cookie = 'client_id=' + uuid + ';samesite=strict' try { this.open() diff --git a/src/client/locales/en.js b/src/client/locales/en.js index c229f005..9bd95e30 100644 --- a/src/client/locales/en.js +++ b/src/client/locales/en.js @@ -1,7 +1,8 @@ module.exports = { // console - console_title: 'Console', + console: 'Console', + console_enabled: 'Enabled', console_clear: 'Clear console', diff --git a/src/client/locales/fr.js b/src/client/locales/fr.js index b58e710b..85b98fab 100644 --- a/src/client/locales/fr.js +++ b/src/client/locales/fr.js @@ -1,7 +1,8 @@ module.exports = { // console - console_title: 'Console', + console: 'Console', + console_enabled: 'Activée', console_clear: 'Vider la console', // editor diff --git a/src/client/managers/session/session.js b/src/client/managers/session/session.js index c9a17aaa..614ae3e2 100644 --- a/src/client/managers/session/session.js +++ b/src/client/managers/session/session.js @@ -212,7 +212,7 @@ var converters = [ } var label = data.label === undefined ? 'auto' : data.label - if (label !== false && data.type && !data.type.match(/button|menu|modal|clone|html/)) { + if (label !== false && data.type && data.type && !data.type.match(/button|menu|modal|clone|html|tab/)) { label = label === 'auto' ? '@{this.id}' : label data.html = label } @@ -239,6 +239,17 @@ var converters = [ } + } + }, + { + version: '1.6.2', + widget: (data)=>{ + + if (data.script && String(data.script).includes('toolbar(')) { + // new "console" submenu in toolbar at index 3 + data.script = String(data.script).replace('toolbar(4)', 'toolbar(5)').replace('toolbar(3)', 'toolbar(4)') + } + } } ] diff --git a/src/client/ui/main-menu.js b/src/client/ui/main-menu.js index 243ffca8..72cb9777 100644 --- a/src/client/ui/main-menu.js +++ b/src/client/ui/main-menu.js @@ -159,11 +159,6 @@ var menuEntries = [ action: ()=>{return rightUiSidePanel.minimized ? rightUiSidePanel.restore() : rightUiSidePanel.minimize()}, shortcut: 'mod + i' }, - { - label: locales('console_title'), - class: ()=>{return 'toggle ' + (uiConsole.minimized ? 'off' : 'on')}, - action: ()=>{return uiConsole.minimized ? uiConsole.restore() : uiConsole.minimize()} - }, { separator: true }, @@ -174,6 +169,24 @@ var menuEntries = [ } ] }, + { + label: locales('console'), + action: [ + { + label: locales('console_enabled'), + class: ()=>{return 'toggle ' + (uiConsole.minimized ? 'off' : 'on')}, + action: ()=>{return uiConsole.minimized ? uiConsole.restore() : uiConsole.minimize()}, + shortcut: 'mod + k' + }, + { + separator: true + }, + { + label: locales('console_clear'), + action: uiConsole.clear.bind(uiConsole), + }, + ] + }, { separator: true }, diff --git a/src/client/ui/ui-console.js b/src/client/ui/ui-console.js index 54c0aa4f..ccce4742 100644 --- a/src/client/ui/ui-console.js +++ b/src/client/ui/ui-console.js @@ -2,7 +2,9 @@ var UiSidePanel = require('./ui-sidepanel'), html = require('nanohtml'), raw = require('nanohtml/raw'), locales = require('../locales'), - {icon} = require('./utils') + {icon} = require('./utils'), + Script = require('../widgets/scripts/script'), + widgetManager = require('../managers/widgets') class UiConsole extends UiSidePanel { @@ -12,10 +14,11 @@ class UiConsole extends UiSidePanel { this.header = DOM.get(this.container, 'osc-panel-header')[0] - this.header.appendChild(html``) + this.header.appendChild(html``) this.messages = this.content.appendChild(html``) - // this.inputWrapper = this.container.appendChild(html``) - // this.input = this.inputWrapper.appendChild(html``) + + this.inputWrapper = this.content.appendChild(html``) + this.input = this.inputWrapper.appendChild(html``) this.actions = this.header.appendChild(html`
`) this.clearBtn = this.actions.appendChild(html`
${raw(icon('trash'))}
`) @@ -26,44 +29,102 @@ class UiConsole extends UiSidePanel { this.length = 0 this.maxLength = 200 - var _this = this, - log = console.log, - error = console.error + this.history = [''] + this.cursor = 0 + + var _this = this + + console._log = console.log console.log = function(message){ _this.log('log', message) - log(...arguments) + console._log(...arguments) } + console._error = console.error console.error = function(message){ _this.log('error', message) - error(...arguments) + console._error(...arguments) } - // this.input.addEventListener('keydown', (event)=>{ - // if (event.keyCode === 13 && !event.shiftKey) { - // - // event.preventDefault() - // DOM.dispatchEvent(event.target, 'change') - // - // } - // }) - // - // this.input.addEventListener('change', (event)=>{ - // try { - // console.log(eval(this.input.value)) - // } catch (err) { - // console.error(err) - // } - // this.input.value = '' - // }) + this.script = new Script({props:{ + id: 'CONSOLE', + script: 'return eval(value)', + event: 'value' + }, parent: widgetManager}) + this.script._not_editable = true + this.script.hash = 'CONSOLE' + + this.input.addEventListener('keydown', (event)=>{ + if (event.keyCode === 13 && !event.shiftKey) { + event.preventDefault() + this.inputValidate() + } else if (event.keyCode === 38) { + if (this.cursor < this.history.length - 1) { + + if (this.input.value.substr(0, this.input.selectionStart).split('\n').length !== 1) return + + this.cursor += 1 + this.input.value = this.history[this.cursor] + event.preventDefault() + } + } else if (event.keyCode === 40) { + if (this.cursor > 0) { + var nLines = this.input.value.split('\n').length + if (this.input.value.substr(0, this.input.selectionStart).split('\n').length !== nLines) return + + this.cursor -= 1 + this.input.value = this.history[this.cursor] + event.preventDefault() + } + } else if (event.keyCode === 9) { + var cur = this.input.selectionStart, + val = this.input.value + this.input.value = val.slice(0, cur) + ' ' + val.slice(cur) + event.preventDefault() + } + + this.inputSize() + + }) + + this.input.addEventListener('input', (event)=>{ + this.inputSize() + }) this.enable() } - log(type, message) { + inputSize() { + this.input.setAttribute('rows',0) + this.input.setAttribute('rows', this.input.value.split('\n').length) + } + + inputValidate() { + + if (this.input.value == '') return + + this.log('input', `${this.input.value}`) + var returnValue = this.script.setValue(this.input.value, {sync: true, send: true}) + if (returnValue === undefined) { + this.log('output undefined', 'undefined') + } else { + this.log('output value', returnValue) + } + + if (this.input.value !== this.history[this.cursor] && this.input.value !== this.history[1]) { + this.history.splice(1, 0, this.input.value) + if (this.history.length > 10) this.history.pop() + } + + this.input.value = '' + this.cursor = 0 + + } + + log(type, message, html) { var node = this.messages.appendChild(html` @@ -81,7 +142,12 @@ class UiConsole extends UiSidePanel { } } - node.textContent = message + if (html) { + node.innerHTML = message + } else { + node.textContent = message + } + if (type !== 'error' && node.textContent.match(/error/i)) node.classList.add('error') node.scrollIntoView() @@ -105,9 +171,10 @@ class UiConsole extends UiSidePanel { this.messages.innerHTML = '' this.length = 0 + this.script.onRemove() } } -module.exports = new UiConsole({selector: '#osc-console', size: 40}) +module.exports = new UiConsole({selector: '#osc-console', minSize: 40, size: 200, minimized: true}) diff --git a/src/client/ui/ui-sidepanel.js b/src/client/ui/ui-sidepanel.js index 6b70fbf1..d588566c 100644 --- a/src/client/ui/ui-sidepanel.js +++ b/src/client/ui/ui-sidepanel.js @@ -17,11 +17,13 @@ class UiSidePanel extends UiWidget { this.cacheKey = 'ui.' + options.selector - this.minWidth = options.size === undefined ? 250 : options.size - this.width = cache.get(this.cacheKey + '.width') || options.size || 250 + var size = cache.get(this.cacheKey + '.width') || 250 + this.minWidth = options.minSize !== undefined ? options.minSize : (options.size !== undefined ? options.size : 250) + this.width = size !== undefined ? size : (options.size !== undefined ? options.size : 250) this.disabled = false - this.minimized = cache.get(this.cacheKey + '.minimized') || false + var minimized = cache.get(this.cacheKey + '.minimized') + this.minimized = minimized !== null ? minimized : (options.minimized || false) this.init = false diff --git a/src/client/widgets/common/widget.js b/src/client/widgets/common/widget.js index a9ecad9a..c97fb9af 100644 --- a/src/client/widgets/common/widget.js +++ b/src/client/widgets/common/widget.js @@ -13,7 +13,7 @@ var EventEmitter = require('../../events/event-emitter'), morph = require('nanomorph'), sanitizeHtml = require('sanitize-html'), updateWidget = ()=>{}, - Script + Script, uiConsole var oscReceiverState = {} @@ -35,6 +35,7 @@ DOM.ready(()=>{ setTimeout(()=>{ updateWidget = require('../../editor/data-workers').updateWidget + uiConsole = require('../../ui/ui-console') }) class Widget extends EventEmitter { @@ -215,6 +216,7 @@ class Widget extends EventEmitter { script: this.getProp('script'), event: 'value' }, builtIn: true, parent: this}) + this.script._not_editable = true this.on('change', (e)=>{ if (e.widget === this && this.mounted && !e.options.fromEdit) { this.script.setValue(e.options.widget ? e.options.widget.value : this.value, {...e.options, id: e.options.id || e.id}) @@ -659,9 +661,7 @@ class Widget extends EventEmitter { }) } catch (err) { - let stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '', - line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : '' - console.error((this.getProp('id') || this.props.id) + '.' + propName + ': JS{{}} error:\n' + err + line) + this.errorProp(propName, 'JS{{}}', err) } try { @@ -680,9 +680,7 @@ class Widget extends EventEmitter { }) } catch (err) { - let stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '', - line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : '' - console.error((this.getProp('id') || this.props.id) + '.' + propName + ': #{} error:\n' + err + line) + this.errorProp(propName, '#{}', err) } for (let k in variables) { @@ -878,6 +876,25 @@ class Widget extends EventEmitter { } + errorProp(name, type, error) { + + let stackline = error.stack ? (error.stack.match(/>:([0-9]+):[0-9]+/) || '') : '', + line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - (type.includes('{}') ? 1 : 0)) : '', + id = this.getProp('id') || this.props.id, + widget = this // used for edit link in console + + while (widget._not_editable && widget.parent !== widgetManager) { + // ignore non editable + widget = widget.parent + } + + // ignore clone wrapper + if (widget.parent !== widgetManager && widget.parent.getProp('type') === 'clone') widget = widget.parent + + console._error(`${id}.${name} ${type} error${line}: ${error}`) + uiConsole.log('error', `${id}.${name} ${type} error${line}: ${error}`, true) + } + setContainerStyles(styles = ['geometry', 'css', 'visibility']) { if (styles.includes('geometry')) { diff --git a/src/client/widgets/containers/clone.js b/src/client/widgets/containers/clone.js index 6a7b2d50..495576c9 100644 --- a/src/client/widgets/containers/clone.js +++ b/src/client/widgets/containers/clone.js @@ -27,7 +27,7 @@ class Clone extends Container() { value: null, osc: null }) - + defaults.style = {css: defaults.style.css} return defaults @@ -98,6 +98,7 @@ class Clone extends Container() { if (e.widget !== this) { e.widget.container.classList.add('not-editable') + e.widget._not_editable = true } }) diff --git a/src/client/widgets/containers/keyboard.js b/src/client/widgets/containers/keyboard.js index 00616517..73e22603 100644 --- a/src/client/widgets/containers/keyboard.js +++ b/src/client/widgets/containers/keyboard.js @@ -133,6 +133,7 @@ class Keyboard extends Panel { key._index = i - start key.container.classList.add('not-editable') + key._not_editable = true key.container.classList.add('key') if (pattern[i % 12] == 'w') { diff --git a/src/client/widgets/containers/matrix.js b/src/client/widgets/containers/matrix.js index e2f12132..8e2f56f2 100644 --- a/src/client/widgets/containers/matrix.js +++ b/src/client/widgets/containers/matrix.js @@ -80,6 +80,7 @@ class Matrix extends Panel { widget._index = i widget.container.classList.add('not-editable') + widget._not_editable = true this.value[i] = widget.getValue() @@ -152,6 +153,7 @@ class Matrix extends Panel { this.children[i].updateProps(Object.keys(data), this, options) // this.children[i] might have been recreated this.children[i].container.classList.add('not-editable') + this.children[i]._not_editable = true } diff --git a/src/client/widgets/containers/patchbay.js b/src/client/widgets/containers/patchbay.js index e2a7e429..eb810919 100644 --- a/src/client/widgets/containers/patchbay.js +++ b/src/client/widgets/containers/patchbay.js @@ -150,6 +150,7 @@ class PatchBay extends Container(Canvas) { parent: this }) w.container.classList.add('not-editable') + w._not_editable = true this.inputsWidgets.push(w) this.inputNodes.push(w.container) } diff --git a/src/client/widgets/scripts/script-vm.js b/src/client/widgets/scripts/script-vm.js index 239fbe90..9f0ac7fa 100644 --- a/src/client/widgets/scripts/script-vm.js +++ b/src/client/widgets/scripts/script-vm.js @@ -271,7 +271,7 @@ class ScriptVm extends Vm { try { callback() } catch(e) { - console.log(e) + this.errorProp('script', 'setTimeout', e) } this.setWidget() this.setValueOptions() @@ -309,7 +309,7 @@ class ScriptVm extends Vm { try { callback() } catch(e) { - console.log(e) + this.errorProp('script', 'setInterval', e) } this.setWidget() this.setValueOptions() diff --git a/src/client/widgets/scripts/script.js b/src/client/widgets/scripts/script.js index 0108bdb6..1e068636 100644 --- a/src/client/widgets/scripts/script.js +++ b/src/client/widgets/scripts/script.js @@ -89,9 +89,7 @@ class Script extends Widget { } catch(err) { - let stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '', - line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : '' - console.error((this.getProp('id') || this.props.id) + '.script error:\n' + err + line) + this.errorProp('script', 'javascript', err) this.script = ()=>{} } @@ -105,17 +103,17 @@ class Script extends Widget { scriptVm.setWidget(this) this.scriptLock = true + var returnValue try { - this.script(context, this.builtIn ? this.parent.parsersLocalScope : this.parsersLocalScope) + returnValue = this.script(context, this.builtIn ? this.parent.parsersLocalScope : this.parsersLocalScope) } catch(err) { - let stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '', - line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : '' - console.error((this.getProp('id') || this.props.id) + '.script error:\n' + err + line) + this.errorProp('script', 'javascript', err) } this.scriptLock = false scriptVm.setWidget() + return returnValue } @@ -125,7 +123,7 @@ class Script extends Widget { scriptVm.setValueOptions(options) - this.run({ + var returnValue = this.run({ value: v, id: options.id, touch: options.touch @@ -133,6 +131,8 @@ class Script extends Widget { scriptVm.setValueOptions(options) + return returnValue + } } diff --git a/src/html/client.html b/src/html/client.html index 7aee3ab4..c1012c7f 100644 --- a/src/html/client.html +++ b/src/html/client.html @@ -17,40 +17,42 @@ - - - -
-
- + + + + +
+
+ + + + +
+ + + + + +
+
+ + + + + +
+ +
+ + +
+
+ - +
- - - - - -
-
- - - - -
-
- - - - -
- - -
-
-
diff --git a/src/python/midi.py b/src/python/midi.py index 8a0220ca..940607b0 100644 --- a/src/python/midi.py +++ b/src/python/midi.py @@ -2,7 +2,7 @@ from head import * from list import * from utils import * -ipc_send('version', '1.2.0') +ipc_send('version', '1.7.0') if 'list' in argv: list() diff --git a/src/scss/ui/console.scss b/src/scss/ui/console.scss index 2a7f8430..8974cde8 100644 --- a/src/scss/ui/console.scss +++ b/src/scss/ui/console.scss @@ -1,7 +1,9 @@ $padding: 8rem; #osc-console { + background: var(--color-background); osc-panel-header { + background: var(--color-ui-background); border-top: 1rem solid var(--color-background); } .toggle-button { @@ -33,15 +35,19 @@ $padding: 8rem; pointer-events: none; } } + osc-panel-content { + display: flex; + flex-direction: column; + font-family: $font-mono; + } } osc-console { - display: block; height: 100%; padding: $padding; overflow-y: auto; - background: var(--color-background); + border-bottom: 1rem solid var(--color-background); } osc-console-message { @@ -49,24 +55,113 @@ osc-console-message { cursor: text; display: block; white-space: pre; + position: relative; + padding-left: 10rem; + &:before { + content: "▮"; + font-family: FontAwesome; + width: 6rem; + display: inline-block; + text-align: center; + position: absolute; + left: 0; + } &.error { color: var(--color-error); + &:before { + content: "▮" + } + } + &.input { + &:before { + content: "\f105" + } + } + &.output { + &:before { + content: "\f104" + } + + &.undefined { + opacity: 0.5; + } + + &.value { + opacity: 0.5; + // &:before { + // opacity: 0.5; + // } + } } margin-bottom: 4rem; + + .edit-widget { + cursor: pointer; + display: inline-block; + padding: 2rem; + border-radius: 2rem; + &.editing { + background: var(--color-ui-background); + } + &[data-widget="CONSOLE"] { + cursor: default; + background: none; + padding: 1rem; + } + } + * { + user-select: inherit; + } + + flex:1; } osc-console-input { display: block; - padding: 4rem; - background: var(--color-ui-background); - height: 30rem; + $field-height: 24rem; + padding-left: 10rem; + + &:before { + content: "\f105"; + font-family: FontAwesome; + width: 6rem; + display: inline-block; + text-align: center; + position: absolute; + left: 0; + line-height: $field-height - 8rem; + padding: 4rem 6rem; + color: var(--color-accent); + } textarea { - padding: 4rem; + font-family: $font-mono; + + line-height: $field-height - 8rem; + padding: 4rem 6rem; + flex: 1; + overflow-x: auto; + overflow-y: hidden; + resize: none; + white-space: pre; display: block; background: var(--color-background); width: 100%; - height: 100%; - resize: none; + cursor: text; + + user-select: initial; + + --scrollbar-size: 6rem; + + // Chromium scrollbar + &::-webkit-scrollbar-thumb:horizontal { + cursor: normal; + } + + // Firefox scrollbar (hidden to preserve height) + scrollbar-width: thin; + &[rows="1"] { + scrollbar-width: none; + } } } diff --git a/src/scss/ui/workspaces.scss b/src/scss/ui/workspaces.scss index 521c4730..fdeccc55 100644 --- a/src/scss/ui/workspaces.scss +++ b/src/scss/ui/workspaces.scss @@ -6,7 +6,7 @@ osc-workspace { --color-stroke: var(--color-widget); // optimize layout recalc - position: absolute; + position: fixed; top:0; left:0; right:0; @@ -14,7 +14,13 @@ osc-workspace { display: flex; flex-direction: row; - overflow: hidden; + + &.vertical { + flex-direction: column; + } + &.horizontal { + flex-direction: row; + } } @@ -24,6 +30,12 @@ osc-panel-container { display:flex; flex-direction: column; + &.vertical { + flex-direction: column; + } + &.horizontal { + flex-direction: row; + } &.center { flex: 1; @@ -328,6 +340,10 @@ osc-panel-content { } +#main { + flex: 1; + min-height: 40rem; +} #osc-greeting-header { --alpha-fill: 0.75; diff --git a/src/scss/widgets/containers.scss b/src/scss/widgets/containers.scss index f6c8c965..bba397ce 100644 --- a/src/scss/widgets/containers.scss +++ b/src/scss/widgets/containers.scss @@ -369,17 +369,20 @@ --widget-spacing: 0; flex: 1; + position: relative; > .widget { border:0!important; box-shadow: none!important; - position: relative!important; - left:auto!important; - bottom:auto!important; - right:auto!important; - top: auto!important; - width: 100%!important; - height: 100%!important; + // on ios, relative position + 100% size and auto position + // does not work well in flex panels + position: absolute!important; + left:0!important; + bottom:0!important; + right:0!important; + top: 0!important; + width: auto!important; + height: auto!important; min-height: initial!important; max-height: initial!important; min-width: initial!important; diff --git a/src/server/callbacks.js b/src/server/callbacks.js index 746551cf..7de58a4b 100644 --- a/src/server/callbacks.js +++ b/src/server/callbacks.js @@ -361,7 +361,7 @@ module.exports = { // cache widget osc data to reduce bandwidth usage if (!widgetHashTable[clientId]) { - widgetHashTable[clientId] = {} + widgetHashTable[clientId] = {CONSOLE: {}} } if (!widgetHashTable[clientId][data.hash]) { diff --git a/src/server/midi.js b/src/server/midi.js index eccb098b..4745f005 100644 --- a/src/server/midi.js +++ b/src/server/midi.js @@ -1,24 +1,38 @@ var {PythonShell} = require('python-shell'), + fs = require('fs'), + path = require('path'), settings = require('./settings'), - midiVersion = '1.2.0' + midiVersion = '1.7.0' var pythonOptions = { scriptPath:__dirname, mode:'text', } +var midiBinaries = { + linux: 'osc-midi-linux', + darwin: 'osc-midi-osx', + win32: 'osc-midi-windows.exe' +} + +var pythonPathOverride +if (process.arch === 'x64' && midiBinaries[process.platform]) { + var p = path.resolve(__dirname, midiBinaries[process.platform]) + if (fs.existsSync(p)) { + pythonPathOverride = p + } +} + class MidiConverter { constructor() { - var pythonPath = settings.read('midi').filter(x=>x.includes('path=')).map(x=>x.split('=')[1])[0] - this.py = new PythonShell('python/midi.py', Object.assign({ args: [ settings.read('debug') ? 'debug' : '', ...settings.read('midi') ], - pythonPath + pythonPath: MidiConverter.getPythonPath() }, pythonOptions)) this.py.childProcess.on('error', (e)=>{ @@ -85,9 +99,7 @@ class MidiConverter { static list() { - var pythonPath = settings.read('midi') ? settings.read('midi').filter(x=>x.includes('path=')).map(x=>x.split('=')[1])[0] : undefined - - PythonShell.run('python/midi.py', Object.assign({pythonPath: pythonPath, args: ['list-only']}, pythonOptions), function(e, results) { + PythonShell.run('python/midi.py', Object.assign({pythonPath: MidiConverter.getPythonPath(), args: ['list-only']}, pythonOptions), function(e, results) { if (e) { if (e.code === 'ENOENT') { console.error(`(ERROR, MIDI) Could not find python binary: ${e.message.replace(/spawn (.*) ENOENT/, '$1')}`) @@ -103,6 +115,16 @@ class MidiConverter { } + static getPythonPath() { + + var pythonPath = settings.read('midi') ? settings.read('midi').filter(x=>x.includes('path=')).map(x=>x.split('=')[1])[0] : undefined + + if (!pythonPath && pythonPathOverride) pythonPath = pythonPathOverride + + return pythonPath + + } + } module.exports = MidiConverter