diff --git a/.dockerignore b/.dockerignore
deleted file mode 100644
index bc487890..00000000
--- a/.dockerignore
+++ /dev/null
@@ -1,3 +0,0 @@
-node_modules
-app
-sessions
\ No newline at end of file
diff --git a/.eslintrc.json b/.eslintrc.json
deleted file mode 100644
index 1f9fff30..00000000
--- a/.eslintrc.json
+++ /dev/null
@@ -1,57 +0,0 @@
-{
- "env": {
- "es2021": true,
- "browser": true,
- "node": true
- },
- "extends": "eslint:recommended",
- "parserOptions": {
- "sourceType": "module"
- },
- "rules": {
- "no-prototype-builtins": "off",
- "no-console": "off",
- "no-useless-escape": "off",
- "no-self-assign": "off",
- "no-empty": [
- "error",
- {
- "allowEmptyCatch": true
- }
- ],
- "no-unused-vars": [
- "error",
- {
- "args": "none"
- }
- ],
- "space-before-function-paren": [
- "error",
- "never"
- ],
- "indent": [
- "error",
- 4,
- {
- "SwitchCase": 1,
- "ObjectExpression": 1,
- "ArrayExpression": 1,
- "MemberExpression": "off",
- "ignoredNodes": ["ConditionalExpression", "TemplateElement"]
- }
- ],
- "linebreak-style": [
- "error",
- "unix"
- ],
- "quotes": [
- "error",
- "single",
- { "allowTemplateLiterals": true }
- ],
- "semi": [
- "error",
- "never"
- ]
- }
-}
diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml
deleted file mode 100644
index 68eaa5f3..00000000
--- a/.forgejo/workflows/build.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-name: Build
-on: [workflow_dispatch]
-
-jobs:
- Deploy:
- runs-on: docker
- container:
- image: ghcr.io/catthehacker/ubuntu:act-latest
-
- steps:
- - name: Checkout
- uses: actions/checkout@v4
- with:
- lfs: 'true'
-
- - name: Docker Login
- run: |
- docker login -u riksolo -p ${{secrets.CONTAINER_REGISTRY_TOKEN}} git.riksolo.com
-
- - name: Build and push
- run: |
- docker build -t git.riksolo.com/riksolo/open-stage-control:latest -t git.riksolo.com/riksolo/open-stage-control:${{github.sha}} .
- docker push git.riksolo.com/riksolo/open-stage-control:latest
- docker push git.riksolo.com/riksolo/open-stage-control:${{github.sha}}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 71086d11..1687d79e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,17 +1,2 @@
-# npmg
node_modules/
-
-# build
-/app/
-
-# python/midi build
-src/server/python/*
-!src/server/python/*.py
-
-# docs build
-src/docs/widgets-reference.js
-properties-reference.md
-
-# packaging
-dist/
-sessions/
\ No newline at end of file
+config.json
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 00000000..f9672bfe
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,42 @@
+sudo: required
+dist: trusty
+language: node_js
+node_js:
+ - "4.1"
+before_install:
+ - sudo dpkg --add-architecture i386
+ - sudo apt-get update -qq
+ - sudo apt-get install -qq wine
+install: npm install --save-optional --production
+deploy:
+ provider: releases
+ api-key:
+ secure: Nb4qJlmLEE2/ETHEYe8V8eGI08d4GuE5kdQef5ZnB4PrstppLlAjShv5E4DNTsyalMOMDjpw9v+9aQNzxGiGv+lCVVL5oFvqvDpcYusRuF9Qua7oJtFh+5FvjgC1DDjauk5Z7WQWMvzWwfNmqbY/lxPbA4zVy4kdYkGV/8WnzA9AL5fU0ZU8gDsFjcr9Pz81XDsDXtPH/+iMuclMsEl8V/ZuswWlZaFn1Jnb1tcGC5WUCsuNQo/+gGfSK6Qcf9AKsIrOjdzi55s4jqH1N7P/kKi4a2tWUTwmSLrOxdUmSYjXVOxMu0cAEnHSeYREv/5o6J0MbfQrDoxh2y5roPZzqE+FAuFLl+b/+bYlW0mrfYfSuP/VX9LYh5JSvrhN7rZuUfMqS1iM7c9Dx8sZadMnvYEAAJhH8IV/9SkuRa/8QoIpXf7YB9v1jERxs4gk5CPT5Aml6nY/CvMWiEQ/wJhC7iZd/QRHshgfNLfAGlbbNU2KP6ZsVAGD601fyST/8neoQqLqS9mteOr1QME3c5EFw+XaauIQNYZSl+wJr8Y1YMcKY+fbJqqR0TXkbsoxFgV9PRf/4ZCjIJYtmelQVlM7j20XavOHM/Ko6/y7a3pohFz+ql3YR9jGF5XW2foXb4+e6DwTGL91/f75hYcsvXxoKbeaBjWpaSK8532UTeVkhPM=
+ file:
+ - "./dist/open-stage-control-i386.deb"
+ - "./dist/open-stage-control-amd64.deb"
+ - "./dist/open-stage-control-armv7l.deb"
+ - "./dist/open-stage-control-linux-ia32.zip"
+ - "./dist/open-stage-control-linux-x64.zip"
+ - "./dist/open-stage-control-linux-armv7l.zip"
+ - "./dist/open-stage-control-osx.zip"
+ - "./dist/open-stage-control-win32.zip"
+ - "./dist/open-stage-control-win64.zip"
+ skip_cleanup: true
+ on:
+ tags: true
+before_deploy:
+ - cd dist
+ - zip -q -r --symlinks open-stage-control-osx open-stage-control-darwin-x64/open-stage-control.app
+ - zip -q -r open-stage-control-win32 open-stage-control-win32-ia32
+ - zip -q -r open-stage-control-win64 open-stage-control-win32-x64
+ - zip -q -r open-stage-control-linux-ia32 open-stage-control-linux-ia32
+ - zip -q -r open-stage-control-linux-x64 open-stage-control-linux-x64
+ - zip -q -r open-stage-control-linux-armv7l open-stage-control-linux-armv7l
+ - cd ..
+ - npm run deb32
+ - npm run deb64
+ - npm run debarm
+ - mv dist/open-stage-control-linux-ia32/*.deb dist/open-stage-control-i386.deb
+ - mv dist/open-stage-control-linux-x64/*.deb dist/open-stage-control-amd64.deb
+ - mv dist/open-stage-control-linux-armv7l/*.deb dist/open-stage-control-armv7l.deb
diff --git a/AI_POLICY.md b/AI_POLICY.md
deleted file mode 100644
index 20067a2d..00000000
--- a/AI_POLICY.md
+++ /dev/null
@@ -1,7 +0,0 @@
-Anything AI-related is strictly prohibited from this project.
-
-If you think this project could benefit from a smart use of AI, think harder.
-
-Think harder about the (hundreds of) millions of data workers that make your AI "smart", not to mention the monumental ecological waste it represents.
-
-If you still think this way, don't tell me.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ff189256..deb7d0ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,1778 +1,197 @@
# Changelog
-## 1.31.2
+## 0.6.2
+
+- cool stuff
+ - armv7l prebuilt binaries ! (raspberry 2, etc)
+- engine
+ - electron 1.3.5
+
+## 0.6.1
- bug fixes
- - editor: fix regression (1.30.0) causing errors when editing the value property
+ - editor: widgets/tabs can be accessed through their parent's children list (#27)
+- engine
+ - electron 1.3.1
-- widgets
- - canvas: allow `onResize` to send and trigger widget synchronization and scripts
-
-## 1.31.1
+## 0.6.0
- bug fixes
- - clone: regression causing error when some widgets have a non-string id
-
-## 1.31.0
-
-- widgets
- - clone, fragment: add `scoped` property. This allows making the widget self-contained (independent from its original) by prefixing all widget ids automatically (and transparently resolving unprefixed ids in advanced syntaxes and scripts within the scope)
-
-- bug fixes
- - midi: unrecognized `no_auto_note_off` option
- - MacOs: the app now quits when all windows are closed
- - launcher: if the Tray icon is enabled, closing the launcher window won't quit the app if the server is running
- - scrollbar widget: fix initial value in vertical mode
- - console: fix copying using CmdOrCtrl+C when the editor is enabled
-
-- custom module
- - objects transmitted using `receive()` will be received as objects by the client app (instead of a json string)
-
-## 1.30.4
-
-- bug fixes
- - remote control: add support for icon transform suffixes
- - editor: fix moving/resing widgets inside folders when using percent units
- - clone: `@{parent.propertyName}` blocks in target widget now update when clone's parent property updates
-
-- widgets
- - encoder: add `horizontal` mode
- - knob: add `encoder` design
-
-## 1.30.3
-
-- bug fixes
- - scrollbar: missing update upon target container resize
- - server: regression breaking reception of osc message over tcp
-
-- widgets
- - file: remember last visited directy per widget if `directory` property is not set
- - knob: add `horizontal` mode
- - eq: filter responses are now only computed when needed; the widget's value is no longer exposed / sync'ed.
- - plot, eq: unclip line drawing on y-axis
-
-- scripting
- - add `uploadFile` function for reading client-side files
- - add `scrollIntoView` function
-
-## 1.30.2
-
-- bug fixes
- - when using objects in properties, numbers-as-strings and booleans-as-strings values are now preserved instead of being converted to their litteral counterparts
- - rgb: fix rendering issue
- - patchbay: interaction and rendering issues
- - `event.preventDefault` in `onTouch` now affect modal buttons
- - menu: use click event instead of tap in `toggle` and `doubleTap-toggle` modes
- - button: missing `move` events in `onTouch`
- - error when logging `event` object in `onTouch`
-
-- widgets
- - modal/button/file: add `click` property
-
-- editor
- - preserve code editor undo history between consecutive edits of a same widget's property
- - preserve fullscreen code editor focus when saving / submitting
-
-- client
- - add `noWarning` client option
-
-## 1.30.1
-
-- bug fixes
- - regression breaking user asset loading from a root directory named "assets"
- - regression breaking custom module's `nativeRequire()` for locally installed modules
-
-## 1.30.0
-
-- bug fixes
- - server: fix resolving absolute file urls containing the remote-root path
- - prevent editor zoom level from affecting drag events when the editor is disabled
- - prevent changing editor zoom level when it's disabled
- - fader: fix touchZone == knob for compact design
- - separator labels missing in inspector
- - make the client app more robust to restrictive browser settings (cookie must still be enabled for the app to fully work)
-
-- widgets
- - the html property is no longer restricted / sanitized
- - input/textarea/select no longer have their appearance property reset in custom html
- - canvas: added `contextType` property
- - file: honor server's `remote-root` option (remove root path from displayed path and returned value)
- - menu: changed default `layout` to `vertical`
- - root/panel/modal/tab: support setting `scroll` to `hidden` (hides scrollbars and allows scrolling)
- - add new `scrollbar` widget that connects to a scrolling container widget and acts as it scrollbar
- - input: add `noCanvas` option to avoid blurry text under some circumstances
- - xy: add `clipX` and `clipY` proprties (allows multixy to set per-pads anges limits)
- - button: add `onTouch` script
- - switch: make `values` property dynamic
-
-- editor
- - selecting a widget automatically shows it in the widget tree if it's not minimized
- - submitting an unchanged value for the `value` property will now affect the value state of the widget even if the property content itself did not change
-
-- scripting
- - user scripts are longer protected against infinite loop and the main window object may be reached (it's not supported to break out of scripting context, but resources are no longer wasted to prevent it)
- - `toolbar()` can now target menu actions by id instead of index
- - `getToolbar()` function added (returns the state of a menu entry toggle)
- - calling `setFocus()` without argument now unfocuses current active element
-
-- midi
- - add `no_auto_note_off` option
- - add `Restart backend` action to the launcher's menu
- - add `restartMidiBackend()` function to custom module context
-
-- breaking change
- - dropped support for iOS 10.3
- - minimum chromium version requirement raised to 70
- - macOS 11 (Big Sur) or above is now required (the node package will work on older system)
- - scrollbars are no longer emulated on iOS
- - scrollbar styling is now done using only the standard css scrollbar-* properties) to be more in line with system scrollbars in general
- - panels no longer use their value to set/get their scrolling state, nor do they sync scrolling automatically. Instead there's now a dedicated scrollbar widget that can be used for this.
-
-- misc
- - now using electron v36.9.5
-
-## 1.29.9
-
-- build
- - fix building from sources now that open stage control is not hosted on github
-
-- scripting
- - user scripts are longer protected against infinite loop
-
-## 1.29.8
-
-- bug fixes
- - firefox: `onTouch` error when the cursor goes outside the page
- - dropdown: label not initialized until a value is set
- - editor: regression (1.29.0) preventing color changes made with the color to be undoable unless validaed with the enter key
- - editor: color picker interaction issue in near #000000
- - rgb: incoming values were not queued when during user interaction
-
-- client
- - add `title` client option
-
-## 1.29.7
-
-- launcher
- - add tray icon and menu (landed in 1.29.6 accidentally), disabled by default (can be enabled from the launcher's menu)
-
-
-## 1.29.6
-
-- bug fixes
- - matrix: prevent error when `quantity` is invalid
- - multixy/xy: send value when setting `spring` to `true` (only if current value is different than spring value)
- - switch/menu/fader: more consistent rendering when `borderRadius` is set
-
-- widgets
- - multixy/xy: add `stepsX` and `stepsY` properties
-
-- misc
- - native silicon buids (osx-arm64)
-
-## 1.29.5
-
-- bug fixes
- - keyboard: regression (1.27.5) breaking `velocity` property
- - editor: retain scroll position in code editors
- - cli: regression (1.28) preventing from setting options from a terminal on windows
-
-
-## 1.29.4
-
-- bug fixes
- - regression (1.29.3) breaking some widget recreation routines
-
-## 1.29.3
-
-- widgets
- - frame: add `allow` property
- - matrix: make `quantity` a dynamic property to avoid losing widget state when it changes
- - patchbay: missing `preArgs` implementation
-
-## 1.29.1 / 1.29.2
-
-- bug fixes
- - scripting: `setFocus` not working on iOS
- - fader/range: drawing error with `pips` enabled
-
-## 1.29.0
-
-- bug fixes
- - file browser: drive listing failing on recent windows
- - root: `hideMenu` not working when `--read-only` is set
- - combining `--read-only` and `--fullscreen` now disables `F11` on built-in client
- - regression breaking `pips` for range widget
-
-- widgets
- - add `onTouch` to all container widgets
- - allow starting a traversing gesture outside a touchable widget
- - fader: make `knobSize` dynamic
-
-## 1.28.5
-
-- bug fixes
- - multixy: error when `points` is `0` (or empty array) (again)
-
-## 1.28.4
-
-- bug fixes
- - multixy: error when `points` is `0` (or empty array)
-
-## 1.28.3
-
-- bug fixes
- - multixy: correclty handle incoming feedback values and simultaneous touch releases
-
-## 1.28.2
-
-- bug fixes
- - regression in feedback handling (unfixes multixy simultaneous spring issue temporarily)
-
-## 1.28.1
-
-- bug fixes
- - eq: `highpass` filter not working as expected with `poles` set
- - fader: `touchZone` not applied to `doubleTap` events
- - fader: `touchZone` not affecting mousewheel interactions
- - fader: regression causing issues with `onTouch` scripts
-
-## 1.28.0
-
-- bug fixes
- - ui: global zoom (CmdOrCtrl + scroll / + / - / 0) issues and conflits with native browser zoom;
- - ui: limit ctrl + scroll zoom speed
- - broken cli when `ELECTRON_RUN_AS_NODE` is set
- - inspector: input bug when a code editor was focused using the tab key
- - inspector: prevent editing non-editable widgets (e.g matrix items) when clicking on their ids in error logs
- - multixy: simultaneous touch releases not working correctly when `spring` is set and feedback values are received shortly after being sent
-
-- widgets
- - fader: add `touchZone` property to allow restricting interaction to a part of the widget
- - eq: add support for n-poles lowpass and highpass filters with the filter's `poles` property
- - eq: adapt sampling frequency to the x-axis range
- - xy/multixy: add `auto` choice to `axisLock` (locks on the first moved axis)
- - file: `extension` can now be an array of strings
- - plot/eq: smoother curves
- - sliders/pads: `doubleTap` can now be `"script"`, in which case `onTouch` will be called with `event.type` set to `doubleTap`
- - xy: add `label` property
- - multixy: add `padsAttr` property for per-pad customization
- - panel: `tabsPosition` can now be `hidden`
- - pads: support percents in `pointSize`
-
-- scripting
- - `console.log` now always print the id of the widget that called it
-
-- editor
- - inspector: tab key navigation now works, property categories can be fold/unfold with enter/space when focused
- - inspector: `F2` now focuses the `html` property in the inpector if `label` is not present
- - tree: add `mod + f` to focus the search input
-
-
-
-## 1.27.5
-
-- bug fixes
- - patchbay: layout issue
- - widget: regression causing error when emptying the css property and leaving only class declarations
- - modal: incorrect position in scrolled containers when `relative` is `true`
- - menu: incorrect position in scrlled containers depending on menu's alignment
- - button: `locals.touchCoords` not updated upon release and incorrect when `doubleTap` is set
-
-## 1.27.4
-
-- bug fixes
- - fader: pips drawing issue causing small a position offset or errors with some browsers
- - script: setFocus not working with textarea widgets
-
-## 1.27.3
-
-- bug fixes
- - regression causing circular loop errors upon certain editions
- - fader: glitch with large `lineWidth` values in default design mode
-
-## 1.27.2
-
-- bug fixes
- - multixy: `default` not applied when points are named
- - clone: avoid some unnecessary property checks
- - clone: prevent missing editions in target properties (e.g. VAR{} renamed with the same return value)
-
-- client
- - show 3-dots menu in read-only mode with access to allowed items (e.g fullscreen)
- - hide console in read-only mode
-
-- widgets
- - matrix: don't implicitely override children's `label`, do it explicitely in `props`' default
-
-- custom module
- - `receive()` and `send()` now accept `host` and `port` to be provided as a single string argument joined by a colon
-
-## 1.27.1
-
-- bug fixes
- - server: `fullscreen` option not working when `read-only` is set
- - led and text widgets not client-syncing
- - patchbay: `address` not working properly when set to `auto`
- - patchbay: `ignoreDefaults` not working properly
- - editor: missing position indicator in color picker pad
- - file browser: fallback to home directory when last visited directory is not accessible
-
-- mobile
- - apply root's (or themes) background color the the browser's topbar when possible
-
-
-## 1.27.0
-
-- bug fixes
- - app address / qr code not updating when network changes
- - issue after theme auto reload (broken grid, colors not updated)
-
-- widgets
- - pads: expose css variable `--point-size`
-
-- custom module
- - provide error backtraces in module.exports functions
- - add `reload()` callback to provide finer control over the module's lifecycle
- - add `stop()` callback (runs when the server stops)
-
-- remote control
- - add /SESSION/CREATE command
-
-- client
- - file browser now remembers the last displayed directory
- - allow dismissing notifications by clicking on them
- - allow toggling notifications globally from main menu
- - add `notifications` client option
-
-## 1.26.2
-
-- bug fixes
- - user resources not loading when using an external browser
- - advanced syntaxes resolution order issue
-
-- advanced syntaxes
- - display an error in the console in some unsupported advanced syntaxes use cases
-
-## 1.26.1
-
-- bug fixes
- - mac: unable to show launcher windows when starting minimized
-
-## 1.26.0
-
-- bug fixes
- - scripting: `getProp()` now correctly returns a copy of the property if it is an object
- - prevent infinite loop when loading widgets with complex inter-dependencies
- - modal: layout issue on iOS 15+
-
-- widgets
- - dropdown: allow resubmitting the same value
- - switch: allow resubmitting the same value
- - plot: missing `logScaleX` and `logScaleY` properties
- - xy/multixy: add `axisLock` property; allow locking one the axis by holding `Shift` while dragging if `axisLock` is not set, bypasses it otherwise.
- - knob/fader/range: add `colorKnob` property
-
-- launcher
- - on Mac, start hidden if `Start minimized` is set
- - allow dropping files into file fields
-
-- custom module
- - expose `tcpServer` to allow monitoring the state of tcp connections
-
-## 1.25.7
-
-- bug fixes
- - rare issue that made the last widget(s) in a container disappear when other widgets in the same container had a specific property dependency pattern
-
-- remote control
- - `/EDIT*` commands sent by a custom module are not affected by the server's `read-only` option anymore
-
-- widgets
- - input: allow using a number in `numeric` to specify stepping value for mousewheel interaction
- - root: add `onPreload` scripting property
-
-## 1.25.6
-
-- bug fixes
- - sliders: error when `steps` is an array
-
-- scripting
- - `stateSet`: add optional `{send: false}` flag
-
-## 1.25.5
-
-- bug fixes
- - code editor: issue when middle clicking in the editor on linux
- - code editor: modern js operators such as `**` not recognized
- - sliders: prevent error when `steps` is not a number, add `auto` mode for using ranges values as steps (it did not work before)
- - pads, range: value not initialized as an array, causing errors in some cases
- - modal: popup not closing when `doubleTap` is true
-
-## 1.25.4
-
-- bug fixes
- - custom module: `receive()` not passing boolean arguments properly
- - fix `--authentication` on iOS clients
-
-- editor
- - display current widget value in the `value` property's help modal
-
-## 1.25.3
-
-- bug fixes
- - input: rendering issues with big font sizes
- - panel: tab rendering issue when initialized with a non-numeric value
- - panel: minor style issue in tab navigation bar
- - scripting: scripting functions not working inside `browseFile()` callback
- - scripting: using `external: true` in `set()` should prevent affected widget from sending any message
- - button: inconsistent value in `push` mode with `decoupled` enabled when setting value from script
-
-## 1.25.2
-
-- bug fixes
- - textarea: escape key not restoring previous value
- - scripting: `setFocus(id)` not affecting textarea widgets
- - led, text, variable: value not synchronized between different clients
- - error when running from sources on Mac
-
-## 1.25.1
-
-- bug fixes
- - regression in inter-widget sync mechanism
- - regression breaking `set()` function in scripts
- - textarea: display nothing instead of "null" when receing no value, null or an empty string
-
-## 1.25.0
-
-- bug fixes
- - multixy: doubleTap not working on touch devices
- - button: `x` and `y` variables not passed to `onValue` when `doubleTap` is true on touch devices
- - advanced syntax: update issue with clones using their own value in their properties
- - client: minor keyboard shortcut issues
- - panel: mitigate client synchronization issue with scrollbars
-
-- widgets
- - menu: add a background to menu items to help distinguish them
- - menu: merge different interaction modes into a single `mode` property
- - menu: add `swipe` mode
-
-- remote control
- - `/STATE/SET`: add optional argument to prevent widgets from sending their value
-
-## 1.24.2
-
-- bug fixes
- - editor: regression breaking widget context menu actions under "Position" submenu
- - touch devices: touchend event not fired on elements removed/detached during touchstart/touchmove callbacks (caused issues when switching tabs using a button inside a tab)
-
-
-## 1.24.1
-
-- bug fixes
- - launcher: `Ctrl+M` keyboard shortcut not working
- - widgets: regression incurring a small delay before resolving a property that depends on a widget's own value
- - server: `--client-size` and `--client-position` options not parsed correctly
-
-- advanced syntaxes
- - support `@{}` inside `IMPORT{}`
-
-## 1.24.0
-
-- bug fixes
- - widgets: circular value feedback issues
- - editor: `ctrl + e` not working when hit multiple times without releasing `ctrl`
- - mobile: "prevent sleep" feature not working
-
-- widgets
- - patchbay: add `in`, `out` and `both` modes to `exclusive` property
- - panel: replace `verticalTabs` property with `tabsPosition` (supports 4 directions)
-
-- custom module
- - add optional `errorCallback` argument to`loadJSON` and `saveJSON`
-
-- server
- - print multiple qrcodes if multiple network interfaces are available and prevent printing a qrcode for the localhost address
-
-- misc
- - add linux rpm packages
-
-## 1.23.0
-
-- bug fixes
- - linkId not working between two encoder widgets
- - fader: `gradient` breakpoints not positioned correctly
- - canvas: `onDraw()` called twice when calling `updateCanvas()`
-
-- midi
- - optional rpn/nrpn parsing as single messages
-
-- widgets
- - keyboard: incoming values different than the `off` property are now interpreted as `on`
-
-- editor
- - when focusing the label property with `F2`, select all text in the text area
- - preserve scroll position in code editor when validating
- - display the id of selected widget in the inspector's header
-
-- scripting
- - expose file browser (from the file widget) as a scripting function
-
-- custom module
- - don't restrict file extension in `loadJSON()` and `saveJSON` functions
-
-- misc
- - add polish locales (@ Manz4rk)
- - add css classes to some notification popups to allow targetting them with css themes
-
-## 1.22.0
-
-- bug fixes
- - keyboard widget: `linkId` not working (unable to link 2 keyboard widgets)
- - slides: issues with ranges containing decimal keys
-
-- launcher
- - add menu options to show the qr code again
- - mac: change "List MIDI devices" keyboard shortcut to `Ctrl+m`
-
-- widgets
- - image: add support for special value "qrcode"
-
-- misc
- - add german locales (@ Magnus Reichel)
- - package file names changed to follow debian's convention
- - add a cli option to disable the qr code (`--no-qrcode`)
-
-## 1.21.0
-
-- bug fixes
- - custom module: fix autoreload on nested submodules
-
-- launcher
- - print a qrcode when the server starts to help connecting mobile devices
-
-- editor
- - horizontal scrolling issues with maximized code editor
-
-- widgets
- - switch/menu/dropdown: add a syntax that supports duplicate labels in `values` property
-
-- custom module
- - expose `global` object that persists accross module reloads.
-
-- scripting
- - onCreate: expose `value`
-
-## 1.20.0
-
-- bug fixes
- - scripting: prevent some functions to be marked as undefined
- - advanced syntaxes: ignores quotes around file path in `IMPORT{}`
-
-- launcher
- - add `Start minimized` menu option
-
-- misc
- - change noFocus client option behavior: the default client window now doesn't take the focus at all, even when a text input is clicked.
- - colorize debug messages for sent and received osc/midi messages
-
-- scripting
- - add `setFocusable()` function to change the focusability of the window on the fly (allows reenabling focus temporarily to interact with a text widget using a dedicated toggle button for example)
- - add `reload()` function
- - expose Navigator object with `getNavigator()`
-
-- widgets
- - fragment: add `fallback` property
-
-## 1.19.2
-
-- bug fixes
- - regression breaking touch move events on desktop touchscreens
-
-## 1.19.1
-
-- bug fixes
- - editor zoom: adjust root widget size when zooming out
-
-## 1.19.0
-
-- editor
- - add keyboard shortcut "h" to hide selection and widget drag / resize handles while pressed
- - inspector: add some shortcut buttons in the header
-
-- widgets
- - add folder widget (flat container that doesn't affect layout)
- - input: add `maxLength` property
- - multixy: allow setting its own value from onValue script while touched
-
+ - pasted widget properly use the pointer's position
+ - traversing gestures are effective from the first touch, not after the first move
+ - out-of-range values are properly clipped by faders/knob
- ui
- - add a virtual onscreen keyboard for desktop clients (can be enabled from the clients main menu)
- - change local zoom (alt+scroll) behavior so that it only affect widgets and add scrollbars to navigate while zooming instead of following the mouse
-
-- server
- - client-options: add `virtualKeyboard` option to enable virtual keyboard by default (desktop clients only)
-
-## 1.18.3
-
-- bug fixes
- - button: regression in push mode (`on` value not passed to `onValue` script when triggered from another widget)
- - button: decoupled push mode returning wrong value when activated from a widget script
-
-## 1.18.2
-
-- bug fixes
- - canvas: `onTouch` not triggered on iOS when when `event.force`, `event.altitudeAngle` or `event.azimuthAngle` changes
- - switch: interaction issue when value labels contain icons
- - ios: attempt to fix rendering glitch when waking up after sleep
-
-## 1.18.1
-
-- widgets
- - button: add `decoupled` property, compatible with all button modes
- - button: remove `decoupled` mode
-
-## 1.18.0
-
-- bug fixes
- - client script source map not loading (helps providing useful error messages)
-
-- widgets
- - button: add `decoupled` mode (toggle mode that only updates its state when it receives a value from osc/midi messages)
- - button: add client option `altTraversing` to allow one-way response to traversing gestures for toggle buttons
- - canvas: iOS: trigger `onTouch` when `event.force`, `event.altitudeAngle` or `event.azimuthAngle` updates
- - knob: add `snap-alt` mode (snap mode that allows jumping between range.min and range.max)
- - all: add `borderRadius` property
-
-- scripting
- - add `updateCanvas()` function (forces a canvas widget to redraw)
-
-- remote control
- - `/NOTIFY`: if multiple arguments are provided, interpret the first one as the icon's name for the client notification
-
-- midi
- - on Mac, name virtual ports after the device name to avoid confusion
-
-- server
- - client-options: add `clientSync` option to allow disabling client synchronization
- - client-options: add `altTraversing` option
-
-- editor
- - add `F2` keyboard shortcut to bring label property input into view if selected widget has one
-
-## 1.17.0
-
-- bug fixes
- - editor: error when ctrl+clicking on a root's child
- - range: multitouch interaction issue
-
-- widget
- - knob / encoder: `sensitivity` and ctrl+drag gesture preserve `circular` mode behavior
- - knob / encoder: `snap` mode now works like `circular` mode except for the touch start event (value can't jump from start to end anymore)
- - patchbay: add `exclusive` option
-
-- editor
- - allow interacting with a widget without selecting it by using the middle mouse button or by holding shift+win (shift+cmd on mac).
-
-## 1.16.6
-
-- bug fixes
- - visibility property update issues
-
-## 1.16.4
-
-- bug fixes
- - modal: display issue when a modal receives the same value multiple times
- - patchbay: `outputs` property not handling object value properly
- - server: resolution conflict between app files and user files
-
-- widgets
- - patchbay: trigger `onValue` script when a connection changes
-
+ - Faders & Meters design improved
+ - The main font (droid sans) is now loaded...
+ - Knob's sizing got smarter
+ - Widgets don't blink not jump when they appear for the first time or when they resize
- misc
- - windows: allow accessing other drives than the default one (list drives when the file browser reaches the filesystem's root)
+ - Fader's `align` option replaced with boolean option `alignRight`
+ - Widget's `label` now accepts special directive `icon: fontawesome-class` to display icons from [FontAwesome](http://fontawesome.io/icons/)
+ - Text widget `defaultText` option added
+- engine
+ - electron 1.2.2
-## 1.16.3
+## 0.5.4
- bug fixes
- - custom module: submodules not loading their own submodules with relative paths properly
- - custom module: issue with circular submodule requires
- - server: harmless error message when importing css files from the main theme file
- - server: allow using folder names "client" and "assets" for user files (eg for images used in a session)
-
-- widgets
- - canvas: add `onResize` script property
- - scripting: expose javascript's `Image` constructor
-
-## 1.16.2
-
-- bug fixes
- - widget visibility not updated properly when set as a non-boolean value
-
-- widgets
- - tabs: detach hidden tabs from the DOM (reduces lag caused by heavy tabs)
-
-## 1.16.1
-
-- bug fixes
- - eq widgets not properly converted when importing v0 sessions
- - image paths with url queries not loaded properly
- - @{} syntax not returning truncated value according to the widget's precision property (fixed for primitive values only, object values are still returned as is)
-
-## 1.16.0
-
-- advanced syntaxes
- - `@{}` and `VAR{}` that return objects / arrays do not return a copy of their value anymore as it may introduce a significant overhead when used extensively. Mutating these objects in `#{}` and `JS{}` scripts will now affect the actual values and should be avoided at all cost.
-- widgets
- - `comments` property flagged as dynamic
- - multixy: add `doubleTap` property
-
-## 1.15.8
-
-- bug fixes
- - range: value update issue (internal touch state not updated properly)
- - scripting: send(): ignore `ignoreDefaults` property
- - script: onKeyboard script not cleaned upon edition / removal
- - editor: some variables not appearing as defined in `onKeyboard`
-
-## 1.15.7
-
-- bug fixes
- - matrix: property resolution issue with object/array items in `props`
- - bypass client option `nofocus=1` when the editor is enabled
- - menu/dropdown: display label when value is undefined
-
-- misc
- - updated midi bridge: provide more information when loading fails; may fix some compatibility issue on windows
-
-## 1.15.6
-
-- bug fixes
- - ios: prevent server error related to the use of cookies
- - scripting: `getVar()` now returns a copy of the variable to prevent mutations on saved object
-
-## 1.15.5
-
-- bug fixes
- - matrix: advanced property issue in `props` property (bis)
-
-- editor
- - inspector: add solo mode with `alt+click` for category panels
-
-## 1.15.4
-
-- bug fixes
- - matrix: advanced property issue in `props` property
-
-## 1.15.3
-
-- bug fixes
- - interaction issue ("deadzone") on touch screens
- - main menu not hidden when `read-only` is set
- - osc messages containing unicode characters not encoded correctly
-
-## 1.15.2
-
-- bug fixes
- - modal: scroll state not restored when the modal container is recreated
- - server: allow spaces and accentuated characters in client id
-
-## 1.15.1
-
-- bug fixes
- - prevent flickering on canvas based widgets when they are recreated
-
-- editor
- - added code editor for `html` and `css` properties
-
-- remote control
- - add `/RELOAD` command
-
-## 1.15.0
-
-- bug fixes
- - editor: prevent accessing non-editable widgets with right arrow
- - multixy: regression causing interaction issue
-
-- widgets
- - add `lock` property to all widgets
-
-- launcher
- - add `Autostart` menu option
-
-- misc
- - update FontAwesome icon font to version 6
-
-## 1.14.6
-
-- bug fixes
- - inspector: script editor: cursor alignment issue in indented lines
- - clone: prevent freeze and print an error when attempting to create a circular clone
- - modal: regression on android that prevents focusing input widgets in modals
-
-## 1.14.5
-
-- bug fixes
- - session loading error with some malformed property cases
-
-## 1.14.4
-
-- bug fixes
- - broken console interpreter since v1.14.0
-
-- widgets
- - button: add `momentary` mode for sending messages with no value; prevent button from getting stuck when `on` and `off` are equal in `momentary` and `tap` modes
-
-- inspector
- - color picker: inline picker widget (no longer in a modal); show color changes on the fly
- - code editor: validate input with `cmd+enter` instead of `ctrl+enter` on Mac
-
-- scripting
- - `screen.height` and `screen.width` always returns the current screen dimensions
- - added `screen.orientation` global variable
-
-- misc
- - some performance improvements
-
-## 1.14.3
-
-- bug fixes
- - osc receivers (`OSC{}` syntax) now apply the same rule as widgets regarding midi messages (only receive if the message's origin matches one of the host widget's midi targets)
- - modal: rendering issue on iOS
- - button: `locals.touchCoords` not updated since v1.14.0
-
-- widgets
- - clone/fragment: remove scripting properties as they are supposed to be overridden in `props`
-
-## 1.14.2
-
-- bug fixes
- - context-menu: double click issue in submenus on small touch screens
- - clone/fragment: broken onDraw / onTouch scripts if cloned widget is a canvas
-
-## 1.14.0, 1.14.1
-
-- bug fixes
- - misc: sending typed arguments (`{type, value}` objects) should override the widget's `typeTags` definition
- - multixy: errors when `ephemeral` is `true`
- - scripting: `setVar` not affecting all widgets when multiple widgets match provided id
-
-- widgets
- - renamed `script` property to `onValue`, `draw` to `onDraw`, `touch` to `onTouch`
- - added `onCreate` script property to all widgets
- - added `onTouch` script to widgets that supported the touch state variable in scripts (now deprecated)
- - script: added `onKeyboard` property, removed `event` property
- - canvas: expose additional touch event informations (`radiusX`, `radiusY`, `rotationAngle` and iOS-only `altitudeAngle`, `azimuthAngle` and `touchType`)
-
-- scripting
- - special keyword `this` now returns the string `"this"`
-
-- advanced syntaxes
- - added `IMPORT{file}` syntax to allow loading external files in properties
-
-- editor
- - add fullscreen mode for properties with code editor enabled
-
-## 1.13.2
-
-- bug fixes
- - editor: keep relative sizes and positions when resizing multiple widgets at a time
-
-- widgets
- - canvas: expose touch pressure (as `event.force`) in the `touch` script.
- - canvas: expose touch events for extra elements added with the `html` property
-
-## 1.13.1
-
-- bug fixes
- - editor: data loss when leaving the editor's focus with no modifications
-
-## 1.13.0
-
-- bug fixes
- - scripting: `storage.getItem()` not returning anything
-
-- editor
- - new code editor for `script`, `touch`, `draw` and `props` properties with syntax highlighting, line numbers, etc
-
-- scripting
- - `set()`: add an option to prevent target widget's script
-
-- widgets
- - root: add `hideMenu` property
-
-- misc
- - minor cosmetic changes
-
-## 1.12.0
-
-- widgets
- - new **canvas** widget (under `pads`): allows creating custom widgets
- - button: expose normalized touch coordinates in scripts as `locals.touchCoords`
- - print a warning in the console when using advanced syntaxes in the script property
-
-## 1.11.1
-
-- bug fixes
- - client options specified in server config not working unless lowercased
- - make disconnection detection less aggressive (don't display notification if reconnection succeeds quickly)
- - panel: initial scroll state issue
-
-## 1.11.0
-
-- bug fixes
- - menu: interaction issue on iOS
- - script: prevent script functions from being called in the wrong scope (ie when leaked using the `globals` object) and print an explicit error
- - containers: prevent errors with some color formats in colorWidget
- - theme: relative url not resolved correctly
-
-- widgets
- - when a panel contains widgets and has `scroll` set to `true`, its value will be used to represent the scroll position for x-axis and y-axis between 0 and 1.
-
-## 1.10.3
-
-- bug fixes
- - config not persistent on windows
-
-- misc
- - read-only mode now hides and disables the main menu
-
-## 1.10.2
-
-- bug fixes
- - certificate expiration issue
- - regression breaking colors in canvas-based widgets
-
-## 1.10.0
-
-- bug fixes
- - sliders: ignore key order in `range`
- - sliders: handle mousewheel increment when starting from a value between two steps with `steps` property defined
- - inspector: allow scrolling in the help modal
- - console: fix command history behavior and increase history size
-
-- widgets
- - encoder: expose angle in script (as `locals.angle`)
- - new textarea widget (multi line input)
- - expose the computed dimensions of canvas-based widgets in `css` (as `--widget-width` and `--widget-height`) and `script` (as `locals.width` and `locals.height`)
-
-- client
- - add `Save backup` menu action (saves a backup copy of current session with an incremented suffix appended to the file name)
-
-## 1.9.14
-
-- bug fixes
- - modal: remove `html` property
- - matrix: nested property inheritance (eg. `@{id_@{id_x}}`) not working in `props`
-
-## 1.9.13
-
-- bug fixes
- - nested property inheritance (eg. `@{id_@{id_x}}`) not updating properly
- - canvas based widgets not updating when hidden
-
-## 1.9.12
-
-- bug fixes
- - client options: options ignored if not lowercased
- - sliders: prevent errors for some edge-case `range` values
-
-## 1.9.11
-
-- bug fixes
- - range: value not properly updated with set()
-
-- misc
- - (built-in client only) add `nofocus` client option to prevent the client window from taking focus unless a text input or a dropdown is clicked.
-
-
-## 1.9.10
-
-- bug fixes
- - matrix: regression from 1.9.8 (broken nested @{} syntax in props property)
-
-- misc
- - midi: detect missing binary (eg when deleted by antivirus) and print a message
-
-## 1.9.9
-
-- bug fixes
- - matrix: regression from 1.9.8
-
-## 1.9.8
-
-- bug fixes
- - matrix: update children when `props` is modified even when the result for `$ = 0` doesn't change
- - fragments: fragment widgets empty when reloading
- - panel: scrollbar issue on iOS 13+
-
-- scripting
- - expose `console.clear()`
-
-## 1.9.7
-
-- bug fixes
- - issue when resizing widget using keyboard shortcuts
- - advanced syntaxes (VAR{}): avoid storing default value as string if it can be parsed as a javascript primitive (boolean, number, etc)
- - advanced syntaxes (VAR{}): ignore quotes around variable name
-
-- editor
- - change keyboard shortcuts for moving widgets (now `mod + arrows`) and navigating in widgets (now `arrows`) to feel more natural with the project tree view.
-
-- widgets
- - script: bypass keyboard shortcuts already used by the editor if it is enabled
- - matrix: removed ambiguous `start` property
- - matrix: advanced syntax blocks can be passed to children without being resolved at the matrix\' scope by adding an underscore before the opening bracket
- - text: add `soft` mode for the `wrap` property
- - input: improve `numeric` mode on iOS
-
-## 1.9.6
-
-- bug fixes
- - advanced syntaxes: `VAR{}` not updating when the default value is edited
- - editor: fix "Bring to front" and "Send to back" context menu actions
-
+ - [desktop] menu bar auto-hide
+ - [headless] multitouch support
- ui
- - add keyboard shortcuts `mod + "+"` and `mod + "-"` to control zoom level
+ - [mobile] better faders pips rendering
+ - fixed horizontal fader knob centering
+ - [mobile] better numeric inputs rendering (not blurred anymore)
+- engine
+ - [desktop] electron 1.2.0 (chrome 51)
-- widgets
- - input: add `numeric` property (allows numeric values only and displays numeric keyboard on mobile devices)
- - button: add `soft` mode for the `wrap` property
- - switch: add `wrap` property
-
-- editor
- - display dropdown and checkbox for boolean properties with extra choices
-
-## 1.9.5
+## 0.5.3
- bug fixes
- - advanced syntaxes: various issues and regressions
- - editor: preserve advanced syntaxes in `left` and `top` when pasting a widget
-
-- editor
- - tree: update widget visibility when it changes dynamically
-
-## 1.9.4
-
-- bug fixes
- - prevent error with empty `OSC{}` blocks
- - regression breaking advanced syntax blocks containing nested brackets
-
-- advanced syntaxes
- - new syntax for creating and using custom variables in properties: `VAR{name, default}`
- - `JS{}` blocks don't require 2 brackets anymore (`JS\{\{}}` still works)
-
-- scripting
- - add `getVar()` and `setVar()` for reading and modifying custom variables. This allows modifying properties directly from scripts (if they contain `VAR{}` blocks).
- - expose session path as `globals.session`
-
-- editor
- - make tree item blink when hitting "Show in tree"
-
-- remote control
- - add `/SCRIPT` command to run scripts remotely
-
-## 1.9.3
-
-- bug fixes
- - scripting: set() not working from a slider to a pad
- - tabs not sending messages / triggering scripts when clicked in editing mode
- - prevent hang with some syntax errors in advanced syntaxes
- - don't show project tree if minimized when creating a new widget (1.9.2 regression)
- - fix "ID + 1" paste for widgets with numeric ids
- - dropdown: reset the underlying dropdown when the widget's value is undefined
-
-- editor
- - tree: allow specifying multiple type filters
- - tree: add "Show in session" context menu action
-
-## 1.9.2
-
-- bug fixes
- - visualizer: remove `bars` and `dots` option
- - plot: fix `bars` option
- - project tree: clear filter input when loading a session
- - server: fix serving files from paths containing accents
- - editor: keep editor open when loading a session
- - menu: prevent clipping in container on iOS
-
-- widgets
- - image: add pre defined values for `size`, `position` and `repeat` properties
- - text: add vertical alignment choices to `align`
-
-- editor
- - tree: add icons before widget ids depending on the category
- - tree: activate tab when selecting it in the project tree
- - tree: allow dragging widgets from a container to another
- - tree: expand container when a new widget is created inside it
- - tree: add support for filtering widgets by type (by typing `type:fader` for example)
- - smarter shift+drag selection: allow selecting widgets in the area when the event started on the parent container
- - select newly created widgets/tab except when copy-pasting
-
-- remote control
- - add `/STATE/SEND` command
-
-## 1.9.1
-
-- bug fixes
- - button: allow writing strings like `"1.0"` in `label` without removing the decimals
- - editor: use css variable `--grid-width` at startup and after disabling & enabling the grid
- - launcher: regression preventing server halt when built-in client is closed manually beforehand
- - scripting: prevent crash (built-in client only) when using the variable `navigator`
-
-- widgets
- - menu/switch/dropdown: reset value to `undefined` when receiving a value that's not defined in `values`
-
-- scripting
- - expose instance of navigator [Clipboard](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard) as `globals.clipboard`
-
-- midi
- - allow sending note off with velocity
- - add option for receiving note off with velocity
-
+ - [again] touch fake-right-click only fires on long touch, not after every tap
+ - traversing gestures bug with touch
- misc
- - v0->v1 session conversion: remove `JS\{\{}}` in script property
+ - better mouse/touch drag events handlers
+- engine
+ - electron 1.1.1
-## 1.9.0
-
-**Warning** Sessions saved with this version will not open in older versions (sessions saved with older version will open in this version).
+## 0.5.2
- bug fixes
- - remote-root option not applied on resources loaded by the client app (css images, etc)
- - input: display issue when resizing the window
- - launcher: cancel stopping the server when there are unsaved changes in the built-in client
+ - touch fake-right-click only fires on long touch, not after every tap
-- editor
- - context menu: add `export` action to export a widget as a fragment file
- - show project tree if minimized when clicking on "Show in tree"
-
-- widget
- - **new** `fragment` widgets (under `containers`): embedded session or fragment file with overridable properties.
- - add `comments` property to all widgets
-
-- launcher
- - add `Always on top` menu toggle
-
-## 1.8.15
+## 0.5.1
- bug fixes
- - editor: error when duplicating widget while if the clipboard is empty
- - ui: local zoom move issue when not in fullscreen
- - custom module: `clearInterval()` not working
- - regression breaking style attribute in html property
+ - feedback is now handled precisely by widets (ie not rounded according to the `precision` option, see issue #21)
+- engine
+ - electron 1.1.0
+## 0.5.0
+
+- bug fixes
+ - touch/mouse events are both handled simultaneously, module rewritten for better performances (see issue #18)
+- engine
+ - electron 1.0.2
+
+
+## 0.4.8
+
+- bug fixes
+ - regression preventing newly created widgets from using the pointer's coordinates as position
+ - add 0.4.7's fix to headless mode
+
+## 0.4.7
+
+- bug fixes
+ - regression causing widgets with `preArgs` to not receive osc correctly
+
+## 0.4.6
+
+- engine
+ - electron 0.37.6
+ - node-osc 2.0.3
+- features
+ - `compact` option added to knob and fader
+ - if an osc input port is specified, osc messages will be sent from it. This enhances compatibility with apps that send their feedback messages directly to the sender.
- misc
- - faster local zoom
+ - mouse/touch dragging handler rewritten, now using event delegation and direct handler calls instead of DOM event bubbling whenever it's possible
-## 1.8.14
-
-- bug fixes
- - `alt+shift+c` not working when pressed before dragging
- - incremental pasting issue with address property
- - generate scrollbars for panels on iOS 13+
- - fix scrolling on chrome for iOS 13+
-
-- editor
- - add `mod+d` and `mod+shift+d` for duplicating widgets
- - use a temporary clipboard when duplicating widgets
-
-- misc
- - inspector: move `script` property to `scripting` category
- - ui: minor style tweaks
-
-
-## 1.8.13
-
-- widgets
- - file: show save icon when mode is set to save
- - file: center icon when hidePath is set to true
- - sliders/pads: apply `spring` property dynamically
+## 0.4.5
+- engine
+ - electron 0.37.3
- ui
- - add `alt`+`wheel` for local zoom centered on cursor
-
-- editor
- - add `alt+c+drag` and `alt+shift+c+drag` for duplicating dragged widgets
-
-## 1.8.12
-
-- bug fixes:
- - project tree: filter input position issue when scrolling
- - sliders/pads: apply `spring` property dynamically
-
-- project tree
- - select range of contiguous widgets with shift + click
-
+ - new logo
+ - better lobby design
- misc
- - plot: remove unused `filters` property; fix description for `rangeX` and `rangeY`
- - console: focus input when the console opens
+ - renamed sliders/pads' `absolute` property to `snap`
-## 1.8.11
+## 0.4.4
- bug fixes
- - switch: widget not reacting at first touch when traversing is enabled on parent
- - sliders: disable mousewheel when `spring` is enabled
-
-- widgets
- - script: add `once` event mode
- - encoder: remove `spring` property
-
-- custom module
- - expose `process` global
-
-- scripting
- - add `openUrl` function
-
-## 1.8.10
-
-- bug fixes
- - modal: issues with children's visibility
- - console: allow multiple arguments in console.log()
-
+ - [headless] scripts are no longer bundled on the fly, it didn't work on some systems
+ - touching widgets without changing their value doesn't make them send the same value again anymore
- ui
- - launcher: add many keyboard shortcuts
- - client: add keyboard shortcuts for clearing the console
-
-- scripting
- - add `setFocus` function to focus an input widget programmatically
-
+ - slightly tightened layout
+- features
+ - `noPip` option added to knob and fader
+ - `preArgs` accepts object if the arg's type needs to be specified
+ - knob supports breakpoints scale, same as fader's
+ - fader and knob pip scales now support custom label
+ - a push/toggle's value can be set to `null` if only the path needs to be sent in the osc messages
+ - push buttons do not update their own leds and return their value (for state save and widgets sync) based on their last changed property (led state or touch on/off)
- misc
- - add `usePercents` client option
+ - refining the fader's pip scale that looked choppy on mobile devices. All pips are now evenly spaced, not relatively to the fader's height.
+ - [desktop mode] saved sessions are added to history
-## 1.8.9
+## 0.4.3
+- features
+ - text widget can be `vertical`
+ - panel widget `scroll` option
- bug fixes
- - script: issue when using the `options` argument in `set()` (options leaked to subsequent set() calls in the script)
- - multixy: `decimals` property not applied
- - multixy: spring behavior not working until all points are released
- - custom module: prevent require() from reading submodules files each time and instead return the object in memory
+ - smart pasting now works when the clipboard contains several widgets whose unsuffixed ids are the identical
+ - osc received array that contain only one item are correctly unpacked (fixes cross-app sync for widgets that don't accept array, broken since the introduction of `preArgs`)
+ - memory leak when loading a new session (cached tabs were not properly purged)
+- misc
+ - push widget doesn't fire its 'on' value if pressed while stuck in 'on' position
+ - panel widgets don't have inner margins anymore
+ - fader widget optimization : the pip scale is generated from a single gradient plus some elements for each breakpoint (instead of one element per percent), thus reducing the number of elements to draw.
-## 1.8.8
-
-- launcher
- - add file browser button for the `theme` option and fix parsing path containing spaces if only one theme is set
-
-- windows
- - remove `ctrl+w` shortcut for closing a window (use `alt+f4` instead)
-
-
-## 1.8.7
-
-- midi
- - add active sensing messages support (received as sysex)
-
-- remote control
- - restore `/TABS` command (for opening tabs by ids)
-
-- widgets
- - encoder: expose rotation speed in script (as `locals.speed`)
-
-## 1.8.6
+## 0.4.2
+- features
+ - new widget : text (just displays received values)
- bug fixes
- - range: per-fader touch event not emitted properly
- - rgb: fix `spring` property
- - rgb: touch event not emitted
+ - widget linking doesn't cause multiple unwanted osc sends anymore
-## 1.8.5
+## 0.4.1
-- bug fixes
- - midi: debug messages displayed as errors
- - launcher: broken context menu
+- features
+ - `preArgs` option for widgets (prepends constants to osc messages args)
-## 1.8.4
-
-- bug fixes
- - input: prevent focus when selecting the widget for edition
- - input: submit content when leaving focus, not only when hitting `enter` or `tab` (`esc` still cancels)
- - midi: prevent midi bridge from stopping when an error occurs; provide meaningful errors when connection fails
-
-- editor
- - inspector: hitting ctrl+s while editing a property will submit the change before saving
+## 0.4.0
+- engine
+ - electron 0.37.2 (chrome 49)
- ui
- - hide the console toggle button when the bottom panel is minimized and the editor is disabled
-
-- widgets
- - file: add `mode` property, for choosing between `open` and `save` modes
- - switch: add `flip` mode
-
-## 1.8.3
-
-- bug fixes
- - keyboard: allow note numbers up to 127
- - server: return http 404 error when a user-requested resource is not found instead of keeping a pending request
- - modal: `visible` property not applied correctly
-
-
-- project tree
- - add an input for filtering displayed widget by id
-
-## 1.8.2
-
-- bug fixes
- - menu: allow manual line breaks ("`\n`") in labels / values
- - custom module: parsing issue when sending widget data using `receive()` (`type` attribute erroneously parsed as an osc typetag)
-
-- widgets
- - html property: allow "href" attribute on "a" elements
-
-
-## 1.8.1
-
-- bug fixes
- - script: stops triggering osc messages under some circumstances
-
-## 1.8.0
-
-- bug fixes
- - project tree: layout issue with deeply nested widgets
- - ios 10.3 regression
- - file browser: layout issue with long paths
-
-- custom module
- - add `nativeRequire` function (allows loading native node modules or locally installed modules)
-
-## 1.7.8
-
-- bug fixes
- - canvas-based widgets not drawn when placed in a modal while having a conditional visibility set
- - text: missing `decimals` property
- - clone: fix usage of osc listener syntax (acts as if clone has an `address` property set to `auto`)
-
-- widgets
- - clone: make `props` property dynamic (avoid full widget rebuild when possible)
-
+ - new flat ui
+ - tab system rewritten : inactive tabs are detached from the DOM tree, thus improving performances while slowing down tab switching.
+ - widget categories in editor's context menu
+- features
+ - logarithmic scaling (log10) support added to knob, fader & xy
+ - mousewheel support added to knob and fader (ctrlKey for fine control)
+ - new widgets : plot, visualizer & meter. Fader built-in feedback meter option
+ - traversing gestures switch in sidepanel
+ - custom color property for all widgets with inheritance (containers)
+ - editor pasting function now smartly increments widget's id and path while keeping label if different from default
+ - true theming support
- misc
- - increase client console history size and allow changing it with client url options
+ - sync/link event handling improved
+ - stylesheets cannot be recompiled on the fly anymore (`--c` switch removed)
+ - **new state save file format, no backward compatibility**
-## 1.7.7
+## 0.3.1
-- bug fixes
- - startup regression
+- electron updated to 0.36.11
+- editor paste menu lets you choose between `Same ID` (cloned widgets) or `New ID` (resets id, label, linkId, and path)
+- minor style updates
-## 1.7.6
+## 0.3.0
-- bug fixes
- - (harmless) error raised when starting the server from the launcher with `debug` set to `true`
+- 3 new widgets
+ - multifader
+ - multitoggle
+ - multipush
-- editor
- - display/save color picked values with css rgba notation instead of hexadecimal
-- widgets
- - modal: add `ignoreTabs` option (allows overflowing tab ancestors)
- - menu: add `ignoreTabs` option
+## 0.2.1
-## 1.7.5
+- style update (push/toggle widgets, widgets' dragging handle)
+- widget dragging/resizing doesn't get broken when editing the root
+- sidepanel toggle doesn't select root for edition anymore
-- bug fixes
- - ios: cloned menu not displayed correctly
- - engine: downgrade to fix startup issue on windows
+## 0.2.0
-## 1.7.4
-
-- bug fixes
- - editor: cloned `dropdown` and `input` widgets not opening when selected
- - widgets: prevent value-stateless widgets (tap buttons, clone, scripts, html and svg) from sending a value for cross-client synchronization (leads to unexpected script execution) and exclude them from state saves
- - input: apply `decimals` number before checking the value against the `validation` expression
- - range: `steps` and `dashed` property not working; remove `origin` property
- - config conflicts between launcher and server (affecting at least session history)
-
-## 1.7.3
-
-- bug fixes
- - custom module / theme: prevent reloading the module while the file is being written to
- - server: if a theme is used, attempt to resolve image urls against the theme file's location
- - modal/button: prevent error when `label` is updated
-
-- widgets
- - encoder: add `ticks` property back
-
-## 1.7.2
-
-- bug fixes
- - midi: mtc parsing error
- - custom module: hot reload cache issue on windows
-
-
-## 1.7.1
-
-- bug fixes
- - regression causing server errors
-
-## 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
- - editor: missing context menu (copy, paste) in inspector inputs
- - widgets: osc listeners not resolving "auto" address
- - cli: `ELECTRON_RUN_AS_NODE` headless mode not working without `--no-gui` option
- - ios: clone widget not laid out properly in horizontal panels
- - ui: missing vertical scrollbar when root's height overflows the workspace
- - server: provide readable error when a file requested by the client file is not found
- - tab: content not drawn when changing visible property
- - matrix: addresses not generated property when matrix' address is `auto`
-
-- 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 value must match)
- - modal: add `relative` position property
-
-- midi
- - accept sending sysex strings without spaces between the bytes
- - load prebuilt midi binary on 64bit linux/windows/osx
- - add support for midi time code messages
-
-- misc
- - sessions converted from v0 will use the widget's html property to display the former label property
-
-## 1.6.2
-
-- bug fixes
- - matrix: issues when changing non-dynamic properties (content not properly removed)
- - input: apply default value when receiving an empty value or no value at all
-
-## 1.6.1
-
-- bug fixes
- - keyboard: prevent `script` property from being copied to each key
-
-- widgets
- - keyboard: make `on` and `off` properties dynamic
- - script: add `getIndex` function
- - matrix/keyboard: `id` variable in script is now the `id` of the child widget that triggered the event
-
-## 1.6.0
-
-- bug fixes
- - range: error when setting `default` property
- - range: fix `doubleTap` property
-
-- widgets
- - all: add `html` property to allow inserting custom content in widgets (label, value, etc) and style it with the `css` property.
-
-- scripting:
- - `send()`: ignore the widget's `bypass` property (allows bypassing default messages and define custom ones)
- - `set()`: add supports for wildcards in the id parameter
- - `set()`: add a 3rd optional parameter for preventing further script executions and/or osc messages from being sent
-
-- custom module
- - automatically reload custom module when the file is modified
- - add support for loading submodules with `require()`
-
-- theme
- - automatically reload theme when the file is modified
-
-## 1.5.4
-
-- bug fixes
- - ssl: generate unique certificates (with random serial numbers) to avoid reuse errors. Certificates generated with older versions of o-s-c will be updated automatically.
- - `~/` path prefix not recognized when using remote control commands like `/SESSION/SAVE`
- - `~/` path prefix not recognized in `remote-root` option
- - editor: paste ID+1: midi-related addresses should not be incremented
-
-- remote control
- - add `/STATE/OPEN` and `/STATE/SAVE` commands
- - ignore unsaved changes when loading a session with `/SESSION/OPEN`
- - resolve relative file paths against `remote-root` setting
-
-## 1.5.3
-
-- bug fixes
- - editor: error when `preArgs` and `address` are modified at the same time (affects `/EDIT` command and matrix/clone widgets)
-
-## 1.5.2
-
-- bug fixes
- - launcher: midi device names containing multiple spaces not parsed correctly
- - fullscreen: lack of support not detected on some ios devices
- - multixy: labels not hidden when `ephemeral` is `true`
-
-- remote control
- - add `/SESSION/OPEN` and `/SESSION/SAVE` commands
-
-## 1.5.1
-
-- bug fixes
- - widgets: touch state scripts not triggering some synchronization mechanism
-
-- widgets
- - encoder: remove `steps`, `ticks` and `origin` properties
- - encoder: make `sensitivity` work with values below 1
-
-## 1.5.0
-
-- bug fixes
- - image: broken value validation
- - menu/dropdown: use correct z-index
- - dropdown: prevent dropdown from opening when selecting the widget for edition
-
-- editor
- - holding `alt` extends the north-west handle to the widget's size to ease dragging
- - widget properties reordered (e.g. style-related properties, even widget-specific, are now under the "style" category)
-
-- widgets
- - remove `colorBg` for all widgets except containers
- - widgets background color is now transparent by default (can be overridden with css)
- - keyboard: added `colorBlack` and `colorWhite` properties to customize key colors
- - dropdown/menu: add `label` property (with support easy key/value display)
- - dropdown/menu: add `icon` toggle property
- - modal: add `popupPadding` property to control the button's and the container's padding independently
-
-## 1.4.1
-
-- bug fixes
- - multixy/range: prevent some extra touch state events;`
-
-## 1.4.0
-
-- bug fixes
- - project tree: error when dropping a widget at its initial position
-
-- editor
- - validate property change when clicking on a widget
- - cancel property change when hitting escape
- - add menu and keyboard shortcuts to reorder widgets
- - add keyboard shortcut to show widget in project tree
- - selected widget is not showed on top of the others anymore
-
-- widgets
- - expose widgets unique identifiers with property name "uuid"
- - xy/multixy: add `ephemeral` property
- - fader/knob/xy/range/multixy: remove `touchAddress` property
- - fader/knob/xy/range/multixy: expose touch state in `script` property (`touchAddress` usages will be converted automatically)
-
-## 1.3.0
-
-- bug fixes
- - editor: hide impossible actions from context-menu (eg adding widgets in tab containers)
- - editor: error when selecting a tab/root widget while a property field contains unsubmitted changes
- - panel: layout issue with tabs & lineWidth property
- - input: extend focusable area
-
-- midi
- - remove variable args in sysex messages (dynamic properties and scripting can be used to this effect)
- - add support for sending sysex bytes as integers
- - allow sending any system message (eg MIDI time code)
- - add support for receiving MIDI time code messages (as raw sysex) (requires adding the `mtc` flag to the midi configuration)
-
-
-## 1.2.1
-
-- scripting
- - expose toolbar menu actions
-
-- remote control
- - optimise small changes made with /EDIT
-
-- widgets
- - button: add `wrap` and `vertical` properties
- - root: add `width` and `height` properties (helps building mobile layouts)
-
-## 1.2.0
-
-- bug fixes
- - editor: id not incremented when pasting multiple widgets with id+1
-
-- main
- - remove support for extra args in the `custom-module` option (fixes some path issues)
-
-- widgets
- - all: add `lineWidth` style property
- - knob: add `solid` & `line` designs
- - fader: add `knobSize` property
-
-- editor
- - preserve percentages in position/size
- - add 'Relative units (%)' option to use percents automatically on new widgets
-
-## 1.1.0
-
-- bug fixes
- - iOS 14+ scrolling issue
-
-- midi
- - add support for channel pressure and key pressure messages
-
-- widgets
- - svg: remove support for non-standard `%x` and `%y` units; fixed layout update when resized;
- - knob: add support for custom dash/gap size in `dashed` property
-
-## 1.0.4
-
-- bug fixes
- - script: broken `storage.getItem` and `storage.removeItem`
- - regression breaking `remote-root` option when starting with the launcher
-
-
-## 1.0.3
-
-- bug fixes
- - modal: layout issue on iOS
-
-- widgets
- - panels: added `contain` property to allow scrolling in vertical/horizontal layouts
-
-- midi
- - add support for named ports in midi configuration
-
-
-## 1.0.2
-
-- bug fixes
- - broken scrolling on iPhone iOS 13
- - window geometry issue
-
-## 1.0.1
-
-- UI
- - windows' dimensions and position are now saved upon closing and restored at startup
-
-## 1.0.0
-
-*This list is not exhaustive*
-
-- compatibility
- - dropped support for iOS 9
- - firefox (75+) support
-
-- UI
- - overhaul design reworked
- - foldable sidepanels
- - removed lobby
- - added toolbar menu
- - display loading (spinner) in a notification instead of a modal
- - mod + w to close window
- - context-menu now use click event to trigger actions, not mousedown/touchstart
- - no more uppercase text by default
-
-- themes
- - built-in themes removed except `orange`
-
-- translations
- - incomplete russian translation removed
-
-- editor
- - project tree
- - dropdown for properties with multiple choices
- - color picker
- - preview numeric values for style-related properties set to auto
- - context menu: added "show in tree" action
- - context menu: removed "edit parent" action
- - allow copying tabs (to tab containers only)
- - shared clipboard across all clients
- - prevent interaction with widgets when `shift` or `ctrl` is held
- - ensure @{} bindings are always updated upon edition
-
-
-- widget changes
- - all: removed `label` option except for buttons, tabs and modals (one should use `text` widgets if needed)
- - all: removed support for `null` and `"self"` targets
- - all: added `ignoreDefaults` property (allows ignoring the server's default targets)
- - all: `precision` property to `decimals`, don't set osc integer typetag when 0
- - all: added `typeTags` property
- - all: multiple style properties to control visibility, colors, alphas and padding
- - all: added `interaction` (=> css `pointer-events: none;`)
- - all: added `expand` (=> css `flex: 1;`)
- - all: prevent html tags in label
- - pads: removed `split` property -> use custom-module or script instead
- - root: can contain widgets or tabs
- - panels: added `layout`, `justify` and `gridTemplate` to help managing layouts (especially responsive ones)
- - panels: added `verticalTabs` property
- - panels: added `traversing` property, allow restricting `traversing` to a specific widget type
- - fader: removed `input`
- - fader: removed `meter`
- - fader: added `gradient`
- - fader: added `round` design style
- - fader: support setting dash size and gap size in `dashed` property
- - switch: added `layout` (including grid)
- - switch: added `click` mode
- - plot/eq: removed `smooth`
- - plots/sliders/pads: reversed `logScale` behavior to match standard implementations; can be either `false` (disabled), `true` (logarithmic scale) or `number` (manual log scale, negative for exponential scale)
- - visualizer: added `framerate` property
- - visualizer: added `freeze` property
- - menu: always centered menu
- - modal: modals can't overflow parent tab boundaries
- - input: removed `vertical`
- - pads, range: when `touchAddress` is set, one message per touched point is sent, in addition to the former touch state message
- - eq: removed `logScaleX` property, always draw logarithmic frequency response
- - eq: logarithmic x-axis scale fixed
- - eq: filters are now defined with the `filters` property, leaving the `value` to its default purpose
- - eq: added `rangeX`
- - html: allow `class`, `title` and `style` attributes
- - dropdown: close menu when receiving a value
- - dropdown: removed empty 1st option
- - switch: removed `showValues` (inconsistent with menu/dropdown, feature covered by `values` property)
- - frame: allow loading non local urls
-
-- widget removals
- - `push`, `toggle`: merged into `button`
- - `strip`: features now covered by `panel`
- - `meter`: duplicate of `fader` with `design` to `compact` and `interaction` to `false`
- - `switcher`, `state`, `crossfader`: removed => state management functions added to the `script` widget
- - `keys`: merged with `script`
- - `gyroscope`: not compatible since chrome 74 unless o-s-c goes HTTPS
-
-
-- remote control
- - removed /TABS
- - added /NOTIFY
-
-- scripting (general)
- - removed MathJS language
- - reuse #{} syntax as as shorthand for JS\{\{}} (one liner, implicit return)
- - added `locals` variable, a variable store scoped to the widget
- - renamed `global` to `globals`
- - expose environment variables in `globals`: `url`, `env` (query parameters), `platform`, `screen` (width/height)
-
-- script widget
- - 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 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)
-
-
-- state
- - quickstate (store/recall from menu) is now stored in the clients cache and persists after refresh/close (cleared with the browser's cache)
-
-- custom module
- - `settings.read(name)`: `name` is now the long name of command-line options (not a camelCased one)
- - `receive()`: optional last argument to pass extra options such as `clientId`
- - client id persist upon page refresh and can be set manually with the client url option `id`
-
-
-- launcher
- - config save/load
- - allow starting/stopping server without rebooting
- - syntax check on `--midi` option
-
-- server
- - renamed `--url-options` to `--client-options` and make them apply even in remote browsers (can be overridden with url queries)
- - removed `--blank`, `--gui-only`, `--examples`
- - hide `--disable-gpu` (cli-only)
- - added cli-only `--cache-dir` and `--config-file`
- - added `--authentication` option
- - added `--use-ssl` option
-
-
-- misc
- - canvas: better visibility checks to avoid unnecessary draw calls
- - visualizer: perf improvement (avoid data processing when not visible), all visualizers hook on the same loop to avoid concurrent timeouts
- - button: in 'tap' mode (formerly push with `noRelease`), never send/sync `off` value, automatically reset to `off` when receiving `on`
- - more detached DOM for lighter nested canvas widgets (ie multixy)
- - unified (kind of) dom html structure for widgets, known css tricks will require adjustments.
- - cache and config files are now stored in a folder named `open-stage-control` (located in the system's default location for config file). The `.open-stage-control` is no longer used.
- - added support for icons rotate/flip transform suffixes (example: `^cog.spin`, `^play.rotate-horizontal`)
+- editor code rewriting
+ - right-click context-menu quick editing (widget copy/cut/paste, add & delete tabs/widgets)
diff --git a/CHANGELOG.v0.md b/CHANGELOG.v0.md
deleted file mode 100644
index 32d3b1a5..00000000
--- a/CHANGELOG.v0.md
+++ /dev/null
@@ -1,1843 +0,0 @@
-# Changelog (v0)
-
-## 0.49.12
-
-
-**This is the last release of the v0 branch**
-
-- bug fixes
- - dropdown: value update issue on iOS 13
-- widgets
- - html: allow `class`, `title` and `style` attributes
-
-## 0.49.11
-
-- bug fixes
- - regression (0.49.10) breaking icon with short names (minimum valid length set to 2 characters)
- - html widget: content not initialized properly
-
-## 0.49.10
-
-- bug fixes
- - svg files not loading
- - canvas glitches when hardware acceleration is disabled (--disable-gpu) (built-in gui only)
-
-- misc
- - prevent `--disable-gpu` from bypassing the launcher window
- - prevent converting `"^icon-name"` to an icon (in text widgets and labels) when `icon-name` is too short to be a valid icon name (minimum 4 characters)
-
-## 0.49.9
-
-- bug fixes
- - downgrade electron engine to fix regression (v0.49.8) on some systems
-
-## 0.49.8
-
-- bug fixes
- - rgb: range not applied when receiving value
-
-## 0.49.7
-
-- bug fixes
- - sync issues when widgets have a single target set
-
-## 0.49.6
-
-- bug fixes
- - windows users launching the app from a terminal now need to add a double dash (--) before their options
- - launcher: disabled unstable `Relaunch` action
-
-## 0.49.5
-
-- bug fixes
- - launcher: file/folder browsing not working
-
-## 0.49.4
-
-- bug fixes
- - image: fixed absolute paths
- - image: reset to 'default' instead of 'value' when receiving an empty value
- - launcher: use current midi config for "List devices" action
- - fader built-in meter: use fader's target (allows midi sync)
-
-## 0.49.3
-
-- bug fixes
- - windows: process not terminated properly when exiting the app
-
-## 0.49.2
-
- - bug fixes
- - plots: prevent `plot/*` widgets from sending messages when using the sidepanel's "send all" function
- - editor: assign correct `address` when emptying the field
- - sidepanel: shadow color issue
-- misc
- - alt-buttons & flat theme tweaks
-
-## 0.49.1
-
-- bug fixes
- - modal: error when `label` depends on a child's property
- - custom module: `send()` function casting numbers to integers instead of floats by default
- - menu: push mode not working on touch devices
-
-## 0.49.0
-
-**Deprecation**
-MathJS syntax is now deprecated and will be removed in the future, sessions using it will be working for a few more versions but users are strongly encouraged to migrate to the javascript syntax.
-
-
-- bug fixes:
- - multiclient sync not working when `targets` is empty
- - widgets: missing `target` property for `plots/*` widgets, required for MIDI bindings
- - editor: set `label` to `auto` instead of `true` when using the toggle button
- - editor: errors when hitting `mod + a` and unselecting widgets
- - modal: correct popup title color
- - options: allow `midi:port_name` pairs in `--send` option
- - sidepanel/state: opening a state file now properly sets it as the next default save location
-- widgets:
- - **new** `menu` widget, circular alternative to the dropdown & switch widgets
- - file: allow selecting folders
- - text: optimize value update when there's no icon to draw
-- editor:
- - convert invalid quote characters automatically to avoid errors
- - tab: added `detached` property (set to false to prevent iframes from reloading when the tab opens)
-
-## 0.48.8
-
-- bug fixes
- - strip: layout issues when moving widget in a strip (min width/height still active)
- - tcp: prevent sending osc messages on udp port when the same port number is set as a tcp target
- - midi: take server default targets into account to determine widget matching
- - save dialog: prevent keys widgets from capturing keystrokes when typing the filename
-
-## 0.48.7
-
-- bug fixes
- - xy: broken `spring` property
- - macOs: add support for emulated right click via `ctrl+click`
- - midi: messages received from a midi port now only affect widgets that send to this port
-
-## 0.48.6
-
-- bug fixes
- - ios: prevent color issues with sliders
- - editor: prevent all keyboard shortcuts from triggering default browser actions
-- main
- - detect http server silent setup failure
-
-## 0.48.5
-
-- bug fixes
- - regression breaking support for utf-8 strings in received osc messages
-
-## 0.48.4
-
-- bug fixes
- - launcher: limit terminal history size to prevent slowdown/freeze
-- widgets
- - knob: text pips support
- - fader: add css variable `--gauge-width`
-
-## 0.48.3
-
-- bug fixes
- - widgets: prevent update errors when widgets are not fully initialized
- - prevent pinch-zoom on touch screen
-
-## 0.48.2
-
-- bug fixes
- - editor: checkbox position in multiline fields
- - patchbay: widget not responding to osc after being edited
-- widgets
- - script: added `httpGet` function for simple local http requests
-
-
-## 0.48.1
-
-- bug fixes
- - modal: `popupLabel` update issues
- - modal: `popupTop` not correctly interpreting percents
- - editor: scrollbar issue in editor's input fields on recent chromium
-
-## 0.48.0
-
-- bug fixes
- - midi: listing devices from context menu not working when the midi options is empty
- - package: broken build from sources on Windows
- - editor: incorrect position when moving a widget from an edge with the keyboard
- - modal: prevent touchend event from reaching the inner widgets when opening the container
- - matrix: clone matrices not properly storing their children's values
- - multipad/range: errors when dragging over when the gesture was initiated on a traversing widget (ie matrix)
-
-- widgets
- - **new** html widget
- - frames: allow loading local html files without requiring a web server to serve them
- - text: escape html tags characters (`<` & `>`)
- - input: added `asYouType` property
- - sliders/pads: added `sensitivity` property
-
-
-## 0.47.4
-
-- bug fixes
- - keys: prevent default browser actions when a combo is bound to a widget (for example print dialog with ctrl+p)
- - xy: broken `doubleTap`
- - widget: error when two sibling widgets have a non-dynamic property depending on each others and on another widget at the same time
- - cli: broken `--version` option
-
-## 0.47.3
-
-- bug fixes
- - regression causing errors with the `value` property
-
-## 0.47.2
-
-- bug fixes
- - midi: `path` option not applied to launcher's `list` contextual action
- - midi: pitchbend messages not received correctly
- - style: layout issues in recent chromium
- - encoder: `0` value in `back` property not working
- - editor: state not completely restored under some conditions
- - push: force release when the widget is removed/recreated while pressed
-
-## 0.47.1
-
-- bug fixes
- - css font faces not loading from absolute/relative paths
-- midi
- - added `path` option for setting python binary path manually
-
-## 0.47.0
-
-- bug fixes
- - launcher: spaces not properly escaped in quoted strings
-- widgets
- - sliders: `default` and `spring` properties are now dynamic
-- server
- - images urls are now resolved relatively to the session path directory by default (fallback to absolute path resolution if not found)
-- custom module
- - added `loadJSON` and `saveJSON` functions
-
-## 0.46.2
-
-- improved canvas rendering speed on chrome v69 and above
-- widgets
- - modal: `scroll` option
- - script: `get(id)` function added in `script`execution context
- - script: `getProp(id, property)` function added in `script`execution context
- - script: `id` variable added in `script`execution context (id of the widget that triggered the script)
-
-## 0.46.1
-
-- bug fixes
- - windows: midi debug strings not printed
-
-## 0.46.0
-
-- bug fixes:
- - modal: `css` not properly applied if the property was previously empty and the modal had been opened at least once
- - image: allow overriding css background-image when value is empty
-- widgets
- - switchers: new `state` widget
-- remote control
- - added `/STATE/[GET|SET|STORE|RECALL]` methods
-- midi
- - print port name in debug messages
- - added `pc_offset` option to act as if program change numbers where between 1 and 128
-
-## 0.45.7
-
-- bug fixes
- - image: `cache` option inverted
- - image: allow whitespaces in url
-- widgets
- - keyboard: `toggles` options
-
-## 0.45.6
-
-- bug fixes
- - bottom horizontal scrollbar not responding on small screens
- - remote file browser: hitting a letter to select a file based on its name was looping on the first two matches only
- - editor: preserve backslashes in enquoted strings (not in objects/arrays)
- - editor: clear the editor when selected widget is removed by an undo/redo action
-- widgets
- - `logScale` can be set to a number to use a logarithm base different from the default
- - knob: `compact` mode is back
-
-## 0.45.5
-
-- bug fixes
- - absolute file paths not resolved under windows
- - nested `@{}` calls issue ([#516](https://github.com/jean-emmanuel/open-stage-control/issues/516))
-
-## 0.45.4
-
-- bug fixes
- - handle network drops correctly (notify immediately and fix reconnection mechanism)
- - formulas breaking the property update mechanism when not resolved
- - modal: title layout issue
-
-## 0.45.3
-
-- bug fixes
- - broken client sync for widgets with `split` set
- - custom module: `receive` function not working when omitting host/port and sending only one argument
- - file browser: prevent error when files/folders cannot be read
-
-## 0.45.2
-
-- bug fixes
- - potential security issue in `JS{{}}` parser
-
-## 0.45.1
-
-- bug fixes
- - broken session local export
- - potential security issue in custom module parser
-
-## 0.45.0
-
-- bug fixes
- - regression (v0.41.4) breaking sync between clients
- - sessions not added to history when opened
- - switch: traversing mode issue
- - remote file browser reactivity issue
- - encoder: broken because `ticks` default was `auto` instead of `360`
-- main
- - state files can be saved remotely
-- widgets
- - **removed** deprecated widgets `multifader`, `multitoggle`, `multipush` and `formula`
- - new `JS{{}}` property syntax, allows writing formulas using javascript
- - errors encountered in `#{}` blocks are now printed to the client console (F12)
- - keys: renamed formula context variable `super` to `meta`
-
-## 0.44.0
-
-- bug fixes
- - ios: clone widget not displaying properly
- - keys: error when leaving the window with the cursor while holding a key-combbo pressed
- - session: disable saving when `--read-only` is set
-- main
- - sessions can be opened and saved from/to the server's filesystem directly
-- widgets
- - new `file` input widget (allows selecting a file on the the serve and sending its absolute filename)
-- midi
- - :warning: **breaking changes** :warning:
- - replaced python dependency `rtmidi` with `python-rtmidi` (provides pre-compiled binaries for all major platforms)
- - sysex messages are now discarded by default, they can be enabled by adding `sysex` to the midi options
-
-## 0.43.0
-
-- bug fixes
- - sidepanel: resize handle overflow issue
-- ui
- - sidepanel: hidden resize handle; show edge resize handle on hover
-- launcher
- - added context menu action to display midi device list without starting the server
-- widgets
- - switch: add `traversing` option (`true` by default)
- - knob: act as a relative encoder when traversing gestures are enabled and `snap` is `false`
- - keys: `key` variable in `keydown` and `keyup` is now always lowercased when referencing a single character
- - keys; expose `code` variable from the keyboard event object (https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code#Code_values)
-- custom module
- - expose shorthand functions `send` and `receives`
- - expose a client object instead of just an id in `app` event handlers to allow retrieving the client's ip address as well
- - custom modules can now be written like standard nodejs modules (using `module.exports` assignement instead of a self-invoking function pattern)
-
-## 0.42.0
-
-- widgets
- - `OSC{}` syntax accepts an optional third argument (`false`) to bypass the host widget's `preArgs`
-- editor
- - sticky header to remind selected widget's id
- - sidepanel can now be resized by dragging its edge
-
-## 0.41.7
-
-- bug fixes
- - matrix: `$` variable not starting at `start`
- - matrix: properties not reset to default when removed from `props`
-
-## 0.41.6
-
-- bug fixes
- - keys: binding conflict with editor
- - xy: drawing performance issue
-
-## 0.41.5
-
-- bug fixes
- - editor: changes applied to wrong widget when clicking on a widget while editing another widget's property
- - push: allow setting `value` property
- - allow whitespaces in path for `--custom-module`
- - error when changing a property that's inherited by a widget to define its address and at least one non-dynamic property
-- widgets
- - sliders: when `steps` is set, scrolling on the widget makes it go directly from one step to another
-
-## 0.41.4
-
-- bug fixes
- - broken `--remote-saving` option*
- - `fader`: built-in `meter` not updating its `address`, `preArgs` & `color` properties
- - incorrect osc messsages when widget's `split` and `preArgs` are set
-
-## 0.41.3
-
-- bug fixes
- - `rgb`: values were rounded even with `precision` different from `0`
-- osc
- - add support for utf8 string argments (encoded/decoded as per standard https://encoding.spec.whatwg.org/#utf-8)
-
-## 0.41.2
-
-- bug fixes
- - geometry properties not properly applied when reset to `auto`
- - `strip` layout not properly applied when changing the widget's `horizontal` property
- - `modal` glitch on chromium v70
-
-## 0.41.1
-
-- bug fixes
- - error when loading session file
- - prevent sidepanel issue when toggling quickly
-
-## 0.41.0
-
-- main
- - `--send` accepts `ip:port` and `domain:port` targets
- - removed previously deprecated `--sync` option
- - `--custom-module` now accepts extra options that can be consumed from the custom module's code
- - sessions located on the server can now be saved remotely, this becomes the default behavior for keyboard shortcut `mod + s`, local export is still available via `mod + shift + s`
- - added `--remote-saving` options to limit remote session saving feature to hosts that match the provided regular expression
-- ui
- - added notifications
-- widgets
- - `matrices`: **new** `patchbay` widget
-- bug fixes
- - layout break when hitting tab with sidepanel closed and editor enabled
- - crash when running the server in an environnement without user home folder
-
-## 0.40.5
-
-- bug fixes
- - clone: editor's selection rectangle appearing after editing the clone's target widget
- - windows: midi issue (python path not found)
-- widgets
- - input: hitting `tab` now validates the value before focusing the next input (hitting `esc` or clicking outside the widget still cancels); when focusing an input widget, its whole value is selected by default; focused/selected text color hint changes.
- - matrix: widgets inherit from the matrix' `id` and osc properties by default
-
-## 0.40.4
-
-- bug fixes
- - editor: widgets/tabs not properly reordered when changing a widget or tab's index by more than 1
- - main: `--no-gui` switch not working when running the app from a different directory
- - regression causing osc receivers (`OSC{}`) to conflict with property listeners (`@{}`)
-- widgets
- - push: add `doubleTap` option
- - osc listeners (`OSC{}`) now accept relative addresses (without leading '/'), automatically prefixed with the widget's address
-
-## 0.40.3
-
-- bug fixes
- - editor: sidepanel & dragging handles not always updated after edition
- - widgets: parsing error when a property contains more than 10 variables
-
-## 0.40.2
-
-- bug fixes
- - regression reversing tabs order
-
-## 0.40.1
-
-- bug fixes
- - editor: issue with tabs selection / edition
- - regression breaking `svg`
-
-## 0.40.0
-
-- bug fixes
- - `--read-only` option not properly working
- - `keyboard`: dynamic properties `target`, `precision` & `preArgs` not being updated dynamically
-- widgets
- - formulas: added `indexOf` function
- - **deprecated** `multifader` / `multipush` / `multitoggle` in favor of the generic `matrix` widget
- - meter: `gradient` can be set as an object to define uneven color breakpoints
-
-## 0.39.8
-
-- bug fixes
- - meter's properties not accessible (overridden with fader's properties)
-- mobile
- - button for preventing device sleep
-
-## 0.39.7
-
-- bug fixes
- - iOS 9.3 compatibility
-- widgets
- - sliders: `steps` property is now dynamic
-
-## 0.39.6
-
-- bug fixes
- - `modal` widgets not working since chrome v70
-
-## 0.39.5
-
-- bug fixes
- - sliders: `steps` option not working when `range.min` is not `0`
- - regression breaking the app for iOS 9.3
-
-## 0.39.4
-
-- widgets
- - multiXy: added `.pad-N` class to inner xy pads to help with css customization
- - xy/multiXy: added css variables `--background`, `--color-pips`, `--pips-opacity` and `--point-opacity`
- - rgb: added `alpha` option
- - xy/multiXy/rgb: design impovements;
- - sliders: new `steps` option
-
-## 0.39.3
-
-- bug fixes
- - broken tabs color property
- - broken `/TABS` command; this command doesn't makes panels send osc messages anymore
-
-## 0.39.2
-
-- bug fixes
- - regresssion: broken --theme option
- - regression: missing 'edit parent' action in editor's context menu
-
-## 0.39.1
-
-- bug fixes
- - regression breaking icons in switches' labels
-
-## 0.39.0
-
-- performance
- - rendering speed improved (session loading time reduced by about 30%)
-- widgets
- - remove support for deprecated properties `path`, `noPip` and `noSync`
- - sliders/pads: `precision` is no longer a dynamic property
-
-## 0.38.7
-
-- bug fixes
- - launcher compatibility issues with electron v3
-
-## 0.38.6
-
-- bug fixes
- - regression with dynamic property `color` in panels and matrices
-- packaging
- - node-only package can be run with electron too
-
-## 0.38.5
-
-- packaging
- - regression causing the client js bundle to be much bigger than needed
- - added node-only package built without electron for unsupported platforms (armv6, etc)
-
-## 0.38.4
-
-- bug fixes
- - `@{parent}` calls not working consistently in clone widgets
- - `slider/pads`: inteverted ranges not working
- - fix `doubleTap` for sliders with `snap` set to `true`
- - undo/redo errors
-- widgets
- - 1-level nested property inheritance calls (`@{id_@{id_2}}`) are now updated dynamically
- - support special css property `class` for adding custom classes to widgets
- - added "smart" traversing gestures mode that limits affected widgets by the type of the first touched widget
- - root: added `traversing` property
-- editor
- - major performance improvements (containers' children are reused whenever possible instead of being recreated)
- - removed widget deletion confirmation popup
- - properties categories can now be folded
- - added keyboard shortcut `F2` for editing the label quickly
- - added keyboard shortcut `mod + s` for saving the session
- - added keyboard shortcut `mod + o` for opening a session
- - use `backspace` instead of `delete` for deleting widgets on MacOs
- - added keyboard shortcut `mod + e` for enabling / disabling the editor
- - added keyboard shortcuts `mod + arrows` for selecting widgets
- - added keyboard shortcut `mod + a` for selecting a widget's siblings and itself
- - added keyboard shortcut `mod + shift + a` for cancelling selection
- - added multi widget selection with mouse when `shift` is pressed
- - right-click doesn't modify current selection when `mod` or `shift` is pressed
-- formulas
- - added `extend(x, y)` function for merging two objects
- - objects' closing brackets (`}`) don't need to be escaped with a backslash anymore
- - show property's computed value in the help popup
-
-## 0.37.4
-
-- bug fixes
- - osc receivers (`OSC{}`) not working in non-dynamic properties
-- remote control
- - added `/GET/#` to get a widget's value without using `/GET` as reply address
-
-## 0.37.3
-
-- bug fixes
- - gyroscope: osc sendings not properly triggered on value updates
-
-
-## 0.37.2
-
-- bug fixes
- - osc: regression making empty `preArgs` count as one empty string argument
-
-## 0.37.1
-
-- bug fixes
- - closing popups when clicking precisely on the "x"
-- translations
- - fr: corrections
- - ru: added russian translation
-
-## 0.37.0
-
-- bug fixes
- - editor: opening the sidepanel doesn't select the root widget anymore
- - ios: fix `doubleTap`
-- widgets
- - **new** `gyroscope` widget
- - **new** `frame` widget
- - **breaking change** in `panel`: dropped Visual Format Language support (`layout` and `spacing` properties)
- - maths: added `timestamp()` function
-- editor
- - widget property names can be clicked to show documentation
-- misc
- - the client app can be translated (https://github.com/jean-emmanuel/open-stage-control/issues/302)
-
-## 0.36.0
-
-- bug fixes
- - `linkId` synchronizations now correctly trigger property updates
- - widgets with multiple `linkId` are now properly handled
- - synchronization issue between `visualizer` widgets
-- widgets
- - `keys` (**breaking changes**): formulas in `keydown` and `keyup` must be explicitely written using the `#{}` syntax; variable `value` got removed from these formulas context (use `@{this}` instead); removed `widgetId` property, the value emitted by the widget on keypress events can be linked with other widgets via the `linkId` property or the property inheritance syntax;
- - `visualizer`: update rate set to default canvas framerate
-- editor
- - **new** keyboard shortcuts (undo, redo, copy, paste, etc)
-
-## 0.35.0
-
-- main
- - added `--state` option for loading a state file with a session file
-- state
- - loading a state file doesn't replace the quick save slot anymore
-- widgets
- - **new** `script` widget
-- misc
- - reduced session file size (indentation set to 2 instead of 4)
-
-## 0.34.4
-
-- bug fixes
- - widgets: dynamic `address` when `split` is `true`
- - strip: missing osc properties (`address` and `preArgs`) for remote control
- - switcher: update linked widgets' osc properties before sending if they depend on the switcher's value
-
-## 0.34.3
-
-- bug fixes
- - launcher: regression breaking the `port` option
-
-## 0.34.2
-
-- bug fixes
- - matrices: spacing issue when wrapped in strips
- - launcher: regression preventing options to be applied
-
-## 0.34.1
-
-- bug fixes
- - switch: display object-values properly when `showValues` is set to `true`
- - prevent non-dynamic properties updates from breaking an osc sending event chain
-- deprecations
- - `formula` has been removed from the editor's context menu
-- custom module
- - expose `app` to the custom module's scope: an event emitter for monitoring the events sent by the different clients
-- misc
- - fixed rpi build
-
-## 0.33.3
-
-- bug fixes
- - matrix: recreation loop issue with matrices of clones
- - multixy: glitch when some letters are used in the points' labels
-
-## 0.33.2
-
-- bug fixes
- - matrix: set initial value at widget's creation; missing border under widget's label
-- widgets
- - property math syntax: add `values()` and `keys()` functions
-
-## 0.33.1
-
-- bug fixes
- - widgets: remove unnused properties to avoid having hidden properties laying around when the type changes (especially dangerous when those properties where linked to other widgets)
-
-## 0.33.0
-
-- bug fixes
- - osc receivers: unregister properly when widgets are recreated (memory leak); allow non-string values (eg. objects)
- - circular property update issues
-- widgets
- - **new** generic `matrix` widget
- - fader: restore right-click focusing the input in compact mode (mouse only)
-
-## 0.32.6
-
-- bug fixes
- - css border-radius not applying correctly for some widgets
-- themes
- - multiple adjustments
-
-## 0.32.5
-
-- bug fixes
- - missing feedback support for widgets with typed preArgs
-- themes
- - improved `dark` theme
- - added `flat`
-
-## 0.32.4
-
-- bug fixes
- - regression breaking typed osc args
-
-
-## 0.32.3
-
-- bug fixes
- - regression in editor/resize function
-
-## 0.32.2
-
-- bug fixes
- - sliders colors not displayed correctly on iOS
-- widgets
- - xy: tiny knob style change
-- editor
- - reallow editing disabled properties
-
-## 0.32.1
-
-- bug fixes
- - error in osc receivers
-
-## 0.32.0
-
-- main
- - add tcp support
-
-## 0.31.0
-
-- bug fixes
- - regression breaking multitouch widgets
-- widgets
- - fader/knob/pad: right-click / long tap doesn't give focus to the input anymore
-
-## 0.30.4
-
-- bug fixes
- - regression breaking touch traversing gestures
- - clone widgets becoming unselectable for edition
- - `preArgs` property still being coerced to an array
-
-## 0.30.3
-
-- bug fixes
- - big regression breaking many touch gestures
-
-## 0.30.2
-
-- bug fixes
- - broken remote-control /TABS command
- - disabled `spacing` property in strips
- - disabled properties in modals
- - broken arm build
-
-
-## 0.30.1
-
-- midi
- - prevent the main process from exiting when MIDI setup fails
-
-## 0.30.0
-
-- widgets
- - `target` and `preArgs` properties are no longer coerced to arrays and can be written as single string values
- - `linkId` supports master and slave modes with `>>` and `<<` prefixes
- - the special `target` token `null` can now be used in conjunction with regular targets, it disables the default global targets set via the `--send` option
-- editor
- - disabled widget properties are now greyed out
-
-## 0.29.2
-
-- bug fixes
- - launcher: parsing errors are not fatal anymore
- - css parsing error on iOS
-
-## 0.29.1
-
-- bug fixes
- - editor: "wrap" deleting the widget just before the one being wrapped
- - regression breaking traversing gestures and high precision gestures (0.29.0)
-- server
- - allow sending osc to broadcast ip addresses
-- widgets
- - limited support for property inheritance nesting (`@{id_@{id_2}}`)
- - support using property inheritance syntax in osc listeners' addresses
-
-## 0.29.0
-
-- beaking changes
- - dropped supported for `.js` sessions (deprecated in 0.20.0)
-- bug fixes
- - zeroconf: unpublish when shutting down
- - ios 9.3 compatibility issue
- - function mispelling in rgb widget
-- widgets
- - modal: added `popupLeft` and `popupTop` properties
- - faders/meter: add css variable `--gauge-opacity` to allow setting a fixed gauge opacity for meters and compact faders
-- custom module
- - messages converted from midi inputs can be filtered
-
-
-## 0.28.3
-
-- bug fixes
- - widgets not correctly drawn when hidden/shown with dynamic css
- - iOS: file upload failing sometimes
-- widgets
- - knob: small design improvements (pips don't take extra space anymore)
-
-## 0.28.2
-
-- bug fixes
- - session list: fix "remove from history" always removing the first item in the list
-- custom module
- - expose `setInterval`
- - expose `clearTimeout` and `clearInterval`
- - prevent errors when failing to run the module
-
-
-## 0.28.1
-
-- bug fixes
- - regression in nested clones structures handling
-
-
-## 0.28.0
-
-- widgets
- - matrices: support setting `split` property as a string to allow using children's indexes in their address (`$` is replaced with the index number)
- - text: `wrap` property doesn't break words by default anymore
- - rgb: added `range` property
-- launcher
- - right-click context menu (copy, paste, clear console, toggle console autoscoll, relaunch app)
- - better font for the console
-
-## 0.27.2
-
-- bug fixes
- - session/state file upload sometimes failing silently
- - regression breaking the app for iOS
-
-## 0.27.1
-
-- bug fixes
- - error when resizing a widget and its clone(s) at the same time
- - error with non string css property
- - session list not reappearing when failing to load
- - broken state file loading
-- misc
- - added a loading indicator when uploading a session file or a state file
-
-## 0.27.0
-
-- bug fixes
- - strip: nested strips were inheriting their parent's `spacing`
- - modal: prevent error when retrieving a child's property
- - modal: prevent touch event from affecting elements behind the popup when closing it
- - clone: some properies in target widget were not applied to the clone
- - clone: prevent clone from resetting its target value when created
- - text: vertical centering issues in narrow widgets
- - dynamic properties: when using a widget's own value to determine its osc settings, these are checked and updated if needed before sending the message
- - prevent error when loading a session containing invalid property inheritance calls
- - broken build for iOS 9.3
-- editor
- - wrap in: insert wrapper at selected widget's index
- - wrap in: set label to false by default when wrapping in a strip or a panel
- - css property `pointer-events:none;` is now ignored when the editor is enabled
- - preverve pecentages when dragging/resizing a widget that has its position/size written in percents
-- widgets
- - **new** `OSC{/address, default_value}` syntax
-- ui
- - sidepanel is now resizable
-- themes
- - `responsive-fonts`: increase size for big screens
-- build
- - dropped support for node < 4.8
-
-## 0.26.3
-
-- bug fixes
- - ios: broken default accent color in clone Widgets
- - ios/android: closing the sidepanel opened the tab next to the menu button
-- editor
- - mac: use `shift` instead of `command` for multi widget selection to match native behaviour and prevent unwanted zoom with trackpads
-- widgets
- - strip: `spacing` now accepts percents
-
-## 0.26.2
-
-- bug fixes
- - regression preventing glass effect from using the widget's color
- - missing last key in keyboard widget
- - editor: select parent widget after deleting a widget
- - regression letting user to scroll the main document
- - editor: wrap/cut/delete multiple widget not working properly
-- widgets
- - text: set line-height relative to font size
- - meter: added `gradient` feature
-
-## 0.26.1
-
-- bug fixes
- - ios: text input fields not editable
-- editor
- - mac: use `command` instead of `ctrl` for multi widget selection
-
-## 0.26.0
-
-- bug fixes
- - editor: when selecting another widget while editing a property, changes where applied to the newly selected widget
- - widgets: css: @media queries parsing
- - prevent some errors when synchronizing clients
- - use command key instead of ctrl for zooming on mac
- - clone: memory leak / freeze
-- default client
- - mac: disabled unsupported pinch zoom
-- themes
- - alt-buttons: modal font-weight & color fix; push button active state colored border
- - added "responsive-fonts" theme
-- editor
- - allow multi widget resizing/dragging
- - tweaked ctrl+click/right-click selection behaviors
- - **new** "Wrap in" context menu
-
-
-## 0.25.0
-
-- bug fixes
- - launcher: parse array options correctly when an item contains spaces,
- - launcher: the terminal now grows and scrolls to bottom automatically
- - editor: broken children reordering; children
- list display bug with long `id`s
-- main
- - add `--fullscreen` switch (default gui only, bypasses the sidepanel fullscreen button)
- - added/updated some themes: `orange`, `light`, `dark`, `alt-buttons` (the latter can be combined with other themes)
-- widgets
- - knob: big knobs design tweaks
- - **new** `default` property that sets a widgets initial/doubleTap/spring value. The `value` property does no longer serve this purpose.
- - **new** `bypass` property that disable osc messages (except when requested via `/GET` and `/EDIT/GET`)
- - panel: **removed** `noSync` property (backward compatible fallback to `bypass`)
- - property inheritance: `@{widget_id.value}`, `@{widget_id}` and `@{widget_id._value}` now all refer to the widget's current value (the latter being kept for backward compatibility); If a property update triggers an osc message, it will now be sent after the other dynamic properties changes are resolved (such as osc `address`, `target`, etc)
- - text: added `align` and `wrap` properties
- - input: added `align` property
- - sliders/xy: `doubleTap` can be an osc address to send a special message instead of resetting the widget's value
-- editor
- - allow selecting multiple widgets (`ctrl + click`) if they share the same parent. Context-menu and sidepanel editing actions apply to all selected widgets
-
-## 0.24.3
-
-- bug fixes
- - property maths: variables names declared in a formula were replaced by their associated value if found in the formula's result
- - missing console logs on windows
-- ui
- - add iOS fullscreen support via add-to-home feature
-- editor
- - ask for confirmation when closing or refreshing the page if the editor has been enabled at least once
- - prevent default widget interaction when selecting a widget for edition
-- widgets
- - knob: small design tweaks
-- misc
- - remove proprietary ffmepg codec from package
-
-## 0.24.2
-
-- bug fixes
- - macOs app menu & shortcuts
-
-## 0.24.1
-
-- bug fixes
- - server/client communication errors
- - prevent error windows from spawning
-- main
- - added some menu items on macOs (including "Quit" !)
-
-## 0.24.0
-
-:warning: **BREAKING CHANGES** :warning:
-
-Read the changelog carefully, old sessions files are likely to need some adjustements to work as they used to. Plots and input widgets had their `widgetId` option removed because it was redundant with the generic `linkId` property.
-
-- bug fixes
- - regression preventing dropdown to display no option selected
- - crossfaders display issue on iOS
- - restored compatibility options for server-client communications
- - xy: `doubleTap` option
- - range: `spring` option
- - plot: crash when drawing only one point
- - widget css: fixed @media queries @keyframes parsings
-- main
- - theme files changes are automatically applied
- - server-client communication system rewritten -> HUGE latency reduction and stability improvement especially under stress conditions
- - engine update (electron@1.8.2)
-- widgets
- - **new** svg plot widget
- - switch: wrap non-array `values` property in an array
- - dropdown: wrap non-array `values` property in an array; always add a default empty value
- - property inheritance: added shorthand default to `_value` when no property is specified (`@{widgetId}`); some properties can now be dynamically changed without recreating the widget entirely
- - property maths: added support for math expressions everywhere via `#{}`
- - input: add glass effect when `editable` is `false`
- - `linkId` can now be set as an array of linkIds
- - plot: added `dots` options; **removed** `points` options (use `value` and property inheritance instead)
- - eq: **removed** `filters` options (use `value` and property inheritance instead)
- - plot/meter/led/rgbled/text: **removed** `widgetId` option
- - input: **removed** `widgetId` option
- - math: **deprecated** `formula` widget
-
-## 0.23.1
-
-- bug fixes
- - regression breaking modal's position in scrolled tab containers
- - widget with a `touchAddress` set now send their touch-off message when removed or recreated while being interacted with
- - broken windows builds (long path issue)
-
-## 0.23.0
-
-- bug fixes
- - plots now send their value to other widget for synchronization as expected
- - text widgets now apply their target widget's precision
- - property inheritance accepts targetting a parent widget by its id
- - multiple icons not displayed correctly
- - broken `--blank` option
-- main
- - added `--disable-gpu` option for disabling hardware acceleration (fixes rendering glitches and reduces input lag on some systems)
-- widgets
- - inputs: **new** `keys` widget, for keyboard bindings
- - property inheritance: new special property name `_value` (retrieve the widget's value, and update when it changes)
- - switch: added `showValues` to display both values and labels in the buttons; array values can now be selected via osc
- - range: both handles can be moved by holding `shift` while dragging
- - rgb: **removed** `touchAddress` option
- - labels/texts: multiple white spaces are no longer merged
- - plot: can receive stringified arrays of coordinates or stringified objects for merging coordinates sets; added `bars` option for drawing barcharts;
- - widgets' `precision` option allows setting a specific data type for numbers (sliders can send doubles !)
-- misc
- - event system rewritten
- - js build size reduced
-
-## 0.22.0
-
-- bug fixes
- - sessions opened from command line with relative paths are now added to the history with their absolute path
- - sending an empty message to a `text` widget resets it to its initial value and without ignoring its `value` property
- - sending no value to a widget with `preArgs` is now possible : all the arguments found in incoming osc messages are now taken into account to match the widgets in the session
- - regression breaking state quicksave from sidepanel
-- engine
- - downgraded to the latest *stable* electron release
-- main
- - added `zeroconf` / `bonjour` publishing for the app's http and osc input ports
- - added `--instance-name` option to differenciate mulitple instances in zeroconf networks
-- widgets
- - sliders/pads: holding `Ctrl` now enables high precision dragging with the mouse and bypasses the `snap` option
- - inputs: renamed `input`'s property `horizontal` to `vertical` to match how the widget actually displays
- - sliders: **new** `range` widget
- - plots: **new** `image` widget
-- remote control
- - **removed** deprecated `/EXEC`
- - renamed `/EDIT_SOFT` to `/EDIT/MERGE`
- - added `/EDIT/GET` (get a widget's data)
- - added `/GET` (get a widget's value)
- - added `/SET` (set a widget's value as if it was interacted with from the interface)
-
-
-## 0.21.3
-
-- bug fixes
- - session/state: regression (0.21.2) breaking save-to-file function
-- ui
- - FontAwesome 5 (icon font) !
-
-## 0.21.2
-
-- bug fixes
- - cli: broken long flag `--no-gui`
- - headless: when running with `node`, errors don't stop the server; when running with `electron` (default), errors are logged in the console instead of being showed in a dialog window
- - switcher widgets regression (broken)
-- midi
- - float values are now allowed and automatically rounded
-- misc
- - some code refactoring
-
-## 0.21.1
-
-- bug fixes
- - visualizer: fix memory leak when editing; fix ignored `smooth` option
- - plots: regression preventing widgets with no `target` option from receiving messages sent by other clients
-
-## 0.21.0
-
-- main
- - renamed `--sync` option to `--send` (deprecation, backward-compatible)
-- widgets
- - sliders/pads: when receiving feedback while touched, the widget waits to be released before updating to the latest received value.
- - input: the widget's value is no longer validated when leaving focus by clicking somewhere else or hitting the `Tab` key (it must be submitted by hitting the `Enter` key); when submitting a value to another widget, the feedback from this widget doesn't trigger a second osc message anymore; non-editable inputs can't steal focus anymore
- - added support for `null` value in `target` option to disable osc sending
-- misc
- - property fields are now parsed using [JSON5](https://github.com/json5/json5), a more flexible notation. Session files are still written in standard JSON format, this is just a way to avoid typing mistakes when using the editor.
- - remote editing also accepts JSON5 notation
-
-## 0.20.3
-
-- bug fixes
- - allow loading `.json` session files from the launcher
-- launcher
- - new log/error console (shows once the app is started)
-
-## 0.20.2
-
-- bug fixes
- - pads: regression breaking the built-in input
- - multifader: inverted order in horizontal mode
-- widgets
- - plots: add `smooth` option (thanks to [cardinal-spline-js](https://github.com/epistemex/cardinal-spline-js)); draw thicker lines
- - pads: draw thicker inner circle
- - mobile
- - prevent devices from entering sleep mode
-
-
-## 0.20.1
-
-- bug fixes
- - error popups not created
-- misc
- - rename sessions files to `.json`
-
-## 0.20.0
-
-- **breaking changes**
- - sessions are now saved as `.json`files by default (the deprecated `.js` extension can still be opened).
- - states are now saved as `.state` files (the old `.preset` files can be renamed without any problem)
-- bug fixes
- - touch release event is properly dispatched in traversing containers (ie keyboards and matrices) (#94)
-- widgets
- - css `border-radius` support enhanced
- - css `color` applies locally while `--color-text` applies to children too
- - plot/text: new lines are properly printed
-- packaging
- - added `arm64` binaries
-- iOS
- - compatibility improved (version 9.3 and above)
-- engine
- - electron 1.8.0 (chrome 59)
-
-## 0.19.6
-
-- hot fix
- - broken formula widget
-
-## 0.19.5
-
-- launcher
- - fixed typo in new version message
-- misc
- - client-side javascript's size reduced, now for real !!
-
-## 0.19.4
-
-- bug fixes
- - buttons: changing `css` background works as expected
- - widgets: changing `css` (text) color works as expected
- - fader: fix hidden input in horizontal + compact mode
- - pads: pips scaling bug
-- widgets
- - `css` font-sizes apply correctly to all children (better use percents)
- - formula: add `unit` option
-- misc
- - client-side javascript's size reduced !
-
-## 0.19.3
-
-- bug fixes
- - midi: noteOff messages not being sent;
-
-## 0.19.2
-
-- bug fixes
- - lobby: regression breaking the lobby for touch devices
-
-
-## 0.19.1
-
-- bug fixes
- - launcher: load correct font
- - midi: python3 compatibility fix
-
-## 0.19.0
-
-- ui
- - general design improved, heavily inspired by [budislavTVP](http://budislavtvp.deviantart.com/) works; color schemes are much simpler and easier to customize (try `--theme light` !); Font changed to Roboto; Texts are slightly thicker and uppercased in most cases for better readability (use css `text-transform:none` to disable the latter).
-- widgets
- - fader: added `dashed` option; added `input` option;
- - meter: added `alignRight` option; added `dashed` option;
- - knob: removed `compact` option; added `dashed` option; added `input` option;
- - xy/rgb: added `input` option; added `pips` option:
- - panel/strip: removed inner widgets dark borders; added `border` option;
- - buttons: new `dropdown` widget;
- - toggle: added `led` option to choose between the old appearance and the new one; added `douleTap` option
- - new `input` widget
- - containers: new `clone` widgets
- - added support for `"self"` value in `target` option (sends the message back to the clients, useful for sending `/EDIT` messages...)
-- editor
- - option fields are now multiline (`ctrl + enter` to add a new line), and pretty printed
- - added checkboxes for boolean options
- - added `Edit Parent` context menu option
-- midi
- - replaced `pyo` dependency with [`pyrtmidi`](https://github.com/patrickkidd/pyrtmidi): lighter, dedicated to midi only, and handling virtual ports (no `mididings` dependency anymore)
- - pitchbend value is now a single integer between 0 and 16383
-- bug fixes
- - fixed VisualFormat errors in iOS
-- main
- - added `--url-options` command line option
- - fixed `--disable-vsync` not working when starting from the launcher
-- documentation
- - new style, better organization
-
-## 0.18.0
-
-:warning: **Breaking changes** :warning:
-
-Sessions saved with this version will not be readable with older versions (old sessions a can be opened but wont be backward-compatible once saved).
-
-
-- widgets
- - add property inheritance between widgets with statements `@{parent.propertyName}`, `@{this.propertyName}` and `@{widgetID.propertyName}`
- - containers: added `variables` options (arbitrary varibles to pass to children)
- - panel: added full osc support (for sending/receiving tab changes)
- - modal: changed style to fit popups' appearance; added `popupWidth` and `popupHeight` options; :warning: removed `tabs` option; added full osc support; added `doubleTap` option (makes it openable with double taps instead of single taps)
- - strip: refactored widget using `panel` as base; added `stretch` and `spacing` option; now it's really cool
- - sliders: added `doubleTap` option (double taps reset the widget to its initial value when enabled)
- - knob/fader: renamed `noPip` option to `pips` (inverted behaviour; backward compatible)
- - encoder: mousewheel support
- - knob: compact design remake
-- bug fixes
- - sliders: fixed `spring` when `value` equals `0`
- - modal: fixed osc values (was `True`/`False` instead of `1`/`0`)
-- session
- - the root panel is now saved as a special `panel` widget (which means it has savable options)
-- custom module
- - add access to the app's `settings` object
-
-## 0.17.8
-
-- bug fixes
- - regression breaking widgets' `split` option (0.17.6)
- - regression breaking the state export button (0.17.7)
- - regression breaking editor's `cut` action (0.17.7)
-- osc
- - javascript object are now stringifyied before beeing sent
-- widgets
- - maths: add `condition` option to [`formula`](http://osc.ammd.net/user-guide/widgets-specifics/maths/#formula)
- - sliders/pads: add `touchAddress` option
- - fader: add `meterAddress`
-
-## 0.17.7
-
-- engine
- - socket.io v2
-- client
- - scripts are now transpiled to ES5 javascript code, thus increasing compatibility with some browser (iOS9's chrome, firefox, etc)
- - scripts size reduced from 2.4M to 1M thanks to minification
-- bug fixes
- - elements duplications in sidepanel when loading another session
-
-## 0.17.6
-
-- main
- - osc sending speed optimization: all static infos (target, address, preArgs) are cached server side to reduce network overhead
-- widgets
- - **new** encoder widget
-- mobile
- - `hdpi` support (add `?hdpi=1` to the server's url)
-- bug fixes
- - launcher: link to the app's address is now clickable
- - sidepanel: layout glitches with iOS
- - midi: `program` now works with the correct number of arguments
-- misc
- - some little style fixes
-
-## 0.17.5
-
-- bug fixes
- - `multixy` snap mode position offset
-- widgets
- - **new** [`rgbled`](http://osc.ammd.net/user-guide/widgets-specifics/plots/#rgbled)
-
-
-## 0.17.4
-
-- bug fixes
- - broken `--blank` option fixed (false-positive detection of concurrency with `--read-only`)
- - remove debug message in console when closing windows
-
-## 0.17.3
-
-Hot fix for `--read-only` switch.
-Dependencies updates.
-
-## 0.17.2 (deleted)
-
-- bug fixes
- - `editor`: correctly remove editing state when disabling the editor right after going to another tab
-- main
- - **new** `--read-only` switch for disabling the editor and preventing change to the session history
-- widgets
- - `panel/modal`: add `layout` option ([Visual Format Language](https://github.com/IjzerenHein/autolayout.js))
- - `css` option now interprets `&` as a selector for the widget's element itself (useful for targetting pseudo-elements such as `&:after`)
- - `plots`: add `widgetId` option to `text`, `meter` and `led`
-
-## 0.17.1
-
-- bug fixes
- - `midi`: missing dependency
- - `headless`: terminate `midi` correctly when process exits
-
-## 0.17.0
-
-- main
- - **new** `midi` support ([documentation](http://osc.ammd.net/user-guide/midi/))
-- ui
- - **new** `/TABS id1 id2 etc` osc address to remotely enable tabs
- - remote editing through `/EXEC` command is now deprecated, use `/EDIT` and `/EDIT_SOFT` instead
-- bug fixes
- - `push` widgets (and `keyboards`) not correctly synchronizing each other (with shared widget ids or between different clients)
-- widgets
- - `css` option now supports css selectors, scoped to the widgets element
- - `matrices` don't pass `css` option to their children anymore; subwidgets' indexes are now append to `preArgs` instead of being prepended.
-- misc
- - app's title uppercased
- - tabs titles' letter-spacing increased
-
-## 0.16.5
-
-- bug fixes
- - `modal`: correct z-stacking with absolutely positionned widgets; proper rendering for inner widgets; disable parent tab's scrolling when opened; fix various style glitches;
- - `strip`: resize glitch when containing compact horizontal sliders
-
-## 0.16.4
-
-- bug fixes
- - tab links broken after activating traversing gestures
- - `push` release is now handled per touch point (releasing one finger used to release all pressed buttons)
-- misc
- - destroy default client window when the app process exits
-
-## 0.16.3
-
-- bug fixes
- - crash when remote-editing widgets in disabled tabs
- - desktop client touch screen support restored
-
-## 0.16.1
-
-- bug fixes
- - string arguments overquoted in sent osc messages
-- custom module
- - added support for initialization script
- - unified expected formatting in sendOsc and receiveOsc methods
-- ui
- - reduced scrollbars width
-
-
-## 0.16.0
-
-- new logo :)
-- bug fixes
- - editor: new widgets are correctly positionned in scrolled areas
-- widgets
- - **new** `formula` widget, a [mathjs](http://mathjs.org/) expression evaluator that can process other widgets' values
- - `multixy` supports named points; fixed drag-dead zone in the border
-
-## 0.15.1
-
-- widgets
- - multifader: add `snap` option
-- misc
- - minor css-related performance fix
- - some titles in the editor had the first-letter uppercased
-
-## 0.15.0
-
-- style
- - improved coherence, no more pure greys, better differenciation between clickable and static elements. Went back from "pure flat" to "flatty" to help with that (ie a few shadows to make layout more self-explanatory). Some widgets were slightly repimped.
-- bug fixes
- - `push`: options separators not hidden in the editor
- - error when touching a non-interractive object while touching a widget with the other fingers
-- widgets
- - `multixy` now behaves smarter: points are assigned to the closest touch points
-- main
- - modifying a session file will automatically update clients that have loaded the same file
-
-## 0.14.0
-
-- bug fixes
- - some layout regressions in chrome v49
-- main
- - osc input port (`-o`) is now set to the http port (`-p`) by default
-- widgets
- - **new** `crossfader` and `switcher` widgets that store and recall the state of other widgets
- - `matrices` now accept multiple color values (that will be sequencially passed to their children)
- - `switches` accept icons in their values' labels
-- engine
- - electron v1.4.13
-- misc
- - all widgets classes were rewritten using ES6 class expressions
- - firefox's minimal version is now 46 because of a ES6 related bug (*note that it's still not officially supported*)
-
-## 0.13.1
-
-- bug fixes
- - regression preventing received osc messages to be properly routed to widgets with `preArgs`
-- debug
- - errors occuring in the browser process are now piped to the main process' console with the source file name and the line number.
-
-## 0.13.0
-
-- main
- - **new** `-b / --blank` option to start editing a new session directly
- - **new** `--disable-vsync` option that improves performance (reduce input lag) on some systems
- - some inconsistent parameter combinations are now prevented
- - firefox compatibility improved (yet not perfect)
- - launcher window is no longer of the `splash` type, as it was difficult to close with some window managers
-- widgets
- - **new** `modal` container : a button that turns into a fullscreen panel when clicked.
- - sliders/xy: add `spring` option that makes that widget jump back to its initial value when released
- - fader: horizontal mode default height fixed
- - keyboard: black keys pressed state is more noticeable
- - matrices: added `start` option to choose the first subwidget's `id`
- - labels' height reduced
-- editor
- - **new** snap-to-grid feature
- - widgets' min-width set to grid's width
-- misc
- - building with node 4 is fixed
-
-## 0.12.0
-
-- bug fixes
- - error popups raised by the main process can be closed
- - sliders don't send same value over network when the value change is below the widget's precision
-- widgets
- - **new** (piano) keyboard widget
- - matrices: fixed `preArgs` option; added `split` option (default to `false`), *this changes the default osc messages formatting for these widgets*
- - icons in labels are inserted using the `^` prefix
- - text: icons support in value
-- tabs
- - icons support in label
-- misc
- - fontawesome update (4.7.0)
-
-## 0.11.6
-
-- widgets
- - meter: rewritten using fader as base
- - strip: center widget horizontally if width is set
- - fader/knob: compact gauge's alpha varies slightly as the distance to the origin grows
-- misc
- - one example session added
-
-## 0.11.5
-
-- bug fixes
- - [regression] broken horizontal fader and pads
-
-## 0.11.4
-
-- bug fixes
- - fader: default `height/width` not set when `top/left` is `auto`
-
-## 0.11.3
-
-- widgets
- - knob: gesture's precision is proportionnal to the widget's size
- - fader: `height:auto` (or `width` for `horizontal` mode) makes the fader expand automatically
-- ui
- - cleaner forms in editor and launcher
-
-## 0.11.2
-
-- touch
- - using multiple fingers to control a widget increases the precision (reduces the gesture's computed speed)
-- widgets
- - fader: display pips in `compact` mode when `range` has multiple breakpoints
- - pads: display pips when `range` has multiple breakpoints
- - multixy: style update (stroked dots, bold number font); `snap` option added; points are automatically assigned to touches as they come; fix `logScale(X|Y)` options
-
-## 0.11.1
-
-- bug fixes
- - meters in faders were not always properly positionned
-- widgets
- - knob: gauge's width is proportionnal to the knob's size in `compact` mode; widget's content centering fixed; `compact` style update;
-
-## 0.11.0
-
-- bug fixes
- - `-g / --no-gui` not preventing the launcher from spawning
- - `-e / --examples` not correctly parsed
-- main
- - launcher displays options descriptions for booleans too
-- widgets
- - added generic `value` option for setting a widget's initial value (does not sync linked widgets nor send osc message)
- - **text** widget's `defaultText` replaced with `value`
- - multixy dots are drawn with filled background instead of stroke
-
-## 0.10.4
-
-- main
- - launcher displays new version if available
- - launcher stays opened after starting the server and/or the gui except if `--gui-only` is set
-
-## 0.10.3
-
-- main
- - launcher: resetting boolean option properly sets it to false
- - launcher: display package's version
- - guis: adjust window's background to match the app's
-- ui
- - launcher and session lobby appear more smoothly
-
-## 0.10.2
-
-- main
- - when executing the app with no CLI argument, a launcher window is created allowing user to adjust settings before starting the server (config is saved in the user's directory)
-
-## 0.10.1
-
-- bug fixes
- - rgb: minor visual glitch on extreme value, drawing performance improved
- - main: examples sessions path are properly stored as absolute paths (fixes `-e / --examples` mode)
-- ui
- - lobby: session file names are diplayed first, then shortened paths
-- misc
- - widgets `precision` doesn't affect their visual interraction accuracy since values are now rounded only before osc sending
-
-## 0.10.0-alpha-2
-
-- bug fixes
- - [windows] fix long path issue (#35) returns
-
-## 0.10.0-alpha
-
-- main
- - **new** `-c / --custom-module` switch allowing user to define custom osc filtering fonctions
- - `address` is now used everywhere instead of `path` to describe osc address to avoid confusion. Session files using the old `path` option for widgets are still supported.
- - **osc bundles** are properly received (subsequent messages are processed separately with a delay if the timetag is set)
- - widgets can be edited via osc messages using the special `/EXEC` address
-
-## 0.9.2
-
-- bug fixes
- - [windows] fix long path issue (#35)
-
-## 0.9.1
-
-- widgets
- - multiXy: added `pointSize` option; made default size bigger; points don't overflow the pad anymore
-
-## 0.9.0
-
-- widgets
- - **new** `multixy` pad
-- misc
- - rewritten `pads` with prototype inheritance and using faders under the hood to handle events (this adds *fader*'s `range` capabilities to *xy*)
-- engine
- - electron 1.4.4
-
-## 0.8.3
-
-- bug fixes
- - scrollbar arrows not showing
- - `fader` pips position when `noPip` is `true`
-- widgets
- - matrices : all `fader`, `push` and `toggle` options are now available to `multifader`, `multipush` and `multitoggle`
-
-## 0.8.2
-
-- bug
- - avoid crash when sending osc with incorrect typetags
- - fixed fallback typetag ('s')
- - fixed broken `null` value for `push` & `toggle`
-
-## 0.8.1
-
-- bug
- - broken `fader` with `horizontal` set to `true` and `compact` set to `false`
-- widgets
- - remove margins from `plots`
- - added `origin` options to `plots`
-
-## 0.8.0
-
-- main
- - the headless server/clients model is now the only one beeing used : the GUI mode is nothing more than an embedded chromium (electron) client
- - when a new client opens a session on the server, it is synchronized with the other clients
- - **new switches** : `--no-gui`, `--gui-only`, `--port`, `--osc-port`, `--version` (see docs)
-- ui
- - explicit loadings
-- widgets
- - make push's backlight only respond to external osc messages (not to synchronization messages from other widgets or clients)
- - removed special `false` value case for push/toggles (which used to disable osc sending)
- - add `norelease` option to `push` for disabling osc messages when releasing the button
- - `true` and `false` values are now properly sent as boolean
- - **args type definition** in `preArgs` option now uses the osc typetags only ('f', 'i', 'T', 'F', etc)
-- engine
- - electron 1.4.3
-- misc
- - rewritten matrices with prototypes inheritance
-
-## 0.7.0
-
-- bug fixes
- - osc messages with 0-item and 1-item args are correctly unpacked and routed
- - buttons can handle messages with 0 arg if one of their state has the value "null"
-- ui
- - nice and bigger scrollbar
- - right-click no longer starts a dragging gesture
-- editor
- - copy/paste data auto-incrementation fix
-- widgets
- - new equalizer plotter
- - push/toggles made more obvious
- - knob's new options: angle and origin
- - fader's new option: origin
-- engine
- - electron 1.4.1 (chrome 53, node 6.5.0)
-- misc
- - added `--examples` switch for showing the availabe example sessions instead of the history
- - rewritten sliders and plots using canvas and prototypes inheritance
- - reorganized package using the two-package.json structure: js and css assets are now create at build time, and only necessary dependencies are shipped with the app
-
-## 0.6.3
-
-- bug fixes
- - regression (since 498ba4a06adf63d76fe7181691299c1cc55e8240) breaking the editor on touch devices
-
-## 0.6.2
-
-- cool stuff
- - armv7l prebuilt binaries ! (raspberry 2, etc)
-- engine
- - electron 1.3.5
-
-## 0.6.1
-
-- bug fixes
- - editor: widgets/tabs can be accessed through their parent's children list (#27)
-- engine
- - electron 1.3.1
-
-## 0.6.0
-
-- bug fixes
- - pasted widget properly use the pointer's position
- - traversing gestures are effective from the first touch, not after the first move
- - out-of-range values are properly clipped by faders/knob
-- ui
- - Faders & Meters design improved
- - The main font (droid sans) is now loaded...
- - Knob's sizing got smarter
- - Widgets don't blink not jump when they appear for the first time or when they resize
-- misc
- - Fader's `align` option replaced with boolean option `alignRight`
- - Widget's `label` now accepts special directive `icon: fontawesome-class` to display icons from [FontAwesome](http://fontawesome.io/icons/)
- - Text widget `defaultText` option added
-- engine
- - electron 1.2.2
-
-## 0.5.4
-
-- bug fixes
- - [desktop] menu bar auto-hide
- - [headless] multitouch support
-- ui
- - [mobile] better faders pips rendering
- - fixed horizontal fader knob centering
- - [mobile] better numeric inputs rendering (not blurred anymore)
-- engine
- - [desktop] electron 1.2.0 (chrome 51)
-
-## 0.5.3
-
-- bug fixes
- - [again] touch fake-right-click only fires on long touch, not after every tap
- - traversing gestures bug with touch
-- misc
- - better mouse/touch drag events handlers
-- engine
- - electron 1.1.1
-
-## 0.5.2
-
-- bug fixes
- - touch fake-right-click only fires on long touch, not after every tap
-
-## 0.5.1
-
-- bug fixes
- - feedback is now handled precisely by widets (ie not rounded according to the `precision` option, see issue #21)
-- engine
- - electron 1.1.0
-
-## 0.5.0
-
-- bug fixes
- - touch/mouse events are both handled simultaneously, module rewritten for better performances (see issue #18)
-- engine
- - electron 1.0.2
-
-
-## 0.4.8
-
-- bug fixes
- - regression preventing newly created widgets from using the pointer's coordinates as position
- - add 0.4.7's fix to headless mode
-
-## 0.4.7
-
-- bug fixes
- - regression causing widgets with `preArgs` to not receive osc correctly
-
-## 0.4.6
-
-- engine
- - electron 0.37.6
- - node-osc 2.0.3
-- features
- - `compact` option added to knob and fader
- - if an osc input port is specified, osc messages will be sent from it. This enhances compatibility with apps that send their feedback messages directly to the sender.
-- misc
- - mouse/touch dragging handler rewritten, now using event delegation and direct handler calls instead of DOM event bubbling whenever it's possible
-
-## 0.4.5
-
-- engine
- - electron 0.37.3
-- ui
- - new logo
- - better lobby design
-- misc
- - renamed sliders/pads' `absolute` property to `snap`
-
-## 0.4.4
-
-- bug fixes
- - [headless] scripts are no longer bundled on the fly, it didn't work on some systems
- - touching widgets without changing their value doesn't make them send the same value again anymore
-- ui
- - slightly tightened layout
-- features
- - `noPip` option added to knob and fader
- - `preArgs` accepts object if the arg's type needs to be specified
- - knob supports breakpoints scale, same as fader's
- - fader and knob pip scales now support custom label
- - a push/toggle's value can be set to `null` if only the path needs to be sent in the osc messages
- - push buttons do not update their own leds and return their value (for state save and widgets sync) based on their last changed property (led state or touch on/off)
-- misc
- - refining the fader's pip scale that looked choppy on mobile devices. All pips are now evenly spaced, not relatively to the fader's height.
- - [desktop mode] saved sessions are added to history
-
-## 0.4.3
-
-- features
- - text widget can be `vertical`
- - panel widget `scroll` option
-- bug fixes
- - smart pasting now works when the clipboard contains several widgets whose unsuffixed ids are the identical
- - osc received array that contain only one item are correctly unpacked (fixes cross-app sync for widgets that don't accept array, broken since the introduction of `preArgs`)
- - memory leak when loading a new session (cached tabs were not properly purged)
-- misc
- - push widget doesn't fire its 'on' value if pressed while stuck in 'on' position
- - panel widgets don't have inner margins anymore
- - fader widget optimization : the pip scale is generated from a single gradient plus some elements for each breakpoint (instead of one element per percent), thus reducing the number of elements to draw.
-
-## 0.4.2
-
-- features
- - new widget : text (just displays received values)
-- bug fixes
- - widget linking doesn't cause multiple unwanted osc sends anymore
-
-## 0.4.1
-
-- features
- - `preArgs` option for widgets (prepends constants to osc messages args)
-
-## 0.4.0
-
-- engine
- - electron 0.37.2 (chrome 49)
-- ui
- - new flat ui
- - tab system rewritten : inactive tabs are detached from the DOM tree, thus improving performances while slowing down tab switching.
- - widget categories in editor's context menu
-- features
- - logarithmic scaling (log10) support added to knob, fader & xy
- - mousewheel support added to knob and fader (ctrlKey for fine control)
- - new widgets : plot, visualizer & meter. Fader built-in feedback meter option
- - traversing gestures switch in sidepanel
- - custom color property for all widgets with inheritance (containers)
- - editor pasting function now smartly increments widget's id and path while keeping label if different from default
- - true theming support
-- misc
- - sync/link event handling improved
- - stylesheets cannot be recompiled on the fly anymore (`--c` switch removed)
- - **new state save file format, no backward compatibility**
-
-## 0.3.1
-
-- electron updated to 0.36.11
-- editor paste menu lets you choose between `Same ID` (cloned widgets) or `New ID` (resets id, label, linkId, and path)
-- minor style updates
-
-## 0.3.0
-
-- 3 new widgets
- - multifader
- - multitoggle
- - multipush
-
-
-## 0.2.1
-
-- style update (push/toggle widgets, widgets' dragging handle)
-- widget dragging/resizing doesn't get broken when editing the root
-- sidepanel toggle doesn't select root for edition anymore
-
-## 0.2.0
-
-- editor code rewriting
- - right-click context-menu quick editing (widget copy/cut/paste, add & delete tabs/widgets)
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 921666c8..00000000
--- a/Dockerfile
+++ /dev/null
@@ -1,29 +0,0 @@
-FROM node:24-alpine
-
-RUN apk --no-cache add git
-
-WORKDIR /usr/src/app
-
-COPY package*.json ./
-
-RUN npm install
-
-COPY . .
-
-RUN npm run build
-
-RUN mkdir /sessions
-RUN touch /sessions/session.json
-
-EXPOSE 8080
-
-ENV ELECTRON_RUN_AS_NODE=1
-
-ENV SEND="127.0.0.1:8080"
-ENV LOAD="/sessions/main.json"
-ENV PORT=8080
-ENV OSC_PORT=8080
-ENV READ_ONLY=false
-
-RUN chmod +x entrypoint.sh
-ENTRYPOINT ["./entrypoint.sh"]
diff --git a/Procfile b/Procfile
new file mode 100644
index 00000000..ca8f8479
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web: node index.js -n $PORT
diff --git a/README.md b/README.md
index 89da9bd5..cc05cfef 100644
--- a/README.md
+++ b/README.md
@@ -1,21 +1,56 @@
-
+# Open Stage Control
-Open Stage Control
+Open Stage Control is a libre desktop OSC bi-directionnal control surface application. It's built with HTML, JavaScript & CSS on top of [Electron](http://electron.atom.io/) framework.
-*Libre and modular OSC / MIDI controller*
+## Documentation
+
+[Read the documentation](http://jean-emmanuel.github.io/open-stage-control/)
+
+*The docs' sources are located in [resources/](resources/)*
+
+## Download
+
+Prebuilt binaries for Linux, Windows and OS X can be found on the [release](https://github.com/jean-emmanuel/open-stage-control/releases) page.
+
+## Demo
+
+You can try the app here [http://openstagecontrol.herokuapp.com/](http://openstagecontrol.herokuapp.com/)
+
+Please note that :
+
+- Chrome/Chromium **49** at least is required
+- Since there is only one instance running, all connected guests are synchronized (widgets using the same osc paths update each other's states) : you might experience some unwanted synchronization with other users unless you specify custom parameters for your widgets.
+- You might want to download the examples sessions files under *examples/* and load them in the app to get started.
-- Website: https://openstagecontrol.ammd.net/
-- Forum: https://openstagecontrol.discourse.group/
-- IRC: Libera.chat #openstagecontrol
+## Features
-----
+- mouse & multi-touch sensitive widgets
+- modular & responsive layout
+- built-in live editor
+- bi-directionnal osc bindings
+- headless server mode with any number of clients using chromium
+- app state store / recall & import / export
+- themes !
-Docker additions by Rik Berkelder.
+## Supported platforms
-mount `/sessions` directory. default session file is created and loaded there.
+Same as [Electron's supported platforms](https://github.com/electron/electron/blob/master/docs/tutorial/supported-platforms.md)
----
-Copyleft © Jean-Emmanuel Doucet 2014-2025.
-This program is a free software released under the [GNU/GPL3](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/LICENSE) license.
+## License & credits
+
+Copyleft © Jean-Emmanuel @ [AMMD](http://ammd.net). This program is released under the GNU/GPL3 license.
+
+It relies on the use of several libraries :
+
+- [Node.js](https://nodejs.org/)
+- [Electron](http://electron.atom.io/)
+- [node-osc](https://github.com/TheAlphaNerd/node-osc)
+- [socket.io](http://socket.io)
+- [browserify](http://browserify.org)
+- [express](http://expressjs.com)
+- [node-sass](https://github.com/sass/node-sass)
+- [jQuery](http://jquery.com/)
+- [jQuery-UI](http://jqueryui.com/) (draggable, resizable & sortable)
+- [Font Awesome](http://fontawesome.io/)
diff --git a/basesession.json b/basesession.json
deleted file mode 100644
index 9ddad0bb..00000000
--- a/basesession.json
+++ /dev/null
@@ -1,49 +0,0 @@
-{
- "createdWith": "Open Stage Control",
- "version": "1.31.2",
- "type": "session",
- "content": {
- "type": "root",
- "lock": false,
- "id": "root",
- "visible": true,
- "interaction": true,
- "comments": "",
- "width": "auto",
- "height": "auto",
- "colorText": "auto",
- "colorWidget": "auto",
- "alphaFillOn": "auto",
- "borderRadius": "auto",
- "padding": "auto",
- "html": "",
- "css": "",
- "colorBg": "auto",
- "layout": "default",
- "justify": "start",
- "gridTemplate": "",
- "contain": true,
- "scroll": true,
- "innerPadding": true,
- "tabsPosition": "top",
- "hideMenu": false,
- "variables": "@{parent.variables}",
- "traversing": false,
- "value": "",
- "default": "",
- "linkId": "",
- "address": "auto",
- "preArgs": "",
- "typeTags": "",
- "decimals": 2,
- "target": "",
- "ignoreDefaults": false,
- "bypass": false,
- "onCreate": "",
- "onValue": "",
- "onTouch": "",
- "onPreload": "",
- "widgets": [],
- "tabs": []
- }
-}
\ No newline at end of file
diff --git a/browser/css/style.css b/browser/css/style.css
new file mode 100644
index 00000000..c27e90a1
--- /dev/null
+++ b/browser/css/style.css
@@ -0,0 +1 @@
+:root{--color-text:rgba(255,255,255,0.8);--color-text-fade:rgba(255,255,255,0.5);--color-bg:#202329;--color-fg:#2d313a;--color-raised:#363b45;--color-faded:#292d34;--color-track:#1c1f25;--color-accent:#528bff;--nav-height:40rem;--sidepanel-size:300rem;--pixel-scale:1}*{margin:0;padding:0;border:0;box-sizing:border-box;text-decoration:none;outline:0;font:inherit;color:inherit;cursor:inherit;-webkit-tap-highlight-color:transparent;-webkit-user-select:none}::-webkit-scrollbar{width:20rem;height:20rem;opacity:1}::-webkit-scrollbar-track-piece{background:var(--color-bg)}::-webkit-scrollbar-track-piece:vertical{border-left:2rem solid var(--color-bg)}::-webkit-scrollbar-track-piece:horizontal{border-top:2rem solid var(--color-bg)}::-webkit-scrollbar-corner{background:transparent}::-webkit-scrollbar-thumb{background:var(--color-raised)}::-webkit-scrollbar-thumb:vertical{border-left:2rem solid var(--color-bg)}::-webkit-scrollbar-thumb:horizontal{border-top:2rem solid var(--color-bg)}body{background:var(--color-bg)}#container{position:absolute;top:0;left:0;bottom:0;right:0;display:flex;flex-direction:column;background:var(--color-bg);padding:2rem}#container.sidepanel-open{right:var(--sidepanel-size)}.content{height:100%;overflow:hidden;position:relative;background:var(--color-fg);padding:2rem}.tab{position:absolute;overflow:auto;left:0;right:0;top:0;bottom:0;background:var(--color-bg);transform:rotateZ(0)}.tab.has-tabs{display:flex;flex-direction:column}.tab.has-tabs>.navigation{background:var(--color-bg)}.tab.has-tabs>.content{background:none}.navigation{height:var(--nav-height);margin-bottom:2rem;flex-shrink:0;font-weight:bold;text-transform:uppercase}.navigation.main li:last-child{width:var(--nav-height);max-width:var(--nav-height);min-width:var(--nav-height)}.navigation.main li:last-child i{margin:0 auto}.navigation ul{list-style:none;display:flex;overflow:hidden;height:100%}.navigation ul li{display:block;min-width:0;flex:1;cursor:pointer;height:100%;margin-right:1rem}.navigation ul li:last-child{margin-right:0}.navigation ul li a{background:var(--color-fg);pointer-events:none;padding:5rem;height:100%;display:flex;align-items:center;overflow:hidden;text-align:center;position:relative}.navigation ul li a span{display:block;width:100%;-webkit-mask:linear-gradient(to left, transparent, #000 10rem) no-repeat}.navigation ul li a:after{content:"";background:var(--color-accent);position:absolute;bottom:0;left:0;right:0;height:1rem;opacity:0;transition:all .2s;transform:scale(0)}.navigation ul li.on a,.navigation ul li .sidepanel-open{position:relative;background:var(--color-raised)}.navigation ul li.on a:after,.navigation ul li .sidepanel-open:after{opacity:1;transform:scale(1)}.navigation ul .parent+li a{padding-left:calc(5rem + 0.5 * var(--nav-height))}.form .input-wrapper{display:flex;margin-bottom:4rem;background:var(--color-bg);align-items:center}.form .input-wrapper:last-child{margin-bottom:0}.form .input-wrapper label{background:var(--color-fg);flex-shrink:0;padding:5rem;border:1rem solid var(--color-bg)}.form .input-wrapper .input,.form .input-wrapper input{background:var(--color-bg);width:100%;padding:5rem}.form .input-wrapper.column{flex-direction:column}.form .input-wrapper.column label{width:100%;padding:7rem;margin-bottom:0}.form label{display:block;font-size:10rem;background:var(--color-faded)}.form .info{color:var(--color-text-fade);margin-bottom:10rem}.form input,.form .input{display:block;border:0;font:inherit;color:var(--color-text);width:100%}.form input:focus,.form .input:focus{border-color:var(--color-accent)}.form input .btn,.form .input .btn{background:var(--color-raised);box-shadow:0 0 0 1rem var(--color-bg)}.form .checkbox{background:var(--color-raised);cursor:pointer}.form .select-wrapper{position:relative;width:100%}.form .select-wrapper:after{content:"\f107";font-family:FontAwesome;position:absolute;padding:5rem;right:0;top:0;font-size:20rem}.form select{-webkit-appearance:none}.form .submit{margin-top:30rem}.form .separator{line-height:30rem;height:30rem;margin-bottom:5rem;position:relative;display:flex;align-items:center}.form .separator:before,.form .separator:after{content:"";top:14rem;width:100%;height:1rem;background:var(--color-text-fade)}.form .separator span{font-variant:small-caps;position:relative;display:block;width:100%;text-align:center}.widget.editing{z-index:11 !important;overflow:visible}.widget.editing:after,li.editing a:before,a.editing:before,.content.editing:before,#container.editing:before{content:"";z-index:999;position:absolute;top:0;left:0;right:0;bottom:0;border:1rem dashed var(--color-accent);pointer-events:none}.context-menu{position:fixed;z-index:999999999;background:var(--color-raised);box-shadow:0 0 4rem 0;color:var(--color-track)}.context-menu .item{color:var(--color-text)}.context-menu .context-menu{position:absolute;left:100%;top:0;opacity:0;pointer-events:none;margin-left:2rem}.context-menu .context-menu:before{content:"";position:absolute;top:0;bottom:0;left:-2rem;width:2rem}.context-menu>.item{padding:10rem 15rem 10rem 10rem;position:relative;cursor:pointer}.context-menu>.item i{margin-right:5rem;width:15rem;text-align:center}.context-menu>.item:hover,.context-menu>.item:focus{background:var(--color-accent)}.context-menu>.item:hover>.context-menu,.context-menu>.item:focus>.context-menu{pointer-events:auto;opacity:1}.context-menu>.item.has-sub:before{content:"\f105";display:block;font-family:FontAwesome;float:right;margin-right:-10rem;padding-left:10rem}.ui-resizable-handle{position:absolute;z-index:1000000;display:flex;justify-content:center;align-items:center;background:var(--color-accent);width:20rem;height:20rem;border-radius:100%;box-shadow:0 0 4rem 0 var(--color-bg)}.ui-resizable-handle:after{content:"";position:absolute;top:-5rem;right:-5rem;left:-5rem;bottom:-5rem}.ui-resizable-handle.ui-resizable-se{content:"";bottom:5rem;right:5rem;cursor:se-resize}.ui-resizable-handle.ui-resizable-se:before{content:"\f065";font-family:FontAwesome;transform:rotate(90deg)}.ui-resizable-handle.ui-resizable-e{top:50%;margin-top:-10rem;right:5rem;cursor:e-resize}.ui-resizable-handle.ui-resizable-e:before{content:"\f051";font-family:FontAwesome}.ui-resizable-handle.ui-resizable-s{bottom:5rem;left:50%;margin-left:-10rem;cursor:s-resize}.ui-resizable-handle.ui-resizable-s:before{content:"\f051";font-family:FontAwesome;transform:rotate(90deg)}.ui-helper{border:1rem dashed var(--color-accent);min-width:30rem !important;min-height:30rem !important;z-index:12 !important;opacity:1 !important}.ui-helper:after{content:"";display:block;width:100%;height:100%;background:var(--color-accent);opacity:.25}.ui-draggable-handle:not(.label){position:absolute;top:5rem;left:5rem;z-index:100000;height:20rem;width:20rem;display:flex;justify-content:center;align-items:center;border-radius:100%;background:var(--color-accent);box-shadow:0 0 4rem 0 var(--color-bg)}.ui-draggable-handle:not(.label):before{content:"\f0b2";font-family:FontAwesome;transform:rotate(45deg)}.ui-draggable-handle{cursor:-webkit-grab}.ui-draggable-handle:active{cursor:-webkit-grabbing}#sidepanel{position:absolute;z-index:999999;width:var(--sidepanel-size);border:8rem solid var(--color-fg);top:0;right:0;bottom:0;margin-right:calc(-1 * var(--sidepanel-size));background:var(--color-fg);transition:transform .25s, opacity .25s;transform:translate3d(0, 0, 0);opacity:0;overflow-y:auto;overflow-x:visible}#sidepanel.sidepanel-open{transform:translate3d(calc(-1 * var(--sidepanel-size)), 0, 0);opacity:1}#sidepanel #options{position:absolute;left:0;top:0;right:0;bottom:0;list-style:none}#sidepanel #options li{display:block;margin-bottom:8rem;position:relative}#sidepanel #options li:last-child{margin:0}#sidepanel #options li .btn+span{position:absolute;right:0rem;top:0rem;padding:8rem;color:var(--color-text-fade)}#sidepanel #options li .btn+span:hover{color:var(--color-text)}#sidepanel #options li ul{padding:4rem}#sidepanel #options li ul li{margin-bottom:4rem}#sidepanel #options .editor .form{margin-top:10rem}#sidepanel #options .help{margin-top:10rem;font-size:.75em;text-align:center;font-style:italic}#sidepanel::-webkit-scrollbar-track-piece{background:var(--color-bg)}#sidepanel::-webkit-scrollbar-track-piece:vertical{border-left:8rem solid var(--color-fg)}#sidepanel::-webkit-scrollbar-thumb{background:var(--color-raised)}#sidepanel::-webkit-scrollbar-thumb:vertical{border-left:8rem solid var(--color-fg)}.actions{padding:1rem;background:var(--color-bg);display:flex;align-items:stretch;flex-wrap:wrap}.actions .title{background:var(--color-faded);min-width:100%;flex-grow:2;padding:10rem;position:relative}.actions .title:before{content:"";position:absolute;top:0;left:0;right:0;bottom:0;box-shadow:0 0 0 1rem;color:var(--color-bg)}.actions a{min-width:33%;flex-grow:4;padding:10rem;display:block;text-align:center;position:relative;color:var(--color-text);overflow:visible}.actions a.on{pointer-events:none}.actions a.on:after{opacity:1;transform:scale(1)}.actions a:before{content:"";position:absolute;top:0;left:0;right:0;bottom:0;box-shadow:0 0 0 1rem;color:var(--color-bg)}.actions a:after{content:"";background:var(--color-accent);position:absolute;top:0;left:0;right:0;height:1rem;opacity:0;transition:all .2s;transform:scale(0)}.widget{display:inline-block;height:auto;overflow:hidden;position:relative;vertical-align:top;box-shadow:-0.5rem -0.5rem 0 0.5rem;color:var(--color-bg);border-right:1rem solid var(--color-bg);border-bottom:1rem solid var(--color-bg);background:var(--color-fg);-webkit-tap-highlight-color:transparent;min-height:30rem;min-width:30rem;display:inline-flex;flex-direction:column}.widget>*{color:var(--color-text)}.widget.absolute-position{position:absolute}.widget.nolabel>.label{display:none}.widget .label{padding:10rem 10rem;text-overflow:ellipsis;overflow:hidden;text-align:center;height:35rem;max-height:35rem;width:100%;background:var(--color-faded);border-bottom:1rem solid var(--color-bg)}.widget .label.accent{color:var(--color-accent)}.widget .input{width:100%;height:30rem;border:0;background:transparent;color:var(--color-text-fade);display:block;padding:7rem 5rem;position:relative;display:var(--display-input)}.widget .input input{position:absolute;top:0;left:0;right:0;bottom:0;padding:7rem 5rem;width:100%;font:inherit;text-align:center;border:0;background:transparent;color:var(--color-accent)}.widget .input canvas{width:100%;height:100%;opacity:0.8}.widget .input input+canvas{visibility:hidden}.widget .input:focus{color:var(--color-accent)}.widget .input[disabled]{color:var(--color-text-fade)}.fader-container{--color-custom:var(--color-accent);--color-pips:var(--color-text-fade);--color-gauge:var(--color-custom);--color-knob:var(--color-custom);width:100rem;min-height:200rem;height:100%}.fader-container.align-right .fader-wrapper .fader{margin-left:calc(50% + 10rem)}.fader-container.align-right .fader-wrapper .meter-container{right:auto;left:-13rem !important}.fader-container.align-right .fader-wrapper .pips{margin-left:-20rem}.fader-container.align-right .fader-wrapper .pips .pip{right:0;left:auto}.fader-container.align-right .fader-wrapper .pips .pip span{right:3rem;left:auto}.fader-container.align-right.compact .fader-wrapper-outer .fader-wrapper .fader .meter-container{left:0 !important;right:auto !important}.fader-container.align-right.compact .has-meter .input{left:calc(50% + 2rem)}.fader-container.compact .fader-wrapper-outer .input{position:absolute;top:50%;transform:rotate(-90deg);pointer-events:none;width:100rem;margin-left:-50rem;left:50%;z-index:3}.fader-container.compact .fader-wrapper-outer .fader-wrapper{padding:1rem 0 0 !important;background:var(--color-track)}.fader-container.compact .fader-wrapper-outer .fader-wrapper .fader{width:100%;margin:0}.fader-container.compact .fader-wrapper-outer .fader-wrapper .fader:before{content:none}.fader-container.compact .fader-wrapper-outer .fader-wrapper .fader .gauge{opacity:.25}.fader-container.compact .fader-wrapper-outer .fader-wrapper .fader .knob{width:100%;height:1rem;background:var(--color-knob)}.fader-container.compact .fader-wrapper-outer .fader-wrapper .fader .knob:before,.fader-container.compact .fader-wrapper-outer .fader-wrapper .fader .knob:after{display:none}.fader-container.compact .fader-wrapper-outer .fader-wrapper .fader .pips{display:none}.fader-container.compact .fader-wrapper-outer .fader-wrapper .fader .meter-container{right:-1rem !important;left:auto !important;width:4rem;top:-2rem}.fader-container.compact .has-meter .input{left:calc(50% - 2rem)}.fader-container .input{margin-top:-5rem}.fader-container .fader-wrapper-outer{display:flex;flex-direction:column;flex:1}.fader-container .fader-wrapper{padding:20rem;flex:1;overflow:hidden;position:relative;display:flex;flex-direction:column;cursor:-webkit-grab}.fader-container .fader-wrapper:active{cursor:-webkit-grabbing}.fader-container .fader-wrapper .fader{width:2rem;position:relative;margin:0 auto;margin-right:calc(50% + 15rem);pointer-events:none;flex:1}.fader-container .fader-wrapper .fader:before{content:"";width:100%;height:100%;background:var(--color-track);z-index:1;display:block;box-shadow:0 0 0 15rem;color:var(--color-fg);position:absolute}.fader-container .fader-wrapper .fader .gauge{position:absolute;bottom:0 !important;top:0 !important;width:100%;height:100%;transform-origin:bottom;max-height:100%;max-width:100%;background:var(--color-gauge);z-index:1}.fader-container .fader-wrapper .fader .knob{position:absolute;bottom:0;width:0;height:0;z-index:2}.fader-container .fader-wrapper .fader .knob:before{content:"";position:absolute;top:-4rem;left:-3rem;height:8rem;width:8rem;background:var(--color-knob);border:none !important;border-radius:100% !important}.fader-container .fader-wrapper .fader .knob:after{content:"";position:absolute;top:-10rem;left:-9rem;height:20rem;width:20rem;border:none !important;border-radius:100% !important;background:var(--color-knob);opacity:.2}.fader-container .fader-wrapper .fader .meter-container{position:absolute;z-index:2;left:auto;right:-15rem;bottom:0;top:0;min-width:0;min-height:0;width:4rem;background:var(--color-bg);height:auto}.fader-container .fader-wrapper .fader .meter-container .meter{margin:0}.fader-container .fader-wrapper .pips{position:absolute;top:0;bottom:0;left:50%;z-index:0;width:4rem;margin-left:17rem;background:linear-gradient(to bottom, transparent 0, transparent 2px, var(--color-pips) 2px, var(--color-pips) 3px, transparent 3px, transparent 5px);background-size:100% 5px;background-repeat:repeat-y}.fader-container .fader-wrapper .pips .pip{height:1px;background:var(--color-pips);color:var(--color-fg);position:absolute;width:8rem;left:0}.fader-container .fader-wrapper .pips .pip:before{content:"";position:absolute;top:-4px;left:0;right:0;bottom:-4px;background:var(--color-fg);z-index:-1}.fader-container .fader-wrapper .pips .pip span{position:absolute;width:30rem;display:block;text-align:center;font-size:10rem;line-height:12rem;left:3rem;top:-5.5rem;color:var(--color-pips)}.fader-container .fader-wrapper.no-pip .pips{display:none !important}.fader-container .fader-wrapper.no-pip .fader{margin:0 auto}.fader-container.horizontal{min-height:80rem;height:auto;width:300rem;flex-shrink:0}.fader-container.horizontal.compact .fader-wrapper-outer .input{transform:none;top:50%;margin-top:-15rem}.fader-container.horizontal.compact .fader-wrapper-outer .fader-wrapper{display:flex;flex:1;padding:0 1rem 0 0 !important}.fader-container.horizontal.compact .fader-wrapper-outer .fader{height:100%;top:0}.fader-container.horizontal.compact .fader-wrapper-outer .fader .knob{width:1rem;height:100%;margin-bottom:0;bottom:0}.fader-container.horizontal.compact .fader-wrapper-outer .fader .meter-container{top:0;left:0 !important;right:-1px !important;width:auto;height:4rem}.fader-container.horizontal .fader-wrapper-outer{position:relative;top:auto;justify-content:center;overflow:hidden}.fader-container.horizontal .fader-wrapper-outer .fader-wrapper{padding:20rem 20rem 40rem;display:block;flex:0;flex-shrink:0}.fader-container.horizontal .fader-wrapper-outer .fader-wrapper.no-pip{padding:20rem}.fader-container.horizontal .fader-wrapper-outer .fader{width:100%;left:auto;top:50%;height:2rem}.fader-container.horizontal .fader-wrapper-outer .fader:before{box-shadow:none}.fader-container.horizontal .fader-wrapper-outer .fader .gauge{transform-origin:left}.fader-container.horizontal .fader-wrapper-outer .fader .meter-container{top:-15rem;left:0;right:0;bottom:auto;height:1rem;min-width:0;min-height:0;width:auto;height:4rem}.fader-container.horizontal .fader-wrapper-outer .fader .knob{bottom:1px}.fader-container.horizontal .fader-wrapper-outer .pips{top:15rem;left:0;right:0;font-size:0;height:4rem;width:100%;margin:0;background:linear-gradient(to right, transparent 0, transparent 2px, var(--color-pips) 2px, var(--color-pips) 3px, transparent 3px, transparent 5px);background-size:5px 100%;background-repeat:repeat-x}.fader-container.horizontal .fader-wrapper-outer .pip{width:1px;height:6rem;margin:0}.fader-container.horizontal .fader-wrapper-outer .pip:before{top:0;bottom:0;left:-4px;right:-4px}.fader-container.horizontal .fader-wrapper-outer .pip span{top:15rem;left:-15rem !important;right:auto}.fader-container.horizontal.compact .has-meter .input{top:calc(50% + 2rem)}.knob-container{--color-custom:var(--color-accent);--color-pips:var(--color-text-fade);--color-gauge:var(--color-custom);--color-knob:var(--color-custom);width:100rem;height:150rem;align-items:center;flex-shrink:0}.knob-container.compact .pips{display:none}.knob-container.compact .input{position:absolute;top:50%;margin-top:-15rem;left:22%;right:22%;width:auto;pointer-events:none}.knob-container.compact .knob-wrapper-outer{position:relative}.knob-container.compact .knob-wrapper{padding:10% 0 !important}.knob-container.compact .knob:before{display:none}.knob-container .knob-wrapper-outer{width:100%;display:flex;flex:1;flex-direction:column;align-items:center;justify-content:center;overflow:hidden}.knob-container .knob-wrapper-outer .input{flex-shrink:0}.knob-container .knob-wrapper-outer .knob-wrapper{padding:15rem 0 15rem;margin:0 auto;width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:0;position:relative;cursor:-webkit-grab}.knob-container .knob-wrapper-outer .knob-wrapper:active{cursor:-webkit-grabbing}.knob-container .knob-wrapper-outer .knob-wrapper.no-pip{padding-bottom:0}.knob-container .knob-wrapper-outer .knob-wrapper.no-pip .pips{display:none}.knob-container .knob-wrapper-outer .knob-wrapper .knob-mask{width:58%;padding-bottom:58%;flex-shrink:0;border-radius:100%;pointer-events:none;position:relative}.knob-container .knob-wrapper-outer .knob-wrapper .knob-mask:before{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:100%;border:2rem solid var(--color-track);transform:rotate(45deg);z-index:4}.knob-container .knob-wrapper-outer .knob-wrapper .knob-mask:after{content:"";position:absolute;top:0rem;left:-3rem;right:-3rem;bottom:-2rem;border-radius:100%;border:12rem solid transparent;border-bottom-color:var(--color-fg);z-index:4}.knob-container .knob-wrapper-outer .knob-wrapper .knob{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;transform:rotateZ(0deg);backface-visibility:hidden;z-index:2}.knob-container .knob-wrapper-outer .knob-wrapper .knob:before{content:"";position:absolute;top:17rem;left:17rem;right:17rem;bottom:17rem;border-radius:100%;background-color:var(--color-raised)}.knob-container .knob-wrapper-outer .knob-wrapper .knob:after{content:"";position:absolute;top:0;left:0;right:0;bottom:0;border-radius:100%;border:2rem solid var(--color-track);border-bottom-color:var(--color-gauge)}.knob-container .knob-wrapper-outer .knob-wrapper .knob.d2:after{border-right-color:var(--color-gauge)}.knob-container .knob-wrapper-outer .knob-wrapper .knob.d3:after{border-top-color:var(--color-gauge);border-right-color:var(--color-gauge)}.knob-container .knob-wrapper-outer .knob-wrapper .handle{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;transform:rotateZ(-45deg);backface-visibility:hidden;z-index:5}.knob-container .knob-wrapper-outer .knob-wrapper .handle:before{content:"";position:absolute;top:50%;left:-3rem;margin-top:-4rem;height:8rem;width:8rem;background:var(--color-knob);border:none !important;border-radius:100% !important}.knob-container .knob-wrapper-outer .knob-wrapper .handle:after{content:"";position:absolute;top:50%;margin-top:-10rem;left:-9rem;height:20rem;width:20rem;border:none !important;border-radius:100% !important;background:var(--color-knob);opacity:.2}.knob-container .knob-wrapper-outer .knob-wrapper .pips{width:100%;pointer-events:none;height:0}.knob-container .knob-wrapper-outer .knob-wrapper .pip{font-size:11rem;color:var(--color-pips);display:inline-block}.knob-container .knob-wrapper-outer .knob-wrapper .pip.min{width:50%;text-align:center}.knob-container .knob-wrapper-outer .knob-wrapper .pip.max{width:50%;text-align:center}.multitoggle-container,.multipush-container,.multifader-container{height:200rem;width:200rem}.multitoggle-container.nolabel .matrix,.multipush-container.nolabel .matrix,.multifader-container.nolabel .matrix{top:0}.matrix{flex:1;overflow:auto;background:var(--color-bg);display:flex;flex-wrap:wrap;flex-direction:row;margin-right:-1rem;margin-bottom:-1rem}.matrix>.widget{min-height:0;min-width:0;margin:0 !important}.matrix>.widget .label{background:none;border:0}.multifader-container .matrix{padding:0 !important;align-items:stretch}.multifader-container .widget{height:auto}.multifader-container .fader-wrapper{padding:10rem 0 20rem !important}.multifader-container .fader-wrapper .fader{left:0 !important}.xy-container,.rgb-container{--color-custom:var(--color-accent);width:200rem;height:250rem;flex-shrink:0;display:flex}.xy-wrapper{height:100%;overflow:hidden;display:flex;flex-direction:column}.xy-wrapper .value{width:100%;display:var(--display-input)}.xy-wrapper .input{width:50%;float:left;height:30rem;text-align:center;position:relative}.xy{position:relative;width:auto;height:100%;overflow:hidden;cursor:-webkit-grab;background:var(--color-faded)}.xy:active{cursor:-webkit-grabbing}.xy .handle{position:absolute;bottom:0;left:0;z-index:2;pointer-events:none;backface-visibility:hidden;transform-origin:center;transform:translate3d(0, 0, 0)}.xy .handle:before{content:"";position:absolute;top:-4rem;right:-4rem;height:8rem;width:8rem;background:var(--color-custom);border:none !important;border-radius:100% !important}.xy .handle:after{content:"";position:absolute;top:-10rem;right:-10rem;height:20rem;width:20rem;border:none !important;border-radius:100% !important;background:var(--color-custom);opacity:.2}.rgb-wrapper .input,.rgb-wrapper input{width:33.33%}.rgb .bg{position:absolute;top:0;left:0;right:0;bottom:0;background-color:red;opacity:.75;pointer-events:none}.rgb .bg:before,.rgb .bg:after{content:"";position:absolute;left:0;top:0;width:100%;height:100%}.rgb .bg:before{background:linear-gradient(to right, #fff 0%, rgba(255,255,255,0) 100%)}.rgb .bg:after{background:linear-gradient(to bottom, transparent 0%, #000 100%)}.rgb .handle:before{content:"";position:absolute;top:-4rem;right:-4rem;height:8rem;width:8rem;background:var(--color-text);border:none !important;border-radius:100% !important}.rgb .handle:after{content:"";position:absolute;top:-10rem;right:-10rem;height:20rem;width:20rem;border:none !important;border-radius:100% !important;background:var(--color-text)}.hue{width:auto;min-height:30rem;overflow:hidden;cursor:-webkit-grab;position:relative;flex-shrink:0}.hue .bg{position:absolute;top:0;left:0;right:0;bottom:0;opacity:0.5;background:transparent linear-gradient(to left, red, #FF0080, #f0f, #8000FF, blue, #0080FF, cyan, #00FF80, lime, #80FF00, #ff0, #FF8000, red) repeat scroll 0% 0%;pointer-events:none}.hue:active{cursor:-webkit-grabbing}.hue .handle{position:absolute;z-index:2;left:0;top:50%;pointer-events:none;transform:translate3d(0, 0, 0)}.hue .handle:before{content:"";position:absolute;top:-4rem;right:-4rem;height:8rem;width:8rem;border:none !important;border-radius:100% !important;box-shadow:none;background:var(--color-text)}.led-container{--color-custom:var(--color-accent);width:100rem;flex-shrink:0}.led-container .led{display:flex;align-items:center;height:100%;padding:10rem 0;overflow:hidden}.led-container .led div{border-radius:100%;width:calc(100% - 20rem);padding-bottom:calc(100% - 20rem);margin:0 auto;background:var(--color-track);position:relative}.led-container .led div span{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:100%;display:block;background-color:var(--color-custom)}.led-container .led div span:after{content:"";border-radius:100%;position:absolute;top:-1rem;left:-1rem;right:-1rem;bottom:-1rem;display:block;border:6rem solid var(--color-fg);opacity:0.8}.plot-container,.visualizer-container{--color-custom:var(--color-accent);height:200rem;width:200rem}.plot-container .plot,.visualizer-container .plot{display:flex;flex-direction:row;flex:1;position:relative}.plot-container canvas,.visualizer-container canvas{position:absolute;top:0;left:0;width:100%;height:100%}.meter-container{--color-custom:var(--color-accent);--color-gauge:var(--color-custom);height:100rem}.meter-container .meter{display:flex;flex-direction:row;flex:1;position:relative;background:var(--color-track)}.meter-container .meter .level{width:100%;flex:1;transform-origin:bottom;background:var(--color-custom)}.meter-container .meter::after{content:"";position:absolute;top:0;left:0;bottom:0;right:0;background-image:linear-gradient(transparent 1px, var(--color-fg) 1px, var(--color-fg) 2px);background-size:100% 2px;background-repeat:repeat}.meter-container .meter.horizontal::after{background-image:linear-gradient(to left, transparent 1px, var(--color-fg) 1px, var(--color-fg) 2px);background-size:2px 100%}.meter-container .meter.horizontal .level{transform-origin:left}.text-container{--color-custom:var(--color-accent)}.text-container .text{flex:1;height:35rem;padding:10rem;justify-content:center;display:flex;align-items:center;background:var(--color-faded);color:var(--color-custom)}.text-container .text.vertical{transform:rotate(180deg);text-overflow:ellipsis;overflow:hidden;-webkit-writing-mode:vertical-lr}.toggle-container{--color-custom:var(--color-accent);width:100rem;min-height:65rem;flex-shrink:0;padding:0 !important;background:var(--color-raised);cursor:pointer}.toggle-container .label{position:absolute;top:1rem;left:0;right:0;bottom:0;height:auto;max-height:initial;border:0;background:none !important;text-align:center;pointer-events:none;display:flex;justify-content:center;align-items:center}.toggle{position:absolute;top:0;left:0;right:0;bottom:0}.toggle .light{position:absolute;left:2rem;right:2rem;top:2rem;height:2rem;pointer-events:none;background:var(--color-custom)}.toggle .light:after{content:"";width:100%;height:100%;display:block;background:var(--color-track)}.toggle.on .light:after{display:none}.push-container{--color-custom:var(--color-accent);width:100rem;min-height:65rem;flex-shrink:0;padding:0 !important;background:var(--color-raised);cursor:pointer}.push-container .label{position:absolute;top:0;left:0;right:0;bottom:0;height:auto;max-height:initial;border:0;background:none !important;text-align:center;pointer-events:none;display:flex;justify-content:center;align-items:center;z-index:1}.push-container .push.active{background:var(--color-fg)}.push-container .push .light{position:absolute;left:auto;background:var(--color-custom);height:4rem;width:4rem;border-radius:4rem;overflow:hidden}.switch-container{--color-custom:var(--color-accent);width:100rem;flex-shrink:0}.switch-container .switch{height:100%;width:100%;cursor:pointer;display:flex;flex-direction:column;align-items:stretch;flex:1}.switch-container .switch.horizontal{flex-direction:row}.switch-container .switch.horizontal .value{padding:28rem 6rem 6rem 6rem;text-align:center;display:flex;justify-content:center;flex-direction:column;border-top:0;border-right:1rem solid var(--color-bg);flex:1;height:auto}.switch-container .switch.horizontal .value:last-child{border-right:0}.switch-container .switch.horizontal .value:before{left:50%;top:8rem;width:8rem;height:8rem;margin-left:-4rem;margin-top:0}.switch-container .switch .value{background:var(--color-raised);color:var(--color-text);width:100%;height:100%;position:relative;border-top:1rem solid var(--color-bg);padding:12rem 12rem 12rem 24rem;white-space:normal;text-align:left;word-break:break-all;overflow:hidden;display:flex;flex-direction:column;justify-content:center}.switch-container .switch .value:first-child{border-top:0}.switch-container .switch .value:last-child{margin-bottom:0}.switch-container .switch .value:before{content:"";position:absolute;left:8rem;top:50%;width:8rem;height:8rem;margin-top:-4rem;background:var(--color-track);border-radius:8rem}.switch-container .switch .value.on:before{background:var(--color-custom)}.strip-container{width:100rem;height:100%;overflow:visible;border:0}.strip-container:before{content:"";position:absolute;top:0;bottom:0;right:0;left:0;pointer-events:none;z-index:2}.strip-container>.strip{height:100%;display:flex;flex-direction:column}.strip-container>.strip>.widget{width:auto;margin:0;box-shadow:none}.strip-container.vertical>.strip>.widget{max-width:100%}.strip-container.vertical::before{border-right:1rem solid var(--color-bg)}.strip-container.horizontal{width:100%;height:200rem;display:flex;flex-direction:row}.strip-container.horizontal::before{border-bottom:1rem solid var(--color-bg)}.strip-container.horizontal>.strip{flex-direction:row;flex:1}.strip-container.horizontal>.strip>.widget{flex-shrink:initial;width:100%;min-height:100%;max-height:100%;height:100%}.strip-container.horizontal>.label{width:35rem;height:100%;border-bottom:0;border-right:1rem solid var(--color-bg);max-height:initial}.strip-container.horizontal>.label span{transform:rotate(180deg);display:block;position:relative;overflow:hidden;text-overflow:ellipsis;-webkit-writing-mode:vertical-lr;text-align:center;height:100%}.panel-container{width:200rem;height:200rem;border:0;background:var(--color-faded)}.panel-container:before{content:"";position:absolute;top:0;bottom:0;right:0;left:0;border-bottom:1rem solid var(--color-bg);border-right:1rem solid var(--color-bg);pointer-events:none;z-index:2}.panel-container ::-webkit-scrollbar-thumb,.panel-container ::-webkit-scrollbar-track-piece{border-top:1rem solid var(--color-bg)}.panel-container.nolabel .panel{top:0}.panel-container .panel{overflow:auto;position:absolute;top:35rem;left:0;right:0;bottom:0}.panel-container .panel.has-tabs{display:flex;flex-direction:column;background:var(--color-bg)}.panel-container .panel.noscroll{overflow:hidden}.panel-container .panel.noscroll>.widget{max-width:100%;max-height:100%}.panel-container .navigation{border-top:0;background:transparent}.panel-container .navigation:after{background:var(--color-bg)}.panel-container .navigation a.on{border-color:var(--color-bg)}.panel-container .content{background:transparent}input:focus::selection{background:var(--color-accent);color:var(--color-text)}input{cursor:text}html,body{height:100%;overflow:hidden;position:relative}html{font-size:calc(var(--pixel-scale) * 1px);max-height:999999px}body{font-size:13rem;line-height:16rem;font-family:Droid Sans;color:var(--color-text);white-space:nowrap;opacity:1;cursor:default}i{font-size:14rem !important}.btn{background:var(--color-raised);display:block;padding:15rem;position:relative;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;cursor:pointer}.btn.small{padding:8rem;padding-right:15rem}.btn.warning{background:firebrick}.btn.disabled{pointer-events:none;color:var(--color-text-fade)}.btn.align-center{text-align:center}#lobby{background:var(--color-bg);position:absolute;top:0;left:0;right:0;bottom:0;z-index:2;display:flex;align-items:center;justify-content:center;overflow-y:auto;padding:20rem}#lobby .main{width:600rem;max-width:100%;max-height:100%;display:flex;flex-direction:column}#lobby .list{flex:1;overflow:auto;background:var(--color-fg);border-top:2rem solid var(--color-bg)}#lobby .header{padding:20rem;white-space:nowrap;text-overflow:ellipsis;flex-grow:0;background-color:var(--color-faded);color:var(--color-accent);font-size:16rem;line-height:24rem}#lobby .footer{background:var(--color-raised);white-space:nowrap;text-overflow:ellipsis;flex-grow:0;background:var(--color-faded);border-top:2rem solid var(--color-bg)}#lobby a{display:block;padding-right:35rem;overflow:hidden;padding-top:15rem;position:relative;white-space:nowrap;text-overflow:ellipsis;background:none;border-bottom:1rem solid var(--color-bg)}#lobby a:hover{background:var(--color-raised)}#lobby a:last-child{border-bottom:0}#lobby a span{position:absolute;right:0rem;top:0rem;padding:15rem;color:var(--color-text-fade)}#loading{position:absolute;top:50%;left:50%;margin-top:-15rem;text-align:center}#loading .spinner{display:block;margin:0 auto;height:30rem;width:30rem;border-radius:50%;border:2rem solid var(--color-track);border-top-color:var(--color-accent);animation:spin .5s linear infinite}#loading #status{margin-top:10rem;display:inline-block}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.popup{position:fixed;top:0;left:0;right:0;bottom:0;padding:10%;display:flex;align-items:center;z-index:1000000}.popup:before{content:"";position:absolute;top:0;left:0;right:0;bottom:0;background:var(--color-bg);opacity:.5}.popup .popup-title{position:relative;padding:15rem;background:var(--color-raised)}.popup .popup-title .closer{position:absolute;right:0rem;top:0;padding:15rem;color:var(--color-text-fade);cursor:pointer}.popup .popup-wrapper{display:flex;flex-direction:column;align-items:stretch;background:var(--color-fg);width:auto;max-width:600rem;margin:0 auto;position:relative;overflow:hidden;border:1rem solid var(--color-track)}.popup .popup-wrapper .popup-content{height:100%;width:100%;padding:10rem;overflow-y:auto;white-space:normal}
diff --git a/browser/favicon.ico b/browser/favicon.ico
new file mode 120000
index 00000000..4057c25b
--- /dev/null
+++ b/browser/favicon.ico
@@ -0,0 +1 @@
+../resources/images/logo.ico
\ No newline at end of file
diff --git a/browser/fonts/droid-sans.css b/browser/fonts/droid-sans.css
new file mode 100644
index 00000000..c35e4b1a
--- /dev/null
+++ b/browser/fonts/droid-sans.css
@@ -0,0 +1,6 @@
+@font-face {
+ font-family: 'Droid Sans';
+ font-style: normal;
+ font-weight: 400;
+ src: local('Droid Sans'), local('DroidSans'), url('droid-sans.woff2') format('woff2');
+}
diff --git a/browser/fonts/droid-sans.woff2 b/browser/fonts/droid-sans.woff2
new file mode 100644
index 00000000..79b4b8d3
Binary files /dev/null and b/browser/fonts/droid-sans.woff2 differ
diff --git a/browser/fonts/font-awesome.min.css b/browser/fonts/font-awesome.min.css
new file mode 100644
index 00000000..79af8f65
--- /dev/null
+++ b/browser/fonts/font-awesome.min.css
@@ -0,0 +1,4 @@
+/*!
+ * Font Awesome 4.6.3 by @davegandy - http://fontawesome.io - @fontawesome
+ * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)
+ */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.woff2?v=4.6.3') format('woff2');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left{margin-right:.3em}.fa.fa-pull-right{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-feed:before,.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper-pp:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-resistance:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-y-combinator-square:before,.fa-yc-square:before,.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-intersex:before,.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-genderless:before{content:"\f22d"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}.fa-yc:before,.fa-y-combinator:before{content:"\f23b"}.fa-optin-monster:before{content:"\f23c"}.fa-opencart:before{content:"\f23d"}.fa-expeditedssl:before{content:"\f23e"}.fa-battery-4:before,.fa-battery-full:before{content:"\f240"}.fa-battery-3:before,.fa-battery-three-quarters:before{content:"\f241"}.fa-battery-2:before,.fa-battery-half:before{content:"\f242"}.fa-battery-1:before,.fa-battery-quarter:before{content:"\f243"}.fa-battery-0:before,.fa-battery-empty:before{content:"\f244"}.fa-mouse-pointer:before{content:"\f245"}.fa-i-cursor:before{content:"\f246"}.fa-object-group:before{content:"\f247"}.fa-object-ungroup:before{content:"\f248"}.fa-sticky-note:before{content:"\f249"}.fa-sticky-note-o:before{content:"\f24a"}.fa-cc-jcb:before{content:"\f24b"}.fa-cc-diners-club:before{content:"\f24c"}.fa-clone:before{content:"\f24d"}.fa-balance-scale:before{content:"\f24e"}.fa-hourglass-o:before{content:"\f250"}.fa-hourglass-1:before,.fa-hourglass-start:before{content:"\f251"}.fa-hourglass-2:before,.fa-hourglass-half:before{content:"\f252"}.fa-hourglass-3:before,.fa-hourglass-end:before{content:"\f253"}.fa-hourglass:before{content:"\f254"}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:"\f255"}.fa-hand-stop-o:before,.fa-hand-paper-o:before{content:"\f256"}.fa-hand-scissors-o:before{content:"\f257"}.fa-hand-lizard-o:before{content:"\f258"}.fa-hand-spock-o:before{content:"\f259"}.fa-hand-pointer-o:before{content:"\f25a"}.fa-hand-peace-o:before{content:"\f25b"}.fa-trademark:before{content:"\f25c"}.fa-registered:before{content:"\f25d"}.fa-creative-commons:before{content:"\f25e"}.fa-gg:before{content:"\f260"}.fa-gg-circle:before{content:"\f261"}.fa-tripadvisor:before{content:"\f262"}.fa-odnoklassniki:before{content:"\f263"}.fa-odnoklassniki-square:before{content:"\f264"}.fa-get-pocket:before{content:"\f265"}.fa-wikipedia-w:before{content:"\f266"}.fa-safari:before{content:"\f267"}.fa-chrome:before{content:"\f268"}.fa-firefox:before{content:"\f269"}.fa-opera:before{content:"\f26a"}.fa-internet-explorer:before{content:"\f26b"}.fa-tv:before,.fa-television:before{content:"\f26c"}.fa-contao:before{content:"\f26d"}.fa-500px:before{content:"\f26e"}.fa-amazon:before{content:"\f270"}.fa-calendar-plus-o:before{content:"\f271"}.fa-calendar-minus-o:before{content:"\f272"}.fa-calendar-times-o:before{content:"\f273"}.fa-calendar-check-o:before{content:"\f274"}.fa-industry:before{content:"\f275"}.fa-map-pin:before{content:"\f276"}.fa-map-signs:before{content:"\f277"}.fa-map-o:before{content:"\f278"}.fa-map:before{content:"\f279"}.fa-commenting:before{content:"\f27a"}.fa-commenting-o:before{content:"\f27b"}.fa-houzz:before{content:"\f27c"}.fa-vimeo:before{content:"\f27d"}.fa-black-tie:before{content:"\f27e"}.fa-fonticons:before{content:"\f280"}.fa-reddit-alien:before{content:"\f281"}.fa-edge:before{content:"\f282"}.fa-credit-card-alt:before{content:"\f283"}.fa-codiepie:before{content:"\f284"}.fa-modx:before{content:"\f285"}.fa-fort-awesome:before{content:"\f286"}.fa-usb:before{content:"\f287"}.fa-product-hunt:before{content:"\f288"}.fa-mixcloud:before{content:"\f289"}.fa-scribd:before{content:"\f28a"}.fa-pause-circle:before{content:"\f28b"}.fa-pause-circle-o:before{content:"\f28c"}.fa-stop-circle:before{content:"\f28d"}.fa-stop-circle-o:before{content:"\f28e"}.fa-shopping-bag:before{content:"\f290"}.fa-shopping-basket:before{content:"\f291"}.fa-hashtag:before{content:"\f292"}.fa-bluetooth:before{content:"\f293"}.fa-bluetooth-b:before{content:"\f294"}.fa-percent:before{content:"\f295"}.fa-gitlab:before{content:"\f296"}.fa-wpbeginner:before{content:"\f297"}.fa-wpforms:before{content:"\f298"}.fa-envira:before{content:"\f299"}.fa-universal-access:before{content:"\f29a"}.fa-wheelchair-alt:before{content:"\f29b"}.fa-question-circle-o:before{content:"\f29c"}.fa-blind:before{content:"\f29d"}.fa-audio-description:before{content:"\f29e"}.fa-volume-control-phone:before{content:"\f2a0"}.fa-braille:before{content:"\f2a1"}.fa-assistive-listening-systems:before{content:"\f2a2"}.fa-asl-interpreting:before,.fa-american-sign-language-interpreting:before{content:"\f2a3"}.fa-deafness:before,.fa-hard-of-hearing:before,.fa-deaf:before{content:"\f2a4"}.fa-glide:before{content:"\f2a5"}.fa-glide-g:before{content:"\f2a6"}.fa-signing:before,.fa-sign-language:before{content:"\f2a7"}.fa-low-vision:before{content:"\f2a8"}.fa-viadeo:before{content:"\f2a9"}.fa-viadeo-square:before{content:"\f2aa"}.fa-snapchat:before{content:"\f2ab"}.fa-snapchat-ghost:before{content:"\f2ac"}.fa-snapchat-square:before{content:"\f2ad"}.fa-pied-piper:before{content:"\f2ae"}.fa-first-order:before{content:"\f2b0"}.fa-yoast:before{content:"\f2b1"}.fa-themeisle:before{content:"\f2b2"}.fa-google-plus-circle:before,.fa-google-plus-official:before{content:"\f2b3"}.fa-fa:before,.fa-font-awesome:before{content:"\f2b4"}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}
diff --git a/browser/fonts/fontawesome-webfont.woff2 b/browser/fonts/fontawesome-webfont.woff2
new file mode 100644
index 00000000..7eb74fd1
Binary files /dev/null and b/browser/fonts/fontawesome-webfont.woff2 differ
diff --git a/browser/index-headless.html b/browser/index-headless.html
new file mode 100644
index 00000000..0abeffbe
--- /dev/null
+++ b/browser/index-headless.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/index.html b/browser/index.html
new file mode 100644
index 00000000..b4f3437a
--- /dev/null
+++ b/browser/index.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/js/app.js b/browser/js/app.js
new file mode 100644
index 00000000..81ac09bf
--- /dev/null
+++ b/browser/js/app.js
@@ -0,0 +1,54 @@
+///////////////////////
+
+WIDGETS = {}
+WIDGETS_LINKED = {}
+WIDGETS_BY_PATH = {}
+SESSION = []
+STATE = []
+
+CLIPBOARD = null
+EDITING = false
+
+TRAVERSING = false
+
+TABS = {}
+
+
+MISC = {
+ iterators: {
+ widget:{},
+ tab:{}
+ }
+}
+
+
+PXSCALE = getComputedStyle(document.documentElement).getPropertyValue("--pixel-scale")
+INITIALZOOM = PXSCALE
+
+
+///////////////////////
+
+$ = jQuery = require('./jquery/jquery.min')
+require('./jquery/jquery.ui')
+require('./jquery/jquery.drag')
+require('./jquery/jquery.resize')
+require('./jquery/jquery.fake-input')
+
+///////////////////////
+
+var callbacks = require('./app/callbacks')
+
+var bindCallback = function(i) {
+ IPC.on(i,function(event,data){
+ callbacks[i](event,data)
+ })
+}
+
+for (i in callbacks) {
+ bindCallback(i)
+}
+
+///////////////////////
+
+
+IPC.send('ready')
diff --git a/browser/js/app/actions.js b/browser/js/app/actions.js
new file mode 100644
index 00000000..9c1d2c13
--- /dev/null
+++ b/browser/js/app/actions.js
@@ -0,0 +1,156 @@
+module.exports = {
+
+ stateQuickSave: function(preset){
+ if (preset) {
+ STATE = preset
+ } else {
+ STATE = module.exports.stateGet()
+ }
+ $('.quickload').removeClass('disabled')
+ },
+
+ stateQuickLoad: function(){
+ module.exports.stateSet(STATE,true)
+ },
+
+ stateSave: function() {
+ state = JSON.stringify(module.exports.stateGet(),null,' ')
+ if (WEBFRAME) {
+ IPC.send('stateSave',state)
+ } else {
+ var down = $(' ')
+ var blob = new Blob([state],{type : 'text/plain'});
+ down.attr('href', window.URL.createObjectURL(blob))
+ down[0].click()
+ }
+
+ },
+
+ stateGet: function (){
+ var data = []
+ for (i in WIDGETS) {
+ var widget = WIDGETS[i]
+ for (var j=widget.length-1;j>=0;j--) {
+ if (widget[j].setValue && widget[j].getValue) {
+ var v = widget[j].getValue()
+ if (v!=undefined) data.push([i,v])
+ break
+ }
+ }
+ }
+ return data
+ },
+
+ stateLoad: function() {
+ if (WEBFRAME) {
+ IPC.send('stateLoad')
+ } else {
+ var prompt = $(' ')
+ prompt.click()
+ prompt.on('change',function(e){
+ var reader = new FileReader();
+ reader.onloadend = function(e) {
+ var preset = e.target.result
+ module.exports.stateSet(JSON.parse(preset),true)
+ STATE = preset
+ }
+ reader.readAsText(e.target.files[0],'utf-8');
+ })
+ }
+ },
+
+ stateSend: function(){
+ var data = module.exports.stateGet()
+ module.exports.stateSet(data,true)
+
+ },
+
+ stateSet: function(preset,send){
+
+ for (i in preset) {
+ var data = preset[i]
+ if (WIDGETS[data[0]]!=undefined) {
+ for (var i=WIDGETS[data[0]].length-1;i>=0;i--) {
+ if (WIDGETS[data[0]][i].setValue) {
+ WIDGETS[data[0]][i].setValue(data[1],send,false)
+ }
+ }
+ }
+ }
+ },
+
+ toggleFullscreen: function(){
+
+ if (WEBFRAME) {
+ IPC.send('fullscreen')
+ } else {
+ var isInFullScreen = document.webkitIsFullScreen
+
+ if (isInFullScreen) {
+ document.webkitExitFullscreen()
+ } else {
+ document.documentElement.webkitRequestFullScreen()
+ }
+ }
+ },
+
+ sessionBrowse: function(){
+
+ if (WEBFRAME) {
+ IPC.send('sessionBrowse')
+ } else {
+ var prompt = $(' ')
+ prompt.click()
+ prompt.on('change',function(e){
+ var reader = new FileReader();
+ reader.onloadend = function(e) {
+ var session = e.target.result
+ IPC.send('sessionOpen',{file:session})
+ }
+ reader.readAsText(e.target.files[0],'utf-8');
+ })
+ }
+ },
+
+ sessionSave: function() {
+ var sessionfile = JSON.stringify(SESSION,null,' ')
+ if (WEBFRAME) {
+ IPC.send('sessionSave',sessionfile)
+ } else {
+ var down = $(' ')
+ var blob = new Blob([sessionfile],{type : 'text/plain'});
+ down.attr('href', window.URL.createObjectURL(blob))
+ down[0].click()
+ }
+
+ },
+
+ editorEnable: function(){
+ $('.editor-root').attr('data-tab','#container').removeClass('disabled')
+ $('.enable-editor').addClass('on')
+ $('.disable-editor').removeClass('on')
+
+ EDITING = true
+ },
+ editorDisable: function(){
+ $('.widget.ui-resizable').resizable('destroy')
+ $('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
+ $('.editing').removeClass('editing')
+ $('.editor-root').addClass('disabled')
+ $('.editor-container').remove()
+ $('.disable-editor').addClass('on')
+ $('.enable-editor').removeClass('on')
+
+ EDITING = false
+ },
+
+ traversingDisable: function(){
+ $('.traversingEnable, .traversingDisable').toggleClass('on')
+ $(document).trigger('disableTraversingGestures')
+ },
+ traversingEnable: function(){
+ $('.traversingEnable, .traversingDisable').toggleClass('on')
+ $(document).enableTraversingGestures()
+ }
+
+}
diff --git a/browser/js/app/callbacks.js b/browser/js/app/callbacks.js
new file mode 100644
index 00000000..549722cc
--- /dev/null
+++ b/browser/js/app/callbacks.js
@@ -0,0 +1,102 @@
+var init = require('./init'),
+ actions = require('./actions'),
+ utils = require('./utils'),
+ icon = utils.icon
+
+module.exports = {
+
+ receiveOsc: function(event,data){
+ var data = data || event
+
+ // fetch ids corresponding to the osc path
+ var path = data.path,
+ pathref = path,
+ args = data.args
+
+ if (typeof data.args == 'object') {
+ for (var i=data.args.length-1;i>=0;i--) {
+ var ref = path+'||||'+data.args.slice(0,i).join('||||')
+ if (WIDGETS_BY_PATH[ref]) {
+ pathref = ref
+ args = data.args.slice(i,data.args.length)
+ args = args.length==1?args[0]:args
+ continue
+ }
+ }
+ } else {
+ args = data.args
+ }
+ for (i in WIDGETS_BY_PATH[pathref]) {
+ if (WIDGETS_BY_PATH[pathref][i]) WIDGETS_BY_PATH[pathref][i].setValue(args,false,true)
+ }
+
+
+ },
+
+ stateLoad: function(event,data){
+ var data = data || event
+ data = JSON.parse(data)
+ actions.stateSet(data,true)
+ actions.stateQuickSave(data)
+ },
+
+ sessionList: function(event,data){
+ var data = data || event
+ $('#lobby').append(`
+ `)
+
+ for (i in data) {
+ $('#lobby .list').append(''+data[i]+''+icon('remove')+' ')
+ }
+ $('#lobby .footer').append(''+icon('folder-open')+' Browse ')
+ $('#lobby .footer').append(''+icon('file-o')+' New ')
+ $('#lobby .load').click(function(e){
+ e.stopPropagation()
+ IPC.send('sessionOpen',{path:$(this).data('session')})
+ })
+ $('#lobby a span').click(function(e){
+ e.stopPropagation()
+ IPC.send('sessionRemoveFromHistory',$(this).parent().data('session'))
+ $(this).parents('a').remove()
+ })
+ $('#lobby .browse').click(function(e){
+ e.stopPropagation()
+ actions.sessionBrowse()
+ })
+ $('#lobby .new').click(function(e){
+ e.stopPropagation()
+ init([{}],function(){$('#open-toggle, .enable-editor').click();$('.editor-root').trigger('mousedown.editor')})
+ })
+ },
+
+ sessionOpen: function(event,data){
+ var data = data || event
+ var session = JSON.parse(data)
+ init(session)
+
+ },
+
+ error: function(event,data){
+ var data = data || event
+
+ utils.createPopup(icon('warning')+' '+data.title,data.text)
+ },
+
+ applyStyle: function(event,data){
+ var data = data || event
+ var style = document.createElement('style');
+ style.innerHTML = data.join('');
+ document.body.appendChild(style);
+ if (data.indexOf('--pixel-scale')!=-1) {
+ PXSCALE = data.match(/--pixel-scale\s*:\s*([^;]*)/)[1]
+ INITIALZOOM = PXSCALE
+ }
+ }
+
+}
diff --git a/browser/js/app/editor/context-menu.js b/browser/js/app/editor/context-menu.js
new file mode 100644
index 00000000..fac69ec0
--- /dev/null
+++ b/browser/js/app/editor/context-menu.js
@@ -0,0 +1,59 @@
+var correctPosition = function (m, parent){
+ var pos = m.offset(),
+ width = m.outerWidth(),
+ height = m.outerHeight(),
+ totalWidth = $('body').outerWidth(),
+ totalHeight = $('body').outerHeight(),
+ leftAdjust = parent=='body'?0:parent.outerWidth()-2
+
+ if (width + pos.left > totalWidth) {
+ m.css({'margin-left':totalWidth-(width + pos.left + leftAdjust)})
+ }
+ if (height + pos.top > totalHeight) {
+ m.css({'margin-top':totalHeight-(height + pos.top)})
+ }
+}
+
+var ev = 'fake-click'
+
+
+var menu = function(e,actions,parent){
+
+ var m = $('')
+ if (parent=='body') {
+ m.css({top:e.pageY+'px',left:e.pageX+'px'})
+ }
+
+ for (label in actions) {
+
+ if (typeof actions[label] == 'object') {
+
+ var item = $(`${label}
`).appendTo(m).on(ev,function(e){e.stopPropagation()})
+ menu(e,actions[label],item)
+
+
+ } else {
+
+ $(`${label}
`).on(ev + '.editor',function(){
+ var callback = actions[label]
+ return function(e){
+ callback()
+ $('.context-menu').remove()
+ }
+ }()).appendTo(m)
+ }
+ }
+
+ m.appendTo(parent)
+
+
+
+ if (parent=='body') {
+ correctPosition(m,parent)
+ } else {
+ parent.hover(function(){correctPosition(m,parent)})
+ }
+
+}
+
+module.exports = menu
diff --git a/browser/js/app/editor/data-workers.js b/browser/js/app/editor/data-workers.js
new file mode 100644
index 00000000..73e9d13d
--- /dev/null
+++ b/browser/js/app/editor/data-workers.js
@@ -0,0 +1,170 @@
+var widgets = require('../widgets'),
+ widgetOptions = widgets.widgetOptions,
+ sync = widgets.sync,
+ parser = require('../parser')
+ parsewidgets = parser.widgets,
+ parsetabs = parser.tabs,
+ ui = require('../ui'),
+ actions = require('../actions'),
+ sidepanelCreateToggle = require('../sidepanel').createToggle,
+ editObject = function(a,b){require('./edit-objects').editObject(a,b,true)},
+ editSession = function(a,b){require('./edit-objects').editSession(a,b,true)},
+ purgeStores = require('./purge')
+
+
+var getObjectData = function(obj){
+ var path = []
+
+ if (obj.hasClass('tab')) {
+ return TABS['#'+obj.attr('id')].data
+ }
+
+ if (obj.is('#container')) {
+ return SESSION
+ }
+
+ while(true) {
+ if (obj.hasClass('widget')) {
+ path.unshift(obj.index())
+ path.unshift('widgets')
+ } else if (obj.hasClass('tab')){
+ path.unshift(obj.data('index'))
+ path.unshift('tabs')
+ } else if (obj.is('#container')) {
+ break
+ }
+
+ obj = obj.parent()
+ }
+
+ path.splice(0,1)
+
+ for (var i=0,data=SESSION, path=path, len=path.length; i${data.label} `)
+
+ editObject(newContainer,data)
+
+ } else if (container.attr('id')=='container') {
+ // session
+ var newContainer = $('#container')
+ container.empty()
+ parsetabs(data,container,true)
+
+ editSession(newContainer,data)
+ sidepanelCreateToggle()
+
+ }
+
+ newContainer.find('[data-tab]:first-child').click()
+
+ $(window).resize()
+
+ purgeStores(purgetabs)
+
+ // restore state
+ actions.stateSet(state,false)
+ sync()
+ ui.scrolls()
+ $('#sidepanel').scrollTop(scroll)
+
+
+ // return updated node
+ return newContainer
+
+}
+
+
+var incrementWidget = function(data){
+
+ if (!data) return
+
+ delete data.linkId
+
+ var id = data.id,
+ label = data.label,
+ path = data.path
+
+ if (id && id==label) {
+ data.label = 'auto'
+ }
+ if (id && path == '/'+id) {
+
+ data.path = 'auto'
+
+ } else if (path){
+ var pathref
+ while (WIDGETS_BY_PATH[pathref]) {
+ path = path.replace(/([0-9]*)$/,function(m){
+ var n = parseInt(m)+1
+ n = isNaN(n)?1:n
+ return n
+ })
+ pathref = data.preArgs&&data.preArgs.length?data.path+'||||'+data.preArgs.join('||||'):data.path
+ }
+ WIDGETS_BY_PATH[pathref] = []
+ data.path = path
+
+ }
+
+ if (id) {
+ while (WIDGETS[id]) {
+ id = id.replace(/([0-9]*)$/,function(m){
+ var n = parseInt(m)+1
+ n = isNaN(n)?1:n
+ return n
+ })
+ }
+ WIDGETS[id] = []
+ data.id = id
+
+ }
+
+
+ for (i in data) {
+ if (typeof data[i] == 'object') data[i] = incrementWidget(data[i])
+ }
+
+ return data
+
+}
+
+module.exports = {
+ updateDom:updateDom,
+ getObjectData:getObjectData,
+ incrementWidget:incrementWidget
+}
diff --git a/browser/js/app/editor/edit-objects.js b/browser/js/app/editor/edit-objects.js
new file mode 100644
index 00000000..8bffcaad
--- /dev/null
+++ b/browser/js/app/editor/edit-objects.js
@@ -0,0 +1,310 @@
+var updateDom = require('./data-workers').updateDom,
+ widgetOptions = require('../widgets').widgetOptions
+
+var ev = 'fake-click'
+
+
+var editObject = function(container, data, refresh){
+
+ if (!refresh && (container.hasClass('editing') || $(`a[data-tab="#${container.attr('id')}"]`).hasClass('editing'))) return
+
+ var isWidget = container.hasClass('widget')
+
+ $('.editing').removeClass('editing')
+ $('.widget.ui-resizable').resizable('destroy')
+ $('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
+
+
+ if (isWidget) {
+ $(container).addClass('editing')
+ } else {
+ $(`[data-tab="#${container.attr('id')}"]`).addClass('editing').click()
+ $(container).parent().addClass('editing')
+ }
+
+
+
+ $('.editor-container').remove()
+ $('.editor').append('
')
+ var form = $('
').appendTo('.editor-container')
+
+
+ var params = isWidget?widgetOptions[data.type]:{label:''}
+
+ for (i in params) {
+
+ if (i.indexOf('separator')!=-1) {
+ $(`${params[i]}
`).appendTo(form)
+ continue
+ } else if (data[i]===undefined) {
+ continue
+ }
+
+ // Common options edit
+ if (i!='widgets' && i!='tabs') {
+
+ var type = typeof data[i],
+ value = type == 'object'?JSON.stringify(data[i]):data[i],
+ wrapper = $('
').appendTo(form),
+ label = $(`${i} `).appendTo(wrapper),
+ input
+
+ if (i=='type') {
+
+ input = $(` `)
+
+ for (t in widgetOptions) {
+ input.append(`${t} `)
+ }
+ select = $('
').append(input)
+ select.appendTo(wrapper)
+
+ } else if (typeof params[i]=='boolean') {
+
+ input = $(` `)
+ input.click(function(){
+ $(this).val(!eval($(this).val())).trigger('change')
+ })
+ input.appendTo(wrapper)
+
+ } else {
+
+ input = $(` `)
+ input.appendTo(wrapper)
+
+ }
+
+
+ input.on('change',function(){
+ // var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
+ var v
+ try {
+ eval(`v=${$(this).val()}`)
+ } catch(err) {
+ v = $(this).val()
+ }
+
+ data[$(this).attr('title')] = v
+ if (v==='') delete data[$(this).attr('title')]
+ updateDom(container,data)
+ })
+
+ }
+
+ }
+
+ // widget list edit
+ if (((isWidget&&widgetOptions[data.type].widgets) || (container.hasClass('tab'))) && (!data.tabs||!data.tabs.length)) {
+
+ var list = $(''),
+ wrapper = $('
').appendTo(form)
+
+ var editItem = function(i) {
+ return function(){
+ container.find('.widget').first().siblings().addBack().eq(i).trigger(ev)
+ }
+ }
+
+ for (i in data.widgets) {
+
+
+ var item = $(`${data.widgets[i].id||data.widgets[i].label} `)
+ .appendTo(list)
+ .click(editItem(i))
+
+ var remove = $(' ')
+ .appendTo(item)
+ .click(function(e){
+ e.stopPropagation()
+ data.widgets.splice($(this).parent().attr('data-index'),1)
+ updateDom(container,data)
+ })
+ }
+
+ list.sortable({
+ forcePlaceholderSize: true,
+ items: '.sortables',
+ start:function(){$(this).sortable( "refreshPositions" )},
+ update: function(e,ui){
+ var prevIndex = $(ui.item).attr('data-index')
+ var newIndex = $(ui.item).index()
+
+ data.widgets.splice(newIndex, 0, data.widgets.splice(prevIndex, 1)[0])
+
+ updateDom(container,data)
+ }
+ })
+
+ var add = $(`+ `).appendTo(list).click(function(){
+ data.widgets = data.widgets || []
+ data.widgets.push({})
+
+ updateDom(container,data)
+ })
+
+ $('widgets ').appendTo(wrapper)
+ list.appendTo(wrapper)
+
+ }
+
+ // tab list edit
+ if (((isWidget&&widgetOptions[data.type].tabs) || (container.hasClass('tab'))) && (!data.widgets||!data.widgets.length)) {
+ //tabs
+ var list = $(''),
+ wrapper = $('
').appendTo(form)
+
+
+ var editItem = function(i) {
+ return function(){
+ container.find('.tab').first().siblings().addBack().eq(i).trigger(ev)
+ }
+ }
+
+ for (i in data.tabs) {
+ var item = $(`${data.tabs[i].label} `)
+ .appendTo(list)
+ .click(editItem(i))
+
+ var remove = $(' ')
+ .appendTo(item)
+ .click(function(e){
+ e.stopPropagation()
+ data.tabs.splice($(this).parent().attr('data-index'),1)
+ updateDom(container,data)
+ })
+ }
+
+ list.sortable({
+ start:function(){$(this).sortable( "refreshPositions" )},
+ forcePlaceholderSize: true,
+ items: '.sortables',
+ update: function(e,ui){
+ var prevIndex = $(ui.item).attr('data-index')
+ var newIndex = $(ui.item).index()
+
+ data.tabs.splice(newIndex, 0, data.tabs.splice(prevIndex, 1)[0])
+
+ updateDom(container,data)
+ }
+ })
+
+ var add = $(`+ `).appendTo(list).click(function(){
+ data.tabs = data.tabs || []
+ data.tabs.push({})
+
+ updateDom(container,data)
+ })
+
+ $('tabs ').appendTo(wrapper)
+ list.appendTo(wrapper)
+ }
+
+ if (data.hasOwnProperty('width')) {
+ var handleTarget
+ container.resizable({
+ handles:'s, e, se',
+ helper: "ui-helper",
+ start: function(event, ui){
+ handleTarget = $(event.originalEvent.target)
+ },
+ stop: function( event, ui ) {
+ if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-s')) data.height = Math.max(ui.size.height,30)/PXSCALE
+ if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-e')) data.width = Math.max(ui.size.width,30)/PXSCALE
+ updateDom(container,data)
+ }
+ })
+ }
+
+ if (data.hasOwnProperty('top')) {
+ container.draggable({
+ cursor:'-webkit-grabbing',
+ stop: function( event, ui ) {
+ event.preventDefault()
+ data.top = (ui.helper.position().top + container.parent().scrollTop())/PXSCALE
+ data.left = (ui.helper.position().left + container.parent().scrollLeft())/PXSCALE
+ ui.helper.remove()
+ updateDom(container,data)
+ },
+ handle:'.ui-draggable-handle, > .label',
+ snap:'.widget',
+ snapTolerance:5,
+ helper:function(){return $('
').css({height:container.outerHeight(),width:container.outerWidth()})}
+ }).append('
')
+ }
+
+}
+
+var editSession = function(container,data,refresh){
+
+ if (!refresh && $('.editor-root').hasClass('editing')) return
+
+ $('.widget.ui-resizable').resizable('destroy')
+ $('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
+
+
+ $('.editing').removeClass('editing')
+ $('.editor-root, #container').addClass('editing')
+
+ $('.editor-container').remove()
+ $('.editor').append('
')
+
+
+ var form = $('
').appendTo('.editor-container'),
+ list = $(''),
+ wrapper = $('
').appendTo(form)
+
+
+ var editItem = function(i) {
+ return function(){
+ container.find('.tab').first().siblings().addBack().eq(i).trigger(ev)
+ }
+ }
+
+ for (i in data) {
+ var item = $(`${data[i].label} `)
+ .appendTo(list)
+ .click(editItem(i))
+
+ var remove = $(' ')
+ .appendTo(item)
+ .click(function(e){
+ e.stopPropagation()
+ data.splice($(this).parent().attr('data-index'),1)
+ updateDom(container,data)
+ })
+ }
+
+
+ list.sortable({
+ start:function(){$(this).sortable( "refreshPositions" )},
+ forcePlaceholderSize: true,
+ items: '.sortables',
+ update: function(e,ui){
+ var prevIndex = $(ui.item).attr('data-index')
+ var newIndex = $(ui.item).index()
+
+ data.splice(newIndex, 0, data.splice(prevIndex, 1)[0])
+
+ updateDom(container,data)
+ }
+ })
+
+ var add = $(`+ `).appendTo(list).click(function(){
+ data = data || []
+ data.push({})
+
+ updateDom(container,data)
+ })
+
+ $('tabs ').appendTo(wrapper)
+ list.appendTo(wrapper)
+
+
+ $('.editor-container').append(form)
+
+}
+
+module.exports = {
+ editObject:editObject,
+ editSession:editSession
+}
diff --git a/browser/js/app/editor/init.js b/browser/js/app/editor/init.js
new file mode 100644
index 00000000..8103c259
--- /dev/null
+++ b/browser/js/app/editor/init.js
@@ -0,0 +1,182 @@
+var data = require('./data-workers'),
+ getObjectData = data.getObjectData,
+ updateDom = data.updateDom,
+ incrementWidget = data.incrementWidget,
+ edit = require('./edit-objects'),
+ editObject = edit.editObject,
+ editSession = edit.editSession,
+ createPopup = require('../utils').createPopup,
+ widgetOptions = require('../widgets').widgetOptions,
+ widgetCategories = require('../widgets').categories,
+ menu = require('./context-menu')
+
+
+
+var init = function(){
+
+ $('body').off('.editor').on('fake-click fake-right-click',function(e,d){
+
+ if (!EDITING) return
+
+ // ignore mouse event when fired by a simulated touch event
+ if (e.type=='mousedown' && e.originalEvent.sourceCapabilities.firesTouchEvents) return
+
+ $('.context-menu').remove()
+
+ var target = $(e.target).is('.widget:not(.not-editable), .tab, [data-tab], #container')?
+ $(e.target):
+ $(e.target).closest('.widget:not(.not-editable), .tab, [data-tab], #container')
+
+ if (!target.length) return
+
+ var container = target.attr('data-tab')?TABS[target.attr('data-tab')].tab:target,
+ type = target.hasClass('widget')?'widget':'tab',
+ parent = container.parent(),
+ index = container.index(),
+ data = getObjectData(container)
+
+ if (container.attr('id')=='container') {
+ editSession(container,SESSION)
+ } else {
+ editObject(container,data)
+ }
+
+
+ if (e.type!='fake-right-click') return
+
+ if (container.attr('id')=='container') {
+ menu(d,{
+ ' Add tab': function(){
+ data.push({})
+ updateDom(container,data)
+ }
+ },'body')
+
+ return
+ }
+
+
+ var actions = {}
+
+ // actions[' Edit'] = function(){editObject(container,data)}
+
+ if (type=='widget') actions[' Copy'] = function(){CLIPBOARD=data}
+
+ if (type=='widget') actions[' Cut'] = function(){
+ CLIPBOARD=JSON.parse(JSON.stringify(data))
+ var parentContainer = container.parents('.widget, .tab, #container').first()
+ parentData = getObjectData(parentContainer)
+
+ parentData.widgets.splice(container.index(),1)
+ updateDom(parentContainer,parentData)
+ }
+
+ if (((type=='widget'&&widgetOptions[data.type].widgets) || (type=='tab')) && (!data.tabs||!data.tabs.length)) {
+
+ if (CLIPBOARD!=null) {
+ actions[' Paste'] = {
+ ' ID + 1':function(){
+ data.widgets = data.widgets || []
+ var newData = incrementWidget(JSON.parse(JSON.stringify(CLIPBOARD)))
+
+
+ if (!target.attr('data-tab')) {
+ newData.top = d.offsetY
+ newData.left= d.offsetX
+ } else {
+ delete newData.top
+ delete newData.left
+ }
+
+ data.widgets.push(newData)
+ updateDom(container,data)
+ },
+ ' Clone':function(){
+ data.widgets = data.widgets || []
+ var newData = JSON.parse(JSON.stringify(CLIPBOARD))
+ if (!target.attr('data-tab')) {
+ newData.top = d.offsetY
+ newData.left= d.offsetX
+ } else {
+ delete newData.top
+ delete newData.left
+ }
+ data.widgets.push(newData)
+ updateDom(container,data)
+ }
+ }
+ }
+
+ actions[' Add widget'] = {}
+ var createFunction = function(widgetType,container,data){
+ return function() {
+ data.widgets = data.widgets || []
+ var newData = {type:widgetType}
+ if (!target.attr('data-tab')) {
+ newData.top = d.offsetY
+ newData.left= d.offsetX
+ }
+ data.widgets.push(newData)
+ updateDom(container,data)
+ }
+ }
+ for (category in widgetCategories) {
+ actions[' Add widget'][category] = {}
+ for (t in widgetCategories[category]) {
+ var wtype = widgetCategories[category][t]
+ actions[' Add widget'][category][wtype] = createFunction(wtype,container,data)
+
+ }
+ }
+
+ }
+ if (((type=='widget'&&widgetOptions[data.type].tabs) || (type=='tab')) && (!data.widgets||!data.widgets.length)) {
+
+ actions[' Add tab'] = function(){
+ data.tabs = data.tabs || []
+ data.tabs.push({})
+ updateDom(container,data)
+ }
+
+ }
+
+ actions[' Delete'] = function(){
+ var popup = createPopup('Are you sure ?',`
+
+ `)
+ $('.confirm-delete').click(function(){
+ popup.close()
+ var parentContainer = container.parents('.widget, .tab, #container').first()
+ parentData = getObjectData(parentContainer)
+
+
+ if (type=='widget') {
+ parentData.widgets.splice(container.index(),1)
+ } else if (type=='tab' && parentContainer.attr('id')!='container') {
+ parentData.tabs.splice(container.data('index'),1)
+ } else {
+ parentData.splice(container.data('index'),1)
+ }
+
+ updateDom(parentContainer,parentData)
+ })
+ $('.cancel-delete').click(function(){
+ popup.close()
+ })
+ $(document).on('keydown.popup', function(e){
+ if (e.keyCode==13) $('.confirm-delete').click()
+ })
+
+
+ }
+
+ menu(d,actions,'body')
+
+ })
+
+}
+
+module.exports = init
diff --git a/browser/js/app/editor/purge.js b/browser/js/app/editor/purge.js
new file mode 100644
index 00000000..ab37f3d0
--- /dev/null
+++ b/browser/js/app/editor/purge.js
@@ -0,0 +1,70 @@
+module.exports = function(purgetabs) {
+
+ // prune tabs store
+ var count, newcount, formerBuffuredTabs, bufferedTabs
+
+ if (purgetabs) {
+ while (true) {
+ // we need to do that several times since tabs are referenced in each of their parents
+
+ // get all buffered tabs
+ formerBuffuredTabs = []
+ for (i in TABS) {
+ formerBuffuredTabs.push(TABS[i].tab[0])
+ }
+
+ // remove deleted tabs that are not referenced (have no navigation link pointing to them)
+ var $f = $(formerBuffuredTabs)
+ for (i in TABS) {
+ if (!($f.find(`[data-tab="${i}"]`).length || i== '#container')) {
+ delete TABS[i]
+ }
+ }
+
+ newcount = Object.keys(TABS).length
+ if (count == newcount) break
+ count = newcount
+
+ }
+ }
+
+
+ bufferedTabs = []
+ for (i in TABS) {
+ bufferedTabs.push(TABS[i].tab[0])
+ }
+
+ // prune widget stores
+ // if widgets cannot be found in buffered tabs, it must be unreferenced
+ var $b = $(bufferedTabs)
+ for (i in WIDGETS) {
+ for (var j=WIDGETS[i].length-1;j>=0;j--) {
+ if (!$b.find(WIDGETS[i][j]).length) {
+ WIDGETS[i].splice(j,1)
+ }
+ }
+ if (!WIDGETS[i].length) {
+ delete WIDGETS[i]
+ }
+ }
+ for (i in WIDGETS_LINKED) {
+ for (var j=WIDGETS_LINKED[i].length-1;j>=0;j--) {
+ if (!$b.find(WIDGETS_LINKED[i][j]).length) {
+ WIDGETS_LINKED[i].splice(j,1)
+ }
+ }
+ if (!WIDGETS_LINKED[i].length) {
+ delete WIDGETS_LINKED[i]
+ }
+ }
+ for (i in WIDGETS_BY_PATH) {
+ for (var j=WIDGETS_BY_PATH[i].length-1;j>=0;j--) {
+ if (!$b.find(WIDGETS_BY_PATH[i][j]).length) {
+ WIDGETS_BY_PATH[i].splice(j,1)
+ }
+ }
+ if (!WIDGETS_BY_PATH[i].length) {
+ delete WIDGETS_BY_PATH[i]
+ }
+ }
+}
diff --git a/browser/js/app/init.js b/browser/js/app/init.js
new file mode 100644
index 00000000..60497957
--- /dev/null
+++ b/browser/js/app/init.js
@@ -0,0 +1,42 @@
+var parsetabs = require('./parser').tabs,
+ ui = require('./ui'),
+ sync = require('./widgets').sync,
+ editorDisable = require('./actions').editorDisable,
+ editorInit = require('./editor/init')
+
+module.exports = function(session,callback) {
+
+ $('#lobby').remove()
+ $('#container').empty()
+ var spinner = $('').appendTo('#container')
+
+ setTimeout(function(){
+ parsetabs(session,$('#container'),true)
+
+ // var t = $('
').appendTo('body')
+ // for (id in TABS) {
+ // if (id!='#container') {
+ // t[0].appendChild(TABS[id].tab[0])
+ // }
+ // }
+ // setTimeout(function(){
+ // t.detach()
+ // },250)
+
+
+ ui.init()
+ editorDisable()
+ editorInit()
+ sync()
+
+
+ setTimeout(function(){
+ spinner.remove()
+ if (!callback) return
+ setTimeout(function(){
+ callback()
+ },25)
+ },25)
+ },25)
+
+}
diff --git a/browser/js/app/parser.js b/browser/js/app/parser.js
new file mode 100644
index 00000000..9331a1ed
--- /dev/null
+++ b/browser/js/app/parser.js
@@ -0,0 +1,184 @@
+var widgets = require('./widgets'),
+ widgetOptions = widgets.widgetOptions,
+ createWidget = widgets.createWidget,
+ icon = require('./utils').icon
+
+var getIterator = function(id,type){
+ var iterator = MISC.iterators[type]
+ if (iterator[id]==undefined) iterator[id] = 0
+ iterator[id] += 1
+ return iterator[id]
+}
+
+var hashCode = function(s){
+ return s.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
+}
+
+module.exports.tabs = function(data,parent,main,parentLabel){
+
+ if (main) {
+ // Reset Globals
+ WIDGETS = {}
+ WIDGETS_LINKED = {}
+ WIDGETS_BY_PATH = {}
+ SESSION = data
+ for (i in TABS) {
+ if (i!='#container') {
+ TABS[i].parent.remove()
+ TABS[i].tab.remove()
+ }
+ }
+ TABS['#container'] = {
+ tab:$('#container')
+ }
+
+ MISC.iterators.tab = {}
+ }
+
+ var main = main?'main ':'',
+ nav = $(document.createElement('div')).addClass(main + 'navigation'),
+ navtabs = $(document.createElement('ul')).addClass('tablist'),
+ content = $(document.createElement('div')).addClass('content')
+
+
+ for (i in data) {
+ var tabData = data[i]
+
+
+ var label = tabData.label||tabData.id||'Unnamed',
+ hash = hashCode(label),
+ id = 'tab_'+hash+'_'+getIterator('tab'+hash,'tab')
+
+ tabData.label = label
+ delete tabData.id
+
+ navtabs.append(`${label} `)
+
+ var tabContent = $(`
`)
+ tabContent.data(tabData)
+
+
+ if (tabData.tabs && tabData.tabs.length) {
+ module.exports.tabs(tabData.tabs,tabContent,false,label)
+ } else if (tabData.widgets && tabData.widgets.length) {
+ module.exports.widgets(tabData.widgets,tabContent)
+ }
+
+ // content.append(tabContent)
+ TABS['#'+id]= {
+ parent:content,
+ tab:tabContent,
+ data:tabData
+ }
+
+ }
+
+ nav[0].appendChild(navtabs[0])
+ parent[0].appendChild(nav[0])
+ parent[0].appendChild(content[0])
+}
+
+
+
+module.exports.widgets = function(data,parent) {
+
+ for (i in data) {
+ var widgetData = data[i]
+
+ widgetData.type = widgetData.type || 'fader'
+
+ var tmpWidgetOptions = JSON.parse(JSON.stringify(widgetOptions))
+
+ for (i in tmpWidgetOptions[widgetData.type]) {
+ if (i.indexOf('separator')==-1 && widgetData[i]===undefined) widgetData[i] = tmpWidgetOptions[widgetData.type][i]
+ }
+
+ if (widgetData.id=='auto') {
+ var id
+ while (!id || WIDGETS[id]) {
+ id=widgetData.type+'_'+getIterator(widgetData.type,'widget')
+ }
+ widgetData.id = id
+ }
+
+ widgetData.path = widgetData.path=='auto'?'/' + widgetData.id:widgetData.path
+ widgetData.target = widgetData.target?(Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]):false
+
+ for (i in widgetData) {
+ if (widgetOptions[widgetData.type][i]===undefined && i!='type') {delete widgetData[i]}
+ }
+
+
+ for (t in {width:'',height:'',top:'',left:''}) {
+ widgetData[t] = `${widgetData[t]}`.indexOf('-')!=-1?0:widgetData[t]
+ }
+
+ if (parent.hasClass('strip')) {
+ delete widgetData.top
+ delete widgetData.left
+ }
+
+ if (widgetData.preArgs!=undefined) {
+ widgetData.preArgs = Array.isArray(widgetData.preArgs)?widgetData.preArgs:[widgetData.preArgs]
+ }
+ if (widgetData.target!=undefined) {
+ widgetData.target = Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]
+ }
+
+ var width = parseFloat(widgetData.width)==widgetData.width?parseFloat(widgetData.width)+'rem' : widgetData.width,
+ height = parseFloat(widgetData.height)==widgetData.height?parseFloat(widgetData.height)+'rem' : widgetData.height,
+ left = parseFloat(widgetData.left)==widgetData.left?parseFloat(widgetData.left)+'rem' : widgetData.left,
+ top = parseFloat(widgetData.top)==widgetData.top?parseFloat(widgetData.top)+'rem' : widgetData.top
+
+
+ var styleW = widgetData.width&&widgetData.width!='auto'?`width:${width};min-width:auto;`:'',
+ styleH = widgetData.height&&widgetData.height!='auto'?`height:${height};min-height:auto;`:'',
+ styleL = widgetData.left&&widgetData.left!='auto'||widgetData.left==0?`left:${left};`:'',
+ styleT = widgetData.top&&widgetData.top!='auto'||widgetData.top==0?`top:${top};`:''
+
+ var label = widgetData.label == 'auto'?
+ widgetData.id:
+ typeof widgetData.label == 'string' && widgetData.label.indexOf('icon:')!=-1?
+ icon(widgetData.label.split(':')[1].trim().replace('fa-','')):
+ widgetData.label
+
+ var widgetContainer = $(`
+
+ `)
+
+ if (widgetData.color && widgetData.color!='auto') widgetContainer[0].style.setProperty('--color-custom',widgetData.color)
+
+ if (widgetData.label===false) widgetContainer.addClass('nolabel')
+
+ // create widget
+ var widgetInner = createWidget[widgetData.type](widgetData,widgetContainer)
+
+
+ widgetContainer[0].appendChild(widgetInner[0])
+
+ // store widget reference for cross widget sync
+ if (WIDGETS[widgetData.id]==undefined) WIDGETS[widgetData.id] = []
+ WIDGETS[widgetData.id].push(widgetInner)
+
+ // store widget with linkId for widgte linking
+ if (widgetData.linkId && widgetData.linkId.length) {
+ if (WIDGETS_LINKED[widgetData.linkId]==undefined) WIDGETS_LINKED[widgetData.linkId] = []
+ WIDGETS_LINKED[widgetData.linkId].push(widgetInner)
+ }
+
+ // store widget by path and encode preArgs for perfect cross-app sync
+ if (widgetData.path) {
+ var pathref = widgetData.preArgs&&widgetData.preArgs.length?widgetData.path+'||||'+widgetData.preArgs.join('||||'):widgetData.path
+ if (WIDGETS_BY_PATH[pathref]==undefined) WIDGETS_BY_PATH[pathref] = []
+ WIDGETS_BY_PATH[pathref].push(widgetInner)
+ }
+
+ parent[0].appendChild(widgetContainer[0])
+ }
+
+ // Editor needs to get the container object
+ if (data && data.length==1) return widgetContainer
+
+}
diff --git a/browser/js/app/sidepanel.js b/browser/js/app/sidepanel.js
new file mode 100644
index 00000000..b164a5a1
--- /dev/null
+++ b/browser/js/app/sidepanel.js
@@ -0,0 +1,143 @@
+var actions = require('./actions'),
+ icon = require('./utils').icon
+
+var data = [
+ {
+ actions: [
+ {
+ title:'Fullscreen (F11)',
+ action:actions.toggleFullscreen
+ }
+
+ ]
+ },
+ {
+ title: icon('sliders') + ' State',
+ actions: [
+ {
+ title:'Store',
+ action:actions.stateQuickSave
+ },
+ {
+ title:'Recall',
+ action:actions.stateQuickLoad,
+ class:'disabled quickload'
+ },
+ {
+ title:'Send All',
+ action:actions.stateSend
+ },
+ {
+ title:'Import',
+ action:actions.stateLoad
+ },
+ {
+ title:'Export',
+ action:actions.stateSave
+ }
+ ]
+ },
+ {
+ title: icon('magic') + ' Traversing gestures',
+ actions: [
+ {
+ title:'On',
+ action:actions.traversingEnable,
+ class:'traversingEnable'
+ },
+ {
+ title:'Off',
+ action:actions.traversingDisable,
+ class:'traversingDisable on'
+ }
+ ]
+ },
+ {
+ title: icon('edit') + ' Editor',
+ class:'editor',
+ actions: [
+ {
+ title:'On',
+ action:actions.editorEnable,
+ class:'enable-editor'
+ },
+ {
+ title:'Off',
+ action:actions.editorDisable,
+ class:'on disable-editor'
+ },
+ {
+ title:'Root',
+ class:'editor-root disabled'
+ },
+ {
+ title:'Load',
+ action:actions.sessionBrowse
+ },
+ {
+ title:'Save',
+ action:actions.sessionSave
+ }
+ ]
+ },
+]
+
+var sidepanel = function(data){
+
+ var bindAction = function(el,callback) {
+ el.click(function(){callback()})
+ }
+
+ var html = $('')
+
+ for (i in data) {
+ var itemData = data[i]
+
+ var item = $(' '),
+ inner = $('
').appendTo(item)
+ wrapper = $('
').appendTo(inner)
+
+ if (itemData.title) $(''+itemData.title+'
').prependTo(wrapper)
+ if (itemData.class) inner.attr('class',itemData.class)
+
+ for (j in itemData.actions) {
+ var actionData = itemData.actions[j]
+ var el = $(''+actionData.title+' ').appendTo(wrapper)
+ if (actionData.action) bindAction(el, actionData.action)
+
+ if (actionData.class) el.addClass(actionData.class)
+
+ }
+ item.appendTo(html)
+
+ }
+
+ return html
+
+}(data)
+
+var toggle = function(){
+ $(`${icon('navicon')} `).appendTo('.navigation.main ul').click(function(e){
+ var t = 0
+ if (!$('#sidepanel').hasClass('sidepanel-open')) t = 250
+
+ $('#open-toggle, #sidepanel').toggleClass('sidepanel-open')
+ setTimeout(function(){
+ $('#container').toggleClass('sidepanel-open')
+ $(window).resize()
+ },t)
+ }).on('mousedown touchstart',function(e){e.stopPropagation()})
+
+ // in case where are hot loading a session
+ if ($('#sidepanel').hasClass('sidepanel-open')) {
+ $('#open-toggle, #container').addClass('sidepanel-open')
+ }
+}
+
+module.exports = {
+ init:function(){
+ $('#sidepanel').append(sidepanel)
+ toggle()
+ },
+ createToggle:toggle
+}
diff --git a/browser/js/app/ui.js b/browser/js/app/ui.js
new file mode 100644
index 00000000..2fe1bca7
--- /dev/null
+++ b/browser/js/app/ui.js
@@ -0,0 +1,71 @@
+var actions = require('./actions'),
+ icon = require('./utils').icon
+
+var sidepanel = require('./sidepanel').init
+
+// Tabs...
+var tabs = function() {
+ $('#container').click(function(e){
+ var link = e.target
+
+ if (!link.hasAttribute('data-tab') || link.classList.contains('on')) return
+
+ var id = link.getAttribute('data-tab')
+
+ link.classList.add('on')
+
+ var previous = $(link).siblings('.on').removeClass('on').data('tab')
+
+ // TABS[id].tab.appendTo(TABS[id].parent)
+ TABS[id].parent[0].appendChild(TABS[id].tab[0])
+ $(previous).detach()
+
+
+ $(id).find('li[data-tab]:first-child, li.parent + li[data-tab]').each(function(){
+ if (!$(this).siblings('.on').length) $(this).click()
+ })
+
+ $(window).resize()
+
+ })
+ $('li[data-tab]').first().click()
+}
+
+// horizontal scrolling & zoom with mousewheel
+// if shift is pressed (native), or if there is no vertical scrollbar,
+// or if mouse is on h-scrollbar
+var scrollbarHeight = 20
+var scrolls = function(){
+ $('html').on('mousewheel.zoom',function(e) {
+ // console.log(e)
+ if (e.ctrlKey) {
+ e.preventDefault()
+ if (e.originalEvent.deltaY==0) return
+ var d = -e.originalEvent.deltaY/(10*Math.abs(e.originalEvent.deltaY))
+
+ PXSCALE = parseFloat(d)+parseFloat(PXSCALE)
+ document.documentElement.style.setProperty("--pixel-scale",'')
+ document.documentElement.style.setProperty("--pixel-scale",PXSCALE)
+
+ }
+ })
+ $(document).on('keydown.resetzoom', function(e){
+ if (e.keyCode==96||e.keyCode==48) {
+ PXSCALE = INITIALZOOM
+ document.documentElement.style.setProperty("--pixel-scale",'')
+ document.documentElement.style.setProperty("--pixel-scale",PXSCALE)
+ }
+ })
+
+}
+
+
+module.exports = {
+ init: function(){
+ sidepanel()
+ tabs()
+ scrolls()
+ },
+ tabs:tabs,
+ scrolls:scrolls
+}
diff --git a/browser/js/app/utils.js b/browser/js/app/utils.js
new file mode 100644
index 00000000..04d7504a
--- /dev/null
+++ b/browser/js/app/utils.js
@@ -0,0 +1,39 @@
+module.exports = {
+
+ createPopup: function(title,content) {
+
+ var popup = $(`
+ `),
+ closer = popup.find('.popup-title .closer')
+
+ closer.click(function(){
+ popup.close()
+ })
+
+
+ popup.close = function(){
+ $(document).off('.popup')
+ popup.remove()
+ }
+
+ popup.find('.popup-content').append(content)
+ $('body').append(popup)
+
+ $(document).on('keydown.popup', function(e){
+ if (e.keyCode==27) popup.close()
+ })
+
+
+
+ return popup
+ },
+ icon: function(i) {
+ return ` `
+ }
+
+}
diff --git a/browser/js/app/widgets.js b/browser/js/app/widgets.js
new file mode 100644
index 00000000..a8d05ad7
--- /dev/null
+++ b/browser/js/app/widgets.js
@@ -0,0 +1,80 @@
+var widgets = {
+ // sliders
+ fader: require('./widgets/fader'),
+ knob: require('./widgets/knob'),
+
+ // buttons
+ toggle: require('./widgets/toggle'),
+ switch: require('./widgets/switch'),
+ push: require('./widgets/push'),
+
+ // pads
+ xy: require('./widgets/xy'),
+ rgb: require('./widgets/rgb'),
+
+ // matrices
+ multitoggle: require('./widgets/multitoggle'),
+ multipush: require('./widgets/multipush'),
+ multifader: require('./widgets/multifader'),
+
+ // plots
+ led: require('./widgets/led'),
+ plot: require('./widgets/plot'),
+ visualizer: require('./widgets/visualizer'),
+ meter: require('./widgets/meter'),
+ text: require('./widgets/text'),
+
+ // containers
+ strip: require('./widgets/strip'),
+ panel: require('./widgets/panel'),
+}
+
+module.exports.categories = {
+ 'Sliders':['fader','knob'],
+ 'Buttons':['toggle','push','switch'],
+ 'Pads':['xy','rgb'],
+ 'Matrices':['multifader','multitoggle','multipush'],
+ 'Plots':['plot','visualizer','led','meter','text'],
+ 'Containers':['panel','strip']
+}
+
+module.exports.widgetOptions = function(){
+ var r = {}
+ for (i in widgets) {
+ r[i] = widgets[i].options
+ }
+ return r
+}()
+
+module.exports.createWidget = function(){
+ var r = {}
+ for (i in widgets) {
+ r[i] = widgets[i].create
+ }
+ return r
+}()
+
+module.exports.sync = function() {
+ $('body').off('sync.global').on('sync.global',function(e,id,widget,linkId){
+ // Widget that share the same id will update each other
+ // without sending any extra osc message
+ if (WIDGETS[id] && WIDGETS[id].length>1) {
+ var v = widget.getValue()
+ for (i in WIDGETS[id]) {
+ if (!WIDGETS[id][i].is(widget) && WIDGETS[id][i].setValue) {
+ WIDGETS[id][i].setValue(v,false,false)
+ }
+ }
+ }
+ // widgets that share the same linkId will update each other.
+ // Updated widgets will send osc messages normally
+ if (WIDGETS_LINKED[linkId] && WIDGETS_LINKED[linkId].length>1) {
+ var v = widget.getValue()
+ for (i in WIDGETS_LINKED[linkId]) {
+ if (!WIDGETS_LINKED[linkId][i].is(widget) && WIDGETS_LINKED[linkId][i].setValue) {
+ WIDGETS_LINKED[linkId][i].setValue(v,true,false)
+ }
+ }
+ }
+ })
+}
diff --git a/browser/js/app/widgets/fader.js b/browser/js/app/widgets/fader.js
new file mode 100644
index 00000000..896309af
--- /dev/null
+++ b/browser/js/app/widgets/fader.js
@@ -0,0 +1,299 @@
+var utils = require('./utils'),
+ clip = utils.clip,
+ mapToScale = utils.mapToScale,
+ sendOsc = utils.sendOsc
+
+module.exports.options = {
+ type:'fader',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ unit:'',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ alignRight:false,
+ horizontal:false,
+ noPip:false,
+ compact:false,
+ color:'auto',
+ css:'',
+
+ separator2:'behaviour',
+
+ snap:false,
+
+ separator3:'osc',
+
+ range:{min:0,max:1},
+ logScale:false,
+ precision:2,
+ meter:false,
+ path:'auto',
+ preArgs:[],
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+ var widget = $(`
+
+ `),
+ gauge = widget.find('.gauge'),
+ knob = widget.find('.knob'),
+ wrapper = widget.find('.fader-wrapper'),
+ fader = widget.find('.fader'),
+ pips = widget.find('.pips'),
+ input = widget.find('.input').fakeInput({align:'center'}),
+ unit = widgetData.unit?' '+widgetData.unit.trim(): '',
+ dimension = widgetData.horizontal?'width':'height',
+ snap = widgetData.snap,
+ logScale = widgetData.logScale,
+ roundFactor = Math.pow(10,widgetData.precision)
+
+
+ if (widgetData.horizontal) {
+ container.addClass('horizontal')
+ } else {
+ if (widgetData.alignRight) container.addClass('align-right')
+ }
+
+ if (widgetData.compact) container.addClass('compact')
+ if (widgetData.noPip) wrapper.addClass('no-pip')
+
+ gauge.size = 0
+ fader.size = 0
+ wrapper.size = 0
+ widget.value = undefined
+
+ if (widgetData.meter) {
+ var parsewidgets = require('../parser').widgets
+ var data = {
+ type:'meter',
+ id: widgetData.id + '/meter',
+ label:false,
+ horizontal:widgetData.horizontal,
+ range:widgetData.range,
+ logScale:widgetData.logScale,
+ path:widgetData.path + '/meter',
+ preArgs:widgetData.preArgs,
+ color:widgetData.color
+ }
+ var element = parsewidgets([data],fader)
+ element[0].classList.add('not-editable')
+ widget[0].classList.add('has-meter')
+ }
+
+
+ var rangeKeys = [],
+ rangeVals = [],
+ rangeLabels = []
+
+ for (k in widgetData.range) {
+ var key = k=='min'?0:k=='max'?100:parseInt(k),
+ val = typeof widgetData.range[k] == 'object'?
+ widgetData.range[k][Object.keys(widgetData.range[k])[0]]:
+ widgetData.range[k],
+ label = typeof widgetData.range[k] == 'object'?
+ Object.keys(widgetData.range[k])[0]:
+ val
+
+ rangeKeys.push(key)
+ rangeVals.push(val)
+ rangeLabels.push(label)
+ }
+
+ var rangeValsMax = Math.max.apply(Math, rangeVals),
+ rangeValsMin = Math.min.apply(Math, rangeVals)
+
+ if (!widgetData.noPip&&!widgetData.compact) {
+ var pipTexts = {}
+ for (k in rangeKeys) {
+ pipTexts[rangeKeys[k]]=rangeLabels[k]
+ }
+
+ var pipsInner = ''
+ for (var i=0;i<=100;i++) {
+ if (pipTexts[i]==undefined) continue
+
+ var pos = dimension=='height'?'bottom':'left';
+
+ var piptext = `${Math.abs(pipTexts[i])>=1000?pipTexts[i]/1000+'k':pipTexts[i]} `
+
+ var add = `
+ ${piptext}
+ `
+ pipsInner = pipsInner + add
+ }
+ pips[0].innerHTML = pipsInner
+ }
+
+
+
+
+
+ fader.resize(function(){
+ fader.size= dimension=='height'?fader.outerHeight():fader.outerWidth()
+ wrapper.size = dimension=='height'?wrapper.outerHeight():wrapper.outerWidth()
+ widget.updateUi(gauge.size)
+ })
+
+ wrapper.on('fake-right-click',function(e){
+ if (!EDITING) {
+ e.stopPropagation()
+ e.preventDefault()
+ input.focus()
+ }
+ })
+
+ wrapper.on('mousewheel',function(e){
+ if (e.originalEvent.wheelDeltaX) return
+
+ e.preventDefault()
+ e.stopPropagation()
+
+ var divider = e.ctrlKey?4:.25
+ gauge.size = clip(gauge.size+e.originalEvent.wheelDelta/(fader.size*divider),[0,100])
+
+ widget.updateUi(gauge.size)
+
+ var v = widget.getValue()
+
+ if (v!=widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+ })
+
+ var off = 0
+ wrapper.on('draginit',function(e,data,traversing){
+ if (snap || traversing) {
+
+ var d = (dimension=='height')?
+ ((fader.size-data.offsetY+(wrapper.size-fader.size)/2) * 100 / fader.size):
+ (data.offsetX - (wrapper.size-fader.size)/2) * 100 / fader.size
+ d = clip(d,[0,100])
+
+ widget.updateUi(d)
+ gauge.size = d
+
+ var v = widget.getValue()
+
+ if (v!=widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ }
+
+ off = gauge.size
+
+ })
+
+
+ wrapper.on('drag',function(e,data){
+
+ var d = (dimension=='height')?-data.deltaY:data.deltaX
+ d = clip(d*100/fader.size+off,[0,100])
+
+ widget.updateUi(d)
+
+ gauge.size = d
+
+ var v = widget.getValue()
+
+ if (v!=widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ })
+
+ widget.updateUi = function(v){
+ var s = v/100,
+ t = dimension=='height'?
+ ['1,'+s+',1','0,'+ Math.round(-s*fader.size) +'px,0']
+ :[s+',1,1',Math.round(s*fader.size) +'px,0,0']
+ gauge[0].setAttribute('style','transform:scale3d('+t[0]+')')
+ knob[0].setAttribute('style','transform:translate3d('+t[1]+')')
+ }
+
+ widget.getValue = function(){
+ var h = clip(gauge.size,[0,100])
+ for (var i=0;i= rangeKeys[i]) {
+ return mapToScale(h,[rangeKeys[i],rangeKeys[i+1]],[rangeVals[i],rangeVals[i+1]],widgetData.precision,logScale)
+ }
+ }
+
+ }
+ widget.setValue = function(v,send,sync) {
+ if (typeof v != 'number') return
+
+ var h,
+ v = clip(Math.round(v*roundFactor)/roundFactor,[rangeValsMin,rangeValsMax])
+ for (var i=0;i= rangeVals[i]) {
+ h = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i],rangeKeys[i+1]],false,logScale,true)
+ break
+ }
+ }
+
+ widget.updateUi(h)
+
+ gauge.size = h
+
+ widget.value = v
+ widget.showValue(v)
+
+
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ if (send) widget.sendValue(v)
+ }
+
+ widget.sendValue = function(v) {
+ var args = widgetData.preArgs.concat(v)
+
+ sendOsc({
+ target:widgetData.target,
+ path:widgetData.path,
+ precision:widgetData.precision,
+ args:args
+ })
+ }
+
+ widget.showValue = function(v) {
+ input.val(v+unit)
+ }
+
+ input.change(function(){
+ widget.setValue(parseFloat(input.val()),true,true)
+ })
+
+ widget.setValue(rangeVals[0])
+
+ return widget
+}
diff --git a/browser/js/app/widgets/knob.js b/browser/js/app/widgets/knob.js
new file mode 100644
index 00000000..6f21a699
--- /dev/null
+++ b/browser/js/app/widgets/knob.js
@@ -0,0 +1,276 @@
+var utils = require('./utils'),
+ clip = utils.clip,
+ mapToScale = utils.mapToScale,
+ sendOsc = utils.sendOsc
+
+module.exports.options = {
+ type:'knob',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ unit:'',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ noPip:false,
+ compact:false,
+ css:'',
+
+ separator2:'behaviour',
+
+ snap:false,
+
+ separator3:'osc',
+
+ range:{min:0,max:1},
+ logScale:false,
+ precision:2,
+ path:'auto',
+ preArgs:[],
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+ var widget = $(`
+
+ `),
+ wrapper = widget.find('.knob-wrapper'),
+ mask = widget.find('.knob-mask'),
+ knob = widget.find('.knob'),
+ handle = widget.find('.handle'),
+ input = widget.find('.input').fakeInput({align:'center'}),
+ range = widgetData.range,
+ unit = widgetData.unit?' '+widgetData.unit.trim(): '',
+ snap = widgetData.snap,
+ logScale = widgetData.logScale,
+ roundFactor = Math.pow(10,widgetData.precision)
+
+ if (widgetData.noPip) wrapper.addClass('no-pip')
+ if (widgetData.compact) container.addClass('compact')
+
+
+ var rangeKeys = [],
+ rangeVals = [],
+ rangeLabels = []
+
+ for (k in widgetData.range) {
+ var key = k=='min'?0:k=='max'?100:parseInt(k),
+ val = typeof widgetData.range[k] == 'object'?
+ widgetData.range[k][Object.keys(widgetData.range[k])[0]]:
+ widgetData.range[k],
+ label = typeof widgetData.range[k] == 'object'?
+ Object.keys(widgetData.range[k])[0]:
+ val
+
+ rangeKeys.push(key)
+ rangeVals.push(val)
+ rangeLabels.push(label)
+ }
+
+ var rangeValsMax = Math.max.apply(Math, rangeVals),
+ rangeValsMin = Math.min.apply(Math, rangeVals)
+
+
+ var pipmin = Math.abs(rangeLabels[0])>=1000?rangeLabels[0]/1000+'k':rangeLabels[0],
+ pipmax = Math.abs(rangeLabels[rangeLabels.length-1])>=1000?rangeLabels[rangeLabels.length-1]/1000+'k':rangeLabels[rangeLabels.length-1]
+
+
+
+ widget.find('.pip.min').text(pipmin)
+ widget.find('.pip.max').text(pipmax)
+
+ mask.size = 0
+ widget.value = undefined
+
+ wrapper.resize(function(e,width,height){
+
+ var w = Math.floor(Math.min(height,width)*.58)
+
+ if (!w || mask.size==w) return
+ mask.size=w
+ mask[0].setAttribute('style',`height:${w}px;width:${w}px;padding-bottom:0`)
+ wrapper.size = {width:wrapper[0].clientWidth,height:wrapper[0].clientHeight}
+ })
+
+ wrapper.on('fake-right-click',function(e){
+ if (!EDITING) {
+ e.stopPropagation()
+ e.preventDefault()
+ input.focus()
+ }
+ })
+
+ wrapper.on('mousewheel',function(e){
+ if (e.originalEvent.wheelDeltaX) return
+
+ e.preventDefault()
+ e.stopPropagation()
+
+ var divider = e.ctrlKey?48:8
+ knob.rotation = clip(knob.rotation+e.originalEvent.wheelDeltaY/divider,[0,270])
+
+ widget.updateUi(knob.rotation)
+
+ var v = widget.getValue()
+
+ if (v!=widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+ })
+
+
+ knob.rotation = 0
+
+ var offR = 0,
+ offX = 0,
+ offY = 0
+ wrapper.on('draginit',function(e,data,traversing){
+
+ if (snap || traversing) {
+
+ var w = wrapper.size.width,
+ h = wrapper.size.height,
+ x = data.offsetX-w/2,
+ y = data.offsetY-h/2,
+ angle = Math.atan2(-y, -x) * 180 / Math.PI +45,
+ r = angle<-90?angle+360:angle
+ r = (angle>=-90 && angle<-45)?270:r
+ r = clip(r,[0,270])
+
+ offX = x
+ offY = y
+
+ widget.updateUi(r)
+
+ knob.rotation = r
+
+ var v = widget.getValue()
+
+ if (v!=widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ }
+
+ offR = knob.rotation
+ })
+
+ wrapper.on('drag',function(e,data){
+
+ var r = clip(-data.deltaY*2+offR,[0,270])
+
+ if (snap || data.ctrlKey || data.shiftKey) {
+ var w = data.target.clientWidth,
+ h = data.target.clientHeight,
+ x = data.deltaX + offX,
+ y = data.deltaY + offY,
+ angle = Math.atan2(-y, -x) * 180 / Math.PI +45,
+ r = angle<-90?angle+360:angle
+ r = (angle>=-90 && angle<-45)?270:r
+ r = clip(r,[0,270])
+ }
+
+ widget.updateUi(r)
+
+ knob.rotation = r
+
+ var v = widget.getValue()
+
+ if (v!=widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+ })
+
+ widget.updateUi = function(r) {
+ knob[0].setAttribute('style','transform:rotateZ('+r+'deg)')
+ handle[0].setAttribute('style','transform:rotateZ('+(r-45)+'deg)')
+
+ if (r>180) {knob.addClass('d3')}
+ else if (r>90) {knob.removeClass('d3').addClass('d2')}
+ else {knob.removeClass('d3 d2')}
+ }
+
+ widget.getValue = function() {
+ var h = knob.rotation
+ for (var i=0;i= rangeKeys[i]*2.7) {
+ return mapToScale(h,[rangeKeys[i]*2.7,rangeKeys[i+1]*2.7],[rangeVals[i],rangeVals[i+1]],widgetData.precision,logScale)
+ }
+ }
+ }
+ widget.showValue = function(v) {
+ input.val(v+unit)
+ }
+ widget.sendValue = function(v) {
+ var args = widgetData.preArgs.concat(v)
+
+ sendOsc({
+ target:widgetData.target,
+ path:widgetData.path,
+ precision:widgetData.precision,
+ args:args
+ })
+ }
+ widget.setValue = function(v,send,sync) {
+ if (typeof v != 'number') return
+
+ var v = clip(Math.round(v*roundFactor)/roundFactor,[rangeValsMin,rangeValsMax]),
+ r
+
+ for (var i=0;i= rangeVals[i]) {
+ r = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i]*2.7,rangeKeys[i+1]*2.7],false,logScale,true)
+ break
+ }
+ }
+
+ knob.rotation = r
+
+ widget.updateUi(r)
+
+ var v = widget.getValue()
+ widget.value = v
+
+ widget.showValue(v)
+
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ if (send) widget.sendValue(v)
+ }
+ input.change(function(){
+ widget.setValue(parseFloat(input.val()),true,true)
+ })
+
+ widget.setValue(rangeVals[0])
+ return widget
+}
diff --git a/browser/js/app/widgets/led.js b/browser/js/app/widgets/led.js
new file mode 100644
index 00000000..1c72dcf8
--- /dev/null
+++ b/browser/js/app/widgets/led.js
@@ -0,0 +1,42 @@
+var utils = require('./utils'),
+ mapToScale = utils.mapToScale
+
+module.exports.options = {
+ type:'led',
+ id:'auto',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ css:'',
+
+ separator2:'osc',
+
+ range:{min:0,max:1},
+ logScale:false,
+ preArgs:[],
+ path:'auto'
+}
+module.exports.create = function(widgetData,container) {
+ var widget = $(`
+
+ `),
+ led = widget.find('span'),
+ range = widgetData.range
+
+ widget.setValue = function(v,send,sync){
+ if (typeof v != 'number') return
+ led.css('opacity',mapToScale(v,[range.min,range.max],[0,1],widgetData.precision,widgetData.logScale,true))
+ }
+
+ widget.setValue(range.min)
+
+ return widget
+}
diff --git a/browser/js/app/widgets/meter.js b/browser/js/app/widgets/meter.js
new file mode 100644
index 00000000..34acb9fa
--- /dev/null
+++ b/browser/js/app/widgets/meter.js
@@ -0,0 +1,87 @@
+var utils = require('./utils'),
+ clip = utils.clip,
+ mapToScale = utils.mapToScale
+
+module.exports.options = {
+ type:'fader',
+ id:'auto',
+
+ separator1:'style',
+
+ label:'auto',
+ unit:'',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ horizontal:false,
+ color:'auto',
+ css:'',
+
+ separator3:'osc',
+
+ range:{min:0,max:1},
+ logScale:false,
+ path:'auto',
+ preArgs:[]
+}
+
+module.exports.create = function(widgetData,container) {
+ var widget = $(`
+
+ `),
+ level = widget.find('.level'),
+ logScale = widgetData.logScale,
+ dimension = widgetData.horizontal?'width':'height',
+ axe = dimension=='height'?'X':'Y'
+
+
+ if (widgetData.horizontal) widget.addClass('horizontal')
+
+
+ var rangeKeys = [],
+ rangeVals = []
+
+ for (k in widgetData.range) {
+ var key = k=='min'?0:k=='max'?100:parseInt(k),
+ val = typeof widgetData.range[k] == 'object'?
+ widgetData.range[k][Object.keys(widgetData.range[k])[0]]:
+ widgetData.range[k]
+
+ rangeKeys.push(key)
+ rangeVals.push(val)
+ }
+
+
+
+ widget.updateUi = function(v){
+ var s = v/100,
+ t = dimension=='height'?
+ '1,'+s+',1'
+ :s+',1,1'
+ level[0].setAttribute('style','transform:scale3d('+t+')')
+ }
+
+
+ widget.setValue = function(v) {
+ if (typeof v != 'number') return
+
+ var h,
+ v=clip(v,[rangeVals[0],rangeVals.slice(-1)[0]])
+ for (var i=0;i= rangeVals[i]) {
+ h = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i],rangeKeys[i+1]],2,logScale,true)
+ break
+ }
+ }
+
+ widget.updateUi(h)
+
+ }
+
+ widget.setValue(rangeVals[0])
+
+ return widget
+}
diff --git a/browser/js/app/widgets/multifader.js b/browser/js/app/widgets/multifader.js
new file mode 100644
index 00000000..213c5a4f
--- /dev/null
+++ b/browser/js/app/widgets/multifader.js
@@ -0,0 +1,85 @@
+module.exports.options = {
+ type:'multifader',
+ id:'auto',
+
+ separator0:'Matrix',
+
+ strips:2,
+
+ separator1:'style',
+
+ label:'auto',
+ unit:'',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ compact:false,
+ css:'',
+
+
+ separator2:'osc',
+
+ range:{min:0,max:1},
+ logScale:false,
+ precision:2,
+ path:'auto',
+ preArgs:[],
+ target:[]
+}
+
+module.exports.create = function(widgetData,container) {
+
+ var parsewidgets = require('../parser').widgets
+
+ var widget = $(`
+
+
\
+ `),
+ $document = $(document)
+
+ widget.value = []
+
+ for (var i=0;i
+ \
+ `),
+ $document = $(document)
+
+ widget.value = []
+
+ for (var i=0;i
+ \
+ `),
+ $document = $(document)
+
+ widget.value = []
+
+ for (var i=0;i
+
+ `)
+
+ if (!widgetData.scroll) widget.addClass('noscroll')
+
+ if (widgetData.tabs.length) {
+ parsetabs(widgetData.tabs,widget)
+ widget.addClass('has-tabs')
+ } else {
+ parsewidgets(widgetData.widgets,widget)
+ }
+ return widget
+}
diff --git a/browser/js/app/widgets/plot.js b/browser/js/app/widgets/plot.js
new file mode 100644
index 00000000..5c407ffb
--- /dev/null
+++ b/browser/js/app/widgets/plot.js
@@ -0,0 +1,214 @@
+var utils = require('./utils'),
+ mapToScale = utils.mapToScale
+
+module.exports.options = {
+ type:'plot',
+ id:'auto',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ css:'',
+
+ separator2:'plot',
+
+ points:[],
+ rangeX: {min:0,max:1},
+ rangeY: {min:0,max:1},
+ logScaleX: false,
+ logScaleY: false,
+
+ separator3:'osc',
+
+ path:'auto',
+ preArgs:[],
+
+}
+module.exports.create = function(widgetData,container) {
+
+ var widget = $(`
+
+
+
+ `),
+ canvas = widget.find('canvas'),
+ ctx = canvas[0].getContext('2d')
+
+ widget.data = []
+ widget.height = undefined
+ widget.width = undefined
+ widget.linkedWidgets = []
+ widget.visible = false
+ widget.textColor = getComputedStyle(document.documentElement).getPropertyValue('--color-text-fade')
+ widget.pips = {
+ x : {
+ min: Math.abs(widgetData.rangeX.min)>=1000?widgetData.rangeX.min/1000+'k':widgetData.rangeX.min,
+ max: Math.abs(widgetData.rangeX.max)>=1000?widgetData.rangeX.max/1000+'k':widgetData.rangeX.max
+ },
+ y : {
+ min: Math.abs(widgetData.rangeY.min)>=1000?widgetData.rangeY.min/1000+'k':widgetData.rangeY.min,
+ max: Math.abs(widgetData.rangeY.max)>=1000?widgetData.rangeY.max/1000+'k':widgetData.rangeY.max
+ }
+ }
+
+
+
+ if (typeof widgetData.points=='string') {
+
+ widget.linkedWidgets.push(widgetData.points)
+
+ } else if (typeof widgetData.points=='object') {
+
+ for (i in widgetData.points) {
+ for (j in widgetData.points[i]) {
+ if (typeof widgetData.points[i][j] == 'string') {
+ widget.linkedWidgets.push(widgetData.points[i][j])
+ }
+ }
+ }
+ }
+
+
+ canvas.resize(function(){
+ var width = canvas.width(),
+ height = canvas.height()
+
+ if (height==100 && width==100) return
+
+ if (!self.visible) {
+ widget.visible = true
+ widget.lineColor = getComputedStyle(widget[0]).getPropertyValue('--color-accent')
+ }
+
+
+ widget.height=height
+ widget.width=width
+
+ canvas[0].setAttribute('width',width)
+ canvas[0].setAttribute('height',height)
+
+ widget.fetchValues()
+ requestAnimationFrame(widget.draw)
+
+ })
+
+
+ widget.handleSync = function(e,id,w) {
+ if (widget.linkedWidgets.indexOf(id)==-1 || !WIDGETS[id]) return
+ widget.fetchValues()
+ requestAnimationFrame(widget.draw)
+ }
+
+ $('body').on('sync',widget.handleSync)
+
+ widget.draw = function(){
+
+
+ ctx.clearRect(0,0,widget.width,widget.height)
+ ctx.beginPath()
+
+ var first = true
+ var point = []
+
+ for (i in widget.data) {
+ var newpoint = widget.data[i].length?
+ [
+ mapToScale(widget.data[i][0],[widgetData.rangeX.min,widgetData.rangeX.max],[15*PXSCALE,widget.width-15*PXSCALE],0,widgetData.logScaleX,true),
+ mapToScale(widget.data[i][1],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15*PXSCALE,15*PXSCALE],0,widgetData.logScaleY,true),
+ ]
+ :
+ [
+ mapToScale(i,[0,widget.data.length-1],[15*PXSCALE,widget.width-15*PXSCALE],0,widgetData.logScaleX,true),
+ mapToScale(widget.data[i],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15*PXSCALE,15*PXSCALE],0,widgetData.logScaleY,true),
+ ]
+
+
+
+ if (first) {
+ ctx.moveTo(newpoint[0],newpoint[1])
+ first = false
+ } else {
+ ctx.moveTo(point[0],point[1])
+ if (widgetData.logScaleX&&!widgetData.logScaleY) {
+ ctx.quadraticCurveTo(point[0], newpoint[1], newpoint[0], newpoint[1])
+ } else if (widgetData.logScaleY&&!widgetData.logScaleX) {
+ ctx.quadraticCurveTo(newpoint[0], point[1], newpoint[0], newpoint[1])
+ } else {
+ ctx.lineTo(newpoint[0],newpoint[1])
+ }
+
+ }
+ ctx.arc(newpoint[0],newpoint[1],1,0,2*Math.PI)
+ point = newpoint
+ }
+
+ ctx.lineWidth = 1.5*PXSCALE
+ ctx.strokeStyle= widget.lineColor
+ ctx.stroke()
+
+ ctx.font = PXSCALE * 10 + 'px sans-serif'
+ ctx.fillStyle = widget.textColor
+
+
+ ctx.textBaseline = "bottom"
+ ctx.textAlign = 'left'
+ ctx.fillText(widget.pips.x.min,12*PXSCALE,widget.height)
+ ctx.textAlign = 'right'
+ ctx.fillText(widget.pips.x.max,widget.width-10,widget.height)
+
+ ctx.save()
+ ctx.translate(0, widget.height)
+ ctx.rotate(-Math.PI/2)
+
+ ctx.textBaseline = "top"
+ ctx.textAlign = 'left'
+ ctx.fillText(widget.pips.y.min,12*PXSCALE,2*PXSCALE)
+ ctx.textAlign = 'right'
+ ctx.fillText(widget.pips.y.max,widget.height-10*PXSCALE,2*PXSCALE)
+ ctx.rotate(Math.PI/2)
+ ctx.restore()
+
+ }
+
+
+
+ widget.fetchValues = function(){
+ var data = [],
+ points = widgetData.points
+
+ if (typeof points=='string' && WIDGETS[points]) {
+
+ data = WIDGETS[points][WIDGETS[points].length-1].getValue()
+
+ } else if (typeof points=='object') {
+
+ for (i in points) {
+
+ data[i] = []
+ for (k in [0,1]) {
+ if (typeof points[i][k] == 'string' && WIDGETS[points[i][k]]) {
+ data[i][k] = WIDGETS[points[i][k]][WIDGETS[points[i][k]].length-1].getValue()
+ } else {
+ data[i][k] = points[i][k]
+ }
+ }
+
+ }
+
+ }
+
+ if (data.length) widget.data = data
+ }
+
+ widget.setValue = function(v) {
+ widget.data = v
+ requestAnimationFrame(widget.draw)
+ }
+
+ return widget
+}
diff --git a/browser/js/app/widgets/push.js b/browser/js/app/widgets/push.js
new file mode 100644
index 00000000..a9081899
--- /dev/null
+++ b/browser/js/app/widgets/push.js
@@ -0,0 +1,109 @@
+var sendOsc = require('./utils').sendOsc
+
+module.exports.options = {
+ type:'push',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ css:'',
+
+ separator2:'osc',
+
+ on:1,
+ off:0,
+ precision:2,
+ path:'auto',
+ preArgs:[],
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+
+
+ var widget = $(`
+
+
+
\
+ `),
+ $document = $(document),
+ light = widget.find('.light')[0]
+
+ widget.value = widget.find('span')
+ widget.state = 0
+ widget.active = 0
+ widget.lastChanged = 'state'
+
+ widget.on('drag',function(e){e.stopPropagation()})
+ widget.on('draginit.push',function(){
+ widget.off('draginit.push')
+ widget.fakeclick()
+ })
+
+ widget.fakeclick = function(){
+ if (!widget.active) widget.setValuePrivate(widgetData.on,true,true)
+ $document.on('dragend.push',function(){
+ widget.setValuePrivate(widgetData.off,true,true)
+ $document.off('dragend.push')
+ widget.on('draginit.push',function(){
+ widget.off('draginit.push')
+ widget.fakeclick()
+ })
+ })
+ }
+
+ widget.getValue = function() {
+ return widget[widget.lastChanged]?widgetData.on:widgetData.off
+ }
+
+ widget.setValuePrivate = function(v,send,sync) {
+ if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
+ widget.addClass('active')
+ widget.active = 1
+ if (send) widget.sendValue(v)
+ widget.lastChanged = 'active'
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ } else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
+ widget.removeClass('active')
+ widget.active = 0
+ if (send) widget.sendValue(v)
+ widget.lastChanged = 'active'
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+ }
+
+ widget.setValue = function(v,send,sync) {
+ if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
+ widget.addClass('on')
+ widget.state = 1
+ if (send) widget.sendValue(v)
+ widget.lastChanged = 'state'
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ } else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
+ widget.removeClass('on')
+ widget.state = 0
+ if (send) widget.sendValue(v)
+ widget.lastChanged = 'state'
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+ }
+
+ widget.sendValue = function(v) {
+ if (v===false) return
+ var args = widgetData.preArgs.concat(v)
+ sendOsc({
+ target:widgetData.target,
+ path:widgetData.path,
+ precision:widgetData.precision,
+ args:args
+ })
+ }
+ widget.setValue()
+ return widget
+}
diff --git a/browser/js/app/widgets/rgb.js b/browser/js/app/widgets/rgb.js
new file mode 100644
index 00000000..a28e5c7d
--- /dev/null
+++ b/browser/js/app/widgets/rgb.js
@@ -0,0 +1,292 @@
+var utils = require('./utils'),
+ clip = utils.clip,
+ mapToScale = utils.mapToScale,
+ hsbToRgb = utils.hsbToRgb,
+ rgbToHsb = utils.rgbToHsb,
+ sendOsc = utils.sendOsc
+
+module.exports.options = {
+ type:'rgb',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ css:'',
+
+ separator2:'behaviour',
+
+ snap:false,
+
+ separator3:'osc',
+
+ precision:0,
+ path:'auto',
+ preArgs:[],
+ split:false,
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+
+ var widget = $(`
+
`),
+ rgbHandle = widget.find('.rgb .handle'),
+ hueHandle = widget.find('.hue .handle'),
+ pad = widget.find('.xy'),
+ huePad = widget.find('.hue'),
+ rgbBg = pad.find('.bg')[0],
+ value = {r:widget.find('.r').fakeInput({align:'center'}),g:widget.find('.g').fakeInput({align:'center'}),b:widget.find('.b').fakeInput({align:'center'})},
+ snap = widgetData.snap,
+ split = widgetData.split?
+ typeof widgetData.split == 'object'?
+ widgetData.split:{r:widgetData.path+'/r',g:widgetData.path+'/g',b:widgetData.path+'/b'}
+ :false
+
+
+ pad.width = 0
+ pad.height = 0
+ rgbHandle.height = 0
+ rgbHandle.width = 0
+ hueHandle.width = 0
+ widget.value = undefined
+
+ pad.resize(function(){
+ var width = pad.innerWidth(),
+ height = pad.innerHeight()
+ if (!width || (pad.height==height && pad.width==width)) return
+ pad.width = width
+ pad.height = height
+ rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*rgbHandle.width/100}px, -${pad.height*rgbHandle.height/100}px,0)`)
+
+ })
+
+
+ var rgbOff = {x:0,y:0}
+ pad.on('draginit',function(e,data,traversing){
+ if (snap || traversing) {
+
+ var h = ((pad.height-data.offsetY) * 100 / pad.height),
+ w = (data.offsetX * 100 / pad.width)
+
+ rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
+ rgbHandle.height = h
+ rgbHandle.width = w
+
+ var v = widget.getValue()
+
+ if (v
widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ }
+
+ rgbOff = {x:rgbHandle.width,y:rgbHandle.height}
+
+ })
+ pad.on('drag',function(e,data){
+
+ var h = clip((-data.deltaY)*100/pad.height+rgbOff.y,[0,100]),
+ w = clip(data.deltaX*100/pad.width+rgbOff.x,[0,100])
+
+ rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
+ rgbHandle.height = h
+ rgbHandle.width = w
+
+ var v = widget.getValue()
+
+ if (vwidget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ })
+
+
+ var hueOff = 0
+ huePad.on('draginit',function(e,data,traversing){
+ if (snap || traversing) {
+
+ var d = (data.offsetX * 100 / pad.width)
+ hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*d/100}px,0,0)`)
+ hueHandle.width = d
+
+
+ var h = clip(hueHandle.width*3.6,[0,360]),
+ rgb = hsbToRgb({h:h,s:100,b:100})
+
+ rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
+
+ var v = widget.getValue()
+
+ if (vwidget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ }
+
+ hueOff = hueHandle.width
+
+ })
+
+
+ huePad.on('drag',function(e,data){
+
+ var w = clip(data.deltaX*100/pad.width+hueOff,[0,100])
+ hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px,0,0)`)
+ hueHandle.width = w
+
+ var h = clip(hueHandle.width*3.6,[0,360]),
+ rgb = hsbToRgb({h:h,s:100,b:100})
+
+ rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
+
+ var v = widget.getValue()
+
+ if (vwidget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ })
+
+
+
+
+
+ widget.getValue = function() {
+ var s = clip(rgbHandle.width,[0,100]),
+ l = clip(rgbHandle.height,[0,100]),
+ h = mapToScale(hueHandle.width,[0,100],[0,360],widgetData.precision),
+ rgb = hsbToRgb({h:h,s:s,b:l})
+ return [rgb.r,rgb.g,rgb.b]
+ }
+ widget.setValue = function(v,send,sync) {
+ if (!v || v.length!=3) return
+
+ for (i in [0,1,2]) {
+ v[i] = clip(v[i],[0,255])
+ }
+
+
+ var hsb = rgbToHsb({r:v[0],g:v[1],b:v[2]})
+
+ var w = mapToScale(hsb.s,[0,100],[0,100],false),
+ h = mapToScale(hsb.b,[0,100],[0,100],false),
+ hueW = mapToScale(hsb.h,[0,360],[0,100],false)
+
+ rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
+ hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*hueW/100}px,0,0)`)
+
+ rgbHandle.height = h
+ rgbHandle.width = w
+ hueHandle.width = hueW
+ widget.value = v
+
+
+ var rgb = hsbToRgb({h:hsb.h,s:100,b:100})
+ rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
+
+ widget.showValue(v)
+
+
+
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ if (send) widget.sendValue(v)
+ }
+ widget.sendValue = function(v) {
+ var args = widgetData.preArgs.concat(v)
+
+ sendOsc({
+ target:split?false:widgetData.target,
+ path:widgetData.path,
+ args:args,
+ precision:widgetData.precision,
+ })
+ if (split) {
+ sendOsc({
+ target:widgetData.target,
+ path:split.r,
+ args:widgetData.preArgs.concat(v[0]),
+ precision:widgetData.precision,
+ sync:false
+ })
+ sendOsc({
+ target:widgetData.target,
+ path:split.g,
+ args:widgetData.preArgs.concat(v[1]),
+ precision:widgetData.precision,
+ sync:false
+ })
+ sendOsc({
+ target:widgetData.target,
+ path:split.b,
+ args:widgetData.preArgs.concat(v[2]),
+ precision:widgetData.precision,
+ sync:false
+ })
+ }
+ }
+
+
+
+ widget.showValue = function(v) {
+ value.r.val(v[0])
+ value.g.val(v[1])
+ value.b.val(v[2])
+ }
+ value.r.change(function(){
+ var r = clip(value.r.val(),[0,255])
+ var v = widget.getValue()
+ widget.setValue([r,v[1],v[2]],true,true)
+ })
+ value.g.change(function(){
+ var g = clip(value.g.val(),[0,255])
+ var v = widget.getValue()
+ widget.setValue([v[0],g,v[2]],true,true)
+ })
+ value.b.change(function(){
+ var b = clip(value.b.val(),[0,255])
+ var v = widget.getValue()
+ widget.setValue([v[0],v[1],b],true,true)
+ })
+
+ widget.setValue([0,0,0])
+
+ return widget
+}
diff --git a/browser/js/app/widgets/strip.js b/browser/js/app/widgets/strip.js
new file mode 100644
index 00000000..35e2eaee
--- /dev/null
+++ b/browser/js/app/widgets/strip.js
@@ -0,0 +1,38 @@
+
+module.exports.options = {
+ type:'strip',
+ id:'auto',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ horizontal:false,
+ color:'auto',
+ css:'',
+
+ separator2:'children',
+
+ widgets:[]
+}
+module.exports.create = function(widgetData,container) {
+
+ var parsewidgets = require('../parser').widgets
+
+ var widget = $(`
+
+
+ `)
+ if (widgetData.horizontal) {
+ container.addClass('horizontal')
+ } else {
+ container.addClass('vertical')
+ }
+
+ parsewidgets(widgetData.widgets,widget)
+
+ return widget
+}
diff --git a/browser/js/app/widgets/switch.js b/browser/js/app/widgets/switch.js
new file mode 100644
index 00000000..c8ad7ddb
--- /dev/null
+++ b/browser/js/app/widgets/switch.js
@@ -0,0 +1,83 @@
+var sendOsc = require('./utils').sendOsc
+
+module.exports.options = {
+ type:'switch',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ horizontal:false,
+ color:'auto',
+ css:'',
+
+ separator2:'osc',
+
+ values:{"Value 1":1,"Value 2":2},
+ precision:2,
+ path:'auto',
+ preArgs:[],
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+
+ var widget = $(`
+
+
+ `),
+ $document = $(document)
+
+ if (widgetData.horizontal) {
+ widget.addClass('horizontal')
+ }
+
+ widget.values = []
+
+ for (k in widgetData.values) {
+ widget.values.push(widgetData.values[k])
+ $(''+k+'
').data({value:widgetData.values[k]}).appendTo(widget)
+ }
+
+ widget.value = undefined
+
+ widget.find('.value').on('draginit',function(e,dd){
+ var data = $(this).data()
+ if (data.value!=widget.value || widget.value===undefined) widget.setValue(data.value,true,true)
+ })
+
+
+
+ widget.getValue = function() {
+ return widget.value
+ }
+ widget.setValue = function(v,send,sync) {
+ var i = widget.values.indexOf(v)
+ if (i!=-1) {
+ widget.value = widget.values[i]
+ widget.find('.on').removeClass('on')
+ widget.find('.value').eq(i).addClass('on').removeClass('ripple').addClass('ripple').delay(250).queue(function(next){
+ $(this).removeClass('ripple')
+ next()
+ })
+ if (send) widget.sendValue(widget.value)
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ }
+ widget.sendValue = function(v) {
+ var args = widgetData.preArgs.concat(v)
+
+ sendOsc({
+ target:widgetData.target,
+ path:widgetData.path,
+ precision:widgetData.precision,
+ args:args
+ })
+ }
+ return widget
+}
diff --git a/browser/js/app/widgets/text.js b/browser/js/app/widgets/text.js
new file mode 100644
index 00000000..7e8467e9
--- /dev/null
+++ b/browser/js/app/widgets/text.js
@@ -0,0 +1,54 @@
+var utils = require('./utils'),
+ mapToScale = utils.mapToScale
+
+module.exports.options = {
+ type:'text',
+ id:'auto',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ vertical:false,
+ color:'auto',
+ css:'',
+
+ separator2:'osc',
+
+ preArgs:[],
+ path:'auto',
+ defaultText:''
+}
+module.exports.create = function(widgetData,container) {
+ var widget = $(`
+
+
+ `),
+ label = widgetData.defaultText!==''?
+ widgetData.defaultText:
+ widgetData.label===false?
+ widgetData.id:
+ widgetData.label=='auto'?
+ widgetData.id:
+ widgetData.label,
+ text = label
+
+
+ if (widgetData.vertical) widget.addClass('vertical')
+
+ widget.setValue = function(v,send,sync){
+ text = typeof v=='object' && !v.length?label:v
+ widget.text(text)
+ }
+
+ widget.getValue = function(){
+ return text
+ }
+
+ widget.setValue(label)
+
+ return widget
+}
diff --git a/browser/js/app/widgets/toggle.js b/browser/js/app/widgets/toggle.js
new file mode 100644
index 00000000..e8c741e9
--- /dev/null
+++ b/browser/js/app/widgets/toggle.js
@@ -0,0 +1,89 @@
+var sendOsc = require('./utils').sendOsc
+
+module.exports.options = {
+ type:'toggle',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ css:'',
+
+ separator2:'osc',
+
+ on:1,
+ off:0,
+ precision:2,
+ path:'auto',
+ preArgs:[],
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+
+ var widget = $(`
+ \
+ `),
+ $document = $(document),
+ light = widget.find('.light')[0]
+
+ widget.value = widget.find('span')
+ widget.state = 0
+
+ widget.on('drag',function(e){e.stopPropagation()})
+ widget.on('draginit.toggle',function(){
+ widget.off('draginit.toggle')
+ widget.fakeclick()
+ })
+
+ widget.fakeclick = function(){
+ var newVal = widget.state?widgetData.off:widgetData.on
+ widget.setValue(newVal,true,true)
+ $document.on('dragend.toggle',function(){
+ $document.off('dragend.toggle')
+ widget.on('draginit.toggle',function(){
+ widget.off('draginit.toggle')
+ widget.fakeclick()
+ })
+ })
+ }
+
+
+ widget.getValue = function() {
+ return widget.state?widgetData.on:widgetData.off
+ }
+ widget.setValue = function(v,send,sync) {
+ if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
+ widget.addClass('on')
+ widget.state = 1
+ if (send) widget.sendValue(widgetData.on)
+ } else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
+ widget.removeClass('on')
+ widget.state = 0
+ if (send) widget.sendValue(widgetData.off)
+ }
+
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+
+ }
+ widget.sendValue = function(v) {
+ if (v===false) return
+ var args = widgetData.preArgs.concat(v)
+
+ sendOsc({
+ target:widgetData.target,
+ path:widgetData.path,
+ precision:widgetData.precision,
+ args:args
+ })
+ }
+ widget.setValue()
+ return widget
+}
diff --git a/browser/js/app/widgets/utils.js b/browser/js/app/widgets/utils.js
new file mode 100644
index 00000000..2f5bf793
--- /dev/null
+++ b/browser/js/app/widgets/utils.js
@@ -0,0 +1,78 @@
+module.exports = {
+
+ sendOsc: function(data){
+ IPC.send('sendOsc', data)
+ },
+
+ clip: function(value,range) {
+ var value = parseFloat(value)
+
+ if (isNaN(value)) value = range[0]
+ return Math.max(Math.min(range[0],range[1]),Math.min(value,Math.max(range[0],range[1])))
+
+ },
+
+ // map a value from a scale to another input and output must be range arrays
+ mapToScale: function(value,rangeIn,rangeOut,precision,log,revertlog) {
+
+ var value = module.exports.clip(value,[rangeIn[0],rangeIn[1]]),
+ roundFactor = precision!=undefined?Math.pow(10,precision):100,
+
+
+ value = log?
+ revertlog?
+ (Math.pow(10,((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])))/9-1/9) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
+ :Math.log10(((value-rangeIn[0])/(rangeIn[1]-rangeIn[0]))*9+1) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
+ :((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
+
+ value = Math.max(Math.min(rangeOut[0],rangeOut[1]),Math.min(value,Math.max(rangeOut[0],rangeOut[1])))
+
+ if (precision!==false) value = Math.round(value*roundFactor)/roundFactor
+
+
+ return value
+
+ },
+
+ hsbToRgb: function (hsb) {
+ var rgb = {}
+ var h = hsb.h
+ var s = hsb.s*255/100
+ var v = hsb.b*255/100
+ if(s == 0) {
+ rgb.r = rgb.g = rgb.b = v
+ } else {
+ var t1 = v
+ var t2 = (255-s)*v/255
+ var t3 = (t1-t2)*(h%60)/60
+ if(h==360) h = 0
+ if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
+ else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
+ else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
+ else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
+ else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
+ else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
+ else {rgb.r=0; rgb.g=0; rgb.b=0}
+ }
+ return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)}
+ },
+
+ rgbToHsb: function (rgb) {
+ var hsb = {h: 0, s: 0, b: 0}
+ var min = Math.min(rgb.r, rgb.g, rgb.b)
+ var max = Math.max(rgb.r, rgb.g, rgb.b)
+ var delta = max - min
+ hsb.b = max
+ hsb.s = max != 0 ? 255 * delta / max : 0
+ if (hsb.s != 0) {
+ if (rgb.r == max) hsb.h = (rgb.g - rgb.b) / delta
+ else if (rgb.g == max) hsb.h = 2 + (rgb.b - rgb.r) / delta
+ else hsb.h = 4 + (rgb.r - rgb.g) / delta
+ } else hsb.h = 0
+ hsb.h *= 60
+ if (hsb.h < 0) hsb.h += 360
+ hsb.s *= 100/255
+ hsb.b *= 100/255
+ return hsb
+ }
+}
diff --git a/browser/js/app/widgets/visualizer.js b/browser/js/app/widgets/visualizer.js
new file mode 100644
index 00000000..cd4e06b6
--- /dev/null
+++ b/browser/js/app/widgets/visualizer.js
@@ -0,0 +1,176 @@
+var utils = require('./utils'),
+ mapToScale = utils.mapToScale,
+ clip = utils.clip
+
+module.exports.options = {
+ type:'visualizer',
+ id:'auto',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ css:'',
+
+ separator2:'plot',
+
+ widgetId:'',
+ duration:1,
+ range: {min:0,max:1},
+ logScale: false,
+
+ separator3:'osc',
+
+ path:'auto',
+ preArgs:[],
+}
+module.exports.create = function(widgetData,container) {
+
+ var widget = $(`
+
+
+
+ `),
+ canvas = widget.find('canvas'),
+ ctx = canvas[0].getContext('2d')
+
+ widget.height = 0
+ widget.width = 0
+ widget.visible = false
+ widget.textColor = getComputedStyle(document.documentElement).getPropertyValue('--color-text-fade')
+ widget.pips = {
+ min: Math.abs(widgetData.range.min)>=1000?widgetData.range.min/1000+'k':widgetData.range.min,
+ max: Math.abs(widgetData.range.max)>=1000?widgetData.range.max/1000+'k':widgetData.range.max
+ }
+ widget.length = Math.round(clip(60*widgetData.duration,[8,4096]))
+ widget.data = new Array(widget.length)
+ widget.value = widgetData.range.min
+
+ canvas.resize(function(){
+ var width = canvas.width(),
+ height = canvas.height()
+
+ if (height==100 && width==100) return
+
+ if (!self.visible) {
+ widget.visible = true
+ widget.lineColor = getComputedStyle(widget[0]).getPropertyValue('--color-accent')
+ }
+
+ widget.height=height
+ widget.width=width
+
+ canvas[0].setAttribute('width',width)
+ canvas[0].setAttribute('height',height)
+
+ requestAnimationFrame(widget.draw)
+
+ })
+
+
+ widget.handleSync = function(e,id,w) {
+ if (widgetData.widgetId!=id || !WIDGETS[id]) return
+ widget.startLoop()
+ }
+
+ $('body').on('sync',widget.handleSync)
+
+
+ widget.cancel = false
+ widget.loop = false
+
+ widget.startLoop = function(){
+
+ if (widget.cancel) clearTimeout(widget.cancel)
+
+ widget.cancel = setTimeout(function(){
+ clearInterval(widget.loop)
+ widget.loop = false
+ widget.cancel = false
+ },1000*widgetData.duration)
+
+ if (widget.loop) return
+
+ widget.loop = setInterval(function(){
+ widget.fetchValue()
+ widget.draw()
+ },1000*widgetData.duration/widget.length)
+ }
+
+
+ widget.draw = function(){
+ ctx.clearRect(0,0,widget.width,widget.height)
+ ctx.beginPath()
+
+ var first = true
+ var point = []
+
+ for (var i=widget.length-1;i>=0;i=i-1) {
+ var newpoint = [
+ mapToScale(i,[0,widget.length-1],[15*PXSCALE,widget.width-15*PXSCALE],1),
+ mapToScale(widget.data[i],[widgetData.range.min,widgetData.range.max],[widget.height-15*PXSCALE,15*PXSCALE],1,widgetData.logScale,true),
+ ]
+ if (first) {
+ ctx.moveTo(newpoint[0],newpoint[1])
+ first = false
+ } else {
+ if (widgetData.logScale) {
+ ctx.quadraticCurveTo(newpoint[0], point[1], newpoint[0], newpoint[1])
+ } else {
+ ctx.lineTo(newpoint[0],newpoint[1])
+ }
+
+ }
+ point = newpoint
+ }
+
+ ctx.lineWidth = 1.5*PXSCALE
+ ctx.strokeStyle= widget.lineColor
+ ctx.stroke()
+
+ ctx.font = PXSCALE * 10 + 'px sans-serif'
+ ctx.fillStyle = widget.textColor
+
+
+ ctx.save()
+ ctx.translate(0, widget.height)
+ ctx.rotate(-Math.PI/2)
+
+ ctx.textBaseline = "top"
+ ctx.textAlign = 'left'
+ ctx.fillText(widget.pips.min,12*PXSCALE,2*PXSCALE)
+ ctx.textAlign = 'right'
+ ctx.fillText(widget.pips.max,widget.height-10*PXSCALE,2*PXSCALE)
+ ctx.rotate(Math.PI/2)
+ ctx.restore()
+
+ }
+
+
+
+ widget.fetchValue = function(){
+ var id = widgetData.widgetId
+
+ if (typeof id == 'string' && WIDGETS[id]) {
+ var v = WIDGETS[id][WIDGETS[id].length-1].getValue()
+ widget.data.push(v)
+ widget.value = v
+ } else {
+ widget.data.push(widget.value)
+ }
+
+ widget.data.splice(0,1)
+
+ }
+
+ widget.setValue = function(v) {
+ widget.value = v
+ widget.startLoop()
+ }
+
+ return widget
+}
diff --git a/browser/js/app/widgets/xy.js b/browser/js/app/widgets/xy.js
new file mode 100644
index 00000000..4bb760d0
--- /dev/null
+++ b/browser/js/app/widgets/xy.js
@@ -0,0 +1,209 @@
+var utils = require('./utils'),
+ clip = utils.clip,
+ mapToScale = utils.mapToScale,
+ sendOsc = utils.sendOsc
+
+module.exports.options = {
+ type:'xy',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ css:'',
+
+ separator2:'behaviour',
+
+ snap:false,
+
+ separator3:'osc',
+
+ rangeX:{min:0,max:1},
+ rangeY:{min:0,max:1},
+ logScaleX:false,
+ logScaleY:false,
+ precision:2,
+ path:'auto',
+ preArgs:[],
+ split:false,
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+ var widget = $(`
+
+ `),
+ handle = widget.find('.handle'),
+ pad = widget.find('.xy'),
+ value = {x:widget.find('.x').fakeInput({align:'center'}),y:widget.find('.y').fakeInput({align:'center'})},
+ range = {x:widgetData.rangeX,y:widgetData.rangeY},
+ snap = widgetData.snap,
+ split = widgetData.split?
+ typeof widgetData.split == 'object'?
+ widgetData.split:{x:widgetData.path+'/x',y:widgetData.path+'/y'}
+ :false;
+ logScaleX = widgetData.logScaleX,
+ logScaleY = widgetData.logScaleY,
+ roundFactor = Math.pow(10,widgetData.precision)
+
+
+ if (widgetData.height!='auto') widget.addClass('manual-height')
+
+ pad.width = 0
+ pad.height = 0
+ handle.height = 0
+ handle.width = 0
+ widget.value = undefined
+
+ pad.resize(function(){
+ var width = pad.innerWidth(),
+ height = pad.innerHeight()
+ if (!width || (pad.height==height && pad.width==width)) return
+ pad.width = width
+ pad.height = height
+
+ widget.updateUi(handle.width,handle.height)
+ })
+
+ var off = {x:0,y:0}
+ pad.on('draginit',function(e,data,traversing){
+
+ if (snap || traversing) {
+ var h = ((pad.height-data.offsetY) * 100 / pad.height),
+ w = (data.offsetX * 100 / pad.width)
+
+ widget.updateUi(w,h)
+
+ handle.height = h
+ handle.width = w
+
+ var v = widget.getValue()
+
+ if (vwidget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ }
+
+ off = {x:handle.width,y:handle.height}
+
+ })
+ pad.on('drag',function(e,data){
+
+ var h = clip((-data.deltaY)*100/pad.height+off.y,[0,100]),
+ w = clip((data.deltaX)*100/pad.width+off.x,[0,100])
+
+ widget.updateUi(w,h)
+
+ handle.height = h
+ handle.width = w
+
+ var v = widget.getValue()
+
+ if (vwidget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ })
+
+
+ widget.updateUi = function(w,h) {
+ handle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
+ }
+
+ widget.getValue = function() {
+ var x = mapToScale(handle.width,[0,100],[range.x.min,range.x.max],widgetData.precision,logScaleX),
+ y = mapToScale(handle.height,[0,100],[range.y.min,range.y.max],widgetData.precision,logScaleY)
+
+ return [x,y]
+ }
+ widget.setValue = function(v,send,sync) {
+ if (!v || v.length!=2) return
+
+ for (i in [0,1]) {
+ v[i] = clip(Math.round(v[i]*roundFactor)/roundFactor,[range[['x','y'][i]].min,range[['x','y'][i]].max])
+ }
+
+ var w = mapToScale(v[0],[range.x.min,range.x.max],[0,100],false,logScaleX,true)
+ h = mapToScale(v[1],[range.y.min,range.y.max],[0,100],false,logScaleY,true),
+
+
+ widget.updateUi(w,h)
+
+ handle.height = h
+ handle.width = w
+ widget.value = v
+
+ widget.showValue(v)
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ if (send) widget.sendValue(v)
+ }
+ widget.sendValue = function(v) {
+ var args = widgetData.preArgs.concat(v)
+
+ sendOsc({
+ target:split?false:widgetData.target,
+ path:widgetData.path,
+ args:args,
+ precision:widgetData.precision,
+ })
+ if (split) {
+ sendOsc({
+ target:widgetData.target,
+ path:split.x,
+ args:widgetData.preArgs.concat(v[0]),
+ precision:widgetData.precision,
+ sync:false
+ })
+ sendOsc({
+ target:widgetData.target,
+ path:split.y,
+ args:widgetData.preArgs.concat(v[1]),
+ precision:widgetData.precision,
+ sync:false
+ })
+ }
+ }
+
+ widget.showValue = function(v) {
+ value.x.val(v[0])
+ value.y.val(v[1])
+ }
+
+ value.x.change(function(){
+ var v = widget.getValue()
+ v[0] = clip(value.x.val(),[range.x.min,range.x.max])
+ widget.setValue(v,true,true)
+ })
+ value.y.change(function(){
+ var v = widget.getValue()
+ v[1] = clip(value.y.val(),[range.y.min,range.y.max])
+ widget.setValue(v,true,true)
+ })
+
+ widget.setValue([range.x.min,range.y.min])
+ return widget
+}
diff --git a/browser/js/browser-headless.bundle.js b/browser/js/browser-headless.bundle.js
new file mode 100644
index 00000000..551c5a49
--- /dev/null
+++ b/browser/js/browser-headless.bundle.js
@@ -0,0 +1,11861 @@
+(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o')
+ var blob = new Blob([state],{type : 'text/plain'});
+ down.attr('href', window.URL.createObjectURL(blob))
+ down[0].click()
+ }
+
+ },
+
+ stateGet: function (){
+ var data = []
+ for (i in WIDGETS) {
+ var widget = WIDGETS[i]
+ for (var j=widget.length-1;j>=0;j--) {
+ if (widget[j].setValue && widget[j].getValue) {
+ var v = widget[j].getValue()
+ if (v!=undefined) data.push([i,v])
+ break
+ }
+ }
+ }
+ return data
+ },
+
+ stateLoad: function() {
+ if (WEBFRAME) {
+ IPC.send('stateLoad')
+ } else {
+ var prompt = $(' ')
+ prompt.click()
+ prompt.on('change',function(e){
+ var reader = new FileReader();
+ reader.onloadend = function(e) {
+ var preset = e.target.result
+ module.exports.stateSet(JSON.parse(preset),true)
+ STATE = preset
+ }
+ reader.readAsText(e.target.files[0],'utf-8');
+ })
+ }
+ },
+
+ stateSend: function(){
+ var data = module.exports.stateGet()
+ module.exports.stateSet(data,true)
+
+ },
+
+ stateSet: function(preset,send){
+
+ for (i in preset) {
+ var data = preset[i]
+ if (WIDGETS[data[0]]!=undefined) {
+ for (var i=WIDGETS[data[0]].length-1;i>=0;i--) {
+ if (WIDGETS[data[0]][i].setValue) {
+ WIDGETS[data[0]][i].setValue(data[1],send,false)
+ }
+ }
+ }
+ }
+ },
+
+ toggleFullscreen: function(){
+
+ if (WEBFRAME) {
+ IPC.send('fullscreen')
+ } else {
+ var isInFullScreen = document.webkitIsFullScreen
+
+ if (isInFullScreen) {
+ document.webkitExitFullscreen()
+ } else {
+ document.documentElement.webkitRequestFullScreen()
+ }
+ }
+ },
+
+ sessionBrowse: function(){
+
+ if (WEBFRAME) {
+ IPC.send('sessionBrowse')
+ } else {
+ var prompt = $(' ')
+ prompt.click()
+ prompt.on('change',function(e){
+ var reader = new FileReader();
+ reader.onloadend = function(e) {
+ var session = e.target.result
+ IPC.send('sessionOpen',{file:session})
+ }
+ reader.readAsText(e.target.files[0],'utf-8');
+ })
+ }
+ },
+
+ sessionSave: function() {
+ var sessionfile = JSON.stringify(SESSION,null,' ')
+ if (WEBFRAME) {
+ IPC.send('sessionSave',sessionfile)
+ } else {
+ var down = $(' ')
+ var blob = new Blob([sessionfile],{type : 'text/plain'});
+ down.attr('href', window.URL.createObjectURL(blob))
+ down[0].click()
+ }
+
+ },
+
+ editorEnable: function(){
+ $('.editor-root').attr('data-tab','#container').removeClass('disabled')
+ $('.enable-editor').addClass('on')
+ $('.disable-editor').removeClass('on')
+
+ EDITING = true
+ },
+ editorDisable: function(){
+ $('.widget.ui-resizable').resizable('destroy')
+ $('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
+ $('.editing').removeClass('editing')
+ $('.editor-root').addClass('disabled')
+ $('.editor-container').remove()
+ $('.disable-editor').addClass('on')
+ $('.enable-editor').removeClass('on')
+
+ EDITING = false
+ },
+
+ traversingDisable: function(){
+ $('.traversingEnable, .traversingDisable').toggleClass('on')
+ $(document).trigger('disableTraversingGestures')
+ },
+ traversingEnable: function(){
+ $('.traversingEnable, .traversingDisable').toggleClass('on')
+ $(document).enableTraversingGestures()
+ }
+
+}
+
+},{}],3:[function(require,module,exports){
+var init = require('./init'),
+ actions = require('./actions'),
+ utils = require('./utils'),
+ icon = utils.icon
+
+module.exports = {
+
+ receiveOsc: function(event,data){
+ var data = data || event
+
+ // fetch ids corresponding to the osc path
+ var path = data.path,
+ pathref = path,
+ args = data.args
+
+ if (typeof data.args == 'object') {
+ for (var i=data.args.length-1;i>=0;i--) {
+ var ref = path+'||||'+data.args.slice(0,i).join('||||')
+ if (WIDGETS_BY_PATH[ref]) {
+ pathref = ref
+ args = data.args.slice(i,data.args.length)
+ args = args.length==1?args[0]:args
+ continue
+ }
+ }
+ } else {
+ args = data.args
+ }
+ for (i in WIDGETS_BY_PATH[pathref]) {
+ if (WIDGETS_BY_PATH[pathref][i]) WIDGETS_BY_PATH[pathref][i].setValue(args,false,true)
+ }
+
+
+ },
+
+ stateLoad: function(event,data){
+ var data = data || event
+ data = JSON.parse(data)
+ actions.stateSet(data,true)
+ actions.stateQuickSave(data)
+ },
+
+ sessionList: function(event,data){
+ var data = data || event
+ $('#lobby').append(`
+ `)
+
+ for (i in data) {
+ $('#lobby .list').append(''+data[i]+''+icon('remove')+' ')
+ }
+ $('#lobby .footer').append(''+icon('folder-open')+' Browse ')
+ $('#lobby .footer').append(''+icon('file-o')+' New ')
+ $('#lobby .load').click(function(e){
+ e.stopPropagation()
+ IPC.send('sessionOpen',{path:$(this).data('session')})
+ })
+ $('#lobby a span').click(function(e){
+ e.stopPropagation()
+ IPC.send('sessionRemoveFromHistory',$(this).parent().data('session'))
+ $(this).parents('a').remove()
+ })
+ $('#lobby .browse').click(function(e){
+ e.stopPropagation()
+ actions.sessionBrowse()
+ })
+ $('#lobby .new').click(function(e){
+ e.stopPropagation()
+ init([{}],function(){$('#open-toggle, .enable-editor').click();$('.editor-root').trigger('mousedown.editor')})
+ })
+ },
+
+ sessionOpen: function(event,data){
+ var data = data || event
+ var session = JSON.parse(data)
+ init(session)
+
+ },
+
+ error: function(event,data){
+ var data = data || event
+
+ utils.createPopup(icon('warning')+' '+data.title,data.text)
+ },
+
+ applyStyle: function(event,data){
+ var data = data || event
+ var style = document.createElement('style');
+ style.innerHTML = data.join('');
+ document.body.appendChild(style);
+ if (data.indexOf('--pixel-scale')!=-1) {
+ PXSCALE = data.match(/--pixel-scale\s*:\s*([^;]*)/)[1]
+ INITIALZOOM = PXSCALE
+ }
+ }
+
+}
+
+},{"./actions":2,"./init":9,"./utils":13}],4:[function(require,module,exports){
+var correctPosition = function (m, parent){
+ var pos = m.offset(),
+ width = m.outerWidth(),
+ height = m.outerHeight(),
+ totalWidth = $('body').outerWidth(),
+ totalHeight = $('body').outerHeight(),
+ leftAdjust = parent=='body'?0:parent.outerWidth()-2
+
+ if (width + pos.left > totalWidth) {
+ m.css({'margin-left':totalWidth-(width + pos.left + leftAdjust)})
+ }
+ if (height + pos.top > totalHeight) {
+ m.css({'margin-top':totalHeight-(height + pos.top)})
+ }
+}
+
+var ev = 'fake-click'
+
+
+var menu = function(e,actions,parent){
+
+ var m = $('')
+ if (parent=='body') {
+ m.css({top:e.pageY+'px',left:e.pageX+'px'})
+ }
+
+ for (label in actions) {
+
+ if (typeof actions[label] == 'object') {
+
+ var item = $(`${label}
`).appendTo(m).on(ev,function(e){e.stopPropagation()})
+ menu(e,actions[label],item)
+
+
+ } else {
+
+ $(`${label}
`).on(ev + '.editor',function(){
+ var callback = actions[label]
+ return function(e){
+ callback()
+ $('.context-menu').remove()
+ }
+ }()).appendTo(m)
+ }
+ }
+
+ m.appendTo(parent)
+
+
+
+ if (parent=='body') {
+ correctPosition(m,parent)
+ } else {
+ parent.hover(function(){correctPosition(m,parent)})
+ }
+
+}
+
+module.exports = menu
+
+},{}],5:[function(require,module,exports){
+var widgets = require('../widgets'),
+ widgetOptions = widgets.widgetOptions,
+ sync = widgets.sync,
+ parser = require('../parser')
+ parsewidgets = parser.widgets,
+ parsetabs = parser.tabs,
+ ui = require('../ui'),
+ actions = require('../actions'),
+ sidepanelCreateToggle = require('../sidepanel').createToggle,
+ editObject = function(a,b){require('./edit-objects').editObject(a,b,true)},
+ editSession = function(a,b){require('./edit-objects').editSession(a,b,true)},
+ purgeStores = require('./purge')
+
+
+var getObjectData = function(obj){
+ var path = []
+
+ if (obj.hasClass('tab')) {
+ return TABS['#'+obj.attr('id')].data
+ }
+
+ if (obj.is('#container')) {
+ return SESSION
+ }
+
+ while(true) {
+ if (obj.hasClass('widget')) {
+ path.unshift(obj.index())
+ path.unshift('widgets')
+ } else if (obj.hasClass('tab')){
+ path.unshift(obj.data('index'))
+ path.unshift('tabs')
+ } else if (obj.is('#container')) {
+ break
+ }
+
+ obj = obj.parent()
+ }
+
+ path.splice(0,1)
+
+ for (var i=0,data=SESSION, path=path, len=path.length; i${data.label} `)
+
+ editObject(newContainer,data)
+
+ } else if (container.attr('id')=='container') {
+ // session
+ var newContainer = $('#container')
+ container.empty()
+ parsetabs(data,container,true)
+
+ editSession(newContainer,data)
+ sidepanelCreateToggle()
+
+ }
+
+ newContainer.find('[data-tab]:first-child').click()
+
+ $(window).resize()
+
+ purgeStores(purgetabs)
+
+ // restore state
+ actions.stateSet(state,false)
+ sync()
+ ui.scrolls()
+ $('#sidepanel').scrollTop(scroll)
+
+
+ // return updated node
+ return newContainer
+
+}
+
+
+var incrementWidget = function(data){
+
+ if (!data) return
+
+ delete data.linkId
+
+ var id = data.id,
+ label = data.label,
+ path = data.path
+
+ if (id && id==label) {
+ data.label = 'auto'
+ }
+ if (id && path == '/'+id) {
+
+ data.path = 'auto'
+
+ } else if (path){
+ var pathref
+ while (WIDGETS_BY_PATH[pathref]) {
+ path = path.replace(/([0-9]*)$/,function(m){
+ var n = parseInt(m)+1
+ n = isNaN(n)?1:n
+ return n
+ })
+ pathref = data.preArgs&&data.preArgs.length?data.path+'||||'+data.preArgs.join('||||'):data.path
+ }
+ WIDGETS_BY_PATH[pathref] = []
+ data.path = path
+
+ }
+
+ if (id) {
+ while (WIDGETS[id]) {
+ id = id.replace(/([0-9]*)$/,function(m){
+ var n = parseInt(m)+1
+ n = isNaN(n)?1:n
+ return n
+ })
+ }
+ WIDGETS[id] = []
+ data.id = id
+
+ }
+
+
+ for (i in data) {
+ if (typeof data[i] == 'object') data[i] = incrementWidget(data[i])
+ }
+
+ return data
+
+}
+
+module.exports = {
+ updateDom:updateDom,
+ getObjectData:getObjectData,
+ incrementWidget:incrementWidget
+}
+
+},{"../actions":2,"../parser":10,"../sidepanel":11,"../ui":12,"../widgets":14,"./edit-objects":6,"./purge":8}],6:[function(require,module,exports){
+var updateDom = require('./data-workers').updateDom,
+ widgetOptions = require('../widgets').widgetOptions
+
+var ev = 'fake-click'
+
+
+var editObject = function(container, data, refresh){
+
+ if (!refresh && (container.hasClass('editing') || $(`a[data-tab="#${container.attr('id')}"]`).hasClass('editing'))) return
+
+ var isWidget = container.hasClass('widget')
+
+ $('.editing').removeClass('editing')
+ $('.widget.ui-resizable').resizable('destroy')
+ $('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
+
+
+ if (isWidget) {
+ $(container).addClass('editing')
+ } else {
+ $(`[data-tab="#${container.attr('id')}"]`).addClass('editing').click()
+ $(container).parent().addClass('editing')
+ }
+
+
+
+ $('.editor-container').remove()
+ $('.editor').append('
')
+ var form = $('
').appendTo('.editor-container')
+
+
+ var params = isWidget?widgetOptions[data.type]:{label:''}
+
+ for (i in params) {
+
+ if (i.indexOf('separator')!=-1) {
+ $(`${params[i]}
`).appendTo(form)
+ continue
+ } else if (data[i]===undefined) {
+ continue
+ }
+
+ // Common options edit
+ if (i!='widgets' && i!='tabs') {
+
+ var type = typeof data[i],
+ value = type == 'object'?JSON.stringify(data[i]):data[i],
+ wrapper = $('
').appendTo(form),
+ label = $(`${i} `).appendTo(wrapper),
+ input
+
+ if (i=='type') {
+
+ input = $(` `)
+
+ for (t in widgetOptions) {
+ input.append(`${t} `)
+ }
+ select = $('
').append(input)
+ select.appendTo(wrapper)
+
+ } else if (typeof params[i]=='boolean') {
+
+ input = $(` `)
+ input.click(function(){
+ $(this).val(!eval($(this).val())).trigger('change')
+ })
+ input.appendTo(wrapper)
+
+ } else {
+
+ input = $(` `)
+ input.appendTo(wrapper)
+
+ }
+
+
+ input.on('change',function(){
+ // var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
+ var v
+ try {
+ eval(`v=${$(this).val()}`)
+ } catch(err) {
+ v = $(this).val()
+ }
+
+ data[$(this).attr('title')] = v
+ if (v==='') delete data[$(this).attr('title')]
+ updateDom(container,data)
+ })
+
+ }
+
+ }
+
+ // widget list edit
+ if (((isWidget&&widgetOptions[data.type].widgets) || (container.hasClass('tab'))) && (!data.tabs||!data.tabs.length)) {
+
+ var list = $(''),
+ wrapper = $('
').appendTo(form)
+
+ var editItem = function(i) {
+ return function(){
+ container.find('.widget').first().siblings().addBack().eq(i).trigger(ev)
+ }
+ }
+
+ for (i in data.widgets) {
+
+
+ var item = $(`${data.widgets[i].id||data.widgets[i].label} `)
+ .appendTo(list)
+ .click(editItem(i))
+
+ var remove = $(' ')
+ .appendTo(item)
+ .click(function(e){
+ e.stopPropagation()
+ data.widgets.splice($(this).parent().attr('data-index'),1)
+ updateDom(container,data)
+ })
+ }
+
+ list.sortable({
+ forcePlaceholderSize: true,
+ items: '.sortables',
+ start:function(){$(this).sortable( "refreshPositions" )},
+ update: function(e,ui){
+ var prevIndex = $(ui.item).attr('data-index')
+ var newIndex = $(ui.item).index()
+
+ data.widgets.splice(newIndex, 0, data.widgets.splice(prevIndex, 1)[0])
+
+ updateDom(container,data)
+ }
+ })
+
+ var add = $(`+ `).appendTo(list).click(function(){
+ data.widgets = data.widgets || []
+ data.widgets.push({})
+
+ updateDom(container,data)
+ })
+
+ $('widgets ').appendTo(wrapper)
+ list.appendTo(wrapper)
+
+ }
+
+ // tab list edit
+ if (((isWidget&&widgetOptions[data.type].tabs) || (container.hasClass('tab'))) && (!data.widgets||!data.widgets.length)) {
+ //tabs
+ var list = $(''),
+ wrapper = $('
').appendTo(form)
+
+
+ var editItem = function(i) {
+ return function(){
+ container.find('.tab').first().siblings().addBack().eq(i).trigger(ev)
+ }
+ }
+
+ for (i in data.tabs) {
+ var item = $(`${data.tabs[i].label} `)
+ .appendTo(list)
+ .click(editItem(i))
+
+ var remove = $(' ')
+ .appendTo(item)
+ .click(function(e){
+ e.stopPropagation()
+ data.tabs.splice($(this).parent().attr('data-index'),1)
+ updateDom(container,data)
+ })
+ }
+
+ list.sortable({
+ start:function(){$(this).sortable( "refreshPositions" )},
+ forcePlaceholderSize: true,
+ items: '.sortables',
+ update: function(e,ui){
+ var prevIndex = $(ui.item).attr('data-index')
+ var newIndex = $(ui.item).index()
+
+ data.tabs.splice(newIndex, 0, data.tabs.splice(prevIndex, 1)[0])
+
+ updateDom(container,data)
+ }
+ })
+
+ var add = $(`+ `).appendTo(list).click(function(){
+ data.tabs = data.tabs || []
+ data.tabs.push({})
+
+ updateDom(container,data)
+ })
+
+ $('tabs ').appendTo(wrapper)
+ list.appendTo(wrapper)
+ }
+
+ if (data.hasOwnProperty('width')) {
+ var handleTarget
+ container.resizable({
+ handles:'s, e, se',
+ helper: "ui-helper",
+ start: function(event, ui){
+ handleTarget = $(event.originalEvent.target)
+ },
+ stop: function( event, ui ) {
+ if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-s')) data.height = Math.max(ui.size.height,30)/PXSCALE
+ if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-e')) data.width = Math.max(ui.size.width,30)/PXSCALE
+ updateDom(container,data)
+ }
+ })
+ }
+
+ if (data.hasOwnProperty('top')) {
+ container.draggable({
+ cursor:'-webkit-grabbing',
+ stop: function( event, ui ) {
+ event.preventDefault()
+ data.top = (ui.helper.position().top + container.parent().scrollTop())/PXSCALE
+ data.left = (ui.helper.position().left + container.parent().scrollLeft())/PXSCALE
+ ui.helper.remove()
+ updateDom(container,data)
+ },
+ handle:'.ui-draggable-handle, > .label',
+ snap:'.widget',
+ snapTolerance:5,
+ helper:function(){return $('
').css({height:container.outerHeight(),width:container.outerWidth()})}
+ }).append('
')
+ }
+
+}
+
+var editSession = function(container,data,refresh){
+
+ if (!refresh && $('.editor-root').hasClass('editing')) return
+
+ $('.widget.ui-resizable').resizable('destroy')
+ $('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
+
+
+ $('.editing').removeClass('editing')
+ $('.editor-root, #container').addClass('editing')
+
+ $('.editor-container').remove()
+ $('.editor').append('
')
+
+
+ var form = $('
').appendTo('.editor-container'),
+ list = $(''),
+ wrapper = $('
').appendTo(form)
+
+
+ var editItem = function(i) {
+ return function(){
+ container.find('.tab').first().siblings().addBack().eq(i).trigger(ev)
+ }
+ }
+
+ for (i in data) {
+ var item = $(`${data[i].label} `)
+ .appendTo(list)
+ .click(editItem(i))
+
+ var remove = $(' ')
+ .appendTo(item)
+ .click(function(e){
+ e.stopPropagation()
+ data.splice($(this).parent().attr('data-index'),1)
+ updateDom(container,data)
+ })
+ }
+
+
+ list.sortable({
+ start:function(){$(this).sortable( "refreshPositions" )},
+ forcePlaceholderSize: true,
+ items: '.sortables',
+ update: function(e,ui){
+ var prevIndex = $(ui.item).attr('data-index')
+ var newIndex = $(ui.item).index()
+
+ data.splice(newIndex, 0, data.splice(prevIndex, 1)[0])
+
+ updateDom(container,data)
+ }
+ })
+
+ var add = $(`+ `).appendTo(list).click(function(){
+ data = data || []
+ data.push({})
+
+ updateDom(container,data)
+ })
+
+ $('tabs ').appendTo(wrapper)
+ list.appendTo(wrapper)
+
+
+ $('.editor-container').append(form)
+
+}
+
+module.exports = {
+ editObject:editObject,
+ editSession:editSession
+}
+
+},{"../widgets":14,"./data-workers":5}],7:[function(require,module,exports){
+var data = require('./data-workers'),
+ getObjectData = data.getObjectData,
+ updateDom = data.updateDom,
+ incrementWidget = data.incrementWidget,
+ edit = require('./edit-objects'),
+ editObject = edit.editObject,
+ editSession = edit.editSession,
+ createPopup = require('../utils').createPopup,
+ widgetOptions = require('../widgets').widgetOptions,
+ widgetCategories = require('../widgets').categories,
+ menu = require('./context-menu')
+
+
+
+var init = function(){
+
+ $('body').off('.editor').on('fake-click fake-right-click',function(e,d){
+
+ if (!EDITING) return
+
+ // ignore mouse event when fired by a simulated touch event
+ if (e.type=='mousedown' && e.originalEvent.sourceCapabilities.firesTouchEvents) return
+
+ $('.context-menu').remove()
+
+ var target = $(e.target).is('.widget:not(.not-editable), .tab, [data-tab], #container')?
+ $(e.target):
+ $(e.target).closest('.widget:not(.not-editable), .tab, [data-tab], #container')
+
+ if (!target.length) return
+
+ var container = target.attr('data-tab')?TABS[target.attr('data-tab')].tab:target,
+ type = target.hasClass('widget')?'widget':'tab',
+ parent = container.parent(),
+ index = container.index(),
+ data = getObjectData(container)
+
+ if (container.attr('id')=='container') {
+ editSession(container,SESSION)
+ } else {
+ editObject(container,data)
+ }
+
+
+ if (e.type!='fake-right-click') return
+
+ if (container.attr('id')=='container') {
+ menu(d,{
+ ' Add tab': function(){
+ data.push({})
+ updateDom(container,data)
+ }
+ },'body')
+
+ return
+ }
+
+
+ var actions = {}
+
+ // actions[' Edit'] = function(){editObject(container,data)}
+
+ if (type=='widget') actions[' Copy'] = function(){CLIPBOARD=data}
+
+ if (type=='widget') actions[' Cut'] = function(){
+ CLIPBOARD=JSON.parse(JSON.stringify(data))
+ var parentContainer = container.parents('.widget, .tab, #container').first()
+ parentData = getObjectData(parentContainer)
+
+ parentData.widgets.splice(container.index(),1)
+ updateDom(parentContainer,parentData)
+ }
+
+ if (((type=='widget'&&widgetOptions[data.type].widgets) || (type=='tab')) && (!data.tabs||!data.tabs.length)) {
+
+ if (CLIPBOARD!=null) {
+ actions[' Paste'] = {
+ ' ID + 1':function(){
+ data.widgets = data.widgets || []
+ var newData = incrementWidget(JSON.parse(JSON.stringify(CLIPBOARD)))
+
+
+ if (!target.attr('data-tab')) {
+ newData.top = d.offsetY
+ newData.left= d.offsetX
+ } else {
+ delete newData.top
+ delete newData.left
+ }
+
+ data.widgets.push(newData)
+ updateDom(container,data)
+ },
+ ' Clone':function(){
+ data.widgets = data.widgets || []
+ var newData = JSON.parse(JSON.stringify(CLIPBOARD))
+ if (!target.attr('data-tab')) {
+ newData.top = d.offsetY
+ newData.left= d.offsetX
+ } else {
+ delete newData.top
+ delete newData.left
+ }
+ data.widgets.push(newData)
+ updateDom(container,data)
+ }
+ }
+ }
+
+ actions[' Add widget'] = {}
+ var createFunction = function(widgetType,container,data){
+ return function() {
+ data.widgets = data.widgets || []
+ var newData = {type:widgetType}
+ if (!target.attr('data-tab')) {
+ newData.top = d.offsetY
+ newData.left= d.offsetX
+ }
+ data.widgets.push(newData)
+ updateDom(container,data)
+ }
+ }
+ for (category in widgetCategories) {
+ actions[' Add widget'][category] = {}
+ for (t in widgetCategories[category]) {
+ var wtype = widgetCategories[category][t]
+ actions[' Add widget'][category][wtype] = createFunction(wtype,container,data)
+
+ }
+ }
+
+ }
+ if (((type=='widget'&&widgetOptions[data.type].tabs) || (type=='tab')) && (!data.widgets||!data.widgets.length)) {
+
+ actions[' Add tab'] = function(){
+ data.tabs = data.tabs || []
+ data.tabs.push({})
+ updateDom(container,data)
+ }
+
+ }
+
+ actions[' Delete'] = function(){
+ var popup = createPopup('Are you sure ?',`
+
+ `)
+ $('.confirm-delete').click(function(){
+ popup.close()
+ var parentContainer = container.parents('.widget, .tab, #container').first()
+ parentData = getObjectData(parentContainer)
+
+
+ if (type=='widget') {
+ parentData.widgets.splice(container.index(),1)
+ } else if (type=='tab' && parentContainer.attr('id')!='container') {
+ parentData.tabs.splice(container.data('index'),1)
+ } else {
+ parentData.splice(container.data('index'),1)
+ }
+
+ updateDom(parentContainer,parentData)
+ })
+ $('.cancel-delete').click(function(){
+ popup.close()
+ })
+ $(document).on('keydown.popup', function(e){
+ if (e.keyCode==13) $('.confirm-delete').click()
+ })
+
+
+ }
+
+ menu(d,actions,'body')
+
+ })
+
+}
+
+module.exports = init
+
+},{"../utils":13,"../widgets":14,"./context-menu":4,"./data-workers":5,"./edit-objects":6}],8:[function(require,module,exports){
+module.exports = function(purgetabs) {
+
+ // prune tabs store
+ var count, newcount, formerBuffuredTabs, bufferedTabs
+
+ if (purgetabs) {
+ while (true) {
+ // we need to do that several times since tabs are referenced in each of their parents
+
+ // get all buffered tabs
+ formerBuffuredTabs = []
+ for (i in TABS) {
+ formerBuffuredTabs.push(TABS[i].tab[0])
+ }
+
+ // remove deleted tabs that are not referenced (have no navigation link pointing to them)
+ var $f = $(formerBuffuredTabs)
+ for (i in TABS) {
+ if (!($f.find(`[data-tab="${i}"]`).length || i== '#container')) {
+ delete TABS[i]
+ }
+ }
+
+ newcount = Object.keys(TABS).length
+ if (count == newcount) break
+ count = newcount
+
+ }
+ }
+
+
+ bufferedTabs = []
+ for (i in TABS) {
+ bufferedTabs.push(TABS[i].tab[0])
+ }
+
+ // prune widget stores
+ // if widgets cannot be found in buffered tabs, it must be unreferenced
+ var $b = $(bufferedTabs)
+ for (i in WIDGETS) {
+ for (var j=WIDGETS[i].length-1;j>=0;j--) {
+ if (!$b.find(WIDGETS[i][j]).length) {
+ WIDGETS[i].splice(j,1)
+ }
+ }
+ if (!WIDGETS[i].length) {
+ delete WIDGETS[i]
+ }
+ }
+ for (i in WIDGETS_LINKED) {
+ for (var j=WIDGETS_LINKED[i].length-1;j>=0;j--) {
+ if (!$b.find(WIDGETS_LINKED[i][j]).length) {
+ WIDGETS_LINKED[i].splice(j,1)
+ }
+ }
+ if (!WIDGETS_LINKED[i].length) {
+ delete WIDGETS_LINKED[i]
+ }
+ }
+ for (i in WIDGETS_BY_PATH) {
+ for (var j=WIDGETS_BY_PATH[i].length-1;j>=0;j--) {
+ if (!$b.find(WIDGETS_BY_PATH[i][j]).length) {
+ WIDGETS_BY_PATH[i].splice(j,1)
+ }
+ }
+ if (!WIDGETS_BY_PATH[i].length) {
+ delete WIDGETS_BY_PATH[i]
+ }
+ }
+}
+
+},{}],9:[function(require,module,exports){
+var parsetabs = require('./parser').tabs,
+ ui = require('./ui'),
+ sync = require('./widgets').sync,
+ editorDisable = require('./actions').editorDisable,
+ editorInit = require('./editor/init')
+
+module.exports = function(session,callback) {
+
+ $('#lobby').remove()
+ $('#container').empty()
+ var spinner = $('').appendTo('#container')
+
+ setTimeout(function(){
+ parsetabs(session,$('#container'),true)
+
+ // var t = $('
').appendTo('body')
+ // for (id in TABS) {
+ // if (id!='#container') {
+ // t[0].appendChild(TABS[id].tab[0])
+ // }
+ // }
+ // setTimeout(function(){
+ // t.detach()
+ // },250)
+
+
+ ui.init()
+ editorDisable()
+ editorInit()
+ sync()
+
+
+ setTimeout(function(){
+ spinner.remove()
+ if (!callback) return
+ setTimeout(function(){
+ callback()
+ },25)
+ },25)
+ },25)
+
+}
+
+},{"./actions":2,"./editor/init":7,"./parser":10,"./ui":12,"./widgets":14}],10:[function(require,module,exports){
+var widgets = require('./widgets'),
+ widgetOptions = widgets.widgetOptions,
+ createWidget = widgets.createWidget,
+ icon = require('./utils').icon
+
+var getIterator = function(id,type){
+ var iterator = MISC.iterators[type]
+ if (iterator[id]==undefined) iterator[id] = 0
+ iterator[id] += 1
+ return iterator[id]
+}
+
+var hashCode = function(s){
+ return s.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
+}
+
+module.exports.tabs = function(data,parent,main,parentLabel){
+
+ if (main) {
+ // Reset Globals
+ WIDGETS = {}
+ WIDGETS_LINKED = {}
+ WIDGETS_BY_PATH = {}
+ SESSION = data
+ for (i in TABS) {
+ if (i!='#container') {
+ TABS[i].parent.remove()
+ TABS[i].tab.remove()
+ }
+ }
+ TABS['#container'] = {
+ tab:$('#container')
+ }
+
+ MISC.iterators.tab = {}
+ }
+
+ var main = main?'main ':'',
+ nav = $(document.createElement('div')).addClass(main + 'navigation'),
+ navtabs = $(document.createElement('ul')).addClass('tablist'),
+ content = $(document.createElement('div')).addClass('content')
+
+
+ for (i in data) {
+ var tabData = data[i]
+
+
+ var label = tabData.label||tabData.id||'Unnamed',
+ hash = hashCode(label),
+ id = 'tab_'+hash+'_'+getIterator('tab'+hash,'tab')
+
+ tabData.label = label
+ delete tabData.id
+
+ navtabs.append(`${label} `)
+
+ var tabContent = $(`
`)
+ tabContent.data(tabData)
+
+
+ if (tabData.tabs && tabData.tabs.length) {
+ module.exports.tabs(tabData.tabs,tabContent,false,label)
+ } else if (tabData.widgets && tabData.widgets.length) {
+ module.exports.widgets(tabData.widgets,tabContent)
+ }
+
+ // content.append(tabContent)
+ TABS['#'+id]= {
+ parent:content,
+ tab:tabContent,
+ data:tabData
+ }
+
+ }
+
+ nav[0].appendChild(navtabs[0])
+ parent[0].appendChild(nav[0])
+ parent[0].appendChild(content[0])
+}
+
+
+
+module.exports.widgets = function(data,parent) {
+
+ for (i in data) {
+ var widgetData = data[i]
+
+ widgetData.type = widgetData.type || 'fader'
+
+ var tmpWidgetOptions = JSON.parse(JSON.stringify(widgetOptions))
+
+ for (i in tmpWidgetOptions[widgetData.type]) {
+ if (i.indexOf('separator')==-1 && widgetData[i]===undefined) widgetData[i] = tmpWidgetOptions[widgetData.type][i]
+ }
+
+ if (widgetData.id=='auto') {
+ var id
+ while (!id || WIDGETS[id]) {
+ id=widgetData.type+'_'+getIterator(widgetData.type,'widget')
+ }
+ widgetData.id = id
+ }
+
+ widgetData.path = widgetData.path=='auto'?'/' + widgetData.id:widgetData.path
+ widgetData.target = widgetData.target?(Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]):false
+
+ for (i in widgetData) {
+ if (widgetOptions[widgetData.type][i]===undefined && i!='type') {delete widgetData[i]}
+ }
+
+
+ for (t in {width:'',height:'',top:'',left:''}) {
+ widgetData[t] = `${widgetData[t]}`.indexOf('-')!=-1?0:widgetData[t]
+ }
+
+ if (parent.hasClass('strip')) {
+ delete widgetData.top
+ delete widgetData.left
+ }
+
+ if (widgetData.preArgs!=undefined) {
+ widgetData.preArgs = Array.isArray(widgetData.preArgs)?widgetData.preArgs:[widgetData.preArgs]
+ }
+ if (widgetData.target!=undefined) {
+ widgetData.target = Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]
+ }
+
+ var width = parseFloat(widgetData.width)==widgetData.width?parseFloat(widgetData.width)+'rem' : widgetData.width,
+ height = parseFloat(widgetData.height)==widgetData.height?parseFloat(widgetData.height)+'rem' : widgetData.height,
+ left = parseFloat(widgetData.left)==widgetData.left?parseFloat(widgetData.left)+'rem' : widgetData.left,
+ top = parseFloat(widgetData.top)==widgetData.top?parseFloat(widgetData.top)+'rem' : widgetData.top
+
+
+ var styleW = widgetData.width&&widgetData.width!='auto'?`width:${width};min-width:auto;`:'',
+ styleH = widgetData.height&&widgetData.height!='auto'?`height:${height};min-height:auto;`:'',
+ styleL = widgetData.left&&widgetData.left!='auto'||widgetData.left==0?`left:${left};`:'',
+ styleT = widgetData.top&&widgetData.top!='auto'||widgetData.top==0?`top:${top};`:''
+
+ var label = widgetData.label == 'auto'?
+ widgetData.id:
+ typeof widgetData.label == 'string' && widgetData.label.indexOf('icon:')!=-1?
+ icon(widgetData.label.split(':')[1].trim().replace('fa-','')):
+ widgetData.label
+
+ var widgetContainer = $(`
+
+ `)
+
+ if (widgetData.color && widgetData.color!='auto') widgetContainer[0].style.setProperty('--color-custom',widgetData.color)
+
+ if (widgetData.label===false) widgetContainer.addClass('nolabel')
+
+ // create widget
+ var widgetInner = createWidget[widgetData.type](widgetData,widgetContainer)
+
+
+ widgetContainer[0].appendChild(widgetInner[0])
+
+ // store widget reference for cross widget sync
+ if (WIDGETS[widgetData.id]==undefined) WIDGETS[widgetData.id] = []
+ WIDGETS[widgetData.id].push(widgetInner)
+
+ // store widget with linkId for widgte linking
+ if (widgetData.linkId && widgetData.linkId.length) {
+ if (WIDGETS_LINKED[widgetData.linkId]==undefined) WIDGETS_LINKED[widgetData.linkId] = []
+ WIDGETS_LINKED[widgetData.linkId].push(widgetInner)
+ }
+
+ // store widget by path and encode preArgs for perfect cross-app sync
+ if (widgetData.path) {
+ var pathref = widgetData.preArgs&&widgetData.preArgs.length?widgetData.path+'||||'+widgetData.preArgs.join('||||'):widgetData.path
+ if (WIDGETS_BY_PATH[pathref]==undefined) WIDGETS_BY_PATH[pathref] = []
+ WIDGETS_BY_PATH[pathref].push(widgetInner)
+ }
+
+ parent[0].appendChild(widgetContainer[0])
+ }
+
+ // Editor needs to get the container object
+ if (data && data.length==1) return widgetContainer
+
+}
+
+},{"./utils":13,"./widgets":14}],11:[function(require,module,exports){
+var actions = require('./actions'),
+ icon = require('./utils').icon
+
+var data = [
+ {
+ actions: [
+ {
+ title:'Fullscreen (F11)',
+ action:actions.toggleFullscreen
+ }
+
+ ]
+ },
+ {
+ title: icon('sliders') + ' State',
+ actions: [
+ {
+ title:'Store',
+ action:actions.stateQuickSave
+ },
+ {
+ title:'Recall',
+ action:actions.stateQuickLoad,
+ class:'disabled quickload'
+ },
+ {
+ title:'Send All',
+ action:actions.stateSend
+ },
+ {
+ title:'Import',
+ action:actions.stateLoad
+ },
+ {
+ title:'Export',
+ action:actions.stateSave
+ }
+ ]
+ },
+ {
+ title: icon('magic') + ' Traversing gestures',
+ actions: [
+ {
+ title:'On',
+ action:actions.traversingEnable,
+ class:'traversingEnable'
+ },
+ {
+ title:'Off',
+ action:actions.traversingDisable,
+ class:'traversingDisable on'
+ }
+ ]
+ },
+ {
+ title: icon('edit') + ' Editor',
+ class:'editor',
+ actions: [
+ {
+ title:'On',
+ action:actions.editorEnable,
+ class:'enable-editor'
+ },
+ {
+ title:'Off',
+ action:actions.editorDisable,
+ class:'on disable-editor'
+ },
+ {
+ title:'Root',
+ class:'editor-root disabled'
+ },
+ {
+ title:'Load',
+ action:actions.sessionBrowse
+ },
+ {
+ title:'Save',
+ action:actions.sessionSave
+ }
+ ]
+ },
+]
+
+var sidepanel = function(data){
+
+ var bindAction = function(el,callback) {
+ el.click(function(){callback()})
+ }
+
+ var html = $('')
+
+ for (i in data) {
+ var itemData = data[i]
+
+ var item = $(' '),
+ inner = $('
').appendTo(item)
+ wrapper = $('
').appendTo(inner)
+
+ if (itemData.title) $(''+itemData.title+'
').prependTo(wrapper)
+ if (itemData.class) inner.attr('class',itemData.class)
+
+ for (j in itemData.actions) {
+ var actionData = itemData.actions[j]
+ var el = $(''+actionData.title+' ').appendTo(wrapper)
+ if (actionData.action) bindAction(el, actionData.action)
+
+ if (actionData.class) el.addClass(actionData.class)
+
+ }
+ item.appendTo(html)
+
+ }
+
+ return html
+
+}(data)
+
+var toggle = function(){
+ $(`${icon('navicon')} `).appendTo('.navigation.main ul').click(function(e){
+ var t = 0
+ if (!$('#sidepanel').hasClass('sidepanel-open')) t = 250
+
+ $('#open-toggle, #sidepanel').toggleClass('sidepanel-open')
+ setTimeout(function(){
+ $('#container').toggleClass('sidepanel-open')
+ $(window).resize()
+ },t)
+ }).on('mousedown touchstart',function(e){e.stopPropagation()})
+
+ // in case where are hot loading a session
+ if ($('#sidepanel').hasClass('sidepanel-open')) {
+ $('#open-toggle, #container').addClass('sidepanel-open')
+ }
+}
+
+module.exports = {
+ init:function(){
+ $('#sidepanel').append(sidepanel)
+ toggle()
+ },
+ createToggle:toggle
+}
+
+},{"./actions":2,"./utils":13}],12:[function(require,module,exports){
+var actions = require('./actions'),
+ icon = require('./utils').icon
+
+var sidepanel = require('./sidepanel').init
+
+// Tabs...
+var tabs = function() {
+ $('#container').click(function(e){
+ var link = e.target
+
+ if (!link.hasAttribute('data-tab') || link.classList.contains('on')) return
+
+ var id = link.getAttribute('data-tab')
+
+ link.classList.add('on')
+
+ var previous = $(link).siblings('.on').removeClass('on').data('tab')
+
+ // TABS[id].tab.appendTo(TABS[id].parent)
+ TABS[id].parent[0].appendChild(TABS[id].tab[0])
+ $(previous).detach()
+
+
+ $(id).find('li[data-tab]:first-child, li.parent + li[data-tab]').each(function(){
+ if (!$(this).siblings('.on').length) $(this).click()
+ })
+
+ $(window).resize()
+
+ })
+ $('li[data-tab]').first().click()
+}
+
+// horizontal scrolling & zoom with mousewheel
+// if shift is pressed (native), or if there is no vertical scrollbar,
+// or if mouse is on h-scrollbar
+var scrollbarHeight = 20
+var scrolls = function(){
+ $('html').on('mousewheel.zoom',function(e) {
+ // console.log(e)
+ if (e.ctrlKey) {
+ e.preventDefault()
+ if (e.originalEvent.deltaY==0) return
+ var d = -e.originalEvent.deltaY/(10*Math.abs(e.originalEvent.deltaY))
+
+ PXSCALE = parseFloat(d)+parseFloat(PXSCALE)
+ document.documentElement.style.setProperty("--pixel-scale",'')
+ document.documentElement.style.setProperty("--pixel-scale",PXSCALE)
+
+ }
+ })
+ $(document).on('keydown.resetzoom', function(e){
+ if (e.keyCode==96||e.keyCode==48) {
+ PXSCALE = INITIALZOOM
+ document.documentElement.style.setProperty("--pixel-scale",'')
+ document.documentElement.style.setProperty("--pixel-scale",PXSCALE)
+ }
+ })
+
+}
+
+
+module.exports = {
+ init: function(){
+ sidepanel()
+ tabs()
+ scrolls()
+ },
+ tabs:tabs,
+ scrolls:scrolls
+}
+
+},{"./actions":2,"./sidepanel":11,"./utils":13}],13:[function(require,module,exports){
+module.exports = {
+
+ createPopup: function(title,content) {
+
+ var popup = $(`
+ `),
+ closer = popup.find('.popup-title .closer')
+
+ closer.click(function(){
+ popup.close()
+ })
+
+
+ popup.close = function(){
+ $(document).off('.popup')
+ popup.remove()
+ }
+
+ popup.find('.popup-content').append(content)
+ $('body').append(popup)
+
+ $(document).on('keydown.popup', function(e){
+ if (e.keyCode==27) popup.close()
+ })
+
+
+
+ return popup
+ },
+ icon: function(i) {
+ return ` `
+ }
+
+}
+
+},{}],14:[function(require,module,exports){
+var widgets = {
+ // sliders
+ fader: require('./widgets/fader'),
+ knob: require('./widgets/knob'),
+
+ // buttons
+ toggle: require('./widgets/toggle'),
+ switch: require('./widgets/switch'),
+ push: require('./widgets/push'),
+
+ // pads
+ xy: require('./widgets/xy'),
+ rgb: require('./widgets/rgb'),
+
+ // matrices
+ multitoggle: require('./widgets/multitoggle'),
+ multipush: require('./widgets/multipush'),
+ multifader: require('./widgets/multifader'),
+
+ // plots
+ led: require('./widgets/led'),
+ plot: require('./widgets/plot'),
+ visualizer: require('./widgets/visualizer'),
+ meter: require('./widgets/meter'),
+ text: require('./widgets/text'),
+
+ // containers
+ strip: require('./widgets/strip'),
+ panel: require('./widgets/panel'),
+}
+
+module.exports.categories = {
+ 'Sliders':['fader','knob'],
+ 'Buttons':['toggle','push','switch'],
+ 'Pads':['xy','rgb'],
+ 'Matrices':['multifader','multitoggle','multipush'],
+ 'Plots':['plot','visualizer','led','meter','text'],
+ 'Containers':['panel','strip']
+}
+
+module.exports.widgetOptions = function(){
+ var r = {}
+ for (i in widgets) {
+ r[i] = widgets[i].options
+ }
+ return r
+}()
+
+module.exports.createWidget = function(){
+ var r = {}
+ for (i in widgets) {
+ r[i] = widgets[i].create
+ }
+ return r
+}()
+
+module.exports.sync = function() {
+ $('body').off('sync.global').on('sync.global',function(e,id,widget,linkId){
+ // Widget that share the same id will update each other
+ // without sending any extra osc message
+ if (WIDGETS[id] && WIDGETS[id].length>1) {
+ var v = widget.getValue()
+ for (i in WIDGETS[id]) {
+ if (!WIDGETS[id][i].is(widget) && WIDGETS[id][i].setValue) {
+ WIDGETS[id][i].setValue(v,false,false)
+ }
+ }
+ }
+ // widgets that share the same linkId will update each other.
+ // Updated widgets will send osc messages normally
+ if (WIDGETS_LINKED[linkId] && WIDGETS_LINKED[linkId].length>1) {
+ var v = widget.getValue()
+ for (i in WIDGETS_LINKED[linkId]) {
+ if (!WIDGETS_LINKED[linkId][i].is(widget) && WIDGETS_LINKED[linkId][i].setValue) {
+ WIDGETS_LINKED[linkId][i].setValue(v,true,false)
+ }
+ }
+ }
+ })
+}
+
+},{"./widgets/fader":15,"./widgets/knob":16,"./widgets/led":17,"./widgets/meter":18,"./widgets/multifader":19,"./widgets/multipush":20,"./widgets/multitoggle":21,"./widgets/panel":22,"./widgets/plot":23,"./widgets/push":24,"./widgets/rgb":25,"./widgets/strip":26,"./widgets/switch":27,"./widgets/text":28,"./widgets/toggle":29,"./widgets/visualizer":31,"./widgets/xy":32}],15:[function(require,module,exports){
+var utils = require('./utils'),
+ clip = utils.clip,
+ mapToScale = utils.mapToScale,
+ sendOsc = utils.sendOsc
+
+module.exports.options = {
+ type:'fader',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ unit:'',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ alignRight:false,
+ horizontal:false,
+ noPip:false,
+ compact:false,
+ color:'auto',
+ css:'',
+
+ separator2:'behaviour',
+
+ snap:false,
+
+ separator3:'osc',
+
+ range:{min:0,max:1},
+ logScale:false,
+ precision:2,
+ meter:false,
+ path:'auto',
+ preArgs:[],
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+ var widget = $(`
+
+ `),
+ gauge = widget.find('.gauge'),
+ knob = widget.find('.knob'),
+ wrapper = widget.find('.fader-wrapper'),
+ fader = widget.find('.fader'),
+ pips = widget.find('.pips'),
+ input = widget.find('.input').fakeInput({align:'center'}),
+ unit = widgetData.unit?' '+widgetData.unit.trim(): '',
+ dimension = widgetData.horizontal?'width':'height',
+ snap = widgetData.snap,
+ logScale = widgetData.logScale,
+ roundFactor = Math.pow(10,widgetData.precision)
+
+
+ if (widgetData.horizontal) {
+ container.addClass('horizontal')
+ } else {
+ if (widgetData.alignRight) container.addClass('align-right')
+ }
+
+ if (widgetData.compact) container.addClass('compact')
+ if (widgetData.noPip) wrapper.addClass('no-pip')
+
+ gauge.size = 0
+ fader.size = 0
+ wrapper.size = 0
+ widget.value = undefined
+
+ if (widgetData.meter) {
+ var parsewidgets = require('../parser').widgets
+ var data = {
+ type:'meter',
+ id: widgetData.id + '/meter',
+ label:false,
+ horizontal:widgetData.horizontal,
+ range:widgetData.range,
+ logScale:widgetData.logScale,
+ path:widgetData.path + '/meter',
+ preArgs:widgetData.preArgs,
+ color:widgetData.color
+ }
+ var element = parsewidgets([data],fader)
+ element[0].classList.add('not-editable')
+ widget[0].classList.add('has-meter')
+ }
+
+
+ var rangeKeys = [],
+ rangeVals = [],
+ rangeLabels = []
+
+ for (k in widgetData.range) {
+ var key = k=='min'?0:k=='max'?100:parseInt(k),
+ val = typeof widgetData.range[k] == 'object'?
+ widgetData.range[k][Object.keys(widgetData.range[k])[0]]:
+ widgetData.range[k],
+ label = typeof widgetData.range[k] == 'object'?
+ Object.keys(widgetData.range[k])[0]:
+ val
+
+ rangeKeys.push(key)
+ rangeVals.push(val)
+ rangeLabels.push(label)
+ }
+
+ var rangeValsMax = Math.max.apply(Math, rangeVals),
+ rangeValsMin = Math.min.apply(Math, rangeVals)
+
+ if (!widgetData.noPip&&!widgetData.compact) {
+ var pipTexts = {}
+ for (k in rangeKeys) {
+ pipTexts[rangeKeys[k]]=rangeLabels[k]
+ }
+
+ var pipsInner = ''
+ for (var i=0;i<=100;i++) {
+ if (pipTexts[i]==undefined) continue
+
+ var pos = dimension=='height'?'bottom':'left';
+
+ var piptext = `${Math.abs(pipTexts[i])>=1000?pipTexts[i]/1000+'k':pipTexts[i]} `
+
+ var add = `
+ ${piptext}
+ `
+ pipsInner = pipsInner + add
+ }
+ pips[0].innerHTML = pipsInner
+ }
+
+
+
+
+
+ fader.resize(function(){
+ fader.size= dimension=='height'?fader.outerHeight():fader.outerWidth()
+ wrapper.size = dimension=='height'?wrapper.outerHeight():wrapper.outerWidth()
+ widget.updateUi(gauge.size)
+ })
+
+ wrapper.on('fake-right-click',function(e){
+ if (!EDITING) {
+ e.stopPropagation()
+ e.preventDefault()
+ input.focus()
+ }
+ })
+
+ wrapper.on('mousewheel',function(e){
+ if (e.originalEvent.wheelDeltaX) return
+
+ e.preventDefault()
+ e.stopPropagation()
+
+ var divider = e.ctrlKey?4:.25
+ gauge.size = clip(gauge.size+e.originalEvent.wheelDelta/(fader.size*divider),[0,100])
+
+ widget.updateUi(gauge.size)
+
+ var v = widget.getValue()
+
+ if (v!=widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+ })
+
+ var off = 0
+ wrapper.on('draginit',function(e,data,traversing){
+ if (snap || traversing) {
+
+ var d = (dimension=='height')?
+ ((fader.size-data.offsetY+(wrapper.size-fader.size)/2) * 100 / fader.size):
+ (data.offsetX - (wrapper.size-fader.size)/2) * 100 / fader.size
+ d = clip(d,[0,100])
+
+ widget.updateUi(d)
+ gauge.size = d
+
+ var v = widget.getValue()
+
+ if (v!=widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ }
+
+ off = gauge.size
+
+ })
+
+
+ wrapper.on('drag',function(e,data){
+
+ var d = (dimension=='height')?-data.deltaY:data.deltaX
+ d = clip(d*100/fader.size+off,[0,100])
+
+ widget.updateUi(d)
+
+ gauge.size = d
+
+ var v = widget.getValue()
+
+ if (v!=widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ })
+
+ widget.updateUi = function(v){
+ var s = v/100,
+ t = dimension=='height'?
+ ['1,'+s+',1','0,'+ Math.round(-s*fader.size) +'px,0']
+ :[s+',1,1',Math.round(s*fader.size) +'px,0,0']
+ gauge[0].setAttribute('style','transform:scale3d('+t[0]+')')
+ knob[0].setAttribute('style','transform:translate3d('+t[1]+')')
+ }
+
+ widget.getValue = function(){
+ var h = clip(gauge.size,[0,100])
+ for (var i=0;i= rangeKeys[i]) {
+ return mapToScale(h,[rangeKeys[i],rangeKeys[i+1]],[rangeVals[i],rangeVals[i+1]],widgetData.precision,logScale)
+ }
+ }
+
+ }
+ widget.setValue = function(v,send,sync) {
+ if (typeof v != 'number') return
+
+ var h,
+ v = clip(Math.round(v*roundFactor)/roundFactor,[rangeValsMin,rangeValsMax])
+ for (var i=0;i= rangeVals[i]) {
+ h = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i],rangeKeys[i+1]],false,logScale,true)
+ break
+ }
+ }
+
+ widget.updateUi(h)
+
+ gauge.size = h
+
+ widget.value = v
+ widget.showValue(v)
+
+
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ if (send) widget.sendValue(v)
+ }
+
+ widget.sendValue = function(v) {
+ var args = widgetData.preArgs.concat(v)
+
+ sendOsc({
+ target:widgetData.target,
+ path:widgetData.path,
+ precision:widgetData.precision,
+ args:args
+ })
+ }
+
+ widget.showValue = function(v) {
+ input.val(v+unit)
+ }
+
+ input.change(function(){
+ widget.setValue(parseFloat(input.val()),true,true)
+ })
+
+ widget.setValue(rangeVals[0])
+
+ return widget
+}
+
+},{"../parser":10,"./utils":30}],16:[function(require,module,exports){
+var utils = require('./utils'),
+ clip = utils.clip,
+ mapToScale = utils.mapToScale,
+ sendOsc = utils.sendOsc
+
+module.exports.options = {
+ type:'knob',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ unit:'',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ noPip:false,
+ compact:false,
+ css:'',
+
+ separator2:'behaviour',
+
+ snap:false,
+
+ separator3:'osc',
+
+ range:{min:0,max:1},
+ logScale:false,
+ precision:2,
+ path:'auto',
+ preArgs:[],
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+ var widget = $(`
+
+ `),
+ wrapper = widget.find('.knob-wrapper'),
+ mask = widget.find('.knob-mask'),
+ knob = widget.find('.knob'),
+ handle = widget.find('.handle'),
+ input = widget.find('.input').fakeInput({align:'center'}),
+ range = widgetData.range,
+ unit = widgetData.unit?' '+widgetData.unit.trim(): '',
+ snap = widgetData.snap,
+ logScale = widgetData.logScale,
+ roundFactor = Math.pow(10,widgetData.precision)
+
+ if (widgetData.noPip) wrapper.addClass('no-pip')
+ if (widgetData.compact) container.addClass('compact')
+
+
+ var rangeKeys = [],
+ rangeVals = [],
+ rangeLabels = []
+
+ for (k in widgetData.range) {
+ var key = k=='min'?0:k=='max'?100:parseInt(k),
+ val = typeof widgetData.range[k] == 'object'?
+ widgetData.range[k][Object.keys(widgetData.range[k])[0]]:
+ widgetData.range[k],
+ label = typeof widgetData.range[k] == 'object'?
+ Object.keys(widgetData.range[k])[0]:
+ val
+
+ rangeKeys.push(key)
+ rangeVals.push(val)
+ rangeLabels.push(label)
+ }
+
+ var rangeValsMax = Math.max.apply(Math, rangeVals),
+ rangeValsMin = Math.min.apply(Math, rangeVals)
+
+
+ var pipmin = Math.abs(rangeLabels[0])>=1000?rangeLabels[0]/1000+'k':rangeLabels[0],
+ pipmax = Math.abs(rangeLabels[rangeLabels.length-1])>=1000?rangeLabels[rangeLabels.length-1]/1000+'k':rangeLabels[rangeLabels.length-1]
+
+
+
+ widget.find('.pip.min').text(pipmin)
+ widget.find('.pip.max').text(pipmax)
+
+ mask.size = 0
+ widget.value = undefined
+
+ wrapper.resize(function(e,width,height){
+
+ var w = Math.floor(Math.min(height,width)*.58)
+
+ if (!w || mask.size==w) return
+ mask.size=w
+ mask[0].setAttribute('style',`height:${w}px;width:${w}px;padding-bottom:0`)
+ wrapper.size = {width:wrapper[0].clientWidth,height:wrapper[0].clientHeight}
+ })
+
+ wrapper.on('fake-right-click',function(e){
+ if (!EDITING) {
+ e.stopPropagation()
+ e.preventDefault()
+ input.focus()
+ }
+ })
+
+ wrapper.on('mousewheel',function(e){
+ if (e.originalEvent.wheelDeltaX) return
+
+ e.preventDefault()
+ e.stopPropagation()
+
+ var divider = e.ctrlKey?48:8
+ knob.rotation = clip(knob.rotation+e.originalEvent.wheelDeltaY/divider,[0,270])
+
+ widget.updateUi(knob.rotation)
+
+ var v = widget.getValue()
+
+ if (v!=widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+ })
+
+
+ knob.rotation = 0
+
+ var offR = 0,
+ offX = 0,
+ offY = 0
+ wrapper.on('draginit',function(e,data,traversing){
+
+ if (snap || traversing) {
+
+ var w = wrapper.size.width,
+ h = wrapper.size.height,
+ x = data.offsetX-w/2,
+ y = data.offsetY-h/2,
+ angle = Math.atan2(-y, -x) * 180 / Math.PI +45,
+ r = angle<-90?angle+360:angle
+ r = (angle>=-90 && angle<-45)?270:r
+ r = clip(r,[0,270])
+
+ offX = x
+ offY = y
+
+ widget.updateUi(r)
+
+ knob.rotation = r
+
+ var v = widget.getValue()
+
+ if (v!=widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ }
+
+ offR = knob.rotation
+ })
+
+ wrapper.on('drag',function(e,data){
+
+ var r = clip(-data.deltaY*2+offR,[0,270])
+
+ if (snap || data.ctrlKey || data.shiftKey) {
+ var w = data.target.clientWidth,
+ h = data.target.clientHeight,
+ x = data.deltaX + offX,
+ y = data.deltaY + offY,
+ angle = Math.atan2(-y, -x) * 180 / Math.PI +45,
+ r = angle<-90?angle+360:angle
+ r = (angle>=-90 && angle<-45)?270:r
+ r = clip(r,[0,270])
+ }
+
+ widget.updateUi(r)
+
+ knob.rotation = r
+
+ var v = widget.getValue()
+
+ if (v!=widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+ })
+
+ widget.updateUi = function(r) {
+ knob[0].setAttribute('style','transform:rotateZ('+r+'deg)')
+ handle[0].setAttribute('style','transform:rotateZ('+(r-45)+'deg)')
+
+ if (r>180) {knob.addClass('d3')}
+ else if (r>90) {knob.removeClass('d3').addClass('d2')}
+ else {knob.removeClass('d3 d2')}
+ }
+
+ widget.getValue = function() {
+ var h = knob.rotation
+ for (var i=0;i= rangeKeys[i]*2.7) {
+ return mapToScale(h,[rangeKeys[i]*2.7,rangeKeys[i+1]*2.7],[rangeVals[i],rangeVals[i+1]],widgetData.precision,logScale)
+ }
+ }
+ }
+ widget.showValue = function(v) {
+ input.val(v+unit)
+ }
+ widget.sendValue = function(v) {
+ var args = widgetData.preArgs.concat(v)
+
+ sendOsc({
+ target:widgetData.target,
+ path:widgetData.path,
+ precision:widgetData.precision,
+ args:args
+ })
+ }
+ widget.setValue = function(v,send,sync) {
+ if (typeof v != 'number') return
+
+ var v = clip(Math.round(v*roundFactor)/roundFactor,[rangeValsMin,rangeValsMax]),
+ r
+
+ for (var i=0;i= rangeVals[i]) {
+ r = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i]*2.7,rangeKeys[i+1]*2.7],false,logScale,true)
+ break
+ }
+ }
+
+ knob.rotation = r
+
+ widget.updateUi(r)
+
+ var v = widget.getValue()
+ widget.value = v
+
+ widget.showValue(v)
+
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ if (send) widget.sendValue(v)
+ }
+ input.change(function(){
+ widget.setValue(parseFloat(input.val()),true,true)
+ })
+
+ widget.setValue(rangeVals[0])
+ return widget
+}
+
+},{"./utils":30}],17:[function(require,module,exports){
+var utils = require('./utils'),
+ mapToScale = utils.mapToScale
+
+module.exports.options = {
+ type:'led',
+ id:'auto',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ css:'',
+
+ separator2:'osc',
+
+ range:{min:0,max:1},
+ logScale:false,
+ preArgs:[],
+ path:'auto'
+}
+module.exports.create = function(widgetData,container) {
+ var widget = $(`
+
+ `),
+ led = widget.find('span'),
+ range = widgetData.range
+
+ widget.setValue = function(v,send,sync){
+ if (typeof v != 'number') return
+ led.css('opacity',mapToScale(v,[range.min,range.max],[0,1],widgetData.precision,widgetData.logScale,true))
+ }
+
+ widget.setValue(range.min)
+
+ return widget
+}
+
+},{"./utils":30}],18:[function(require,module,exports){
+var utils = require('./utils'),
+ clip = utils.clip,
+ mapToScale = utils.mapToScale
+
+module.exports.options = {
+ type:'fader',
+ id:'auto',
+
+ separator1:'style',
+
+ label:'auto',
+ unit:'',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ horizontal:false,
+ color:'auto',
+ css:'',
+
+ separator3:'osc',
+
+ range:{min:0,max:1},
+ logScale:false,
+ path:'auto',
+ preArgs:[]
+}
+
+module.exports.create = function(widgetData,container) {
+ var widget = $(`
+
+ `),
+ level = widget.find('.level'),
+ logScale = widgetData.logScale,
+ dimension = widgetData.horizontal?'width':'height',
+ axe = dimension=='height'?'X':'Y'
+
+
+ if (widgetData.horizontal) widget.addClass('horizontal')
+
+
+ var rangeKeys = [],
+ rangeVals = []
+
+ for (k in widgetData.range) {
+ var key = k=='min'?0:k=='max'?100:parseInt(k),
+ val = typeof widgetData.range[k] == 'object'?
+ widgetData.range[k][Object.keys(widgetData.range[k])[0]]:
+ widgetData.range[k]
+
+ rangeKeys.push(key)
+ rangeVals.push(val)
+ }
+
+
+
+ widget.updateUi = function(v){
+ var s = v/100,
+ t = dimension=='height'?
+ '1,'+s+',1'
+ :s+',1,1'
+ level[0].setAttribute('style','transform:scale3d('+t+')')
+ }
+
+
+ widget.setValue = function(v) {
+ if (typeof v != 'number') return
+
+ var h,
+ v=clip(v,[rangeVals[0],rangeVals.slice(-1)[0]])
+ for (var i=0;i= rangeVals[i]) {
+ h = mapToScale(v,[rangeVals[i],rangeVals[i+1]],[rangeKeys[i],rangeKeys[i+1]],2,logScale,true)
+ break
+ }
+ }
+
+ widget.updateUi(h)
+
+ }
+
+ widget.setValue(rangeVals[0])
+
+ return widget
+}
+
+},{"./utils":30}],19:[function(require,module,exports){
+module.exports.options = {
+ type:'multifader',
+ id:'auto',
+
+ separator0:'Matrix',
+
+ strips:2,
+
+ separator1:'style',
+
+ label:'auto',
+ unit:'',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ compact:false,
+ css:'',
+
+
+ separator2:'osc',
+
+ range:{min:0,max:1},
+ logScale:false,
+ precision:2,
+ path:'auto',
+ preArgs:[],
+ target:[]
+}
+
+module.exports.create = function(widgetData,container) {
+
+ var parsewidgets = require('../parser').widgets
+
+ var widget = $(`
+
+
\
+ `),
+ $document = $(document)
+
+ widget.value = []
+
+ for (var i=0;i
+ \
+ `),
+ $document = $(document)
+
+ widget.value = []
+
+ for (var i=0;i
+ \
+ `),
+ $document = $(document)
+
+ widget.value = []
+
+ for (var i=0;i
+
+ `)
+
+ if (!widgetData.scroll) widget.addClass('noscroll')
+
+ if (widgetData.tabs.length) {
+ parsetabs(widgetData.tabs,widget)
+ widget.addClass('has-tabs')
+ } else {
+ parsewidgets(widgetData.widgets,widget)
+ }
+ return widget
+}
+
+},{"../parser":10}],23:[function(require,module,exports){
+var utils = require('./utils'),
+ mapToScale = utils.mapToScale
+
+module.exports.options = {
+ type:'plot',
+ id:'auto',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ css:'',
+
+ separator2:'plot',
+
+ points:[],
+ rangeX: {min:0,max:1},
+ rangeY: {min:0,max:1},
+ logScaleX: false,
+ logScaleY: false,
+
+ separator3:'osc',
+
+ path:'auto',
+ preArgs:[],
+
+}
+module.exports.create = function(widgetData,container) {
+
+ var widget = $(`
+
+
+
+ `),
+ canvas = widget.find('canvas'),
+ ctx = canvas[0].getContext('2d')
+
+ widget.data = []
+ widget.height = undefined
+ widget.width = undefined
+ widget.linkedWidgets = []
+ widget.visible = false
+ widget.textColor = getComputedStyle(document.documentElement).getPropertyValue('--color-text-fade')
+ widget.pips = {
+ x : {
+ min: Math.abs(widgetData.rangeX.min)>=1000?widgetData.rangeX.min/1000+'k':widgetData.rangeX.min,
+ max: Math.abs(widgetData.rangeX.max)>=1000?widgetData.rangeX.max/1000+'k':widgetData.rangeX.max
+ },
+ y : {
+ min: Math.abs(widgetData.rangeY.min)>=1000?widgetData.rangeY.min/1000+'k':widgetData.rangeY.min,
+ max: Math.abs(widgetData.rangeY.max)>=1000?widgetData.rangeY.max/1000+'k':widgetData.rangeY.max
+ }
+ }
+
+
+
+ if (typeof widgetData.points=='string') {
+
+ widget.linkedWidgets.push(widgetData.points)
+
+ } else if (typeof widgetData.points=='object') {
+
+ for (i in widgetData.points) {
+ for (j in widgetData.points[i]) {
+ if (typeof widgetData.points[i][j] == 'string') {
+ widget.linkedWidgets.push(widgetData.points[i][j])
+ }
+ }
+ }
+ }
+
+
+ canvas.resize(function(){
+ var width = canvas.width(),
+ height = canvas.height()
+
+ if (height==100 && width==100) return
+
+ if (!self.visible) {
+ widget.visible = true
+ widget.lineColor = getComputedStyle(widget[0]).getPropertyValue('--color-accent')
+ }
+
+
+ widget.height=height
+ widget.width=width
+
+ canvas[0].setAttribute('width',width)
+ canvas[0].setAttribute('height',height)
+
+ widget.fetchValues()
+ requestAnimationFrame(widget.draw)
+
+ })
+
+
+ widget.handleSync = function(e,id,w) {
+ if (widget.linkedWidgets.indexOf(id)==-1 || !WIDGETS[id]) return
+ widget.fetchValues()
+ requestAnimationFrame(widget.draw)
+ }
+
+ $('body').on('sync',widget.handleSync)
+
+ widget.draw = function(){
+
+
+ ctx.clearRect(0,0,widget.width,widget.height)
+ ctx.beginPath()
+
+ var first = true
+ var point = []
+
+ for (i in widget.data) {
+ var newpoint = widget.data[i].length?
+ [
+ mapToScale(widget.data[i][0],[widgetData.rangeX.min,widgetData.rangeX.max],[15*PXSCALE,widget.width-15*PXSCALE],0,widgetData.logScaleX,true),
+ mapToScale(widget.data[i][1],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15*PXSCALE,15*PXSCALE],0,widgetData.logScaleY,true),
+ ]
+ :
+ [
+ mapToScale(i,[0,widget.data.length-1],[15*PXSCALE,widget.width-15*PXSCALE],0,widgetData.logScaleX,true),
+ mapToScale(widget.data[i],[widgetData.rangeY.min,widgetData.rangeY.max],[widget.height-15*PXSCALE,15*PXSCALE],0,widgetData.logScaleY,true),
+ ]
+
+
+
+ if (first) {
+ ctx.moveTo(newpoint[0],newpoint[1])
+ first = false
+ } else {
+ ctx.moveTo(point[0],point[1])
+ if (widgetData.logScaleX&&!widgetData.logScaleY) {
+ ctx.quadraticCurveTo(point[0], newpoint[1], newpoint[0], newpoint[1])
+ } else if (widgetData.logScaleY&&!widgetData.logScaleX) {
+ ctx.quadraticCurveTo(newpoint[0], point[1], newpoint[0], newpoint[1])
+ } else {
+ ctx.lineTo(newpoint[0],newpoint[1])
+ }
+
+ }
+ ctx.arc(newpoint[0],newpoint[1],1,0,2*Math.PI)
+ point = newpoint
+ }
+
+ ctx.lineWidth = 1.5*PXSCALE
+ ctx.strokeStyle= widget.lineColor
+ ctx.stroke()
+
+ ctx.font = PXSCALE * 10 + 'px sans-serif'
+ ctx.fillStyle = widget.textColor
+
+
+ ctx.textBaseline = "bottom"
+ ctx.textAlign = 'left'
+ ctx.fillText(widget.pips.x.min,12*PXSCALE,widget.height)
+ ctx.textAlign = 'right'
+ ctx.fillText(widget.pips.x.max,widget.width-10,widget.height)
+
+ ctx.save()
+ ctx.translate(0, widget.height)
+ ctx.rotate(-Math.PI/2)
+
+ ctx.textBaseline = "top"
+ ctx.textAlign = 'left'
+ ctx.fillText(widget.pips.y.min,12*PXSCALE,2*PXSCALE)
+ ctx.textAlign = 'right'
+ ctx.fillText(widget.pips.y.max,widget.height-10*PXSCALE,2*PXSCALE)
+ ctx.rotate(Math.PI/2)
+ ctx.restore()
+
+ }
+
+
+
+ widget.fetchValues = function(){
+ var data = [],
+ points = widgetData.points
+
+ if (typeof points=='string' && WIDGETS[points]) {
+
+ data = WIDGETS[points][WIDGETS[points].length-1].getValue()
+
+ } else if (typeof points=='object') {
+
+ for (i in points) {
+
+ data[i] = []
+ for (k in [0,1]) {
+ if (typeof points[i][k] == 'string' && WIDGETS[points[i][k]]) {
+ data[i][k] = WIDGETS[points[i][k]][WIDGETS[points[i][k]].length-1].getValue()
+ } else {
+ data[i][k] = points[i][k]
+ }
+ }
+
+ }
+
+ }
+
+ if (data.length) widget.data = data
+ }
+
+ widget.setValue = function(v) {
+ widget.data = v
+ requestAnimationFrame(widget.draw)
+ }
+
+ return widget
+}
+
+},{"./utils":30}],24:[function(require,module,exports){
+var sendOsc = require('./utils').sendOsc
+
+module.exports.options = {
+ type:'push',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ css:'',
+
+ separator2:'osc',
+
+ on:1,
+ off:0,
+ precision:2,
+ path:'auto',
+ preArgs:[],
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+
+
+ var widget = $(`
+
+
+
\
+ `),
+ $document = $(document),
+ light = widget.find('.light')[0]
+
+ widget.value = widget.find('span')
+ widget.state = 0
+ widget.active = 0
+ widget.lastChanged = 'state'
+
+ widget.on('drag',function(e){e.stopPropagation()})
+ widget.on('draginit.push',function(){
+ widget.off('draginit.push')
+ widget.fakeclick()
+ })
+
+ widget.fakeclick = function(){
+ if (!widget.active) widget.setValuePrivate(widgetData.on,true,true)
+ $document.on('dragend.push',function(){
+ widget.setValuePrivate(widgetData.off,true,true)
+ $document.off('dragend.push')
+ widget.on('draginit.push',function(){
+ widget.off('draginit.push')
+ widget.fakeclick()
+ })
+ })
+ }
+
+ widget.getValue = function() {
+ return widget[widget.lastChanged]?widgetData.on:widgetData.off
+ }
+
+ widget.setValuePrivate = function(v,send,sync) {
+ if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
+ widget.addClass('active')
+ widget.active = 1
+ if (send) widget.sendValue(v)
+ widget.lastChanged = 'active'
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ } else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
+ widget.removeClass('active')
+ widget.active = 0
+ if (send) widget.sendValue(v)
+ widget.lastChanged = 'active'
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+ }
+
+ widget.setValue = function(v,send,sync) {
+ if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
+ widget.addClass('on')
+ widget.state = 1
+ if (send) widget.sendValue(v)
+ widget.lastChanged = 'state'
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ } else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
+ widget.removeClass('on')
+ widget.state = 0
+ if (send) widget.sendValue(v)
+ widget.lastChanged = 'state'
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+ }
+
+ widget.sendValue = function(v) {
+ if (v===false) return
+ var args = widgetData.preArgs.concat(v)
+ sendOsc({
+ target:widgetData.target,
+ path:widgetData.path,
+ precision:widgetData.precision,
+ args:args
+ })
+ }
+ widget.setValue()
+ return widget
+}
+
+},{"./utils":30}],25:[function(require,module,exports){
+var utils = require('./utils'),
+ clip = utils.clip,
+ mapToScale = utils.mapToScale,
+ hsbToRgb = utils.hsbToRgb,
+ rgbToHsb = utils.rgbToHsb,
+ sendOsc = utils.sendOsc
+
+module.exports.options = {
+ type:'rgb',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ css:'',
+
+ separator2:'behaviour',
+
+ snap:false,
+
+ separator3:'osc',
+
+ precision:0,
+ path:'auto',
+ preArgs:[],
+ split:false,
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+
+ var widget = $(`
+
`),
+ rgbHandle = widget.find('.rgb .handle'),
+ hueHandle = widget.find('.hue .handle'),
+ pad = widget.find('.xy'),
+ huePad = widget.find('.hue'),
+ rgbBg = pad.find('.bg')[0],
+ value = {r:widget.find('.r').fakeInput({align:'center'}),g:widget.find('.g').fakeInput({align:'center'}),b:widget.find('.b').fakeInput({align:'center'})},
+ snap = widgetData.snap,
+ split = widgetData.split?
+ typeof widgetData.split == 'object'?
+ widgetData.split:{r:widgetData.path+'/r',g:widgetData.path+'/g',b:widgetData.path+'/b'}
+ :false
+
+
+ pad.width = 0
+ pad.height = 0
+ rgbHandle.height = 0
+ rgbHandle.width = 0
+ hueHandle.width = 0
+ widget.value = undefined
+
+ pad.resize(function(){
+ var width = pad.innerWidth(),
+ height = pad.innerHeight()
+ if (!width || (pad.height==height && pad.width==width)) return
+ pad.width = width
+ pad.height = height
+ rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*rgbHandle.width/100}px, -${pad.height*rgbHandle.height/100}px,0)`)
+
+ })
+
+
+ var rgbOff = {x:0,y:0}
+ pad.on('draginit',function(e,data,traversing){
+ if (snap || traversing) {
+
+ var h = ((pad.height-data.offsetY) * 100 / pad.height),
+ w = (data.offsetX * 100 / pad.width)
+
+ rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
+ rgbHandle.height = h
+ rgbHandle.width = w
+
+ var v = widget.getValue()
+
+ if (v
widget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ }
+
+ rgbOff = {x:rgbHandle.width,y:rgbHandle.height}
+
+ })
+ pad.on('drag',function(e,data){
+
+ var h = clip((-data.deltaY)*100/pad.height+rgbOff.y,[0,100]),
+ w = clip(data.deltaX*100/pad.width+rgbOff.x,[0,100])
+
+ rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
+ rgbHandle.height = h
+ rgbHandle.width = w
+
+ var v = widget.getValue()
+
+ if (vwidget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ })
+
+
+ var hueOff = 0
+ huePad.on('draginit',function(e,data,traversing){
+ if (snap || traversing) {
+
+ var d = (data.offsetX * 100 / pad.width)
+ hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*d/100}px,0,0)`)
+ hueHandle.width = d
+
+
+ var h = clip(hueHandle.width*3.6,[0,360]),
+ rgb = hsbToRgb({h:h,s:100,b:100})
+
+ rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
+
+ var v = widget.getValue()
+
+ if (vwidget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ }
+
+ hueOff = hueHandle.width
+
+ })
+
+
+ huePad.on('drag',function(e,data){
+
+ var w = clip(data.deltaX*100/pad.width+hueOff,[0,100])
+ hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px,0,0)`)
+ hueHandle.width = w
+
+ var h = clip(hueHandle.width*3.6,[0,360]),
+ rgb = hsbToRgb({h:h,s:100,b:100})
+
+ rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
+
+ var v = widget.getValue()
+
+ if (vwidget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ })
+
+
+
+
+
+ widget.getValue = function() {
+ var s = clip(rgbHandle.width,[0,100]),
+ l = clip(rgbHandle.height,[0,100]),
+ h = mapToScale(hueHandle.width,[0,100],[0,360],widgetData.precision),
+ rgb = hsbToRgb({h:h,s:s,b:l})
+ return [rgb.r,rgb.g,rgb.b]
+ }
+ widget.setValue = function(v,send,sync) {
+ if (!v || v.length!=3) return
+
+ for (i in [0,1,2]) {
+ v[i] = clip(v[i],[0,255])
+ }
+
+
+ var hsb = rgbToHsb({r:v[0],g:v[1],b:v[2]})
+
+ var w = mapToScale(hsb.s,[0,100],[0,100],false),
+ h = mapToScale(hsb.b,[0,100],[0,100],false),
+ hueW = mapToScale(hsb.h,[0,360],[0,100],false)
+
+ rgbHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
+ hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*hueW/100}px,0,0)`)
+
+ rgbHandle.height = h
+ rgbHandle.width = w
+ hueHandle.width = hueW
+ widget.value = v
+
+
+ var rgb = hsbToRgb({h:hsb.h,s:100,b:100})
+ rgbBg.setAttribute('style','background-color:rgb('+rgb.r+','+rgb.g+','+rgb.b+')')
+
+ widget.showValue(v)
+
+
+
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ if (send) widget.sendValue(v)
+ }
+ widget.sendValue = function(v) {
+ var args = widgetData.preArgs.concat(v)
+
+ sendOsc({
+ target:split?false:widgetData.target,
+ path:widgetData.path,
+ args:args,
+ precision:widgetData.precision,
+ })
+ if (split) {
+ sendOsc({
+ target:widgetData.target,
+ path:split.r,
+ args:widgetData.preArgs.concat(v[0]),
+ precision:widgetData.precision,
+ sync:false
+ })
+ sendOsc({
+ target:widgetData.target,
+ path:split.g,
+ args:widgetData.preArgs.concat(v[1]),
+ precision:widgetData.precision,
+ sync:false
+ })
+ sendOsc({
+ target:widgetData.target,
+ path:split.b,
+ args:widgetData.preArgs.concat(v[2]),
+ precision:widgetData.precision,
+ sync:false
+ })
+ }
+ }
+
+
+
+ widget.showValue = function(v) {
+ value.r.val(v[0])
+ value.g.val(v[1])
+ value.b.val(v[2])
+ }
+ value.r.change(function(){
+ var r = clip(value.r.val(),[0,255])
+ var v = widget.getValue()
+ widget.setValue([r,v[1],v[2]],true,true)
+ })
+ value.g.change(function(){
+ var g = clip(value.g.val(),[0,255])
+ var v = widget.getValue()
+ widget.setValue([v[0],g,v[2]],true,true)
+ })
+ value.b.change(function(){
+ var b = clip(value.b.val(),[0,255])
+ var v = widget.getValue()
+ widget.setValue([v[0],v[1],b],true,true)
+ })
+
+ widget.setValue([0,0,0])
+
+ return widget
+}
+
+},{"./utils":30}],26:[function(require,module,exports){
+
+module.exports.options = {
+ type:'strip',
+ id:'auto',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ horizontal:false,
+ color:'auto',
+ css:'',
+
+ separator2:'children',
+
+ widgets:[]
+}
+module.exports.create = function(widgetData,container) {
+
+ var parsewidgets = require('../parser').widgets
+
+ var widget = $(`
+
+
+ `)
+ if (widgetData.horizontal) {
+ container.addClass('horizontal')
+ } else {
+ container.addClass('vertical')
+ }
+
+ parsewidgets(widgetData.widgets,widget)
+
+ return widget
+}
+
+},{"../parser":10}],27:[function(require,module,exports){
+var sendOsc = require('./utils').sendOsc
+
+module.exports.options = {
+ type:'switch',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ horizontal:false,
+ color:'auto',
+ css:'',
+
+ separator2:'osc',
+
+ values:{"Value 1":1,"Value 2":2},
+ precision:2,
+ path:'auto',
+ preArgs:[],
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+
+ var widget = $(`
+
+
+ `),
+ $document = $(document)
+
+ if (widgetData.horizontal) {
+ widget.addClass('horizontal')
+ }
+
+ widget.values = []
+
+ for (k in widgetData.values) {
+ widget.values.push(widgetData.values[k])
+ $(''+k+'
').data({value:widgetData.values[k]}).appendTo(widget)
+ }
+
+ widget.value = undefined
+
+ widget.find('.value').on('draginit',function(e,dd){
+ var data = $(this).data()
+ if (data.value!=widget.value || widget.value===undefined) widget.setValue(data.value,true,true)
+ })
+
+
+
+ widget.getValue = function() {
+ return widget.value
+ }
+ widget.setValue = function(v,send,sync) {
+ var i = widget.values.indexOf(v)
+ if (i!=-1) {
+ widget.value = widget.values[i]
+ widget.find('.on').removeClass('on')
+ widget.find('.value').eq(i).addClass('on').removeClass('ripple').addClass('ripple').delay(250).queue(function(next){
+ $(this).removeClass('ripple')
+ next()
+ })
+ if (send) widget.sendValue(widget.value)
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ }
+ widget.sendValue = function(v) {
+ var args = widgetData.preArgs.concat(v)
+
+ sendOsc({
+ target:widgetData.target,
+ path:widgetData.path,
+ precision:widgetData.precision,
+ args:args
+ })
+ }
+ return widget
+}
+
+},{"./utils":30}],28:[function(require,module,exports){
+var utils = require('./utils'),
+ mapToScale = utils.mapToScale
+
+module.exports.options = {
+ type:'text',
+ id:'auto',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ vertical:false,
+ color:'auto',
+ css:'',
+
+ separator2:'osc',
+
+ preArgs:[],
+ path:'auto',
+ defaultText:''
+}
+module.exports.create = function(widgetData,container) {
+ var widget = $(`
+
+
+ `),
+ label = widgetData.defaultText!==''?
+ widgetData.defaultText:
+ widgetData.label===false?
+ widgetData.id:
+ widgetData.label=='auto'?
+ widgetData.id:
+ widgetData.label,
+ text = label
+
+
+ if (widgetData.vertical) widget.addClass('vertical')
+
+ widget.setValue = function(v,send,sync){
+ text = typeof v=='object' && !v.length?label:v
+ widget.text(text)
+ }
+
+ widget.getValue = function(){
+ return text
+ }
+
+ widget.setValue(label)
+
+ return widget
+}
+
+},{"./utils":30}],29:[function(require,module,exports){
+var sendOsc = require('./utils').sendOsc
+
+module.exports.options = {
+ type:'toggle',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ css:'',
+
+ separator2:'osc',
+
+ on:1,
+ off:0,
+ precision:2,
+ path:'auto',
+ preArgs:[],
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+
+ var widget = $(`
+ \
+ `),
+ $document = $(document),
+ light = widget.find('.light')[0]
+
+ widget.value = widget.find('span')
+ widget.state = 0
+
+ widget.on('drag',function(e){e.stopPropagation()})
+ widget.on('draginit.toggle',function(){
+ widget.off('draginit.toggle')
+ widget.fakeclick()
+ })
+
+ widget.fakeclick = function(){
+ var newVal = widget.state?widgetData.off:widgetData.on
+ widget.setValue(newVal,true,true)
+ $document.on('dragend.toggle',function(){
+ $document.off('dragend.toggle')
+ widget.on('draginit.toggle',function(){
+ widget.off('draginit.toggle')
+ widget.fakeclick()
+ })
+ })
+ }
+
+
+ widget.getValue = function() {
+ return widget.state?widgetData.on:widgetData.off
+ }
+ widget.setValue = function(v,send,sync) {
+ if (v===widgetData.on || (v=='false'&&widgetData.on===false)) {
+ widget.addClass('on')
+ widget.state = 1
+ if (send) widget.sendValue(widgetData.on)
+ } else if (v===widgetData.off || (v=='false'&&widgetData.off===false)) {
+ widget.removeClass('on')
+ widget.state = 0
+ if (send) widget.sendValue(widgetData.off)
+ }
+
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+
+ }
+ widget.sendValue = function(v) {
+ if (v===false) return
+ var args = widgetData.preArgs.concat(v)
+
+ sendOsc({
+ target:widgetData.target,
+ path:widgetData.path,
+ precision:widgetData.precision,
+ args:args
+ })
+ }
+ widget.setValue()
+ return widget
+}
+
+},{"./utils":30}],30:[function(require,module,exports){
+module.exports = {
+
+ sendOsc: function(data){
+ IPC.send('sendOsc', data)
+ },
+
+ clip: function(value,range) {
+ var value = parseFloat(value)
+
+ if (isNaN(value)) value = range[0]
+ return Math.max(Math.min(range[0],range[1]),Math.min(value,Math.max(range[0],range[1])))
+
+ },
+
+ // map a value from a scale to another input and output must be range arrays
+ mapToScale: function(value,rangeIn,rangeOut,precision,log,revertlog) {
+
+ var value = module.exports.clip(value,[rangeIn[0],rangeIn[1]]),
+ roundFactor = precision!=undefined?Math.pow(10,precision):100,
+
+
+ value = log?
+ revertlog?
+ (Math.pow(10,((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])))/9-1/9) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
+ :Math.log10(((value-rangeIn[0])/(rangeIn[1]-rangeIn[0]))*9+1) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
+ :((value-rangeIn[0])/(rangeIn[1]-rangeIn[0])) * (rangeOut[1]-rangeOut[0]) + rangeOut[0]
+
+ value = Math.max(Math.min(rangeOut[0],rangeOut[1]),Math.min(value,Math.max(rangeOut[0],rangeOut[1])))
+
+ if (precision!==false) value = Math.round(value*roundFactor)/roundFactor
+
+
+ return value
+
+ },
+
+ hsbToRgb: function (hsb) {
+ var rgb = {}
+ var h = hsb.h
+ var s = hsb.s*255/100
+ var v = hsb.b*255/100
+ if(s == 0) {
+ rgb.r = rgb.g = rgb.b = v
+ } else {
+ var t1 = v
+ var t2 = (255-s)*v/255
+ var t3 = (t1-t2)*(h%60)/60
+ if(h==360) h = 0
+ if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
+ else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
+ else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
+ else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
+ else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
+ else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
+ else {rgb.r=0; rgb.g=0; rgb.b=0}
+ }
+ return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)}
+ },
+
+ rgbToHsb: function (rgb) {
+ var hsb = {h: 0, s: 0, b: 0}
+ var min = Math.min(rgb.r, rgb.g, rgb.b)
+ var max = Math.max(rgb.r, rgb.g, rgb.b)
+ var delta = max - min
+ hsb.b = max
+ hsb.s = max != 0 ? 255 * delta / max : 0
+ if (hsb.s != 0) {
+ if (rgb.r == max) hsb.h = (rgb.g - rgb.b) / delta
+ else if (rgb.g == max) hsb.h = 2 + (rgb.b - rgb.r) / delta
+ else hsb.h = 4 + (rgb.r - rgb.g) / delta
+ } else hsb.h = 0
+ hsb.h *= 60
+ if (hsb.h < 0) hsb.h += 360
+ hsb.s *= 100/255
+ hsb.b *= 100/255
+ return hsb
+ }
+}
+
+},{}],31:[function(require,module,exports){
+var utils = require('./utils'),
+ mapToScale = utils.mapToScale,
+ clip = utils.clip
+
+module.exports.options = {
+ type:'visualizer',
+ id:'auto',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ css:'',
+
+ separator2:'plot',
+
+ widgetId:'',
+ duration:1,
+ range: {min:0,max:1},
+ logScale: false,
+
+ separator3:'osc',
+
+ path:'auto',
+ preArgs:[],
+}
+module.exports.create = function(widgetData,container) {
+
+ var widget = $(`
+
+
+
+ `),
+ canvas = widget.find('canvas'),
+ ctx = canvas[0].getContext('2d')
+
+ widget.height = 0
+ widget.width = 0
+ widget.visible = false
+ widget.textColor = getComputedStyle(document.documentElement).getPropertyValue('--color-text-fade')
+ widget.pips = {
+ min: Math.abs(widgetData.range.min)>=1000?widgetData.range.min/1000+'k':widgetData.range.min,
+ max: Math.abs(widgetData.range.max)>=1000?widgetData.range.max/1000+'k':widgetData.range.max
+ }
+ widget.length = Math.round(clip(60*widgetData.duration,[8,4096]))
+ widget.data = new Array(widget.length)
+ widget.value = widgetData.range.min
+
+ canvas.resize(function(){
+ var width = canvas.width(),
+ height = canvas.height()
+
+ if (height==100 && width==100) return
+
+ if (!self.visible) {
+ widget.visible = true
+ widget.lineColor = getComputedStyle(widget[0]).getPropertyValue('--color-accent')
+ }
+
+ widget.height=height
+ widget.width=width
+
+ canvas[0].setAttribute('width',width)
+ canvas[0].setAttribute('height',height)
+
+ requestAnimationFrame(widget.draw)
+
+ })
+
+
+ widget.handleSync = function(e,id,w) {
+ if (widgetData.widgetId!=id || !WIDGETS[id]) return
+ widget.startLoop()
+ }
+
+ $('body').on('sync',widget.handleSync)
+
+
+ widget.cancel = false
+ widget.loop = false
+
+ widget.startLoop = function(){
+
+ if (widget.cancel) clearTimeout(widget.cancel)
+
+ widget.cancel = setTimeout(function(){
+ clearInterval(widget.loop)
+ widget.loop = false
+ widget.cancel = false
+ },1000*widgetData.duration)
+
+ if (widget.loop) return
+
+ widget.loop = setInterval(function(){
+ widget.fetchValue()
+ widget.draw()
+ },1000*widgetData.duration/widget.length)
+ }
+
+
+ widget.draw = function(){
+ ctx.clearRect(0,0,widget.width,widget.height)
+ ctx.beginPath()
+
+ var first = true
+ var point = []
+
+ for (var i=widget.length-1;i>=0;i=i-1) {
+ var newpoint = [
+ mapToScale(i,[0,widget.length-1],[15*PXSCALE,widget.width-15*PXSCALE],1),
+ mapToScale(widget.data[i],[widgetData.range.min,widgetData.range.max],[widget.height-15*PXSCALE,15*PXSCALE],1,widgetData.logScale,true),
+ ]
+ if (first) {
+ ctx.moveTo(newpoint[0],newpoint[1])
+ first = false
+ } else {
+ if (widgetData.logScale) {
+ ctx.quadraticCurveTo(newpoint[0], point[1], newpoint[0], newpoint[1])
+ } else {
+ ctx.lineTo(newpoint[0],newpoint[1])
+ }
+
+ }
+ point = newpoint
+ }
+
+ ctx.lineWidth = 1.5*PXSCALE
+ ctx.strokeStyle= widget.lineColor
+ ctx.stroke()
+
+ ctx.font = PXSCALE * 10 + 'px sans-serif'
+ ctx.fillStyle = widget.textColor
+
+
+ ctx.save()
+ ctx.translate(0, widget.height)
+ ctx.rotate(-Math.PI/2)
+
+ ctx.textBaseline = "top"
+ ctx.textAlign = 'left'
+ ctx.fillText(widget.pips.min,12*PXSCALE,2*PXSCALE)
+ ctx.textAlign = 'right'
+ ctx.fillText(widget.pips.max,widget.height-10*PXSCALE,2*PXSCALE)
+ ctx.rotate(Math.PI/2)
+ ctx.restore()
+
+ }
+
+
+
+ widget.fetchValue = function(){
+ var id = widgetData.widgetId
+
+ if (typeof id == 'string' && WIDGETS[id]) {
+ var v = WIDGETS[id][WIDGETS[id].length-1].getValue()
+ widget.data.push(v)
+ widget.value = v
+ } else {
+ widget.data.push(widget.value)
+ }
+
+ widget.data.splice(0,1)
+
+ }
+
+ widget.setValue = function(v) {
+ widget.value = v
+ widget.startLoop()
+ }
+
+ return widget
+}
+
+},{"./utils":30}],32:[function(require,module,exports){
+var utils = require('./utils'),
+ clip = utils.clip,
+ mapToScale = utils.mapToScale,
+ sendOsc = utils.sendOsc
+
+module.exports.options = {
+ type:'xy',
+ id:'auto',
+ linkId:'',
+
+ separator1:'style',
+
+ label:'auto',
+ left:'auto',
+ top:'auto',
+ width:'auto',
+ height:'auto',
+ color:'auto',
+ css:'',
+
+ separator2:'behaviour',
+
+ snap:false,
+
+ separator3:'osc',
+
+ rangeX:{min:0,max:1},
+ rangeY:{min:0,max:1},
+ logScaleX:false,
+ logScaleY:false,
+ precision:2,
+ path:'auto',
+ preArgs:[],
+ split:false,
+ target:[]
+}
+module.exports.create = function(widgetData,container) {
+ var widget = $(`
+
+ `),
+ handle = widget.find('.handle'),
+ pad = widget.find('.xy'),
+ value = {x:widget.find('.x').fakeInput({align:'center'}),y:widget.find('.y').fakeInput({align:'center'})},
+ range = {x:widgetData.rangeX,y:widgetData.rangeY},
+ snap = widgetData.snap,
+ split = widgetData.split?
+ typeof widgetData.split == 'object'?
+ widgetData.split:{x:widgetData.path+'/x',y:widgetData.path+'/y'}
+ :false;
+ logScaleX = widgetData.logScaleX,
+ logScaleY = widgetData.logScaleY,
+ roundFactor = Math.pow(10,widgetData.precision)
+
+
+ if (widgetData.height!='auto') widget.addClass('manual-height')
+
+ pad.width = 0
+ pad.height = 0
+ handle.height = 0
+ handle.width = 0
+ widget.value = undefined
+
+ pad.resize(function(){
+ var width = pad.innerWidth(),
+ height = pad.innerHeight()
+ if (!width || (pad.height==height && pad.width==width)) return
+ pad.width = width
+ pad.height = height
+
+ widget.updateUi(handle.width,handle.height)
+ })
+
+ var off = {x:0,y:0}
+ pad.on('draginit',function(e,data,traversing){
+
+ if (snap || traversing) {
+ var h = ((pad.height-data.offsetY) * 100 / pad.height),
+ w = (data.offsetX * 100 / pad.width)
+
+ widget.updateUi(w,h)
+
+ handle.height = h
+ handle.width = w
+
+ var v = widget.getValue()
+
+ if (vwidget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ }
+
+ off = {x:handle.width,y:handle.height}
+
+ })
+ pad.on('drag',function(e,data){
+
+ var h = clip((-data.deltaY)*100/pad.height+off.y,[0,100]),
+ w = clip((data.deltaX)*100/pad.width+off.x,[0,100])
+
+ widget.updateUi(w,h)
+
+ handle.height = h
+ handle.width = w
+
+ var v = widget.getValue()
+
+ if (vwidget.value) {
+ widget.value = v
+
+ widget.sendValue(v)
+ widget.showValue(v)
+
+ widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ }
+
+ })
+
+
+ widget.updateUi = function(w,h) {
+ handle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px, -${pad.height*h/100}px,0)`)
+ }
+
+ widget.getValue = function() {
+ var x = mapToScale(handle.width,[0,100],[range.x.min,range.x.max],widgetData.precision,logScaleX),
+ y = mapToScale(handle.height,[0,100],[range.y.min,range.y.max],widgetData.precision,logScaleY)
+
+ return [x,y]
+ }
+ widget.setValue = function(v,send,sync) {
+ if (!v || v.length!=2) return
+
+ for (i in [0,1]) {
+ v[i] = clip(Math.round(v[i]*roundFactor)/roundFactor,[range[['x','y'][i]].min,range[['x','y'][i]].max])
+ }
+
+ var w = mapToScale(v[0],[range.x.min,range.x.max],[0,100],false,logScaleX,true)
+ h = mapToScale(v[1],[range.y.min,range.y.max],[0,100],false,logScaleY,true),
+
+
+ widget.updateUi(w,h)
+
+ handle.height = h
+ handle.width = w
+ widget.value = v
+
+ widget.showValue(v)
+ if (sync) widget.trigger('sync',[widgetData.id,widget,widgetData.linkId])
+ if (send) widget.sendValue(v)
+ }
+ widget.sendValue = function(v) {
+ var args = widgetData.preArgs.concat(v)
+
+ sendOsc({
+ target:split?false:widgetData.target,
+ path:widgetData.path,
+ args:args,
+ precision:widgetData.precision,
+ })
+ if (split) {
+ sendOsc({
+ target:widgetData.target,
+ path:split.x,
+ args:widgetData.preArgs.concat(v[0]),
+ precision:widgetData.precision,
+ sync:false
+ })
+ sendOsc({
+ target:widgetData.target,
+ path:split.y,
+ args:widgetData.preArgs.concat(v[1]),
+ precision:widgetData.precision,
+ sync:false
+ })
+ }
+ }
+
+ widget.showValue = function(v) {
+ value.x.val(v[0])
+ value.y.val(v[1])
+ }
+
+ value.x.change(function(){
+ var v = widget.getValue()
+ v[0] = clip(value.x.val(),[range.x.min,range.x.max])
+ widget.setValue(v,true,true)
+ })
+ value.y.change(function(){
+ var v = widget.getValue()
+ v[1] = clip(value.y.val(),[range.y.min,range.y.max])
+ widget.setValue(v,true,true)
+ })
+
+ widget.setValue([range.x.min,range.y.min])
+ return widget
+}
+
+},{"./utils":30}],33:[function(require,module,exports){
+WEBFRAME = false
+
+// mainProcess & renderProcess communication engine
+// electron's ipc module is not available here, we use socket.io as a replacement
+var socket = require('socket.io-client')
+
+IPC = socket.connect()
+IPC.send = IPC.emit
+
+
+require('./app')
+
+},{"./app":1,"socket.io-client":39}],34:[function(require,module,exports){
+// jQuery drag event handler
+// note: triggerHandler() is used instead of trigger() when event bubblig is not
+// necessary, this increases performances a lot.
+;(function($){
+ var events = {
+ touch:{start:'touchstart',stop:'touchend touchcancel',move:'touchmove',touch:true},
+ mouse:{start:'mousedown',stop:'mouseup',move:'mousemove',out:'mouseout',touch:false}
+ },
+
+
+ $document = $(document),
+ getOffset = function(obj) {
+ var offsetLeft = 0
+ var offsetTop = 0
+ if (obj) {
+ do {
+ if (!isNaN(obj.offsetLeft)) {
+ offsetLeft += obj.offsetLeft - obj.scrollLeft
+ }
+ if (!isNaN(obj.offsetTop)) {
+ offsetTop += obj.offsetTop - obj.scrollTop
+ }
+ } while(obj = obj.offsetParent )
+ }
+
+ return {left: offsetLeft, top: offsetTop}
+ }
+
+
+ $.event.special.draginit = $.event.special.drag = {
+ setup:function(){
+
+ var $this = $(this)
+
+ if ($this.data('dragSetup')) return
+ $this.data('dragSetup','true')
+
+
+ // mouse single touch handler
+ var previousEvent = null,
+ target = null,
+ traversing = false,
+ mouseStartHandler = function(e){
+
+ // ignore mouse event when fired by a simulated touch event
+ if (e.originalEvent.sourceCapabilities.firesTouchEvents) return
+
+ isPointerDown = true
+ target = $this
+ previousEvent = e
+
+ e.speedX = 0
+ e.speedY = 0
+ e.deltaX = 0
+ e.deltaY = 0
+
+ target.triggerHandler('draginit',[e,e.originalEvent.traversing])
+
+ $document.on(events.mouse.move,mouseMoveHandler)
+ $document.on(events.mouse.stop,mouseStopHandler)
+ $document.on(events.mouse.out,mouseOutHandler)
+
+ },
+ mouseMoveHandler = function(e){
+ e.stopPropagation()
+
+ e.speedX = e.pageX - previousEvent.pageX
+ e.speedY = e.pageY - previousEvent.pageY
+ e.deltaX = e.speedX + previousEvent.deltaX
+ e.deltaY = e.speedY + previousEvent.deltaY
+
+
+ if (e.originalEvent.traversing) {
+ target = $(e.target)
+ e.preventDefault()
+ target.triggerHandler('draginit',[e,e.originalEvent.traversing])
+ } else {
+ target.triggerHandler('drag',[e,e.originalEvent.traversing])
+ }
+
+ previousEvent = e
+ },
+ mouseStopHandler = function(e){
+ e.stopPropagation()
+
+ // ignore mouse event when fired by a simulated touch event
+ if (e.originalEvent.sourceCapabilities.firesTouchEvents) return
+
+ e.speedX = e.pageX - previousEvent.pageX
+ e.speedY = e.pageY - previousEvent.pageY
+ e.deltaX = e.deltaX + previousEvent.deltaX
+ e.deltaY = e.deltaY + previousEvent.deltaY
+
+
+ target.trigger('dragend',[e,e.originalEvent.traversing])
+ isPointerDown = false
+ $document.off(events.mouse.move,mouseMoveHandler)
+ $document.off(events.mouse.stop,mouseStopHandler)
+ $document.off(events.mouse.out,mouseOutHandler)
+ },
+ mouseOutHandler = function(e){
+ if (e.originalEvent.traversing) {
+ e.stopPropagation()
+
+ e.speedX = e.pageX - previousEvent.pageX
+ e.speedY = e.pageY - previousEvent.pageY
+ e.deltaX = e.deltaX + previousEvent.deltaX
+ e.deltaY = e.deltaY + previousEvent.deltaY
+
+ target.trigger('dragend',[e,e.originalEvent.traversing])
+
+ previousEvent = e
+
+ }
+ }
+
+
+ $this.on(events.mouse.start,mouseStartHandler)
+
+
+ // multi touch hanlder
+ window.targets = window.targets || {}
+ window.previousTouches = window.previousTouches || {}
+ window.touchActive = window.touchActive || false
+
+ var self = this,
+ touchStartHandler = function(e){
+ e.preventDefault()
+
+ var oE = e.originalEvent
+
+ for (i in oE.changedTouches) {
+ if (isNaN(i)) continue
+
+ var touch = oE.changedTouches[i],
+ id = touch.identifier
+
+ targets[id] = $(touch.target)
+ previousTouches[id] = touch
+
+ touch.speedX = 0
+ touch.speedY = 0
+
+ touch.deltaX = 0
+ touch.deltaY = 0
+
+ var off = getOffset(touch.target)
+ touch.offsetX = touch.pageX-off.left
+ touch.offsetY = touch.pageY-off.top
+
+ targets[id].triggerHandler('draginit',[touch,e.originalEvent.traversing])
+
+ }
+
+ if (!touchActive) {
+ $document.on(events.touch.move,touchMoveHandler)
+ $document.on(events.touch.stop,touchStopHandler)
+ touchActive = true
+ }
+
+ },
+ touchMoveHandler = function(e){
+
+ var oE = e.originalEvent
+
+ for (i in oE.changedTouches) {
+ if (isNaN(i)) continue
+
+
+ var touch = oE.changedTouches[i],
+ id = touch.identifier
+
+ if (e.originalEvent.traversing) {
+ targets[id] = $(document.elementFromPoint(touch.clientX, touch.clientY))
+ }
+
+ // touched[targets[id]] = touched[targets[id]]?touched[targets[id]]+1:1
+
+ touch.speedX = touch.pageX - previousTouches[id].pageX
+ touch.speedY = touch.pageY - previousTouches[id].pageY
+
+ touch.deltaX = touch.speedX + previousTouches[id].deltaX
+ touch.deltaY = touch.speedY + previousTouches[id].deltaY
+
+ touch.offsetX = previousTouches[id].offsetX+touch.speedX
+ touch.offsetY = previousTouches[id].offsetY+touch.speedY
+
+ if (e.originalEvent.traversing) {
+ touch.traversing = true
+ var previousTarget = document.elementFromPoint(previousTouches[id].clientX, previousTouches[id].clientY)
+ if (targets[id][0]!=previousTarget) {
+ var off = getOffset(targets[id][0])
+ touch.offsetX = touch.pageX-off.left
+ touch.offsetY = touch.pageY-off.top
+ $(previousTarget).trigger('dragend',[touch,e.originalEvent.traversing])
+ }
+ e.preventDefault()
+ if (oE.traversingContainer.contains(targets[id][0])) targets[id].triggerHandler('draginit',[touch,e.originalEvent.traversing])
+
+ } else {
+
+ targets[id].triggerHandler('drag',[touch,e.originalEvent.traversing])
+
+ }
+
+ previousTouches[id] = touch
+
+ }
+
+ },
+ touchStopHandler = function(e){
+
+ var oE = e.originalEvent
+
+ for (i in oE.changedTouches) {
+
+ if (isNaN(i)) continue
+
+ var touch = oE.changedTouches[i],
+ id = touch.identifier
+
+ $(oE.changedTouches[i].target).trigger('dragend',[touch,e.originalEvent.traversing])
+
+ delete previousTouches[id]
+ delete targets[id]
+
+ }
+
+ if (oE.touches.length==0) {
+ $document.off(events.touch.move,touchMoveHandler)
+ $document.off(events.touch.stop,touchStopHandler)
+ touchActive = false
+ }
+
+ }
+
+ $this.on(events.touch.start,touchStartHandler)
+
+
+ }
+
+ }
+
+
+
+
+
+
+
+
+ var makeEventTraversing = function(e){
+ e.traversing=true
+ if (!e.traversingContainer) e.traversingContainer=this
+ }
+
+
+ $.fn.enableTraversingGestures = function() {
+
+ var self = this[0]
+
+ var down = function(e){
+ makeEventTraversing(e)
+ self.addEventListener("mousemove", makeEventTraversing, true)
+ self.addEventListener("touchmove", makeEventTraversing, true)
+ self.addEventListener("mouseout", makeEventTraversing, true)
+ document.addEventListener("mouseup",up,true)
+ document.addEventListener("touchend",up,true)
+ },
+ up = function(){
+ self.removeEventListener("mousemove", makeEventTraversing, true)
+ self.removeEventListener("touchmove", makeEventTraversing, true)
+ self.removeEventListener("mouseout", makeEventTraversing, true)
+ document.removeEventListener("mouseup",up,true)
+ document.removeEventListener("touchend",up,true)
+ }
+
+ self.addEventListener("mousedown", down, true)
+ self.addEventListener("touchstart", down, true)
+
+
+ this.on('disableTraversingGestures',function() {
+ self.removeEventListener("mousedown", down, true)
+ self.removeEventListener("touchstart", down, true)
+ })
+
+
+ return this
+
+ }
+
+
+ $document.on('mousedown',function(e){
+
+ if (e.originalEvent.sourceCapabilities && e.originalEvent.sourceCapabilities.firesTouchEvents) return
+
+ $(e.target).trigger('fake-click')
+
+ if (e.button==2) {
+ e.preventDefault()
+ $(e.target).trigger('fake-right-click',e)
+ }
+
+ })
+
+ var touchTapTimer = false,
+ clearTouchTapTimer = function() {
+ clearTimeout(touchTapTimer)
+ touchTapTimer = false
+ }
+
+ $document.on(events.touch.start,function(e){
+ $(e.target).trigger('fake-click')
+
+ if (!touchTapTimer&&e.originalEvent.touches.length==1) {
+ touchTapTimer = setTimeout(function(){
+ if (touchTapTimer) {
+ var touch = e.originalEvent.changedTouches[0],
+ off = getOffset(touch.target)
+
+ touch.offsetX = touch.pageX-off.left
+ touch.offsetY = touch.pageY-off.top
+ $(e.originalEvent.changedTouches[0].target).trigger('fake-right-click',touch)
+ }
+ touchTapTimer = false
+ },600)
+ } else {
+ clearTouchTapTimer()
+ }
+ })
+
+ $document.on(events.touch.stop + ' ' + events.touch.move,function(e){
+ clearTouchTapTimer()
+ })
+
+ $document.on('contextmenu',function(){return false})
+
+})(jQuery)
+
+},{}],35:[function(require,module,exports){
+;(function ($) {
+ $.fn.fakeInput = function(options) {
+
+ var settings = $.extend({
+ align:'left'
+ }, options );
+
+ var self= this,
+ canvas = $(' ').appendTo(self),
+ ctx = canvas[0].getContext('2d')
+
+ self.value = undefined
+ self.height = undefined
+ self.width = undefined
+ self.color = undefined
+ self.center = settings.align == 'center'
+
+ self.attr('tabindex',"0")
+
+ canvas.resize(function(e,width,height){
+ e.stopPropagation()
+
+ var width = width*2,
+ height = height*2
+
+ if (height==100 && width==100) return
+
+ self.color = getComputedStyle(document.documentElement).getPropertyValue("--color-text")
+ self.height=height
+ self.width=width
+
+ canvas[0].setAttribute('width',width)
+ canvas[0].setAttribute('height',height)
+
+ self.val(self.value)
+ })
+
+ self.val = function(newVal) {
+ if (newVal==undefined) return self.value
+
+ self.value = newVal
+
+ if (!self.height || !self.width || (self.height==100 && self.width==100)) return
+
+ ctx.clearRect(0,0,self.width,self.height)
+ ctx.font = PXSCALE * 2 * 13 + 'px Droid Sans'
+ ctx.textBaseline = "top"
+ ctx.fillStyle = self.color
+
+ if (self.center) {
+ ctx.textAlign = settings.align
+ ctx.fillText(newVal,self.width/2,0)
+ } else {
+ ctx.fillText(newVal,0,0)
+ }
+
+
+ }
+
+ self.on('focus',function(){
+ self.attr('tabindex','-1')
+ var i = $(' ')
+ .prependTo(self)
+ .val(self.value)
+ .focus()
+ .change(function(){
+ self.val($(this).val())
+ i.blur()
+ setTimeout(function(){self.focus()},1)
+ })
+ i.blur(function(){
+ self.attr('tabindex','0')
+ i.remove()
+ $(document).off('.fakeInput')
+ })
+ $(document).on('touchstart.fakeInput mousedown.fakeInput',function(e){
+ if (e.originalEvent.target!=i[0]) {
+ i.blur()
+ }
+ })
+
+ })
+
+ return self
+
+ }
+})(jQuery)
+
+},{}],36:[function(require,module,exports){
+/*! jQuery v3.0.0 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector,-deprecated | (c) jQuery Foundation | jquery.org/license */
+!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.0.0 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector,-deprecated",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:f.call(this)},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.prevObject=this,b},each:function(a){return r.each(this,a)},map:function(a){return this.pushStack(r.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(f.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:h,sort:c.sort,splice:c.splice},r.extend=r.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||r.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(r.isPlainObject(d)||(e=r.isArray(d)))?(e?(e=!1,f=c&&r.isArray(c)?c:[]):f=c&&r.isPlainObject(c)?c:{},g[b]=r.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},r.extend({expando:"jQuery"+(q+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===r.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){var b=r.type(a);return("number"===b||"string"===b)&&!isNaN(a-parseFloat(a))},isPlainObject:function(a){var b,c;return a&&"[object Object]"===k.call(a)?(b=e(a))?(c=l.call(b,"constructor")&&b.constructor,"function"==typeof c&&m.call(c)===n):!0:!1},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?j[k.call(a)]||"object":typeof a},globalEval:function(a){p(a)},camelCase:function(a){return a.replace(t,"ms-").replace(u,v)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b){var c,d=0;if(w(a)){for(c=a.length;c>d;d++)if(b.call(a[d],d,a[d])===!1)break}else for(d in a)if(b.call(a[d],d,a[d])===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(s,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(w(Object(a))?r.merge(c,"string"==typeof a?[a]:a):h.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:i.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,e,f=0,h=[];if(w(a))for(d=a.length;d>f;f++)e=b(a[f],f,c),null!=e&&h.push(e);else for(f in a)e=b(a[f],f,c),null!=e&&h.push(e);return g.apply([],h)},guid:1,proxy:function(a,b){var c,d,e;return"string"==typeof b&&(c=a[b],b=a,a=c),r.isFunction(a)?(d=f.call(arguments,2),e=function(){return a.apply(b||this,d.concat(f.call(arguments)))},e.guid=a.guid=a.guid||r.guid++,e):void 0},now:Date.now,support:o}),"function"==typeof Symbol&&(r.fn[Symbol.iterator]=c[Symbol.iterator]),r.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,b){j["[object "+b+"]"]=b.toLowerCase()});function w(a){var b=!!a&&"length"in a&&a.length,c=r.type(a);return"function"===c||r.isWindow(a)?!1:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var x=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\x00-\\xa0])+",M="\\["+K+"*("+L+")(?:"+K+"*([*^$|!~]?=)"+K+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+L+"))|)"+K+"*\\]",N=":("+L+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+M+")*)|.*)\\)|)",O=new RegExp(K+"+","g"),P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(N),U=new RegExp("^"+L+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L+"|[*])"),ATTR:new RegExp("^"+M),PSEUDO:new RegExp("^"+N),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),aa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ba=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g,ca=function(a,b){return b?"\x00"===a?"\ufffd":a.slice(0,-1)+"\\"+a.charCodeAt(a.length-1).toString(16)+" ":"\\"+a},da=function(){m()},ea=ta(function(a){return a.disabled===!0},{dir:"parentNode",next:"legend"});try{G.apply(D=H.call(v.childNodes),v.childNodes),D[v.childNodes.length].nodeType}catch(fa){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s=b&&b.ownerDocument,w=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==w&&9!==w&&11!==w)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==w&&(l=Z.exec(a)))if(f=l[1]){if(9===w){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(s&&(j=s.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(l[2])return G.apply(d,b.getElementsByTagName(a)),d;if((f=l[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==w)s=b,r=a;else if("object"!==b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(ba,ca):b.setAttribute("id",k=u),o=g(a),h=o.length;while(h--)o[h]="#"+k+" "+sa(o[h]);r=o.join(","),s=$.test(a)&&qa(b.parentNode)||b}if(r)try{return G.apply(d,s.querySelectorAll(r)),d}catch(x){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(P,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("fieldset");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=c.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&a.sourceIndex-b.sourceIndex;if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return function(b){return"label"in b&&b.disabled===a||"form"in b&&b.disabled===a||"form"in b&&b.disabled===!1&&(b.isDisabled===a||b.isDisabled!==!a&&("label"in b||!ea(b))!==a)}}function pa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function qa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),v!==n&&(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(n.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}},d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return"undefined"!=typeof b.getElementsByClassName&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=Y.test(n.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML=" ",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){a.innerHTML=" ";var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+K+"*[*^$|!~]?="),2!==a.querySelectorAll(":enabled").length&&q.push(":enabled",":disabled"),o.appendChild(a).disabled=!0,2!==a.querySelectorAll(":disabled").length&&q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Y.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"*"),s.call(a,"[s!='']:x"),r.push("!=",N)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Y.test(o.compareDocumentPosition),t=b||Y.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?I(k,a)-I(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?I(k,a)-I(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)g.unshift(c);c=b;while(c=c.parentNode)h.unshift(c);while(g[d]===h[d])d++;return d?la(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(S,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.escape=function(a){return(a+"").replace(ba,ca)},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(_,aa),a[3]=(a[3]||a[4]||a[5]||"").replace(_,aa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return V.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&T.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(_,aa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(O," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while(p){m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()===r:1===m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m===b))break;return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(P,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(_,aa),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return U.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(_,aa).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:oa(!1),disabled:oa(!0),checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:pa(function(){return[0]}),last:pa(function(a,b){return[b-1]}),eq:pa(function(a,b,c){return[0>c?c+b:c]}),even:pa(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:pa(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:pa(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:pa(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function ta(a,b,c){var d=b.dir,e=b.next,f=e||d,g=c&&"parentNode"===f,h=x++;return b.first?function(b,c,e){while(b=b[d])if(1===b.nodeType||g)return a(b,c,e)}:function(b,c,i){var j,k,l,m=[w,h];if(i){while(b=b[d])if((1===b.nodeType||g)&&a(b,c,i))return!0}else while(b=b[d])if(1===b.nodeType||g)if(l=b[u]||(b[u]={}),k=l[b.uniqueID]||(l[b.uniqueID]={}),e&&e===b.nodeName.toLowerCase())b=b[d]||b;else{if((j=k[f])&&j[0]===w&&j[1]===h)return m[2]=j[2];if(k[f]=m,m[2]=a(b,c,i))return!0}}}function ua(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function va(a,b,c){for(var d=0,e=b.length;e>d;d++)ga(a,b[d],c);return c}function wa(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(c&&!c(f,d,e)||(g.push(f),j&&b.push(h)));return g}function xa(a,b,c,d,e,f){return d&&!d[u]&&(d=xa(d)),e&&!e[u]&&(e=xa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||va(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:wa(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=wa(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?I(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=wa(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ya(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ta(function(a){return a===b},h,!0),l=ta(function(a){return I(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[ta(ua(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return xa(i>1&&ua(m),i>1&&sa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(P,"$1"),c,e>i&&ya(a.slice(i,e)),f>e&&ya(a=a.slice(e)),f>e&&sa(a))}m.push(c)}return ua(m)}function za(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){o=0,g||l.ownerDocument===n||(m(l),h=!p);while(q=a[o++])if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){o=0;while(q=b[o++])q(t,u,g,h);if(f){if(r>0)while(s--)t[s]||u[s]||(u[s]=E.call(i));u=wa(u)}G.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&ga.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=ya(b[c]),f[u]?d.push(f):e.push(f);f=A(a,za(e,d)),f.selector=a}return f},i=ga.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(_,aa),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=V.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(_,aa),$.test(j[0].type)&&qa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&sa(j),!a)return G.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,!b||$.test(a)&&qa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("fieldset"))}),ja(function(a){return a.innerHTML=" ","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML=" ",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(J,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);r.find=x,r.expr=x.selectors,r.expr[":"]=r.expr.pseudos,r.uniqueSort=r.unique=x.uniqueSort,r.text=x.getText,r.isXMLDoc=x.isXML,r.contains=x.contains,r.escapeSelector=x.escape;var y=function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&r(a).is(c))break;d.push(a)}return d},z=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},A=r.expr.match.needsContext,B=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,C=/^.[^:#\[\.,]*$/;function D(a,b,c){if(r.isFunction(b))return r.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return r.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(C.test(b))return r.filter(b,a,c);b=r.filter(b,a)}return r.grep(a,function(a){return i.call(b,a)>-1!==c&&1===a.nodeType})}r.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?r.find.matchesSelector(d,a)?[d]:[]:r.find.matches(a,r.grep(b,function(a){return 1===a.nodeType}))},r.fn.extend({find:function(a){var b,c,d=this.length,e=this;if("string"!=typeof a)return this.pushStack(r(a).filter(function(){for(b=0;d>b;b++)if(r.contains(e[b],this))return!0}));for(c=this.pushStack([]),b=0;d>b;b++)r.find(a,e[b],c);return d>1?r.uniqueSort(c):c},filter:function(a){return this.pushStack(D(this,a||[],!1))},not:function(a){return this.pushStack(D(this,a||[],!0))},is:function(a){return!!D(this,"string"==typeof a&&A.test(a)?r(a):a||[],!1).length}});var E,F=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,G=r.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||E,"string"==typeof a){if(e="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:F.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof r?b[0]:b,r.merge(this,r.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),B.test(e[1])&&r.isPlainObject(b))for(e in b)r.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}return f=d.getElementById(e[2]),f&&(this[0]=f,this.length=1),this}return a.nodeType?(this[0]=a,this.length=1,this):r.isFunction(a)?void 0!==c.ready?c.ready(a):a(r):r.makeArray(a,this)};G.prototype=r.fn,E=r(d);var H=/^(?:parents|prev(?:Until|All))/,I={children:!0,contents:!0,next:!0,prev:!0};r.fn.extend({has:function(a){var b=r(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(r.contains(this,b[a]))return!0})},closest:function(a,b){var c,d=0,e=this.length,f=[],g="string"!=typeof a&&r(a);if(!A.test(a))for(;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&r.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?r.uniqueSort(f):f)},index:function(a){return a?"string"==typeof a?i.call(r(a),this[0]):i.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(r.uniqueSort(r.merge(this.get(),r(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function J(a,b){while((a=a[b])&&1!==a.nodeType);return a}r.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return y(a,"parentNode")},parentsUntil:function(a,b,c){return y(a,"parentNode",c)},next:function(a){return J(a,"nextSibling")},prev:function(a){return J(a,"previousSibling")},nextAll:function(a){return y(a,"nextSibling")},prevAll:function(a){return y(a,"previousSibling")},nextUntil:function(a,b,c){return y(a,"nextSibling",c)},prevUntil:function(a,b,c){return y(a,"previousSibling",c)},siblings:function(a){return z((a.parentNode||{}).firstChild,a)},children:function(a){return z(a.firstChild)},contents:function(a){return a.contentDocument||r.merge([],a.childNodes)}},function(a,b){r.fn[a]=function(c,d){var e=r.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=r.filter(d,e)),this.length>1&&(I[a]||r.uniqueSort(e),H.test(a)&&e.reverse()),this.pushStack(e)}});var K=/\S+/g;function L(a){var b={};return r.each(a.match(K)||[],function(a,c){b[c]=!0}),b}r.Callbacks=function(a){a="string"==typeof a?L(a):r.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h-1)f.splice(c,1),h>=c&&h--}),this},has:function(a){return a?r.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=g=[],c||b||(f=c=""),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j};function M(a){return a}function N(a){throw a}function O(a,b,c){var d;try{a&&r.isFunction(d=a.promise)?d.call(a).done(b).fail(c):a&&r.isFunction(d=a.then)?d.call(a,b,c):b.call(void 0,a)}catch(a){c.call(void 0,a)}}r.extend({Deferred:function(b){var c=[["notify","progress",r.Callbacks("memory"),r.Callbacks("memory"),2],["resolve","done",r.Callbacks("once memory"),r.Callbacks("once memory"),0,"resolved"],["reject","fail",r.Callbacks("once memory"),r.Callbacks("once memory"),1,"rejected"]],d="pending",e={state:function(){return d},always:function(){return f.done(arguments).fail(arguments),this},"catch":function(a){return e.then(null,a)},pipe:function(){var a=arguments;return r.Deferred(function(b){r.each(c,function(c,d){var e=r.isFunction(a[d[4]])&&a[d[4]];f[d[1]](function(){var a=e&&e.apply(this,arguments);a&&r.isFunction(a.promise)?a.promise().progress(b.notify).done(b.resolve).fail(b.reject):b[d[0]+"With"](this,e?[a]:arguments)})}),a=null}).promise()},then:function(b,d,e){var f=0;function g(b,c,d,e){return function(){var h=this,i=arguments,j=function(){var a,j;if(!(f>b)){if(a=d.apply(h,i),a===c.promise())throw new TypeError("Thenable self-resolution");j=a&&("object"==typeof a||"function"==typeof a)&&a.then,r.isFunction(j)?e?j.call(a,g(f,c,M,e),g(f,c,N,e)):(f++,j.call(a,g(f,c,M,e),g(f,c,N,e),g(f,c,M,c.notifyWith))):(d!==M&&(h=void 0,i=[a]),(e||c.resolveWith)(h,i))}},k=e?j:function(){try{j()}catch(a){r.Deferred.exceptionHook&&r.Deferred.exceptionHook(a,k.stackTrace),b+1>=f&&(d!==N&&(h=void 0,i=[a]),c.rejectWith(h,i))}};b?k():(r.Deferred.getStackHook&&(k.stackTrace=r.Deferred.getStackHook()),a.setTimeout(k))}}return r.Deferred(function(a){c[0][3].add(g(0,a,r.isFunction(e)?e:M,a.notifyWith)),c[1][3].add(g(0,a,r.isFunction(b)?b:M)),c[2][3].add(g(0,a,r.isFunction(d)?d:N))}).promise()},promise:function(a){return null!=a?r.extend(a,e):e}},f={};return r.each(c,function(a,b){var g=b[2],h=b[5];e[b[1]]=g.add,h&&g.add(function(){d=h},c[3-a][2].disable,c[0][2].lock),g.add(b[3].fire),f[b[0]]=function(){return f[b[0]+"With"](this===f?void 0:this,arguments),this},f[b[0]+"With"]=g.fireWith}),e.promise(f),b&&b.call(f,f),f},when:function(a){var b=arguments.length,c=b,d=Array(c),e=f.call(arguments),g=r.Deferred(),h=function(a){return function(c){d[a]=this,e[a]=arguments.length>1?f.call(arguments):c,--b||g.resolveWith(d,e)}};if(1>=b&&(O(a,g.done(h(c)).resolve,g.reject),"pending"===g.state()||r.isFunction(e[c]&&e[c].then)))return g.then();while(c--)O(e[c],h(c),g.reject);return g.promise()}});var P=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;r.Deferred.exceptionHook=function(b,c){a.console&&a.console.warn&&b&&P.test(b.name)&&a.console.warn("jQuery.Deferred exception: "+b.message,b.stack,c)};var Q=r.Deferred();r.fn.ready=function(a){return Q.then(a),this},r.extend({isReady:!1,readyWait:1,holdReady:function(a){a?r.readyWait++:r.ready(!0)},ready:function(a){(a===!0?--r.readyWait:r.isReady)||(r.isReady=!0,a!==!0&&--r.readyWait>0||Q.resolveWith(d,[r]))}}),r.ready.then=Q.then;function R(){d.removeEventListener("DOMContentLoaded",R),a.removeEventListener("load",R),r.ready()}"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",R),a.addEventListener("load",R));var S=function(a,b,c,d,e,f,g){
+var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)S(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},T=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function U(){this.expando=r.expando+U.uid++}U.uid=1,U.prototype={cache:function(a){var b=a[this.expando];return b||(b={},T(a)&&(a.nodeType?a[this.expando]=b:Object.defineProperty(a,this.expando,{value:b,configurable:!0}))),b},set:function(a,b,c){var d,e=this.cache(a);if("string"==typeof b)e[r.camelCase(b)]=c;else for(d in b)e[r.camelCase(d)]=b[d];return e},get:function(a,b){return void 0===b?this.cache(a):a[this.expando]&&a[this.expando][r.camelCase(b)]},access:function(a,b,c){return void 0===b||b&&"string"==typeof b&&void 0===c?this.get(a,b):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d=a[this.expando];if(void 0!==d){if(void 0!==b){r.isArray(b)?b=b.map(r.camelCase):(b=r.camelCase(b),b=b in d?[b]:b.match(K)||[]),c=b.length;while(c--)delete d[b[c]]}(void 0===b||r.isEmptyObject(d))&&(a.nodeType?a[this.expando]=void 0:delete a[this.expando])}},hasData:function(a){var b=a[this.expando];return void 0!==b&&!r.isEmptyObject(b)}};var V=new U,W=new U,X=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Y=/[A-Z]/g;function Z(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(Y,"-$&").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:X.test(c)?JSON.parse(c):c}catch(e){}W.set(a,b,c)}else c=void 0;return c}r.extend({hasData:function(a){return W.hasData(a)||V.hasData(a)},data:function(a,b,c){return W.access(a,b,c)},removeData:function(a,b){W.remove(a,b)},_data:function(a,b,c){return V.access(a,b,c)},_removeData:function(a,b){V.remove(a,b)}}),r.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=W.get(f),1===f.nodeType&&!V.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=r.camelCase(d.slice(5)),Z(f,d,e[d])));V.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){W.set(this,a)}):S(this,function(b){var c;if(f&&void 0===b){if(c=W.get(f,a),void 0!==c)return c;if(c=Z(f,a),void 0!==c)return c}else this.each(function(){W.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){W.remove(this,a)})}}),r.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=V.get(a,b),c&&(!d||r.isArray(c)?d=V.access(a,b,r.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=r.queue(a,b),d=c.length,e=c.shift(),f=r._queueHooks(a,b),g=function(){r.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return V.get(a,c)||V.access(a,c,{empty:r.Callbacks("once memory").add(function(){V.remove(a,[b+"queue",c])})})}}),r.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthf;f++)d=a[f],d.style&&(c=d.style.display,b?("none"===c&&(e[f]=V.get(d,"display")||null,e[f]||(d.style.display="")),""===d.style.display&&ba(d)&&(e[f]=fa(d))):"none"!==c&&(e[f]="none",V.set(d,"display",c)));for(f=0;g>f;f++)null!=e[f]&&(a[f].style.display=e[f]);return a}r.fn.extend({show:function(){return ga(this,!0)},hide:function(){return ga(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){ba(this)?r(this).show():r(this).hide()})}});var ha=/^(?:checkbox|radio)$/i,ia=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,ja=/^$|\/(?:java|ecma)script/i,ka={option:[1,""," "],thead:[1,""],col:[2,""],tr:[2,""],td:[3,""],_default:[0,"",""]};ka.optgroup=ka.option,ka.tbody=ka.tfoot=ka.colgroup=ka.caption=ka.thead,ka.th=ka.td;function la(a,b){var c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&r.nodeName(a,b)?r.merge([a],c):c}function ma(a,b){for(var c=0,d=a.length;d>c;c++)V.set(a[c],"globalEval",!b||V.get(b[c],"globalEval"))}var na=/<|?\w+;/;function oa(a,b,c,d,e){for(var f,g,h,i,j,k,l=b.createDocumentFragment(),m=[],n=0,o=a.length;o>n;n++)if(f=a[n],f||0===f)if("object"===r.type(f))r.merge(m,f.nodeType?[f]:f);else if(na.test(f)){g=g||l.appendChild(b.createElement("div")),h=(ia.exec(f)||["",""])[1].toLowerCase(),i=ka[h]||ka._default,g.innerHTML=i[1]+r.htmlPrefilter(f)+i[2],k=i[0];while(k--)g=g.lastChild;r.merge(m,g.childNodes),g=l.firstChild,g.textContent=""}else m.push(b.createTextNode(f));l.textContent="",n=0;while(f=m[n++])if(d&&r.inArray(f,d)>-1)e&&e.push(f);else if(j=r.contains(f.ownerDocument,f),g=la(l.appendChild(f),"script"),j&&ma(g),c){k=0;while(f=g[k++])ja.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),o.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="",o.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var pa=d.documentElement,qa=/^key/,ra=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,sa=/^([^.]*)(?:\.(.+)|)/;function ta(){return!0}function ua(){return!1}function va(){try{return d.activeElement}catch(a){}}function wa(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)wa(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=ua;else if(!e)return a;return 1===f&&(g=e,e=function(a){return r().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=r.guid++)),a.each(function(){r.event.add(this,b,e,d,c)})}r.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.get(a);if(q){c.handler&&(f=c,c=f.handler,e=f.selector),e&&r.find.matchesSelector(pa,e),c.guid||(c.guid=r.guid++),(i=q.events)||(i=q.events={}),(g=q.handle)||(g=q.handle=function(b){return"undefined"!=typeof r&&r.event.triggered!==b.type?r.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(K)||[""],j=b.length;while(j--)h=sa.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n&&(l=r.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=r.event.special[n]||{},k=r.extend({type:n,origType:p,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&r.expr.match.needsContext.test(e),namespace:o.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,o,g)!==!1||a.addEventListener&&a.addEventListener(n,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),r.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.hasData(a)&&V.get(a);if(q&&(i=q.events)){b=(b||"").match(K)||[""],j=b.length;while(j--)if(h=sa.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){l=r.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&p!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||r.removeEvent(a,n,q.handle),delete i[n])}else for(n in i)r.event.remove(a,n+b[j],c,d,!0);r.isEmptyObject(i)&&V.remove(a,"handle events")}},dispatch:function(a){var b=r.event.fix(a),c,d,e,f,g,h,i=new Array(arguments.length),j=(V.get(this,"events")||{})[b.type]||[],k=r.event.special[b.type]||{};for(i[0]=b,c=1;cc;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?r(e,this).index(i)>-1:r.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h\x20\t\r\n\f]*)[^>]*)\/>/gi,ya=/
-{% endblock %}
diff --git a/scripts/build-css.js b/scripts/build-css.js
deleted file mode 100644
index 1884a440..00000000
--- a/scripts/build-css.js
+++ /dev/null
@@ -1,48 +0,0 @@
-var sass = require('sass'),
- path = require('path'),
- fs = require('fs')
-
-var indir = path.resolve(__dirname + '/../src/scss/'),
- outdir= path.resolve(__dirname + '/../app/assets/')
-
-fs.mkdirSync(outdir + '/themes/', {recursive: true})
-
-fs.readdirSync(indir + '/themes/').forEach(file => {
-
- if (file.includes('.scss') && file !== 'default.scss') {
- let result = sass.renderSync({
- file: indir + '/themes/' + file,
- outputStyle: 'compressed',
- silenceDeprecations: ['mixed-decls', 'slash-div', 'import', 'legacy-js-api']
- })
-
- fs.writeFileSync(outdir + '/themes/' + file.split('/').pop().replace('scss', 'css'), result.css)
- }
-
-})
-
-var result = sass.renderSync({
- file: indir + '/index.scss',
- outFile: outdir + '/open-stage-control.css',
- outputStyle: 'compressed',
- sourceMap: true,
- silenceDeprecations: ['mixed-decls', 'slash-div', 'import', 'legacy-js-api']
-})
-
-fs.writeFileSync(outdir + '/open-stage-control.css', result.css)
-fs.writeFileSync(outdir + '/open-stage-control.css.map', result.map)
-
-
-if (process.argv.includes('--reload')) {
-
- var WS = require('../node_modules/ws')
-
- var ipc = new WS('ws://127.0.0.1:8080/dev/')
-
- ipc.on('error', ()=>{})
- ipc.on('open', ()=>{
- ipc.send('["reloadCss"]')
- process.exit()
- })
-
-}
diff --git a/scripts/client.plugin-watch.js b/scripts/client.plugin-watch.js
deleted file mode 100644
index 41204c80..00000000
--- a/scripts/client.plugin-watch.js
+++ /dev/null
@@ -1,40 +0,0 @@
-var ansiHTML = require('ansi-html'),
- WS = require('../node_modules/ws'),
- path = require('path')
-
-function send(msg, data){
- var ipc = new WS('ws://127.0.0.1:8080/dev/')
- ipc.on('error', ()=>{})
- ipc.on('open', ()=>{
- ipc.send(JSON.stringify([msg, data]))
- ipc.close()
- })
-}
-
-module.exports = function watchChangePlugin() {
-
- var reloadClient = false
-
- return {
-
- buildEnd(error) {
-
- if (error) {
- var msg = `
- ${error.message.replace(path.resolve(__dirname + '/..'),'')} at line ${error.loc.line}\n${error.frame}
-
`
- send('errorPopup', msg.trim())
- reloadClient = false
- } else {
- reloadClient = true
- }
-
- },
-
- writeBundle() {
- if (reloadClient) {
- send('reload')
- }
- }
- }
-}
diff --git a/scripts/client.rollup.config.js b/scripts/client.rollup.config.js
deleted file mode 100644
index c23b26ae..00000000
--- a/scripts/client.rollup.config.js
+++ /dev/null
@@ -1,98 +0,0 @@
-var commonjs = require('@rollup/plugin-commonjs'),
- nodeResolve = require('@rollup/plugin-node-resolve'),
- json = require('@rollup/plugin-json'),
- babel = require('@rollup/plugin-babel'),
- terser = require('@rollup/plugin-terser'),
- copy = require('rollup-plugin-copy'),
- license = require('rollup-plugin-license'),
- watchChange = require('./client.plugin-watch'),
- package = require('../package.json'),
- path = require('path'),
- watch = process.argv.includes('--watch')
-
-module.exports = {
- input: 'src/client/index.mjs',
- output: [
- {
- dir: 'app/client/',
- chunkFileNames: `[name].js`,
- entryFileNames: `[name].js`,
- format: 'es',
- sourcemap: true,
- sourcemapExcludeSources: true
- },
- ],
- treeshake: false,
- watch: {
- clearScreen: false
- },
- plugins: [
- json(),
- nodeResolve({
- browser: true
- }),
- commonjs(),
- watch ? {} : babel({
- babelHelpers: 'bundled',
- babelrc: false,
- exclude: [
- /node_modules\/core-js/,
- /node_modules\/ace-builds/
- ],
- presets: [[
- '@babel/preset-env',
- {
- targets: {
- ios: '11',
- chrome: '70'
- },
- useBuiltIns: 'usage',
- corejs: 3,
- modules:false
- }
- ]]
- }),
- watch ? {} : terser({
- sourceMap: true,
- keep_classnames: true,
- keep_fnames: true,
- output: {
- comments: false,
- },
- }),
- {
- name: 'remove-node-modules-from-source-map',
- enforce: 'post',
- transform(code, id) {
- if (id.includes('node_modules')) {
- return { code, map: { mappings: '' } }
- }
- }
- },
- watch ? {} :license({
- thirdParty: {
- includeSelf: true,
- output: 'app/client/LICENSES',
- },
- }),
- watch ? {} : copy({
- targets: [
- {src: 'resources/images/logo_nobadge.png', dest: 'app/assets/', rename: 'favicon.png'},
- {src: 'resources/images/logo.png', dest: 'app/assets/'},
- {src: 'resources/images/logo_tray.png', dest: 'app/assets/'},
- {src: 'resources/images/logo_tray@x2.png', dest: 'app/assets/'},
- {src: 'resources/images/logo_16x16.png', dest: 'app/assets/'},
- {src: 'resources/fonts/*', dest: 'app/assets/fonts/'},
- {src: 'node_modules/ace-builds/src-min/worker-css.js', dest: 'app/client/ace/'},
- {src: 'node_modules/ace-builds/src-min/worker-html.js', dest: 'app/client/ace/'},
- {src: 'node_modules/ace-builds/src-min/worker-javascript.js', dest: 'app/client/ace/'},
- {src: 'node_modules/ace-builds/src-min/ace.js', dest: 'app/client/ace/'},
- {src: 'src/html/client.html', dest: 'app/client/', rename: 'index.html', transform: (contents)=>{
- return contents.toString().replace(/\$\{([^\}]+)\}/g, (m, p1)=>{return package[p1]})
- }},
-
- ]
- }),
- watchChange()
- ]
-};
diff --git a/scripts/dist_packages.sh b/scripts/dist_packages.sh
deleted file mode 100755
index 8805f515..00000000
--- a/scripts/dist_packages.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/bash
-
-# clean
-rm -rf dist app
-
-# buid
-npm run build
-npm run build-docs
-npm run package -- --all
-PLATFORM=darwin ARCH=arm64 npm run package
-npm run package-node
-
-# get current version
-VERSION=$(sed -nE 's/^\s*"version":\ "(.*?)",$/\1/p' package.json)
-
-cd dist
-
-# fetch & copy midi bins
-mkdir tmp && cd tmp
-cp ../../bin/osc-midi-* ./
-chmod +x *
-touch .expect-midi-bin
-cp {.expect-midi-bin,osc-midi-linux} ../open-stage-control-linux-x64/resources/app/server/python/
-cp {.expect-midi-bin,osc-midi-windows.exe} ../open-stage-control-win32-x64/resources/app/server/python/
-cp {.expect-midi-bin,osc-midi-osx} ../open-stage-control-darwin-x64/open-stage-control.app/Contents/Resources/app/server/python/
-cp {.expect-midi-bin,osc-midi-osx} ../open-stage-control-darwin-arm64/open-stage-control.app/Contents/Resources/app/server/python/
-cd ..
-rm -rf tmp
-
-# make packages
-mkdir packages
-npm run deb64
-npm run rpm64
-mv *.{deb,rpm} packages/
-
-mv open-stage-control-node open-stage-control_${VERSION}_node
-mv open-stage-control-win32-x64 open-stage-control_${VERSION}_win32-x64
-mv open-stage-control-linux-x64 open-stage-control_${VERSION}_linux-x64
-
-echo "Creating zip packages..."
-zip -q -r --symlinks packages/open-stage-control_${VERSION}_osx-x64.zip open-stage-control-darwin-x64/open-stage-control.app
-zip -q -r --symlinks packages/open-stage-control_${VERSION}_osx-arm64.zip open-stage-control-darwin-arm64/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-x64.zip open-stage-control_${VERSION}_win32-x64
-zip -q -r packages/open-stage-control_${VERSION}_linux-x64.zip open-stage-control_${VERSION}_linux-x64
diff --git a/scripts/docs.rollup.config.js b/scripts/docs.rollup.config.js
deleted file mode 100644
index 5b27aa0f..00000000
--- a/scripts/docs.rollup.config.js
+++ /dev/null
@@ -1,25 +0,0 @@
-var commonjs = require('@rollup/plugin-commonjs'),
- nodeResolve = require('@rollup/plugin-node-resolve'),
- json = require('@rollup/plugin-json')
-
-module.exports = {
- input: 'src/docs/widgets-reference.mjs',
- output: [
- {
- file: 'src/docs/widgets-reference.js',
- inlineDynamicImports: true,
- format: 'commonjs',
- sourcemap: false,
- strict: false,
- indent: false,
- name: '_'
- },
- ],
- plugins: [
- json(),
- nodeResolve({
- browser: true
- }),
- commonjs()
- ]
-};
diff --git a/scripts/launcher.rollup.config.js b/scripts/launcher.rollup.config.js
deleted file mode 100644
index c0b2eda1..00000000
--- a/scripts/launcher.rollup.config.js
+++ /dev/null
@@ -1,48 +0,0 @@
-var commonjs = require('@rollup/plugin-commonjs'),
- nodeResolve = require('@rollup/plugin-node-resolve'),
- json = require('@rollup/plugin-json'),
- babel = require('@rollup/plugin-babel'),
- terser = require('@rollup/plugin-terser'),
- copy = require('rollup-plugin-copy'),
- license = require('rollup-plugin-license'),
- package = require('../package.json'),
- path = require('path')
-
-module.exports = {
- input: 'src/launcher/index.mjs',
- output: [
- {
- dir: 'app/launcher/',
- chunkFileNames: `[name].js`,
- format: 'commonjs',
- sourcemap: true,
- sourcemapExcludeSources: true,
- strict: false
- },
- ],
- treeshake: false,
- external: ['electron'],
- watch: {
- clearScreen: false
- },
- plugins: [
- json(),
- commonjs({
- ignoreGlobal: true,
- ignoreDynamicRequires: true
- }),
- nodeResolve(),
- terser(),
- license({
- thirdParty: {
- includeSelf: true,
- output: 'app/launcher/LICENSES',
- },
- }),
- copy({
- targets: [
- {src: 'src/html/launcher.html', dest: 'app/launcher/', rename: 'index.html'},
- ]
- })
- ]
-};
diff --git a/scripts/package-node.js b/scripts/package-node.js
deleted file mode 100644
index 6fdae1bc..00000000
--- a/scripts/package-node.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var cpr = require('cpr'),
- path = require('path'),
- files = ['../app', '../dist/open-stage-control-node']
-
-cpr(...files.map(f => path.resolve(__dirname + '/' + f)), {
- filter: /node_modules\/(serialport|uws)/,
- overwrite: true
-}, ()=>{
-
- console.warn('\x1b[36m%s\x1b[0m', '=> Build artifacts created in ' + path.resolve(__dirname + '/../dist'))
-
-})
diff --git a/scripts/package.js b/scripts/package.js
deleted file mode 100644
index de33b599..00000000
--- a/scripts/package.js
+++ /dev/null
@@ -1,32 +0,0 @@
-const packager = require('@electron/packager'),
- path = require('path'),
- appData = require('../app/package.json'),
- safeFFMPEG = require('electron-packager-plugin-non-proprietary-codecs-ffmpeg').default,
- licensePath = path.resolve(__dirname + '/../LICENSE'),
- fs = require('fs')
-
-var all = process.argv.includes('--all')
-
-packager({
- dir: path.resolve(__dirname + '/../app'),
- name: appData.name,
- platform: all ? ['linux', 'win32', 'darwin'] : process.env.PLATFORM,
- arch: process.env.ARCH || 'x64',
- electronVersion: process.env.ELECTRON_VERSION || require('../package.json').optionalDependencies.electron,
- overwrite: true,
- out: path.resolve(__dirname + '/../dist'),
- icon: path.resolve(__dirname + '/../resources/images/logo'),
- ignore: /(node_modules\/(serialport|uws)|docs\/fonts)/,
- afterExtract: [safeFFMPEG],
- prune: false
-}).then((appPaths)=>{
-
- for (var appPath of appPaths) {
- var electronLicensePath = path.join(appPath, 'LICENSE')
- fs.copyFileSync(electronLicensePath, electronLicensePath + '.electron')
- fs.copyFileSync(licensePath, electronLicensePath)
- }
-
- console.warn('\x1b[36m%s\x1b[0m', '=> Build artifacts created in ' + path.resolve(__dirname + '/../dist'))
-
-})
diff --git a/scripts/server.rollup.config.js b/scripts/server.rollup.config.js
deleted file mode 100644
index dac5b03a..00000000
--- a/scripts/server.rollup.config.js
+++ /dev/null
@@ -1,65 +0,0 @@
-var commonjs = require('@rollup/plugin-commonjs'),
- nodeResolve = require('@rollup/plugin-node-resolve'),
- json = require('@rollup/plugin-json'),
- babel = require('@rollup/plugin-babel'),
- terser = require('@rollup/plugin-terser'),
- copy = require('rollup-plugin-copy'),
- license = require('rollup-plugin-license'),
- package = require('../package.json'),
- path = require('path')
-
-module.exports = {
- input: {
- 'node/index': 'src/server/node/index.mjs',
- 'electron/index': 'src/server/electron/index.mjs'
- },
- output: [
- {
- dir: 'app/server/',
- chunkFileNames: `[name].js`,
- format: 'commonjs',
- sourcemap: true,
- sourcemapExcludeSources: true,
- strict: false
- },
- ],
- treeshake: false,
- external: ['electron', '@serialport'],
- watch: {
- clearScreen: false
- },
- plugins: [
- json(),
- commonjs({
- ignoreGlobal: true,
- ignoreDynamicRequires: true
- }),
- nodeResolve({
- preferBuiltins: true
- }),
- license({
- thirdParty: {
- includeSelf: true,
- output: 'app/server/LICENSES',
- },
- }),
- terser({
- sourceMap: true,
- keep_classnames: true,
- keep_fnames: true,
- output: {
- comments: false,
- },
- }),
- copy({
- targets: [
- {src: 'src/index.js', dest: 'app/'},
- {src: 'src/server/index.js', dest: 'app/server/'},
- {src: 'src/server/python/*.py', dest: 'app/server/python/'},
- {src: 'node_modules/fsevents/fsevents.node', dest: 'app/server/'},
- {src: 'LICENSE', dest: 'app/'},
- {src: 'package.json', dest: 'app/'},
- ]
- })
- ]
-};
diff --git a/src/client/backup.mjs b/src/client/backup.mjs
deleted file mode 100644
index 8e1cef83..00000000
--- a/src/client/backup.mjs
+++ /dev/null
@@ -1,62 +0,0 @@
-import cache from './managers/cache.mjs'
-
-var session, state, editor, ipc
-;(async()=>{
- session = (await import('./managers/session/index.mjs')).default
- state = (await import('./managers/state.mjs')).default
- editor = (await import('./editor/index.mjs')).default
- ipc = (await import('./ipc/index.mjs')).default
-})()
-
-var localBackup = cache.get('backup', false)
-
-
-export const exists = localBackup !== null
-
-export function save() {
-
- if (session.session) {
- cache.set('backup', {
- session: session.session.data,
- saveMode: session.saveMode,
- sessionPath: session.sessionPath,
- fragments: session.fragments,
- state: state.get(),
- history: editor.history,
- historyState: editor.historyState,
- editorEnabled: editor.enabled,
- }, false)
- }
-
-}
-
-export function load() {
-
- if (localBackup) {
-
- var data = localBackup
-
- cache.remove('backup', false)
- for (let k in data.fragments) {
- session.setFragment({path: k, fileContent: data.fragments[k]})
- }
- session.load(data.session, ()=>{
-
- session.setSaveMode(data.saveMode)
- 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)
-
- })
-
- }
-
-}
diff --git a/src/client/dom.mjs b/src/client/dom.mjs
deleted file mode 100644
index 798802b6..00000000
--- a/src/client/dom.mjs
+++ /dev/null
@@ -1,82 +0,0 @@
-export function dispatchEvent(element, name, data) {
-
- var event = new CustomEvent(name, {
- detail: data,
- bubbles: true,
- cancelable: true
- })
-
- element.dispatchEvent(event)
-
-}
-
-export function addEventListener(element, events, listener, capture) {
-
- var eventsAsObject = typeof events == 'string' ? events.split(' ') : events
-
- for (var i in eventsAsObject) {
-
- element.addEventListener(eventsAsObject[i], listener, capture)
-
- }
-
-}
-
-export function get(a, b) {
-
- var context = b ? a : document,
- selector = b || a,
- nodes
-
- if (selector.indexOf('>') === 0) selector = ':scope ' + selector
-
- if (selector.indexOf(' ') === -1 && selector.indexOf(',') === -1 && selector.indexOf('[') === -1) {
- if (selector.indexOf('#') === 0 && context === document) {
- nodes = [document.getElementById(selector.substr(1, selector.length - 1))]
- } else if (selector.lastIndexOf('.') === 0) {
- nodes = context.getElementsByClassName(selector.substr(1, selector.length - 1))
- }
- }
-
- if (!nodes) nodes = context.querySelectorAll(selector)
-
- return [...nodes]
-
-}
-
-export function each(context, selector, callback) {
-
- var nodes = get(context, selector)
-
- nodes.forEach(callback)
-
- return nodes
-
-}
-
-export function index(element) {
- var parent = element.parentNode
- return parent ? Array.prototype.indexOf.call(parent.children, element) : -1
-}
-
-export function offset(element, container) {
-
- var offsetLeft = 0,
- offsetTop = 0
-
- if (element) {
- do {
- if (!isNaN(element.offsetLeft)) {
- offsetLeft += element.offsetLeft - element.scrollLeft
- }
- if (!isNaN(element.offsetTop)) {
- offsetTop += element.offsetTop - element.scrollTop
- }
- } while ((element = element.offsetParent) && element !== container)
- }
-
- return {
- left: offsetLeft,
- top: offsetTop
- }
-}
diff --git a/src/client/editor/context-menu.mjs b/src/client/editor/context-menu.mjs
deleted file mode 100644
index a13fbf26..00000000
--- a/src/client/editor/context-menu.mjs
+++ /dev/null
@@ -1,364 +0,0 @@
-import {updateWidget} from './data-workers.mjs'
-import {categories} from '../widgets/index.mjs'
-import widgetManager from '../managers/widgets.mjs'
-import {icon} from '../ui/utils.mjs'
-import editor from './index.mjs'
-import locales from '../locales/index.mjs'
-import ContextMenu from '../ui/context-menu.mjs'
-import {GRIDWIDTH, PXSCALE} from '../globals.mjs'
-
-var sessionManager
-;(async()=>{
- sessionManager = (await import('../managers/session/index.mjs')).default
-})()
-
-
-var contextMenu = new ContextMenu()
-
-var multiSelectKey = (navigator.platform || '').match('Mac') ? 'metaKey' : 'ctrlKey'
-
-var handleClick = function(event) {
-
- if (
- !editor.enabled ||
- event.detail.button === 1 ||
- (event.detail.metaKey && event.detail.shiftKey)
- ) return
-
- if (!event.detail[multiSelectKey] && event.type !== 'fast-right-click' && (
- event.target.classList.contains('no-widget-select') ||
- event.target.id === 'open-toggle'
- )) { return }
-
- var eventData = event.detail,
- targetWidget = widgetManager.getWidgetByElement(eventData.target, ':not(.not-editable)')
-
- if (!targetWidget) return
-
- while (targetWidget.meta.not_editable && targetWidget.parent) {
- targetWidget = targetWidget.parent
- }
-
- // if the widget is not already selected
- if (!targetWidget.container.classList.contains('editing') || event.detail.ctrlKey || event.detail.shiftKey) {
- // add a flag to the original event to prevent draginit
- // and prevent any further fast-click (ie input focus)
- eventData.capturedByEditor = true
- event.capturedByEditor = true
- }
-
-
- if (editor.inspector.focusedInput) {
- editor.inspector.onChange()
- editor.inspector.focusedInput = null
- if (!document.body.contains(eventData.target)) return
- }
-
- if (event.type !== 'fast-right-click') {
-
- if (targetWidget.getProp('type') === 'tab') {
- targetWidget.parent.setValue(targetWidget.parent.children.indexOf(targetWidget), {sync: true, send: true})
- }
-
- if (
- event.target.tagName === 'LI' && // Project tree
- event.detail.shiftKey &&
- editor.selectedWidgets.length > 0 &&
- targetWidget.parent === editor.selectedWidgets[0].parent
- ) {
- var siblings = targetWidget.parent.children,
- from = siblings.indexOf(editor.selectedWidgets[0]),
- to = siblings.indexOf(targetWidget),
- range = siblings.slice(Math.min(from, to), Math.max(from, to) + 1).filter(w=>!editor.selectedWidgets.includes(w))
-
- targetWidget = editor.selectedWidgets.concat(range)
- }
-
- editor.select(targetWidget, {multi: event.detail[multiSelectKey]})
-
- }
-
- // right-click menu
- if (event.type !== 'fast-right-click') return
-
- if (!event.detail.shiftKey && !event.detail[multiSelectKey] && editor.selectedWidgets.length <= 1) {
- if (editor.inspector.focusedInput) editor.inspector.onChange()
- editor.select(targetWidget)
- }
-
- if (!editor.selectedWidgets.length) return
-
- var data = editor.selectedWidgets.map((w)=>w.props),
- widget = editor.selectedWidgets[0],
- parent = widget.parent,
- actions = []
-
- var clickX = Math.round((eventData.offsetX + eventData.target.scrollLeft) / (GRIDWIDTH * PXSCALE)) * GRIDWIDTH,
- clickY = Math.round((eventData.offsetY + eventData.target.scrollTop) / (GRIDWIDTH * PXSCALE)) * GRIDWIDTH
-
- if (parent !== widgetManager) {
-
- if (event.target.tagName !== 'LI') { // not Project tree
- actions.push({
- label: icon('project-diagram') + ' ' + locales('editor_show_in_tree'),
- action: ()=>{
- editor.widgetTree.showWidget(editor.selectedWidgets[0])
- editor.widgetTree.blinkSelected()
- },
- shortcut: 't'
- })
-
- } else {
-
- actions.push({
- label: icon('eye') + ' ' + locales('editor_show_in_session'),
- action: ()=>{
- for (let w of editor.selectedWidgets) {
- editor.widgetTree.showWidgetInSession(w)
- }
- },
- shortcut: 'y'
- })
-
- }
-
- actions.push({
- separator: true
- })
-
- actions.push({
- label: icon('copy') + ' ' + locales('editor_copy'),
- action: editor.copyWidget.bind(editor),
- shortcut: 'mod + c'
- })
-
- actions.push({
- label: icon('cut') + ' ' + locales('editor_cut'),
- action: editor.cutWidget.bind(editor),
- shortcut: 'mod + x'
- })
-
- }
-
- if (widget.childrenType !== undefined) {
-
- if (editor.clipboard !== null) {
-
- var pasteActions = [],
- canPaste = true
-
- if (
- editor.clipboard[0].type === 'tab' && widget.childrenType === 'widget' ||
- editor.clipboard[0].type !== 'tab' && widget.childrenType === 'tab'
- ) canPaste = false
-
- if (canPaste) {
-
- pasteActions.push({
- label: icon('paste') + ' ' + locales('editor_paste'),
- action: ()=>{
- editor.pasteWidget(clickX, clickY)
- },
- shortcut: 'mod + v'
- })
- pasteActions.push({
- label: icon('plus-square') + ' ' + locales('editor_pasteindent'),
- action: ()=>{
- editor.pasteWidget(clickX, clickY, true)
- },
- shortcut: 'mod + shift + v'
-
- })
-
- if (editor.idClipboard && widgetManager.getWidgetById(editor.idClipboard).length && editor.clipboard[0].type !== 'tab') {
- pasteActions.push({
- label: icon('clone') + ' ' + locales('editor_clone'),
- action: ()=>{
- editor.pasteWidgetAsClone(clickX, clickY)
- }
- })
- }
-
- }
-
- actions.push({
- label: icon('paste') + ' ' + locales('editor_paste'),
- action: pasteActions,
- class: canPaste ? '' : 'disabled'
- })
-
- }
-
- }
-
- if (parent !== widgetManager && editor.selectedWidgets.length === 1 && editor.selectedWidgets[0].parent.children.length > 1) {
- actions.push({
- separator: true
- })
- actions.push({
- label: icon('layer-group') + ' Position',
- action: [
- {
- label: locales('editor_back'),
- action: ()=>{
- editor.handleKeydown('home')
- },
- shortcut: 'Home'
- },
- {
- label: locales('editor_farther'),
- action: ()=>{
- editor.handleKeydown('pageup')
- },
- shortcut: 'Page Up'
- },
- {
- label: locales('editor_closer'),
- action: ()=>{
- editor.handleKeydown('pagedown')
- },
- shortcut: 'Page Down'
- },
- {
- label: locales('editor_front'),
- action: ()=>{
- editor.handleKeydown('end')
- },
- shortcut: 'End'
- }
- ]
- })
-
- }
-
- if (widget.childrenType !== undefined) {
-
- var addActions = []
-
- for (let category in categories) {
-
- var catActions = []
-
- for (let t in categories[category]) {
-
- let type = categories[category][t]
-
- catActions.push({
-
- label: type,
- action: ()=>{
-
- var newData = {type: type}
-
- if (!eventData.target.classList.contains('tablink')) {
- newData.top = clickY
- newData.left= clickX
- }
-
- if (editor.usePercents) {
- newData.top = (100 * clickY / editor.selectedWidgets[0].widget.offsetHeight).toFixed(2) + '%'
- newData.left= (100 * clickX / editor.selectedWidgets[0].widget.offsetWidth).toFixed(2) + '%'
- newData.height= '6%'
- newData.width = '8%'
- }
-
- data[0].widgets = data[0].widgets || []
- data[0].widgets.push(newData)
-
- var indexes = {addedIndexes: [data[0].widgets.length -1]}
-
- updateWidget(editor.selectedWidgets[0], indexes)
- editor.pushHistory(indexes)
-
- var newWidget = editor.selectedWidgets[0].children[editor.selectedWidgets[0].children.length - 1]
- editor.select([newWidget])
- if (!editor.widgetTree.parent.minimized) editor.widgetTree.showWidget(newWidget)
-
-
- }
- })
-
- }
-
- addActions.push({
- label: category,
- action: catActions
- })
-
- }
-
- if (data.length == 1 && widget.childrenType !== undefined) {
- if (actions.length) actions.push({
- separator: true
- })
- }
-
- if (data.length == 1 && widget.childrenType !== 'tab') {
- actions.push({
- label: icon('plus') + ' ' + locales('editor_addwidget'),
- action: addActions
- })
- }
-
- if (data.length == 1 && widget.childrenType !== 'widget') {
-
- actions.push({
- label: icon('plus') + ' ' + locales('editor_addtab'),
- action: ()=>{
- data[0].tabs = data[0].tabs || []
- data[0].tabs.push({})
-
- var indexes = {addedIndexes: [data[0].tabs.length -1]}
-
- updateWidget(editor.selectedWidgets[0], indexes)
- editor.pushHistory(indexes)
-
- var newWidget = editor.selectedWidgets[0].children[editor.selectedWidgets[0].children.length - 1]
-
- editor.select([newWidget])
- if (!editor.widgetTree.parent.minimized) editor.widgetTree.showWidget(newWidget)
- newWidget.parent.setValue(newWidget.parent.children.indexOf(newWidget))
-
-
- }
- })
-
- }
-
- }
-
-
- if (parent !== widgetManager && data.length === 1) {
-
- actions.push({
- separator: true
- })
-
- actions.push({
- label: icon('file-download') + ' ' + locales('editor_fragment_export'),
- action: ()=>{
- sessionManager.saveFragment(editor.selectedWidgets[0].props)
- }
- })
- }
-
- if (parent !== widgetManager) {
-
- actions.push({
- separator: true
- })
-
- actions.push({
- label: icon('trash') + ' ' + locales('editor_delete'),
- action: editor.deleteWidget.bind(editor),
- shortcut: 'delete'
- })
-
- }
-
- contextMenu.open(eventData, actions)
-
-}
-
-document.body.addEventListener('fast-right-click', handleClick, true)
-document.body.addEventListener('fast-click', handleClick, true)
diff --git a/src/client/editor/data-workers.mjs b/src/client/editor/data-workers.mjs
deleted file mode 100644
index 3a1b1f8e..00000000
--- a/src/client/editor/data-workers.mjs
+++ /dev/null
@@ -1,241 +0,0 @@
-import widgetManager from '../managers/widgets.mjs'
-import stateManager from '../managers/state.mjs'
-import parser from '../parser.mjs'
-import * as resize from '../events/resize.mjs'
-
-var Panel, Matrix, editor
-;(async()=>{
- Panel = (await import('../widgets/containers/panel.mjs')).default
- Matrix = (await import('../widgets/containers/matrix.mjs')).default
- editor = (await import('./index.mjs')).default
-})()
-
-var scrollState = {}
-
-function updateWidget(widget, options={}) {
-
- if (options.editedProps) {
- // alternate routine for small edits
- var propNames = options.editedProps
-
- if (
- // if non dynamic props have changed, skip this and use rebuild routine
- !propNames.some(n => !widget.isDynamicProp(n))
- ) {
- var edited = widget.updateProps(options.editedProps, null, {fromEditor: true}) || widget
-
- editor.widgetTree.updateTree(editor.selectedWidgets)
-
- if (editor.selectedWidgets.includes(widget) && !options.preventSelect) {
- editor.select(edited)
- }
-
- return edited
-
- }
-
- }
-
-
- if (!widget.mounted) {
- console.debug(`updateWidget prevented on ${widget.getProp('id')} (widget not mounted yet)`)
- return
- }
-
- var reuseChildren = options.reuseChildren !== false && widget instanceof Panel
- && !(widget instanceof Matrix)
-
- var children = undefined,
- removedChildren = []
-
- if (reuseChildren) {
- children = [...widget.children]
- if (options.removedIndexes) {
- options.removedIndexes = options.removedIndexes.sort((a, b) => b - a)
- for (let i of options.removedIndexes) {
- removedChildren.push(children.splice(i, 1)[0])
- }
- }
- if (options.addedIndexes) {
- options.addedIndexes = options.addedIndexes.sort((a, b) => a - b)
- for (let i of options.addedIndexes) {
- children.splice(i, 0, null)
- }
- }
-
- }
-
- // get widget's index
- var index = widget.parent.children.indexOf(widget)
-
- // list widgets to remove
- removedChildren = removedChildren.filter(x => x !== undefined)
- var removedWidgets = reuseChildren ?
- removedChildren.map(x => x.getAllChildren().concat(x)).concat(widget).reduce((a,b)=>a.concat(b), []) :
- widget.getAllChildren().concat(widget)
-
- // save state
- if (stateManager.queueCounter === 0) {
- scrollState = {} // scrollable modals don't store their scroll state in their value
- }
- stateManager.incrementQueue()
- for (let w of removedWidgets) {
- if (widgetManager.widgets[w.hash]) {
- let id = w.getProp('id'),
- value = w.getValue(),
- valueProp = w.getProp('value')
-
- stateManager.pushValueState(id, value)
- if (valueProp !== '' && valueProp !== undefined) stateManager.pushValueOldProp(id, valueProp)
- }
- if (w.getProp('scroll') && w.getProp('type') === 'modal') {
- var s = w.getScroll()
- if (s[0] !== 0 || s[1] !== 0) {
- scrollState[w.getProp('id')] = s
- }
- }
- }
-
- // remove old widgets
- widgetManager.removeWidgets(removedWidgets)
-
- // create new widget
- var newWidget = parser.parse({
- data: widget.props,
- parent: widget.parent,
- parentNode: widget.parentNode,
- reCreateOptions: options.reCreateOptions,
- locals: widget.parsersLocalScope,
- variables: widget.variables,
- hash: widget.hash,
- children: children,
- index: index,
- meta: widget.meta
- })
-
- newWidget.container.parentNode.replaceChild(newWidget.container, widget.container)
-
- if (newWidget.getProp('type') === 'tab') newWidget.parent.trigger('tab-created', {widget: widget})
-
-
- if (reuseChildren && !(newWidget instanceof Panel)) {
- // remove remaining children if widget is not a container anymore
- widgetManager.removeWidgets(widget.getAllChildren())
- }
-
- if (reuseChildren) {
- // children don't listen to their parent's 'widget-created' event
- // so we have to let them know it's been updated
- widgetManager.trigger('prop-changed', {
- id: newWidget.getProp('id'),
- props: [],
- widget: newWidget,
- options: {}
- })
- }
-
- resize.check(newWidget.container)
-
- // restore state
- stateManager.decrementQueue()
- if (stateManager.queueCounter === 0) {
- for (let id in scrollState) {
- for (let w of widgetManager.getWidgetById(id)) {
- if (w.getProp('scroll')) w.setScroll(scrollState[id][0], scrollState[id][1])
- }
- }
- }
-
- editor.widgetTree.updateTree(editor.selectedWidgets)
-
- if (editor.selectedWidgets.includes(widget) && !options.preventSelect) {
- editor.select(newWidget)
- }
-
- return newWidget
-
-}
-
-
-var fakeStore = {}
-
-var incrementWidget = function(data, root){
-
- if (!data) return
-
- if (root !== false) {
- fakeStore = {
- id:[],
- address:[]
- }
- }
-
- if (Array.isArray(data)) {
- for (let i in data) {
- data[i] = incrementWidget(data[i], false)
- }
- return data
- }
-
- var id = String(data.id),
- address = String(data.address)
-
- if (id && address == '/' + id) {
-
- data.address = 'auto'
-
- } else if (!address.match(/^(auto|\/control|\/note|\/program|\/sysex|\/mtc|\/key_pressure|\/channel_pressure|\/pitch)$/)) {
-
- var addressref = widgetManager.createAddressRef(null, data.preArgs,address)
-
- while (fakeStore.address.indexOf(address) != -1 || widgetManager.getWidgetByAddress(addressref).length) {
-
- address = address.replace(/([0-9]*)$/,function(m){
- var n = parseInt(m)+1
- n = isNaN(n)?1:n
- return n
- })
- addressref = widgetManager.createAddressRef(null, data.preArgs,address)
- }
-
- fakeStore.address.push(address)
-
- data.address = address
-
- }
-
- if (id) {
- while (fakeStore.id.indexOf(id) != -1 || widgetManager.getWidgetById(id).length) {
- id = id.replace(/([0-9]*)$/,function(m){
- var n = parseInt(m)+1
- n = isNaN(n)?1:n
- return n
- })
- }
-
- fakeStore.id.push(id)
-
- data.id = id
-
- }
-
- if (data.widgets && data.widgets.length) {
- for (let i in data.widgets) {
- data.widgets[i] = incrementWidget(data.widgets[i], false)
- }
- }
-
- if (data.tabs && data.tabs.length) {
- for (let i in data.tabs) {
- data.tabs[i] = incrementWidget(data.tabs[i], false)
- }
- }
-
- return data
-
-}
-
-export {
- updateWidget,
- incrementWidget
-}
diff --git a/src/client/editor/diff.mjs b/src/client/editor/diff.mjs
deleted file mode 100644
index 1d3bd083..00000000
--- a/src/client/editor/diff.mjs
+++ /dev/null
@@ -1,29 +0,0 @@
-import diff from 'jsondiffpatch'
-
-export {diff}
-export function diffToWidget(widget, diff) {
-
- // traverse a diff patch and the associated widget
- // to return the first node (widget and sub-patch) with actual changes
-
- var children = diff.tabs || diff.widgets
-
- if (children) {
- var childrenKeys = Object.keys(children),
- deletedChildren = childrenKeys.filter(x => typeof x === 'string' && x.match(/_[0-9]+/)),
- changedChildren = childrenKeys.filter(x => !isNaN(x))
- }
-
- if (
- !children ||
- Array.isArray(children) || // 'tabs' or 'widgets' property created
- deletedChildren.length || // 'tabs' or 'widgets' property created
- changedChildren.length !== 1 || // children reordered (or same property edited in multiple widgets, but case ignored)
- Array.isArray(children[changedChildren[0]]) // child item created
- ) {
- return [widget, diff]
- }
-
- return diffToWidget(widget.children[changedChildren[0]], children[changedChildren[0]])
-
-}
diff --git a/src/client/editor/index.mjs b/src/client/editor/index.mjs
deleted file mode 100644
index d7e262f2..00000000
--- a/src/client/editor/index.mjs
+++ /dev/null
@@ -1,1136 +0,0 @@
-import keyboardJS from 'keyboardjs/dist/keyboard.min.js'
-import {updateWidget, incrementWidget} from './data-workers.mjs'
-import {diff, diffToWidget} from './diff.mjs'
-import widgetManager from '../managers/widgets.mjs'
-import {deepCopy} from '../utils.mjs'
-import {defaults, widgets} from '../widgets/index.mjs'
-import UiSelectArea from '../ui/ui-selectarea.mjs'
-import UiInspector from '../ui/ui-inspector.mjs'
-import UiTree from '../ui/ui-tree.mjs'
-import UiDragResize from '../ui/ui-dragresize.mjs'
-import uiConsole from '../ui/ui-console.mjs'
-import notifications from '../ui/notifications.mjs'
-import locales from '../locales/index.mjs'
-import {leftUiSidePanel, rightUiSidePanel} from '../ui/index.mjs'
-import ipc from '../ipc/index.mjs'
-import {DOM, GRIDWIDTH, GRIDWIDTH_CSS, ENV, PXSCALE, setGRIDWIDTH, READ_ONLY} from '../globals.mjs'
-import zoom from '../ui/zoom.mjs'
-
-var sessionManager
-;(async()=>{
- sessionManager = (await import('../managers/session/index.mjs')).default
- await import('./context-menu.mjs')
-})()
-
-const macOs = (navigator.platform || '').match('Mac')
-const HISTORY_SIZE = 50
-
-class Editor {
-
- constructor() {
-
- zoom.editor = this
-
- this.inspector = new UiInspector({selector: '#osc-inspector'})
- this.inspector.on('update', (event)=>{
-
- var {propName, value, preventHistory} = event,
- newWidgets = [],
- error = false
-
- if (this.selectedWidgets.some(w=>w.getProp('lock')) && propName !== 'lock') {
- this.select(this.selectedWidgets)
- return
- }
-
- for (var w of this.selectedWidgets) {
-
- let previousValue = w.props[propName]
-
- if ((propName === 'label' || propName === 'popupLabel') && value === true) {
- w.props[propName] = 'auto'
- } else {
- w.props[propName] = value !== '' ? value : deepCopy(defaults[w.props.type]._props()[propName])
- }
-
- try {
-
- newWidgets.push(updateWidget(w, {editedProps: [propName], preventSelect: this.selectedWidgets.length > 1}))
-
- } catch (e) {
-
- w.props[propName] = previousValue
- updateWidget(w, {editedProps: [propName], preventSelect: this.selectedWidgets.length > 1})
-
- if (uiConsole.minimized) notifications.add({
- class: 'error',
- message: locales('inspector_error'),
- duration: 7000
- })
- console.error(
- `Error while setting ${propName} to: ${JSON.stringify(value)}.\n` +
- 'It\'s probably a bug, please open a new bug ticket with the following informations at' +
- 'https://github.com/jean-emmanuel/open-stage-control/issues'
- )
- throw e
- // console.error(e)
- // error = true
- }
- }
-
- if (error) return
-
- if (!preventHistory) this.pushHistory()
-
- if (newWidgets.length > 1) this.select(newWidgets)
-
- })
-
-
- this.widgetTree = new UiTree({selector: '#osc-tree', parent: leftUiSidePanel})
- this.widgetTree.on('sorted', (event)=>{
-
- var {oldIndex, newIndex, from, to} = event,
- propName = from.childrenType + 's',
- container
-
- if (from === to) {
-
- if (to.props[propName].length < 2) return
-
- to.props[propName].splice(newIndex, 0, to.props[propName].splice(oldIndex, 1)[0])
-
- var indices = [newIndex, oldIndex]
- if (Math.abs(oldIndex - newIndex) > 1) {
- for (var i = Math.min(newIndex, oldIndex) + 1; i < Math.max(newIndex, oldIndex); i++) {
- indices.push(i)
- }
- }
-
- container = updateWidget(to, {removedIndexes: indices, addedIndexes: indices, preventSelect: true})
-
- this.pushHistory({removedIndexes: indices, addedIndexes: indices})
- this.select(container.children[newIndex])
-
- } else {
-
- to.props[propName].splice(newIndex, 0, from.props[propName][oldIndex])
- from.props[propName].splice(oldIndex, 1)
-
- updateWidget(from, {removedIndexes: [oldIndex], preventSelect: true})
- container = updateWidget(to, {addedIndexes: [newIndex], preventSelect: true})
-
- this.pushHistory()
- this.select(container.children[newIndex])
-
- }
-
- if (!event.ignoreTree) this.widgetTree.showWidget(container.children[newIndex])
-
-
- })
-
- this.oscContainer = DOM.get('#osc-container')[0]
-
-
-
- this.widgetDragResize = new UiDragResize({})
- this.widgetDragResize.on('move', (e)=>{
- var left = Math.round(e.left / GRIDWIDTH) * GRIDWIDTH,
- top = Math.round(e.top / GRIDWIDTH) * GRIDWIDTH
-
- if (e.copying) {
- this.duplicateWidget(left, top, e.shiftKey)
- } else {
- var dX = left - e.initLeft,
- dY = top - e.initTop
- this.moveWidget(dX, dY)
- }
- })
- this.widgetDragResize.on('drag-resize', (e)=>{
- var width = Math.round(e.width / GRIDWIDTH) * GRIDWIDTH,
- height = Math.round(e.height / GRIDWIDTH) * GRIDWIDTH
- var dX = width - e.initWidth,
- dY = height - e.initHeight
- this.resizeWidget(dX, dY)
- })
-
- this.selectedWidgets = []
-
- this.clipboard = null
- this.tmpClipboard = null
- this.idClipboard = null
- ipc.on('clipboard', (data)=>{
- this.clipboard = data.clipboard
- this.idClipboard = data.idClipboard
- })
-
- this.usePercents = !!ENV.usepercents
-
- this.enabled = false
- this.grid = true
-
- this.unsavedSession = false
- window.onbeforeunload = ()=>{
- if (editor.unsavedSession) return true
- }
-
- this.history = []
- this.historyState = -1
- this.historySession = null
-
- this.mousePosition = {}
- this.mouveMoveHandler = this.mouseMove.bind(this)
- this.mouveLeaveHandler = this.mouseLeave.bind(this)
-
- keyboardJS.withContext('editing', ()=>{
-
- var combos = [
- 'mod + z',
- 'mod + y',
- 'mod + shift + z',
- 'mod + c',
- 'mod + x',
- 'mod + v',
- 'mod + shift + v',
- 'mod + d',
- 'mod + shift + d',
- macOs ? 'backspace' : 'delete',
- 'alt + up',
- 'alt + down',
- 'alt + right',
- 'alt + left',
- 'up',
- 'down',
- 'right',
- 'left',
- 'mod + shift + a',
- 'mod + a',
- 'mod + up',
- 'mod + down',
- 'mod + left',
- 'mod + right',
- 'pageup',
- 'pagedown',
- 'home',
- 'end',
- 't',
- 'y',
- 'f2',
- 'h',
- 'mod + f'
- ]
-
- for (let c of combos) {
- keyboardJS.bind(c, (e)=>{
- e.catchedByEditor = true
- this.handleKeydown(c, e)
- }, (e)=>{
- e.catchedByEditor = true
- this.handleKeyup(c, e)
- })
- }
-
- })
-
- this.selectarea = new UiSelectArea('[data-widget]:not(.not-editable)', (elements, e)=>{
-
- var widgets = elements.map(e => widgetManager.getWidgetByElement(e, ':not(.not-editable)')).filter(e => e)
-
- if (e.ctrlKey) {
-
- // only add siblings to current selection
-
- for (var i in widgets) {
- this.select(widgets[i], {multi:true, fromLasso:true, lassoEnd: i == widgets.length - 1})
- }
-
- } else {
-
- // select the largest group of siblings in area
-
- var groups = {}
- for (var w of widgets) {
- var g = w.parent.hash
- if (!g) continue
- if (!groups[g]) groups[g] = []
- if (!groups[g].includes(w)) groups[g].push(w)
- }
-
- groups = Object.values(groups)
-
- // if the event started from a container widget (but not in the project tree)
- // remove groups that are more than one level away from that container
- if (e.target.tagName !== 'LI' && this.selectedWidgets[0].childrenType !== undefined) {
- groups = groups.filter(g=>g[0].parent === this.selectedWidgets[0] || g[0].parent === this.selectedWidgets[0].parent)
- }
-
- var lengths = groups.map(g=>g.length),
- selection = groups[lengths.lastIndexOf(Math.max(...lengths))]
-
- if (selection) this.select(selection)
- }
-
-
-
- })
-
-
- }
-
- handleKeydown(combo, e){
-
- if (
- this.inspector.helpModalOpened ||
- e && e.target && e.target.tagName.match(/INPUT|TEXTAREA|SELECT|OSC-CONSOLE/)
- ) return
-
- if (e) e.preventDefault()
-
- switch (combo) {
-
- case 'mod + z':
- this.undo()
- break
-
- case 'mod + y':
- case 'mod + shift + z':
- this.redo()
- break
-
- case 'mod + c':
- if (!window.getSelection().toString().length) this.copyWidget()
- break
-
- case 'mod + x':
- if (!window.getSelection().toString().length) this.cutWidget()
- break
-
- case 'mod + v':
- if (!window.getSelection().toString().length) this.pasteWidget(this.mousePosition.x, this.mousePosition.y, false)
- break
-
- case 'mod + shift + v':
- this.pasteWidget(this.mousePosition.x, this.mousePosition.y, true)
- break
-
- case 'mod + d':
- this.duplicateWidget(this.mousePosition.x, this.mousePosition.y, false)
- break
-
- case 'mod + shift + d':
- this.duplicateWidget(this.mousePosition.x, this.mousePosition.y, true)
- break
-
- case 'backspace':
- case 'delete':
- this.deleteWidget()
- break
-
- case 'alt + up':
- case 'alt + down':
- case 'alt + right':
- case 'alt + left':
- if (!this.selectedWidgets.length || this.selectedWidgets[0].parent === widgetManager) return
-
- if (this.selectedWidgets[0].props.height === undefined && e.key.match(/Arrow(Up|Down)/)) return
- if (this.selectedWidgets[0].props.width === undefined && e.key.match(/Arrow(Left|Right)/)) return
-
- var deltaW = e.key === 'ArrowLeft' ? -GRIDWIDTH : e.key === 'ArrowRight' ? GRIDWIDTH : 0,
- deltaH = e.key === 'ArrowUp' ? -GRIDWIDTH : e.key === 'ArrowDown' ? GRIDWIDTH : 0
-
- if (e.shiftKey) {
- deltaW *= 5
- deltaH *= 5
- }
-
- this.resizeWidget(deltaW, deltaH)
-
- break
-
- case 'mod + up':
- case 'mod + down':
- case 'mod + right':
- case 'mod + left':
- if (!this.selectedWidgets.length) return
-
- if (this.selectedWidgets[0].props.top === undefined && e.key.match(/Arrow(Up|Down)/)) return
- if (this.selectedWidgets[0].props.left === undefined && e.key.match(/Arrow(Left|Right)/)) return
-
- var deltaX = e.key === 'ArrowLeft' ? -GRIDWIDTH : e.key === 'ArrowRight' ? GRIDWIDTH : 0,
- deltaY = e.key === 'ArrowUp' ? -GRIDWIDTH : e.key === 'ArrowDown' ? GRIDWIDTH : 0
-
- if (e.shiftKey) {
- deltaX *= 5
- deltaY *= 5
- }
-
- this.moveWidget(deltaX, deltaY)
-
- break
-
- case 'mod + shift + a':
- if (!this.selectedWidgets.length) return
- this.unselect()
- this.selectedWidgets = []
- this.inspector.clear()
- break
-
- case 'mod + a':
- if (!this.selectedWidgets.length) return
-
- var curWidget1 = this.selectedWidgets[0]
-
- if (curWidget1.parent !== widgetManager) {
- this.select([...curWidget1.parent.children])
- }
- break
-
- case 'up':
- case 'down':
- case 'right':
- case 'left':
- if (!this.selectedWidgets.length) return
-
- var curWidget = this.selectedWidgets[0],
- toSelect = null
-
- if (e.key === 'ArrowLeft' && curWidget.parent !== widgetManager) {
-
- toSelect = curWidget.parent
-
- } else if (e.key === 'ArrowRight') {
-
- if (curWidget.children[0] && !curWidget.children[0].meta.not_editable) {
- toSelect = curWidget.children[0]
- }
-
- } else if((e.key == 'ArrowUp') || (e.key == 'ArrowDown')){
-
- if (curWidget.parent === widgetManager) return
-
- let toSelectList = [...curWidget.parent.children]
-
- if (toSelectList && toSelectList.length) {
- toSelectList.sort((a,b) => a.container.offsetLeft > b.container.offsetLeft)
- var idx = toSelectList.indexOf(curWidget)
- if (idx >= 0) {
- var nextIdx = (idx + (e.key === 'ArrowUp' ? -1 : 1 ) + toSelectList.length) % toSelectList.length
- toSelect = toSelectList[nextIdx]
- }
- }
- }
-
- if (toSelect) {
- this.select(toSelect)
- }
-
- break
-
- case 'pagedown':
- case 'pageup':
- case 'home':
- case 'end':
- if (this.selectedWidgets.length !== 1 || this.selectedWidgets[0].parent.children.length <= 1) return
-
- var curWidget2 = this.selectedWidgets[0],
- index = curWidget2.parent.children.indexOf(curWidget2),
- maxIndex = curWidget2.parent.children.length - 1,
- newIndex
-
- if (combo === 'pagedown') newIndex = Math.min(index + 1, maxIndex)
- else if (combo === 'pageup') newIndex = Math.max(index - 1, 0)
- else if (combo === 'end') newIndex = maxIndex
- else if (combo === 'home') newIndex = 0
-
- if (index !== newIndex) {
- this.widgetTree.trigger('sorted', {
- from: curWidget2.parent,
- to: curWidget2.parent,
- oldIndex: index,
- newIndex: newIndex,
- ignoreTree: true
- })
- }
- break
-
- case 't':
- if (!this.selectedWidgets.length) return
- this.widgetTree.showWidget(editor.selectedWidgets[0])
- this.widgetTree.blinkSelected()
- break
- case 'y':
- if (!this.selectedWidgets.length) return
- for (let w of editor.selectedWidgets) {
- this.widgetTree.showWidgetInSession(w)
- }
- this.widgetTree.showWidget(editor.selectedWidgets[0])
- break
- case 'f2':
- if (!this.selectedWidgets.length) return
- if (this.selectedWidgets[0].props.label === undefined && this.selectedWidgets[0].props.html === undefined) return
- if (!this.inspector.expandedCategories.includes('style')) {
- var header = DOM.get(this.inspector.container, '.category-header[data-name="style"]')[0]
- if (header) {
- header.parentNode.classList.add('expanded')
- this.inspector.expandedCategories.push('style')
- }
- }
- var labelProp = this.selectedWidgets[0].props.label === undefined ? 'html' : 'label'
- var input = DOM.get(this.inspector.container, `textarea[name="${labelProp}"]`)[0]
- if (input) {
- if (input._ace_input) {
- input._ace_input.focus()
- } else {
- input.focus()
- input.setSelectionRange(0, input.value.length)
- input.scrollIntoView({block: 'center'})
- }
- }
- break
- case 'h':
- document.body.classList.add('editor-hide-selection')
- break
- case 'mod + f':
- if (this.widgetTree.parent.minimized) this.widgetTree.parent.restore()
- this.widgetTree.filter.focus()
- break
-
- }
-
-
- }
-
- handleKeyup(combo, e){
-
- if (
- this.inspector.helpModalOpened ||
- (e && e.target && e.target.tagName && e.target.tagName.match(/INPUT|TEXTAREA|SELECT/))
- ) return
-
- if (e) e.preventDefault()
-
- switch (combo) {
-
- case 'h':
- document.body.classList.remove('editor-hide-selection')
- break
-
- }
- }
-
- toggleGrid() {
-
- this.grid = !this.grid
-
- setGRIDWIDTH(this.grid ? GRIDWIDTH_CSS : 1)
-
- document.body.style.setProperty('--grid-width', GRIDWIDTH)
- document.body.classList.toggle('no-grid', GRIDWIDTH == 1)
-
- }
-
- enable() {
-
- if (READ_ONLY || sessionManager.session === null) return
-
- this.enabled = true
-
- document.body.classList.add('editor-enabled')
- document.body.classList.remove('editor-disabled')
-
- this.widgetTree.updateTree(this.selectedWidgets)
-
- leftUiSidePanel.enable()
- rightUiSidePanel.enable()
-
-
- // keyboardJS hack: prevent releaseAllKeys when switching context
- var locale = keyboardJS._locale
- keyboardJS._locale = null
- keyboardJS.setContext('editing')
- keyboardJS._locale = locale
-
- this.oscContainer.addEventListener('mousemove', this.mouveMoveHandler)
- this.oscContainer.addEventListener('mouseleave', this.mouveLeaveHandler)
-
- this.selectarea.enable()
-
- }
-
- disable() {
-
- this.unselect()
- this.selectedWidgets = []
-
- document.body.classList.add('editor-disabled')
- document.body.classList.remove('editor-enabled')
-
- // keyboardJS hack: prevent releaseAllKeys when switching context
- var locale = keyboardJS._locale
- keyboardJS._locale = null
- keyboardJS.setContext('global')
- keyboardJS._locale = locale
-
- this.oscContainer.removeEventListener('mousemove', this.mouveMoveHandler)
- this.oscContainer.removeEventListener('mouseleave', this.mouveLeaveHandler)
-
- leftUiSidePanel.disable()
- rightUiSidePanel.disable()
- this.widgetTree.clear()
- this.inspector.clear()
-
- this.selectarea.disable()
-
- this.enabled = false
-
- }
-
-
- unselect() {
-
- this.widgetDragResize.clear()
- this.inspector.clear()
-
- DOM.each(document, '.editing', (element)=>{
- element.classList.remove('editing')
- })
-
- this.widgetTree.select([])
-
- }
-
- select(widget, options={}){
-
- if (!this.enabled) return
-
- if (Array.isArray(widget)) {
-
- this.selectedWidgets = widget
-
- } else if (options.multi) {
-
- var sameLevel = false
-
- while (!sameLevel && widget.parent !== widgetManager) {
- let test = true
- if (this.selectedWidgets.length && this.selectedWidgets[0].parent !== widget.parent) test = false
- sameLevel = test
- if (!sameLevel) widget = widget.parent
- }
-
- if (!this.selectedWidgets.includes(widget) && sameLevel) {
-
- this.selectedWidgets.push(widget)
-
- } else if (sameLevel && !options.fromLasso){
-
- this.selectedWidgets.splice(this.selectedWidgets.indexOf(widget), 1)
-
- }
-
- } else {
-
- this.selectedWidgets = [widget]
-
- }
-
- if (this.selectedWidgets.length) {
- var parent = this.selectedWidgets[0].parent
- while (parent !== widgetManager) {
- if (parent.getProp('lock')) {
- this.selectedWidgets = [parent]
- }
- parent = parent.parent
- }
- }
-
- if (options.fromLasso && !options.lassoEnd) return
-
- this.unselect()
-
- if (this.selectedWidgets.length > 0) {
-
- this.inspector.inspect(this.selectedWidgets)
- this.createSelectionBlock()
-
- } else {
-
- this.inspector.clear()
-
- }
-
- }
-
-
- createSelectionBlock(){
-
- for (let widget of this.selectedWidgets) {
- DOM.each(document, `[data-widget="${widget.hash}"]`, (item)=>{
- item.classList.add('editing')
- })
- }
- this.widgetTree.select(this.selectedWidgets)
- this.widgetDragResize.create(this.selectedWidgets)
- if (!this.widgetTree.parent.minimized) {
- this.widgetTree.showWidget(editor.selectedWidgets[editor.selectedWidgets.length-1])
- }
-
- }
-
- mouseMove(e) {
-
- this.mousePosition.x = Math.round((e.offsetX + e.target.scrollLeft) / (GRIDWIDTH * PXSCALE)) * GRIDWIDTH,
- this.mousePosition.y = Math.round((e.offsetY + e.target.scrollTop) / (GRIDWIDTH * PXSCALE)) * GRIDWIDTH
-
- }
-
- mouseLeave(e) {
-
- this.mousePosition = {}
-
- }
-
- copyWidget(tmp) {
-
- if (!this.selectedWidgets.length) return
- if (this.selectedWidgets[0].getProp('type') === 'root') return
-
- this.clipboard = deepCopy(this.selectedWidgets.map((w)=>w.props))
- this.idClipboard = this.selectedWidgets[0].getProp('id')
-
- ipc.send('clipboard', {
- clipboard: this.clipboard,
- idClipboard: this.idClipboard
- })
-
- }
-
- duplicateWidget(x, y, increment) {
-
- if (!this.selectedWidgets.length) return
- if (this.selectedWidgets[0].getProp('type') === 'root') return
-
- this.tmpClipboard = deepCopy(this.selectedWidgets.map((w)=>w.props))
- var index = Math.max(...this.selectedWidgets.map(w=>w.parent.children.indexOf(w)))
- this.select(this.selectedWidgets[0].parent)
- this.pasteWidget(x, y, increment, index + 1, true)
- this.select(this.selectedWidgets[0].children[index + 1])
-
- }
-
- cutWidget() {
-
- this.copyWidget()
- this.deleteWidget()
-
- }
-
- pasteWidget(x, y, increment, index, tmp) {
-
- if (!this.selectedWidgets.length) return
-
- var clipboard = tmp ? this.tmpClipboard : this.clipboard
-
- if (clipboard === null) return
-
- if (
- this.selectedWidgets[0].childrenType === undefined ||
- clipboard[0].type === 'tab' && this.selectedWidgets[0].childrenType === 'widget' ||
- clipboard[0].type !== 'tab' && this.selectedWidgets[0].childrenType === 'tab'
- ) return
-
- var pastedData = deepCopy(clipboard),
- minTop = Infinity,
- minLeft = Infinity
-
- if (increment) {
- pastedData = incrementWidget(pastedData)
- }
-
-
- if (x !== undefined) {
-
- for (let i in pastedData) {
-
- let top = pastedData[i].top,
- left = pastedData[i].left
-
- if (typeof top === 'string' && top.includes('%')) {
- top = parseFloat(top) / 100 * this.selectedWidgets[0].widget.offsetHeight
- pastedData[i]._atop = top
- pastedData[i]._ptop = true
- }
-
- if (typeof left === 'string' && left.includes('%')) {
- left = parseFloat(left) / 100 * this.selectedWidgets[0].widget.offsetWidth
- pastedData[i]._aleft = left
- pastedData[i]._pleft = true
- }
-
-
- if (top < minTop) minTop = top
- if (left < minLeft) minLeft = left
-
- }
-
- for (let i in pastedData) {
-
- if (!String(pastedData[i].left).match(/\{/)) {
-
- if (pastedData[i]._pleft) {
- pastedData[i].left = ((pastedData[i]._aleft - minLeft + x) * 100 / this.selectedWidgets[0].widget.offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
- } else {
- pastedData[i].left += - minLeft + x
- }
-
- }
-
- if (!String(pastedData[i].top).match(/\{/)) {
-
- if (pastedData[i]._ptop) {
- pastedData[i].top = ((pastedData[i]._atop - minTop + y) * 100 / this.selectedWidgets[0].widget.offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
- } else {
- pastedData[i].top += - minTop + y
- }
-
- }
-
-
- }
-
- }
-
-
- // paste data
-
- var store = clipboard[0].type === 'tab' ? 'tabs' : 'widgets'
-
- this.selectedWidgets[0].props[store] = this.selectedWidgets[0].props[store] || []
-
- var indexes = {addedIndexes: []},
- start = index || this.selectedWidgets[0].props[store].length
-
- this.selectedWidgets[0].props[store].splice(start, 0, ...pastedData)
-
- for (let i = 0; i < pastedData.length; i++) {
- indexes.addedIndexes.push(start + pastedData.length - 1 - i )
- }
-
- if (index)indexes.reuseChildren=false
-
- updateWidget(this.selectedWidgets[0], indexes)
-
- this.pushHistory(indexes)
-
- if (!leftUiSidePanel.minimized) this.widgetTree.showWidget(this.selectedWidgets[0].children[0])
-
- }
-
- pasteWidgetAsClone(x, y) {
-
- if (!this.selectedWidgets.length || this.clipboard === null) return
- if (!this.idClipboard || !widgetManager.getWidgetById(this.idClipboard).length) return
-
- if (
- this.selectedWidgets[0].childrenType === undefined ||
- this.clipboard[0].type === 'tab' ||
- this.clipboard[0].type !== 'tab' && this.selectedWidgets[0].childrenType === 'tab'
- ) return
-
- var clone = {type: 'clone', widgetId: this.idClipboard},
- pastedData = deepCopy(this.clipboard)
-
- clone.width = pastedData[0].width
- clone.height = pastedData[0].height
-
-
- if (x !== undefined) {
-
- clone.left = x
- clone.top = y
-
- if (this.usePercents) {
- clone.top = (100 * y / editor.selectedWidgets[0].widget.offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
- clone.left= (100 * x / editor.selectedWidgets[0].widget.offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
- }
-
-
- }
-
- this.selectedWidgets[0].props.widgets = this.selectedWidgets[0].props.widgets || []
- this.selectedWidgets[0].props.widgets.push(clone)
-
- var indexes = {addedIndexes: [this.selectedWidgets[0].props.widgets.length -1]}
-
- updateWidget(this.selectedWidgets[0], indexes)
-
- this.pushHistory(indexes)
-
- if (!leftUiSidePanel.minimized) this.widgetTree.showWidget(this.selectedWidgets[0].children[0])
-
-
- }
-
-
- deleteWidget() {
-
- if (!this.selectedWidgets.length) return
- if (this.selectedWidgets[0].getProp('type') === 'root') return
-
- var type = this.selectedWidgets[0].props.type == 'tab' ? 'tab' : 'widget',
- parent = this.selectedWidgets[0].parent,
- index = this.selectedWidgets.map(w => parent.children.indexOf(w)).sort((a,b)=>{return b-a}),
- removedIndexes = []
-
- if (type === 'widget') {
- for (let i of index) {
- removedIndexes.push(i)
- parent.props.widgets.splice(i,1)
- }
- } else {
- for (let i of index) {
- removedIndexes.push(i)
- parent.props.tabs.splice(i,1)
- }
- }
-
- var container = updateWidget(parent, {preventSelect: true, removedIndexes})
- if (container.children.length) {
- this.select(container.children[Math.min(index.pop(), container.children.length - 1)])
- } else {
- this.select(container)
- }
- this.pushHistory({removedIndexes})
-
- }
-
- /* Utility function to retrieve the first sizable node */
- getWidgetParentContainer(widget) {
-
- while (widget.parent instanceof widgets.folder) {
- widget = widget.parent
- }
-
- return widget.container.parentNode
-
- }
-
- resizeWidget(deltaW, deltaH) {
-
- if (!this.selectedWidgets.length) return
-
- if (this.selectedWidgets.some(w=>w.getProp('lock'))) {
- this.createSelectionBlock()
- return
- }
-
- var newWidgets = [],
- area = this.widgetDragResize,
- editedProps = []
-
- for (var i = 0; i < this.selectedWidgets.length; i++) {
-
- let w = this.selectedWidgets[i],
- nW, nH, nL, nT
-
- nW = w.container.offsetWidth + deltaW * w.container.offsetWidth / area.initWidth
- nH = w.container.offsetHeight + deltaH * w.container.offsetHeight / area.initHeight
-
- if (this.selectedWidgets.length > 1) {
- nL = w.container.offsetLeft + deltaW * (w.container.offsetLeft - area.initLeft) / area.initWidth
- nT = w.container.offsetTop + deltaH * (w.container.offsetTop - area.initTop) / area.initHeight
- }
-
- if (deltaW !== 0 && w.props.width !== undefined && w.parent.getProp('layout') !== 'vertical') {
- var newWidth = Math.max(nW, GRIDWIDTH) / PXSCALE
- if (typeof w.props.width === 'string' && w.props.width.indexOf('%') > -1) {
- w.props.width = (100 * PXSCALE * newWidth / this.getWidgetParentContainer(w).offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
- } else {
- w.props.width = newWidth
- }
- editedProps.push('width')
-
- if (this.selectedWidgets.length > 1) {
- var newLeft = Math.max(nL, GRIDWIDTH) / PXSCALE
- if (typeof w.props.left === 'string' && w.props.left.indexOf('%') > -1) {
- w.props.left = (100 * PXSCALE * newLeft / this.getWidgetParentContainer(w).offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
- } else if (w.props.left !== 'auto'){
- w.props.left = newLeft
- }
- editedProps.push('left')
- }
-
- }
-
- if (deltaH !== 0 && w.props.height !== undefined && w.parent.getProp('layout') !== 'horizontal') {
- var newHeight = Math.max(nH, GRIDWIDTH) / PXSCALE
- if (typeof w.props.height === 'string' && w.props.height.indexOf('%') > -1) {
- w.props.height = (100 * PXSCALE * newHeight / this.getWidgetParentContainer(w).offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
- } else {
- w.props.height = newHeight
- }
- editedProps.push('height')
-
- if (this.selectedWidgets.length > 1) {
- var newTop = Math.max(nT, GRIDWIDTH) / PXSCALE
- if (typeof w.props.top === 'string' && w.props.top.indexOf('%') > -1) {
- w.props.top = (100 * PXSCALE * newTop / this.getWidgetParentContainer(w).offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
- } else if (w.props.top !== 'auto'){
- w.props.top = newTop
- }
- editedProps.push('top')
- }
- }
-
- if (w.props.width !== undefined || w.props.height !== undefined) newWidgets.push(updateWidget(w, {editedProps: editedProps, preventSelect: this.selectedWidgets.length > 1}))
-
- }
-
- this.pushHistory()
-
- // if (newWidgets.length > 1) this.select(newWidgets, {preventSelect: this.selectedWidgets.length > 1})
- this.createSelectionBlock()
-
- }
-
- moveWidget(deltaX, deltaY) {
-
- if (!this.selectedWidgets.length) return
-
- if (this.selectedWidgets.some(w=>w.getProp('lock'))) {
- this.createSelectionBlock()
- return
- }
-
- var newWidgets = []
-
- for (var w of this.selectedWidgets) {
-
- var newTop = Math.max(parseInt(w.container.offsetTop) / PXSCALE + deltaY, 0)
- if (typeof w.props.top === 'string' && w.props.top.indexOf('%') > -1) {
- w.props.top = (100 * PXSCALE * newTop / this.getWidgetParentContainer(w).offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
- } else {
- w.props.top = newTop
- }
- var newLeft = Math.max(parseInt(w.container.offsetLeft) / PXSCALE + deltaX, 0)
- if (typeof w.props.left === 'string' && w.props.left.indexOf('%') > -1) {
- w.props.left = (100 * PXSCALE * newLeft / this.getWidgetParentContainer(w).offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
- } else {
- w.props.left = newLeft
- }
-
- newWidgets.push(updateWidget(w, {editedProps: ['top', 'left'], preventSelect: this.selectedWidgets.length > 1}))
-
- }
-
- this.pushHistory()
-
- // if (newWidgets.length > 1) this.select(newWidgets)
- this.createSelectionBlock()
-
- }
-
-
-
- pushHistory(indexes) {
-
- if (!ENV.noWarning) {
- this.unsavedSession = true
- }
-
- if (this.historyState > -1) {
- this.history.splice(0, this.historyState + 1)
- this.historyState = -1
- }
-
- var d = diff.diff(this.historySession, sessionManager.session.getRoot())
-
- if (d) {
- diff.patch(this.historySession, deepCopy(d))
- this.history.unshift([deepCopy(d), indexes])
- if (this.history.length > HISTORY_SIZE) this.history.pop()
- }
-
- }
-
- clearHistory() {
-
- this.history = []
- this.historyState = -1
- this.historySession = deepCopy(sessionManager.session.getRoot())
-
- }
-
- undo() {
-
- if (this.historyState === this.history.length - 1) return
-
- this.historyState += 1
-
- var [patch, indexes] = this.history[this.historyState],
- d1 = deepCopy(patch),
- d2 = deepCopy(patch)
-
- diff.unpatch(this.historySession, d1)
- diff.unpatch(sessionManager.session.getRoot(), d2)
-
- this.updateWidgetFromPatch(patch, indexes ? {
- addedIndexes: deepCopy(indexes.removedIndexes),
- removedIndexes: deepCopy(indexes.addedIndexes),
- } : undefined)
-
- }
-
- redo() {
-
- if (this.historyState === -1) return
-
- var [patch, indexes] = this.history[this.historyState],
- d1 = deepCopy(patch),
- d2 = deepCopy(patch)
-
- diff.patch(this.historySession, d1)
- diff.patch(sessionManager.session.getRoot(), d2)
-
- this.updateWidgetFromPatch(patch, indexes ? {
- addedIndexes: deepCopy(indexes.addedIndexes),
- removedIndexes: deepCopy(indexes.removedIndexes),
- } : undefined)
-
- this.historyState -= 1
-
- }
-
- updateWidgetFromPatch(patch, indexes) {
-
- var [widget, subpatch] = diffToWidget(widgetManager.getWidgetById('root')[0], patch),
- options = {}
-
- if (indexes) {
- options = {...indexes}
- } else {
- options.editedProps = Object.keys(subpatch)
- options.reuseChildren = false
- }
-
- updateWidget(widget, options)
-
- if (this.selectedWidgets[0] && !widgetManager.widgets[this.selectedWidgets[0].hash]) {
- this.unselect()
- this.selectedWidgets = []
- this.inspector.clear()
- } else if (this.selectedWidgets[0]) {
- this.widgetDragResize.create(this.selectedWidgets)
- }
-
- }
-
-
-
-
-}
-
-var editor = new Editor()
-
-export default editor
diff --git a/src/client/events/click.mjs b/src/client/events/click.mjs
deleted file mode 100644
index 44f76794..00000000
--- a/src/client/events/click.mjs
+++ /dev/null
@@ -1,83 +0,0 @@
-import iOS from '../ui/ios.mjs'
-import editor from '../editor/index.mjs'
-import {DOM, FOCUSABLE, ENV} from '../globals.mjs'
-
-const macOs = (navigator.platform || '').match('Mac')
-
-var longTouchTimer = false,
- clearLongTouchTimer = function() {
- if (longTouchTimer) {
- clearTimeout(longTouchTimer)
- longTouchTimer = false
- }
- }
-
-if (macOs) {
- // on macOs, ctrl+click generates a contextmenu event
- // that should be interpreted as a rightclick
- document.body.addEventListener('contextmenu', (event)=>{
- event.preventDefault()
- DOM.dispatchEvent(event.target, 'fast-right-click', event)
- })
-} else {
- document.body.addEventListener('contextmenu', (event)=>{
- if (
- event.target &&
- !event.target.classList.contains('ace_content') &&
- !event.target.tagName.match(/INPUT|TEXTAREA|OSC-CONSOLE|OSC-CONSOLE-MESSAGE/)
- ) event.preventDefault()
- })
-}
-
-function mouseToFastClick(event) {
-
- if (event.pointerType === 'touch') return
- if (event.button == 2) event.preventDefault()
-
- var e = event
-
- var name = event.button == 2 ? 'fast-right-click' : 'fast-click'
-
- DOM.dispatchEvent(e.target, name, e)
-
- if (!FOCUSABLE && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
- console.debug('ELECTRON.BLUR()')
- }
-
-}
-
-function touchToFastClick(event) {
-
- var e = event.changedTouches[0]
-
- e.shiftKey = event.shiftKey
- e.ctrlKey = event.ctrlKey
-
- DOM.dispatchEvent(e.target, 'fast-click', e)
-
- if (e.preventOriginalEvent) event.preventDefault()
-
- longTouchTimer = setTimeout(()=>{
-
- var off = DOM.offset(e.target)
-
- e.offsetX = e.pageX - off.left
- e.offsetY = e.pageY - off.top
-
- DOM.dispatchEvent(e.target, 'fast-right-click', e)
-
- clearLongTouchTimer()
-
- }, 600)
-
- if (ENV.nofocus && !editor.enabled && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
- console.debug('ELECTRON.BLUR()')
- }
-
-}
-
-if (!iOS) document.addEventListener('pointerdown', mouseToFastClick, true)
-document.addEventListener('touchstart', touchToFastClick, {passive: false, capture: true})
-
-
-DOM.addEventListener(document, 'touchend touchmove touchcancel', clearLongTouchTimer)
diff --git a/src/client/events/dom-event.mjs b/src/client/events/dom-event.mjs
deleted file mode 100644
index 24c81d77..00000000
--- a/src/client/events/dom-event.mjs
+++ /dev/null
@@ -1,42 +0,0 @@
-export default function(eventName, options={}){
-
- var widget_storage_key = '_' + eventName + '_widget'
-
- function closestWidgetContainer(target) {
- var container = target
- while (container !== null) {
- if (container[widget_storage_key]) {
- return container
- } else {
- container = container.parentNode
- }
- }
- return null
- }
-
- function triggerWidgetEvent(target, event) {
- var container = closestWidgetContainer(target)
- if (container) container[widget_storage_key].trigger(eventName, event)
- }
-
- document.addEventListener(eventName, (event)=>{
- triggerWidgetEvent(event.target, event)
- }, {passive: !!options.passive, capture: !!options.capture})
-
- return {
-
- setup: function(options) {
- var {element} = options || {element: this.container}
- element[widget_storage_key] = this
- },
-
- teardown: function(options) {
- var {element} = options || {element: this.container}
- delete element[widget_storage_key]
- }
-
-
- }
-
-
-}
diff --git a/src/client/events/double-click.mjs b/src/client/events/double-click.mjs
deleted file mode 100644
index 1649c411..00000000
--- a/src/client/events/double-click.mjs
+++ /dev/null
@@ -1,45 +0,0 @@
-import {DOUBLE_TAP_TIME} from '../globals.mjs'
-
-export default (element, callback, options={})=>{
-
- var lastTapTime = 0,
- lastTapX,
- lastTapY
-
- element.addEventListener(options.click ? 'click' : 'fast-click', (event)=>{
-
- if (event.capturedByEditor && !options.ignoreEditorCapture) return
-
- var tapTime = Date.now(),
- tapLength = tapTime - lastTapTime,
- eventData = options.click ? event : event.detail
-
- if (
-
- tapLength < DOUBLE_TAP_TIME &&
- Math.abs(lastTapX - eventData.pageX) < 20 &&
- Math.abs(lastTapY - eventData.pageY) < 20 &&
- (!options.click || event.pageX !== 0) // prevent fake click emitted with keyboard focus events
-
- ) {
-
- // execute callback at next cycle to ensure draginit events are resolved first
- setTimeout(()=>{
- callback(event.detail)
- }, 0)
- lastTapTime = 0
-
- // prevent touchend
- if (!options.click) event.detail.preventOriginalEvent = true
-
- } else {
-
- lastTapTime = tapTime
- lastTapX = eventData.pageX
- lastTapY = eventData.pageY
-
- }
-
- })
-
-}
diff --git a/src/client/events/drag.mjs b/src/client/events/drag.mjs
deleted file mode 100644
index 66799589..00000000
--- a/src/client/events/drag.mjs
+++ /dev/null
@@ -1,426 +0,0 @@
-import {normalizeDragEvent, resetEventOffset, TRAVERSING_SAMEWIDGET} from './utils.mjs'
-import iOS from '../ui/ios.mjs'
-import {DOM} from '../globals.mjs'
-
-var targets = {},
- previousPointers = {}
-
-function pointerDownHandler(event) {
-
- if (event.capturedByEditor || event.touchPunch) return event
-
- if (!event.target._drag_multitouch) {
- for (var i in targets) {
- if (targets[i] == event.target) return event
- }
- }
-
- event = normalizeDragEvent(event)
- event.stopPropagation = true
-
- var target = closestDragContainer(event.target)
-
- if (!target) return event
-
- if (event.traversingStack) {
-
- var widget = target._drag_widget,
- local = event.traversingStack.stack[event.traversingStack.stack.length - 1]
-
- if (widget.getProp) {
- // if first touched widget is a container, wait until another widget is touched while moving
- event.traversingStack.firstType = widget.isContainer ? '?' : widget.getProp('type')
- }
-
- if (local.mode === TRAVERSING_SAMEWIDGET) {
- if (local.type === '') {
- local.type = event.traversingStack.firstType
- }
- event.traversing = local.type === event.traversingStack.firstType || event.traversingStack.firstType === '?'
- } else {
- event.traversing = true
- }
-
- }
-
- targets[event.pointerId] = target
- previousPointers[event.pointerId] = event
-
-
- if (event.pointerType !== 'mouse') domObserver.activate()
-
- triggerWidgetEvent(targets[event.pointerId], 'draginit', event)
-
- if (event.cancelDragEvent) clearPointer(event)
-
- return event
-
-}
-
-function pointerMoveHandler(event) {
-
- event = normalizeDragEvent(event, previousPointers[event.pointerId])
-
- event.stopPropagation = true
-
- if (event.traversing) {
-
- var previousTarget = targets[event.pointerId],
- target = event.isTouch ?
- document.elementFromPoint(event.clientX, event.clientY)
- : event.target
-
- if (target) target = closestDragContainer(target)
-
- var local = null,
- containersOnly = false,
- backupTarget = target
-
- if (target && event.traversingStack) {
- for (var i = event.traversingStack.stack.length - 1; i > -1; i--) {
- if (event.traversingStack.stack[i].container.contains(target)) {
- local = event.traversingStack.stack[i]
- break
- }
- }
- if (!local) {
- target = null
- } else if (local.mode === TRAVERSING_SAMEWIDGET) {
- var widget = target._drag_widget
- if (local.type === '?' && widget.getProp && !widget.isContainer) local.type = widget.getProp('type')
- if (widget.getProp && local.type !== widget.getProp('type')) target = null
- }
- }
-
-
-
-
- if (target && event.isTouch) {
- resetEventOffset(event, target)
- }
-
- if (previousTarget !== target && !containersOnly) {
- triggerWidgetEvent(previousTarget, 'dragend', event)
- }
-
-
- if (target) {
-
- if (previousTarget === target) {
-
- triggerWidgetEvent(target, 'drag', event)
-
- } else {
- triggerWidgetEvent(target, 'draginit', event)
-
- }
-
- } else {
-
- // notify container of move events if no draggable widget is under the pointer
- triggerWidgetEvent(backupTarget, 'drag', event, true)
-
- }
-
- targets[event.pointerId] = target
-
-
- } else {
- triggerWidgetEvent(targets[event.pointerId], 'drag', event)
- }
-
- previousPointers[event.pointerId] = event
-
-}
-
-function pointerUpHandler(event) {
-
- event = normalizeDragEvent(event, previousPointers[event.pointerId])
- event.stopPropagation = true
-
- triggerWidgetEvent(targets[event.pointerId], 'dragend', event)
-
- clearPointer(event)
-
-}
-
-function clearPointer(event) {
-
- delete targets[event.pointerId]
- delete previousPointers[event.pointerId]
-
- if (domObserver.active) {
- var t
- for (var k in targets) {t=targets[k]}
- if (t === undefined) domObserver.deactivate()
- }
-
-}
-
-
-// Move / Up Filter
-
-function pointerMoveFilter(event) {
-
- if (targets[event.pointerId] !== undefined) {
- pointerMoveHandler.call(targets[event.pointerId], event)
- }
-
-}
-
-function pointerUpFilter(event) {
-
- if (targets[event.pointerId] !== undefined) {
- pointerUpHandler.call(targets[event.pointerId], event)
- delete targets[event.pointerId]
- }
-
-}
-
-// Mouse events wrappers
-
-function mouseDownCapture(event) {
- if (event.pointerType === 'touch') return
- event.stopPropagation()
- // event.pointerId = 'mouse'
- pointerDownHandler(event)
-}
-
-function mouseMoveCapture(event) {
- if (event.pointerType === 'touch') return
- // event.pointerId = 'mouse'
- event.inertia = event.ctrlKey ? 10 : 1
- pointerMoveFilter(event)
-}
-
-function mouseUpCapture(event){
- if (event.pointerType === 'touch') return
- // event.pointerId = 'mouse'
- pointerUpFilter(event)
-}
-
-
-// Touch events wrappers
-
-// Touchend event is not emitted when target element is removed/detached
-// Watch for DOM mutations and simulate pointerUp if a registered
-// target is removed/detached
-const domObserver = new MutationObserver(function(mutations) {
- for (var id in targets) {
- var event = previousPointers[id],
- target = targets[id]
-
- if (!event || event.pointerType === 'mouse') continue
-
- for (var mutation of mutations) {
- for (var node of mutation.removedNodes) {
- if (node == target || node.contains(target)){
- pointerUpHandler(event)
- }
- }
- }
- }
-})
-domObserver.active = false
-domObserver.activate = ()=>{
- if (!domObserver.active) {
- domObserver.observe(DOM.get('#osc-container')[0], {subtree: true, childList: true})
- domObserver.active = true
- }
-}
-domObserver.deactivate = ()=>{
- if (domObserver.active) {
- domObserver.disconnect()
- domObserver.active = false
- }
-}
-
-function touchDownCapture(event) {
-
- var preventDefault = true
-
- event.stopPropagation()
-
- for (var i in event.changedTouches) {
- if (isNaN(i) || !event.changedTouches[i]) continue
- var touchEvent = event.changedTouches[i]
-
- if (event.traversingStack) {
- touchEvent.traversingStack = event.traversingStack
- }
-
- touchEvent.pointerId = touchEvent.identifier
-
- touchEvent = pointerDownHandler(touchEvent)
-
- // allow scroll if drag is cancelled or widget is a container
- if (touchEvent.cancelDragEvent || touchEvent.allowScroll) preventDefault = false
- }
- if (preventDefault) event.preventDefault()
-}
-
-function touchMoveCapture(event) {
- for (var i in event.changedTouches) {
- if (isNaN(i) || !event.changedTouches[i]) continue
- var touchEvent = event.changedTouches[i]
- touchEvent.fingers = 0
- for (var j in event.touches) {
- if (event.touches[j].target && event.touches[j].target.isSameNode(touchEvent.target)) {
- touchEvent.fingers += 1
- }
- }
-
- touchEvent.pointerId = touchEvent.identifier
- pointerMoveFilter(touchEvent)
- }
-}
-
-function touchUpCapture(event) {
- for (var i in event.changedTouches) {
- if (isNaN(i) || !event.changedTouches[i]) continue
- var touchEvent = event.changedTouches[i]
- touchEvent.pointerId = touchEvent.identifier
- pointerUpFilter(touchEvent)
- }
-}
-
-
-
-function ancestorDragContainers(target) {
- var containers = [],
- container = target
- while (container !== null) {
- if (container._drag_widget) {
- containers.splice(0, 0, container._drag_widget)
- if (container._drag_widget.root) break
- }
- container = container.parentNode
- }
- return containers
-}
-
-function closestDragContainer(target) {
- var container = target
- while (container !== null) {
- if (container._drag_widget) {
- return container
- } else {
- container = container.parentNode
- }
- }
- return null
-}
-
-// Callback trigger
-
-function triggerWidgetEvent(target, name, event, containersOnly) {
-
- // trigger drag events from parent to child
- var widgets = ancestorDragContainers(target),
- widget
-
- for (widget of widgets) {
- if (containersOnly && !widget.isContainer) continue
- widget.trigger(name, event)
- if (event.preventDefault) break
- }
-
- // if child is a container, let it scroll
- if (widget && widget.scroll) event.allowScroll = true
-}
-
-// init
-if (!iOS) {
- document.addEventListener('pointermove', mouseMoveCapture, true)
- if ('onwebkitmouseforcechanged' in document) document.addEventListener('webkitmouseforcechanged', mouseMoveCapture, true)
-}
-if (!iOS) document.addEventListener('pointerup', mouseUpCapture, true)
-
-document.addEventListener('touchmove', touchMoveCapture, true)
-
-if ('ontouchforcechange' in document) document.addEventListener('touchforcechange', touchMoveCapture, true)
-
-DOM.addEventListener(document, 'touchend touchcancel', touchUpCapture, true)
-
-if (!iOS) document.addEventListener('pointerdown', mouseDownCapture)
-
-export function setup(options) {
-
- if (
- this._customBindings['drag'] !== 0 ||
- this._customBindings['draginit'] !== 0 ||
- this._customBindings['dragend'] !== 0 ||
- !options || options.ignoreCustomBindings
- ) {
- return
- }
-
- var {element, multitouch} = options
-
- element.addEventListener('touchstart', touchDownCapture, false)
- element._drag_widget = this
- element._drag_multitouch = multitouch
-
-}
-
-export function teardown(options) {
-
- if (
- this._customBindings['drag'] !== 0 ||
- this._customBindings['draginit'] !== 0 ||
- this._customBindings['dragend'] !== 0 ||
- !options || options.ignoreCustomBindings
- ) {
- return
- }
-
- var {element} = options
-
- element.style.touchAction = ''
- element.removeEventListener('touchstart', touchDownCapture, false)
- delete element._drag_widget
- delete element._drag_multitouch
-
-}
-
-export function enableTraversingGestures(element, options={}) {
-
- if (element._traversing) return
-
- var traversing = options.type ? TRAVERSING_SAMEWIDGET : true,
- traversingType = options.type === 'smart' || options.type === 'auto' ? '' : options.type
-
- element._traversing = traversing
-
- function makeEventTraversing(event) {
- if (event.ctrlKey) return
- if (!event.traversingStack) event.traversingStack = {firstType: '', stack: []}
- event.traversingStack.stack.push({
- container: element.parentNode,
- mode: traversing,
- type: traversingType
- })
-
- }
-
- if (!iOS) element.addEventListener('pointerdown', makeEventTraversing, true)
- element.addEventListener('touchstart', makeEventTraversing, true)
-
- element.addEventListener('disableTraversingGestures', (e)=>{
- e.stopPropagation()
- if (!iOS) element.removeEventListener('pointerdown', makeEventTraversing, true)
- element.removeEventListener('touchstart', makeEventTraversing, true)
-
- })
-
-}
-
-export function disableTraversingGestures(element) {
-
- if (!element._traversing) return
-
- delete element._traversing
-
- DOM.dispatchEvent(element, 'disableTraversingGestures')
-
-}
diff --git a/src/client/events/event-emitter.mjs b/src/client/events/event-emitter.mjs
deleted file mode 100644
index 8e0f020d..00000000
--- a/src/client/events/event-emitter.mjs
+++ /dev/null
@@ -1,142 +0,0 @@
-import domEvent from './dom-event.mjs'
-import * as drag from './drag.mjs'
-import * as resize from './resize.mjs'
-
-var customEvents = {
- 'draginit': drag,
- 'drag': drag,
- 'dragend': drag,
- 'resize': resize,
- 'wheel': domEvent('wheel'),
- 'scroll': domEvent('scroll', {capture: true}),
- 'click': domEvent('click'),
- 'fast-click': domEvent('fast-click'),
- 'focus': domEvent('focus', {capture: true}),
- 'blur': domEvent('blur', {capture: true}),
- 'change': domEvent('change')
-}
-
-// micro optimisation from eventemitter3
-var has = Object.prototype.hasOwnProperty
-
-export default class EventEmitter {
-
- constructor() {
-
- this._customBindings = {}
- this._listeners = {}
-
- for (var evt in customEvents) {
- this._customBindings[evt] = 0
- }
-
- }
-
- trigger(evt, data) {
-
- if (has.call(this._listeners, evt)) {
- // shallow copy in case a listener gets added/removed while looping
- var listeners = this._listeners[evt].slice(0)
- for (var i = 0, len = listeners.length; i !== len; i++) {
- listeners[i](data)
- }
- }
-
- // Event bubbling
- // DOM events won't bubble
- // Virtual events will unless data.stopPropagation is set
- if (!data || !data.stopPropagation) {
- if (this.parent) this.parent.trigger(evt, data)
- }
-
- return this
-
- }
-
- on(evt, listener, options) {
-
- if (options) {
-
- // Custom event setup
- if (has.call(customEvents, evt)) {
- this._customBindings[evt]
- if (this._customBindings[evt] === 0) {
- listener._options = options
- customEvents[evt].setup.call(this, options)
- }
- this._customBindings[evt]++
- }
-
- // Context storing
- if (options.context) listener._context = options.context
-
- }
-
- // Add listener
- if (!has.call(this._listeners, evt)) this._listeners[evt] = []
-
- var listeners = this._listeners[evt]
-
- if (listeners.indexOf(listener) === -1) listeners.push(listener)
-
- return this
-
- }
-
- off(evt, listener, context) {
-
- // Remove listener
- if (evt && has.call(this._listeners, evt)) {
-
- var listeners = this._listeners[evt]
-
- if (listener) {
-
- var index = listeners.indexOf(listener)
-
- if (index !== -1) {
-
- if (context && context !== listener._context) return this
-
- listeners.splice(index, 1)
-
- // Custom event teardown
- if (has.call(customEvents, evt)) {
-
- if (this._customBindings[evt] !== 0) {
- this._customBindings[evt]--
- if (this._customBindings[evt] === 0) {
- customEvents[evt].teardown.call(this, listener._options)
- delete listener._options
- }
- }
-
- }
-
- }
-
- } else {
-
- for (var i = listeners.length - 1; i !== -1; i--) {
-
- if (!context || context == listeners[i]._context) {
- this.off(evt, listeners[i], context)
- }
-
- }
-
- }
-
- } else if (!evt) {
-
- for (var k in this._listeners) {
- this.off(k, undefined, context)
- }
-
- }
-
- return this
-
- }
-
-}
diff --git a/src/client/events/resize.mjs b/src/client/events/resize.mjs
deleted file mode 100644
index fab074f9..00000000
--- a/src/client/events/resize.mjs
+++ /dev/null
@@ -1,63 +0,0 @@
-import fastdom from 'fastdom'
-
-var elements = []
-
-export function check(context, force){
- fastdom.measure(()=>{
- // Iterate over all elements to which the 'resize' event is bound.
- let resizedElems = [],
- cachedStyles = []
- for (let i = elements.length - 1; i >= 0; i--) {
- var elem = elements[i]
-
- if (!context.contains(elem)) continue
-
- var style = window.getComputedStyle(elem),
- width = parseInt(style['width']) - parseInt(style['padding-left']) - parseInt(style['padding-right']),
- height = parseInt(style['height']) - parseInt(style['padding-top']) - parseInt(style['padding-bottom'])
-
- if (!width || !height) continue
-
- // If element size has changed since the last time, update the element
- // data store and trigger the 'resize' event.
- if (force || width != elem.resizedataw || height != elem.resizedatah) {
- elem.resizedataw = width
- elem.resizedatah = height
- resizedElems.push(elem)
- cachedStyles.push(style)
- }
- }
- for (let i = resizedElems.length - 1; i >= 0; i--) {
- resizedElems[i]._resize_widget.trigger('resize', {
- width: resizedElems[i].resizedataw,
- height: resizedElems[i].resizedatah,
- style:cachedStyles[i],
- stopPropagation: true
- })
- }
- })
-
-}
-
-window.addEventListener('resize', ()=>{check(document)})
-
-export function setup(options) {
-
- if (!options) return
- if (elements.indexOf(options.element) == -1) {
- elements.push(options.element)
- options.element._resize_widget = this
- }
-
-}
-
-export function teardown(options) {
-
- if (!options) return
-
- if (elements.indexOf(options.element) != -1) {
- elements.splice(elements.indexOf(options.element), 1)
- delete options.element._resize_widget
- }
-
-}
diff --git a/src/client/events/transform-coords.mjs b/src/client/events/transform-coords.mjs
deleted file mode 100644
index 7978dc3f..00000000
--- a/src/client/events/transform-coords.mjs
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-
- Adapted from https://gist.github.com/Yaffle/1145197#file-convertpointfrompagetonode-js
-
- Disabled for now
-
-
-*/
-
-
-
-/* global WebKitCSSMatrix */
-var I = new WebKitCSSMatrix()
-
-function Point(x, y, z) {
- this.x = x
- this.y = y
- this.z = z
-}
-
-Point.prototype.transformBy = function(matrix) {
- var tmp = matrix.multiply(I.translate(this.x, this.y, this.z))
- return new Point(tmp.m41, tmp.m42, tmp.m43)
-}
-
-function getTransformationMatrix(w) {
-
- var transformationMatrix = I,
- node = w
-
- while (node) {
- if (node._ignore_css_transforms) break
- if (node._drag_widget) {
-
- var transform = node._drag_widget.cssTransform || 'none',
- c = transform === 'none' ? I : new WebKitCSSMatrix(transform)
-
- transformationMatrix = c.multiply(transformationMatrix)
-
- }
- node = node.parentNode
-
- }
-
- transformationMatrix = I.multiply(transformationMatrix)
-
- return transformationMatrix
-
-}
-
-export default function cssTransformCoords(node, x, y) {
-
- return new Point(x, y, 0).transformBy(getTransformationMatrix(node).inverse())
-
-}
diff --git a/src/client/events/utils.mjs b/src/client/events/utils.mjs
deleted file mode 100644
index 850191a7..00000000
--- a/src/client/events/utils.mjs
+++ /dev/null
@@ -1,123 +0,0 @@
-import {DOM} from '../globals.mjs'
-
-var zoom
-setTimeout(async()=>{
- // use setTimeout to fix init order in safari...
- zoom = (await import('../ui/zoom.mjs')).default
-})
-
-// impot cssTransformCoords from './transform-coords.mjs'
-
-const Touch = window.Touch || class Touch {}
-
-
-export function fix(e) {
-
- var localZoom = zoom.editor && zoom.editor.enabled ? zoom.localZoom : 1
-
- return {
-
- target: e.target === document ? null : e.target, // firefox passes document when outside the page
- firstTarget: null,
- offsetX: e.offsetX,
- offsetY: e.offsetY,
- pageX: e.pageX,
- pageY: e.pageY,
- clientX: e.clientX,
- clientY: e.clientY,
- movementX: e.movementX === undefined ? undefined : e.movementX / localZoom,
- movementY: e.movementY === undefined ? undefined : e.movementY / localZoom,
- pointerId: e.pointerId,
- pointerType: e.pointerType,
- button: e.button,
- altKey: e.altKey,
- ctrlKey: e.ctrlKey,
- shiftKey: e.shiftKey,
- inertia: e.multitouch ? 1 : e.inertia,
- traversing: e.traversing,
- traversingStack: e.traversingStack,
- multitouch: e.multitouch,
- isTouch: e instanceof Touch,
- force: e.webkitForce || e.force || 0,
- radiusX: e.radiusX,
- radiusY: e.radiusY,
- rotationAngle: e.rotationAngle,
- // iOS only
- altitudeAngle: e.altitudeAngle,
- azimuthAngle: e.azimuthAngle,
- touchType: e.touchType
- }
-
-}
-
-export function normalizeDragEvent(event, previousEvent) {
-
- event = fix(event)
-
- event.firstTarget = previousEvent ? previousEvent.firstTarget : event.target
-
- if (event.movementX === undefined) {
-
- event.movementX = previousEvent ? event.pageX - previousEvent.pageX : 0
- event.movementY = previousEvent ? event.pageY - previousEvent.pageY : 0
-
- }
-
- if (event.isTouch && !previousEvent) {
-
- resetEventOffset(event, event.target)
-
- } else if (previousEvent) {
-
- event.offsetX = previousEvent.offsetX + event.movementX
- event.offsetY = previousEvent.offsetY + event.movementY
-
- }
-
- if (event.inertia === undefined) {
-
- event.inertia = 1
-
- }
-
- if (previousEvent) {
-
- if (previousEvent.traversing) event.traversing = previousEvent.traversing
- if (previousEvent.traversingStack) event.traversingStack = previousEvent.traversingStack
-
- if (previousEvent.multitouch) {
- event.multitouch = previousEvent.multitouch
- event.inertia = 1
- }
-
- }
-
-
- // if (!event.traversing) {
- // // css transform fix (doesn't work well with traversing gestures)
- // var transformedCoords = cssTransformCoords(event.firstTarget, event.movementX, event.movementY)
- // event.movementX = transformedCoords.x
- // event.movementY = transformedCoords.y
- // }
-
- return event
-
-}
-
-export function resetEventOffset(event, target) {
-
- var off = DOM.offset(target)
-
- event.offsetX = event.pageX - off.left
- event.offsetY = event.pageY - off.top
-
- // if (!event.traversing) {
- // // css transform fix (doesn't work well with traversing gestures)
- // var transformedCoords = cssTransformCoords(event.firstTarget, event.offsetX, event.offsetY)
- // event.offsetX = transformedCoords.x
- // event.offsetY = transformedCoords.y
- // }
-
-}
-
-export const TRAVERSING_SAMEWIDGET = 1
diff --git a/src/client/globals.mjs b/src/client/globals.mjs
deleted file mode 100644
index 6dabbaf3..00000000
--- a/src/client/globals.mjs
+++ /dev/null
@@ -1,61 +0,0 @@
-import json5 from 'json5'
-import pkg from '../../package.json'
-import * as dom from './dom.mjs'
-
-export var IP = window.IP || ''
-export var ENV = window.ENV || {}
-location.search.replace(/[?&]+([^=&j]+)=([^&]*)/gi, (s,k,v)=>{
- ENV[k]=v
-})
-for (var k in ENV) {
- ENV[k.toLowerCase()] = ENV[k]
-}
-
-export var LANG = ENV.lang === 'debug' ? 'debug' : (ENV.lang || navigator.language || '').substr(0, 2).toLowerCase()
-
-export var PACKAGE = pkg
-
-export var LOADING = null
-
-export var READ_ONLY = window.READ_ONLY || false
-export var KIOSK = window.KIOSK || false
-export var GRIDWIDTH_CSS = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--grid-width'))
-export function setGRIDWIDTH_CSS(x) {GRIDWIDTH_CSS = x}
-export var GRIDWIDTH = GRIDWIDTH_CSS
-export function setGRIDWIDTH(x) {GRIDWIDTH = x}
-
-
-
-
-
-
-export var ELECTRON_NOGPU = false
-export var CANVAS_FRAMERATE = parseFloat(ENV.framerate || 60)
-export var CANVAS_SCALING = parseFloat(ENV.forcehdpi) || ( ENV.hdpi ? window.devicePixelRatio : 1 )
-export var INITIALZOOM = ENV.zoom ? parseFloat(ENV.zoom) : 1
-export var PXSCALE = INITIALZOOM
-export function setPXSCALE(x) {PXSCALE = x}
-document.documentElement.style.setProperty('font-size', PXSCALE + 'px')
-
-export var DOUBLE_TAP_TIME = ENV.doubletap ? parseInt(ENV.doubletap) : 375
-
-export var CLIENT_SYNC = parseInt(ENV.clientSync) !== 0
-
-export var TOGGLE_ALT_TRAVERSING = !!ENV.altTraversing
-
-export var VIRTUAL_KEYBOARD = !!ENV.virtualKeyboard
-export function setVIRTUAL_KEYBOARD(x) {
- VIRTUAL_KEYBOARD = x
-}
-
-export var FOCUSABLE = !ENV.noFocus
-if (!FOCUSABLE) console.debug('ELECTRON.SETFOCUSABLE(0)')
-else console.debug('ELECTRON.SETFOCUSABLE(1)')
-export function setFOCUSABLE(x) {FOCUSABLE = x}
-
-
-export var JSON5 = json5
-
-export var DOM = dom
-
-export var TITLE = ENV.title || (PACKAGE.productName + ' v' + PACKAGE.version)
diff --git a/src/client/index.mjs b/src/client/index.mjs
deleted file mode 100644
index 630e8834..00000000
--- a/src/client/index.mjs
+++ /dev/null
@@ -1,25 +0,0 @@
-import {TITLE} from './globals.mjs'
-import './stacktrace.mjs'
-import './ui/init.mjs'
-
-import locales from './locales/index.mjs'
-import uiLoading from './ui/ui-loading.mjs'
-import ipc from './ipc/index.mjs'
-import * as backup from './backup.mjs'
-
-uiLoading(locales('loading_server'))
-
-ipc.init(()=>{
-
-
- document.title = TITLE
-
- ipc.send('open', {hotReload: backup.exists})
-
- window.onunload = ()=>{
- ipc.send('close')
- }
-
- backup.load()
-
-})
diff --git a/src/client/ipc/callbacks.mjs b/src/client/ipc/callbacks.mjs
deleted file mode 100644
index 990a7e61..00000000
--- a/src/client/ipc/callbacks.mjs
+++ /dev/null
@@ -1,171 +0,0 @@
-import raw from 'nanohtml/raw'
-import fastdom from 'fastdom'
-import osc from '../osc.mjs'
-import session from '../managers/session/index.mjs'
-import widgetManager from '../managers/widgets.mjs'
-import state from '../managers/state.mjs'
-import editor from '../editor/index.mjs'
-import locales from '../locales/index.mjs'
-import UiModal from '../ui/ui-modal.mjs'
-import uiLoading from '../ui/ui-loading.mjs'
-import notifications from '../ui/notifications'
-import * as backup from '../backup.mjs'
-import {updateMobileThemeColor, icon} from '../ui/utils.mjs'
-import {CLIENT_SYNC, DOM, ENV, TITLE, setGRIDWIDTH_CSS} from '../globals.mjs'
-
-export default {
-
- bundle: function(data) {
- for (let i in data) {
- osc.receive(data[i])
- }
- },
-
- receiveOsc: function(data){
- osc.receive(data)
- },
-
- connected:function(){
- uiLoading(false)
- },
-
- sessionOpen: function(data){
-
- session.open(data)
-
- },
-
- sessionNew: function(){
-
- session.create()
-
- },
-
- sessionSaved: function(data){
-
- editor.unsavedSession = false
-
- },
-
- fragmentLoad: function(data){
-
- session.setFragment(data)
-
- },
-
- stateLoad: function(data){
-
- state.load(data.state, data.send, data.path)
-
- },
-
- stateSend:function(){
-
- if (!CLIENT_SYNC) return
-
- notifications.add({
- icon: 'wifi',
- class: 'client-connected',
- message: locales('loading_newclient')
- })
-
- setTimeout(function(){
-
- osc.syncOnly = true
- state.send()
- osc.syncOnly = false
-
- },200)
-
- },
-
- editorDisable: function(data){
-
- editor.disable(data.permanent)
-
- },
-
- error: function(data){
- new UiModal({title: raw(icon('exclamation-triangle') + ' ' + locales('error')), content: raw(data), closable:true})
- },
-
- errorLog: function(data) {
-
- console.error(data)
-
- },
-
- reloadCss: function(){
- var queryString = '?__OSC_ASSET__=1&reload=' + Date.now()
- var sheets = DOM.get(document, 'link[rel="stylesheet"][hot-reload]')
- var loaded = 0
-
- for (let stylesheet of sheets) {
- stylesheet.href = stylesheet.href.replace(/\?.*|$/, queryString)
-
- // use image hack to catch stylesheet load event
- let img = document.createElement('img')
- document.body.appendChild(img)
-
- img.onerror = img.onload = ()=>{
- img.onerror = img.onload = null
- document.body.removeChild(img)
-
- if (++loaded === sheets.length) {
- var root = widgetManager.getWidgetById('root')[0]
- if (root) root.onPropChanged('colorWidget')
- fastdom.measure(()=>{
- setGRIDWIDTH_CSS(parseInt(getComputedStyle(document.documentElement).getPropertyValue('--grid-width')))
- fastdom.mutate(()=>{
- editor.toggleGrid()
- editor.toggleGrid()
- })
- })
- updateMobileThemeColor(root)
- }
- }
-
- img.src = stylesheet.href
-
-
- }
-
- },
-
- reload: function(){
-
- backup.save()
- editor.unsavedSession = false
- window.location.href = window.location.href
-
- },
-
- notify: function(data) {
-
- var message = data.message || ''
-
- if (data.locale) message = locales(data.locale) + message
-
- notifications.add({
- icon: data.icon,
- class: data.class,
- message: message
- })
-
- },
-
- setTitle: function(data) {
-
- if (ENV.title) return
-
- document.title = TITLE + (data ? ' (' + data + ')' : '')
-
- },
-
- serverTargets: function(data) {
-
- if (data) osc.serverTargets = data
-
- }
-
-}
diff --git a/src/client/ipc/index.mjs b/src/client/ipc/index.mjs
deleted file mode 100644
index 9a3d4275..00000000
--- a/src/client/ipc/index.mjs
+++ /dev/null
@@ -1,206 +0,0 @@
-import {nanoid} from 'nanoid'
-import EventEmitter from '../events/event-emitter.mjs'
-import cache from '../managers/cache.mjs'
-import {ENV} from '../globals.mjs'
-
-var notifications, locales, callbacks
-
-var loadDeps = (async()=>{
- notifications = (await import('../ui/notifications.mjs')).default
- locales = (await import('../locales/index.mjs')).default
- callbacks = (await import('./callbacks.mjs')).default
-
- // wait for other js chunks too since we'll connect to the server once this provise resolves
- await import('../editor/context-menu.mjs')
- await import('../remote-control.mjs')
- await import('../ui/ui-keyboard.mjs')
-})()
-
-var uuid, localUuid = ENV.id || cache.get('uuid', false)
-if (localUuid) {
- uuid = localUuid
-} else {
- uuid = nanoid(10)
- cache.set('uuid', uuid, false)
-}
-
-var reconnectTimeout = 500,
- hearbeatInterval = 5000,
- hearbeatTimeout = 3000,
- protocol = document.location.protocol === 'https:' ? 'wss://' : 'ws://'
-
-class Ipc extends EventEmitter {
-
- constructor() {
-
- super()
-
- this.socket = null
-
- this.queue = []
-
- this.disconnected = false
-
- this.reconnectTimeout = undefined
- this.disconnectTimeout = undefined
-
- this.hearbeat = undefined
- this.hearbeatTimeout = undefined
- this.on('pong', ()=>{
- clearTimeout(this.hearbeatTimeout)
- })
- this.on('ping', ()=>{
- this.socket.send('["pong"]')
- })
-
- document.cookie = 'client_id=' + uuid + ';samesite=strict'
-
-
- }
-
- init(callback) {
-
- loadDeps.then(()=>{
-
- for (let i in callbacks) {
- let callback = callbacks[i]
- this.on(i, (data)=>{
- callback(data)
- })
- }
-
- try {
- this.open()
- } catch(e) {
- console.warn('Could not open a WebSocket connection')
- console.log(e)
- }
-
- callback()
-
- })
-
- }
-
- open() {
-
- this.socket = new WebSocket(protocol + window.location.host + '/' + uuid + '/' + window.AUTH)
-
- this.socket.onclose = this.socket.onerror = ()=>{
- if (!this.connected()) this.close()
- }
-
- this.socket.onopen = (e)=>{
-
- this.hearbeat = setInterval(()=>{
- if (!this.connected()) return
- this.socket.send('["ping"]')
- this.hearbeatTimeout = setTimeout(()=>{
- if (this.connected()) this.close()
- }, hearbeatTimeout)
- }, hearbeatInterval)
-
- if (notifications && this.disconnected) notifications.add({
- icon: 'wifi',
- class: 'server-connected',
- message: locales('server_connected'),
- id: 'ipc_state'
- })
-
- this.disconnected = false
-
- this.trigger('connect')
- this.flush()
-
- this.socket.onmessage = (e)=>{
- this.receive(e.data)
- }
-
- }
-
- }
-
- close() {
-
- this.socket.onclose = this.socket.onerror = null
-
- this.socket.close()
-
- this.socket = null
-
- clearInterval(this.hearbeat)
- clearTimeout(this.hearbeatTimeout)
-
- clearTimeout(this.disconnectTimeout)
- this.disconnectTimeout = setTimeout(()=>{
- // delay notification in case reconnection succeeds quickly
- if (notifications && !this.connected()) notifications.add({
- icon: 'wifi',
- class: 'error',
- message: locales('server_disconnected'),
- id: 'ipc_state',
- duration: Infinity
- })
- this.disconnected = true
-
- }, reconnectTimeout * 2)
-
-
- clearTimeout(this.reconnectTimeout)
- this.reconnectTimeout = setTimeout(()=>{
- this.open()
- }, reconnectTimeout)
-
- }
-
- connected() {
-
- return this.socket && this.socket.readyState == this.socket.OPEN
-
- }
-
- receive(message) {
-
- if (typeof message == 'string') {
-
- var packet = JSON.parse(message)
-
- if (Array.isArray(packet) && typeof packet[0] == 'string') {
-
- this.trigger(packet[0], packet[1])
-
- }
-
- }
-
- }
-
- send(event, data) {
-
- var packet = JSON.stringify([event, data])
-
- if (this.connected()) {
- this.socket.send(packet)
- } else {
- this.queue.push(packet)
- }
-
- }
-
- flush(){
-
- for (var i in this.queue) {
-
- if (this.connected()) this.socket.send(this.queue[i])
-
- }
-
- this.queue = []
-
- }
-
-}
-
-var ipc = new Ipc()
-
-export default ipc
diff --git a/src/client/locales/de.mjs b/src/client/locales/de.mjs
deleted file mode 100644
index ecf7a2c0..00000000
--- a/src/client/locales/de.mjs
+++ /dev/null
@@ -1,141 +0,0 @@
-export default {
-
- // console
- console: 'Konsole',
- console_enabled: 'Aktiv',
- console_clear: 'Konsole leeren',
-
-
- // editor
- editor: 'Editor',
- editor_enabled: 'Aktiv',
- editor_grid: 'Raster',
- editor_tree: 'Projektbaum',
- editor_inspector: 'Inspektor',
- editor_percents: 'Relative Einheiten (%)',
-
- // editor context-menu
- editor_show_in_tree: 'Zeige in Baum',
- editor_show_in_session: 'Zeige in Sitzung',
- editor_front: 'In den Vordergrund',
- editor_closer: 'Eine Ebene nach vorne',
- editor_back: 'In den Hintergrund',
- editor_farther: 'Eine Ebene nach hinten',
- editor_copy: 'Kopieren',
- editor_cut: 'Ausschneiden',
- editor_paste: 'Einfügen',
- editor_pasteindent: 'ID + 1',
- editor_clone: 'Duplizieren',
- editor_addwidget: 'Widget hinzufügen',
- editor_addtab: 'Tab hinzufügen',
- editor_delete: 'Löschen',
-
- editor_fragment: 'Fragment',
- editor_fragment_export: 'Export',
- editor_fragment_import: 'Import',
-
- editor_ace_help: 'Hilfe',
- editor_ace_help_title: 'Tastenkombinationen für den Code-Editor',
-
- // loadings
- loading_upload: 'Datei wird hochgeladen…',
- loading_newclient: 'Neuer Client verbindet sich…',
- loading_server: 'Server verbinden…',
- loading_session: 'Sitzung laden…',
-
- // file
- file_open: 'Öffnen',
- file_open_recent: 'Kürzlich geöffnet',
- file_open_recent_wait: 'Liste noch nicht geladen, bitte schließen Sie das Menü und öffnen Sie es erneut',
- file_save: 'Speichern',
- file_save_as: 'Speichern unter…',
- file_backup: 'Backup speichern',
- file_import: 'Importieren',
- file_export: 'Exportieren',
-
- // keyboard
- keyboard: 'Virtuelle Tastatur',
- keyboard_layout: {
- default: [
- '{esc} ` 1 2 3 4 5 6 7 8 9 0 - = {zrck}',
- '{tab} q w e r t z u i o p [ ] \\',
- '{lock} a s d f g h j k l ; \' {enter}',
- '{shift} z x c v b n m , . / {shift}',
- '{leer}'
- ],
- shift: [
- '{esc} ~ ! @ # $ % ^ & * ( ) _ + {zrck}',
- '{tab} Q W E R T Y U I O P { } |',
- '{lock} A S D F G H J K L : " {enter}',
- '{shift} Z X C V B N M < > ? {shift}',
- '{leer}'
- ]
- },
- keyboard_escape: 'Esc',
-
- // fragment mode
- fragment_mode: 'Fragment Modus',
- fragment_mode_warning: 'Fragment Modus aktiviert',
- fragment_mode_explanation: 'Die Sitzung wird als Fragment gespeichert: nur das erste untergeordnete Element von root wird gespeichert.',
-
- // fullscreen
- fullscreen: 'Vollbild',
- fullscreen_unnavailable: 'Vollbild nicht verfügbar',
- fullscreen_addtohome: 'Sie müssen diese Seite zu Ihrem Startbildschirm hinzufügen, um sie im Vollbildmodus zu starten',
-
- // inspector
- inspector_error: 'Es ist ein Fehler aufgetreten. Öffne die Konsole, um mehr zu lesen.',
- inspector_zoom_in: 'Vergrößern',
- inspector_zoom_reset: 'Zoom zurücksetzen',
- inspector_zoom_ou: 'Verkleinern',
- inspector_reset_selection: 'Widget(s) abwählen',
- inspector_toggle_grid: 'Raster ein-/ausblenden',
-
- // nosleep
- nosleep: 'Prevent sleep',
-
- // notifications
- notifications: 'Benachrichtigungen',
-
- // remote save
- remotesave_open: 'Öffnen (auf dem Server)',
- remotesave_save: 'Speichern (auf dem Server)',
- remotesave_overwrite: 'Diese Datei existiert bereits, möchtest du sie überschreiben?',
- remotesave_fail: 'Die Datei konnte nicht auf dem Server gespeichert werden, verwende stattdessen "export".',
- remotesave_success: 'Datei erfolgreich gespeichert',
- remotesave_forbidden: 'Speichern auf dem Server nicht möglich, verwende stattdessen "exportieren".',
-
- // server
- server_disconnected: 'Die Verbindung zum Server ist unterbrochen worden',
- server_connected: 'Die Verbindung zum Server wurde wiederhergestellt',
-
- // session
- session: 'Sitzung',
- session_new: 'Neue Sitzung',
- session_malformed: 'Fehlerhafte Sitzungsdatei.',
- session_parsingerror: 'Fehler beim Parsing.',
- session_uploaderror: 'Hochladen der Sitzungsdatei fehlgeschlagen.',
- session_unsaved: 'Die Änderungen gehen verloren, wenn du diese Sitzung schließt, ohne zu speichern. Fortfahren?',
- session_oldversion_title: 'Warnung',
- session_oldversion: 'Diese Sitzung wurde mit einer älteren Version dieser Software erstellt - eine automatische Konvertierung wurde durchgeführt. Nach dem Speichern wird diese Sitzung wahrscheinlich nicht korrekt mit älteren Versionen geladen, es wird empfohlen, eine Sicherungskopie davon zu erstellen.',
-
- // state
- state: 'Status',
- state_store: 'Laden',
- state_recall: 'Abrufen',
- state_send: 'Alle senden',
- state_import: 'Import',
- state_export: 'Export',
- state_uploaderror: 'Hochladen der Statusdatei fehlgeschlagen.',
- state_storesuccess: 'Status gespeichert',
- state_recallsuccess: 'Status abgerufen',
- state_sendsuccess: 'Status gesendet',
-
- // tree
- tree_filter: 'Filter',
-
- // misc
- error: 'Error'
-
-
-}
diff --git a/src/client/locales/en.mjs b/src/client/locales/en.mjs
deleted file mode 100644
index 99b6531f..00000000
--- a/src/client/locales/en.mjs
+++ /dev/null
@@ -1,141 +0,0 @@
-export default {
-
- // console
- console: 'Console',
- console_enabled: 'Enabled',
- console_clear: 'Clear console',
-
-
- // editor
- editor: 'Editor',
- editor_enabled: 'Enabled',
- editor_grid: 'Grid',
- editor_tree: 'Project tree',
- editor_inspector: 'Inspector',
- editor_percents: 'Relative units (%)',
-
- // editor context-menu
- editor_show_in_tree: 'Show in tree',
- editor_show_in_session: 'Show in session',
- editor_front: 'Bring to front',
- editor_closer: 'Bring closer',
- editor_back: 'Send to back',
- editor_farther: 'Send farther',
- editor_copy: 'Copy',
- editor_cut: 'Cut',
- editor_paste: 'Paste',
- editor_pasteindent: 'ID + 1',
- editor_clone: 'Clone',
- editor_addwidget: 'Add widget',
- editor_addtab: 'Add tab',
- editor_delete: 'Delete',
-
- editor_fragment: 'Fragment',
- editor_fragment_export: 'Export',
- editor_fragment_import: 'Import',
-
- editor_ace_help: 'Help',
- editor_ace_help_title: 'Code editor keyboard shortcuts',
-
- // loadings
- loading_upload: 'Uploading file…',
- loading_newclient: 'New client connecting…',
- loading_server: 'Connecting server…',
- loading_session: 'Loading session…',
-
- // file
- file_open: 'Open',
- file_open_recent: 'Open recent',
- file_open_recent_wait: 'List not loaded yet, please close and reopen the menu',
- file_save: 'Save',
- file_save_as: 'Save as…',
- file_backup: 'Save backup',
- file_import: 'Import',
- file_export: 'Export',
-
- // keyboard
- keyboard: 'Virtual keyboard',
- keyboard_layout: {
- default: [
- '{esc} ` 1 2 3 4 5 6 7 8 9 0 - = {bksp}',
- '{tab} q w e r t y u i o p [ ] \\',
- '{lock} a s d f g h j k l ; \' {enter}',
- '{shift} z x c v b n m , . / {shift}',
- '{space}'
- ],
- shift: [
- '{esc} ~ ! @ # $ % ^ & * ( ) _ + {bksp}',
- '{tab} Q W E R T Y U I O P { } |',
- '{lock} A S D F G H J K L : " {enter}',
- '{shift} Z X C V B N M < > ? {shift}',
- '{space}'
- ]
- },
- keyboard_escape: 'Esc',
-
- // fragment mode
- fragment_mode: 'Fragment mode',
- fragment_mode_warning: 'Fragment mode enabled',
- fragment_mode_explanation: 'The session will be saved as a fragment: only the first child of root will be saved.',
-
- // fullscreen
- fullscreen: 'Fullscreen',
- fullscreen_unnavailable: 'Fullscreen not available',
- fullscreen_addtohome: 'You must add this page to your home screen to launch it in fullscreen',
-
- // inspector
- inspector_error: 'An error just occurred, open the console to read more.',
- inspector_zoom_in: 'Zoom in',
- inspector_zoom_reset: 'Reset zoom',
- inspector_zoom_ou: 'Zoom out',
- inspector_reset_selection: 'Unselect widget(s)',
- inspector_toggle_grid: 'Show/hide the grid',
-
- // nosleep
- nosleep: 'Prevent sleep',
-
- // notifications
- notifications: 'Notifications',
-
- // remote save
- remotesave_open: 'Open (on the server)',
- remotesave_save: 'Save (on the server)',
- remotesave_overwrite: 'This file already exists, do you want to overwrite it?',
- remotesave_fail: 'The file could not be saved on the server, use "export" instead',
- remotesave_success: 'File saved successfully',
- remotesave_forbidden: 'You\'re note allowed to save on server, use "export" instead',
-
- // server
- server_disconnected: 'The connection to the server has been interrupted',
- server_connected: 'The connection to the server has been restored',
-
- // session
- session: 'Session',
- session_new: 'New session',
- session_malformed: 'Malformed session file.',
- 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 of this software, an automatic conversion has been done. Once saved, this session will probably not load correctly with older versions, it is recommended to make a backup copy of it.',
-
- // state
- state: 'State',
- state_store: 'Store',
- state_recall: 'Recall',
- state_send: 'Send All',
- state_import: 'Import',
- state_export: 'Export',
- state_uploaderror: 'Failed to upload state file.',
- state_storesuccess: 'State saved',
- state_recallsuccess: 'State recalled',
- state_sendsuccess: 'State sent',
-
- // tree
- tree_filter: 'Filter',
-
- // misc
- error: 'Error'
-
-
-}
diff --git a/src/client/locales/fr.mjs b/src/client/locales/fr.mjs
deleted file mode 100644
index 05f6c9b3..00000000
--- a/src/client/locales/fr.mjs
+++ /dev/null
@@ -1,141 +0,0 @@
-export default {
-
- // console
- console: 'Console',
- console_enabled: 'Activée',
- console_clear: 'Vider la console',
-
- // editor
- editor: 'Editeur',
- editor_enabled: 'Activé',
- editor_grid: 'Grille',
- editor_tree: 'Arborescence',
- editor_inspector: 'Inspecteur',
- editor_percents: 'Unités relatives (%)',
-
- // editor context-menu
- editor_show_in_tree: 'Voir dans l\'arborescence',
- editor_show_in_session: 'Voir dans la session',
- editor_front: 'Amener devant',
- editor_closer: 'Amener plus près',
- editor_back: 'Envoyer à l\'arrière',
- editor_farther: 'Envoyer plus loin',
- editor_copy: 'Copier',
- editor_cut: 'Couper',
- editor_paste: 'Coller',
- editor_pasteindent: 'ID + 1',
- editor_clone: 'Clone',
- editor_addwidget: 'Ajouter widget',
- editor_addtab: 'Ajouter onglet',
- editor_delete: 'Supprimer',
-
- editor_fragment: 'Fragment',
- editor_fragment_export: 'Exporter',
- editor_fragment_import: 'Importer',
-
- editor_ace_help: 'Aide',
- editor_ace_help_title: 'Raccourcis claviers de l\'éditeur',
-
- // loadings
- loading_upload: 'Téléversement…',
- loading_newclient: 'Connexion d\'un nouveau client…',
- loading_server: 'Connexion au serveur…',
- loading_session: 'Chargement de la session…',
-
- // file
- file_open: 'Ouvrir',
- file_open_recent: 'Récemment ouvert(s)',
- file_open_recent_wait: 'Liste non chargée, veuillez fermer puis ouvrir le menu à nouveau',
- file_save: 'Enregistrer',
- file_save_as: 'Enregistrer sous…',
- file_backup: 'Enregistrer une sauvegarde',
- file_import: 'Importer',
- file_export: 'Exporter',
-
- // keyboard
- keyboard: 'Clavier virtuel',
- keyboard_layout: {
- default: [
- '{esc} \u00B2 & \u00E9 \" \' ( - \u00E8 _ \u00E7 \u00E0 ) = {bksp}',
- '{tab} a z e r t y u i o p ^ $',
- '{lock} q s d f g h j k l m \u00F9 * {enter}',
- '{shift} < w x c v b n , ; : ! {shift}',
- '{space}',
- ],
- shift: [
- '{esc} ` 1 2 3 4 5 6 7 8 9 0 \u00B0 + {bksp}',
- '{tab} A Z E R T Y U I O P \u00A8 \u00A3',
- '{lock} Q S D F G H J K L M % \u00B5 {enter}',
- '{shift} > W X C V B N ? . / \u00A7 {shift}',
- '{space}'
- ]
- },
- keyboard_escape: 'Échap',
-
- // fullscreen
- fullscreen: 'Plein écran',
- fs_unnavailable: 'Plein écran indisponible',
- fs_addtohome: 'Vous devez ajouter cette page à votre écran d\'accueil pour pouvoir l\'ouvrir en plein écran.',
-
- // fragment mode
- fragment_mode: 'Mode fragment',
- fragment_mode_warning: 'Mode fragment activé',
- fragment_mode_explanation: 'La session sera enregistrée sous forme de fragment : seul le premier descendant de l\'élément root sera sauvegardé.',
-
- // inspector
- inspector_error: 'Une erreur vient de survenir, ouvrez la console pour en savoir plus.',
- inspector_zoom_in: 'Zoom avant',
- inspector_zoom_reset: 'Zoom initial',
- inspector_zoom_out: 'Zoom arrière',
- inspector_reset_selection: 'Déséléctionner',
- inspector_toggle_grid: 'Afficher / masquer la grille',
-
-
- // nosleep
- nosleep: 'Empêcher la veille',
-
- // notifications
- notifications: 'Notifications',
-
- // remote save
- remotesave_open: 'Ouvrir (sur le serveur)',
- remotesave_save: 'Enregistrer (sur le serveur)',
- remotesave_overwrite: 'Un fichier du même nom existe déjà, voulez le remplacer ?',
- remotesave_fail: 'Le fichier n\'a pas pu être enregistré sur le serveur, utilisez la fonction "exporter"',
- remotesave_success: 'Le fichier a été enregistré avec succès',
- remotesave_forbidden: 'Vous n\'êtes pas autorisé à sauvegarder sur le serveur, utilisez la fonction "exporter"',
-
- // server
- server_disconnected: 'La connexion avec le serveur a été interrompue',
- server_connected: 'La connexion avec le serveur a été rétablie',
-
- // session
- session: 'Session',
- session_new: 'Nouvelle session',
- session_malformed: 'Fichier de session mal formé.',
- 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 de ce logiciel, une conversion automatique a été appliquée. Une fois sauvegardée, cette session risque de ne plus charger correctement avec les anciennes versions, il est recommandé d\'en faire une copie de sauvegarde.',
-
- // state
- state: 'État',
- state_store: 'Sauver',
- state_recall: 'Rappeler',
- state_send: 'Envoyer',
- state_import: 'Importer',
- state_export: 'Exporter',
- state_uploaderror: 'Échec à l\'envoi du fichier d\'état.',
- state_storesuccess: 'État de l\'interface sauvegardé',
- state_recallsuccess: 'État de l\'interface restauré',
- state_sendsuccess: 'État de de l\'interface envoyé',
-
- // tree
- tree_filter: 'Filtrer',
-
- // misc
- error: 'Erreur'
-
-
-}
diff --git a/src/client/locales/index.mjs b/src/client/locales/index.mjs
deleted file mode 100644
index 3f8920f7..00000000
--- a/src/client/locales/index.mjs
+++ /dev/null
@@ -1,17 +0,0 @@
-import en from './en.mjs'
-import fr from './fr.mjs'
-import de from './de.mjs'
-import pl from './pl.mjs'
-import {LANG} from '../globals.mjs'
-
-var locales = {
- en, fr, de, pl,
- debug: {
- /* empty */
- keyboard_layout: en.keyboard_layout
- }
-}
-
-var lang = locales[LANG] ? LANG : 'en'
-
-export default key=>locales[lang][key] || `!${key}!`
diff --git a/src/client/locales/pl.mjs b/src/client/locales/pl.mjs
deleted file mode 100644
index 059f7cc7..00000000
--- a/src/client/locales/pl.mjs
+++ /dev/null
@@ -1,141 +0,0 @@
-export default {
-
- // console
- console: 'Terminal',
- console_enabled: 'Włączony',
- console_clear: 'Wyczyść terminal',
-
-
- // editor
- editor: 'Edytor',
- editor_enabled: 'Włączony',
- editor_grid: 'Siatka',
- editor_tree: 'Drzewo projekty',
- editor_inspector: 'Inspektor',
- editor_percents: 'Jednostki względne (%)',
-
- // editor context-menu
- editor_show_in_tree: 'Pokaż w drzewie',
- editor_show_in_session: 'Pokaż w sesji',
- editor_front: 'Przenieś na pierwszy plan',
- editor_closer: 'Przenieś wyżej',
- editor_back: 'Przenieś na ostatni plan',
- editor_farther: 'Przenieś niżej',
- editor_copy: 'Kopiuj',
- editor_cut: 'Wytnij',
- editor_paste: 'Wklej',
- editor_pasteindent: 'Wklej i zwiększ ID o 1',
- editor_clone: 'Sklonuj',
- editor_addwidget: 'Dodaj widget',
- editor_addtab: 'Dodaj kartę',
- editor_delete: 'Usuń',
-
- editor_fragment: 'Fragment',
- editor_fragment_export: 'Eksportuj',
- editor_fragment_import: 'Importuj',
-
- editor_ace_help: 'Pomoc',
- editor_ace_help_title: 'Skróty klawiszowe edytora kodu',
-
- // loadings
- loading_upload: 'Wysyłanie pliku…',
- loading_newclient: 'Nowy klient podłączony…',
- loading_server: 'Podłączanie do serwera…',
- loading_session: 'Wczytywanie sesji…',
-
- // file
- file_open: 'Otwórz',
- file_open_recent: 'Ostatnio otwierane',
- file_open_recent_wait: 'Lista nie jest jeszcze załadowana, zamknij i otwórz ponownie to menu',
- file_save: 'Zapisz',
- file_save_as: 'Zapisz jako…',
- file_backup: 'Zapisz kopię zapasową',
- file_import: 'Importuj',
- file_export: 'Eksportuj',
-
- // keyboard
- keyboard: 'Klawiatura wirtualna',
- keyboard_layout: {
- default: [
- '{esc} ` 1 2 3 4 5 6 7 8 9 0 - = {bksp}',
- '{tab} q w e r t y u i o p [ ] \\',
- '{lock} a s d f g h j k l ; \' {enter}',
- '{shift} z x c v b n m , . / {shift}',
- '{space}'
- ],
- shift: [
- '{esc} ~ ! @ # $ % ^ & * ( ) _ + {bksp}',
- '{tab} Q W E R T Y U I O P { } |',
- '{lock} A S D F G H J K L : " {enter}',
- '{shift} Z X C V B N M < > ? {shift}',
- '{space}'
- ]
- },
- keyboard_escape: 'Esc',
-
- // fragment mode
- fragment_mode: 'Tryb fragmentów',
- fragment_mode_warning: 'Tryb fragmentów włączony',
- fragment_mode_explanation: 'Ta sesja zostanie zapisana jako fragment: tylko pierwsze dziecko roota zostanie zapisane.',
-
- // fullscreen
- fullscreen: 'Tryb pełnoekranowy',
- fullscreen_unnavailable: 'Tryb pełnoekranowy niedostęĻny',
- fullscreen_addtohome: 'Musisz dodać tę stronę do Twojego ekranu domowego by otworzyć ja w trybie pełnoekranowym',
-
- // inspector
- inspector_error: 'Wystąpił błąd, otwórz terminal by dowiedzieć się więcej.',
- inspector_zoom_in: 'Przybliż',
- inspector_zoom_reset: 'Domyślny stopień przybliżenia',
- inspector_zoom_ou: 'Oddal',
- inspector_reset_selection: 'Odznacz widget(y)',
- inspector_toggle_grid: 'Pokaż/ukryj siatkę',
-
- // nosleep
- nosleep: 'Nie pozwalaj na uśpienie ekranu',
-
- // notifications
- notifications: 'Powiadomienia',
-
- // remote save
- remotesave_open: 'Otwórz (na serwerze)',
- remotesave_save: 'Sapisz (na serwerze)',
- remotesave_overwrite: 'Ten plik już istnieje, czy chcesz go nadpisać?',
- remotesave_fail: 'Ten plik nie mógł zostać zapisany na serwerze, użyj eksportu',
- remotesave_success: 'Plik zapisany pomyślnie',
- remotesave_forbidden: 'Nie masz uprawnień do zapisania pliku na serwerze, użyj eksportu',
-
- // server
- server_disconnected: 'Połączenie z serwerem zostało przerwane',
- server_connected: 'Połączenie z serwerem zostało nawiązane',
-
- // session
- session: 'Sesja',
- session_new: 'Nowa sesja',
- session_malformed: 'Niewłaściwy plik sesji.',
- session_parsingerror: 'Błąd parsowania pliku sesji.',
- session_uploaderror: 'Nie udało się przesłać pliku sesji.',
- session_unsaved: 'Jeśli zamkniesz tę sesję bez uprzedniego zapisu, wprowadzone zmiany zostaną utracone. Czy chcesz kontynuować?',
- session_oldversion_title: 'Ostrzeżenie',
- session_oldversion: 'Ta sesja została stworzona przy użyciu starszej wersji tego oprogramowania - dokonano automatycznej konwersji. Po zapisaniu, sesja ta prawdopodobnie nie będzie ładować się poprawnie ze starszymi wersjami, zaleca się wykonanie kopii bezpieczeństwa.',
-
- // state
- state: 'Stan',
- state_store: 'Zachowaj',
- state_recall: 'Przywołaj',
- state_send: 'Wyślij wszystkie',
- state_import: 'Importuj',
- state_export: 'Eksportuj',
- state_uploaderror: 'Nie udało się przesłać pliku stanu.',
- state_storesuccess: 'Zapisano stan',
- state_recallsuccess: 'Przywołano stan',
- state_sendsuccess: 'Wysłano stan',
-
- // tree
- tree_filter: 'Filtruj',
-
- // misc
- error: 'Błąd'
-
-
-}
diff --git a/src/client/managers/cache.mjs b/src/client/managers/cache.mjs
deleted file mode 100644
index 1d1cee77..00000000
--- a/src/client/managers/cache.mjs
+++ /dev/null
@@ -1,71 +0,0 @@
-var keyPrefix = 'osc.'
-
-class Cache {
-
- set(key, value, persistent = true) {
-
- try {
-
- var storage = persistent ? localStorage : sessionStorage
-
- storage.setItem(keyPrefix + key, JSON.stringify(value))
-
- } catch(e){
- console.error(`Could not write to ${persistent ? 'localStorage' : 'sessionStorage'}: ${e}`)
- console.debug(e)
- }
-
-
- }
-
- get(key, persistent = true) {
-
- try {
-
- var storage = persistent ? localStorage : sessionStorage
-
- return JSON.parse(storage.getItem(keyPrefix + key))
-
- } catch(e){
- console.error(`Could not read from ${persistent ? 'localStorage' : 'sessionStorage'}: ${e}`)
- console.debug(e)
- return null
- }
-
- }
-
- remove(key, persistent = true) {
-
- var storage = persistent ? localStorage : sessionStorage
-
- storage.removeItem(keyPrefix + key)
-
- }
-
- clear(domain) {
-
- if (domain) {
-
- for (let storage of [localStorage, sessionStorage]) {
-
- for (let k in storage) {
- if (k.indexOf(keyPrefix + domain) === 0) {
- storage.removeItem(k)
- }
- }
-
- }
-
-
- } else {
-
- localStorage.clear()
- sessionStorage.clear()
-
- }
-
- }
-
-}
-
-export default new Cache()
diff --git a/src/client/managers/session/index.mjs b/src/client/managers/session/index.mjs
deleted file mode 100644
index 80fc4d16..00000000
--- a/src/client/managers/session/index.mjs
+++ /dev/null
@@ -1,298 +0,0 @@
-import {saveAs} from 'file-saver'
-import ipc from '../../ipc/index.mjs'
-import parser from '../../parser.mjs'
-import editor from '../../editor/index.mjs'
-import uiFilebrowser from '../../ui/ui-filebrowser.mjs'
-import uiFileupload from '../../ui/ui-fileupload.mjs'
-import UiModal from '../../ui/ui-modal.mjs'
-import uiLoading from '../../ui/ui-loading.mjs'
-import uiConsole from '../../ui/ui-console'
-import widgetManager from '../widgets.mjs'
-import locales from '../../locales/index.mjs'
-import Session from './session.mjs'
-import EventEmitter from '../../events/event-emitter.mjs'
-import {deepEqual} from '../../utils.mjs'
-import {DOM, READ_ONLY, PACKAGE, CLIENT_SYNC} from '../../globals.mjs'
-
-var SessionManager = class SessionManager extends EventEmitter {
-
- constructor() {
-
- super()
-
- this.session = null
- this.saveMode = 'session'
- this.fragments = {}
- this.lock = false
- this.lastDir = null
- this.setSessionPath('')
-
- ipc.on('connect', ()=>{
- ipc.send('sessionSetPath', {path: this.sessionPath})
- })
-
- }
-
- load(session, callback) {
-
- if (this.lock) return
-
- this.lock = true
-
- var container = DOM.get('#osc-container')[0]
-
- uiLoading(locales('loading_session'))
-
- setTimeout(()=>{
- try {
-
- uiConsole.clear()
- this.session = new Session(session, 'session')
- container.innerHTML = ''
- parser.reset()
- parser.parse({
- data: this.session.getRoot(),
- parentNode: DOM.get('#osc-container')[0],
- parent: widgetManager
- })
- editor.clearHistory()
- editor.widgetTree.filter.value = ''
- DOM.get(document, '#osc-greeting-header')[0].classList.add('hidden')
- this.setSaveMode(this.session.isFragment ? 'fragment' : 'session')
-
- } catch (err) {
- uiLoading(false)
- new UiModal({title: locales('session_parsingerror'), content: err.message, icon: 'exclamation-triangle', closable:true})
- this.lock = false
- ipc.send('sessionSetPath', {path: this.sessionPath})
- throw err
- }
-
- for (var h in widgetManager.widgets) {
- if (widgetManager.widgets[h].value !== undefined) {
- widgetManager.trigger('value-changed', {
- widget: widgetManager.widgets[h],
- id: widgetManager.widgets[h].getProp('id'),
- linkId: widgetManager.widgets[h].getProp('linkId'),
- options: {}
- })
- }
- }
-
- if (editor.enabled) {
- editor.disable()
- editor.enable()
- }
-
- DOM.dispatchEvent(window, 'resize')
-
- setTimeout(()=>{
- uiLoading(false)
- this.lock = false
- editor.unsavedSession = false
- this.setSessionPath('')
- if (callback) callback()
- }, 25)
-
- }, 25)
-
- }
-
- save(path, backup=false) {
-
- if (!this.session || READ_ONLY) return
-
- if (path) this.setSessionPath(path)
-
- if (editor.inspector.focusedInput) {
- editor.inspector.onChange()
- }
-
- if (!this.sessionPath) return this.saveAs()
-
- if (this.saveMode === 'session') {
-
- ipc.send('sessionSave', {
- session: this.session.toJSON(),
- path: this.sessionPath,
- backup: backup
- })
-
- } else {
-
- var data = this.session.data.content.widgets.length ?
- this.session.data.content.widgets[0] :
- this.session.data.content.tabs[0]
-
- ipc.send('sessionSave', {
- session: new Session({
- content: data,
- version: PACKAGE.version
- }, 'fragment'),
- path: this.sessionPath,
- backup: backup
- })
-
- }
-
- }
-
- saveBackup() {
- this.save('', true)
- }
-
- saveAs() {
-
- if (!this.session || READ_ONLY) return
-
- uiFilebrowser({extension: 'json', save:true, directory: this.lastDir}, (path)=>{
- this.lastDir = path[0]
- this.save(path)
- })
-
- }
-
- export() {
-
- 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')
-
- editor.unsavedSession = false
-
- }
-
- open(data) {
-
- this.load(data.fileContent, ()=>{
- this.setSessionPath(data.path)
- ipc.send('sessionOpened', {path: data.path, sync: CLIENT_SYNC})
- })
-
- }
-
- requestOpen(path) {
-
- ipc.send('sessionOpen', {path: path})
-
- }
-
- browse() {
-
- if (READ_ONLY) return
-
- uiFilebrowser({extension: 'json', directory: this.lastDir}, (path)=>{
- if (editor.unsavedSession && !confirm(locales('session_unsaved'))) return
- this.lastDir = path[0]
- this.requestOpen(path)
- })
-
- }
-
- import() {
-
- if (READ_ONLY) return
-
- uiFileupload('.json', (path, result)=>{
- var session
- try {
- session = JSON.parse(result)
- } catch (err) {
- 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, ()=>{
- ipc.send('sessionSetPath', {path: 'imported'})
- })
-
- }, ()=>{
- new UiModal({title: locales('error'), content: locales('session_uploaderror'), icon: 'exclamation-triangle', closable:true})
- })
-
- }
-
- create() {
-
- if (editor.unsavedSession && !confirm(locales('session_unsaved'))) return
-
- this.load(null, ()=>{
- ipc.send('sessionSetPath', {path: ''})
- editor.enable()
- editor.select(widgetManager.getWidgetById('root'))
- })
- }
-
- setSessionPath(path) {
-
- this.sessionPath = path
-
- }
-
- setFragment(data) {
-
- var {path, fileContent, raw, notFound} = data,
- update = false
-
- if (notFound) {
- this.trigger('fragment-not-found', {path: path})
- return
- }
-
- if (raw) {
- if (this.fragments[path] !== fileContent) {
- this.fragments[path] = fileContent
- update = true
- }
- } else {
- var fragment = new Session(fileContent, 'fragment')
- if (!deepEqual(this.fragments[path], fragment)) {
- this.fragments[path] = fragment
- update = true
- }
- }
-
- if (update) this.trigger('fragment-updated', {path: path})
-
-
- }
-
- getFragment(path, data) {
-
- return this.fragments[path]
-
- }
-
- saveFragment(data) {
-
- uiFilebrowser({extension: 'json', save:true, directory: this.lastDir}, (path)=>{
- this.lastDir = path[0]
- ipc.send('sessionSave', {
- session: new Session({
- content: data,
- version: PACKAGE.version
- }, 'fragment'),
- path: path
- })
- })
-
- }
-
- loadFragment(path, raw=false) {
-
- ipc.send('fragmentLoad', {path, raw})
-
- }
-
- setSaveMode(mode) {
-
- this.saveMode = mode
- document.body.classList.toggle('fragment-mode', mode === 'fragment')
-
- }
-
-}
-
-var sessionManager = new SessionManager()
-
-export default sessionManager
diff --git a/src/client/managers/session/session.mjs b/src/client/managers/session/session.mjs
deleted file mode 100644
index 0a8eff48..00000000
--- a/src/client/managers/session/session.mjs
+++ /dev/null
@@ -1,351 +0,0 @@
-import semver from 'semver'
-import UiModal from '../../ui/ui-modal.mjs'
-import locales from '../../locales/index.mjs'
-import {PACKAGE} from '../../globals.mjs'
-
-class Session {
-
- constructor(data, type) {
-
- if (data === null) {
-
- data = {
- content: {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 || data.content, converter.widget)
-
- if (converter.warning && type !== 'fragment') warning = true
-
- }
-
- }
-
-
- if (warning) {
-
- new UiModal({title: locales('session_oldversion_title'), content: locales('session_oldversion'), icon: 'exclamation-triangle', closable:true})
-
- }
-
- }
-
-
-
- if (type === 'session' && data.type === 'fragment') {
- // opening fragment as a session
- if (data.content.type === 'tab') {
- data.content = {type: 'root', tabs: [data.content]}
- } else {
- data.content = {type: 'root', widgets: [data.content]}
- }
- this.isFragment = true
- }
-
- if (type === 'fragment' && data.type === 'session') {
- // opening session as a fragment
- data.content.type = 'panel'
- }
-
- data.createdWith = PACKAGE.productName
- data.version = PACKAGE.version
- if (type) data.type = type
-
- // push content to end of file
- var c = data.content
- delete data.content
- data.content = c
-
- 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.content
-
- }
-
- toJSON() {
-
- return JSON.stringify(this.data, null, ' ')
-
- }
-
-}
-
-var converters = [
- {
- version: '0.49.12',
- warning: true,
- global: (data)=>{
-
- if (Array.isArray(data)) data = data[0]
-
- 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 'tab':
- case 'panel':
- case 'root':
- if (data.widgets && data.widgets.length) {
- data.innerPadding = false
- data.padding = 0
- data.alphaStroke = 0
- }
- break
-
- case 'strip':
- data.type = 'panel'
- data.layout = data.horizontal ? 'horizontal' : 'vertical'
- data.alphaStroke = 0
- if (data.spacing) {
- data.padding = data.spacing
- } else {
- data.innerPadding = false
- data.padding = 0
- }
- 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.filters = 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).trim().replace(/JS\{\{(.*)\}\}/s, '$1').trim()}
- } else if (type === 'keydown') {
- ${String(data.keyDown).trim().replace(/JS\{\{(.*)\}\}/s, '$1').trim()}
- }
- `
- break
- case 'script':
- data.script = String(data.script).trim().replace(/JS\{\{(.*)\}\}/s, '$1').trim()
- break
-
- }
-
- var label = data.label === undefined ? 'auto' : data.label
- 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
- }
-
- }
- },
- {
- version: '1.3.0',
- widget: (data)=>{
-
- switch (data.type) {
-
- case 'fader':
- case 'knob':
- case 'xy':
- case 'range':
- case 'multixy':
- if (data.touchAddress && String(data.touchAddress).length) {
- let sendScript = data.type.match(/range|multixy/) ? 'if (touch.length) send(address, touch[0], touch[1])\n else send(address, touch)' : 'send(address, touch)',
- originalScript = data.script ? ` else {\n // original script\n ${data.script}\n // -----------\n}` : ''
- data.script = `\nif (touch !== undefined) {\n // generated automatically\n // from touchAddress\n var address = "${data.touchAddress}"\n ${sendScript}\n}${originalScript}`
- }
- break
-
- }
-
- }
- },
- {
- 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)')
- }
-
- }
- },
- {
- version: '1.8.15',
- global: (data)=>{
-
- data.content = data.session
- delete data.session
- return data
-
- }
- },
- {
- version: '1.13.2',
- warning: true,
- widget: (data)=>{
-
- if (data.script !== undefined) {
- if (data.type === 'script') {
- if (data.event === 'once') {
- data.onCreate = data.script
- } else if (data.event === 'keyboard') {
- data.onKeyboard = data.script
- } else if (data.event === 'value') {
- data.onValue = data.script
- }
- } else {
- data.onValue = data.script
- }
- }
- if (data.type === 'canvas') {
- if (data.draw !== undefined) data.onDraw = data.draw
- if (data.touch !== undefined) data.onTouch = data.touch
- }
-
- }
- },
- {
- version: '1.23.0',
- widget: (data)=>{
- if (data.type === 'patchbay' && data.exclusive === true) {
- data.exclusive = 'in'
- }
- else if ((data.type === 'panel' || data.type === 'root') && data.verticalTabs === true) {
- data.tabsPosition = 'left'
- delete data.verticalTabs
- }
- }
- },
- {
- version: '1.24.2',
- widget: (data)=>{
- if (data.type === 'menu') {
- if (data.toggle) {
- data.mode = data.doubleTap ? 'toggle' : 'doubleTap-toggle'
- } else if (data.doubleTap) {
- data.mode = 'doubleTap'
- } else {
- data.mode = 'default'
- }
- delete data.toggle
- delete data.doubleTap
- }
- }
- }
-]
-
-Session.converters = {}
-for (var i in converters) {
- Session.converters[converters[i].version] = converters[i]
-}
-
-export default Session
diff --git a/src/client/managers/state.mjs b/src/client/managers/state.mjs
deleted file mode 100644
index 606a436b..00000000
--- a/src/client/managers/state.mjs
+++ /dev/null
@@ -1,263 +0,0 @@
-import {saveAs} from 'file-saver'
-import ipc from '../ipc/index.mjs'
-import widgetManager from './widgets.mjs'
-import cache from './cache.mjs'
-import uiFilebrowser from '../ui/ui-filebrowser.mjs'
-import uiFileupload from '../ui/ui-fileupload.mjs'
-import notifications from '../ui/notifications.mjs'
-import locales from '../locales/index.mjs'
-import {deepCopy} from '../utils.mjs'
-
-
-var StateManager = class StateManager {
-
- constructor() {
-
- this.statePath = ''
- this.lastDir = null
-
- this.quickState = cache.get('state.quickState') || null
-
- this.valueStateQueue = {}
- this.valueOldPropQueue = {}
- this.valueNewPropQueue = {}
- this.queueCounter = 0
-
- }
-
- get(filter) {
-
- var data = {}
-
- for (let i in widgetManager.widgets) {
-
- var widget = widgetManager.widgets[i]
-
- if (filter && !filter(widget)) continue
-
- if (widget.setValue && widget.getValue && !widget.noValueState) {
-
- var v = widget.getValue()
-
- if (v !== undefined) {
-
- data[widget.getProp('id')] = v
-
- }
-
- }
- }
-
- return data
-
- }
-
- set(preset,send) {
-
- for (let id in preset) {
-
- var value = preset[id],
- widgets = widgetManager.getWidgetById(id)
-
- if (widgets.length) {
-
- for (var j = widgets.length - 1; j >= 0; j--) {
-
- if (widgets[j].setValue && !widgets[j].noValueState) {
-
- widgets[j].setValue(value, {send:send, sync:true})
-
- }
-
- }
-
- }
-
- }
-
- }
-
- send(options) {
-
- for (let i in widgetManager.widgets) {
-
- var widget = widgetManager.widgets[i]
-
- if (widget.sendValue && !widget.noValueState) {
- widget.sendValue(null, options)
- }
- }
-
- }
-
- save(path) {
-
- if (path) this.statePath = path
-
- if (!this.statePath) return this.saveAs()
-
- ipc.send('stateSave', {
- session: JSON.stringify(this.get(), null, ' '),
- path: this.statePath
- })
-
- }
-
- saveAs() {
-
- uiFilebrowser({extension: 'state', save:true, directory: this.lastDir}, (path)=>{
- this.lastDir = path[0]
- this.save(path)
- })
-
- }
-
- requestOpen(path) {
-
- ipc.send('stateOpen', {path: path})
-
- }
-
- browse() {
-
- uiFilebrowser({extension: 'state', directory: this.lastDir}, (path)=>{
- this.lastDir = path[0]
- this.requestOpen(path)
- })
-
- }
-
- load(state, send, path) {
-
- if (!state) return
-
- this.setStatePath(path)
-
- try {
- if (typeof state === 'string') {
- state = JSON.parse(state)
- }
-
- if (Array.isArray(state)) {
- // backward compatibility
- var ostate = {}
- for (var i in state) {
- ostate[state[i][0]] = state[i][1]
- }
- state = ostate
- }
-
- this.set(state, send)
- notifications.add({
- icon: 'sliders-h',
- class: 'state-recall',
- message: locales('state_recallsuccess')
- })
- } catch(e) {
- this.loadError()
- }
-
- }
-
- loadError(){
-
- notifications.add({
- class: 'error',
- message: locales('state_uploaderror')
- })
-
- }
-
-
- import() {
-
- uiFileupload('.state', (path, result)=>{
- this.load(result, true)
- }, (e)=>{
- this.loadError()
- })
-
- }
-
- export() {
-
- var state = JSON.stringify(this.get(),null,' ')
- var blob = new Blob([state],{type : 'application/json'})
- saveAs(blob, new Date().toJSON().slice(0,10)+'_'+new Date().toJSON().slice(11,16) + '.state')
-
- }
-
- quickSave() {
-
- this.quickState = deepCopy(this.get())
- localStorage.setItem('osc.state.quickState', JSON.stringify(this.quickState))
-
- }
-
- quickLoad() {
-
- this.load(this.quickState, true)
-
- }
-
- setStatePath(path) {
-
- if (!path) return
- this.statePath = path
-
- }
-
- pushValueState(id, value) {
- this.valueStateQueue[id] = value
- }
-
- pushValueOldProp(id, value) {
- this.valueOldPropQueue[id] = typeof value == 'object' ? JSON.stringify(value) : value
- }
-
- pushValueNewProp(id, value) {
- this.valueNewPropQueue[id] = typeof value == 'object' ? JSON.stringify(value) : value
- if (this.queueCounter == 0) this.flush()
- }
-
- flush(){
-
- for (let id in this.valueStateQueue) {
- if (this.valueStateQueue[id] !== undefined) {
- for (let w of widgetManager.getWidgetById(id)) {
- if (w.noValueState) continue
- w.setValue(this.valueStateQueue[id], {sync: true, script: false})
- }
- }
- }
-
- for (let id in this.valueNewPropQueue) {
- if (this.valueNewPropQueue[id] != this.valueOldPropQueue[id]) {
- for (let w of widgetManager.getWidgetById(id)) {
- if (w.noValueState) continue
- w.setValue(w.getProp('value'), {sync: true})
- }
- }
- }
-
- this.valueStateQueue = {}
- this.valueOldPropQueue = {}
- this.valueNewPropQueue = {}
- }
-
- incrementQueue() {
- this.queueCounter++
- }
-
- decrementQueue() {
- this.queueCounter--
- if (this.queueCounter == 0) {
- this.flush()
- }
- }
-
-}
-
-var stateManager = new StateManager()
-
-export default stateManager
diff --git a/src/client/managers/widgets.mjs b/src/client/managers/widgets.mjs
deleted file mode 100644
index cf569d9a..00000000
--- a/src/client/managers/widgets.mjs
+++ /dev/null
@@ -1,350 +0,0 @@
-import EventEmitter from '../events/event-emitter.mjs'
-import ipc from '../ipc/index.mjs'
-
-class WidgetManager extends EventEmitter {
-
- constructor() {
-
- super()
-
- this.widgets = {}
- this.children = []
-
- this.addressRoute = {}
- this.idRoute = {}
- this.linkIdRoute = {}
-
- this.linkIdLock = []
- this.linkIdLockDepth = 0
-
- this.preArgsSeparator = '||||'
-
- this.on('value-changed', this.onChange.bind(this))
-
- ipc.on('connect', ()=>{
- for (var hash in this.widgets) {
- this.registerWidget(this.widgets[hash])
- }
- })
-
- }
-
- onChange(e) {
-
- if (!e) return
-
- var {id, widget, linkId, options} = e
-
- if (linkId) {
- if (!Array.isArray(linkId)) linkId = [linkId]
- linkId = linkId.map(x=>String(x).replace(/^>>\s*/, '')).filter(x=>x.indexOf('<<') < 0)
- // scopable; prefix linkId with the closest (most restrictive) scope
- if (widget.scopes.length) linkId = linkId.map(x => x + widget.scopes[0])
- linkId = linkId.filter(x=>this.linkIdLock.indexOf(x)<0)
- this.linkIdLock = this.linkIdLock.concat(linkId)
- this.linkIdLockDepth++
- }
-
- var widgetsById = this.getWidgetById(id),
- widgetsByLinkId = linkId ? this.getWidgetByLinkId(linkId) : []
-
- // Widget that share the same id will update each other
- // without sending any extra osc message or running scripts
- if (widgetsById.length > 1) {
- let v = widget.getValue()
- for (let i in widgetsById) {
- if (widgetsById[i] !== widget) {
- widgetsById[i].setValue(v,{send:false,sync:false, id})
- // Because of sync:false, updated widgets that use @{this}
- // in their properties wont update them, we trigger it manually
- if (widgetsById[i].linkedPropsValue['this']) {
- widgetsById[i].onLinkedPropsChanged({id, widget: widgetsById[i], options: {send: false, sync: false, id}}, 'value-changed')
- }
- }
- }
- }
-
- // widgets that share the same linkId will update each other.
- // Updated widgets will send osc messages normally
- if (widgetsByLinkId.length > 0) {
- let v = widget.getValue()
- for (let i in widgetsByLinkId) {
- if (widgetsByLinkId[i] !== widget) {
- widgetsByLinkId[i].setValue(v,{send: options.send, sync: true, script:options.script, widget, id})
- }
- }
- }
-
- if (linkId && this.linkIdLockDepth) {
- this.linkIdLockDepth--
- if (!this.linkIdLockDepth) {
- this.linkIdLock = []
- }
- }
- }
-
- createAddressRef(widget, preArgs, address) {
-
- preArgs = widget ? widget.getProp('preArgs') : preArgs
- address = widget ? widget.getProp('address') === 'auto' ? '/' + widget.getProp('id') : widget.getProp('address') : address
-
- if (!Array.isArray(preArgs) && preArgs !== '') preArgs = [preArgs]
- if (preArgs === '') preArgs = []
-
- preArgs = preArgs.map(x=>typeof x === 'object' && x !== null && x.value !== undefined ? x.value : x)
-
- return preArgs && preArgs.length ?
- address + this.preArgsSeparator + preArgs.join(this.preArgsSeparator)
- : address
-
- }
-
- addWidget(widget) {
-
- var hash = widget.hash,
- address = this.createAddressRef(widget),
- id = widget.getProp('id'),
- linkId = widget.getProp('linkId')
-
- this.widgets[hash] = widget
-
- if (!this.idRoute[id]) this.idRoute[id] = []
- this.idRoute[id].push(hash)
-
- if (address) {
- if (!this.addressRoute[address]) this.addressRoute[address] = []
- this.addressRoute[address].push(hash)
- }
-
- if (linkId) {
- if (!Array.isArray(linkId)) linkId = [linkId]
- linkId = linkId.map(x=>String(x).replace(/^<<\s*/, '')).filter(x=>x.indexOf('>>') < 0)
- // scopable; prefix linkId with the closest (most restrictive) scope
- if (widget.scopes.length) linkId = linkId.map(x => x + widget.scopes[0])
- for (var i in linkId) {
- if (linkId[i]) {
- if (!this.linkIdRoute[linkId[i]]) this.linkIdRoute[linkId[i]] = []
- this.linkIdRoute[linkId[i]].push(hash)
- }
- }
- }
-
- this.registerWidget(widget)
-
- }
-
- registerWidget(widget, updatedData, oldData) {
-
- ipc.send('addWidget', {
- hash: widget.hash,
- data: updatedData || {
- preArgs: widget.getProp('preArgs'),
- target: widget.getProp('target'),
- typeTags: widget.getProp('typeTags'),
- address: widget.getProp('address') === 'auto' ? '/' + widget.getProp('id') : widget.getProp('address'),
- }
- })
-
- if (updatedData && oldData) {
- var address = this.createAddressRef(null, oldData.preArgs, oldData.address),
- newAddress = this.createAddressRef(widget),
- hash = widget.hash
-
- if (address && this.addressRoute[address].indexOf(hash) != -1) this.addressRoute[address].splice(this.addressRoute[address].indexOf(hash), 1)
-
- if (!this.addressRoute[newAddress]) this.addressRoute[newAddress] = []
- this.addressRoute[newAddress].push(hash)
- }
-
- }
-
- removeWidget(widget) {
-
- var hash = widget.hash,
- address = this.createAddressRef(widget),
- linkId = widget.getProp('linkId'),
- id = widget.getProp('id')
-
- if (this.widgets[hash]) {
- if (this.widgets[hash].onRemove) {
- this.widgets[hash].onRemove()
- }
-
- delete this.widgets[hash]
-
- ipc.send('removeWidget', {
- hash:hash
- })
-
- widget.trigger('widget-removed', {widget: widget})
- widget.off('widget-removed')
-
- }
- if (id && this.idRoute[id].indexOf(hash) != -1) this.idRoute[id].splice(this.idRoute[id].indexOf(hash), 1)
- if (address && this.addressRoute[address].indexOf(hash) != -1) this.addressRoute[address].splice(this.addressRoute[address].indexOf(hash), 1)
-
- if (!Array.isArray(linkId)) linkId = [linkId]
- linkId = linkId.map(x=>String(x).replace(/^<<\s*/, '')).filter(x=>x.indexOf('>>') < 0)
- // scopable; prefix linkId with the closest (most restrictive) scope
- if (widget.scopes.length) linkId = linkId.map(x => x + widget.scopes[0])
- for (var i in linkId) {
- if (linkId[i] && this.linkIdRoute[linkId[i]] && this.linkIdRoute[linkId[i]].indexOf(hash) != -1) this.linkIdRoute[linkId[i]].splice(this.linkIdRoute[linkId[i]].indexOf(hash), 1)
- }
-
- }
-
- removeWidgets(widgets, nested) {
-
- for (let i in widgets) {
-
- if (Array.isArray(widgets[i])) {
-
- this.removeWidgets(widgets[i], true)
-
- } else if (this.widgets[widgets[i].hash]) {
-
- this.removeWidget(widgets[i])
-
- }
-
- }
-
- if (!nested) this.purge()
-
- }
-
- purge() {
-
- for (let route of [this.addressRoute, this.idRoute, this.linkIdRoute]) {
- for (let key in route) {
- for (let i=route[key].length-1; i>=0; i--) {
- let hash = route[key][i]
- if (!this.widgets[hash]) {
- route[key].splice(i, 1)
- }
- }
- }
- }
-
- }
-
- reset() {
-
- this.removeWidgets(Object.values(this.widgets))
-
- this.off()
-
- this.on('value-changed', this.onChange.bind(this))
-
- }
-
-
- getWidgetBy(key, dict, widgets = []) {
-
- var hash, w
-
- if (Array.isArray(key)) {
- for (let i in key) {
- this.getWidgetBy(key[i], dict, widgets)
- }
- return widgets
- }
-
- if (dict[key]) {
- for (let i = dict[key].length-1; i>=0; i--) {
- hash = dict[key][i]
- w = this.widgets[hash]
- if (!w) {
- dict[key].splice(i,1)
- } else if (widgets.indexOf(w) == -1) {
- widgets.push(w)
- }
- }
- }
-
- return widgets
-
- }
-
- getWidgetById(id, scope) {
-
- /*
- scopable: return matching widgets only for the closest scope with results
- */
- if (scope && scope.length) {
- if (!Array.isArray(scope)) scope = [scope]
- for (var prefix of scope) {
- var prefixedId = Array.isArray(id) ? id.map(i=>prefix + i) : prefix + id
-
- var widgets = this.getWidgetBy(prefixedId, this.idRoute)
-
- if (widgets.length) return widgets
- }
- return []
- }
-
- return this.getWidgetBy(id, this.idRoute)
-
- }
-
- getWidgetByLinkId(linkId) {
-
- return this.getWidgetBy(linkId, this.linkIdRoute)
-
- }
-
- getWidgetByAddress(address) {
-
- return this.getWidgetBy(address, this.addressRoute)
-
- }
-
- getWidgetByAddressAndArgs(address, args) {
-
- var addressref = address,
- restArgs = args
-
- if (typeof args == 'object' && args != null) {
- for (var i = args.length; i >= 0; i--) {
-
- var ref = this.createAddressRef(null, args.slice(0,i), address)
-
- if (this.getWidgetByAddress(ref).length) {
- addressref = ref
- restArgs = args.slice(i, args.length)
- break
- }
-
- }
- } else {
- restArgs = args
- }
-
-
- if (restArgs == null || restArgs.length == 0) restArgs = null
- else if (restArgs.length == 1) restArgs = restArgs[0]
-
-
- var widgets = this.getWidgetByAddress(addressref)
-
- return [
- widgets,
- restArgs
- ]
-
- }
-
- getWidgetByElement(e, filter = '') {
- var element = e ? e.closest('[data-widget]' + filter) : undefined
- if (element) {
- return element._widget_instance ?
- element._widget_instance :
- this.widgets[element.getAttribute('data-widget')]
- }
- }
-
-}
-
-var widgetManager = new WidgetManager()
-
-export default widgetManager
diff --git a/src/client/osc.mjs b/src/client/osc.mjs
deleted file mode 100644
index 08223ccb..00000000
--- a/src/client/osc.mjs
+++ /dev/null
@@ -1,94 +0,0 @@
-import widgetManager from './managers/widgets.mjs'
-import EventEmitter from './events/event-emitter.mjs'
-import ipc from './ipc/index.mjs'
-import {deepEqual} from './utils.mjs'
-import {CLIENT_SYNC} from './globals.mjs'
-
-var Osc = class Osc extends EventEmitter {
-
- constructor() {
-
- super()
-
- this.syncOnly = false
- this.remoteControl = {}
- this.serverTargets = []
-
- ;(async()=>{
- this.remoteControl = (await import('./remote-control.mjs')).default
- })()
-
- }
-
- send(data) {
-
- if (this.syncOnly) {
-
- this.sync(data)
-
- } else {
-
- if (!CLIENT_SYNC) data.noSync = 1
-
- ipc.send('sendOsc', data)
-
- }
-
- }
-
- sync(data) {
-
- if (CLIENT_SYNC) ipc.send('syncOsc', data)
-
- }
-
- match(widget, data) {
-
- let widgetTarget = widget.getProp('target'),
- match = true
-
- if (data._rawTarget) {
- // if the message target is provided (when message comes from another client connected to the same server)
- // then we only update the widgets that have the exact same target
- match = deepEqual(widgetTarget, data._rawTarget)
-
- } else if (data.host === 'midi') {
- // if the message comes from a midi port, only update widgets that send to that port
- let widgetArrayTarget = Array.isArray(widgetTarget) ? widgetTarget : [widgetTarget],
- strTarget = data.host + ':' + data.port
-
- match = widgetArrayTarget.includes(strTarget) ||
- (!widgetArrayTarget.includes(null) && this.serverTargets.includes(strTarget))
-
- }
-
- return match
-
- }
-
- receive(data){
-
- if (data._rawTarget && !CLIENT_SYNC) return
-
- if (typeof this.remoteControl.exists === 'function' && this.remoteControl.exists(data.address)) this.remoteControl.exec(data.address, data.args, data.cm)
-
- var [widgets, restArgs] = widgetManager.getWidgetByAddressAndArgs(data.address, data.args)
-
- for (let i in widgets) {
-
- if (this.match(widgets[i], data)) {
- widgets[i].setValue(restArgs,{send:false,sync:true,fromExternal:!data.target})
- }
-
- }
-
- this.trigger(data.address, data)
-
- }
-
-}
-
-
-var osc = new Osc()
-
-export default osc
diff --git a/src/client/parser.mjs b/src/client/parser.mjs
deleted file mode 100644
index 38d6da48..00000000
--- a/src/client/parser.mjs
+++ /dev/null
@@ -1,128 +0,0 @@
-import widgetManager from './managers/widgets.mjs'
-import stateManager from './managers/state.mjs'
-import {deepCopy} from './utils.mjs'
-
-var Parser = class Parser {
-
- constructor() {
-
- this.iterators = {}
- this.widgets = {}
- this.defaults = {}
-
- ;(async()=>{
- this.widgets = (await import('./widgets/index.mjs')).widgets
- for (var k in this.widgets) {
- this.defaults[k] = this.widgets[k].defaults()._props()
- }
- })()
-
- }
-
- getIterator(id) {
-
- this.iterators[id] = (this.iterators[id] || 0) + 1
- return this.iterators[id]
-
- }
-
- reset() {
-
- this.iterators = {}
- widgetManager.reset()
-
- }
-
- parse(options) {
-
- var {
- data,
- parentNode,
- parent,
- tab,
- reCreateOptions,
- children,
- index,
- hash,
- locals,
- variables,
- meta
- } = options
-
- var props = data
-
- // Set default widget type
- props.type = tab ? 'tab' : props.type || 'fader'
-
- if (!this.widgets[props.type]) {
- console.error('[' + props.id + '] Widget type "' + props.type +'" does not exist, falling back to "fader"')
- props.type = 'fader'
- }
-
- // Get widget's defaults
- var defaults = this.defaults[props.type]
-
- // Set widget's undefined options to default
- for (let i in defaults) {
- if (i.indexOf('_') !== 0 && props[i] === undefined) props[i] = deepCopy(defaults[i])
- }
-
- // Generate widget's id, based on its type
- if (props.id === 'auto' || !props.id) {
- var id
- while (!id || widgetManager.getWidgetById(id).length) {
- id = props.type + '_' + this.getIterator(props.type)
- }
- props.id = id
- }
-
- // Remove props that don't apply
- for (let j in props) {
- if (defaults[j] === undefined || j[0] === '_') delete props[j]
- }
-
- // create widget
- var widget = new this.widgets[props.type]({
- props,
- parent,
- parentNode,
- reCreateOptions,
- children,
- hash,
- locals,
- variables,
- meta
- })
-
- widgetManager.addWidget(widget)
-
- // set widget's initial state
- var defaultValue = widget.getProp('default'),
- currentValue = widget.getProp('value')
-
- if (currentValue !== '' && currentValue !== undefined) {
-
- stateManager.pushValueNewProp(widget.getProp('id'), currentValue)
-
- } else if (defaultValue !== '' && defaultValue !== undefined) {
-
- widget.setValue(defaultValue, {defaultInit: true})
-
- }
-
- widget.created(index)
-
-
- parentNode.appendChild(widget.container)
- widget.mounted = true
-
- // Editor needs to get the container object
- return widget
-
- }
-
-}
-
-var parser = new Parser()
-
-export default parser
diff --git a/src/client/remote-control.mjs b/src/client/remote-control.mjs
deleted file mode 100644
index 10526a5d..00000000
--- a/src/client/remote-control.mjs
+++ /dev/null
@@ -1,326 +0,0 @@
-import deepExtend from 'deep-extend'
-import {updateWidget} from './editor/data-workers.mjs'
-import editor from './editor/index.mjs'
-import widgetManager from './managers/widgets.mjs'
-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, JSON5} from './globals.mjs'
-
-var callbacks = {
- '/EDIT': function(args, custom_module) {
-
- if (READ_ONLY && !custom_module) return
-
- var [id, json, opts] = args,
- newdata = typeof json == 'string' ? JSON5.parse(json) : json,
- options = typeof opts == 'string' ? JSON5.parse(opts) : {},
- widgets = widgetManager.getWidgetById(id)
-
- if (!widgets.length) return
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- var widget = widgets[i],
- data = widget.props
-
- for (var k in newdata) {
- data[k] = newdata[k]
- }
-
- updateWidget(widget, {
- reuseChildren: !(newdata.widgets || newdata.tabs),
- editedProps: Object.keys(newdata)
- })
-
- }
-
- editor.pushHistory()
-
- if (options.noWarning) editor.unsavedSession = false
-
- },
- '/EDIT/MERGE': function(args, custom_module) {
-
- if (READ_ONLY && !custom_module) return
-
- var [id, json, opts] = args,
- newdata = typeof json == 'string' ? JSON5.parse(json) : json,
- options = typeof opts == 'string' ? JSON5.parse(opts) : {},
- widgets = widgetManager.getWidgetById(id)
-
- if (!widgets.length) return
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- var widget = widgets[i],
- data = widget.props
-
- deepExtend(data, newdata)
-
- updateWidget(widget, {
- reuseChildren: !(newdata.widgets || newdata.tabs),
- editedProps: Object.keys(newdata)
- })
-
- }
-
- editor.pushHistory()
-
- if (options.noWarning) editor.unsavedSession = false
-
- },
- '/EDIT/UNDO': function(args, custom_module) {
-
- if (READ_ONLY && !custom_module) return
-
- editor.undo()
-
- },
- '/EDIT/REDO': function(args, custom_module) {
-
- if (READ_ONLY && !custom_module) return
-
- editor.redo()
-
- },
- '/EDIT/GET': function(args) {
-
- var [target, idOrAddress, ...preArgs] = args,
- widgets = []
-
- if (idOrAddress[0] == '/') {
-
- widgets = widgetManager.getWidgetByAddress(
- widgetManager.createAddressRef(null, preArgs, idOrAddress)
- )
-
- } else {
-
- widgets = widgetManager.getWidgetById(idOrAddress)
-
- }
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- return widgets[i].sendValue({
- target: [target],
- address: '/EDIT/GET',
- preArgs: [idOrAddress, ...preArgs],
- v: JSON.stringify(widgets[i].props),
- noSync: true
- }, {force: true})
-
- }
-
- },
- '/GET': function(args, transparentReply) {
-
- var [target, idOrAddress, ...preArgs] = args,
- widgets = []
-
- if (idOrAddress[0] == '/') {
-
- widgets = widgetManager.getWidgetByAddress(
- widgetManager.createAddressRef(null, preArgs, idOrAddress)
- )
-
- } else {
-
- widgets = widgetManager.getWidgetById(idOrAddress)
-
- }
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- let overrides = {
- target: [target],
- noSync: true
- }
-
- if (!transparentReply) {
-
- overrides.address = '/GET'
- overrides.preArgs = [idOrAddress, ...preArgs]
-
- }
-
- return widgets[i].sendValue(overrides, {force: true})
-
- }
-
- },
- '/GET/#': function(args) {
-
- callbacks['/GET'](args, true)
-
- },
- '/SET': function(args) {
-
- var [idOrAddress, ...preArgsOrValue] = args,
- widgets = [],
- value = null
-
- if (idOrAddress[0] == '/') {
-
- [widgets, value] = widgetManager.getWidgetByAddressAndArgs(
- idOrAddress,
- preArgsOrValue
- )
-
- } else {
-
- widgets = widgetManager.getWidgetById(idOrAddress)
- value = preArgsOrValue
- if (value.length == 0) value = null
- else if (value.length == 1) value = value[0]
-
- }
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- return widgets[i].setValue(value, {
- sync: true,
- send: true
- })
-
- }
-
- },
- '/STATE/GET': function(args) {
-
- if (Array.isArray(args)) args = args[0]
-
- var target = args,
- root = widgetManager.getWidgetById('root')[0],
- state = stateManager.get()
-
- root.sendValue({
- target: [target],
- address: '/STATE/GET',
- preArgs: [],
- v: JSON.stringify(state),
- noSync: true
- }, {force: true})
-
- },
- '/STATE/SET': function(args) {
-
- if (!Array.isArray(args)) args = [args]
-
- var json = args[0],
- data = typeof json == 'string' ? JSON5.parse(json) : json,
- send = !(args[1] === 0 || args[1] === false)
-
- stateManager.set(data, send)
-
- },
- '/STATE/STORE': function(args) {
-
- stateManager.quickSave()
-
- },
- '/STATE/RECALL': function(args) {
-
- stateManager.quickLoad()
-
- },
- '/STATE/SEND': function(args) {
-
- stateManager.send()
-
- },
- '/STATE/OPEN': function(args) {
-
- if (!Array.isArray(args)) args = [args]
-
- stateManager.requestOpen(args[0])
-
- },
- '/STATE/SAVE': function(args) {
-
- if (!Array.isArray(args)) args = [args]
-
- stateManager.save(args[0])
-
- },
- '/NOTIFY': function(args) {
-
- if (!Array.isArray(args)) args = [args]
-
- var icon
- if (args.length > 1 && typeof args[0] === 'string' && args[0].indexOf(' ') === -1) {
- icon = args.shift()
- }
-
- notifications.add({
- message: args.join('\n') || ' ',
- icon: icon
- })
-
- },
- '/LOG': function(args) {
-
- console.log(args)
-
- },
- '/SESSION/CREATE': function(args) {
-
- editor.unsavedSession = false
-
- sessionManager.create()
-
- },
- '/SESSION/OPEN': function(args) {
-
- if (!Array.isArray(args)) args = [args]
-
- sessionManager.requestOpen(args[0])
-
- },
- '/SESSION/SAVE': function(args) {
-
- if (!Array.isArray(args)) args = [args]
-
- sessionManager.save(args[0])
-
- },
- '/TABS': function(args) {
-
- if (!Array.isArray(args)) args = [args]
-
- for (let id of args) {
- let ws = widgetManager.getWidgetById(id)
- for (let w of ws) {
- if (w.getProp('type') === 'tab') {
- var index = w.parent.children.indexOf(w)
- w.parent.setValue(index, {sync: true, send: false})
- }
- }
- }
- },
- '/SCRIPT': function(args) {
-
- if (!Array.isArray(args)) args = [args]
-
- uiConsole.script.run({input_code: args[0]}, {sync: true, send: true})
-
- },
- '/RELOAD': function(args) {
-
- window.location.href = window.location.href
-
- }
-}
-
-export default {
- exec: function(name, args, custom_module){
- if (callbacks[name]) {
- callbacks[name](args, custom_module)
- }
- },
- exists: function(name){
- return name in callbacks
- }
-}
diff --git a/src/client/stacktrace.mjs b/src/client/stacktrace.mjs
deleted file mode 100644
index e25bfd2f..00000000
--- a/src/client/stacktrace.mjs
+++ /dev/null
@@ -1,21 +0,0 @@
-import StackTrace from 'stacktrace-js'
-import ipc from './ipc/index.mjs'
-import uiConsole from './ui/ui-console.mjs'
-
-window.onerror = function(msg,url,row,col, error) {
-
- StackTrace.fromError(error).then((stackframes)=>{
-
- var stringifiedStack = ' ' + stackframes.join('\n ')
-
- uiConsole.log('error', `${msg}\n${stringifiedStack}`)
- ipc.send('errorLog', `(ERROR, CLIENT) ${msg}\n${stringifiedStack}`)
-
- }).catch(()=>{
-
- uiConsole.log('error', `${msg}\n at ${url}:${row}:${col}\n (no stacktrace available)`)
- ipc.send('errorLog', `(ERROR, CLIENT) ${msg}\n at ${url}:${row}:${col}\n (no stacktrace available)`)
-
- })
-
-}
diff --git a/src/client/ui/context-menu.mjs b/src/client/ui/context-menu.mjs
deleted file mode 100644
index 9630f4d8..00000000
--- a/src/client/ui/context-menu.mjs
+++ /dev/null
@@ -1,221 +0,0 @@
-import html from 'nanohtml'
-import raw from 'nanohtml/raw'
-import keyboardJS from 'keyboardjs/dist/keyboard.min.js'
-import UiWidget from './ui-widget.mjs'
-import {DOM, PXSCALE} from '../globals.mjs'
-
-var mod = (navigator.platform || '').match('Mac') ? 'cmd' : 'ctrl',
- MENU_CONTAINER
-
-class ContextMenu extends UiWidget {
-
- constructor(options={}){
-
- super(options)
-
- if (!MENU_CONTAINER) MENU_CONTAINER = DOM.get('osc-workspace')[0]
-
-
- this.container = html``
- this.clickHandler = (e)=>{
- if (this.container && !this.container.contains(e.target)) {
- this.close()
- }
- }
-
-
- this.position = options.position
- if (this.position) {
- this.container.style.top = this.position[0] + 'rem'
- this.container.style.left = this.position[1] + 'rem'
- }
-
- this.container.addEventListener('click', (e)=>{
- e.preventDefault()
- if (e.target._action){
- e.target._action()
- this.close()
- }
- })
-
- this.hoverNode = null
- this.container.addEventListener('mousemove', (e)=>{
- if (this.hoverNode === e.target) return
- this.hoverNode = e.target
- if (!e.target.classList.contains('focus')) {
- DOM.each(e.target.parentNode, '.focus', (el)=>{
- el.classList.remove('focus')
- })
- e.target.classList.add('focus')
- }
- })
-
- this.container.addEventListener('touchstart', (e)=>{
- if (e.target.classList.contains('has-sub')) e.preventDefault()
- if (!e.target.classList.contains('focus')) {
- DOM.each(e.target.parentNode, '.focus', (el)=>{
- el.classList.remove('focus')
- })
- e.target.classList.add('focus')
- } else {
- e.target.classList.remove('focus')
- DOM.each(e.target, '.focus', (el)=>{
- el.classList.remove('focus')
- })
- }
- })
-
-
- }
-
- parse(actions, node) {
-
- for (let action of actions) {
-
- if (action.separator) {
-
- node.appendChild(html`
`)
-
- } else if (Array.isArray(action.action)) {
-
- let submenu = html``,
- label = typeof action.label === 'function' ? action.label() : action.label,
- iclass = typeof action.class === 'function' ? action .class() : action.class,
- item = html`${raw(label)}
`
-
- if (action.disabled) {
-
- item.classList.add('disabled')
-
- } else {
-
- item.appendChild(submenu)
-
- this.parse(action.action, submenu)
-
- }
-
- node.appendChild(item)
-
- } else {
-
- let label = typeof action.label === 'function' ? action.label() : action.label,
- iclass = typeof action.class === 'function' ? action.class() : action.class,
- item = html`${raw(label)}
`
-
- if (action.disabled) item.classList.add('disabled')
-
- item._action = action.action
- node.appendChild(item)
-
- if (action.shortcut) {
-
- item.appendChild(html`${action.shortcut.replace('mod', mod)}
`)
-
- }
-
- }
-
- }
-
- }
-
- open(e, actions, parent) {
-
- this.container.innerHTML = ''
- this.parse(actions, this.container)
-
- MENU_CONTAINER.appendChild(this.container)
-
- if (!this.position) {
- this.container.style.top = e.pageY / PXSCALE + 'rem'
- this.container.style.left = e.pageX / PXSCALE + 'rem'
- }
-
-
- this.correctPosition(this.container)
-
- DOM.each(this.container, '.context-menu', (m)=>{
- this.correctPosition(m, m.parentNode)
- })
-
- document.addEventListener('fast-click', this.clickHandler, true)
- document.addEventListener('fast-right-click', this.clickHandler, true)
-
- this.trigger('open')
-
- }
-
- close() {
-
- if (this.container) {
-
- this.container.parentNode.removeChild(this.container)
-
- // remove position fix
- this.container.style.bottom = ''
- this.container.style.right = ''
- this.container.style.marginRight = ''
-
- }
-
- document.removeEventListener('fast-click', this.clickHandler, true)
- document.removeEventListener('fast-right-click', this.clickHandler, true)
-
- this.hoverNode = null
-
- this.trigger('close')
-
- }
-
- correctPosition(menu, parent) {
-
- var position = DOM.offset(menu),
- width = menu.offsetWidth,
- height = menu.offsetHeight,
- totalWidth = MENU_CONTAINER.offsetWidth,
- totalHeight = MENU_CONTAINER.offsetHeight
-
- if (width + position.left > totalWidth) {
- if (position.left - width > 0) {
- menu.style.right = parent ? '100%' : '0'
- menu.style.left = 'auto'
- menu.style.marginRight = '-0.5rem'
- } else {
- menu.style.left = (parent.offsetWidth + (totalWidth - width - position.left)) / PXSCALE + 'rem'
- }
- }
-
- if (height + position.top > totalHeight && position.top - height > 0) {
- menu.style.top = 'auto'
- menu.style.bottom = '0rem'
- }
-
- }
-
- bindShortcuts(actions) {
-
- for (let action of actions) {
-
- if (action.disabled) continue
-
- if (Array.isArray(action.action)) {
-
- this.bindShortcuts(action.action)
-
- } else if (action.shortcut && action.action) {
-
- keyboardJS.bind(action.shortcut, (e)=>{
- e.preventDefault()
- action.action()
- })
-
- }
-
- }
-
- }
-
-}
-
-export default ContextMenu
diff --git a/src/client/ui/fullscreen.mjs b/src/client/ui/fullscreen.mjs
deleted file mode 100644
index af0787fb..00000000
--- a/src/client/ui/fullscreen.mjs
+++ /dev/null
@@ -1,43 +0,0 @@
-import screenfull from 'screenfull'
-import UiModal from './ui-modal.mjs'
-import locales from '../locales/index.mjs'
-import iOS from './ios.mjs'
-
-var fullscreen
-
-if (screenfull.isEnabled && !iOS) {
-
- fullscreen = screenfull
-
-} else {
-
- class IOSFullScreen {
-
- constructor(){
-
- this.enabled = !navigator.standalone
- this.isFullScreen = navigator.standalone
-
- }
-
- toggle(){
-
- new UiModal({
- title: locales('fullscreen_unnavailable'),
- content: locales('fullscreen_addtohome'),
- closable: true
- })
-
- }
-
- on(){}
-
- }
-
- fullscreen = new IOSFullScreen()
-
-}
-
-window.ELECTRON_FULLSCREEN = ()=>{fullscreen.toggle()}
-
-export default fullscreen
diff --git a/src/client/ui/index.mjs b/src/client/ui/index.mjs
deleted file mode 100644
index 62a03c9b..00000000
--- a/src/client/ui/index.mjs
+++ /dev/null
@@ -1,5 +0,0 @@
-import UiSidePanel from './ui-sidepanel.mjs'
-import locales from '../locales/index.mjs'
-
-export const leftUiSidePanel = new UiSidePanel({selector: 'osc-panel-container.left', label: locales('editor_tree')})
-export const rightUiSidePanel= new UiSidePanel({selector: 'osc-panel-container.right', label: locales('editor_inspector')})
diff --git a/src/client/ui/init.mjs b/src/client/ui/init.mjs
deleted file mode 100644
index 072a3341..00000000
--- a/src/client/ui/init.mjs
+++ /dev/null
@@ -1,14 +0,0 @@
-import './zoom.mjs'
-import '../events/click.mjs'
-import './ios.mjs'
-import './notifications.mjs'
-import './ui-workspace.mjs'
-import './main-menu.mjs'
-import './ui-console.mjs'
-import {updateMobileThemeColor, device} from './utils.mjs'
-
-updateMobileThemeColor()
-
-if (!device.is('mobile') && !device.is('tablet')) {
- import('./ui-keyboard.mjs')
-}
diff --git a/src/client/ui/ios.mjs b/src/client/ui/ios.mjs
deleted file mode 100644
index c9f3267e..00000000
--- a/src/client/ui/ios.mjs
+++ /dev/null
@@ -1,59 +0,0 @@
-import {DOM} from '../globals.mjs'
-import {device, os} from './utils.mjs'
-
-
-var iOS = (device.is('mobile') || device.is('tablet')) && os.is('ios')
-
-// Prevent iOS Pull-To-Refresh
-
-if (iOS && parseInt(os.version.split('.')[0]) < 13) {
-
- // prevent overscroll
- // breaks scrolling on iOS <= 13 (besides it doesn't seem to be needed)
-
- var supportsPassiveOption = false
- try {
- document.createElement('div').addEventListener('test', function() {}, {
- get passive() {
- supportsPassiveOption = true
- return false
- }
- })
- } catch(e) {}
-
- iOS = true
-
- var preventNextMove = false
-
- document.addEventListener('touchstart', (e)=>{
- if (e.touches.length === 1 && !e.target._drag_widget) preventNextMove = true
- }, supportsPassiveOption ? {passive: false} : false)
-
- document.addEventListener('touchmove', (e)=>{
- // preventDefault the first overscrolling touchmove
- if (preventNextMove) {
- preventNextMove = false
- e.preventDefault()
- }
- }, supportsPassiveOption ? {passive: false} : false)
-
-
-}
-
-if (iOS) {
- // when waking from sleep, iOS may have trouble rendering the session properly
- // this attempts to force a full redraw by shortly resizing the main container
- document.onvisibilitychange = ()=>{
- if (document.visibilityState === 'visible') {
- var main = DOM.get('osc-panel-container#main')[0]
- main.style.marginBottom = '1px'
- main.style.marginRight = '1px'
- setTimeout(()=>{
- main.style.marginBottom = ''
- main.style.marginRight = ''
- })
- }
- }
-}
-
-export default iOS
diff --git a/src/client/ui/main-menu.mjs b/src/client/ui/main-menu.mjs
deleted file mode 100644
index 092c002a..00000000
--- a/src/client/ui/main-menu.mjs
+++ /dev/null
@@ -1,334 +0,0 @@
-import NoSleep from 'nosleep.js'
-import UiToolbar from './ui-toolbar.mjs'
-import ipc from '../ipc/index.mjs'
-import locales from '../locales/index.mjs'
-import notifications from './notifications.mjs'
-import fullscreen from './fullscreen.mjs'
-import editor from '../editor/index.mjs'
-import sessionManager from '../managers/session/index.mjs'
-import stateManager from '../managers/state.mjs'
-import {leftUiSidePanel, rightUiSidePanel} from '../ui/index.mjs'
-import uiConsole from '../ui/ui-console.mjs'
-import {READ_ONLY, KIOSK, VIRTUAL_KEYBOARD, setVIRTUAL_KEYBOARD} from '../globals.mjs'
-import {device} from './utils.mjs'
-
-
-var recentSessions = [{label: locales('file_open_recent_wait'), class: 'disabled'}]
-var menuEntries = [
-
- {
- label: locales('session'),
- disabled: READ_ONLY,
- action: [
- {
- label: locales('session_new'),
- action: sessionManager.create.bind(sessionManager),
- id: 'session-new'
- },
- {
- separator: true
- },
- {
- label: locales('file_open'),
- action: sessionManager.browse.bind(sessionManager),
- shortcut: 'mod + o',
- id: 'session-open'
- },
- {
- label: locales('file_open_recent'),
- action: recentSessions,
- class: ()=>{return !recentSessions.length ? 'disabled' :''}
- },
- {
- separator: true
- },
- {
- label: locales('file_save'),
- action: sessionManager.save.bind(sessionManager),
- shortcut: 'mod + s',
- class: ()=>{return sessionManager.session === null ? 'disabled' :''},
- id: 'session-save'
- },
- {
- label: locales('file_save_as'),
- action: sessionManager.saveAs.bind(sessionManager),
- shortcut: 'mod + shift + s',
- class: ()=>{return sessionManager.session === null ? 'disabled' :''},
- id: 'session-save-as'
- },
- {
- label: locales('fragment_mode'),
- class: ()=>{return 'toggle ' + (sessionManager.saveMode === 'fragment' ? 'on' : 'off')},
- action: ()=>{sessionManager.setSaveMode(sessionManager.saveMode === 'session' ? 'fragment' : 'session')},
- id: 'session-fragment'
- },
- {
- separator: true
- },
- {
- label: locales('file_backup'),
- action: sessionManager.saveBackup.bind(sessionManager),
- shortcut: 'mod + b',
- class: ()=>{return sessionManager.session === null || !sessionManager.sessionPath ? 'disabled' :''},
- id: 'session-backup'
- },
- {
- separator: true
- },
- {
- label: locales('file_import'),
- action: sessionManager.import.bind(sessionManager),
- id: 'session-import'
- },
- {
- label: locales('file_export'),
- action: sessionManager.export.bind(sessionManager),
- class: ()=>{return sessionManager.session === null ? 'disabled' :''},
- id: 'session-export'
- },
-
- ]
- },
- {
- label: locales('state'),
- disabled: READ_ONLY,
- class: ()=>{return sessionManager.session === null ? 'disabled' : ''},
- action: [
- {
- label: locales('state_store'),
- action: stateManager.quickSave.bind(stateManager),
- id: 'state-store'
- },
- {
- label: locales('state_recall'),
- class: ()=>{return stateManager.quickState === null ? 'disabled' : ''},
- action: stateManager.quickLoad.bind(stateManager),
- id: 'state-recall'
- },
- {
- label: locales('state_send'),
- action: ()=>{
- stateManager.send()
- notifications.add({
- icon: 'sliders-h',
- message: locales('state_sendsuccess')
- })
- },
- id: 'state-send'
- },
- {
- separator: true
- },
- {
- label: locales('file_open'),
- action: stateManager.browse.bind(stateManager),
- id: 'state-open'
- },
- {
- label: locales('file_save'),
- action: stateManager.save.bind(stateManager),
- id: 'state-save'
- },
- {
- label: locales('file_save_as'),
- action: stateManager.saveAs.bind(stateManager),
- id: 'state-save-as'
- },
- {
- separator: true
- },
- {
- label: locales('file_import'),
- action: stateManager.import.bind(stateManager),
- id: 'state-import'
- },
- {
- label: locales('file_export'),
- action: stateManager.export.bind(stateManager),
- id: 'state-export'
- },
- ]
- },
- {
- label: locales('editor'),
- disabled: READ_ONLY,
- class: ()=>{return sessionManager.session === null ? 'disabled' : ''},
- action: [
- {
- label: locales('editor_enabled'),
- class: ()=>{return 'toggle ' + (editor.enabled ? 'on' : 'off')},
- action: ()=>{
- if (editor.enabled) editor.disable()
- else editor.enable()
- },
- shortcut: 'mod + e',
- id: 'editor-enabled'
- },
- {
- separator: true
- },
- {
- label: locales('editor_grid'),
- class: ()=>{return 'toggle ' + (editor.grid ? 'on' : 'off')},
- action: editor.toggleGrid.bind(editor),
- shortcut: 'mod + g',
- id: 'editor-grid'
- },
- {
- label: locales('editor_tree'),
- class: ()=>{return 'toggle ' + (leftUiSidePanel.minimized ? 'off' : 'on')},
- action: ()=>{return leftUiSidePanel.minimized ? leftUiSidePanel.restore() : leftUiSidePanel.minimize()},
- shortcut: 'mod + t',
- id: 'editor-tree'
- },
- {
- label: locales('editor_inspector'),
- class: ()=>{return 'toggle ' + (rightUiSidePanel.minimized ? 'off' : 'on')},
- action: ()=>{return rightUiSidePanel.minimized ? rightUiSidePanel.restore() : rightUiSidePanel.minimize()},
- shortcut: 'mod + i',
- id: 'editor-inspector'
- },
- {
- separator: true
- },
- {
- label: locales('editor_percents'),
- class: ()=>{return 'toggle ' + (editor.usePercents ? 'on' : 'off')},
- action: ()=>{editor.usePercents = !editor.usePercents},
- id: 'editor-percents'
- }
- ]
- },
- {
- label: locales('console'),
- disabled: READ_ONLY,
- action: [
- {
- label: locales('console_enabled'),
- class: ()=>{return 'toggle ' + (uiConsole.minimized ? 'off' : 'on')},
- action: ()=>{
- if (uiConsole.minimized) {
- uiConsole.restore()
- uiConsole.input.focus()
- } else {
- uiConsole.minimize()
- }
- },
- shortcut: 'mod + k',
- id: 'console-enabled'
- },
- {
- separator: true
- },
- {
- label: locales('console_clear'),
- action: uiConsole.clear.bind(uiConsole),
- shortcut: 'mod + l',
- id: 'console-clear'
-
- },
- ]
- },
- {
- separator: true
- },
- {
- label: locales('fullscreen'),
- disabled: KIOSK && navigator.userAgent.match(/OpenStageControl/), // built-in electron client only
- class: ()=>{return 'toggle ' + (fullscreen.isFullscreen ? 'on' : 'off')},
- action: ()=>{
- if (fullscreen.isEnabled) fullscreen.toggle()
- },
- shortcut: 'f11',
- id: 'fullscreen'
- },
- {
- label: locales('notifications'),
- class: ()=>{return 'toggle ' + (notifications.visible ? 'on' : 'off')},
- action: ()=>{
- notifications.setVisibility(!notifications.visible)
- },
- id: 'notifications'
- }
-
-]
-
-if (device.is('mobile') || device.is('tablet')) {
-
-
- var noSleep = new NoSleep(),
- noSleepState = false,
- wakeLock = null
-
- menuEntries.push({
- label: locales('nosleep'),
- class: ()=>{return 'toggle ' + (noSleepState ? 'on' : 'off')},
- action:()=>{
- noSleepState = !noSleepState
- if (noSleepState) {
- if ('wakeLock' in navigator) {
- navigator.wakeLock.request('screen').then((l)=>{
- wakeLock = l
- wakeLock.addEventListener('release', ()=>{
- noSleepState = false
- })
- }).catch((err)=>{
- console.error(`Could not acquire wake lock:\n${err.name}, ${err.message}`)
- wakeLock = null
- })
- }
- if (wakeLock === null) noSleep.enable()
- } else {
- if ('wakeLock' in navigator && wakeLock !== null) {
- wakeLock.release().then(()=>{
- wakeLock = null
- })
- } else {
- noSleep.disable()
- }
- }
- },
- id: 'prevent-sleep'
- })
-
-} else {
-
- menuEntries.push({
- label: locales('keyboard'),
- class: ()=>{return 'toggle ' + (VIRTUAL_KEYBOARD ? 'on' : 'off')},
- action: ()=>{
- setVIRTUAL_KEYBOARD(!VIRTUAL_KEYBOARD)
- },
- id: 'virtual-keyboard'
- })
-
-}
-
-
-
-
-
-class MainMenu extends UiToolbar {
-
- constructor(options) {
-
- super(options)
-
- ipc.on('sessionList', (data)=>{
- if (recentSessions.length) {
- recentSessions.splice(0, 10)
- }
- for (let s of data) [
- recentSessions.push({
- label: s,
- action: ()=>{sessionManager.requestOpen(s)}
- })
- ]
- })
-
- }
-
-}
-
-
-export default new MainMenu({selector: '#main-menu', position: [40, 1], entries: menuEntries})
diff --git a/src/client/ui/notifications.mjs b/src/client/ui/notifications.mjs
deleted file mode 100644
index 19bafba5..00000000
--- a/src/client/ui/notifications.mjs
+++ /dev/null
@@ -1,142 +0,0 @@
-import html from 'nanohtml'
-import raw from 'nanohtml/raw'
-import morph from 'nanomorph'
-import UiWidget from './ui-widget.mjs'
-import {DOM, ENV} from '../globals.mjs'
-import {icon} from './utils'
-
-
-var DEFAULT_DURATION = 3500
-
-class Toast {
-
- constructor(data) {
-
- this.id = data.id || Date.now()
- this.update(data)
-
- }
-
- update(data) {
-
- this.expires = Date.now() + (data.duration || DEFAULT_DURATION)
-
- var toast = html`
-
- ${raw(icon(data.icon || (data.class === 'error' ? 'exclamation' : 'bell')))}
-
-
- `
-
- DOM.get(toast, '.content')[0].textContent = data.message
-
- if (this.html) {
- this.html = morph(this.html, toast)
- this.html.style.height = this.html.offsetHeight + 'px'
- } else {
- this.html = toast
- }
-
- }
-
- appendTo(el) {
-
- el.appendChild(this.html)
- this.html.style.height = this.html.offsetHeight + 'px'
-
- }
-
- removeFrom(el) {
-
- this.html.classList.add('remove')
- setTimeout(()=>{
- if (el.contains(this.html)) el.removeChild(this.html)
- }, 200)
-
- }
-
-}
-
-class Notifications extends UiWidget {
-
- constructor(options) {
-
- super(options)
-
- this.toasts = []
-
- this.loop = null
- this.visible = undefined
-
- this.setVisibility(ENV.notifications != 0)
-
- this.container.addEventListener('fast-click', (e)=>{
- for (var toast of this.toasts) {
- if (toast.html.contains(e.target)) this.remove(toast)
- }
- })
-
- }
-
- add(data) {
-
- if (data.id) {
- var match = this.toasts.filter(x => x.id === data.id)
- if (match.length) {
- return match[0].update(data)
- }
- }
-
- var toast = new Toast(data)
-
- toast.appendTo(this.container)
- this.toasts.push(toast)
-
- this.startLoop()
-
- }
-
- remove(toast) {
-
- toast.removeFrom(this.container)
- this.toasts.splice(this.toasts.indexOf(toast), 1)
-
- if (this.toasts.length === 0) this.stopLoop()
-
- }
-
- startLoop() {
-
- if (this.loop) return
-
- this.loop = setInterval(()=>{
- for (var i = this.toasts.length - 1; i > -1; i--) {
- if (Date.now() > this.toasts[i].expires) {
- this.remove(this.toasts[i])
- }
- }
-
- },100)
-
- }
-
- stopLoop() {
-
- if (!this.loop) return
-
- clearInterval(this.loop)
- this.loop = null
-
- }
-
-
- setVisibility(v) {
-
- this.visible = v
- this.container.style.display = v ? '' : 'none'
-
- }
-
-}
-
-export default new Notifications({selector: '#notifications'})
diff --git a/src/client/ui/ui-code-editor.mjs b/src/client/ui/ui-code-editor.mjs
deleted file mode 100644
index 8998f752..00000000
--- a/src/client/ui/ui-code-editor.mjs
+++ /dev/null
@@ -1,343 +0,0 @@
-import html from 'nanohtml'
-import raw from 'nanohtml/raw'
-import UiModal from './ui-modal.mjs'
-import locales from '../locales/index.mjs'
-import {icon} from '../ui/utils.mjs'
-import scriptVm from '../widgets/scripts/script-vm.mjs'
-import modeJavascript from 'ace-builds/src-noconflict/mode-javascript.js'
-import modeCss from 'ace-builds/src-noconflict/mode-css.js'
-import modeHtml from 'ace-builds/src-noconflict/mode-html.js'
-import {DOM} from '../globals.mjs'
-
-
-var scriptGlobals = scriptVm.globals,
- editors = {}, editorModes = {
- javascript: modeJavascript,
- css: modeCss,
- html: modeHtml
- },
- codeEditorModKey = (navigator.platform || '').match('Mac') ? 'Cmd' : 'Ctrl'
-
-
-const ace = window.ace
-ace.config.set('basePath', '/__APP_DIR__/client/ace/')
-
-function setCommandEnabled(editor, name, enabled) {
- var command = editor.commands.byName[name]
- if (!command.bindKeyOriginal)
- command.bindKeyOriginal = command.bindKey
- command.bindKey = enabled ? command.bindKeyOriginal : null
- editor.commands.addCommand(command)
-}
-
-
-class CodeEditor {
-
- constructor(parent, name, language, syntaxChecker) {
-
- this.parent = parent
- this.name = name
- this.language = language
- this.syntaxChecker = syntaxChecker
-
- this.field = null
- this.input = null
- this.widget = null
- this.container = html`
`
- this.helpBtn = html`${locales('editor_ace_help')}
`
- this.fsBtn = html`${raw(icon('expand'))}
`
-
- this.helpBtn.addEventListener('fast-click', (e)=>{
- this.help()
- })
- this.fsBtn.addEventListener('fast-click', (e)=>{
- this.fullscreen()
- })
-
- this.closeKey = ((e)=>{
- // this handler may remain dangling if closing with ctrl+enter
- // we ignore this as it has no effect
- if (e.key != 'Escape') return
- this.field.classList.remove('fullscreen')
- this.editor.setOptions({maxLines: 30})
- this.editor.fullscreen = false
- document.removeEventListener('keydown', this.closeKey)
- this.field.removeEventListener('fast-click', this.closeClick)
- this.editor.blur()
- this.parent.parentContainer.classList.remove('editor-breakout')
- }).bind(this)
-
- this.closeClick = ((e)=>{
- if (e.target === this.field) {
- this.closeKey({key: 'Escape'})
- }
- }).bind(this)
-
- this.editor = ace.edit(this.container)
-
- if (editorModes[language]) this.editor.getSession().setMode('ace/mode/' + language)
-
- this.editor.setOptions({
- autoScrollEditorIntoView: true,
- copyWithEmptySelection: true,
- highlightIndentGuides:false,
- tooltipFollowsMouse: false,
- tabSize: 2,
- maxLines: 30,
- dragEnabled: false,
- useWorker: syntaxChecker !== false
- })
-
- this.editor.$blockScrolling = Infinity
- this.editor.commands.bindKeys({
- 'ctrl-l': null, 'ctrl-f': null, 'ctrl-h': null, 'ctrl-,': null,
- 'cmd-l': null, 'cmd-f': null, 'cmd-h': null, 'cmd-,': null,
- })
- this.editor.renderer.setScrollMargin(4, 4, 0, 4)
- this.editor.element = this.container
- this.editor.element.classList.add('ace_dark')
- this.editor.textarea = DOM.get(this.container, '.ace_text-input')[0]
- this.editor.textarea.name = name
- this.editor.textarea._ace = true
- this.editor.setHighlightActiveLine(false)
- this.editor.setHighlightGutterLine(false)
-
- if (language === 'javascript' && syntaxChecker !== false) {
- this.editor.getSession().$worker.send('setOptions', [{
- asi: true, // no semicolon
- esversion: 7,
- strict: 'implied',
- node: false,
- browser: true,
- validthis: true,
- undef: true,
- globals: {}
- }])
- }
-
- this.container.addEventListener('mousedown', (e)=>{
- if (e.button === 1) {
- e.preventDefault()
- e.stopPropagation()
- }
- }, {capture: true})
-
- }
-
- bind(widget, field) {
-
- this.widget = widget
- this.field = field
- this.input = DOM.get(field, 'textarea')[0]
-
- var editor = this.editor,
- input = this.input
-
- input.style.display = 'none'
- input._ace_input = editor.textarea
- input.tabIndex = -1
-
- editor.setValue(input.value)
- editor.textarea.osc_input = input
- editor.textarea.tabIndex = 0
-
- this.field.classList.remove('dirty')
-
- editor.removeAllListeners('focus')
- this.editor.on('focus', (e)=>{
- this.parent.focusedInput = this.input
- this.editor.setHighlightActiveLine(true)
- this.editor.setHighlightGutterLine(true)
-
- this.editor.removeAllListeners('blur')
- this.editor.removeAllListeners('change')
- this.editor.removeAllListeners('changeSelection')
- this.editor.on('change', (e)=>{
- this.input.value = this.editor.getValue()
- this.editor.dirty = true
- if (this.editor.fullscreen) {
- this.field.classList.add('dirty')
- }
- })
-
- this.typing = false
- setCommandEnabled(this.editor, 'indent', false)
- setCommandEnabled(this.editor, 'outdent', false)
-
- setTimeout(()=>{
- if (this.pos) {
- this.editor.moveCursorTo(this.pos.row, this.pos.column)
- } else {
- var pos = this.editor.getCursorPosition()
- if (pos.row === undefined || pos.column === undefined) {
- this.editor.gotoLine(0)
- }
-
- }
-
- this.typing = false
- this.editor.on('changeSelection', ()=>{
- if (this.typing) return
- let pos = this.editor.getCursorPosition()
- if (pos.row || pos.column) {
- setCommandEnabled(this.editor, 'indent', true)
- setCommandEnabled(this.editor, 'outdent', true)
- }
- this.typing = true
- })
- })
-
-
- this.editor.on('blur', (e)=>{
- this.pos = this.editor.getCursorPosition()
- this.editor.setHighlightActiveLine(false)
- this.editor.setHighlightGutterLine(false)
- this.editor.selection.setRange({start:0,end:0})
- if (this.editor.fullscreen) {
- e.preventDefault()
- return
- }
- this.input.value = this.editor.getValue()
- this.parent.focusedInput = this.input
- if (this.editor.dirty) {
- this.editor.dirty = false
- this.parent.onChange()
- }
- this.parent.focusedInput = null
-
- })
-
- })
-
-
- editor.setOptions({maxLines: 30})
- editor.dirty = false
-
- if (this.language === 'javascript') {
- let globals = {}
-
- if (this.name === 'onKeyboard') {
- globals = {type: true, key: true, code: true, ctrl: true, shift: true, alt: true, meta: true}
- } else if (this.name === 'onCreate') {
- globals = {value: true}
- } else if (this.name === 'onValue') {
- globals = {id: true, value: true, touch: true}
- } else if (this.name === 'onDraw') {
- globals = {value: true, height: true, width: true, ctx: true, cssVars: true}
- } else if (this.name === 'onTouch') {
- globals = this.widget.getProp('type') === 'canvas' ?
- {value: true, height: true, width: true, event: true} :
- {value: true, event: true, handle: true}
- } else if (this.name === 'onResize') {
- globals = {value: true, height: true, width: true, cssVars: true}
- }
-
- for (var k in scriptGlobals) {
- globals[k] = true
- }
-
- globals.locals = true
- globals.console = true
- globals.JS = true
- globals.this = false
-
- if (this.syntaxChecker !== false) editor.getSession().$worker.send('changeOptions', [{
- globals: globals
- }])
- }
-
- field.appendChild(editor.element)
- field.appendChild(this.helpBtn)
- field.appendChild(this.fsBtn)
-
- editor.selection.setRange({start:0,end:0})
-
- if (this.hash !== widget.hash) {
- // preserve undo history if widget is the same
- editor.getSession().getUndoManager().reset()
- this.hash = widget.hash
- this.pos = null
- } else if (editor.fullscreen) {
- this.fullscreen()
- }
-
- editor.resize()
-
- }
-
- fullscreen() {
-
- this.editor.fullscreen = this.field.classList.toggle('fullscreen')
- this.editor.setOptions({maxLines: this.editor.fullscreen ? 0 : 30})
- this.field.style.setProperty('--prefix', this.editor.fullscreen ? '"' + this.widget.getProp('id') + '."' : '')
- setTimeout(()=>{
- window.dispatchEvent(new Event('resize'))
- })
-
- if (this.editor.fullscreen) {
- this.parent.parentContainer.classList.add('editor-breakout')
- this.editor.focus()
- document.addEventListener('keydown', this.closeKey)
- this.field.addEventListener('fast-click', this.closeClick)
- } else {
- this.parent.parentContainer.classList.remove('editor-breakout')
- document.removeEventListener('keydown', this.closeKey)
- this.field.removeEventListener('fast-click', this.closeClick)
- }
- }
-
- help() {
-
- var keybindings = []
- var commandMap = {}
-
- this.editor.keyBinding.$handlers.forEach(function(handler) {
- var ckb = handler.commandKeyBinding
- for (var i in ckb) {
- var key = i.replace(/(^|-)\w/g, function(x) { return x.toUpperCase() })
- var commands = ckb[i]
- if (!Array.isArray(commands))
- commands = [commands]
- commands.forEach(function(command) {
- if (typeof command != 'string')
- command = command.name
- if (commandMap[command]) {
- commandMap[command].key += '|' + key
- } else {
- commandMap[command] = {key: key, command: command}
- keybindings.push(commandMap[command])
- }
- })
- }
- })
-
- var modal = new UiModal({closable: true, title: html`${locales('editor_ace_help_title')} `, html: true, content: html`
-
-
-
-
- Shortcut
- Command
-
-
- ${codeEditorModKey}-Enter save
- ${keybindings.map(k=>html`${k.key} ${k.command} `)}
-
-
- `})
-
-
- this.parent.helpModalOpened = true
-
- modal.on('close', ()=>{
- this.parent.helpModalOpened = false
- })
-
- }
-
-}
-
-export default function(parent, name, language, syntaxChecker) {
- if (!editors[name]) editors[name] = new CodeEditor(parent, name, language, syntaxChecker)
- return editors[name]
-}
diff --git a/src/client/ui/ui-colorpicker.mjs b/src/client/ui/ui-colorpicker.mjs
deleted file mode 100644
index 2b6df433..00000000
--- a/src/client/ui/ui-colorpicker.mjs
+++ /dev/null
@@ -1,119 +0,0 @@
-import html from 'nanohtml'
-import chroma from 'chroma-js'
-import UiWidget from './ui-widget.mjs'
-import Rgb from '../widgets/pads/rgb.mjs'
-import * as resize from '../events/resize.mjs'
-
-
-class ColorPicker extends UiWidget {
-
- constructor() {
-
- super({})
-
- this.name = ''
- this.value = ''
-
- this.rgb = new Rgb({props: {
- ...Rgb.defaults()._props(),
- type: 'rgb',
- width: 'auto',
- height: 'auto',
- alphaStroke: 0,
- snap: true,
- alpha: true
- }, parent: this, meta: {not_editable: true}})
-
- this.container = html`
-
- ${this.rgb.container}
-
- `
-
- this.rgb.on('value-changed', (e)=>{
- e.stopPropagation = true
- this.value = chroma(this.rgb.value).hex()
- this.trigger('change', {preventHistory: true})
- })
-
- var dragEndCb = (e)=>{
- this.value = chroma(this.rgb.value).hex()
- this.trigger('change')
- }
- this.rgb.pad.on('dragend', dragEndCb)
- this.rgb.hue.on('dragend', dragEndCb)
- this.rgb.alpha.on('dragend', dragEndCb)
-
-
- this.opened = 0
-
- this.escKeyHandler = ((e)=>{
- if (e.key == 'Escape') this.close()
- }).bind(this)
-
- this.enterKeyHandler = ((e)=>{
- if (e.key == 'Enter') this.confirm()
- }).bind(this)
-
- }
-
- open() {
-
- this.parentNode.appendChild(this.container)
- resize.check(this.rgb.container)
- this.opened = 1
-
- document.addEventListener('keydown', this.escKeyHandler)
- document.addEventListener('keydown', this.enterKeyHandler)
- }
-
- close() {
-
- if (this.parentNode && this.parentNode.contains(this.container)) {
- this.parentNode.removeChild(this.container)
- }
- this.setName()
- this.opened = 0
-
- document.removeEventListener('keydown', this.escKeyHandler)
- document.removeEventListener('keydown', this.enterKeyHandler)
- }
-
- confirm() {
-
- this.value = chroma(this.rgb.getValue(true)).css('rgba')
- this.trigger('change')
- this.close()
-
- }
-
- isVisible() {
-
- return true
-
- }
-
- setName(n = '') {
-
- this.name = n
-
- }
-
- setValue(v) {
-
- if (v === 'transparent') v = '#00000000'
-
- this.rgb.setValue(chroma(v).rgba())
-
- }
-
- setParent(node) {
-
- if (this.opened && node !== this.parentNode) this.close()
- this.parentNode = node
-
- }
-
-}
-
-export default ColorPicker
diff --git a/src/client/ui/ui-console.mjs b/src/client/ui/ui-console.mjs
deleted file mode 100644
index 5c960158..00000000
--- a/src/client/ui/ui-console.mjs
+++ /dev/null
@@ -1,197 +0,0 @@
-import html from 'nanohtml'
-import raw from 'nanohtml/raw'
-import UiSidePanel from './ui-sidepanel.mjs'
-import locales from '../locales/index.mjs'
-import {icon} from './utils.mjs'
-import Script from '../widgets/scripts/script.mjs'
-import Widget from '../widgets/common/widget.mjs'
-import widgetManager from '../managers/widgets.mjs'
-import {DOM, ENV, READ_ONLY} from '../globals.mjs'
-
-class UiConsole extends UiSidePanel {
-
- constructor(options) {
-
- super(options)
-
- this.header = DOM.get(this.container, 'osc-panel-header')[0]
-
- this.header.appendChild(html`${locales('console')} `)
- this.messages = this.content.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'))}
`)
- this.clearBtn.addEventListener('click', ()=>{
- this.clear()
- })
-
- this.length = 0
- this.maxLength = ENV.consolelength || 300
-
- this.history = ['']
- this.cursor = 0
-
-
- var _this = this
-
- console._log = console.log
- console.log = function(message){
- for (let arg of arguments) {
- _this.log('log', arg)
- }
- console._log(...arguments)
- }
-
- console._error = console.error
- console.error = function(message){
- for (let arg of arguments) {
- _this.log('error', arg)
- }
- console._error(...arguments)
- }
-
- console._clear = console.clear
- console.clear = function(){
- _this.clear()
- console._clear()
- }
-
- this.widget = new Widget({props: {id: 'CONSOLE'}, parent: widgetManager, meta: {not_editable: true}})
- this.script = new Script({
- widget: this.widget,
- property: '',
- code: 'var navigator; return eval(input_code)',
- context: {input_code: ''}
- })
- this.widget.hash = 'CONSOLE'
-
- this.input.addEventListener('keydown', (event)=>{
- if (event.key === 'Enter' && !event.shiftKey) {
- event.preventDefault()
- this.inputValidate()
- } else if (event.key == 'ArrowUp') {
- 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.key == 'ArrowDown') {
- 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.key == 'DOM_VK_TAB' && this.input.value !== '') {
- 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.messages.addEventListener('keydown', (event)=>{
- if (event.key == 'Escape') {
- this.messages.blur()
- }
- })
-
- if (!READ_ONLY) this.enable()
-
- }
-
- 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.run({input_code: 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[1]) {
- this.history.splice(1, 0, this.input.value)
- if (this.history.length > 50) this.history.pop()
- }
-
- this.input.value = ''
- this.cursor = 0
-
- }
-
- log(type, message, as_html) {
- var msg =html`
-
-
-
- `
-
- var node = this.messages.appendChild(msg)
- if (typeof message === 'object') {
- if (!(message instanceof Error)) {
- try {
- message = JSON.stringify(message)
- } catch (_) {}
- } else {
- message = String(message) + message.stack
- }
- }
-
- if (as_html) {
- node.innerHTML = message
- } else {
- node.textContent = message
- }
-
- node.scrollIntoView()
-
- if (++this.length > this.maxLength) this.purge()
-
-
- }
-
- purge() {
-
- var children = [...this.messages.children]
- for (var i = 0; i < this.maxLength / 2; i++) {
- this.messages.removeChild(children[i])
- }
- this.length = this.maxLength / 2 + 1
-
- }
-
- clear() {
-
- this.messages.innerHTML = ''
- this.length = 0
- this.script.onRemove()
-
- }
-
-}
-
-export default new UiConsole({selector: '#osc-console', minSize: 40, size: 200, minimized: true})
diff --git a/src/client/ui/ui-dragresize.mjs b/src/client/ui/ui-dragresize.mjs
deleted file mode 100644
index f4e62c59..00000000
--- a/src/client/ui/ui-dragresize.mjs
+++ /dev/null
@@ -1,241 +0,0 @@
-import html from 'nanohtml'
-import fastdom from 'fastdom'
-import keyboardJS from 'keyboardjs/dist/keyboard.min.js'
-import UiWidget from './ui-widget.mjs'
-import {DOM, PXSCALE, GRIDWIDTH} from '../globals.mjs'
-
-var Tab, Root, Folder
-;(async()=>{
- Tab = (await import('../widgets/containers/tab.mjs')).default
- Root = (await import('../widgets/containers/root.mjs')).default
- Folder = (await import('../widgets/containers/folder.mjs')).default
-})()
-
-class UiDragResize extends UiWidget {
-
- constructor(options) {
-
- super(options)
-
- this.container = html`
-
- `
-
-
- this.initLeft = 0
- this.initTop = 0
- this.initWidth = 0
- this.initHeight = 0
-
- this.left = 0
- this.top = 0
- this.width = 0
- this.height = 0
-
- this.widgets = []
- this.mounted = false
-
- this.handles = DOM.get(this.container, '.handle')
- this.dragging = null
- this.copying = null
- this.shiftKey = false
-
- this.on('draginit', (event)=>{
-
- var node = event.firstTarget
- if ((event.shiftKey && !event.altKey) || !this.handles.includes(node)) return
-
- this.initLeft = this.left
- this.initTop = this.top
- this.initWidth = this.width
- this.initHeight = this.height
- this.matrix = ''
-
- this.container.classList.add('dragging')
- this.dragging = node.getAttribute('data-action').split(',')
- delete event.traversingStack
- delete event.traversing
-
- }, {element: this.container})
-
- this.on('drag', (event)=>{
-
- if (!this.dragging) return
-
- for (var k of this.dragging) {
-
- switch (k) {
- case 'left':
- case 'width':
- this[k] += event.movementX / PXSCALE
- break
- case 'top':
- case 'height':
- this[k] += event.movementY / PXSCALE
- break
-
- }
-
- }
-
- this.updateCss(true)
-
-
- }, {element: this.container})
-
-
- this.on('dragend', (event)=>{
-
- if (!this.dragging) return
-
- var node = event.firstTarget
- if (!this.handles.includes(node)) return
-
- this.container.classList.remove('dragging')
- this.left = Math.max(0, this.left)
- this.top = Math.max(0, this.top)
- this.shiftKey = event.shiftKey
- this.trigger(this.dragging.indexOf('left') > -1 ? 'move' : 'drag-resize', this)
- this.dragging = null
- this.copying = null
- this.shiftKey = false
-
- }, {element: this.container})
-
- window.addEventListener('resize', ()=>{
- if (this.mounted) this.updateRectangle()
- })
-
- // this.handles[0]._ignore_css_transforms = true
-
- keyboardJS.withContext('editing', ()=>{
- keyboardJS.bind('alt', (e)=>{
- if (e.target.tagName !== 'TEXTAREA') this.handles[0].classList.add('full')
- }, (e)=>{
- if (e.target && e.target.tagName !== 'TEXTAREA') this.handles[0].classList.remove('full')
- })
- keyboardJS.bind('alt+c', (e)=>{
- if (e.target.tagName === 'TEXTAREA') return
- this.copying = true
- this.container.classList.add('copying')
- }, (e)=>{
- if (e.target.tagName === 'TEXTAREA') return
- this.copying = false
- this.container.classList.remove('copying')
- })
- })
-
- }
-
- clear() {
-
- if (!this.mounted) return
-
- this.container.parentNode.removeChild(this.container)
- this.mounted = false
- this.widgets = []
-
-
- }
-
- create(widgets) {
-
- this.clear()
-
- this.widgets = widgets.slice().filter(
- w=>w.getProp('visible') &&
- !(w instanceof Tab) &&
- !(w instanceof Root) &&
- !(w instanceof Folder)
- )
-
- if (!this.widgets.length) return
-
- this.updateRectangle()
-
- this.initLeft = this.left
- this.initTop = this.top
- this.initWidth = this.width
- this.initHeight = this.height
-
- fastdom.mutate(()=>{
- if (this.widgets.length) {
- this.widgets[0].parentNode.appendChild(this.container)
- this.mounted = true
- }
- })
-
- }
-
- updateRectangle() {
-
- var widgets = this.widgets,
- widget = widgets[0],
- layout = String(widget.parent.getProp('layout'))
-
- var handlesVisibility = [
- layout === 'default', // nw
- layout.match(/horizontal|default/), // e
- layout.match(/vertical|default/), // s
- ]
- handlesVisibility.push(handlesVisibility[1] && handlesVisibility[2]) // se
-
- fastdom.measure(()=>{
-
- var lefts = widgets.map(w => w.container.offsetLeft),
- tops = widgets.map(w => w.container.offsetTop),
- rights = widgets.map(w => w.container.offsetLeft + w.container.offsetWidth),
- bottoms = widgets.map(w => w.container.offsetTop + w.container.offsetHeight)
-
- this.left = Math.min(...lefts) / PXSCALE
- this.top = Math.min(...tops) / PXSCALE
- this.width = (Math.max(...rights) - Math.min(...lefts)) / PXSCALE
- this.height = (Math.max(...bottoms) - Math.min(...tops)) / PXSCALE
-
- fastdom.mutate(()=>{
-
- for (var i in handlesVisibility) {
- this.handles[i].style.display = handlesVisibility[i] ? '' : 'none'
- }
-
- this.updateCss()
-
- // this.cssTransform = widget.cssTransform || 'none'
- // this.cssTransformOrigin = widget.cssTransformOrigin
-
- })
-
- })
-
-
- }
-
- updateCss(grid) {
-
- for (let k of ['top', 'left', 'width', 'height']) {
-
- var val = this[k]
-
- if (k === 'width' || k === 'height') val = Math.max(10 * PXSCALE, val)
- if (grid && this.dragging.includes(k)) {
- val = Math.round(val / GRIDWIDTH) * GRIDWIDTH
- }
-
- this.container.style.setProperty('--' + k, val + 'rem')
-
- // this.container.style.transform = this.cssTransform
- // this.container.style.transformOrigin = this.cssTransformOrigin
-
- }
-
- }
-
-}
-
-export default UiDragResize
diff --git a/src/client/ui/ui-filebrowser.mjs b/src/client/ui/ui-filebrowser.mjs
deleted file mode 100644
index 766e3194..00000000
--- a/src/client/ui/ui-filebrowser.mjs
+++ /dev/null
@@ -1,215 +0,0 @@
-import html from 'nanohtml'
-import raw from 'nanohtml/raw'
-import keyboardJS from 'keyboardjs/dist/keyboard.min.js'
-import locales from '../locales/index.mjs'
-import ipc from '../ipc/index.mjs'
-import doubleClick from '../events/double-click.mjs'
-import {icon} from './utils.mjs'
-import UiModal from './ui-modal.mjs'
-import {DOM} from '../globals.mjs'
-
-
-export default function UiFilebrowser(options, callback, closeCallback) {
-
- var save = options.save,
- saveInputFocus = undefined,
- previousKbContext = keyboardJS.getContext()
-
- var popup = new UiModal({
- height: 360,
- closable: true,
- html: true,
- title: locales(save ? 'remotesave_save' : 'remotesave_open'),
- hide: true
- })
-
- var container = DOM.get(popup.container, '.popup-content')[0],
- browser = html`
`,
- ariane = html`
`,
- list = html``,
- saveInput = html` `,
- actions = html`
-
- ${saveInput}
-
${raw(icon('times'))} Cancel
- ${
- save ?
- html`
${raw(icon('save'))} Save
` :
- html`
${raw(icon('folder-open'))} Open
`
- }
-
- `
-
- var files = [],
- root = '',
- path = ''
-
- var extRe = options.extension ? new RegExp('.*\\.' + options.extension + '$') : /.*/
-
- if (save) {
- saveInput.addEventListener('change', ()=>{
- if (!saveInput.value.match(extRe)) saveInput.value += '.' + options.extension
- })
- saveInput.addEventListener('focus', ()=>{
- saveInputFocus = true
- })
- list.addEventListener('change', ()=>{
- saveInputFocus = false
- var choice = DOM.get(list, ':checked')[0]
- if (choice && choice.classList.contains('file')) {
- saveInput.value = choice.value
- }
- })
- }
-
- doubleClick(list, submit, {click: true})
-
- function submit(){
-
- var choice = DOM.get(list, ':checked')[0]
-
- if (!choice && (!save || !saveInput.value) && !options.loadDir) return
-
- if (choice && choice.classList.contains('folder') && (!save || !saveInputFocus)) {
- ipc.send('listDir', {path: [path, choice.value]})
- } else {
- if (save) {
- if (files.some(x=>x.name===saveInput.value)) {
- if (!confirm(locales('remotesave_overwrite'))) return
- }
- callback([path, saveInput.value], root)
- popup.close()
- } else {
- callback([path, choice ? choice.value : ''], root)
- popup.close()
- }
- }
-
- }
-
- actions.addEventListener('click', (e)=>{
- if (e.target.classList.contains('submit')) {
- submit()
- } else if ((e.target.classList.contains('cancel'))){
- popup.close()
- }
- })
-
- function keyDownHandler(e){
-
- if (e.key == 'Enter') {
- if (save) {
- document.addEventListener('keyup', keyUpHandler)
- } else {
- submit()
- }
- } else if (e.target === saveInput) {
- return
- } else if (e.key == 'DOM_VK_BACK_SPACE' || e.keyCode === 8) {
- list.childNodes[0].firstElementChild.checked = true
- submit()
- } else if (e.key.length === 1) {
- var letter = e.key.toLowerCase(),
- current = DOM.get(list, ':checked')[0],
- minIndex = -1,
- index = -1
-
- if (current) minIndex = DOM.index(current.parentNode)
-
- for (let i in files) {
- if (files[i].name[0].toLowerCase() === letter && !list.childNodes[i].firstElementChild.checked) {
- if (index === -1) index = i
- if (minIndex !== -1 && i < minIndex) continue
- index = i
- break
- }
- }
-
- if (index !== -1) {
- list.childNodes[index].firstElementChild.click()
- list.childNodes[index].firstElementChild.focus()
- }
- }
- }
- function keyUpHandler(e){
-
- if (e.key == 'Enter') {
- setTimeout(submit, 100)
- document.removeEventListener('keyup', keyUpHandler)
- }
-
- }
-
- document.addEventListener('keydown', keyDownHandler)
-
- ipc.on('listDir', (data)=>{
- path = data.path
- root = data.root
- ariane.textContent = root ? path.replace(root, '/') : path
-
- files = data.files.filter(x=>x.folder || x.name.match(extRe))
-
- function alphaSort(a, b){
- // convert to strings and force lowercase
- a = typeof a.name === 'string' ? a.name.toLowerCase() : a.name.toString()
- b = typeof b.name === 'string' ? b.name.toLowerCase() : b.name.toString()
- return a.localeCompare(b)
- }
-
- var fo = files.filter(x=>x.folder),
- fi = files.filter(x=>!x.folder)
-
- fo.sort(alphaSort)
- fi.sort(alphaSort)
-
- files = fo.concat(fi)
-
- files.unshift({
- name: '..',
- folder: true
- })
-
-
- browser.removeChild(list)
- list.innerHTML = ''
- for (let i in files) {
- var file = files[i]
- list.appendChild(html`
-
-
-
${raw(icon(file.folder ? 'folder' : 'osc'))} ${file.name}
-
- `)
- }
-
-
- browser.insertBefore(list, actions)
-
-
- if (save && saveInputFocus === undefined) {
- saveInput.focus()
- } else {
- list.childNodes[0].firstElementChild.focus()
- }
-
- }, {context: popup})
-
- popup.on('close', ()=>{
- ipc.off('listDir', null, popup)
- document.removeEventListener('keydown', keyDownHandler)
- document.removeEventListener('keyup', keyUpHandler)
- keyboardJS.setContext(previousKbContext)
- if (closeCallback) closeCallback(path)
- })
-
- browser.appendChild(ariane)
- browser.appendChild(list)
- browser.appendChild(actions)
- container.appendChild(browser)
-
- ipc.send('listDir', {extension: options.extension, path: options.directory ? [options.directory] : null})
-
- popup.open()
- keyboardJS.setContext('filebrowser')
-
-}
diff --git a/src/client/ui/ui-fileupload.mjs b/src/client/ui/ui-fileupload.mjs
deleted file mode 100644
index 818f5c06..00000000
--- a/src/client/ui/ui-fileupload.mjs
+++ /dev/null
@@ -1,45 +0,0 @@
-import html from 'nanohtml'
-import locales from '../locales/index.mjs'
-import uiLoading from './ui-loading.mjs'
-import {DOM} from '../globals.mjs'
-
-var SINGLETON = null,
- CONTAINER = null
-
-export default function uiFileUpload(types, ok, error) {
-
- if (!CONTAINER) CONTAINER = DOM.get('osc-modal-container')[0]
-
- if (SINGLETON) CONTAINER.removeChild(SINGLETON)
-
- SINGLETON = html` `
-
- if (types) SINGLETON.accept = types
-
- CONTAINER.appendChild(SINGLETON)
-
- SINGLETON.addEventListener('change',function(e){
-
-
- var reader = new FileReader(),
- file = e.target.files[0]
-
- uiLoading(locales('loading_upload'))
-
- reader.onerror = reader.onabort = function(e) {
- uiLoading(false)
- error(e)
- }
-
- reader.onload = function(e) {
- uiLoading(false)
- ok(file.path, e.target.result)
- }
-
- reader.readAsText(file, 'utf-8')
-
- })
-
- SINGLETON.click()
-
-}
diff --git a/src/client/ui/ui-inspector-field.mjs b/src/client/ui/ui-inspector-field.mjs
deleted file mode 100644
index ceff8e21..00000000
--- a/src/client/ui/ui-inspector-field.mjs
+++ /dev/null
@@ -1,137 +0,0 @@
-import html from 'nanohtml'
-import raw from 'nanohtml/raw'
-import chroma from 'chroma-js'
-import UiWidget from './ui-widget.mjs'
-import {categories} from '../widgets/index.mjs'
-import {icon} from '../ui/utils.mjs'
-
-class UiInspectorField extends UiWidget {
-
- constructor(options) {
-
- super(options)
-
- this.name = options.name
- this.widget = options.widget
- this.value = options.value
- this.default = options.default
-
- this.container = html` `
- this.label = this.container.appendChild(html`${this.name} `)
-
- if (this.name === 'type' || this.name === 'widgetType') this.createTypeSelect()
- else this.createInput()
-
- }
-
- createTypeSelect() {
-
-
- if (this.widget.props.type == 'tab' || this.widget.props.type == 'root') {
- this.container.appendChild(html`
-
- `)
- return
- }
-
- this.createInput()
-
- var select = html` `
-
- for (let cname in categories) {
-
- var optGroup = html` `
-
- for (let wtype of categories[cname]) {
- optGroup.appendChild(html`${wtype} `)
- }
-
- select.appendChild(optGroup)
-
- }
-
- var wrapper = html` `
- wrapper.appendChild(select)
- this.container.appendChild(wrapper)
-
- }
-
- createInput() {
-
-
- var stringValue = typeof this.value !== 'string' ?
- JSON.stringify(this.value, null, ' ').replace(/\n\s\s\s\s/g, ' ').replace(/\n\s\s(\}|\])/g, ' $1') : this.value
-
-
- let input = html``
-
- if (this.name === 'id' && this.widget.props.type === 'root') input.disabled = true
-
- if (this.default.value === 'auto' && stringValue === 'auto') {
- input.placeholder = stringValue
- } else {
- input.textContent = stringValue
- }
-
- this.container.appendChild(input)
-
-
- if (this.default.choices) {
-
- let wrapper = html` `,
- select = wrapper.appendChild(html` `)
- for (let choice of this.default.choices) {
- select.appendChild(html`${choice} `)
- }
-
- this.container.appendChild(wrapper)
-
- }
-
- if (this.default.type.includes('boolean')) {
-
- let toggle = html`
-
- ${raw(icon('check'))}
-
- `
-
- this.container.appendChild(toggle)
-
- }
-
- if (this.name.includes('color')) {
-
- let style = window.getComputedStyle(this.widget.container),
- colorData = this.widget.constructor.cssVariables.find(x=>x.js === this.name),
- val = 'transparent'
-
- try {
- val = chroma(style.getPropertyValue(colorData.css).trim()).hex('rgba')
- } catch(e) {}
- this.container.appendChild(html`
-
- `)
-
-
- } else if (stringValue === 'auto' && this.widget.constructor.cssVariables.some(x=>x.js === this.name)) {
-
- let style = window.getComputedStyle(this.widget.container),
- data = this.widget.constructor.cssVariables.find(x=>x.js === this.name),
- val = style.getPropertyValue(data.css).trim()
-
- if (data.toJs) val = data.toJs(val)
- this.container.appendChild(html`
- ${val}
- `)
-
-
-
- }
-
- }
-
-
-}
-
-export default UiInspectorField
diff --git a/src/client/ui/ui-inspector.mjs b/src/client/ui/ui-inspector.mjs
deleted file mode 100644
index 05a71af2..00000000
--- a/src/client/ui/ui-inspector.mjs
+++ /dev/null
@@ -1,434 +0,0 @@
-import html from 'nanohtml'
-import raw from 'nanohtml/raw'
-import fastdom from 'fastdom'
-import morph from 'nanomorph'
-import UiWidget from './ui-widget.mjs'
-import UiInspectorField from './ui-inspector-field.mjs'
-import UiColorPicker from './ui-colorpicker.mjs'
-import UiModal from './ui-modal.mjs'
-import {defaults} from '../widgets/index.mjs'
-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, JSON5} from '../globals.mjs'
-
-var editor
-;(async()=>{
- editor = (await import('../editor/index.mjs')).default
-})()
-
-
-var codeEditorModKey = (navigator.platform || '').match('Mac') ? 'metaKey' : 'ctrlKey'
-
-class UiInspector extends UiWidget {
-
- constructor(options) {
-
- super(options)
-
- this.mounted = false
-
- this.expandedCategories = ['widget']
-
- this.widget = null
-
- this.toolbar = this.container.appendChild(html`
-
- `)
- this.toolbarBtns = {}
- DOM.each(this.toolbar, '.btn', (item)=>{
- var action = item.getAttribute('data-action')
- if (action) {
- if (action !== 'selected-id') item.setAttribute('title', locales('inspector_' + action.replace('-', '_')))
- this.toolbarBtns[action] = item
- }
- })
- zoom.on('local-zoom-changed',()=>{
- this.toolbarBtns['zoom-out'].classList.toggle('active', zoom.localZoom < 1)
- this.toolbarBtns['zoom-in'].classList.toggle('active', zoom.localZoom > 1)
- })
-
-
- this.content = this.container.appendChild(html`
`)
-
- this.container.addEventListener('fast-click', (e)=>{
-
- if (e.target.classList.contains('category-header')) {
- var name = e.target.getAttribute('data-name')
-
- if (e.detail.altKey) {
- DOM.each(this.container, 'osc-inspector-category.expanded', (item)=>{
- let iname = item.firstChild.getAttribute('data-name'),
- index = this.expandedCategories.indexOf(iname)
- if (iname !== name) {
- if (index > -1) this.expandedCategories.splice(index, 1)
- item.classList.remove('expanded')
- }
- })
- }
- var expandedIndex = this.expandedCategories.indexOf(name)
- e.target.parentNode.classList.toggle('expanded', expandedIndex < 0)
- if (expandedIndex > -1) {
- this.expandedCategories.splice(expandedIndex, 1)
- } else {
- this.expandedCategories.push(name)
- }
-
- } else if (e.target.classList.contains('toolbar-btn')) {
-
- switch (e.target.getAttribute('data-action')) {
- case 'zoom-out':
- zoom.setLocalZoom(zoom.localZoom - 0.1)
- break
- case 'zoom-reset':
- zoom.setLocalZoom(1)
- break
- case 'zoom-in':
- zoom.setLocalZoom(zoom.localZoom + 0.1)
- break
- case 'reset-selection':
- editor.unselect()
- break
- case 'toggle-grid':
- editor.toggleGrid()
- break
- }
-
- }
-
- })
- this.parentContainer = DOM.get('osc-panel-container.right')[0]
-
- this.colorPicker = new UiColorPicker()
- this.colorPicker.on('change', (event)=>{
- var textarea = DOM.get(this.container, `textarea[name="${this.colorPicker.name}"]`)
- if (textarea) {
- textarea[0].value = this.colorPicker.value
- DOM.dispatchEvent(textarea[0], 'change', event)
- }
- })
-
- this.container.addEventListener('click', (e)=>{
-
- var node = e.target
-
- if (node.tagName === 'OSC-INSPECTOR-CHECKBOX') {
-
- let name = node.getAttribute('name'),
- textarea = DOM.get(this.container, `textarea[name="${name}"]`)
-
- if (textarea) {
- fastdom.mutate(()=>{
- textarea[0].value = !node.classList.contains('on')
- DOM.dispatchEvent(textarea[0], 'change')
- })
- }
-
- } else if (node.tagName === 'OSC-INSPECTOR-COLOR') {
-
- let name = node.getAttribute('name')
-
- if (this.colorPicker.name === name) {
- this.colorPicker.close()
- } else {
- this.colorPicker.setParent(node.parentNode)
- this.colorPicker.setName(name)
- this.colorPicker.setValue(node.getAttribute('value'))
- this.colorPicker.open()
- }
-
- } else if (node.tagName === 'LABEL') {
-
- this.help(node.textContent)
-
- }
-
- })
-
-
- this.container.addEventListener('change', this.onChange.bind(this))
- this.container.addEventListener('keydown', this.onKeydown.bind(this))
- this.container.addEventListener('input', this.onInput.bind(this))
-
- this.lock = false
- this.clearTimeout = null
-
- this.helpModalOpened = false
-
- }
-
- clear() {
-
- this.clearTimeout = setTimeout(()=>{
- this.widget = null
- this.content.innerHTML = ''
- this.toolbarBtns['selected-id'].firstChild.innerHTML = ''
- this.mounted = false
- this.clearTimeout = null
- this.colorPicker.close()
- this.parentContainer.classList.remove('editor-breakout')
- })
-
- }
-
- inspect(widgets) {
-
- if (this.clearTimeout) {
- clearTimeout(this.clearTimeout)
- this.clearTimeout = null
- }
-
-
- var widget = widgets[0],
- lock = widgets.some(w=>w.getProp('lock')),
- props = defaults[widget.props.type],
- codeEditorFields = []
-
- this.widget = widget
-
- var content = html`
`
-
- for (let categoryName in props) {
-
- if (categoryName === 'children') continue
-
- let category = html` `,
- categoryLabel = categoryName === 'class_specific' ? widget.props.type : categoryName
-
- if (widgets.length > 1 && categoryName === 'class_specific') categoryLabel = 'shared properties'
-
- category.appendChild(html`
-
- `)
-
- let notEmpty
- let field
-
- for (let propName in props[categoryName]) {
-
- // skip if property is not shared between selected widgets
- if (widgets.some((w)=>{
- let shared = false
- for (let c in defaults[widget.props.type]) {
- if (defaults[w.props.type][c] && defaults[w.props.type][c].hasOwnProperty(propName)) {
- shared = true
- break
- }
- }
- return !shared
- })) continue
-
- if (propName.includes('_separator')) {
- if (field) field.classList.add('last-child')
- field = html`${props[categoryName][propName]}
`
- } else {
- var def = defaults[widget.props.type][categoryName][propName]
- if (field && def.editor) field.classList.add('last-child')
- var first = !field || field.classList.contains('separator')
- field = new UiInspectorField({
- parent: this,
- widget: widget,
- name: propName,
- value: widget.props[propName],
- default: def,
- }).container
- if (first) field.classList.add('first-child')
-
- if (def.editor) {
- codeEditorFields.push([propName, def.editor, def.syntaxChecker, widget])
- field.classList.add('has-editor')
- }
- }
-
- if (field) {
- category.appendChild(field)
- notEmpty = true
- }
-
- }
-
- if (notEmpty) {
- content.appendChild(category)
- }
-
- }
-
- this.lock = true
-
- morph(this.content, content)
-
- this.toolbarBtns['selected-id'].firstChild.innerHTML = widgets.map(x=>x.getProp('id')).join(', ')
-
- if (codeEditorFields.length) {
- let fields = DOM.get(this.container, '.has-editor')
- for (var i in codeEditorFields) {
- let [propName, language, syntax, widget] = codeEditorFields[i]
- let codeEditor = getCodeEditor(this, propName, language, syntax)
- codeEditor.bind(widget, fields[i])
- }
- }
-
- this.mounted = true
- this.lock = false
-
- if (this.colorPicker.opened) {
-
- var picker = DOM.get(this.container, `osc-inspector-color[name="${this.colorPicker.name}"]`)
- if (picker && picker[0]) {
- this.colorPicker.setValue(picker[0].getAttribute('value'))
- this.colorPicker.open()
- } else {
- this.colorPicker.close()
- }
-
- }
-
-
- }
-
- onChange(event) {
-
- if (this.lock) return
-
- this.lock = true
-
- var input = this.focusedInput || event.target
-
- this.focusedInput = null
-
- input.blur()
-
- if (document.activeElement === input._ace_input) input._ace_input.blur()
-
- var value = input.value,
- str = value.replace(/[‟“”]/g, '"').replace(/[‘’]/g, '\''), // convert invalid quote characters
- v
-
- try {
- v = JSON5.parse(str)
- } catch(err) {
- v = str
- }
-
- this.trigger('update', {
- propName: input.name,
- value: v,
- preventHistory: event && event.detail && event.detail.preventHistory
- })
-
- // this may not be reached if an error is thrown
- // but the lock will undone at the next inspect() call
- this.lock = false
- }
-
- onKeydown(event) {
-
- if (event.target.tagName === 'TEXTAREA') {
-
- if (event.key == 'Enter' &&
- ((!event.shiftKey && !event.target._ace) ||
- (event[codeEditorModKey] && event.target._ace))
- ) {
-
- event.preventDefault()
- DOM.dispatchEvent(event.target, 'change')
-
- } else if (event.key == 'Escape') {
-
- event.preventDefault()
- event.target.value = event.target.textContent
- event.target.blur()
-
- }
-
- } else if ((event.key == 'Enter' || event.key == ' ') && event.target.classList.contains('category-header')) {
-
- event.preventDefault()
- DOM.dispatchEvent(event.target, 'fast-click', {})
-
- }
-
- }
-
- onInput(event) {
-
- if (event.target._ace) return
-
- this.focusedInput = event.target
-
- // text autoheight
- this.focusedInput.setAttribute('rows',0)
- this.focusedInput.setAttribute('rows', this.focusedInput.value.split('\n').length)
-
- }
-
- help(name) {
-
- var _defaults = defaults[this.widget.getProp('type')],
- category = Object.keys(_defaults).find(x=>_defaults[x].hasOwnProperty(name)),
- defaultValue = _defaults[category][name],
- dynamic = this.widget.isDynamicProp(name),
- htmlHelp = Array.isArray(defaultValue.help) ? defaultValue.help.join(' ').replace(/ -/g, '-') : defaultValue.help
-
- htmlHelp = htmlHelp ? html`${raw(htmlHelp.replace(/`([^`]*)`/g, '$1'))}
` : ''
-
- DOM.each(htmlHelp, 'a', (el)=>{
- el.target = '_blank'
- })
-
- var computedValue = this.widget.getProp(name)
-
- if (typeof computedValue === 'string') {
- try {
- computedValue = JSON.stringify(JSON.parse(computedValue), null, ' ')
- } catch(e) {}
- } else {
- computedValue = JSON.stringify(computedValue, null, ' ')
- }
-
- var modal = new UiModal({closable: true, title: html`${name} `, html: true, content: html`
-
-
-
-
- ${htmlHelp}
-
-
-
Computed property: ${computedValue || 'empty'}
-
- ${name === 'value' ? raw(`
-
-
Current value: ${JSON.stringify(this.widget.getValue())}
-
- `): ''}
-
- `})
-
-
- this.helpModalOpened = true
- modal.on('close', ()=>{
- this.helpModalOpened = false
- })
-
- }
-
-}
-
-export default UiInspector
diff --git a/src/client/ui/ui-keyboard.mjs b/src/client/ui/ui-keyboard.mjs
deleted file mode 100644
index ad4767d3..00000000
--- a/src/client/ui/ui-keyboard.mjs
+++ /dev/null
@@ -1,481 +0,0 @@
-import html from 'nanohtml'
-import raw from 'nanohtml/raw'
-import morph from 'nanomorph'
-import UiWidget from './ui-widget.mjs'
-import {icon} from './utils.mjs'
-import locales from '../locales/index.mjs'
-import doubleClick from '../events/double-click.mjs'
-import {DOM, VIRTUAL_KEYBOARD} from '../globals.mjs'
-
-var layout = locales('keyboard_layout')
-
-const numericLayout = [
- '{sep} + 7 8 9',
- '{sep} - 4 5 6',
- '{sep} * 1 2 3',
- '{sep} / {up} 0 .',
- '{sep} {left} {down} {right} {enter}'
-]
-const keysDisplay = {
- '{esc}': locales('keyboard_escape'),
- '{bksp}': icon('delete-left'),
- '{enter}': icon('arrow-turn-down.rotate-90'),
- '{lock}': icon('arrow-up-from-bracket'),
- '{shift}': icon('arrow-up'),
- '{tab}': icon('arrow-right-arrow-left'),
- '{space}': ' ',
- '{left}': icon('arrow-left'),
- '{right}': icon('arrow-right'),
- '{up}': icon('arrow-up'),
- '{down}': icon('arrow-down'),
-
-}
-
-class OscKeybard extends UiWidget {
-
- constructor(options) {
-
- super(options)
-
- this.keys = {}
- this.pressedKeys = {}
- this.repeatKeys = {}
- this.lock = false
- this.shift = false
- this.input = null
- this.value = null
- this.visible = false
- this.selectionInit = 0
-
- this.display = html` `
- this.container.appendChild(html`${this.display}
`)
-
- for (var k in layout) {
- layout[k] = layout[k].map((r, i)=>(r + ' ' + (numericLayout[i]||'')).trim().split(' '))
- }
-
- var keyId = 0
-
- for (var i = 0; i < layout.default.length; i++) {
- var rowData = layout.default[i],
- row = html`
`
-
- for (var j = 0; j < rowData.length; j++) {
- var keyData = rowData[j],
- shiftData = layout.shift[i][j],
- key = html`
-
- ${raw(keysDisplay[keyData] || keyData)}
- ${raw(keysDisplay[shiftData] || shiftData)}
- `
-
- keyId++
- this.keys[keyId] = key
- key.appendChild = keysDisplay[keyData] || keyData
-
- key.classList.add(keyData.replace('{', '').replace('}', ''))
-
- key.setAttribute('data-id', keyId)
- key.setAttribute('data-key', keyData)
- key.setAttribute('data-shift', shiftData)
-
- row.appendChild(key)
- }
- this.container.appendChild(row)
- }
-
- this.container.addEventListener('mousedown', (e)=>{
- // prevent keyboard from stealing focus from input
- e.preventDefault()
-
- }, {capture: true})
-
-
- this.on('draginit', (e)=>{
-
- if (this.pressedKeys[e.pointerId]) return
-
- if (e.target.tagName === 'KEY') {
-
- var keyId = e.target.getAttribute('data-id')
-
- if (keyId === null) return
-
- var key = this.keys[keyId]
-
- if (key.getAttribute('data-key') === '{lock}') {
- this.lock = !this.lock
- key.classList.toggle('active', this.lock)
- } else {
- key.classList.add('active')
- this.pressedKeys[e.pointerId] = key
- }
-
- this.checkShift()
-
- this.repeatKeys[e.pointerId] = [
- setTimeout(()=>{
- this.repeatKeys[e.pointerId][1] = setInterval(()=>{
- this.keyDown(key.getAttribute(this.shift !== this.lock ? 'data-shift' : 'data-key'))
- }, 50)
- },800)
- ]
-
- this.keyDown(key.getAttribute(this.shift !== this.lock ? 'data-shift' : 'data-key'))
-
- } else if (e.target.tagName === 'CHAR') {
-
- // move cursor
- if (this.display.contains(e.target) && e.target !== this.display) {
- var pos = DOM.index(e.target)
- // adjust cursor depening on where we clicked on the letter
- if (e.offsetX - DOM.offset(e.target).left >= e.target.offsetWidth / 2)
- pos += 1
-
- this.input.selectionStart = pos
- this.selectionInit = pos
- if (!e.shiftKey) {
- this.input.selectionEnd = pos
- }
- this.clickHandler()
- }
-
- }
-
-
- }, {element: this.container, multitouch: true})
-
- doubleClick(this.display, ()=>{
- this.input.selectionStart = 0
- this.input.selectionEnd = this.input.value.length
- this.clickHandler()
- })
-
- this.on('drag', (e)=>{
-
- if (e.target.tagName === 'CHAR') {
-
- // move cursor
- if (this.display.contains(e.target) && e.target !== this.display) {
- var pos = DOM.index(e.target)
- // adjust cursor depening on where we clicked on the letter
- if (e.offsetX - DOM.offset(e.target).left >= e.target.offsetWidth / 2)
- pos += 1
-
- if (pos < this.selectionInit) {
- this.input.selectionStart = pos
- } else {
- this.input.selectionEnd = pos
- }
-
- this.clickHandler()
- }
-
- }
-
- }, {element: this.container, multitouch: true})
-
- this.on('dragend', (e)=>{
-
- if (!this.pressedKeys[e.pointerId]) return
-
- var key = this.pressedKeys[e.pointerId],
- keyData = key.getAttribute('data-key')
-
- key.classList.remove('active')
-
- if (keyData === '{lock}') return
-
- delete this.pressedKeys[e.pointerId]
-
- clearTimeout(this.repeatKeys[e.pointerId][0])
- clearInterval(this.repeatKeys[e.pointerId][1])
-
- this.checkShift()
-
- }, {element: this.container, multitouch: true})
-
-
- document.addEventListener('focus', (e)=>{
- if (!VIRTUAL_KEYBOARD) return
- // show keyboard when entering input focus
- if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') {
- setTimeout(()=>{
- this.show(e.target)
- })
- }
- }, {capture: true})
-
-
- this.boundSelectHandler = this.selectHandler.bind(this)
- this.boundBlurHandler = this.blurHandler.bind(this)
- this.boundKeydownHandler = this.keydownHandler.bind(this)
- this.boundChangeHandler = this.changeHandler.bind(this)
- this.boundInputHandler = this.inputHandler.bind(this)
- this.boundClickHandler = this.clickHandler.bind(this)
-
- }
-
- keyDown(key) {
-
- if (!this.input) return
-
- var startPos = this.input.selectionStart,
- endPos = this.input.selectionEnd,
- editLength, str
-
- switch (key) {
- case '{lock}':
- case '{shift}':
- return
- case '{esc}':
- this.input.value = this.value
- this.input.blur()
- return
- case '{enter}':
- if (this.shift) {
- str = '\n'
- editLength = 1
- break
- } else {
- DOM.dispatchEvent(this.input, 'change')
- return
- }
- case '{bksp}':
- if (startPos === endPos && startPos === 0) break
- this.input.value = this.input.value.substring(0, startPos - 1)
- + this.input.value.substring(endPos, this.input.value.length)
- editLength = -1
- break
- case '{tab}':
- str = ' '
- break
- case '{space}':
- str = ' '
- break
- case '{left}':
- this.input.selectionStart = this.input.selectionEnd = Math.max(this.input.selectionStart - 1, 0)
- this.keydownHandler()
- return
- case '{right}':
- this.input.selectionStart = this.input.selectionEnd = this.input.selectionStart + 1
- this.keydownHandler()
- return
- case '{up}':
- case '{down}':
- if (this.input.value.includes('\n')) {
- var chars = this.input.value.split('\n').map(x=>x.length + 1),
- line = 0,
- charCount = 0,
- newPos = 0,
- posAtLine
-
- for (let i = 0; i < chars.length; i++) {
- charCount += chars[i]
- if (charCount > this.input.selectionStart) {
- posAtLine = chars[i] - (charCount - this.input.selectionStart)
- break
- }
- line++
- }
- line = key === '{up}' ? line - 1 : line + 1
- for (let i = 0; i < line; i++) {
- newPos += chars[i]
- }
- if (posAtLine > chars[line] - 1) posAtLine = chars[line] - 1
-
- this.input.selectionStart =
- this.input.selectionEnd = newPos + posAtLine
- } else {
- this.input.selectionStart =
- this.input.selectionEnd = key === '{up}' ? 0 : this.input.value.length
- }
- this.keydownHandler()
- return
- default:
- str = key
- break
- }
-
- if (str !== undefined) {
-
- this.input.value = this.input.value.substring(0, startPos)
- + str
- + this.input.value.substring(endPos, this.input.value.length)
-
- if (editLength === undefined) editLength = str.length
-
- }
-
- this.input.selectionStart = startPos + editLength
- this.input.selectionEnd = startPos + editLength
-
- this.inputHandler()
-
- }
-
- checkShift() {
-
- var shift = false
- for (var k in this.pressedKeys) {
- var dataKey = this.pressedKeys[k].getAttribute('data-key')
- if (dataKey === '{shift}') {
- shift = true
- }
- }
- this.shift = shift
- this.container.classList.toggle('shift', this.lock !== this.shift)
-
- }
-
- updateDisplay() {
-
- var value = ''
-
- if (this.input) value = this.input.value
-
- var content = html` `
- for (var i in value) {
- let c, nl
- switch (value[i]) {
- case '\n':
- c = raw('')
- nl = true
- break
- case ' ':
- c = raw(' ')
- break
- default:
- c = value[i]
- break
- }
- content.appendChild(html`
- ${c}
- `)
- }
-
- morph(this.display, content)
-
- setTimeout(()=>{
- this.updateCursor()
- })
- }
-
- updateCursor() {
-
- if (!this.input) return
-
- var start = this.input.selectionStart,
- end = this.input.selectionEnd
-
-
- this.display.classList.remove('first-char-caret')
- DOM.each(this.display, 'char', (el)=>{
- el.classList.remove('caret')
- el.classList.remove('select')
- })
-
- if (start === null || end === null) return
-
- var caretChar = DOM.get(this.display, 'char:nth-child(' + start + ')')[0]
-
- if (caretChar) {
- caretChar.classList.add('caret')
- caretChar.scrollIntoView()
- }
- else this.display.classList.add('first-char-caret')
- if (start !== end) {
- DOM.each(this.display, 'char:nth-child(n+' + (start + 1) + '):nth-child(-n+' + (end ) +')', (el)=>{
- el.classList.add('select')
- })
- }
-
- }
-
- show(input){
-
- if (input.osc_input) return // not compatible with code editor
- if (this.visible) return
-
- this.input = input
- this.value = this.input.value
-
- this.input.addEventListener('blur', this.boundBlurHandler)
- this.input.addEventListener('input', this.boundInputHandler)
- this.input.addEventListener('change', this.boundChangeHandler)
- this.input.addEventListener('keydown', this.boundKeydownHandler)
- this.input.addEventListener('select', this.boundSelectHandler)
- this.input.addEventListener('click', this.boundClickHandler)
-
- this.updateDisplay()
-
- this.container.style.display = 'flex'
-
- this.visible = true
-
- }
-
- hide(){
-
- if (!this.visible) return
-
- this.input.removeEventListener('blur', this.boundBlurHandler)
- this.input.removeEventListener('input', this.boundInputHandler)
- this.input.removeEventListener('change', this.boundChangeHandler)
- this.input.removeEventListener('keydown', this.boundKeydownHandler)
- this.input.removeEventListener('select', this.boundSelectHandler)
- this.input.removeEventListener('click', this.boundClickHandler)
-
- this.input = null
- this.value = null
-
-
- this.container.style.display = 'none'
-
- this.visible = false
-
- for (let k in this.repeatKeys) {
- clearTimeout(this.repeatKeys[k][0])
- clearInterval(this.repeatKeys[k][1])
- }
-
- for (let k in this.pressedKeys) {
- this.pressedKeys[k].classList.remove('active')
- delete this.pressedKeys[k]
- }
- }
-
-
- blurHandler(e) {
- setTimeout(()=>{
- this.hide()
- })
- }
- inputHandler(e) {
- setTimeout(()=>{
- this.updateDisplay()
- })
- }
- changeHandler(e) {
- setTimeout(()=>{
- this.hide()
- })
- }
- keydownHandler(e) {
- setTimeout(()=>{
- this.updateCursor()
- })
- }
- selectHandler(e) {
- setTimeout(()=>{
- this.updateCursor()
- })
- }
- clickHandler(e) {
- setTimeout(()=>{
- this.updateCursor()
- })
- }
-}
-
-export default new OscKeybard({element: DOM.get('osc-keyboard')[0]})
diff --git a/src/client/ui/ui-loading.mjs b/src/client/ui/ui-loading.mjs
deleted file mode 100644
index 24bcdc2b..00000000
--- a/src/client/ui/ui-loading.mjs
+++ /dev/null
@@ -1,22 +0,0 @@
-import notifications from './notifications.mjs'
-
-var loading = null, timeout = null
-
-export default function(title) {
-
- if (title === false && loading) {
- clearTimeout(timeout)
- timeout = setTimeout(()=>{
- notifications.remove(loading)
- loading = null
- }, 500)
- } else if (title !== false) {
- notifications.add({
- id: 'LOADING',
- icon: 'spinner fa-spin',
- message: title
- })
- loading = notifications.toasts[notifications.toasts.length - 1]
- }
-
-}
diff --git a/src/client/ui/ui-modal.mjs b/src/client/ui/ui-modal.mjs
deleted file mode 100644
index 0c8f7e49..00000000
--- a/src/client/ui/ui-modal.mjs
+++ /dev/null
@@ -1,107 +0,0 @@
-import html from 'nanohtml'
-import raw from 'nanohtml/raw'
-import UiWidget from './ui-widget.mjs'
-import {icon} from './utils.mjs'
-import {DOM} from '../globals.mjs'
-
-var MODAL_SINGLETON = null,
- MODAL_CONTAINER = null
-
-class UiModal extends UiWidget {
-
- constructor(options) {
-
- super(options)
-
- if (!MODAL_CONTAINER) MODAL_CONTAINER = DOM.get('osc-modal-container')[0]
-
- if (options.closable) {
-
- if (MODAL_SINGLETON) MODAL_SINGLETON.close()
- MODAL_SINGLETON = this
-
- }
-
- this.escKey = options.closable || options.escKey
- this.enterKey = options.enterKey
- this.state = 0
-
- this.container = html`
-
- `
-
- if (options.width) this.container.style.setProperty('--width', options.width + 'rem')
- if (options.height) this.container.style.setProperty('--height', options.height + 'rem')
-
- if (options.closable) {
- var closer = DOM.get(this.container, '.popup-title .closer')[0]
- this.container.addEventListener('fast-click',(e)=>{
- if (e.target === this.container || e.target === closer) {
- e.detail.preventOriginalEvent = true
- this.close()
- }
- })
- }
-
- if (this.escKey) {
- this.escKeyHandler = ((e)=>{
- if (e.key == 'Escape') this.close()
- }).bind(this)
- }
-
- if (this.enterKey) {
- this.enterKeyHandler = ((e)=>{
- if (e.key == 'Enter') this.enterKey.call(this, e)
- }).bind(this)
- }
-
- if (!options.hide) this.open()
-
-
- }
-
-
-
- close() {
-
- if (!this.state) return
- this.state = 0
-
- if (this.escKey) document.removeEventListener('keydown', this.escKeyHandler)
- if (this.enterKey) document.removeEventListener('keydown', this.enterKeyHandler)
-
- MODAL_CONTAINER.removeChild(this.container)
-
- this.trigger('close')
-
- }
-
- open() {
-
- if (this.state) return
- this.state = 1
-
- if (this.escKey) document.addEventListener('keydown', this.escKeyHandler)
- if (this.enterKey) document.addEventListener('keydown', this.enterKeyHandler)
-
- MODAL_CONTAINER.appendChild(this.container)
-
- this.trigger('open')
- }
-
-}
-
-export default UiModal
diff --git a/src/client/ui/ui-selectarea.mjs b/src/client/ui/ui-selectarea.mjs
deleted file mode 100644
index 1ef816a7..00000000
--- a/src/client/ui/ui-selectarea.mjs
+++ /dev/null
@@ -1,129 +0,0 @@
-import html from 'nanohtml'
-import {DOM} from '../globals.mjs'
-
-class UiSelectArea {
-
- constructor(selector, callback){
-
- this.startX = 0
- this.startY = 0
- this.curX = 0
- this.curY = 0
-
- this.rectCoords = [0, 0, 0, 0]
- this.rectSize = [0, 0]
- this.elements = []
-
- this.rect = document.body.appendChild(html`
`)
-
- this.selector = selector
- this.callback = callback
-
- this.boundMousedown = this.mousedown.bind(this)
- this.boundMousemove = this.mousemove.bind(this)
- this.boundMouseup = this.mouseup.bind(this)
-
- }
-
- mousedown(e) {
- if (!e.shiftKey || event.altKey || event.button === 2 || (event.shiftKey && event.metaKey)) return
- this.startX = this.curX = e.clientX
- this.startY = this.curY = e.clientY
- this.down = true
- this.updateRect()
- }
-
- mousemove(e) {
- if (!this.down) return
- e.preventDefault()
- e.stopPropagation()
- this.curX = e.clientX
- this.curY = e.clientY
- this.updateRect()
- }
-
- mouseup(e) {
- if (!this.down) return
- this.down = false
-
- if (this.rectSize[0] > 0 && this.rectSize[1] > 0) {
- this.callback(this.getElements(), e)
- this.rect.classList.add('hidden')
- }
-
- this.elements = []
-
- }
-
- updateRect() {
-
- var x0 = Math.min(this.startX, this.curX),
- y0 = Math.min(this.startY, this.curY),
- x1 = Math.max(this.startX, this.curX),
- y1 = Math.max(this.startY, this.curY),
- w = x1 - x0,
- h = y1 - y0
-
- if (w < 1 || h < 1) {
- this.rect.classList.add('hidden')
- } else {
- this.rect.classList.remove('hidden')
- this.rect.setAttribute('style', `width:${w}px;height:${h}px;left:${x0}px;top:${y0}px`)
- }
-
- this.rectSize = [w, h]
- this.rectCoords = [x0, x1, y0, y1]
-
- }
-
- getElements(){
-
- var [x0, x1, y0, y1] = this.rectCoords,
- startEl = document.elementFromPoint(this.startX, this.startY),
- elements = [startEl]
-
- this.elements = DOM.each(document, this.selector, (el)=>{
-
- var {left, right, top, bottom} = el.getBoundingClientRect()
- if (!(
- left > x1 ||
- right < x0 ||
- top > y1 ||
- bottom < y0
- )) {
- if (el !== startEl) elements.push(el)
- }
-
- })
-
- // slower implementation...
- // for (var x = x0; x <= x1; x += 10) {
- // for (var y = y0; y <= y1; y += 10) {
- // var el = document.elementFromPoint(x, y)
- // if (elements.indexOf(el) < 0) elements.push(el)
- // }
- // }
-
- return elements
-
- }
-
- enable() {
-
- document.addEventListener('pointerdown', this.boundMousedown)
- document.addEventListener('pointermove', this.boundMousemove, true)
- document.addEventListener('pointerup', this.boundMouseup)
-
- }
-
- disable() {
-
- document.removeEventListener('pointerdown', this.boundMousedown)
- document.removeEventListener('pointermove', this.boundMousemove, true)
- document.removeEventListener('pointerup', this.boundMouseup)
-
- }
-
-}
-
-export default UiSelectArea
diff --git a/src/client/ui/ui-sidepanel.mjs b/src/client/ui/ui-sidepanel.mjs
deleted file mode 100644
index b571374f..00000000
--- a/src/client/ui/ui-sidepanel.mjs
+++ /dev/null
@@ -1,139 +0,0 @@
-import UiWidget from './ui-widget.mjs'
-import cache from '../managers/cache.mjs'
-import {DOM, PXSCALE} from '../globals.mjs'
-
-class UiSidePanel extends UiWidget {
-
- constructor(options) {
-
- super(options)
-
- if (options.label) DOM.get(this.container, 'osc-panel-header')[0].textContent = options.label
-
- this.vertical = this.container.classList.contains('bottom') || this.container.classList.contains('top')
- this.resizeDirection = this.container.classList.contains('left') || this.container.classList.contains('top') ? 1 : -1
- this.resizeHandle = DOM.get(this.container, '.resize-handle')[0]
- this.toggleButton = DOM.get(this.container, '.toggle-button')[0]
- this.content = DOM.get(this.container, 'osc-panel-content')[0]
-
- this.cacheKey = 'ui.' + options.selector
-
- 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 : 350)
-
- this.disabled = false
- var minimized = cache.get(this.cacheKey + '.minimized')
- this.minimized = minimized !== null ? minimized : (options.minimized || false)
- this.init = false
-
-
- this.on('draginit', (event)=>{
-
- this.width = parseInt(this.container[this.vertical ? 'offsetHeight' : 'offsetWidth']) / PXSCALE
-
- }, {element: this.resizeHandle})
-
- this.on('drag', (event)=>{
-
- this.width += this.resizeDirection * event[this.vertical ? 'movementY' : 'movementX'] / PXSCALE
- this.updateWidth()
-
- }, {element: this.resizeHandle})
-
- this.on('dragend', (event)=>{
-
- this.width = parseInt(this.container[this.vertical ? 'offsetHeight' : 'offsetWidth']) / PXSCALE
- cache.set(this.cacheKey + '.width', this.width)
- DOM.dispatchEvent(window, 'resize')
-
- }, {element: this.resizeHandle})
-
- this.toggleButton.addEventListener('click', ()=>{
-
- if (this.disabled) return
-
- if (this.minimized) this.restore()
- else this.minimize()
-
- })
-
- this.updateWidth()
- this.disable()
-
- }
-
- enable() {
-
- this.container.classList.remove('disabled')
- this.disabled = false
-
- if (!this.minimized) this.open()
-
- }
-
- disable() {
-
- this.container.classList.add('disabled')
- this.disabled = true
-
- this.close()
-
- }
-
- minimize() {
-
- if (this.minimized) return
-
- this.minimized = true
- cache.set(this.cacheKey + '.minimized', true)
-
- if (!this.disabled) this.close()
-
-
- }
-
- restore() {
-
- if (!this.minimized) return
-
- this.minimized = false
- cache.set(this.cacheKey + '.minimized', false)
-
- if (!this.disabled) this.open()
-
-
- }
-
- updateWidth() {
-
- this.container.style[this.vertical ? 'height' : 'width'] = this.width + 'rem'
- this.container.style.setProperty('--sidepanel-size', this.width + 'rem')
-
- }
-
- open() {
-
- this.container.style[this.vertical ? 'height' : 'width'] = this.width + 'rem'
- this.container.style[this.vertical ? 'minHeight' : 'minWidth'] = this.minWidth + 'rem'
- this.container.classList.remove('minimized')
-
- DOM.dispatchEvent(window, 'resize')
-
- }
-
- close() {
-
- this.container.style[this.vertical ? 'height' : 'width'] = 0
- this.container.style[this.vertical ? 'minHeight' : 'minWidth'] = 0
- this.container.classList.add('minimized')
-
- DOM.dispatchEvent(window, 'resize')
-
- }
-
-}
-
-
-
-export default UiSidePanel
diff --git a/src/client/ui/ui-toolbar.mjs b/src/client/ui/ui-toolbar.mjs
deleted file mode 100644
index 1daa090c..00000000
--- a/src/client/ui/ui-toolbar.mjs
+++ /dev/null
@@ -1,63 +0,0 @@
-import UiWidget from './ui-widget.mjs'
-import ContextMenu from './context-menu.mjs'
-
-class UiToolbar extends UiWidget {
-
- constructor(options) {
-
- super(options)
-
- this.menu = new ContextMenu({
- position: options.position
- })
- this.opened = false
- this.entries = options.entries
-
- this.menu.bindShortcuts(this.entries)
-
- this.container.addEventListener('fast-click', (e)=>{
- if (this.opened) this.close()
- else this.open(e)
- })
-
- this.menu.on('close', ()=>{
- setTimeout(()=>{
- this.opened = false
- this.toggleState()
- })
- })
-
- }
-
- open(e) {
-
- if (this.opened) return
- this.menu.open(e.detail, this.entries)
-
- this.opened = true
- this.toggleState()
-
-
- }
-
- close() {
-
- if (this.opened) return
-
- this.menu.close()
-
- this.opened = false
- this.toggleState()
-
- }
-
- toggleState() {
-
- this.container.classList.toggle('on', this.opened)
-
- }
-
-}
-
-
-export default UiToolbar
diff --git a/src/client/ui/ui-tree.mjs b/src/client/ui/ui-tree.mjs
deleted file mode 100644
index 42afb6c4..00000000
--- a/src/client/ui/ui-tree.mjs
+++ /dev/null
@@ -1,369 +0,0 @@
-import UiWidget from './ui-widget'
-import html from 'nanohtml'
-import doubleClick from '../events/double-click'
-import Sortable from 'sortablejs'
-import morph from 'nanomorph'
-import locales from '../locales'
-import raw from 'nanohtml/raw'
-import {icon} from './utils.mjs'
-import {widgets, categories} from '../widgets/index.mjs'
-import {DOM} from '../globals.mjs'
-
-var Root, Panel, Matrix, Keyboard, widgetManager
-;(async()=>{
- Root = (await import('../widgets/containers/root.mjs')).default
- Panel = (await import('../widgets/containers/panel.mjs')).default
- Matrix = (await import('../widgets/containers/matrix.mjs')).default
- Keyboard = (await import('../widgets/containers/keyboard.mjs')).default
- widgetManager = (await import('../managers/widgets.mjs')).default
-})()
-
-
-var widgetIcons = {
- root: 'bookmark',
- tab: 'window-maximize',
- folder: 'folder',
- menu: 'list',
- dropdown: 'list',
- switch: 'list',
- input: 'i-cursor',
- file: 'file-import',
- modal: 'window-restore',
- clone: 'cube',
- fragment: 'cube',
- patchbay: 'project-diagram',
- frame: 'globe'
-
-}
-
-var categoryIcons = {
- 'Basics': 'toggle-on',
- 'Containers': 'table-list',
- 'Frames': 'images',
- 'Graphs': 'chart-area',
- 'Indicators': 'info-circle',
- 'Pads': 'crosshairs',
- 'Sliders': 'sliders-h.rotate-90',
- 'Scripts': 'code',
-}
-
-for (var type in widgets) {
- if (widgetIcons[type]) continue
- for (var cat in categoryIcons) {
- if (categories[cat].includes(type)) {
- widgetIcons[type] = categoryIcons[cat]
- }
- }
-}
-
-
-class UiTree extends UiWidget {
-
- constructor(options) {
-
- super(options)
-
- this.mounted = false
- this.fragment = this.container.appendChild(html`${locales('fragment_mode_warning')}
`)
- this.filter = this.container.appendChild(html` `)
- this.wrapper = this.container.appendChild(html`
`)
- this.list = this.wrapper.appendChild(html` `
- this.deferredUpdateTimeout = null
-
-
- this.expanded = {}
- this.init = false
-
- this.container.addEventListener('fast-click', (event)=>{
-
- var node = event.target
- if (node.classList.contains('toggle')) {
- var exp = node.parentNode.classList.toggle('expanded')
- if (exp) {
- this.expanded[node.parentNode.getAttribute('data-widget')] = true
- } else {
- delete this.expanded[node.parentNode.getAttribute('data-widget')]
- }
- }
-
-
- })
-
- doubleClick(this.container, (event)=>{
-
- var node = event.target
- if (node.classList.contains('container')) {
- var exp = node.classList.toggle('expanded')
- if (exp) {
- this.expanded[node.getAttribute('data-widget')] = true
- } else {
- delete this.expanded[node.getAttribute('data-widget')]
- }
- }
-
- }, {ignoreEditorCapture: true})
-
-
- this.sortables = []
- this.sortCallback = (event)=>{
-
- var from = widgetManager.widgets[event.from.getAttribute('data-hash')],
- to = widgetManager.widgets[event.to.getAttribute('data-hash')]
-
- if (!to || (from === to && event.oldIndex === event.newIndex)) return
-
- this.trigger('sorted', {
- oldIndex: event.oldIndex,
- newIndex: event.newIndex,
- from: from,
- to: to
- })
-
- }
-
- this.filter.addEventListener('change', ()=>{
- this.applyFilter()
- })
- var filterTypeTimeout = null
- this.filter.addEventListener('keydown', ()=>{
- clearTimeout(filterTypeTimeout)
- filterTypeTimeout = setTimeout(()=>{
- this.applyFilter()
- }, 100)
- })
-
- }
-
- clear() {
-
- this.list.innerHTML = ''
- this.init = false
- this.mounted = false
- for (var s of this.sortables) {
- s.destroy()
- }
- this.sortables = []
-
- }
-
- updateTree(selectedWidgets) {
-
- if (this.parent.minimized || this.parent.disabled) {
- clearTimeout(this.deferredUpdateTimeout)
- this.deferredUpdateTimeout = setTimeout(()=>{
- this.deferredUpdateTree(selectedWidgets)
- })
- } else {
- this.deferredUpdateTree(selectedWidgets)
- }
-
- }
-
- deferredUpdateTree(selectedWidgets) {
-
- this.deferredUpdateTimeout = null
-
- for (var s of this.sortables) {
- s.destroy()
- }
- this.sortables = []
-
- var content = this.parseWidgets(widgetManager.getWidgetById('root')[0], selectedWidgets)
-
- if (!content) return
-
- // morph DOM
- if (this.mounted) {
- morph(this.list.firstChild, content)
- } else {
- this.list.appendChild(content)
- }
-
-
- // sortable lists
- DOM.each(this.list, 'ol', (el)=>{
- let placeholder = null
- this.sortables.push(new Sortable(el, {
- group: {
- name: 'group',
- pull: (to, from)=>from.el.dataset.childrenType === to.el.dataset.childrenType || to.el.dataset.childrenType === '',
- put: (to, from)=>from.el.dataset.childrenType === to.el.dataset.childrenType || to.el.dataset.childrenType === '',
- },
- onEnd: (e)=>{
- e.from.removeChild(placeholder)
- placeholder = null
- if (e.from === e.to && e.newIndex > e.oldIndex) e.newIndex--
- this.sortCallback(e)
- },
- setData: (dataTransfer)=>{
- dataTransfer.setDragImage(this.dragDummy, 0, 0)
- },
- onStart: (event)=>{
- placeholder = event.from.insertBefore(event.clone.cloneNode(true), event.from.childNodes[event.oldIndex])
- placeholder.style.display = 'block'
- },
- }))
- })
-
- this.mounted = true
- this.applyFilter()
-
- }
-
- showWidget(widget) {
-
- var node = DOM.get(this.list, `[data-widget="${widget.hash}"]`)
- if (node.length) {
- node = node[0]
- var parent = node.parentNode
- while (parent !== this.list) {
- if (parent.classList.contains('container')) {
- parent.classList.add('expanded')
- this.expanded[parent.getAttribute('data-widget')] = true
- }
- parent = parent.parentNode
- }
- var nodeRect = node.classList.contains('container') ? node.firstChild.getBoundingClientRect() : node.getBoundingClientRect(),
- treeRect = this.wrapper.getBoundingClientRect()
-
- if (nodeRect.top < treeRect.top) {
- node.scrollIntoView({block: 'start'})
- } else if (nodeRect.bottom > treeRect.bottom) {
- node.scrollIntoView({block: 'nearest'})
- }
- this.wrapper.scrollLeft = (node.depth - 1) * 20
- }
-
- if (this.parent.minimized) this.parent.restore()
-
- }
-
- blinkSelected() {
-
- DOM.each(this.list, '.editing', (el)=>{
- el.classList.add('editor-blink')
- this.wrapper.scrollLeft = (el.depth - 1) * 20
- setTimeout(()=>{
- el.classList.remove('editor-blink')
- }, 800)
- })
-
- }
-
- showWidgetInSession(widget) {
-
- var parent = widget
- while (parent !== widgetManager) {
- if (parent.getProp('type') === 'tab') parent.parent.setValue(parent.parent.children.indexOf(parent), {sync: true, send: true})
- else if (parent.getProp('type') === 'modal') parent.setValue(1, {sync: true, send: true})
- parent = parent.parent
- }
- widget.container.classList.add('editor-blink')
- widget.container.scrollIntoView({block: 'center'})
- setTimeout(()=>{
- widget.container.classList.remove('editor-blink')
- }, 800)
-
- }
-
- select() {
-
- // hint selection in folded containers
- DOM.each(this.list, '.contains-editing', (element)=>{
- element.classList.remove('contains-editing')
- })
- var selected = DOM.get(this.list, '.editing')[0]
- if (selected) {
- var node = selected.parentNode
- while (node && node !== this.list) {
- if (node.classList.contains('container')) {
- node.classList.add('contains-editing')
- }
- node = node.parentNode
- }
- }
- }
-
- parseWidgets(widget, selectedWidgets, depth = 1) {
-
- if (!widget) return
-
- var selected = selectedWidgets.includes(widget),
- id = widget.getProp('id'),
- node = html`
- ${raw(icon(widgetIcons[widget.getProp('type')] || 'root'))}${id}${widget.getProp('lock')? raw(icon('lock')) :''} `
-
-
- node.depth = depth
-
- if (widget instanceof Panel && !(widget instanceof Matrix || widget instanceof Keyboard)) {
- node.insertBefore(html` `, node.childNodes[0])
- node.classList.add('container')
- if (this.expanded[widget.hash]) node.classList.add('expanded')
- if (!this.init && widget instanceof Root) {
- node.classList.add('expanded')
- this.expanded[widget.hash] = true
- this.init = true
- }
- var sublist = node.appendChild(html` `)
- for (let child of widget.children) {
- if (child) sublist.appendChild(this.parseWidgets(child, selectedWidgets, depth))
- }
-
- }
-
- for (var h in this.expanded) {
- if (!widgetManager.widgets[h]) delete this.expanded[h]
- }
-
- return node
-
- }
-
- applyFilter() {
-
- var filter = this.filter.value.replace(/type\:[^\s]+/g, '').trim(),
- types = this.filter.value.match(/type\:([^\s]+)/g)
-
- if (types) types = types.map(x=>x.split(':')[1])
-
- if (!filter && !types) {
- this.list.classList.remove('filter-active')
- } else {
- this.list.classList.add('filter-active')
-
- var show = []
- DOM.each(this.list, 'li', (element)=>{
- var match = element.innerText.includes(filter)
- if (types && !types.includes(element.dataset.type)) match = false
- element.classList.toggle('filter-hide', !match)
- if (match) show.push(element)
- })
-
- DOM.each(this.list, '.container.filter-hide', (element)=>{
- if (show.some(el=>element.contains(el))) element.classList.remove('filter-hide')
- })
-
- }
-
- }
-
- updateVisibility(widget) {
-
- if (!this.parent.disabled) {
-
- var w = DOM.get(this.list, '[data-widget="' + widget.hash + '"]')[0]
-
- if (w) {
- w.classList.toggle('invisible', !widget.getProp('visible'))
- }
-
- }
-
- }
-
-}
-
-export default UiTree
diff --git a/src/client/ui/ui-widget.mjs b/src/client/ui/ui-widget.mjs
deleted file mode 100644
index 9d8db2b6..00000000
--- a/src/client/ui/ui-widget.mjs
+++ /dev/null
@@ -1,17 +0,0 @@
-import EventEmitter from '../events/event-emitter.mjs'
-import {DOM} from '../globals.mjs'
-
-class UiWidget extends EventEmitter {
-
- constructor(options={}) {
-
- super()
-
- this.container = options.selector ? DOM.get(options.selector)[0] : options.element
- this.parent = options.parent
-
- }
-
-}
-
-export default UiWidget
diff --git a/src/client/ui/ui-workspace.mjs b/src/client/ui/ui-workspace.mjs
deleted file mode 100644
index 41205230..00000000
--- a/src/client/ui/ui-workspace.mjs
+++ /dev/null
@@ -1,16 +0,0 @@
-import UiWidget from './ui-widget.mjs'
-import {setScrollbarColor} from './utils.mjs'
-
-class UiWorkspace extends UiWidget {
-
- constructor(options) {
-
- super(options)
-
- setScrollbarColor(this.container)
-
- }
-
-}
-
-export default new UiWorkspace({selector: 'osc-workspace'})
diff --git a/src/client/ui/utils.mjs b/src/client/ui/utils.mjs
deleted file mode 100644
index c23afcc7..00000000
--- a/src/client/ui/utils.mjs
+++ /dev/null
@@ -1,66 +0,0 @@
-import chroma from 'chroma-js'
-import fastdom from 'fastdom'
-import {UAParser} from 'ua-parser-js'
-import {DOM} from '../globals.mjs'
-
-var {device, os} = UAParser().withFeatureCheck()
-
-export {device, os}
-
-export function icon(i) {
- var iclass = i.split('.').join(' fa-')
- return ` `
-}
-
-export function iconify(string){
- return String(string).replace(/\^[^\s]{2,}/g,(x)=>{return icon(x.substring(1))})
-}
-
-export function setScrollbarColor(container) {
-
- fastdom.measure(()=>{
-
- var computedStyle = window.getComputedStyle(container),
- alpha = parseFloat(computedStyle.getPropertyValue('--alpha-scrollbar')),
- alphaOn = parseFloat(computedStyle.getPropertyValue('--alpha-scrollbar-on')),
- color = computedStyle.getPropertyValue('--color-fill').trim()
-
- if (color === 'transparent') {
- // prevent chroma-js error
- // irrelevant case, but still...
- color = 'rgb(0, 0, 0)'
- alpha = 0
- alphaOn = 0
- }
-
- if (color) {
- fastdom.mutate(()=>{
- try {
- container.style.setProperty('--color-scrollbar', chroma(color).alpha(alpha).css())
- container.style.setProperty('--color-scrollbar-on', chroma(color).alpha(alphaOn).css())
- } catch(e) {}
- })
- }
-
- })
-
-}
-
-export function updateMobileThemeColor(root) {
-
- fastdom.measure(()=>{
-
- var style = window.getComputedStyle(root ? root.widget : document.documentElement),
- color = style.getPropertyValue('--color-background').trim()
-
- fastdom.mutate(()=>{
-
- for (var el of DOM.get('meta[name="theme-color"], meta[name="apple-mobile-web-app-status-bar-style"]')) {
- el.setAttribute('content', color)
- }
-
- })
-
- })
-
-}
diff --git a/src/client/ui/zoom.mjs b/src/client/ui/zoom.mjs
deleted file mode 100644
index a39b0837..00000000
--- a/src/client/ui/zoom.mjs
+++ /dev/null
@@ -1,94 +0,0 @@
-import EventEmitter from '../events/event-emitter.mjs'
-import {DOM, PXSCALE, INITIALZOOM, setPXSCALE} from '../globals.mjs'
-
-var mod = (navigator.platform || '').match('Mac') ? 'metaKey' : 'ctrlKey'
-
-class Zoom extends EventEmitter {
-
- constructor() {
-
- super()
-
- this.localZoom = 1
- this.lastWheelZoom = 0
- this.editor = null
-
- document.addEventListener('wheel', (event)=>{
- if (event.ctrlKey) event.preventDefault()
-
- var now = Date.now()
- if (now - this.lastWheelZoom > 50) {
-
- if (event[mod]) {
-
- event.preventDefault()
-
- if (event.deltaY === 0) return
-
- let d = - event.deltaY / (10 * Math.abs(event.deltaY))
- if (!isNaN(d)) this.setGlobalZoom(d + PXSCALE)
- }
- if (event.altKey) {
- event.preventDefault()
- let d = - event.deltaY / (10 * Math.abs(event.deltaY)) * 2
- if (!isNaN(d)) this.setLocalZoom(d + this.localZoom)
- }
-
- this.lastWheelZoom = now
- }
-
- }, {passive: false})
-
- document.addEventListener('keydown', (event)=>{
- if (event[mod]) {
-
- if (event.key == 'DOM_VK_0' || event.key == 'Numpad0'|| event.code == 'Digit0') {
- event.preventDefault()
- this.setGlobalZoom(INITIALZOOM)
- this.setLocalZoom(1)
- }
- else if (event.key == '+' || event.key == '=' || event.keyCode === 107) {
- event.preventDefault()
- this.setGlobalZoom(PXSCALE + 0.1)
- }
- else if (event.key == '-' || event.keyCode === 109) {
- event.preventDefault()
- this.setGlobalZoom(PXSCALE - 0.1)
- }
-
- }
- }, {passive: false})
-
- }
-
- setLocalZoom(zoom) {
-
- if (this.editor && !this.editor.enabled) return
-
- zoom = Math.max(Math.min(zoom, 4), 0.25)
- if (zoom !== this.localZoom) {
- requestAnimationFrame(()=>{
- this.localZoom = zoom
- document.documentElement.style.setProperty('--local-zoom', this.localZoom)
- document.body.classList.toggle('local-zoom-in', this.localZoom > 1)
- document.body.classList.toggle('local-zoom-out', this.localZoom < 1)
- this.trigger('local-zoom-changed')
- })
- }
-
- }
-
- setGlobalZoom(zoom) {
-
- if (zoom !== PXSCALE) {
- setPXSCALE(zoom)
- document.documentElement.style.setProperty('font-size', PXSCALE + 'px')
- DOM.dispatchEvent(window, 'resize')
- this.trigger('global-zoom-changed')
- }
-
- }
-
-}
-
-export default new Zoom()
diff --git a/src/client/utils.mjs b/src/client/utils.mjs
deleted file mode 100644
index e7c07471..00000000
--- a/src/client/utils.mjs
+++ /dev/null
@@ -1,49 +0,0 @@
-export function deepCopy(obj, decimals) {
-
- var copy = obj
-
- if (obj === null) {
- return obj
- }
-
- if (typeof obj === 'object') {
- copy = Array.isArray(obj) ? [] : {}
- for (let key in obj) {
- copy[key] = deepCopy(obj[key], decimals)
- }
- } else if (typeof obj == 'number') {
- return decimals === undefined ? copy : parseFloat(copy.toFixed(decimals))
- }
-
- return copy
-
-}
-
-export function deepEqual(a, b) {
-
- var ta = typeof a,
- tb = typeof b
-
- if (ta !== tb) {
- return false
- } else if (ta === 'object') {
- return JSON.stringify(a) === JSON.stringify(b)
- } else {
- return a === b
- }
-
-}
-
-export function isJSON(str) {
- // heuristic to avoid using JSON when unnecessary
- // if the string doesn't start with one of these chars
- // it's going to fail
- // ref in source: https://github.com/douglascrockford/JSON-js
- return ' \n+-eE{([0123456789tfn"'.indexOf(str[0]) !== -1
-
-}
-
-export function isJSONObject(str) {
- // same, but only for object/array/bool/null
- return '{[tfn'.indexOf(str[0]) !== -1
-}
diff --git a/src/client/widgets/basics/button.mjs b/src/client/widgets/basics/button.mjs
deleted file mode 100644
index 7ce2b3d4..00000000
--- a/src/client/widgets/basics/button.mjs
+++ /dev/null
@@ -1,438 +0,0 @@
-import html from 'nanohtml'
-import Widget from '../common/widget.mjs'
-import doubleTap from '../mixins/double_tap.mjs'
-import {deepEqual, isJSON} from '../../utils.mjs'
-import {iconify} from '../../ui/utils.mjs'
-import parser from '../../parser.mjs'
-import {TOGGLE_ALT_TRAVERSING} from '../../globals.mjs'
-
-class Button extends Widget {
-
- static description() {
-
- return 'On / off button.'
-
- }
-
- static defaults() {
-
- var defaults = super.defaults(Button).extend({
- style: {
- _separator_button_style: 'Button style',
- colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s text color when active.'},
- label: {type: 'string|boolean', value: 'auto', help: [
- 'Set to `false` to hide completely',
- '- Insert icons using the prefix ^ followed by the icon\'s name : `^play`, `^pause`, etc (see https://fontawesome.com/search?m=free&s=solid',
- '- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal`',
- ]},
- vertical: {type: 'boolean', value: false, help: 'Set to `true` to display the text vertically'},
- wrap: {type: 'boolean|string', value: false, choices: [false, true, 'soft'], help: [
- 'Set to `true` to wrap long lines automatically. Set to `soft` to avoid breaking words.',
- ]},
- },
- class_specific: {
- on: {type: '*', value: 1, help: [
- 'Set to `null` to send send no argument in the osc message. Ignored if `mode` is `momentary`.',
- ]},
- off: {type: '*', value: 0, help: [
- 'Set to `null` to send send no argument in the osc message. Must be different from `on`. Ignored if `mode` is `momentary` or `tap`.',
- ]},
- mode: {type: 'string', value: 'toggle', choices: ['toggle', 'push', 'momentary', 'tap'], help: [
- 'Interaction mode:',
- '- `toggle` (classic on/off switch)',
- '- `push` (press & release)',
- '- `momentary` (no release, no value sent with the address)',
- '- `tap` (no release, sends `on` as value)',
- ]},
- 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'},
- click: {type: 'boolean', value: false, help: 'Set to `true` to activate upon click event instead of tap (ignored if `mode` is `push`)'},
- decoupled: {type: 'boolean', value: false, help: [
- 'Set to `true` make the local feedback update only when it receives a value from an osc/midi message that matches the `on` or `off` property.',
- 'When `decoupled`, the button\'s value is ambiguous: when interacted with, it will send the value that\'s requested (`on` or `off` for `toggle` and `push` modes, `on` for `tap` mode, `null` for `momentary`), otherwise it will return the value received from the feedback message (`on` or `off` property).',
- 'From a script property, feedback messages can be simulated with:',
- '`set("widget_id", value, {external: true})`'
- ]},
- },
- scripting: {
- onTouch: {type: 'script', value: '', editor:'javascript', help: ['Script executed when the panel is touched and released, and when the pointer moves when the widget is touched. See documentation .',]},
- }
- })
-
- defaults.scripting.onValue.help.push(
- 'Additional variables:',
- '- `locals.touchCoords`: `[x, y]` array representing the touch coordinates, normalized between 0 and 1.',
- '- `locals.external`: `true` if value was received from an osc/midi message, `false otherwise`.'
- )
-
- return defaults
-
- }
-
- constructor(options) {
-
- super({...options, html: html` `})
-
- this.state = 0
- this.touchActive = false
- this.localSet = false
- this.pulseIn = null
- this.pulseOut = null
-
- this.buttonSize = [100, 100]
- this.exposeTouchCoords = String(this.getProp('onValue')).includes('touchCoords')
- this.parsersLocalScope.external = false
- this.parsersLocalScope.touchCoords = [0.5, 0.5]
- if (this.exposeTouchCoords) {
- this.on('resize', (e)=>{
- this.buttonSize = [e.width, e.height]
- }, {element: this.widget})
- }
-
- if (this.getProp('onTouch')) {
- this.on('draginit',(e)=>this.onTouch(e, 'start'), {element: this.container})
- }
-
- var mode = this.getProp('mode'),
- tap = mode === 'momentary' || mode === 'tap',
- push = mode === 'push' || tap,
- click = this.getProp('click') && mode !== 'push'
-
- if (push) {
-
- if (this.getProp('doubleTap')) {
-
- doubleTap(this, (e)=>{
-
- this.touchActive = true
-
- if (this.exposeTouchCoords) {
- this.parsersLocalScope.touchCoords = [e.offsetX / this.buttonSize[0], 1 - e.offsetY / this.buttonSize[1]]
- }
-
- this.setValue(this.getProp('on'), {sync: true, send: true, local:true, y: e.offsetY})
-
- if (tap) this.container.classList.add('active')
-
- }, {element: this.container, click: click})
-
- } else {
-
- this.on(click ? 'click': 'draginit',(e)=>{
-
- if (this.touchActive) return
-
- this.touchActive = true
-
- if (this.exposeTouchCoords) {
- this.parsersLocalScope.touchCoords = [e.offsetX / this.buttonSize[0], 1 - e.offsetY / this.buttonSize[1]]
- }
-
- this.setValue(this.getProp('on'), {sync: true, send: true, local:true, y: e.offsetY})
-
- if (tap) this.container.classList.add('active')
-
-
- }, {element: this.container})
-
- }
-
- if (this.exposeTouchCoords) {
- this.on('drag',(e)=>{
-
- if (!this.touchActive) return
-
- this.parsersLocalScope.touchCoords[0] += e.movementX / this.buttonSize[0]
- this.parsersLocalScope.touchCoords[1] += e.movementY / this.buttonSize[1]
-
- }, {element: this.container})
- }
-
- this.on('dragend',()=>{
-
- if (!this.touchActive) return
-
- this.touchActive = false
-
- if (!tap) this.setValue(this.getProp('off'), {sync: true, send: true, local:true})
- if (tap) this.container.classList.remove('active')
-
-
- }, {element: this.container})
-
- } else {
-
- if (this.getProp('doubleTap')) {
-
- doubleTap(this, (e)=>{
-
-
- this.touchActive = true
- this.setValue(this.state ? this.getProp('off') : this.getProp('on'), {sync: true, send: true, y: e.offsetY, x: e.offsetX, local:true})
-
- }, {element: this.container, click: click})
-
- } else {
-
- this.on(click ? 'click': 'draginit',(e)=>{
-
- if (this.touchActive) return
-
- if (e.traversingStack && TOGGLE_ALT_TRAVERSING) {
- if (e.traversingStack.firstButtonValue === undefined) {
- e.traversingStack.firstButtonValue = this.state
- } else if (e.traversingStack.firstButtonValue !== this.state) {
- return
- }
- }
-
- this.touchActive = true
- this.setValue(this.state ? this.getProp('off') : this.getProp('on'), {sync: true, send: true, y: e.offsetY, x: e.offsetX, local:true})
-
- }, {element: this.container})
-
- this.on('dragend',()=>{
-
- this.touchActive = false
-
- }, {element: this.container})
-
- }
-
- }
-
- if (tap) this.noValueState = true
-
- this.label = html` `
-
- if (this.getProp('wrap')) this.label.classList.add('wrap')
- if (this.getProp('wrap') === 'soft') this.label.classList.add('wrap-soft')
- if (this.getProp('vertical')) this.label.classList.add('vertical')
-
- this.updateLabel()
-
- if (this.getProp('decoupled')) {
-
- this.decoupledValue = parser.parse({
- data: {
- type: 'variable',
- id: this.getProp('id') + '/decoupledValue',
- ignoreDefaults: true,
- },
- parentNode: this.widget,
- parent: this,
- meta: {...this.meta}
- })
- this.decoupledValue.on('value-changed', (e)=>{
- this.container.classList.toggle('on', this.decoupledValue.value)
- if (e.options.send) this.decoupledValue.sendValue()
- })
-
- }
-
- if (this.getProp('onTouch')) {
- this.on('drag',(e)=>this.onTouch(e, 'move'), {element: this.container})
- this.on('dragend',(e)=>this.onTouch(e, 'stop'), {element: this.container})
- }
-
- }
-
- onTouch(e, name) {
-
- var event = {...e}
-
- event.type = name
-
- this.scripts.onTouch.run({
- value: this.value,
- event: event
- }, {sync: true, send: true})
-
- }
-
- get value() {
-
- switch (this.getProp('mode')) {
- case 'toggle':
- if (this.getProp('decoupled')) {
- if (this.localSet) {
- // return requested value
- return this.getProp(this.decoupledValue.value ? 'off' : 'on')
- } else {
- // return feedback value
- return this.getProp(this.decoupledValue.value ? 'on' : 'off')
- }
- } else {
- return this.getProp(this.state ? 'on' : 'off')
- }
- case 'push':
- if (this.getProp('decoupled')) {
- if (this.localSet) {
- // return requested value
- return this.getProp(this.touchActive ? 'on' : 'off')
- } else {
- // return feedback value
- return this.getProp(this.decoupledValue.value ? 'on' : 'off')
- }
- } else {
- return this.getProp(this.state ? 'on' : 'off')
- }
- case 'tap':
- if (this.localSet || !this.getProp('decoupled')) {
- return this.getProp('on')
- } else {
- return this.getProp(this.decoupledValue.value ? 'on' : 'off')
- }
- case 'momentary':
- if (this.localSet || !this.getProp('decoupled')) {
- return null
- } else {
- return this.getProp(this.decoupledValue.value ? 'on' : 'off')
- }
- default:
- return null
- }
-
- }
-
- setValue(v, options={}) {
-
- if (typeof v === 'string' && isJSON(v)) {
- try {
- v = JSON.parse(v)
- } catch (err) {}
- }
-
- var newstate,
- mode = this.getProp('mode')
-
- if (deepEqual(v, this.getProp('on'))) {
-
- newstate = 1
-
- } else if (deepEqual(v, this.getProp('off'))) {
-
- newstate = 0
-
- } else if (mode === 'momentary' && (v === null || v === undefined)) {
- newstate = 1
-
- }
-
- if (newstate !== undefined) {
-
- this.parsersLocalScope.external = !!options.fromExternal
-
- if (this.getProp('decoupled')) {
-
- if (options.fromExternal) {
- this.state = newstate
- this.decoupledValue.setValue(newstate, {sync: true})
- } else if (!options.local && this.getProp('mode') === 'push') {
- if (newstate === 1 && !this.touchActive) {
- this.touchActive = 1
- setTimeout(()=>{this.touchActive = 0})
- } else {
- this.touchActive = 0
- }
- }
-
- } else {
-
- this.state = newstate
-
- if (mode === 'toggle' || mode === 'push') {
- this.container.classList.toggle('on', this.state)
- }
-
- }
-
-
- if (options.local || !options.fromExternal) this.localSet = true
-
- if (options.send) this.sendValue()
- if (options.sync) this.changed(options)
-
- if (options.local || !options.fromExternal) this.localSet = false
-
- // tap mode
- if (newstate && (mode === 'momentary' || mode === 'tap') && !options.tapRelease) {
-
- // reset value
- if (mode === 'tap') this.setValue(this.getProp('off'), {sync: false, send: false, tapRelease: true})
-
- // pulse
- clearTimeout(this.pulseIn)
- clearTimeout(this.pulseOut)
-
- this.container.classList.remove('pulse')
-
- if (this.getProp('decoupled') && options.fromExternal) return
-
- this.pulseIn = setTimeout(()=>{
- this.container.classList.add('pulse')
- this.pulseOut = setTimeout(()=>{
- this.container.classList.remove('pulse')
- }, 150)
- }, 16)
-
- }
-
- }
-
-
-
- }
-
- updateLabel() {
-
- if (!this.label) return
-
- if (this.getProp('label') === false) {
-
- if (this.widget.contains(this.label)) this.widget.removeChild(this.label)
-
- } else {
- this.label.innerHTML = this.getProp('label') == 'auto'?
- this.getProp('id'):
- iconify(String(this.getProp('label')).replace(/
-
-
-
- `})
-
- if (this.getProp('icon')) {
- this.widget.appendChild(html`
`)
- } else {
- this.container.classList.add('no-icon')
- }
-
- if (this.getProp('align') === 'left') this.widget.classList.add('left')
- if (this.getProp('align') === 'right') this.widget.classList.add('right')
-
- this.select = this.widget.appendChild(html` `)
- this.text = DOM.get(this.widget, '.text')[0]
-
- this.parseValues()
-
- this.on('change', (e)=>{
- this.setValue(this.values[this.select.selectedIndex], {sync:true, send:true, fromLocal:true})
- }, {element: this.select})
-
- this.on('fast-click', (e)=>{
- // allow resubmitting same value
- this.select.selectedIndex = -1
- }, {element: this.select})
-
-
- this.select.selectedIndex = -1
- this.selected = -1
- this.container.classList.add('noselect')
-
- }
-
- parseValues() {
-
- super.parseValues()
-
- this.select.innerHTML = ''
- for (var i = 0; i < this.values.length; i++) {
- this.select.appendChild(html`
-
- ${this.keys[i]}
-
- `)
- }
-
- }
-
- setValue(v,options={}) {
-
- var i = this.getIndex(v)
-
- this.value = this.values[i]
-
- this.select.selectedIndex = i
- this.selected = i
-
- this.setLabel()
-
- if (document.activeElement === this.select && iOS) {
- // force menu close on ios
- this.select.blur()
- }
-
- for (var j = 0; j < this.select.options.length; j++) {
- this.select.options[j].classList.toggle('on', i === j)
- }
-
- if (options.send) this.sendValue()
- if (options.sync) this.changed(options)
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- var ret = super.onPropChanged(...arguments)
-
- switch (propName) {
-
- case 'values':
- this.parseValues()
- return
- case 'label':
- this.setLabel()
- return
- }
-
- return ret
-
- }
-
-}
-
-Dropdown.dynamicProps = Dropdown.prototype.constructor.dynamicProps.concat(
- 'values',
- 'label'
-)
-
-
-export default Dropdown
diff --git a/src/client/widgets/basics/file.mjs b/src/client/widgets/basics/file.mjs
deleted file mode 100644
index 61bb427c..00000000
--- a/src/client/widgets/basics/file.mjs
+++ /dev/null
@@ -1,106 +0,0 @@
-import html from 'nanohtml'
-import Widget from '../common/widget.mjs'
-import uiFilebrowser from '../../ui/ui-filebrowser.mjs'
-import {DOM} from '../../globals.mjs'
-
-export default class File extends Widget {
-
- static description() {
-
- return 'File/Folder selector (server-side).'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- style: {
- _separator_file_style: 'File style',
- align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'},
- hidePath: {type: 'boolean', value: false, help: 'Set to `true` to only display the filename (the whole path will still be used as value)'},
- mode: {type: 'string', value: 'open', choices: ['open', 'save'], help: 'File browser mode'},
- click: {type: 'boolean', value: false, help: 'Set to `true` to activate upon click event instead of tap'},
- },
- class_specific: {
- directory: {type: 'string', value: 'auto', help: 'Default browsing directory'},
- extension: {type: 'string|array', value: '*', help: 'Only display files with this extension. Multiple extensions can be specified with an array of strings (`["jpg", "jpeg"]`)'},
- allowDir: {type: 'boolean', value: false, help: 'Allow selecting a folder (by pressing "open" when no file is selected)'}
- }
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: html`
-
-
-
-
- `})
-
- if (this.getProp('align') === 'left') this.widget.classList.add('left')
- if (this.getProp('align') === 'right') this.widget.classList.add('right')
- if (this.getProp('mode') === 'save') this.widget.classList.add('save')
- if (this.getProp('hidePath')) this.widget.classList.add('hide-path')
-
- this.text = DOM.get(this.widget, '.text')[0]
- this.lastDir = null
-
- var ext = this.getProp('extension')
- if (Array.isArray(ext)) {
- ext = '(' + ext.join('|') + ')'
- }
-
- this.on(this.getProp('click') ? 'click' : 'fast-click', (e)=>{
-
- if (e.capturedByEditor === true) return
-
- uiFilebrowser({
- extension: ext.replace(/^\.?(.*)$/, '$1'),
- directory: this.getProp('directory') === 'auto' ? this.lastDir : this.getProp('directory'),
- loadDir: this.getProp('allowDir'),
- save: this.getProp('mode') === 'save'
- }, (path, root)=>{
-
- var sep = path[0][0] === '/' ? '/' : '\\',
- val = path.join(sep)
- if (root) val = val.replace(root, sep).replace(sep + sep, sep)
-
- this.setValue(val, {
- sync: true,
- send: true
- })
-
- }, (path)=>{
- this.lastDir = path
- })
- }, {element: this.widget})
-
- }
-
-
- setValue(v, options={}) {
-
- this.value = v
-
- if (this.getProp('hidePath') && typeof v === 'string') {
- var sep = v[0] === '/' ? '/' : '\\'
- if (v[v.length - 1] === sep) {
- this.text.textContent = v.substr(0, v.length - 1).split(sep).pop() + sep
- } else {
- this.text.textContent = v.split(sep).pop()
- }
- } else {
- this.text.textContent = v
- }
-
- if (options.send) this.sendValue()
- if (options.sync) this.changed(options)
-
- }
-
-
-
-
-}
diff --git a/src/client/widgets/basics/input.mjs b/src/client/widgets/basics/input.mjs
deleted file mode 100644
index ffc89619..00000000
--- a/src/client/widgets/basics/input.mjs
+++ /dev/null
@@ -1,249 +0,0 @@
-import html from 'nanohtml'
-import Canvas from '../common/canvas.mjs'
-import {deepCopy} from '../../utils.mjs'
-
-class Input extends Canvas {
-
- static description() {
-
- return 'Text input.'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- style: {
- _separator_input_style: 'Input style',
- align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'},
- unit: {type: 'string', value: '', help: 'Unit will be appended to the displayed widget\'s value (it doesn\'t affect osc messages)'},
- noCanvas: {type: 'boolean', value: false, help: [
- 'Set to `true` to not a use a canvas for rendering the value when not focused.',
- 'Use this if the text renders blurry (less effecient when updating the value frequently).'
- ]},
- },
- class_specific: {
- asYouType: {type: 'boolean', value: false, help: 'Set to `true` to make the input send its value at each keystroke'},
- numeric: {type: 'boolean|number', value: false, help: [
- 'Set to `true` to allow numeric values only and display a numeric keyboard on mobile devices',
- 'Can be a number to specify the stepping value for mousewheel interaction (only when the input is focused).']},
- validation: {type: 'string', value: '', help: [
- 'Regular expression: if the submitted value doesn\'t match the regular expression, it will be reset to the last valid value.',
- 'If leading and trailing slashes are omitted, they will be added automatically and the flag will be set to "gm"',
- 'Examples:',
- '- `^[0-9]*$` accepts digits only, any number of them',
- '- `/^[a-z\s]{0,10}$/i` accept between 0 and 10 alphabetic characters and spaces (case insensitive)',
- ]},
- maxLength: {type: 'number', value: '', help: ['Maximum number of characters allowed']}
- },
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: html`
-
-
-
- `})
-
- this.value = ''
- this.stringValue = ''
- this.focused = false
- this.validation = null
- this.useCanvas = !this.getProp('noCanvas')
-
- if (this.getProp('vertical')) this.widget.classList.add('vertical')
- if (this.getProp('align') === 'left') this.widget.classList.add('left')
- if (this.getProp('align') === 'right') this.widget.classList.add('right')
-
- this.input = html` `
-
- if (!this.useCanvas) {
- this.widget.insertBefore(this.input, this.canvas)
- }
-
- if (this.getProp('numeric')) {
- this.input.type = 'number'
- this.input.pattern = '[0-9\.]*'
- this.input.inputMode = 'decimal'
- this.input.step = parseFloat(this.getProp('numeric')) || 1
- }
-
- if (this.getProp('maxLength') !== '') {
- this.maxLength = parseInt(this.getProp('maxLength'))
- this.input.maxLength = this.maxLength
- } else {
- this.maxLength = -1
- }
-
- var asYouType = this.getProp('asYouType')
-
- if (this.getProp('validation') !== '') {
- var validation = String(this.getProp('validation')),
- flags = validation.match(/^\/.*\/.*$/) ? validation.split('/').pop() : 'gm',
- regExpString = validation.match(/^\/.*\/.*$/) ? validation.replace(/^\/(.*)\/.*$/, '$1') : validation
-
- if (!regExpString.match(/^\^.*\$$/)) regExpString = '^' + regExpString + '$'
-
- this.validation = new RegExp(regExpString, flags)
- }
-
- if (this.getProp('interaction')) {
-
- if (this.useCanvas) {
- this.widget.setAttribute('tabindex', 0)
- }
-
- this.on('focus', this.focus.bind(this), {element: this.widget})
- this.on('blur', (e)=>{
- this.blur(true)
- }, {element: this.input})
- this.input.addEventListener('keydown', (e)=>{
- if (e.key == 'Enter') this.blur()
- else if (e.key == 'Escape') this.blur(false)
- else if (asYouType) {
- setTimeout(()=>{
- this.inputChange()
- })
- }
- })
- }
-
- }
-
- focus() {
-
- if (this.focused) return
- this.focused = true
-
- if (this.useCanvas) {
- this.widget.insertBefore(this.input, this.canvas)
- this.widget.setAttribute('tabindex','-1')
- this.input.value = this.stringValue
- this.input.focus()
- }
-
-
- setTimeout(()=>{
- this.input.select()
- })
-
- }
-
- blur(change=true) {
-
- if (!this.focused) return
- this.focused = false
-
- if (change) this.inputChange()
-
- if (this.useCanvas) {
- this.widget.removeChild(this.input)
- this.widget.setAttribute('tabindex','0')
- } else {
- this.input.blur()
- }
- }
-
- inputChange() {
-
- this.setValue(this.input.value, {sync:true, send:true})
-
- }
-
-
- cacheCanvasStyle(style){
-
- if (!this.useCanvas) return
-
- super.cacheCanvasStyle(style)
-
- }
-
-
- resizeHandle(event){
-
- if (!this.useCanvas) return
-
- super.resizeHandle(event)
-
- }
-
- setValue(v, options={} ) {
-
- if (this.validation && !this.getStringValue(v).match(this.validation)) {
- this.input.value = this.value
- return
- }
-
- if (this.maxLength !== -1 && this.getStringValue(v).length > this.maxLength) {
- v = this.getStringValue(v).substr(0, this.maxLength)
- this.input.value = v
- }
-
- try {
- this.value = JSON.parse(v)
- } catch (err) {
- this.value = v
- }
-
- if (this.value === '' || this.value === null) this.value = this.getProp('default')
-
- this.stringValue = this.getStringValue(this.value)
-
- if (this.useCanvas) {
- this.batchDraw()
- } else {
- this.input.value = this.stringValue
- }
-
- if (options.send && !options.fromSync) this.sendValue()
- if (options.sync) this.changed(options)
-
- }
-
- draw() {
-
- if (!this.useCanvas) return
-
- var v = this.stringValue,
- width = this.width,
- height = this.height
-
- if (this.getProp('unit') && v.length) v += ' ' + this.getProp('unit')
-
- this.clear()
-
- this.ctx.fillStyle = this.cssVars.colorText
-
- // hack ? prevent weird offset added for unknown reason when font size increases
- var offy = this.fontSize / 10
-
- if (this.textAlign == 'center') {
- this.ctx.fillText(v, Math.round(width/2), Math.round(height/2 + offy))
- } else if (this.textAlign == 'right') {
- this.ctx.fillText(v, width, Math.round(height/2 + offy))
- } else {
- this.ctx.fillText(v, 0, Math.round(height/2 + offy))
- }
-
- this.clearRect = [0, 0, width, height]
-
- }
-
- getStringValue(v) {
- if (v === undefined) return ''
- return typeof v != 'string' ?
- JSON.stringify(deepCopy(v, this.decimals)).replace(/,/g, ', ') :
- v
- }
-
-}
-
-Input.dynamicProps = Input.prototype.constructor.dynamicProps
- .filter(x=>x !== 'interaction')
-
-
-export default Input
diff --git a/src/client/widgets/basics/menu-base.mjs b/src/client/widgets/basics/menu-base.mjs
deleted file mode 100644
index c5eadf08..00000000
--- a/src/client/widgets/basics/menu-base.mjs
+++ /dev/null
@@ -1,76 +0,0 @@
-import Widget from '../common/widget.mjs'
-import {iconify} from '../../ui/utils.mjs'
-import {deepEqual} from '../../utils.mjs'
-
-class MenuBase extends Widget {
-
- constructor(options) {
-
- super(options)
-
- this.value = undefined
- this.values = []
- this.keys = []
- this.objectInValues = false
-
- }
-
- parseValues() {
-
- this.values = []
- this.keys = []
-
- var values = this.getProp('values') || []
-
- if (
- typeof values === 'object' && values !== null &&
- Array.isArray(values.labels) && Array.isArray(values.values) &&
- Object.keys(values).length === 2 && values.labels.length === values.values.length
- ) {
-
- this.values = values.values
- this.keys = values.labels
-
- } else {
-
- if (!Array.isArray(values) && !(typeof values === 'object' && values !== null)) {
- values = values !== '' ? [values] : []
- }
-
- this.values = !Array.isArray(values) ? Object.values(values) : values
- this.keys = !Array.isArray(values) ? Object.keys(values) : this.values
- }
-
- this.objectInValues = this.values.some(x=>typeof x === 'object')
-
- }
-
- getIndex(value) {
-
- var index = this.values.indexOf(value)
- if (index === -1 && this.objectInValues) {
- for (var i = 0; i < this.values.length; i++) {
- if (deepEqual(value, this.values[i])) return i
- }
- }
- return index
-
- }
-
- setLabel() {
-
- var string = this.getProp('label') === 'auto' ? '%value' : this.getProp('label'),
- i = this.selected
-
-
- if (i > -1 && string) {
- this.text.innerHTML = iconify(String(string).replace(/%value/g, typeof this.value === 'string' ? this.value : JSON.stringify(this.value)).replace(/%key/g, this.keys[i]))
- } else {
- this.text.innerHTML = iconify(String(string).replace(/%value/g, '').replace(/%key/g, ''))
- }
-
- }
-
-}
-
-export default MenuBase
diff --git a/src/client/widgets/basics/menu.mjs b/src/client/widgets/basics/menu.mjs
deleted file mode 100644
index dd9a6e43..00000000
--- a/src/client/widgets/basics/menu.mjs
+++ /dev/null
@@ -1,390 +0,0 @@
-import html from 'nanohtml'
-import raw from 'nanohtml/raw'
-import MenuBase from './menu-base.mjs'
-import {iconify} from '../../ui/utils.mjs'
-import doubleTap from '../mixins/double_tap'
-import iOS from '../../ui/ios.mjs'
-import {DOM} from '../../globals.mjs'
-
-class Menu extends MenuBase {
-
- static description() {
-
- return 'Drag and drop menu with a circular or grid layout.'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- geometry: {
- _separator_menu_geometry: 'Menu geometry',
- size: {type: 'number|array', value: 200, help: [
- '- If `layout` is `circular`: diameter (in px)',
- '- Else: square size or `[width, height]` array',
- ]},
- ignoreTabs: {type: 'boolean', value: false, help: 'Set to `true` to allow the menu overflowing its tab ancestors.'},
-
- },
- style: {
- _separator_menu_style: 'Menu style',
- label: {type: 'string|boolean', value: 'auto', help: 'Displayed text (defaults to current value). Keywords `%key` and `%value` will be replaced by the widget\'s selected key/value.'},
- icon: {type: 'boolean', value: 'true', help: 'Set to `false` to hide the dropdown icon'},
- textAlign: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'},
- menuAlignV: {type: 'string', value: 'center', choices: ['center', 'top', 'bottom'], help: 'Set to `top` or `bottom` to change menu alignment (otherwise center)'},
- menuAlignH: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change menu alignment (otherwise center)'},
- layout: {type: 'string', value: 'vertical', choices: ['circular', 'horizontal', 'vertical', 'grid'], help: [
- 'Defines how the menu\'s item are laid out'
- ]},
- gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns or a valid value for the css property "grid-template".'},
- },
- class_specific: {
- mode: {type: 'string', value: 'default', choices: ['default', 'toggle', 'swipe', 'doubleTap', 'doubleTap-toggle'], help: [
- 'Interaction modes:',
- '- `default`: opens on touch, closes and changes value on release',
- '- `toggle`: opens on click, closes and changes value on next click',
- '- `swipe`: opens on touch, changes value when the pointer moves above items, closes on release',
- '- `doubleTap`: same as `default` but opens on double tap',
- '- `doubleTap-toggle`: same as `toggle` but opens on double tap',
- ]},
- values: {type: 'array|object', value: [1, 2, 3], help: [
- '`Array` of possible values to switch between : `[1,2,3]`',
- '`Object` of label:value pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won\'t be kept',
- '`{"labels": [], "values": []}` `object` where `labels` and `values` arrays must be of the same length. This syntax allows using the same label for different values.',
- ]},
- weights: {type: 'array', value: '', help: [
- '`Array` of `number` defining the weights of each value in `values`',
- 'Ignored when `mode` is `grid`'
- ]},
- }
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: html`
-
-
-
-
- `})
-
- if (this.getProp('icon')) {
- this.widget.appendChild(html`
`)
- } else {
- this.container.classList.add('no-icon')
- }
-
- this.widget.classList.add('text-align-' + this.getProp('textAlign'))
- this.widget.classList.add('menu-align-h-' + this.getProp('menuAlignH'))
- this.widget.classList.add('menu-align-v-' + this.getProp('menuAlignV'))
-
- this.menu = html` `
- this.text = DOM.get(this.widget, '.text')[0]
-
- this.opened = false
-
- this.selected = -1
-
- this.mode = String(this.getProp('mode'))
-
- this.parseValues()
-
- if (this.mode.includes('doubleTap')) {
-
- doubleTap(this, (e)=>{
- if (this.opened) return
- this.open(e)
- }, {element: this.widget, click: this.mode.includes('toggle')})
-
- this.on('draginit',(e)=>{
-
- if (this.opened && this.mode.includes('toggle')) {
-
- this.selectValue(e)
- this.submitValue()
-
- }
-
- // multitouch is only needed for iOS which fails otherwise
- }, {element: this.widget, multitouch: iOS})
-
-
- } else {
-
- this.on(this.mode.includes('toggle') ? 'click' : 'draginit',(e)=>{
-
- if (this.opened && this.mode.includes('toggle')) {
-
- this.selectValue(e)
- this.submitValue()
-
- } else if (!this.opened) {
-
- this.open(e)
-
- }
-
- }, {element: this.widget, multitouch: iOS})
-
-
- }
-
- if (!this.mode.includes('toggle')) {
-
- this.on('drag',(e)=>{
-
- this.selectValue(e, true)
- if (this.mode === 'swipe' && this.values[this.selected] !== this.value) {
- this.submitValue()
- }
-
- }, {element: this.widget})
-
- this.on('dragend',()=>{
-
- if (!this.opened) return
- if (this.mode === 'swipe') {
- this.close()
- } else {
- this.submitValue()
- }
-
- }, {element: this.widget})
-
- } else {
-
- this.toggleCloseHandler = (e)=>{
- if (!this.opened || this.menu.contains(e.target)) return
- this.close()
- }
- document.addEventListener('fast-click', this.toggleCloseHandler)
-
- }
-
- this.setMode()
- this.setSize()
-
- }
-
- open(e) {
-
- if (this.opened) return
-
- this.opened = true
- this.fixParents()
-
- this.container.classList.add('on')
- this.widget.appendChild(this.menu)
-
- }
-
- close() {
-
- if (!this.opened) return
-
- this.opened = false
- this.fixParents()
- DOM.each(this.menu, '.active', (el)=>{el.classList.remove('active')})
- this.container.classList.remove('on')
- this.widget.removeChild(this.menu)
-
- }
-
- selectValue(e, drag) {
-
- // touch hover fix
- var node = drag && e.isTouch ? document.elementFromPoint(e.clientX, e.clientY)
- : e.target
-
- if (node === this.menu || !this.menu.contains(node)) {
- DOM.each(this.menu, '.active', (el)=>{el.classList.remove('active')})
- this.selected = -1
- } else if (!node.classList.contains('active')) {
- DOM.each(this.menu, '.active', (el)=>{el.classList.remove('active')})
- node.classList.add('active')
- this.selected = DOM.index(node)
- }
-
- }
-
- submitValue(e) {
-
- if (this.mode !== 'swipe') this.close()
- if (this.selected > -1) {
- this.setValue(this.values[this.selected], {send: true, sync: true})
- }
-
- }
-
- parseValues() {
-
- super.parseValues()
-
- var nval = this.values.length,
- circular = this.getProp('layout') === 'circular',
- weights = this.getProp('weights'),
- totalWeight
-
- if (this.opened) this.widget.removeChild(this.menu)
- this.menu.innerHTML = ''
-
- weights = Array.isArray(weights) ? weights.slice(0, nval) : Array(nval).fill(1)
- if (weights.length < nval) weights = weights.concat(Array(nval - weights.length).fill(1))
- totalWeight = weights.reduce((a, b) => a + b, 0)
-
- var ac = 0
- for (var i = 0; i < nval; i++) {
- let angle = Math.min(360 * weights[i] / totalWeight, 120),
- skew = 90 - angle
-
- this.menu.appendChild(html`
-
-
${raw(iconify(this.keys[i]))}
-
- `)
- ac+=angle
-
- }
-
- if (circular) this.menu.appendChild(html`
`)
-
-
- this.setValue(this.value)
-
- if (this.opened) this.widget.appendChild(this.menu)
-
- }
-
- setMode() {
-
- var layout = this.getProp('layout')
- this.container.classList.toggle('box', layout !== 'circular')
- this.container.classList.toggle('circular', layout === 'circular')
- this.container.classList.toggle('grid', layout === 'grid')
- this.container.classList.toggle('vertical', layout === 'vertical')
- this.container.classList.toggle('horizontal', layout === 'horizontal')
-
- if (layout === 'grid') {
- var template = this.getProp('gridTemplate') || Math.round(this.values.length / 2)
- this.menu.style.gridTemplate = template === parseInt(template) ? `none / repeat(${template}, 1fr)` : template
- }
-
- }
-
- setSize() {
-
- var size = this.getProp('size')
- if (Array.isArray(size)) {
- this.container.style.setProperty('--size', parseInt(size[0]) + 'rem')
- this.container.style.setProperty('--size-box-w', parseInt(size[0]) + 'rem')
- this.container.style.setProperty('--size-box-h', parseInt(size[1]) + 'rem')
-
- } else {
- this.container.style.setProperty('--size', parseInt(size) + 'rem')
- this.container.style.setProperty('--size-box-w', parseInt(size) + 'rem')
- this.container.style.setProperty('--size-box-h', parseInt(size) + 'rem')
- }
-
- }
-
- fixParents() {
-
- var parent = this.parent,
- scrollX = 0,
- scrollY = 0,
- stop = this.getProp('ignoreTabs') ? /root/ : /root|tab/
-
- while (parent && parent.props && !String(parent.getProp('type')).match(stop)) {
-
- parent.modalBreakout += (this.opened ? 1 : -1)
- if (parent.modalBreakout > 0) parent.container.classList.add('modal-breakout')
- else if (parent.modalBreakout === 0) parent.container.classList.remove('modal-breakout')
- else parent.modalBreakout = 0
-
- scrollX += parent.widget.scrollLeft
- scrollY += parent.widget.scrollTop
-
- parent = parent.parent
- }
-
- scrollX += parent.widget.scrollLeft
- scrollY += parent.widget.scrollTop
-
- this.container.style.setProperty('--parent-scroll-x', scrollX + 'px')
- this.container.style.setProperty('--parent-scroll-y', scrollY + 'px')
-
- }
-
- setValue(v,options={}) {
-
- var i = this.getIndex(v)
-
- this.value = this.values[i]
- this.selected = i
- DOM.each(this.menu, '.on', (el)=>{el.classList.remove('on')})
- this.setLabel()
-
- if (i !== -1) {
- DOM.get(this.menu, '.item')[i].classList.add('on')
- }
-
- if (options.send) this.sendValue()
- if (options.sync) this.changed(options)
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- var ret = super.onPropChanged(...arguments)
-
- switch (propName) {
-
- case 'label':
- this.setLabel()
- return
- case 'size':
- this.setSize()
- return
- case 'layout':
- this.parseValues()
- this.setMode()
- return
- case 'columns':
- this.setMode()
- return
- case 'values':
- this.parseValues()
- return
-
- }
-
- return ret
-
- }
-
- onRemove() {
-
- if (this.getProp('toggle')) {
- document.removeEventListener('fast-click', this.toggleCloseHandler)
- }
- if (this.opened) {
- this.close()
- }
- super.onRemove()
-
- }
-
-}
-
-Menu.dynamicProps = Menu.prototype.constructor.dynamicProps.concat(
- 'label',
- 'size',
- 'layout',
- 'columns',
- 'values'
-)
-
-
-export default Menu
diff --git a/src/client/widgets/basics/switch.mjs b/src/client/widgets/basics/switch.mjs
deleted file mode 100644
index 88d12f31..00000000
--- a/src/client/widgets/basics/switch.mjs
+++ /dev/null
@@ -1,172 +0,0 @@
-import html from 'nanohtml'
-import raw from 'nanohtml/raw'
-import MenuBase from './menu-base.mjs'
-import {iconify} from '../../ui/utils'
-import {DOM} from '../../globals.mjs'
-
-class Switch extends MenuBase {
-
- static description() {
-
- return 'Value selector button.'
-
- }
-
- static defaults() {
-
- return super.defaults(Switch).extend({
- style: {
- _separator_switch_style: 'Switch style',
- colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s text color when active.'},
- layout: {type: 'string', value: 'vertical', choices: ['vertical', 'horizontal', 'grid'], help:'Defines how items should be laid out'},
- gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns or a valid value for the css property "grid-template".'},
- wrap: {type: 'boolean|string', value: false, choices: [false, true, 'soft'], help: [
- 'Set to `true` to wrap long lines automatically. Set to `soft` to avoid breaking words.',
- ]},
- },
- class_specific: {
- values: {type: 'array|object', value: {'Value 1':1,'Value 2':2}, help: [
- '`Array` of possible values to switch between : `[1,2,3]`',
- '`Object` of `"label":value` pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won\'t be kept',
- '`{"labels": [], "values": []}` `object` where `labels` and `values` arrays must be of the same length. This syntax allows using the same label for different values.',
- ]},
- mode: {type: 'string', value: 'tap', choices: ['tap', 'slide', 'click', 'flip'], help: [
- 'Interaction mode:',
- '- `tap`: activates when the pointer is down but prevents further scrolling',
- '- `slide`: same as `tap` but allows sliding between values',
- '- `click`: activates upon click only and allows further scrolling',
- '- `flip`: selects the next value upon click regardless of where the widget is touched',
- ]},
- }
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: html` `})
-
- this.container.classList.add('layout-' + this.getProp('layout'))
- if (this.getProp('wrap')) this.container.classList.add('wrap')
- if (this.getProp('wrap') === 'soft') this.container.classList.add('wrap-soft')
-
- if (this.getProp('layout') === 'grid') {
- var template = this.getProp('gridTemplate') || 2
- this.widget.style.gridTemplate = template === parseInt(template) ? `none / repeat(${template}, 1fr)` : template
- }
-
- this.parseValues()
-
-
- var dragCallback = (e, slide)=>{
-
- var index = 0,
- node = e.target
-
- if (e.target === this.widget && e.traversing === true && e.firstTarget) {
- node = e.firstTarget
- }
-
- if (slide && e.isTouch) {
- // special traversing touch fix
- node = document.elementFromPoint(e.clientX, e.clientY)
- }
-
- if (node === this.widget || !this.widget.contains(node)) return
-
- while ((node = node.previousSibling)) {
- if (node.nodeType != 3) {
- index++
- }
- }
-
- var value = this.values[index]
-
- if (slide && value === this.value) return
-
- this.setValue(value, {sync: true, send: true})
-
- }
-
- if (this.getProp('mode') === 'tap' || this.getProp('mode') === 'slide') {
- this.on('draginit', dragCallback , {element: this.widget})
- this.on('drag', (e)=>{
- if (this.getProp('mode') === 'slide' || e.traversing) dragCallback(e, true)
- } , {element: this.widget})
- } else if (this.getProp('mode') === 'click') {
- this.on('click', dragCallback, {element: this.widget})
- } else if (this.getProp('mode') === 'flip') {
- this.on('click', ()=>{
- var i = (this.getIndex(this.value) + 1) % this.values.length
- this.setValue(this.values[i], {sync: true, send: true})
- }, {element: this.widget})
- }
-
- }
-
- parseValues() {
-
- super.parseValues()
-
- this.widget.innerHTML = ''
-
- for (var i = 0; i < this.values.length; i++) {
-
- this.widget.appendChild(html`
- ${raw(iconify(this.keys[i]))}
- `)
-
- }
-
- this.setValue(this.value)
-
- }
-
- setValue(v, options={}) {
-
- var i = this.getIndex(v)
-
- this.value = this.values[i]
-
- DOM.each(this.widget, '.on', (el)=>{el.classList.remove('on')})
-
- if (i !== -1) {
- DOM.get(this.widget, 'value')[i].classList.add('on')
- }
-
- if (options.send) this.sendValue(this.value)
- if (options.sync) this.changed(options)
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- var ret = super.onPropChanged(...arguments)
-
- switch (propName) {
-
- case 'values':
- this.parseValues()
- }
-
- return ret
-
- }
- setCssVariables() {
-
- super.setCssVariables()
-
- this.container.classList.toggle('padding-0', this.getProp('padding') === -1)
-
- }
-}
-
-Switch.dynamicProps = Switch.prototype.constructor.dynamicProps.concat(
- 'values'
-)
-
-Switch.cssVariables = Switch.prototype.constructor.cssVariables.concat(
- {js: 'colorTextOn', css: '--color-text-on'}
-)
-
-export default Switch
diff --git a/src/client/widgets/basics/textarea.mjs b/src/client/widgets/basics/textarea.mjs
deleted file mode 100644
index 0e426827..00000000
--- a/src/client/widgets/basics/textarea.mjs
+++ /dev/null
@@ -1,119 +0,0 @@
-import html from 'nanohtml'
-import Widget from '../common/widget.mjs'
-import {DOM} from '../../globals.mjs'
-
-class TextArea extends Widget {
-
- static description() {
-
- return 'Text area (multi line input). Tip: hit shift + enter for new lines.'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- style: {
- // _separator_input_style: 'Textarea style',
- },
- class_specific: {
-
- },
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: html`
-
-
-
- `})
-
- this.value = ''
- this.stringValue = ''
- this.focused = false
- this.validation = null
- this.input = DOM.get(this.widget, 'textarea')[0]
-
- if (this.getProp('align') === 'left') this.widget.classList.add('left')
- if (this.getProp('align') === 'right') this.widget.classList.add('right')
-
-
- if (this.getProp('interaction')) {
-
- this.input.setAttribute('tabindex', 0)
- this.on('focus', this.onFocus.bind(this), {element: this.input})
- this.on('blur', (e)=>{
- this.blur(true)
- }, {element: this.input})
-
- this.input.addEventListener('keydown', (e)=>{
- if (e.key == 'Enter' && !e.shiftKey) {
- // enter
- e.preventDefault()
- this.blur()
- }
- else if (e.key == 'Escape') {
- // esc
- this.blur(false)
- this.input.value = this.value
- }
- })
-
- }
-
- }
-
- onFocus() {
-
- if (this.focused) return
- this.focused = true
-
- }
-
- focus() {
-
- this.input.focus()
-
- }
-
- blur(change=true) {
-
- if (!this.focused) return
- this.focused = false
-
- this.input.blur()
-
- if (change) this.inputChange()
-
- }
-
- inputChange() {
-
- this.setValue(this.input.value, {sync:true, send:true})
-
- }
-
-
- setValue(v, options={} ) {
-
- this.value = v === '' || v === null ? this.getProp('default') : String(v)
-
- if (this.value === '') this.value = this.getProp('default')
-
- if (this.input.value !== this.value) this.input.value = this.value
-
- if (options.send && !options.fromSync) this.sendValue()
- if (options.sync) this.changed(options)
-
- }
-
-}
-
-TextArea.dynamicProps = TextArea.prototype.constructor.dynamicProps
- .filter(x=>x !== 'interaction')
-
-
-export default TextArea
diff --git a/src/client/widgets/common/canvas.mjs b/src/client/widgets/common/canvas.mjs
deleted file mode 100644
index 6f63d34a..00000000
--- a/src/client/widgets/common/canvas.mjs
+++ /dev/null
@@ -1,253 +0,0 @@
-import html from 'nanohtml'
-import fastdom from 'fastdom'
-import Widget from './widget.mjs'
-import * as resize from '../../events/resize.mjs'
-import canvasQueue from './queue.mjs'
-import {ENV, CANVAS_SCALING, ELECTRON_NOGPU, DOM} from '../../globals.mjs'
-
-
-class Canvas extends Widget {
-
- static defaults() {
-
- var defaults = super.defaults(Canvas)
- defaults.style.css.help.push(
- 'Canvas-based widget have their computed width and height available as css variables (read-only):',
- '- `--widget-width`',
- '- `--widget-height`',
- )
- defaults.scripting.onValue.help.push(
- 'Canvas-based widget have their computed width and height available as local variables:',
- '- `locals.width`',
- '- `locals.height`',
- )
- return defaults
-
- }
-
- constructor(options) {
-
- super(options)
-
- this.canvas = DOM.get(this.container, 'canvas')[0]
-
- this.ctx = this.canvas.getContext(this.getProp('contextType') || '2d',{
- desynchronized: !ELECTRON_NOGPU && ENV.desynccanvas ? true : false,
- alpha: true
- })
-
- this.height = undefined
- this.width = undefined
- this.scaling = 1
-
- this.clearRect = []
-
- this.hasSize = false
-
- this.colors = {}
- this.cssVars = {}
-
- this.on('resize', this.resizeHandleProxy.bind(this), {element: this.canvas})
-
- this.ctx.arc = (x, y, r, s, e, c)=>{
-
- this.ctx.__proto__.arc.call(this.ctx, x, y, Math.max(0,r), s, e, c)
-
- }
-
- }
-
- resizeHandleProxy() {
-
- fastdom.measure(()=>{
- this.resizeHandle(...arguments)
- })
-
- }
-
- resizeHandle(event){
-
- var {width, height, style} = event,
- ratio = CANVAS_SCALING * this.scaling
-
- this.height = height
- this.width = width
-
- this.parsersLocalScope.height = this.height
- this.parsersLocalScope.width = this.width
-
- this.clearRect = []
-
- this.cacheCanvasStyle(style)
-
- fastdom.mutate(()=>{
-
- this.canvas.setAttribute('width', width * ratio)
- this.canvas.setAttribute('height', height * ratio)
- this.container.style.setProperty('--widget-height', this.height + 'rem')
- this.container.style.setProperty('--widget-width', this.width + 'rem')
-
- this.ctx.font = this.fontWeight + ' ' + this.fontSize + 'px ' + this.fontFamily
- this.ctx.textBaseline = 'middle'
- this.ctx.textAlign = this.textAlign
-
- if (ratio != 1) {
- this.ctx.setTransform(1, 0, 0, 1, 0, 0)
- this.ctx.scale(ratio, ratio)
- }
-
- this.extraResizeHandle(event)
-
- if (!this.hasSize) {
- this.hasSize = true
- this.setVisibility()
- }
-
- if (this.width > 0 && this.height > 0 && this.visible) {
- this.draw()
- }
-
- })
-
- }
-
- extraResizeHandle(event) {
-
- // to be overridden if subclass needs additional actions
- // before redraw
-
- }
-
- setVisibility(){
-
- var visible = this.visible
- super.setVisibility()
- if (!visible && this.visible) this.batchDraw()
-
- }
-
- cacheCanvasStyle(style){
-
- style = style || window.getComputedStyle(this.canvas)
-
- for (var data of this.constructor.cssVariables) {
-
- var val = style.getPropertyValue(data.css).trim()
-
- if (typeof val === 'string' && val.match(/(var|calc)\(/)) {
- // property not computed because of calc() or var() in user style
- // -> attempt to force calculation
- var dummy = html`
`
- this.container.appendChild(dummy)
- let s = window.getComputedStyle(dummy)
- val = parseInt(s.getPropertyValue('width'))
- this.container.removeChild(dummy)
- }
-
- this.cssVars[data.js] = data.toJs ? data.toJs(val) : val
-
-
- }
-
- this.fontFamily = style.getPropertyValue('font-family').trim()
- this.textAlign = style.getPropertyValue('text-align').trim()
- this.fontSize = parseFloat(style.getPropertyValue('font-size').trim())
- this.fontWeight = parseFloat(style.getPropertyValue('font-weight').trim())
-
- }
-
- clear() {
-
- if (!this.clearRect.length) {
-
- this.ctx.clearRect(0, 0, this.width, this.height)
-
- } else if (typeof this.clearRect[0] == 'object') {
-
- for (let i in this.clearRect) {
- this.ctx.clearRect(...this.clearRect[i])
- }
-
- } else {
-
- this.ctx.clearRect(...this.clearRect)
-
- }
-
- }
-
- batchDraw() {
-
- if (this.hasSize && this.visible) canvasQueue.push(this)
-
- }
-
- draw(){
- throw new Error('Calling unimplemented draw() method')
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- var ret = super.onPropChanged(...arguments)
-
- switch (propName) {
-
- case 'colorText':
- case 'colorWidget':
- case 'colorFill':
- case 'colorStroke':
- case 'colorKnob':
- case 'alphaStroke':
- case 'alphaFillOff':
- case 'alphaFillOn':
- case 'colorBg':
- case 'pointSize':
- case 'knobSize':
- fastdom.measure(()=>{
- this.cacheCanvasStyle()
- fastdom.mutate(()=>{
- this.batchDraw()
- })
- })
- return
- case 'css':
- if (!/\/\*\s*noresize\s*\*\//.test(this.getProp('css'))) resize.check(this.canvas, true)
- fastdom.measure(()=>{
- this.cacheCanvasStyle()
- fastdom.mutate(()=>{
- this.batchDraw()
- })
- })
- // falls through
- case 'lineWidth':
- case 'padding':
- resize.check(this.canvas, true)
- fastdom.measure(()=>{
- this.cacheCanvasStyle()
- fastdom.mutate(()=>{
- this.batchDraw()
- })
- })
- return
- }
-
- return ret
-
-
- }
-
- onRemove() {
- this.off('resize')
- this.canvas.width = 0
- this.canvas.height = 0
- super.onRemove()
- }
-
-}
-
-Canvas.cssVariables = Canvas.prototype.constructor.cssVariables.concat(
- {js: 'alphaPips', css: '--alpha-pips', toCss: x=>parseFloat(x), toJs: x=>parseFloat(x)},
- {js: 'alphaPipsText', css: '--alpha-pips-text', toCss: x=>parseFloat(x), toJs: x=>parseFloat(x)}
-)
-
-export default Canvas
diff --git a/src/client/widgets/common/container.mjs b/src/client/widgets/common/container.mjs
deleted file mode 100644
index 594c4dd3..00000000
--- a/src/client/widgets/common/container.mjs
+++ /dev/null
@@ -1,77 +0,0 @@
-import Widget from './widget.mjs'
-
-var Container = (Class=Widget)=> class extends Class {
-
- constructor(options) {
-
- super(options)
-
- this.isContainer = true
-
- this.on('widget-created', (e)=>{
-
- if (e.widget.parent === this) {
-
- var index = e.index
- if (index !== undefined) {
- if (!this.children[index]) {
- this.children[index] = e.widget
- } else {
- this.children.splice(index, 0, e.widget)
- }
- } else {
- this.children.push(e.widget)
- }
- }
-
- })
-
- this.on('widget-removed', (e)=>{
-
- if (e.widget.parent === this) {
- this.children.splice(this.children.indexOf(e.widget), 1)
- }
-
- })
-
- }
-
- alignChildrenProps() {
-
- // this is needed after editor.undo to fix data shifting:
- // say we have children [a, b, c] bound with session data [a, b, c]
- // we delete one widget [ b, c] the data changes too: [ b, c]
- // undo first only mutates the data: [a, b, c]
- // so children have their data mutated too, child 'b' gets data 'a' and so on
- // each child has to get the data corresponding to its index again.
- // ...right ? :)
- var tabs = this.getProp('tabs'),
- widgets= this.getProp('widgets'),
- type = tabs && tabs.length ? 'tabs' : widgets && widgets.length ? 'widgets' : null,
- data = type ? this.getProp(type) : null
-
- if (!type) return
-
-
- for (let i in this.children) {
- if (this.children[i] && data[i]) {
- this.children[i].props = data[i]
- this.children[i].cachedProps[type] = this.children[i].props[type]
- if (this.children[i].alignChildrenProps) {
- this.children[i].alignChildrenProps()
- }
- }
- }
-
- }
-
- onRemove() {
-
- super.onRemove()
-
- }
-
-}
-
-
-export default Container
diff --git a/src/client/widgets/common/osc-receiver.mjs b/src/client/widgets/common/osc-receiver.mjs
deleted file mode 100644
index 7809355d..00000000
--- a/src/client/widgets/common/osc-receiver.mjs
+++ /dev/null
@@ -1,88 +0,0 @@
-import osc from '../../osc.mjs'
-import {isJSON, isJSONObject} from '../../utils.mjs'
-import {JSON5} from '../../globals.mjs'
-
-export default class OscReceiver {
-
- constructor(options) {
-
- var {address, value, parent, propName, usePreArgs} = options
-
- if (typeof value === 'string' && isJSON(value)) {
- try {
- this.value = JSON5.parse(value)
- } catch (err) {
- this.value = value
- }
- } else {
- this.value = value
- }
-
- this.parent = parent
- this.propNames = [propName]
- this.usePreArgs = usePreArgs
- this.boundCallback = this.callback.bind(this)
- this.prefix = ''
- this.setAddress(address)
-
- }
-
- setAddress(address) {
-
- if (this.address !== address) {
-
- if (this.address) osc.off(this.prefix + this.address, this.boundCallback, this.parent)
-
- if (address) this.address = address
-
- if (this.address[0] !== '/') {
- var parentAddress = this.parent.getProp('address') || this.parent.resolveProp('address', undefined, false, this)
- if (parentAddress === 'auto') {
- var id = this.parent.getProp('id') || this.parent.resolveProp('id', undefined, false, this)
- parentAddress = '/' + id
- }
- this.prefix = parentAddress
- if (this.prefix[this.prefix.length - 1] !== '/') this.prefix += '/'
- }
-
- osc.on(this.prefix + this.address, this.boundCallback, {context: this.parent})
-
- }
-
- }
-
- addProp(propName){
-
- if (!this.propNames.includes(propName)) this.propNames.push(propName)
-
- }
-
- callback(data) {
-
- var {args} = data
-
- if (!Array.isArray(args)) args = [args]
- var preArgs = this.usePreArgs ? (this.parent.getProp('preArgs') || []) : []
- if (!Array.isArray(preArgs) && preArgs !== '') preArgs = [preArgs]
- if (args.length >= preArgs.length) {
- for (var i in preArgs) {
- if (preArgs[i] !== args[i]) return
- }
- if (!osc.match(this.parent, data)) return
- var value = args.slice(preArgs.length)
- if (value.length < 2) value = value[0]
- if (typeof value === 'string' && isJSONObject(value)) {
- try {
- this.value = JSON5.parse(value)
- } catch (err) {
- this.value = value
- }
- } else {
- this.value = value
- }
- this.parent.updateProps(this.propNames)
- }
-
- }
-
-}
diff --git a/src/client/widgets/common/queue.mjs b/src/client/widgets/common/queue.mjs
deleted file mode 100644
index b983e137..00000000
--- a/src/client/widgets/common/queue.mjs
+++ /dev/null
@@ -1,69 +0,0 @@
-import EventEmitter from '../../events/event-emitter.mjs'
-import {CANVAS_FRAMERATE} from '../../globals.mjs'
-
-class CanvasQueue extends EventEmitter{
-
- constructor() {
-
- super()
-
- this.queue = {}
- this.flushed = 0
- this.running = false
- this.frameLength = 1000 / CANVAS_FRAMERATE
- this.lastFrame = 0
- this.boundLoop = this.loop.bind(this)
-
- }
-
- push(widget) {
-
- this.queue[widget.hash] = widget
- this.flushed = 0
- if (!this.running) this.startLoop()
-
- }
-
- startLoop() {
-
- this.running = true
- this.flushed = 0
- requestAnimationFrame(this.boundLoop)
-
- }
-
- flush() {
-
- for (var h in this.queue) {
- if (this.queue[h].width > 0 && this.queue[h].height > 0 && this.queue[h].visible) {
- this.queue[h].draw()
- }
- }
-
- this.queue = {}
- this.flushed++
-
- }
-
- loop(timestamp) {
-
- if (this.flushed >= 10) {
- this.running = false
- return
- }
-
- requestAnimationFrame(this.boundLoop)
-
- var delta = timestamp - this.lastFrame
-
- if (delta > this.frameLength) {
- this.lastFrame = timestamp - (delta % this.frameLength)
- this.trigger('frame', {timestamp})
- this.flush()
- }
-
- }
-
-}
-
-export default new CanvasQueue()
diff --git a/src/client/widgets/common/widget.mjs b/src/client/widgets/common/widget.mjs
deleted file mode 100644
index a5626a35..00000000
--- a/src/client/widgets/common/widget.mjs
+++ /dev/null
@@ -1,1482 +0,0 @@
-import html from 'nanohtml'
-import morph from 'nanomorph'
-import scopeCss from 'scope-css'
-import {nanoid} from 'nanoid'
-import EventEmitter from '../../events/event-emitter.mjs'
-import osc from '../../osc.mjs'
-import widgetManager from '../../managers/widgets.mjs'
-import {urlParser, balancedReplace} from '../utils.mjs'
-import Vm from '../vm.mjs'
-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, JSON5} from '../../globals.mjs'
-
-var updateWidget = ()=>{},
- uiConsole, widgetTree, widgetDragResize, sessionManager
-
-setTimeout(async()=>{
- // use setTimeout to fix init order in safari...
- updateWidget = (await import('../../editor/data-workers.mjs')).updateWidget
- uiConsole = (await import('../../ui/ui-console.mjs')).default
- widgetTree = (await import('../../editor/index.mjs')).default.widgetTree
- widgetDragResize = (await import('../../editor/index.mjs')).default.widgetDragResize
- sessionManager = (await import('../../managers/session/index.mjs')).default
-})
-
-var vm = new Vm()
-
-var oscReceiverState = {}
-
-var OSCProps = [
- 'decimals',
- 'address',
- 'preArgs',
- 'typeTags',
- 'target',
- 'bypass'
-]
-
-class Widget extends EventEmitter {
-
- static description() {
-
- return ''
-
- }
-
- static defaults(Class=Widget) {
-
- var defaults = {
- widget: {
- lock: {type: 'boolean', value: false, help: 'Set to `true` to prevent modifying this widget with the editor. This will not prevent deleting the widget or moving it from a container to another.'},
- type: {type: 'string', value: 'auto', help: 'Widget type'},
- id: {type: 'string', value: 'auto', help: 'Widgets sharing the same `id` will act as clones and update each other\'s value(s) without sending extra osc messages (avoid doing so unless the widgets expect the exact same values).' },
- visible: {type: 'boolean', value: true, help: 'Set to `false` to hide the widget.'},
- interaction: {type: 'boolean', value: true, help: 'Set to `false` to disable pointer interactions.'},
- comments: {type: 'string', value: '', help: 'User comments.'},
- },
- geometry: {
- left: {type: 'number|string', value: 'auto', help: [
- 'When both top and left are set to auto, the widget is positioned according to the normal flow of the page (from left to right, by order of creation).',
- 'Otherwise, the widget will be positioned at absolute coordinates'
- ]},
- top: {type: 'number|percentage', value: 'auto', help: [
- 'When both top and left are set to auto, the widget is positioned according to the normal flow of the page (from left to right, by order of creation).',
- 'Otherwise, the widget will be positioned at absolute coordinates'
- ]},
- width: {type: 'number|percentage', value: 'auto', help: 'Widget width'},
- height: {type: 'number|percentage', value: 'auto', help: 'Widget height'},
- expand: {type: 'boolean|number', value: false, help: 'If parent\'s layout is `vertical` or `horizontal`, set this to `true` to stretch the widget to use available space automatically.'},
- },
- style: {
- colorText: {type: 'string', value: 'auto', help: 'Text color. Set to "auto" to inherit from parent widget. Must be a valid css color.'},
- colorWidget: {type: 'string', value: 'auto', help: 'Widget\'s default accent color. Set to "auto" to inherit from parent widget. Must be a valid css color.'},
- colorStroke: {type: 'string', value: 'auto', help: 'Stroke color. Set to "auto" to use `colorWidget`. Must be a valid css color.'},
- colorFill: {type: 'string', value: 'auto', help: 'Fill color. Set to "auto" to use `colorWidget`. Must be a valid css color.'},
- 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).'},
- lineWidth: {type: 'number', value: 'auto', help: 'Stroke width.'},
- borderRadius: {type: 'number|string', value: 'auto', help: 'Border radius expressed as a number or a css string. This property may not work for all widgets.'},
- padding: {type: 'number', value: 'auto', help: 'Inner spacing.'},
- html: {type: 'string', value: '', editor: 'html', syntaxChecker: false, help: [
- 'Custom html content to be inserted in the widget (before the widget\'s content). Elements are all unstyled by default, `css` should be used to customize their appearance.',
- 'The code is automatically wrapped in <div class="html"></div>',
- 'Note: inserting scripts may break the application.',
- ]},
- css: {type: 'string', value: '', editor: 'css', syntaxChecker: false, help: [
- 'CSS rules. See documentation .',
- 'Some style-related properties can be set or read from css using css variables:',
- ...Class.cssVariables.map(x=>'- `' + x.css + '`: `' + x.js + '`')
- ]},
- },
- class_specific: {
-
- },
- value: {
- value: {type: '*', value: '', help: 'Define the widget\'s value depending on other widget\'s values / properties using the advanced property syntax'},
- default: {type: '*', value: '', help: 'If set, the widget will be initialized with this value when the session is loaded.'},
- linkId: {type: 'string|array', value: '', help: [
- 'Widgets sharing the same `linkId` update each other\'s value(s) AND send their respective osc messages.',
- '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)'
- ]},
- },
- osc: {
- address: {type: 'string', value: 'auto', help: [
- 'OSC address for sending / receiving messages, it must start with a slash (`/`)',
- 'By default ("auto"), the widget\'s id is used: `/widget_id`',
- ]},
- preArgs: {type: '*|array', value: '', help: [
- 'A value or array of values that will be prepended to the widget\'s value in the OSC messages it sends.',
- 'Incoming messages must match these to affect by the widget.',
- ]},
- typeTags: {type: 'string', value: '', help: [
- 'Defines the osc argument types, one letter per argument (including preArgs)',
- '- If empty, the types are inferred automatically from the values (with numbers casted to floats by default)',
- '- If there are more arguments than type letters, the last type is used for the extra arguments',
- 'See OSC 1.0 specification for existing typetags'
- ]},
- decimals: {type: 'integer', value: 2, help: [
- 'Defines the number of decimals to send.',
- ]},
- target: {type: 'string|array|null', value: '', help: [
- 'This defines the targets of the widget\'s OSC messages',
- '- A `string` or `array` of strings formatted as follow: `ip:port` or `["ip:portA", "ip:portB"]`',
- '- If midi is enabled, targets can be `midi:device_name`',
- '- If no target is set, messages can still be sent if the server has default targets',
- ]},
- ignoreDefaults: {type: 'boolean', value: false, help: 'Set to `true` to ignore the server\'s default targets'},
- bypass: {type: 'boolean', value: false, help: 'Set to `true` to prevent the widget from sending any osc message'}
- },
- scripting: {
- onCreate: {type: 'script', value: '', editor: 'javascript', help: ['Script executed when the widget (and its children) is created. See documentation .']},
- onValue: {type: 'script', value: '', editor: 'javascript', help: ['Script executed when the widget\'s value updates. See documentation .']},
- }
- }
-
- Object.defineProperty(defaults, '_props', {
- enumerable: false,
- value: function(){
- let props = {}
- for (let category in this) {
- for (let k in this[category]) {
- if (k[0] === '_') continue
- props[k] = this[category][k].value
- }
- }
- return props
- }
- })
-
- Object.defineProperty(defaults, 'extend', {
- enumerable: false,
- value: function(obj){
- for (let i in obj) {
- if (obj[i] === null) delete this[i]
- else {
- if (this[i] === undefined) this[i] = {}
- for (let j in obj[i]) {
- if (obj[i][j] === null) delete this[i][j]
- else if (j[0] === '_') {
- this[i][j] = obj[i][j]
- } else {
- if (!this[i][j]) this[i][j] = {}
- Object.assign(this[i][j], obj[i][j])
- }
- }
- }
- }
- return this
- }
- })
-
- return defaults
-
- }
-
- constructor(options={}) {
-
- super()
-
- this.widget = options.html
- this.props = options.props
- this.errors = {}
- this.parent = options.parent
- this.parentNode = options.parentNode
- this.hash = options.hash || 'W' + nanoid(9)
- this.children = []
- this.reCreateOptions = options.reCreateOptions
- this.meta = options.meta || {}
- this.removed = false
- this.mounted = false
- this.visible = true
- this.scopes = []
-
- if (options.value !== undefined) this.value = options.value
-
- this.parsers = {}
- this.parsersLocalScope = options.locals || {}
- this.timeouts = {}
- this.intervals = {}
- this.variables = options.variables || {}
- this.fragments = {}
-
- this.createPropsCache()
-
- if (this.getProp('id') == 'root' && this.parent !== widgetManager) {
- this.props.id = '_root'
- this.cachedProps.id = '_root'
- }
-
- if (this.getProp('type') == 'root' && this.parent !== widgetManager) {
- this.props.type = 'panel'
- this.cachedProps.type = 'panel'
- }
-
-
-
- // cache decimals
- if (this.props.decimals !== undefined) {
- this.decimals = Math.min(20, Math.max(this.getProp('decimals'), 0))
- }
-
- // scripting
- this.scripts = {}
-
- if (this.getProp('onCreate')) {
- this.scripts.onCreate = new Script({
- widget: this,
- property: 'onCreate',
- code: this.getProp('onCreate'),
- context: {value: 0}
- })
- }
-
- if (this.getProp('onValue')) {
- this.scripts.onValue = new Script({
- widget: this,
- property: 'onValue',
- code: this.getProp('onValue'),
- context: {value: 0, id: '', touch: undefined}
- })
- this.on('value-changed', (e)=>{
- if (e.widget === this && this.mounted && e.options.script !== false) {
- this.scripts.onValue.run({
- value: e.options.widget ? e.options.widget.value : this.value,
- id: e.options.id || e.id
- }, e.options)
- }
- })
- }
-
- if (this.getProp('onTouch') && this.getProp('type') !== 'canvas') {
- this.scripts.onTouch = new Script({
- widget: this,
- property: 'onTouch',
- code: this.getProp('onTouch'),
- context: {event: {}, value: 0}
- })
- this.on('touch', (e)=>{
- var multi = Array.isArray(e.touch),
- state = multi ? e.touch[1] : e.touch
- this.scripts.onTouch.run({
- event: {type: state ? 'start' : 'stop', handle: multi ? e.touch[0] : undefined},
- value: this.value
- }, {sync: true, send: true})
- })
- }
-
- // legacy touch state in onValue script
- if (String(this.getProp('onValue')).includes('touch') && !this.getProp('onTouch')) {
- this.on('touch', (e)=>{
- this.scripts.onValue.run({
- value: this.value,
- id: this.getProp('id'),
- touch: e.touch
- }, {sync: true, send: true})
- })
- }
-
-
- this.style = null
- this.container = html`
-
- `
-
- if (this.widget) this.container.appendChild(this.widget)
- this.container._widget_instance = this
-
-
- this.container.classList.toggle('no-interaction', !this.getProp('interaction'))
-
- this.setContainerStyles()
- this.setCssVariables()
- this.setVisibility()
-
- this.extraHtml = null
- if (this.getProp('html')) this.updateHtml()
-
- }
-
- contains(widget) {
-
- if (this.children.indexOf(widget) > 0) return true
-
- var parent = widget.parent
- while (parent && parent !== widgetManager) {
- if (parent === this) return true
- parent = parent.parent
- }
- return false
-
- }
-
- getAllChildren() {
-
- var children = []
- for (var i = 0; i < this.children.length; i++) {
- if (!this.children[i]) continue
- children.push(this.children[i])
- children = children.concat(this.children[i].getAllChildren())
- }
- return children
-
-
- }
-
- created(index) {
-
- this.trigger('widget-created', {
- id: this.getProp('id'),
- widget: this,
- options: this.reCreateOptions,
- index: index
- })
-
- if (this.scripts.onCreate) this.scripts.onCreate.run({value: this.value}, {sync: true, send: true, onCreate: true})
-
- }
-
- changed(options) {
-
- this.trigger('value-changed', {
- widget: this,
- options: options,
- id: this.getProp('id'),
- linkId: this.getProp('linkId')
- })
-
- }
-
- sendValue(overrides, options={}) {
-
- if (this.selfLinkedOSCProps) {
- this.updateProps(this.selfLinkedOSCProps, this)
- }
-
- if (this.getProp('bypass') && !options.force) return
-
- var data = {
- h: this.hash,
- v: this.getValue(true),
- }
-
- if (this.getProp('ignoreDefaults') && !options.force) data.i = 1
-
- if (overrides) {
- for (var k in overrides) {
- data[k] = overrides[k]
- }
- }
-
- if (options.syncOnly) {
-
- osc.sync(data)
-
- } else {
-
- osc.send(data)
-
- }
-
- }
-
- setValue() {}
-
- getValue(withdecimals) {
-
- return deepCopy(this.value, withdecimals ? this.decimals : undefined)
-
- }
-
- areEquivalentValueProps(a, b) {
- /* See commit c1720b4a and https://openstagecontrol.discourse.group/t/widget-update-when-setting-value-via-edit/4186/7
- * for the root of this...
- */
-
- var currentValue = deepCopy(this.value)
- var va, vb
-
- this.setValue(a, {coerceTest: true})
- va = deepCopy(this.value)
- this.setValue(b, {coerceTest: true})
- vb = deepCopy(this.value)
-
- this.setValue(currentValue)
-
- return deepEqual(va, vb)
- }
-
- checkLinkedProps(propNames) {
-
- // Dynamic props cache check
- var linkedProps = []
-
- Object.values(this.nestedLinkedProps).forEach(l => linkedProps = linkedProps.concat(l))
- Object.values(this.linkedProps).forEach(l => linkedProps = linkedProps.concat(l))
- Object.values(this.linkedPropsValue).forEach(l => linkedProps = linkedProps.concat(l))
- Object.values(this.oscReceivers).forEach(r => linkedProps = linkedProps.concat(r.propNames))
- Object.values(this.variables).forEach(r => linkedProps = linkedProps.concat(r.propNames))
- Object.values(this.fragments).forEach(l => linkedProps = linkedProps.concat(l))
-
- if (
- // if prop/osc listeners/custom vars have changed (@{} / OSC{} / VAR{})
- // refresh the widget's props cache and update linked props bindings
- propNames.map(x => this.props[x]).some(x => typeof x === 'string' && x.match(/(OSC|@|VAR|IMPORT)\{/))
- || propNames.some(n => linkedProps.includes(n))
- ) {
- this.createPropsCache()
- return true
- }
-
- }
-
- createPropsCache() {
-
- /*
- scopable: cache id prefixes (scopes), from nearest to farthest
- */
- this.scopes = []
- if (this.meta.scopable) {
- var parent = this.parent
- do {
- if (parent.getProp('scoped')) {
- this.scopes.push(parent.scopeId)
- }
- parent = parent.parent
- } while (parent.meta.scopable || parent.getProp('scoped'))
- for (var i=0; i < this.scopes.length; i++) {
- this.scopes[i] = this.scopes.slice(i).reverse().join('/') + '/'
- }
- }
- // include global scope
- if (this.scopes.length) this.scopes.push('')
-
- // @{props} links lists
- this.linkedProps = {}
- this.nestedLinkedProps = {}
- this.linkedPropsValue = {}
-
- // reset VAR{} links
- for (var name in this.variables) {
- this.variables[name].propNames = []
- }
-
- // OSC{/path} receivers
- if (this.oscReceivers) {
- this.removeOscReceivers()
- }
- this.oscReceivers = {}
-
- // IMPORT{} fragments
- this.fragments = {}
-
- // Cache resolved props
- this.cachedProps = {}
- this.cachedProps.uuid = this.hash
-
- for (var k in this.props) {
- if (k != 'widgets' && k != 'tabs') {
- this.cachedProps[k] = this.resolveProp(k, undefined, true)
- } else {
- this.cachedProps[k] = this.props[k]
- }
- }
-
- this.createLinkedPropsBindings()
-
- }
-
- createLinkedPropsBindings() {
-
- if (!this.linkedCreatedCallback && Object.keys(this.linkedProps).length) {
-
- this.linkedCreatedCallback = (e)=>{
- this.onLinkedPropsChanged(e, 'widget-created')
- }
-
- this.linkedPropChangedCallback = (e)=>{
- this.onLinkedPropsChanged(e, 'prop-changed')
- }
-
- widgetManager.on('widget-created', this.linkedCreatedCallback, {context: this})
- widgetManager.on('prop-changed', this.linkedPropChangedCallback, {context: this})
-
- } else if (this.linkedCreatedCallback && !Object.keys(this.linkedProps).length) {
-
- widgetManager.off('widget-created', this.linkedCreatedCallback)
- widgetManager.off('prop-changed', this.linkedPropChangedCallback)
- delete this.linkedCreatedCallback
- delete this.linkedPropChangedCallback
-
- }
-
- if (!this.linkedValueChangedCallback && Object.keys(this.linkedPropsValue).length) {
-
- this.linkedValueChangedCallback = (e)=>{
- this.onLinkedPropsChanged(e, 'value-changed')
- }
-
- widgetManager.on('value-changed', this.linkedValueChangedCallback, {context: this})
-
- } else if (this.linkedPropsValueCallback && !Object.keys(this.linkedPropsValue).length) {
-
- widgetManager.off('value-changed', this.linkedValueChangedCallback)
- delete this.linkedValueChangedCallback
-
- }
-
- if (!this.linkedFragmentCallback && Object.keys(this.fragments).length) {
-
- this.linkedFragmentCallback = (e)=>{
- var {path} = e
- if (this.fragments[path]) this.updateProps(this.fragments[path])
- }
-
- sessionManager.on('fragment-updated', this.linkedFragmentCallback, {context: this})
-
- } else if (this.linkedFragmentCallback && !Object.keys(this.fragments).length) {
-
- sessionManager.off('fragment-updated', this.linkedFragmentCallback)
- delete this.linkedFragmentCallback
-
- }
-
- var selfLinkedOSCProps = (this.linkedPropsValue['this'] || []).filter(i=>OSCProps.indexOf(i) > -1)
- this.selfLinkedOSCProps = selfLinkedOSCProps.length ? selfLinkedOSCProps : false
-
- }
-
- onLinkedPropsChanged(e, type) {
-
- var {id, widget, options} = e,
- changedProps = type === 'prop-changed' ? e.props : type === 'value-changed' ? ['value'] : undefined,
- linkedProps = type === 'value-changed' ? this.linkedPropsValue : this.linkedProps
-
- if (widget === this.parent) {
- if (type === 'widget-created') return
- id = 'parent'
- } else if (this.parent !== widgetManager && widget === this.parent.parent && this.parent.getProp('type') === 'clone') {
- // ignore clone wrapper when resolving properties
- id = 'parent'
- }
-
- if (widget === this) id = 'this'
-
- /*
- scopable: attempt to resolve scoped widget updates against ids in advanced syntax blocks
- */
- if (this.scopes.length) {
- var unprefixedId
- for (var p of this.scopes) {
- if (id.includes(p)) {
- unprefixedId = id.replace(p, '')
- if (this.nestedLinkedProps[unprefixedId] || linkedProps[unprefixedId]) {
- id = unprefixedId
- break
- }
- }
- }
- }
-
- if (this.nestedLinkedProps[id]) {
- this.updateLinkedPropsWithNesting(id)
- }
-
- if (linkedProps[id]) {
- this.updateProps(linkedProps[id], widget, options, changedProps)
- }
-
- }
-
- removeOscReceivers() {
-
- osc.off(undefined, undefined, this)
- for (var i in this.oscReceivers) {
- oscReceiverState[i] = this.oscReceivers[i].value
- }
- this.oscReceivers = {}
-
- }
-
- updateLinkedPropsWithNesting(i) {
-
- for (var prop of this.nestedLinkedProps[i]) {
-
- // 1. remove all linked props found in properties bound to the nested link
- for (var linksStores of [this.linkedPropsValue, this.linkedProps]) {
- for (let id in linksStores) {
- if (linksStores[id].includes(prop)) {
- linksStores[id].splice(linksStores[id].indexOf(prop), 1)
- if (!linksStores[id].length) delete linksStores[id]
- }
- }
- }
-
-
- // 2. resolve these props again and recreate links (3rd arg to true)
- this.resolveProp(prop, undefined, true, this)
-
- }
-
-
- }
-
- resolveProp(propName, propValue, storeLinks=true, originalWidget, originalPropName, context, recursive) {
-
- propValue = propValue !== undefined ? propValue : deepCopy(this.props[propName])
- originalWidget = originalWidget || this
- originalPropName = originalPropName || propName
-
- var variables = {},
- defaultScope = this.constructor.parsersContexts[propName] || {},
- jsScope = context || {},
- varnumber = 999
-
- if (typeof propValue == 'string') {
-
- propValue = balancedReplace('@', '{', '}', propValue, (content)=>{
-
- if (content.indexOf('@{') >= 0) {
-
- content = balancedReplace('@', '{', '}', content, (subcontent)=>{
- return this.resolveProp(propName + '-nested', '@{' + subcontent + '}', storeLinks ? 'nested' : false, this)
- })
-
- }
-
- let id = content.split('.'),
- k, subk
-
- if (id.length > 1) {
-
- k = id.pop()
- subk = undefined
-
- if (id.length > 1) {
- subk = k
- k = id.pop()
- }
-
- id = id.join('.')
-
- } else {
-
- id = id[0]
- k = 'value'
-
- }
-
- var widgets = id == 'parent' && this.parent ?
- [this.parent] : id == 'this' ? [this] :
- widgetManager.getWidgetById(id, this.scopes)
-
- if (!widgets.length) {
- var parent = this.parent
- while (parent && parent != widgetManager) {
- if (parent.getProp('id') == id) {
- widgets.push(parent)
- break
- }
- parent = parent.parent
- }
- }
-
-
- // ignore clone wrapper in @parent stack (https://framagit.org/jean-emmanuel/open-stage-control/-/work_items/379)
- if (widgets[0] === this.parent && this.parent !== widgetManager && this.parent.getProp('type') === 'clone') widgets = [this.parent.parent]
-
- if (storeLinks) {
-
- if (propName.indexOf('-nested') !== -1) propName = propName.replace('-nested', '')
-
- if (k == 'value') {
-
- if (!this.linkedPropsValue[id]) this.linkedPropsValue[id] = []
- if (this.linkedPropsValue[id].indexOf(propName) == -1) this.linkedPropsValue[id].push(propName)
-
- } else {
-
- if (!this.linkedProps[id]) this.linkedProps[id] = []
- if (this.linkedProps[id].indexOf(propName) == -1) this.linkedProps[id].push(propName)
-
- }
-
- if (storeLinks === 'nested') {
- if (!this.nestedLinkedProps[id]) this.nestedLinkedProps[id] = []
- if (this.nestedLinkedProps[id].indexOf(propName) == -1) this.nestedLinkedProps[id].push(propName)
- }
-
- }
-
- for (var i in widgets) {
-
- if (widgets[i] === widgetManager) continue
-
- if (widgets[i].props[k] !== undefined || k === 'value' || k === 'uuid') {
-
- if (k !== 'value' && originalPropName === k && widgets[i] === originalWidget) {
- return 'ERR_CIRCULAR_REF'
- }
-
- var r
- switch (k) {
- case 'value':
- r = typeof widgets[i].value === 'object' ? widgets[i].value : widgets[i].getValue(true)
- break
- case 'uuid':
- r = widgets[i].hash
- break
- case 'tabs':
- case 'widgets':
- r = widgets[i].props[k]
- break
- default:
- r = widgets[i].resolveProp(k, undefined, storeLinks, originalWidget, originalPropName)
- break
- }
-
- if (subk !== undefined && r !== undefined) r = r[subk]
-
- var varname = 'VAR_' + varnumber
- varnumber--
-
- variables[varname] = r
- jsScope[varname] = r
-
- return varname
-
- }
-
- }
-
- return 'undefined'
-
- })
-
- propValue = balancedReplace('VAR', '{', '}', propValue, (args)=>{
-
- if (args === '') return 'undefined'
-
- let [name, value] = args.split(',')
- .map(x=>x.trim())
- .map(x=>x.replace(/VAR_[0-9]+/g, (m)=>{
- return typeof variables[m] === 'string' ? variables[m] : JSON.stringify(variables[m])
- }))
-
- if (typeof value === 'string' && isJSON(value)) {
- try {
- value = JSON5.parse(value)
- } catch (err) {}
- }
-
- if (
- // remove quotes
- (name[0] === '"' && name[name.length - 1] === '"') ||
- (name[0] === '\'' && name[name.length - 1] === '\'')
- ) name = name.slice(1, name.length - 1)
-
- if (!this.variables[name]) {
-
- this.variables[name] = {default: value, value: value, propNames: [propName]}
-
-
- } else if (!this.variables[name].propNames.includes(propName)) {
-
- this.variables[name].propNames.push(propName)
-
- }
-
- // update value if default changed
- if (
- value !== undefined &&
- !this.variables[name].updated && // only true on edit
- value !== this.variables[name].default
- ) {
- this.variables[name].default = value
- this.variables[name].value = value
- if (this.variables[name].propNames.length > 1) {
- this.updateProps(this.variables[name].propNames.filter(x=>x!==propName))
- }
- }
-
- var r = this.variables[name].value
-
- var varname = 'VAR_' + varnumber
- varnumber--
-
- variables[varname] = r
- jsScope[varname] = r
-
- return varname
- })
-
- propValue = balancedReplace('IMPORT', '{', '}', propValue, (file)=>{
-
- file = file.replace(/VAR_[0-9]+/g, (m)=>{
- return typeof variables[m] === 'string' ? variables[m] : JSON.stringify(variables[m])
- })
-
- if (
- // remove quotes
- (file[0] === '"' && file[file.length - 1] === '"') ||
- (file[0] === '\'' && file[file.length - 1] === '\'')
- ) file = file.slice(1, file.length - 1)
-
- if (storeLinks) {
- if (!this.fragments[file]) this.fragments[file] = []
- if (!this.fragments[file].includes(propName)) this.fragments[file].push(propName)
- }
- var r
- if (sessionManager.getFragment(file)) {
- r = sessionManager.getFragment(file)
- } else {
- sessionManager.loadFragment(file, true)
- r = ''
- }
-
- var varname = 'VAR_' + varnumber
- varnumber--
-
- variables[varname] = r
- jsScope[varname] = r
-
- return varname
- })
-
- propValue = balancedReplace('OSC', '{', '}', propValue, (args)=>{
-
- if (args === '') return 'undefined'
-
- let [address, value, usePreArgs] = args.split(',')
- .map(x=>x.trim())
- .map(x=>x.replace(/VAR_[0-9]+/g, (m)=>{
- return typeof variables[m] === 'string' ? variables[m] : JSON.stringify(variables[m])
- }))
-
- if (!address) return 'undefined'
-
- if (!this.oscReceivers[args]) {
- this.oscReceivers[args] = new OscReceiver({
- address: address,
- value: value,
- parent: this,
- propName: propName,
- usePreArgs: usePreArgs === 'false' ? false : true
- })
- if (oscReceiverState[args]) {
- this.oscReceivers[args].value = oscReceiverState[args]
- delete oscReceiverState[args]
- }
- } else {
- this.oscReceivers[args].setAddress(address)
- this.oscReceivers[args].addProp(propName)
- this.oscReceivers[args].usePreArgs = usePreArgs === 'false' ? false : true
- }
-
- var r = this.oscReceivers[args].value
-
- var varname = 'VAR_' + varnumber
- varnumber--
-
- variables[varname] = r
- jsScope[varname] = r
-
- return varname
- })
-
- try {
- propValue = balancedReplace('JS', '{', '}', propValue, (code)=>{
-
- if (code[0] === '{' && code[code.length - 1] === '}') code = code.slice(1, code.length - 1)
-
- if (!this.parsers[code]) this.parsers[code] = vm.compile(code, defaultScope)
-
- let r
- vm.setWidget(this)
- try {
- r = this.parsers[code](jsScope, this.parsersLocalScope)
- } catch (err) {
- vm.setWidget()
- throw err
- }
- vm.setWidget()
-
- if (r === undefined) r = ''
-
- return typeof r !== 'string' ? JSON.stringify(r) : r
-
- })
- } catch (err) {
- this.errorProp(propName, 'JS{}', err)
- }
-
- try {
- propValue = balancedReplace('#', '{', '}', propValue, (code)=>{
-
- if (!this.parsers[code]) this.parsers[code] = vm.compile('return ' + code.trim(), defaultScope)
-
- let r
- vm.setWidget(this)
- try {
- r = this.parsers[code](jsScope, this.parsersLocalScope)
- } catch (err) {
- vm.setWidget()
- throw err
- }
- vm.setWidget()
-
- if (r === undefined) r = ''
-
- return typeof r !== 'string' ? JSON.stringify(r) : r
-
- })
- } catch (err) {
-
- this.errorProp(propName, '#{}', err)
- }
-
- for (let k in variables) {
- var v = typeof variables[k] === 'string' ? variables[k] : JSON.stringify(variables[k])
- propValue = propValue.replace(new RegExp(k, 'g'), v)
- }
-
- if (
- // json heuristic
- isJSON(propValue) &&
- // allow "false" string in label
- (propName !== 'label' || propValue === 'false') &&
- // don't coerce booleans and numbers as strings in objects
- (!recursive || (isNaN(propValue) && propValue != 'true' && propValue != 'false'))
- ) {
- try {
- propValue = JSON.parse(propValue)
- } catch (err) {}
- }
-
- } else if (propValue != null && typeof propValue == 'object') {
- for (let k in propValue) {
- propValue[k] = this.resolveProp(propName, propValue[k], storeLinks, originalWidget, originalPropName, context, true)
- }
- }
-
-
- return this.transformProp(propName, propValue)
-
-
- }
-
- transformProp(propName, propValue) {
-
- switch (propName) {
- /*
- scopable: prefix id with the closest (most restrictive) scope
- */
- case 'id':
- if (this.scopes.length) {
- propValue = this.scopes[0] + propValue
- }
- break
- }
-
- return propValue
-
- }
-
- getProp(propName) {
- return this.cachedProps[propName]
- }
-
-
- isDynamicProp(propName) {
-
- return this.constructor.dynamicProps.indexOf(propName) !== -1
-
- }
-
- updateProps(propNames, widget, options, updatedProps = []) {
-
- if (propNames.includes('value')) {
- propNames.splice(propNames.indexOf('value'), 1)
- propNames.push('value')
- }
-
- if (widget && options) options.id = widget.getProp('id')
-
- var reCreate = false,
- changedProps = []
-
- for (var propName of propNames) {
-
- if (widget === this && updatedProps.includes(propName)) continue
-
- let propValue = this.resolveProp(propName, undefined, false),
- oldPropValue = this.getProp(propName)
-
- if (
- !deepEqual(oldPropValue, propValue) ||
- (options && options.fromEditor && propName == 'value' && !this.areEquivalentValueProps(propValue, oldPropValue))
- ) {
- if (!this.isDynamicProp(propName)) {
-
- if (this.constructor._defaults[propName] === undefined) {
-
- // ignore invalid properties
- continue
-
- } else if (widget && this.contains(widget)) {
-
- this.errorProp(propName, '@{}', `a container can't use its child's properties to define non-dynamic properties.`)
- continue
-
- } else if (widget === this && updatedProps.length === 1 && updatedProps[0] === 'value') {
-
- this.errorProp(propName, '@{}', `a widget can't use it's own value to define non-dynamic properties.`)
- continue
-
- } else {
-
- reCreate = true
- break
-
- }
-
- } else {
-
- changedProps.push({propName, propValue, oldPropValue})
-
- }
-
- }
- }
-
- if (reCreate) {
-
- return this.reCreateWidget({reCreateOptions: options})
-
- }
-
-
- if (changedProps.length) {
-
- for (var i in changedProps) {
- this.cachedProps[changedProps[i].propName] = changedProps[i].propValue
- this.onPropChanged(changedProps[i].propName, options, changedProps[i].oldPropValue)
- }
-
- widgetManager.trigger('prop-changed', {
- id: this.getProp('id'),
- props: changedProps,
- widget: this,
- options: options
- })
-
- }
-
- if (options && options.fromEditor) {
-
- // update advanced syntax bindings if its an edition
- if (this.checkLinkedProps(propNames)) {
-
- // emit prop-changed event if not already
- // to make sure an advanced syntax changes don't go unnoticed by clone
- var unNotified = propNames.filter(n => !changedProps.includes(n))
- widgetManager.trigger('prop-src-changed', {
- id: this.getProp('id'),
- props: unNotified,
- widget: this,
- options: options
- })
- }
-
- }
-
- }
-
- onPropChanged(propName, options={}, oldPropValue) {
-
- switch(propName) {
-
- case 'value':
- this.setValue(this.getProp('value'), {sync: true, send: options.send, id: options.id})
- return
-
- case 'top':
- case 'left':
- this.setContainerStyles(['geometry'])
- return
-
- case 'height':
- case 'width':
- case 'expand': {
- this.setContainerStyles(['geometry'])
- let container = this.parent !== widgetManager && this.parent.getProp('layout') !== 'default' ? this.parent.container : this.container
- resize.check(container)
- if (widgetDragResize.mounted && widgetDragResize.widgets.includes(this)) widgetDragResize.updateRectangle()
- return
- }
-
- case 'visible': {
- this.setVisibility()
- let container = this.parent !== widgetManager && this.parent.getProp('layout') !== 'default' ? this.parent.container : this.container
- resize.check(container)
- widgetTree.updateVisibility(this)
- return
- }
-
- case 'interaction':
- this.container.classList.toggle('no-interaction', !this.getProp('interaction'))
- return
-
- case 'html':
- this.updateHtml()
- resize.check(this.container)
- return
-
- case 'css': {
- this.setContainerStyles(['css'])
- var re = /width|height|display|margin|padding|flex/
- if (re.test(oldPropValue) || re.test(this.getProp('css'))) {
- let container = this.parent !== widgetManager && this.parent.getProp('layout') !== 'default' ? this.parent.container : this.container
- resize.check(container)
- if (widgetDragResize.mounted && widgetDragResize.widgets.includes(this)) widgetDragResize.updateRectangle()
- }
- return
- }
-
- case 'colorText':
- case 'colorWidget':
- case 'colorFill':
- case 'colorStroke':
- case 'alphaStroke':
- case 'alphaFillOff':
- case 'alphaFillOn':
- case 'lineWidth':
- case 'padding':
- this.setCssVariables()
- return
-
- case 'decimals':
- this.decimals = Math.min(20, Math.max(this.getProp('decimals'), 0))
- return
-
- case 'address':
- case 'preArgs':
- case 'typeTags':
- case 'target':
- if (propName === 'address') {
- for (var k in this.oscReceivers) {
- var receiver = this.oscReceivers[k]
- if (receiver.prefix !== '') {
- receiver.setAddress()
- }
- }
- }
- var data = {},
- oldData = {
- preArgs: propName == 'preArgs' ? oldPropValue : this.getProp('preArgs'),
- address: propName == 'address' ? oldPropValue : this.getProp('address')
- }
- data[propName] = this.getProp(propName)
-
- if (data.address === 'auto') data.address = '/' + this.getProp('id')
- if (oldData.address === 'auto') oldData.address = '/' + this.getProp('id')
-
- widgetManager.registerWidget(this, data, oldData)
- return
-
- }
-
- }
-
-
- log(message) {
-
- if (!uiConsole) return
-
- var widget = this,
- id = widget.getProp('id')
-
- console._log(`${id}${name ? '.' + name : ''}: ${message}`)
- uiConsole.log('log', `${id} : ${message}`, true)
-
- }
-
- 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 : 2)) : '',
- id = this.getProp('id') || this.props.id,
- widget = this // used for edit link in console
-
- while (widget.meta.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 ? '.' + name : ''} ${type} error${line}: ${error}`)
- console.debug(error)
- uiConsole.log('error', `${id} ${name ? '.' + name : ''} ${type} error${line}: ${error}`, true)
- }
-
- setContainerStyles(styles = ['geometry', 'css', 'visibility']) {
-
- if (styles.includes('geometry')) {
-
- // geometry
- var absolutePos = false
- for (let d of ['width', 'height', 'top', 'left']) {
- let val = this.getProp(d),
- geometry
-
- if (val !== undefined) {
- if (parseFloat(val) < 0) val = 0
- geometry = parseFloat(val) == val ? parseFloat(val)+'rem' : val
- }
-
- if (geometry) {
- if (geometry === 'auto') geometry = ''
- this.container.style[d] = geometry
- if (d === 'width') this.container.style.minWidth = geometry
- if (d === 'height') this.container.style.minHeight = geometry
- absolutePos = absolutePos || geometry && (d === 'top' || d === 'left')
-
- }
- }
- this.container.classList.toggle('absolute-position', absolutePos)
- this.container.classList.toggle('flex-expand', this.getProp('expand'))
- this.container.classList.toggle('not-editable', !!this.meta.not_editable)
-
-
- }
-
- if (styles.includes('css')) {
-
- // css
- var css = String(this.getProp('css')),
- extraCssClasses = []
-
- // extra css "class" property
- css = css.replace(/^[^\S\n]*class[^\S\n]*:[^\S\n]*([^;\n\s]+);?/igm, (m, c)=>{
- if (c === 'widget' || c.includes('-container')) return m
- extraCssClasses.push(c.replace(/"'/g,''))
- return ''
- })
-
-
- // escape windows absolute file paths
- css = css.replace(/url\(([^)]*)\)/g, (m, url)=>{
- var parser = urlParser(url)
- if (!parser.protocol.match(/http|data/)) m = m.replace(':', '_:_')
- m = m.replace(/\\/g, '\\\\')
- return m
- })
-
-
- var prefix = '#' + this.hash,
- scopedCss = '',
- unScopedCss = ''
-
- if (css.includes('{')) {
-
- scopedCss = scopeCss(css, prefix)
-
- css
- .replace(/\{[^}]*\}/g, '')
- .replace(/^[^@#.]*:.*/gm, (m)=>{
- unScopedCss += m[m.length - 1] === ';' ? m : m + ';'
- })
-
- if (scopedCss.indexOf('@keyframes') > -1) scopedCss = scopedCss.replace(new RegExp(prefix + '\\s+([0-9]+%|to|from)', 'g'), ' $1')
- if (scopedCss.indexOf('&') > -1) scopedCss = scopedCss.replace(new RegExp(prefix + '\\s&', 'g'), prefix)
-
- } else {
-
- unScopedCss = css
-
- }
-
-
-
-
- var style = (unScopedCss ? prefix + '{' + unScopedCss + '}\n' : '') + scopedCss
- style = style.trim()
-
- if (this.style && this.container.contains(this.style)) {
- if (style) this.style.innerText = style
- else this.container.removeChild(this.style)
- } else if (scopedCss.length || unScopedCss.length){
- this.style = html``
- this.container.insertBefore(this.style, this.container.childNodes[0] || null)
- }
-
-
- // apply extra css classes
- if (!deepEqual(extraCssClasses, this.extraCssClasses)) {
- if (this.extraCssClasses && this.extraCssClasses.length) {
- this.container.classList.remove(...this.extraCssClasses)
- this.extraCssClasses = []
- }
-
- if (extraCssClasses.length) {
- this.container.classList.add(...extraCssClasses)
- this.extraCssClasses = extraCssClasses
- }
- }
-
-
- // store transform matrix if any
- // if (css.includes('transform')) {
- // setTimeout(()=>{
- // var style = window.getComputedStyle(this.container)
- // this.cssTransform = style.transform || 'none'
- // this.cssTransformOrigin = style.transformOrigin
- // })
- // } else {
- // this.cssTransform = 'none'
- // }
-
-
- }
-
- }
-
- setCssVariables() {
-
-
- for (var data of this.constructor.cssVariables) {
-
- var val = this.getProp(data.js)
- this.container.style.setProperty(data.css, val !== undefined && val !== 'auto' ? data.toCss ? data.toCss(val) : val : '')
-
- }
-
- }
-
- updateHtml(){
-
- var extraHtml = this.getProp('html') || null
-
- if (this.extraHtml) {
- if (!extraHtml) {
- this.container.removeChild(this.extraHtml)
- this.extraHtml = null
- } else {
- let newHtml = html`
`
- newHtml.innerHTML = extraHtml
- morph(this.extraHtml, newHtml)
- }
-
- } else if (extraHtml) {
- let newHtml = html`
`
- newHtml.innerHTML = extraHtml
- this.container.insertBefore(newHtml, this.widget)
- this.extraHtml = newHtml
- }
-
- }
-
- isVisible() {
-
- return this.getProp('visible') && this.parent.isVisible()
-
- }
-
- setVisibility() {
-
- var visible = this.isVisible()
-
- if (visible !== this.visible) {
- this.visible = !!visible
- this.container.style.display = this.visible ? '' : 'none'
-
- for (var c of this.children) {
- if (c) c.setVisibility()
- }
-
- }
-
- }
-
- reCreateWidget(options={}){
-
- if (!this.removed) return updateWidget(this, options)
-
- }
-
- onRemove(){
-
- for (var k in this.scripts) {
- this.scripts[k].onRemove()
- }
-
- this.removed = true
- for (var name in this._listeners) {
- if (name !== 'widget-removed') this.off(name)
- }
-
- widgetManager.off(undefined, undefined, this)
- sessionManager.off(undefined, undefined, this)
- this.removeOscReceivers()
-
- }
-
-}
-
-Widget.parsersContexts = {}
-
-Widget.cssVariables = [
- {js: 'colorBg', css: '--color-background'},
- {js: 'colorWidget', css: '--color-widget'},
- {js: 'colorFill', css: '--color-fill'},
- {js: 'colorStroke', css: '--color-stroke'},
- {js: 'colorText', css: '--color-text'},
- {js: 'padding', css: '--widget-padding', toCss: x=>parseFloat(x) + 'rem', toJs: x=>parseFloat(x) * PXSCALE},
- {js: 'lineWidth', css: '--line-width', toCss: x=>parseFloat(x) + 'rem', toJs: x=>parseFloat(x) * PXSCALE},
- {js: 'borderRadius', css: '--border-radius', toCss: x=>parseFloat(x) == x ? x + 'rem' : x, toJs: x=>parseFloat(x)},
- {js: 'alphaFillOn', css: '--alpha-fill-on', toCss: x=>parseFloat(x), toJs: x=>parseFloat(x)},
- {js: 'alphaFillOff', css: '--alpha-fill-off', toCss: x=>parseFloat(x), toJs: x=>parseFloat(x)},
- {js: 'alphaStroke', css: '--alpha-stroke', toCss: x=>parseFloat(x), toJs: x=>parseFloat(x)},
-]
-
-Widget.dynamicProps = [
- 'visible',
- 'interaction',
- 'comments',
-
- 'top',
- 'left',
- 'height',
- 'width',
- 'expand',
-
-
- 'colorText',
- 'colorWidget',
- 'colorFill',
- 'colorStroke',
- 'alphaStroke',
- 'alphaFillOff',
- 'alphaFillOn',
- 'padding',
- 'lineWidth',
- 'html',
- 'css',
-
- 'value',
-
- 'decimals',
- 'address',
- 'preArgs',
- 'typeTags',
- 'target',
- 'bypass'
-]
-
-export default Widget
diff --git a/src/client/widgets/containers/clone.mjs b/src/client/widgets/containers/clone.mjs
deleted file mode 100644
index bf855b51..00000000
--- a/src/client/widgets/containers/clone.mjs
+++ /dev/null
@@ -1,342 +0,0 @@
-import html from 'nanohtml'
-import Container from '../common/container.mjs'
-import widgetManager from '../../managers/widgets.mjs'
-import * as resize from '../../events/resize.mjs'
-import parser from '../../parser.mjs'
-import {deepCopy, deepEqual} from '../../utils.mjs'
-import {diff, diffToWidget} from '../../editor/diff'
-import Session from '../../managers/session/session.mjs'
-
-var excludedCloneClasses = ['widget', 'absolute-position', 'not-editable', 'editing', 'flex-expand', 'no-interaction']
-
-class Clone extends Container() {
-
- static description() {
-
- return 'Widget replication with overridable properties.'
-
- }
-
- static defaults() {
-
- var defaults = super.defaults().extend({
-
- class_specific: {
- widgetId: {type: 'string', value: '', help: '`id` of the widget to clone'},
- scoped: {type: 'boolean|string', value: false, help: [
- 'Set to `true` to prefix all cloned `id`s inside the clone with a unique identifier and make the clone independent from its original. All `@{}` blocks and scripts will be prefixed automatically so that they resolve to widgets within the clone if possible, falling back to unprefixed ids otherwise. `linkId` will be prefixed as well but will only resolve within the clone.',
- '`clone` and `scrollbar` widgets will prioritize targets closer to their scope, falling back to farther target.',
- 'Set this property to a string to define the `ìd` prefix manually (a trailing slash will be added automatically). This can be useful if one must access a scoped widget via scripting or remote control commands.'
- ]},
- props: {type: 'object', value: {}, editor: 'javascript', syntaxChecker: false, help: 'Cloned widget\'s properties to override'},
- },
- value: null,
- osc: null,
- scripting: null
- })
-
- defaults.style = {css: defaults.style.css}
-
- return defaults
-
- }
-
- constructor(options) {
-
- options.props.address = 'auto'
- options.props.variables = '@{parent.variables}'
-
- super({...options, html: html`
`})
-
- this.noValueState = true
-
- this.cloneLock = false
- this.cloneTarget = null
- this.targetRank = null
- this.cloneClass = []
-
- this.scopeId = this.getProp('scoped') === true ? this.hash : this.getProp('scoped') === false ? '' : this.getProp('scoped')
-
- this.modalBreakout = 0
-
- this.container.classList.add('empty')
-
- var parent = this.parent
- while (parent !== widgetManager) {
- if (parent.getProp('id') === this.getProp('widgetId')) {
- this.errorProp('widgetId', 'circular reference', 'cannot create clone: target widget is a parent of this clone.')
- return
- }
- parent = parent.parent
- }
-
- this.getCloneTarget()
-
- widgetManager.on('widget-created', (e)=>{
-
- // if in a non-scoped context we don't watch for a closer target once we have one
- if (!this.scopes.length && this.cloneTarget) return
-
- var {id, widget} = e
-
- if (String(id).includes(this.getProp('widgetId')) && this.isValidCloneTarget(widget)) {
-
- this.getCloneTarget()
-
- }
-
- }, {context: this})
-
- var onPropChanged = (e)=>{
- // watch for prop changes initiated by the editor
- // Other changes (from advanced syntaxes) are already
- // handled by standard widget mechanicsé
-
- if (!this.cloneTarget) return
- if (!e.options || !e.options.fromEditor) return
-
- if (e.widget === this.cloneTarget || this.cloneTarget.contains(e.widget)) {
-
- this.updateClone(e.options)
-
- }
-
- }
-
- widgetManager.on('prop-changed', onPropChanged, {context: this})
-
- // see common/widget.js @ updateProps()
- widgetManager.on('prop-src-changed', onPropChanged, {context: this})
-
- }
-
- getCloneTarget() {
-
- // attempt to acquire a cloneTarget if 'widget-created' event has not been caught
- // (the target might have been created before the clone itself)
-
- var scopes = this.scopes.length ? this.scopes : [''],
- target = null,
- rank = 0
-
- for (var scope of scopes) {
- var widgets = widgetManager.getWidgetById(this.getProp('widgetId'), scope)
- .filter(w=>this.isValidCloneTarget(w))
- target = widgets[0]
-
- if (!target) {
- rank++
- continue
- }
-
- for (var w of widgets) {
- // when duplicating clones pointing to an object with a static id,
- // each clone will recreate an object with the same id internally
- // we try to get the original one if there is more than 2 clone pointing to the same id (avoiding cloning the clone)
- if (!(w.parent && w.parent.getProp('type') == 'clone')) {
- target = w
- break
- }
- }
-
- if (rank < this.targetRank || this.targetRank == null) {
-
- var clone = this.children[0]
-
- this.unbindTarget()
-
- if (!clone) {
-
- this.updateContainer(false)
- this.bindTarget(target, rank)
- this.createClone()
-
- } else {
-
- this.bindTarget(target, rank)
- this.updateClone()
-
- }
- }
-
- return
-
- }
-
- }
-
- isValidCloneTarget(widget) {
-
- return !(widget.contains(this) || this.contains(widget))
-
- }
-
- createClone(init) {
-
- if (this.cloneLock) return
-
- this.cloneLock = true
-
- var data = {...deepCopy(this.cloneTarget.props), ...this.getProp('props')}
-
- Session.converters['1.13.2'].widget(data)
-
- parser.parse({
- data: data,
- parentNode: this.widget,
- parent: this,
- meta: {
- not_editable: true,
- clone: true,
- scopable: true
- }
- })
-
- this.updateContainer(!init)
-
- this.cloneLock = false
-
- }
-
- unbindTarget() {
-
- if (!this.cloneTarget) return
-
- this.cloneTarget.off(undefined, undefined, this)
-
- this.cloneTarget = null
- this.targetRank = null
-
- }
-
- bindTarget(target, rank) {
-
- if (!target) return
-
- this.cloneTarget = target
- this.targetRank = rank
-
- // listen for cloneTarget's deletion
- // if it is just edited, its recreation will be caught by the global 'widget-created' event handler
- this.cloneTarget.on('widget-removed', (e)=>{
- if (this.cloneTarget === e.widget) {
- this.unbindTarget()
- }
- }, {context: this})
-
- // listen for cloneTarget's content updates
- this.cloneTarget.on('widget-created', (e)=>{
-
- var {widget} = e
-
- // if updated widget is in a nested clone, ignore it:
- // it will be handled by the nested clone that targets it
- if (!widget.meta.clone) {
- this.updateClone()
- }
-
- }, {context: this})
-
- }
-
- updateClone(options) {
-
- if (this.cloneLock) return
-
- this.cloneLock = true
-
- var data = {...deepCopy(this.cloneTarget.props), ...this.getProp('props')},
- clone = this.children[0]
-
- Session.converters['1.13.2'].widget(data)
-
- var delta = diff.diff(clone.props, data) || {},
- [widget, patch] = diffToWidget(clone, delta),
- changedProps = Object.keys(patch)
-
- if (changedProps.length) {
-
- diff.patch(widget.props, patch)
-
-
- if (changedProps.some(x => !widget.isDynamicProp(x))) {
-
- clone.reCreateWidget({reuseChildren: false})
- this.updateContainer(false)
-
- } else {
-
- widget.updateProps(changedProps, this, options)
- this.updateContainer(true)
-
- }
-
- }
-
-
-
- this.cloneLock = false
-
- }
-
- updateContainer(checkResize) {
-
-
- if (this.cloneTarget) {
-
- var classes = [...this.cloneTarget.container.classList].filter(i=>excludedCloneClasses.indexOf(i) === -1)
-
- if (!deepEqual(classes, this.cloneClass)) {
- this.container.classList.remove(...this.cloneClass)
- this.cloneClass = classes
- this.container.classList.add(...this.cloneClass)
- }
-
- this.container.classList.remove('empty')
-
- if (checkResize) resize.check(this.widget)
-
- } else if (this.cloneClass.length) {
-
- this.container.classList.remove(...this.cloneClass)
- this.container.classList.add('empty')
- this.cloneClass = []
- this.widget.innerHTML = ''
- widgetManager.removeWidgets(this.getAllChildren())
-
- }
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- if (super.onPropChanged(...arguments)) return true
-
- switch (propName) {
-
- case 'widgetId':
- this.getCloneTarget()
- return
- case 'props':
- if (this.children[0]) this.updateClone()
- return
-
- }
-
- }
-
- onRemove(){
-
- this.unbindTarget()
- super.onRemove()
-
- }
-
-}
-
-Clone.dynamicProps = Clone.prototype.constructor.dynamicProps.concat(
- 'widgetId',
- 'props'
-)
-
-export default Clone
diff --git a/src/client/widgets/containers/folder.mjs b/src/client/widgets/containers/folder.mjs
deleted file mode 100644
index 6f8f3722..00000000
--- a/src/client/widgets/containers/folder.mjs
+++ /dev/null
@@ -1,60 +0,0 @@
-import Panel from './panel.mjs'
-
-class Folder extends Panel {
-
- static description() {
-
- return 'Flat container that doesn\'t affect layout. Mostly useful for grouping widgets in the tree.'
-
- }
-
- static defaults() {
-
- var defaults = super.defaults().extend({
- class_specific: {
- traversing: null
- },
- style: {
-
- },
- geometry: null,
- osc: null,
- scripting: null,
- value: null,
- children: {
- widgets: {type: 'array', value: [], help: 'Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously.'},
- }
- })
-
- defaults.style = {
- colorText: defaults.style.colorText,
- colorWidget: defaults.style.colorWidget,
- css: defaults.style.css,
- }
-
- return defaults
-
- }
-
- constructor(options) {
-
- super(options)
-
- }
-
- getProp(propName) {
-
- if (propName === 'layout') {
- return this.parent.getProp('layout')
- } else {
- return super.getProp(propName)
- }
-
- }
-
-
-}
-
-
-
-export default Folder
diff --git a/src/client/widgets/containers/fragment.mjs b/src/client/widgets/containers/fragment.mjs
deleted file mode 100644
index 0979425f..00000000
--- a/src/client/widgets/containers/fragment.mjs
+++ /dev/null
@@ -1,223 +0,0 @@
-import html from 'nanohtml'
-import Container from '../common/container.mjs'
-import widgetManager from '../../managers/widgets.mjs'
-import * as resize from '../../events/resize.mjs'
-import parser from '../../parser.mjs'
-import {deepCopy, deepEqual} from '../../utils.mjs'
-import {diff, diffToWidget} from '../../editor/diff'
-import Session from '../../managers/session/session.mjs'
-
-var sessionManager
-;(async()=>{
- sessionManager = (await import('../../managers/session/index.mjs')).default
-})()
-
-var excludedfragmentClasses = ['widget', 'absolute-position', 'not-editable', 'editing', 'flex-expand', 'no-interaction']
-
-class Fragment extends Container() {
-
- static description() {
-
- return 'Embedded session or fragment file with overridable properties.'
-
- }
-
- static defaults() {
-
- var defaults = super.defaults().extend({
-
- class_specific: {
- file: {type: 'string', value: '', help: 'Fragment file path (relative to the session or theme file location by default, falling back to absolute path)'},
- fallback: {type: 'string', value: '', help: 'Fallack fragment file path, loaded if `file` can\'t be opened'},
- scoped: {type: 'boolean|string', value: false, help: [
- 'Set to `true` to prefix all cloned `id`s inside the clone with a unique identifier and make the clone independent from its original. All `@{}` blocks and scripts will be prefixed automatically so that they resolve to widgets within the clone if possible, falling back to unprefixed ids otherwise. `linkId` will be prefixed as well but will only resolve within the clone.',
- '`clone` and `scrollbar` widgets will prioritize targets closer to their scope, falling back to farther target.',
- 'Set this property to a string to define the `ìd` prefix manually (a trailing slash will be added automatically). This can be useful if one must access a scoped widget via scripting or remote control commands.'
- ]},
- props: {type: 'object', value: {}, editor: 'javascript', syntaxChecker: false, help: 'Fragment widget\'s properties to override'},
- },
- value: null,
- osc: null,
- scripting: null
- })
-
- defaults.style = {css: defaults.style.css}
-
- return defaults
-
- }
-
- constructor(options) {
-
- options.props.address = 'auto'
- options.props.variables = '@{parent.variables}'
-
- super({...options, html: html`
`})
-
- this.noValueState = true
-
- this.scopeId = this.getProp('scoped') === true ? this.hash : this.getProp('scoped') === false ? '' : this.getProp('scoped')
-
- this.modalBreakout = 0
-
- this.fragmentClass = []
- this.container.classList.add('empty')
-
- sessionManager.on('fragment-updated', (e)=>{
- var {path} = e
- if (path === this.getProp('file') || path === this.getProp('fallback')) {
- this.createFragment()
- }
- }, {context: this})
-
- sessionManager.on('fragment-not-found', (e)=>{
- var {path} = e
- if (path === this.getProp('file')) {
- if (this.getProp('fallback')) {
- if (this.getFragment()) this.createFragment()
- else sessionManager.loadFragment(this.getProp('fallback'))
- } else {
- this.log('fragment file not found')
- }
- } else if (path === this.getProp('fallback') && !this.getFragment()) {
- this.log('fallback fragment file not found')
- }
- }, {context: this})
-
- if (this.getProp('file')) {
- if (sessionManager.getFragment(this.getProp('file'))) {
- this.createFragment(true)
- } else {
- sessionManager.loadFragment(this.getProp('file'))
- }
- }
-
-
- }
-
- getFragment() {
-
- var fragment = sessionManager.getFragment(this.getProp('file'))
-
- if (!fragment && this.getProp('fallback')) {
- fragment = sessionManager.getFragment(this.getProp('fallback'))
- }
-
- return fragment
-
- }
-
- createFragment(init) {
-
- var fragment = this.getFragment()
-
- if (!fragment) return
-
-
- var data = {...deepCopy(fragment.getRoot()), ...this.getProp('props')}
-
- Session.converters['1.13.2'].widget(data)
-
- parser.parse({
- data: data,
- parentNode: this.widget,
- parent: this,
- meta: {
- not_editable: true,
- fragment: true,
- scopable: true
- }
- })
-
- this.updateContainer(!init)
-
- }
-
-
- updateContainer(checkResize) {
-
-
- if (this.children[0]) {
-
- var classes = [...this.children[0].container.classList].filter(i=>excludedfragmentClasses.indexOf(i) === -1)
-
- if (!deepEqual(classes, this.fragmentClass)) {
- this.container.classList.remove(...this.fragmentClass)
- this.fragmentClass = classes
- this.container.classList.add(...this.fragmentClass)
- }
-
- this.container.classList.remove('empty')
-
- if (checkResize) resize.check(this.widget)
-
- } else if (this.fragmentClass.length) {
-
- this.container.classList.remove(...this.fragmentClass)
- this.container.classList.add('empty')
- this.fragmentClass = []
- this.widget.innerHTML = ''
- widgetManager.removeWidgets(this.getAllChildren())
-
- }
-
- }
-
- updateFragment() {
-
-
- var fragment = this.getFragment()
-
- if (!fragment) return
-
- var data = {...deepCopy(fragment.getRoot()), ...this.getProp('props')},
- fragmentWidget = this.children[0]
-
- Session.converters['1.13.2'].widget(data)
-
- var delta = diff.diff(fragmentWidget.props, data) || {},
- [widget, patch] = diffToWidget(fragmentWidget, delta),
- changedProps = Object.keys(patch)
-
- if (changedProps.length) {
-
- diff.patch(widget.props, patch)
-
-
- if (changedProps.some(x => !widget.isDynamicProp(x))) {
-
- fragmentWidget.reCreateWidget({reuseChildren: false})
- this.updateContainer(false)
-
- } else {
-
- widget.updateProps(changedProps, this)
- this.updateContainer(true)
-
- }
-
- }
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- if (super.onPropChanged(...arguments)) return true
-
- switch (propName) {
-
- case 'props':
- if (this.children[0]) this.updateFragment()
- return
-
- }
-
- }
-
-}
-
-Fragment.dynamicProps = Fragment.prototype.constructor.dynamicProps.concat(
- 'props'
-)
-
-export default Fragment
diff --git a/src/client/widgets/containers/keyboard.mjs b/src/client/widgets/containers/keyboard.mjs
deleted file mode 100644
index cdbfd8bc..00000000
--- a/src/client/widgets/containers/keyboard.mjs
+++ /dev/null
@@ -1,195 +0,0 @@
-import Panel from './panel.mjs'
-import Widget from '../common/widget.mjs'
-import parser from '../../parser.mjs'
-import {mapToScale} from '../utils.mjs'
-
-
-class Keyboard extends Panel {
-
- static description() {
-
- return 'Piano keyboard.'
-
- }
-
- static defaults() {
-
- return Widget.defaults().extend({
- style: {
- _separator_keyboard_style: 'Keyboard style',
- colorWhite: {type: 'string', value: 'auto', help: 'White keys color.'},
- colorBlack: {type: 'string', value: 'auto', help: 'Black keys color.'},
- },
- class_specific: {
- keys: {type: 'number', value: 25, help: 'Defines the number keys'},
- start: {type: 'number', value: 48, help: [
- 'MIDI note number to start with (default is C4)',
- 'Standard keyboards settings are: `[25, 48]`, `[49, 36]`, `[61, 36]`, `[88, 21]`'
- ]},
- traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'},
- on: {type: '*', value: 1, help: [
- 'Set to `null` to send send no argument in the osc message',
- ]},
- off: {type: '*', value: 0, help: [
- 'Set to `null` to send send no argument in the osc message',
- ]},
- velocity: {type: 'boolean', value: false, help: [
- 'Set to `true` to map the touch coordinates between `off` (top) and `on` (bottom). Requires `on` and `off` to be numbers',
- ]},
- mode: {type: 'string', value: 'push', choices: ['push', 'toggle', 'tap'], help: [
- 'Interaction mode:',
- '- `push` (press & release)',
- '- `toggle` (on/off switches)',
- '- `tap` (no release)'
- ]},
- },
- value: {
- value: {type: 'array', value: '', help: [
- 'The keyboard widget accepts the following values:',
- '- a `[note, value]` array to set the value of a single key where `note` is the note number and `value` depends on the `on` and `off` properties (any value different from `off` will be interpreted as `on`).',
- '- an array of values with one item per key in the keyboard'
- ]}
- },
- })
-
- }
-
- constructor(options) {
-
- super(options)
-
- this.childrenType = undefined
- this.value = []
- this.keyHeight = 100
-
- this.on('resize', (e)=>{
- this.keyHeight = e.height
- }, {element: this.widget})
-
-
- this.on('value-changed',(e)=>{
-
- var widget = e.widget
-
- if (widget === this) return
-
-
- var value
- if (widget.getValue()) {
- if (this.getProp('velocity')) {
- var height = widget._black ? this.keyHeight * 0.65 : this.keyHeight
- value = mapToScale(e.options.y, [0, height * 0.9], [this.getProp('off'), this.getProp('on')], this.decimals)
- } else {
- value = this.getProp('on')
- }
- } else {
- value = this.getProp('off')
- }
-
- this.value[widget._index] = value
-
- if (e.options.send) {
- var start = parseInt(this.getProp('start'))
- this.sendValue({
- v: [e.widget._index + start, value]
- })
- }
-
- this.changed({
- ...e.options,
- id: widget.getProp('id')
- })
-
-
- })
-
- var start = parseInt(this.getProp('start')),
- keys = parseInt(this.getProp('keys'))
-
- var pattern = 'wbwbwwbwbwbw',
- whiteKeys = 0, whiteKeys2 = 0, i
-
- for (i = start; i < keys + start && i < 128; i++) {
- if (pattern[i % 12] == 'w') whiteKeys++
- }
-
- this.container.style.setProperty('--nkeys', whiteKeys)
-
- for (i = start; i < keys + start && i < 128; i++) {
-
- var data = {
- top: 'auto',
- left: 'auto',
- height: 'auto',
- width: 'auto',
- type: 'button',
- mode: this.getProp('mode'),
- id: this.getProp('id') + '/' + i,
- label: false,
- css: '',
- bypass: true,
- on: 1,
- off: 0,
- }
-
- var key = parser.parse({
- data: data,
- parentNode: this.widget,
- parent: this,
- meta: {not_editable: true}
- })
-
- key._index = i - start
- key.container.classList.add('key')
-
- if (pattern[i % 12] == 'w') {
- key.container.classList.add('white')
- whiteKeys2++
- } else {
- key.container.classList.add('black')
- key.container.style.setProperty('--rank', whiteKeys2)
- key._black = true
- }
-
- this.value[i - start] = this.getProp('off')
-
- }
-
- }
-
- setValue(v, options={}) {
-
- if (!Array.isArray(v)) return
-
- if (v.length === this.children.length) {
- for (var i = 0; i < this.children.length; i++){
- this.children[i].setValue(v[i] !== this.getProp('off') ? 1 : 0, options)
- }
- }
-
- else if (
- v.length === 2 &&
- v[0] >= parseInt(this.getProp('start')) && v[0] < 128
- ) {
- var index = v[0] - parseInt(this.getProp('start'))
- if (this.children[index]) {
- this.children[index].setValue(v[1] !== this.getProp('off') ? 1 : 0, options)
- }
- }
-
- }
-
-}
-
-
-Keyboard.dynamicProps = Keyboard.prototype.constructor.dynamicProps.concat(
- 'on',
- 'off',
-)
-
-Keyboard.cssVariables = Keyboard.prototype.constructor.cssVariables.concat(
- {js: 'colorWhite', css: '--color-white-key'},
- {js: 'colorBlack', css: '--color-black-key'}
-)
-
-export default Keyboard
diff --git a/src/client/widgets/containers/matrix.mjs b/src/client/widgets/containers/matrix.mjs
deleted file mode 100644
index 32cb4c24..00000000
--- a/src/client/widgets/containers/matrix.mjs
+++ /dev/null
@@ -1,276 +0,0 @@
-import Panel from './panel.mjs'
-import parser from '../../parser.mjs'
-import {deepCopy} from '../../utils.mjs'
-import Session from '../../managers/session/session.mjs'
-import widgetManager from '../../managers/widgets.mjs'
-
-
-class Matrix extends Panel {
-
- static description() {
-
- return 'Generic matrix for creating rows/columns of widgets.'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- class_specific: {
- widgetType: {type: 'string', value: 'button', help: 'Defines the type of the widgets in the matrix'},
- quantity: {type: 'number', value: 4, help: 'Defines the number of widgets in the matrix'},
- props: {type: 'object', value: {label: '#{$}'}, editor: 'javascript', syntaxChecker: false, help: [
- 'Defines a set of property to override the widgets\' defaults.',
- 'JS{} and #{} blocks in this field are resolved with an extra variable representing each widget\'s index: `$` (e.g. `#{$}`)',
- 'Advanced syntax blocks (@{}, OSC{}, JS{}, VAR{} and #{}) are resolved at the matrix\' scope (ie @{this.variables} returns the matrix\' variables property)',
- 'Advanced syntax blocks can be passed to children without being resolved at the matrix\' scope by adding an underscore before the opening bracket.',
- 'Note: unless overridden, children inherit from the matrix\' `id` and osc properties (`id` and `address` are appended with `/$`)'
- ]},
- },
- style: {
- layout: {type: 'string', value: 'horizontal', choices: ['horizontal', 'vertical', 'grid'], help: 'Defines how children are laid out.'},
- tabsPosition: null,
- }
- })
-
- }
-
- constructor(options) {
-
- super(options)
-
- this.childrenType = undefined
-
- this.value = []
-
- this.resolveLock = false
-
- this.on('value-changed',(e)=>{
-
- if (e.widget === this) return
-
- var widget = this.getProp('widgetType') === 'clone' ? e.widget.parent : e.widget
-
- if (widget.parent !== this) return
-
- this.value[widget._index] = e.widget.getValue()
-
- this.changed({
- ...e.options,
- id: widget.getProp('id')
- })
-
- })
-
- if (parser.widgets[this.getProp('widgetType')]) {
-
- var quantity = Math.max(parseInt(this.getProp('quantity')) || 0, 0)
-
- for (let i = 0; i < quantity; i++) {
-
- var props = deepCopy(this.getProp('props')[i])
- var data = this.defaultProps(i)
-
- if (typeof props === 'object' && props !== null) {
- Object.assign(data, props)
- }
-
- data = JSON.parse(JSON.stringify(data).replace(/(JS|#|OSC|@|VAR)_\{/g, '$1{'))
-
- Session.converters['1.13.2'].widget(data)
-
- var widget = parser.parse({
- data: data,
- parentNode: this.widget,
- parent: this,
- meta: {not_editable: true}
- })
-
- widget._index = i
-
- this.value[i] = widget.getValue()
-
- }
-
- } else {
-
- this.errors.widgetType = this.getProp('widgetType') + ' is not a valid widget type'
-
- }
-
-
-
- }
-
- defaultProps(i) {
-
- return {
- type: this.getProp('widgetType'),
- id: '@{parent.id}/' + i,
- address: '#{@{parent.address} == "auto" ? "/" + @{parent.id} : @{parent.address}}/' + i,
- preArgs: '@{parent.preArgs}',
- target: '@{parent.target}',
- decimals: '@{parent.decimals}',
- bypass: '@{parent.bypass}',
- top: 'auto',
- left: 'auto',
- height: 'auto',
- width: 'auto'
- }
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- if (super.onPropChanged(...arguments)) return true
-
- switch (propName) {
-
- case 'quantity':
-
- var quantity = Math.max(parseInt(this.getProp('quantity')) || 0, 0)
- oldPropValue = Math.max(parseInt(oldPropValue) || 0, 0)
-
- if (oldPropValue > quantity) {
-
- for (let i = oldPropValue - 1; i >= quantity; i--) {
- if (this.widget.contains(this.children[i].container)) {
- this.widget.removeChild(this.children[i].container)
- }
- widgetManager.removeWidgets(this.children[i].getAllChildren().concat(this.children[i]))
- }
-
- } else {
-
- this.cachedProps.props = this.resolveProp('props', undefined, true)
-
- for (let i = oldPropValue; i < quantity; i++) {
-
- var props = deepCopy(this.getProp('props')[i])
- var data = this.defaultProps(i)
-
- if (typeof props === 'object' && props !== null) {
- Object.assign(data, props)
- }
-
- data = JSON.parse(JSON.stringify(data).replace(/(JS|#|OSC|@|VAR)_\{/g, '$1{'))
-
- Session.converters['1.13.2'].widget(data)
-
- var widget = parser.parse({
- data: data,
- parentNode: this.widget,
- parent: this,
- meta: {not_editable: true}
- })
-
- widget._index = i
-
- }
-
- }
-
-
- return
-
- case 'props':
-
- for (let i = this.children.length - 1; i >= 0; i--) {
-
- let data = deepCopy(this.getProp('props')[i])
-
- if (typeof data !== 'object' || data === null || Array.isArray(data)) {
- data = {}
- }
-
- data = JSON.parse(JSON.stringify(data).replace(/(JS|#|OSC|@|VAR)_\{/g, '$1{'))
-
- Session.converters['1.13.2'].widget(data)
-
- if (typeof oldPropValue[i] === 'object' && oldPropValue[i] !== null) {
- // if an overridden default props is removed, set it back to default
- let overriddenDefaults,
- widgetDefaults
- for (var k in oldPropValue[i]) {
- if (data[k] === undefined) {
- if (Matrix.overriddenDefaults.indexOf(k) !== -1) {
- overriddenDefaults = overriddenDefaults || this.defaultProps(i)
- data[k] = overriddenDefaults[k]
- } else {
- widgetDefaults = widgetDefaults || parser.defaults[data.type || this.getProp('widgetType')]
- data[k] = deepCopy(widgetDefaults[k])
- }
- }
- }
- }
-
- Object.assign(this.children[i].props, data)
-
- this.children[i].updateProps(Object.keys(data), this, options)
-
- }
-
- return
-
- }
-
- }
-
- resolveProp(propName, propValue, storeLinks, originalWidget, originalPropName, context) {
-
- if (propName === 'props' && !this.resolveLock) {
-
- this.resolveLock = true
-
- propValue = propValue !== undefined ? propValue : this.props[propName]
-
- var data = [],
- quantity = Math.max(parseInt(this.resolveProp('quantity', undefined, false, false, false)) || 0, 0)
-
- if (typeof propValue === 'object' && propValue !== null && !Array.isArray(propValue)) {
- for (let i = 0; i < quantity; i++) {
- data[i] = {}
- for (var k in propValue) {
- data[i][k] = super.resolveProp(propName, deepCopy(propValue[k]), i === 0 ? storeLinks : false, originalWidget, originalPropName, {$: i})
- }
- }
-
- } else {
-
- for (let i = 0; i < quantity; i++) {
- data[i] = super.resolveProp(propName, deepCopy(propValue), i === 0 ? storeLinks : false, originalWidget, originalPropName, {$: i})
- }
-
- }
-
-
- this.resolveLock = false
-
- return data
-
- } else {
-
- return super.resolveProp(propName, propValue, storeLinks, originalWidget, originalPropName, context)
-
- }
-
- }
-}
-
-
-
-Matrix.overriddenDefaults = [
- 'type', 'id', 'address', 'preArgs', 'target', 'decimals', 'bypass',
- 'label', 'top', 'left', 'height', 'width'
-]
-
-Matrix.parsersContexts.props = {
- $: 0
-}
-
-Matrix.dynamicProps = Matrix.prototype.constructor.dynamicProps.concat(
- 'quantity',
- 'props'
-)
-
-export default Matrix
diff --git a/src/client/widgets/containers/modal.mjs b/src/client/widgets/containers/modal.mjs
deleted file mode 100644
index 1b810164..00000000
--- a/src/client/widgets/containers/modal.mjs
+++ /dev/null
@@ -1,297 +0,0 @@
-import html from 'nanohtml'
-import raw from 'nanohtml/raw'
-import Panel from './panel.mjs'
-import {icon, iconify} from '../../ui/utils.mjs'
-import * as resize from '../../events/resize.mjs'
-import doubleTap from '../mixins/double_tap'
-import {DOM, PXSCALE} from '../../globals.mjs'
-
-class Modal extends Panel {
-
- static description() {
-
- return 'A toggle button that opens a popup panel. Cannot contain tabs directly.'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- class_specific: {
- doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the modal require a double tap to open instead of a single tap (allows scrolling when touching the modal button)'},
- click: {type: 'boolean', value: false, help: 'Set to `true` to make the modal open/close upon click event instead of tap (allows scrolling when touching the modal button)'},
- },
- geometry: {
- _separator_modal_geometry: 'Modal geometry',
- popupWidth: {type: 'number|percentage', value: '80%', help: 'Modal popup\'s size'},
- 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'},
- relative: {type: 'boolean', value: false, help: 'Set to `true` to make the modal\'s position relative to the button\'s position.'},
- ignoreTabs: {type: 'boolean', value: false, help: 'Set to `true` to allow the modal overflowing its tab ancestors.'},
- },
- style: {
- _separator_modal_style: 'Modal style',
- label: {type: 'string|boolean', value: 'auto', help: [
- 'Set to `false` to hide completely',
- '- Insert icons using the prefix ^ followed by the icon\'s name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)',
- '- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal`',
- ]},
- popupLabel: {type: 'string|boolean', value: 'auto', help: 'Alternative label for the modal popup'},
- popupPadding: {type: 'number', value: 'auto', help: 'Modal\'s inner spacing.'},
- tabsPosition: null,
- html: null
- },
- children: {
- tab: null
- },
- value: {
- value: {type: 'integer', value: '', help: [
- 'Defines the modal\'s state:`0` for closed, `1` for opened'
- ]},
- }
- })
-
- }
-
- constructor(options) {
-
- super(options)
-
- this.popup = html`
-
- `
-
- this.container.appendChild(this.popup)
- this.popupContent = DOM.get(this.popup, '.popup-content')[0]
-
-
- // convert dimensions / coordinates to rem
- var geometry = {}
- for (var g of ['Width', 'Height', 'Left', 'Top']) {
- geometry[g] = parseFloat(this.getProp('popup' + g)) == this.getProp('popup' + g) ? parseFloat(this.getProp('popup' + g)) + 'rem' : this.getProp('popup' + g)
- }
-
- this.popup.style.setProperty('--width', geometry.Width)
- this.popup.style.setProperty('--height', geometry.Height)
-
- if (geometry.Left !== 'auto') {
- this.popup.style.setProperty('--left', geometry.Left)
- this.popup.classList.add('x-positionned')
- }
-
- if (geometry.Top !== 'auto') {
- this.popup.style.setProperty('--top', geometry.Top)
- this.popup.classList.add('y-positionned')
- }
-
- this.toggle = this.container.appendChild(html`
`)
-
- var closer = DOM.get(this.popup, '.closer')[0]
-
- this.on(this.getProp('click') ? 'click' : 'draginit',(e)=>{
- if ((e.target === this.popup || e.target === closer) && this.value == 1) {
- this.setValue(0, {sync:true, send:true})
- } else if (!this.getProp('doubleTap') && e.target === this.toggle) {
- if (e.capturedByEditor === true) return
- this.setValue(1, {sync:true, send:true})
- }
- }, {element: this.container})
-
- if (this.getProp('doubleTap')) {
- doubleTap(this, ()=>{
- this.setValue(1, {sync:true, send:true})
- }, {element: this.toggle, click: this.getProp('click')})
- }
-
- this.escapeKeyHandler = ((e)=>{
- if (e.key == 'Escape') this.setValue(0, {sync:true, send:true})
- }).bind(this)
-
- this.value = 0
- this.init = false
- this.labelChange = true
-
- this.container.classList.toggle('relative', this.getProp('relative'))
- this.popupContent.classList.add('layout-' + this.getProp('layout'))
-
- this.label = html` `
- this.updateLabel()
-
- this.childrenType = 'widget'
-
- }
-
- setValue(v, options={}) {
-
- if (this.init === undefined) return
-
- var val = v ? 1 : 0
-
- if (val === this.value) return
-
- this.value = val
-
- if (!this.init && this.value) {
- this.popupContent.appendChild(this.widget)
- this.init = true
- }
-
- if (this.value && this.labelChange) {
- this.updatePopupLabel()
- }
-
- if (this.getProp('scroll') && this.value) this.scrollLock = true
-
- this.popup.classList.toggle('show', this.value)
- this.container.classList.toggle('on', this.value)
-
- this.bindEscKey(this.value)
-
- if (this.init) this.fixParents()
-
- this.setVisibility()
- if (this.value) {
- resize.check(this.widget, true)
-
- if (this.getProp('scroll')) {
- setTimeout(()=>{
- this.scrollWidth = this.widget.scrollWidth - this.widget.clientWidth
- this.scrollHeight = this.widget.scrollHeight - this.widget.clientHeight
- this.setScroll(this.scroll[0], this.scroll[1], true)
- })
- }
- }
-
-
- if (options.send) this.sendValue()
- if (options.sync) this.changed(options)
-
-
- }
-
- fixParents() {
-
- var parent = this.parent,
- scrollX = 0,
- scrollY = 0,
- stop = this.getProp('ignoreTabs') ? /root/ : /root|tab/
-
- while (parent && parent.props && !String(parent.getProp('type')).match(stop)) {
-
- parent.modalBreakout += (this.value ? 1 : -1)
- if (parent.modalBreakout > 0) parent.container.classList.add('modal-breakout')
- else if (parent.modalBreakout === 0) parent.container.classList.remove('modal-breakout')
- else parent.modalBreakout = 0
-
- scrollX += parent.widget.scrollLeft
- scrollY += parent.widget.scrollTop
-
- parent = parent.parent
- }
-
- scrollX += parent.widget.scrollLeft
- scrollY += parent.widget.scrollTop
-
- if (this.getProp('relative')) {
- this.container.style.setProperty('--parent-scroll-x', scrollX + 'px')
- this.container.style.setProperty('--parent-scroll-y', scrollY + 'px')
- }
-
- this.modalBreakout += (this.value ? 1 : -1)
- if (this.modalBreakout > 0) this.container.classList.add('modal-breakout')
- else if (this.modalBreakout === 0) this.container.classList.remove('modal-breakout')
- else this.modalBreakout = 0
-
-
- }
-
- bindEscKey(set) {
-
- if (set) {
- document.addEventListener('keydown', this.escapeKeyHandler)
- } else {
- document.removeEventListener('keydown', this.escapeKeyHandler)
- }
-
- }
-
- onRemove() {
- this.bindEscKey(false)
- this.setValue(0)
- super.onRemove()
- }
-
- updateLabel() {
-
- if (!this.label) return
-
- if (this.getProp('label') === false) {
-
- if (this.container.contains(this.label)) this.container.removeChild(this.label)
-
- } else {
- this.label.innerHTML = this.getProp('label') == 'auto'?
- this.getProp('id'):
- iconify(String(this.getProp('label')).replace(/parseFloat(x) + 'rem', toJs: x=>parseFloat(x) * PXSCALE},
-)
-
-Modal.dynamicProps = Modal.prototype.constructor.dynamicProps.concat(
- 'label',
- 'popupLabel',
- 'popupPadding'
-)
-
-export default Modal
diff --git a/src/client/widgets/containers/panel.mjs b/src/client/widgets/containers/panel.mjs
deleted file mode 100644
index 7ab1aa4c..00000000
--- a/src/client/widgets/containers/panel.mjs
+++ /dev/null
@@ -1,404 +0,0 @@
-import html from 'nanohtml'
-import fastdom from 'fastdom'
-import Container from '../common/container.mjs'
-import widgetManager from '../../managers/widgets.mjs'
-import parser from '../../parser.mjs'
-import {enableTraversingGestures, disableTraversingGestures} from '../../events/drag.mjs'
-import {setScrollbarColor} from '../../ui/utils.mjs'
-import Script from '../scripts/script.mjs'
-import {DOM} from '../../globals.mjs'
-
-class Panel extends Container() {
-
- static description() {
-
- return 'Widgets or Tabs container.'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- class_specific: {
- variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
- traversing: {type: 'boolean', value: false, choices: [false, true, 'smart'], help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` to limit affected widgets by the type of the first touched widget'},
- },
- style: {
- _separator_panel_style: 'Panel style',
- colorBg: {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 or a valid value for the css property "grid-template".'},
- contain: {type: 'boolean', value: true, help:'If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel.'},
- scroll: {type: 'boolean|string', value: true, choices: [true, false, 'hidden', 'manual'], help: [
- '- `true`: scrollbars are show and content is scrollble',
- '- `false`: scrollbars are hidden and content is not scrollble',
- '- `"hidden"`: scrollbars are hidden (using css, may not work on old browsers) and content is scrollble',
- '- `"manual"`: scrollbars are hidden (using css, may not work on old browsers) and content is scrollble only using scripting or scrollbar widgets',
- ]},
- innerPadding: {type : 'boolean', value: true, help: 'Set to `false` to make the `padding` property apply only between children and not at the container\'s inner boundaries.'},
- tabsPosition: {type: 'string', value: 'top', choices: ['top', 'bottom', 'left', 'right', 'hidden'], help: 'Defines the position of the navigation bar if the panel contains tabs'},
- },
- value: {
- value: {type: 'integer|array', value: '', help: [
- 'If the panel contains tabs, its value defines which tab is selected selected (by index, starting with 0).',
- 'If the panel contains widgets and `scroll` is `true`, its value is an array that contains the scrolling state between 0 and 1 for the x and y axis. '
- ]}
- },
- children: {
- widgets: {type: 'array', value: [], help: 'Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously.'},
- tabs: {type: 'array', value: [], help: 'Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously'},
- },
- scripting: {
- onTouch: {type: 'script', value: '', editor:'javascript', help: ['Script executed when the panel is touched and released, and when the pointer moves when the widget is touched. See documentation .',]},
- }
- })
-
- }
-
- constructor(options) {
-
-
- super({...options, html: html` `})
-
- this.childrenType = ''
-
- if (options.root && this.getProp('onPreload')) {
- this.scripts.onPreload = new Script({
- widget: this,
- property: 'onPreload',
- code: this.getProp('onPreload'),
- context: {}
- })
- if (this.scripts.onPreload) this.scripts.onPreload.run({}, {})
- }
-
- this.container.classList.toggle('no-inner-padding', !this.getProp('innerPadding'))
- this.container.classList.toggle('no-scroll', !this.getProp('scroll') || this.getProp('scroll') == 'manual')
- this.container.classList.toggle('hidden-scroll', this.getProp('scroll') == 'hidden')
- this.container.classList.add('layout-' + this.getProp('layout'))
- this.container.classList.toggle('layout-contain', this.getProp('contain'))
-
- this.modalBreakout = 0
-
- var layout = this.getProp('layout')
- if (layout === 'grid') {
-
- var template = this.getProp('gridTemplate') || 2
- this.widget.style.gridTemplate = template === parseInt(template) ? `none / repeat(${template}, 1fr)` : template
-
- } else if (layout === 'vertical' || layout === 'horizontal'){
-
- var justify = this.getProp('justify')
- if (justify === 'start' || justify === 'end') justify = 'flex-' + justify
- this.widget.style.justifyContent = justify
-
- }
-
- if (this.getProp('tabs') && this.getProp('tabs').length) {
-
- this.container.classList.add('contains-tabs')
- this.container.classList.add('tabs-' + this.getProp('tabsPosition'))
-
- } else {
-
- this.container.classList.add('contains-widgets')
-
- if (this.getProp('scroll')) {
- this.scrollLock = false
- this.scrollLockTimeout = null
- this.scroll = [0, 0]
- this.scrollThumb = [1, 1]
- this.scrollWidth = 1
- this.scrollHeight = 1
- fastdom.measure(()=>{
- this.scrollWidth = this.widget.scrollWidth - this.widget.clientWidth
- this.scrollHeight = this.widget.scrollHeight - this.widget.clientHeight
- this.scrollThumb = [this.widget.clientWidth / this.widget.scrollWidth || 1, this.widget.clientHeight / this.widget.scrollHeight || 1]
- })
- this.on('scroll', (e)=>{
- if (this.scrollLock) e.locked = true
- this.scrollWidth = this.widget.scrollWidth - this.widget.clientWidth
- this.scrollHeight = this.widget.scrollHeight - this.widget.clientHeight
- this.scroll = [this.widget.scrollLeft / this.scrollWidth || 0, this.widget.scrollTop / this.scrollHeight || 0]
- this.scrollThumb = [this.widget.clientWidth / this.widget.scrollWidth || 1, this.widget.clientHeight / this.widget.scrollHeight || 1]
- }, {element: this.widget})
-
- }
-
- }
-
-
-
-
- this.tabs = []
-
- if (this.getProp('tabs') && this.getProp('tabs').length) {
-
- this.childrenType = 'tab'
-
- this.value = -1
-
- this.navigation = this.widget.appendChild(html`
`)
-
- this.children = options.children || new Array(this.getProp('tabs').length)
- var tlength = this.children.length
-
- for (let i = 0; i < tlength; i++) {
- if (this.children[i]) {
- this.widget.appendChild(this.children[i].container)
- this.children[i].mounted = true
- this.children[i].parent = this
- this.children[i].parentNode = this.widget
- } else {
- parser.parse({
- data: this.getProp('tabs')[i],
- parentNode: this.widget,
- parent: this,
- tab: true,
- index: i,
- meta: {...this.meta}
- })
- }
- }
-
- if (options.children) this.alignChildrenProps()
-
- this.createNavigation()
-
- this.on('fast-click', (e)=>{
- if (!e.target.hasAttribute('data-widget') || e.capturedByEditor) return
- var index = DOM.index(e.target)
- this.setValue(index, {sync: true, send:this.value != index})
- }, {element: this.navigation})
-
- this.on('tab-created', (e)=>{
- this.createNavigation()
- e.stopPropagation = true
- })
-
- this.setValue(Number(this.getProp('value')) || 0)
-
- } else if (this.getProp('widgets') && this.getProp('widgets').length) {
-
- this.value = -1
-
- this.childrenType = 'widget'
-
- this.children = options.children || new Array(this.getProp('widgets').length)
- var wlength = this.children.length
-
- for (let i = 0; i < wlength; i++) {
- if (this.children[i]) {
- this.widget.appendChild(this.children[i].container)
- this.children[i].mounted = true
- this.children[i].parent = this
- this.children[i].parentNode = this.widget
- } else {
- parser.parse({
- data: this.getProp('widgets')[i],
- parentNode: this.widget,
- parent: this,
- index: i,
- meta: {...this.meta}
- })
- }
- }
-
- if (options.children) this.alignChildrenProps()
-
-
- }
-
- if (this.getProp('traversing')) this.setTraversing()
-
- if (this.getProp('onTouch')) {
- this.on('draginit',(e)=>this.onTouch(e, 'start'), {element: this.container, multitouch: true})
- this.on('drag',(e)=>this.onTouch(e, 'move'), {element: this.container, multitouch: true})
- this.on('dragend',(e)=>this.onTouch(e, 'stop'), {element: this.container, multitouch: true})
- }
-
- }
-
- createNavigation() {
-
- this.navigation.innerHTML = ''
- this.tabs = []
-
- DOM.each(this.widget, '> .widget', (tab)=>{
-
- let widget = widgetManager.getWidgetByElement(tab),
- style = ''
-
- style += widget.getProp('colorWidget') === 'auto' ? '' : `--color-widget:${widget.getProp('colorWidget')};`
- style += widget.getProp('colorFill') === 'auto' ? '' : `--color-fill:${widget.getProp('colorFill')};`
- style += widget.getProp('colorText') === 'auto' ? '' : `--color-text:${widget.getProp('colorText')};`
-
- if (!widget.getProp('visible')) style += 'display:none;'
-
- this.tabs.push(widget)
- var label = html`
-
-
- `
- label.innerHTML = widget.label
- this.navigation.appendChild(label)
-
- })
-
-
- this.setValue(this.value)
-
- }
-
- setValue(v, options={}) {
-
- if (this.childrenType === 'tab' && typeof v == 'number' && v >= 0 && v < this.tabs.length) {
-
- for (let i in this.tabs) {
- if (i != v) this.tabs[i].hide()
- }
-
- this.value = v
-
- this.tabs[v].show()
- DOM.each(this.navigation, 'div', (el)=>{el.classList.remove('on')})[v].classList.add('on')
-
- if (options.send) this.sendValue()
- if (options.sync) this.changed(options)
-
- }
-
- }
-
- getScroll() {
-
- return this.scroll
-
- }
-
- setScroll(x, y, updateDom, lock=true) {
-
- if (x !== undefined) {
- this.scroll[0] = x
- if (updateDom) {
- if (this.widget.scrollLeft != x * this.scrollWidth) {
- this.scrollLock = !!lock
- this.widget.scrollLeft = x * this.scrollWidth
- }
- }
- }
- if (y !== undefined) {
- this.scroll[1] = y
- if (updateDom) {
- if (this.widget.scrollTop != y * this.scrollHeight) {
- this.scrollLock = !!lock
- this.widget.scrollTop = y * this.scrollHeight
- }
- }
- }
-
- // unlock scroll events only after some time to prevent smooth scrolling
- // issues in firefox and prevent feedback loops
- if (this.scrollLock) {
- clearTimeout(this.scrollLockTimeout)
- this.scrollLockTimeout = setTimeout(()=>{
- this.scrollLock = false
- },100)
- }
-
- }
-
- onTouch(e, name) {
-
- var event = {...e},
- w
-
- event.targetName = event.target ? event.target.getAttribute('name') : ''
- event.targetTagName = event.target ? event.target.tagName : ''
-
- w = widgetManager.getWidgetByElement(event.target)
- if (w) event.target = w === this ? 'this' : w.getProp('id')
- else event.target = null
-
- w = widgetManager.getWidgetByElement(event.firstTarget)
- if (w) event.firstTarget = w === this ? 'this' : w.getProp('id')
- else event.firstTarget = null
-
- event.type = name
-
- this.scripts.onTouch.run({
- value: this.value,
- event: event
- }, {sync: true, send: true})
-
- e.inertia = parseFloat(event.inertia) || 1
-
- if (name != 'stop' && event.preventDefault) e.preventDefault = true
- if (event.allowScroll) e.allowScroll = true
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- if (super.onPropChanged(...arguments)) return true
-
- switch (propName) {
-
- case 'traversing':
- this.setTraversing()
- return
-
- case 'colorBg':
- this.setCssVariables()
- // falls through
- case 'colorWidget':
- case 'colorText':
- case 'colorFill':
- case 'colorStroke':
- case 'alphaStroke':
- case 'alphaFillOff':
- case 'alphaFillOn':
- case 'padding':
- for (var w of this.children) {
- if (w) w.onPropChanged(propName)
- }
- return
-
- }
-
- }
-
- setCssVariables() {
-
- super.setCssVariables()
- setScrollbarColor(this.container)
-
- }
-
- setTraversing(update) {
-
- var traversing = this.getProp('traversing')
-
- disableTraversingGestures(this.widget)
-
- if (traversing) {
- enableTraversingGestures(this.widget, {type: typeof traversing === 'string' ? traversing : undefined})
- }
-
- }
-
-
- onRemove() {
- super.onRemove()
- }
-
-}
-
-Panel.dynamicProps = Panel.prototype.constructor.dynamicProps.concat(
- 'colorBg',
- 'variables',
- 'traversing'
-)
-
-export default Panel
diff --git a/src/client/widgets/containers/patchbay.mjs b/src/client/widgets/containers/patchbay.mjs
deleted file mode 100644
index cc10fc29..00000000
--- a/src/client/widgets/containers/patchbay.mjs
+++ /dev/null
@@ -1,380 +0,0 @@
-import html from 'nanohtml'
-import Widget from '../common/widget.mjs'
-import Canvas from '../common/canvas.mjs'
-import Container from '../common/container.mjs'
-import {iconify} from '../../ui/utils.mjs'
-import parser from '../../parser.mjs'
-import {DOM, PXSCALE} from '../../globals.mjs'
-
-class PatchBayNode extends Widget {
-
-
- static defaults() {
-
- return super.defaults().extend({
- style: {
- label: {type: 'string', value: ''}
- }
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: html` `})
-
- this.widget.innerHTML = iconify(this.getProp('label').replace(//g, '>').replace(/\n/g,' '))
-
- this.value = []
-
- }
-
- setValue(v, options={} ) {
-
- this.value = Array.isArray(v) ? v : v ? [v] : []
-
- var allowed = this.parent.outputsValues
- for (var i = this.value.length -1; i > -1; i--) {
- if (allowed.indexOf(this.value[i]) === -1) {
- this.value.splice(i, 1)
- }
- }
-
- if (
- (this.parent.getProp('exclusive') === true
- || this.parent.getProp('exclusive') === 'in'
- || this.parent.getProp('exclusive') === 'both')
- && this.value.length > 1
- ) {
- this.value = [this.value.pop()]
- }
-
- if (
- (this.parent.getProp('exclusive') === 'out' || this.parent.getProp('exclusive') === 'both')
- && this.value.length > 0
- ) {
- for (var input of this.parent.inputsWidgets) {
- if (input !== this && input.value.some(x=>this.value.includes(x))) {
- input.setValue(input.value.filter(x=>!this.value.includes(x)), options)
- }
- }
- }
-
-
-
- this.parent.batchDraw()
-
- if (options.send) this.sendValue()
- if (options.sync) this.changed(options)
-
- }
-
- toggleValue(v) {
-
- var index = this.value.indexOf(v)
-
- if (index > -1) {
- this.value.splice(index, 1)
- } else {
- this.value.push(v)
- }
-
- this.setValue(this.value, {sync: true, send: true})
-
- }
-
-
-}
-
-class PatchBay extends Container(Canvas) {
-
- static description() {
-
- return 'Connect inputs to outputs.'
-
- }
-
- static defaults() {
-
- var defaults = super.defaults().extend({
- class_specific: {
- inputs: {type: 'array|object', value: ['input_1', 'input_2'], help: [
- '- `Array` of input names : `[\'input_1\', \'input_2\']`',
- '- `Object` of `"label_1": "input_1"` pairs (example: `{"label a": "name 1", "label b": "name 2"}`). Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won\'t be kept',
- '',
- 'Patchbay inputs can be connected to one or more outputs and will send messages of the following form when they are connected/disconnected: ',
- '`/patchbay_address input_x output_x output_y etc`',
- 'If no output is connected to the input, the message will be `/patchbay_address input_x`',
- 'The inputs values can be consumed with the property inheritance syntax: `@{patchbay_id/input_1}` returns an array of output names connected to `input_1`.',
- 'To change connections via scripting, one must target the input nodes as follows: `set(\'patchbay_id/input_name\', [\'output_x\', \'output_y\'])`'
- ]},
- outputs: {type: 'array|object', value: ['output_1', 'output_2'], help: 'List of output values the inputs can connect to (see `inputs`).'},
- exclusive: {type: 'string', value: false, choices: [false, 'in', 'out', 'both'], help: [
- '- `in`: allows only one connection per input',
- '- `out`: allows only one connection per output',
- '- `both`: allows only one connection per input and output'
- ]}
- }
- })
-
- defaults.style.css.help.concat(
- 'The inputs/outputs width can be adjusted by using the `.nodes` selector:',
- '`.nodes { width: 25% }`',
- )
-
- return defaults
- }
-
- static normalizeArrayObject(obj) {
-
- if (typeof obj !== 'object' || obj === null) {
- return PatchBay.normalizeArrayObject([obj])
- } else if (Array.isArray(obj)) {
- var ret = {},
- k, i
- for (i = 0; i < obj.length; i++) {
- k = typeof obj[i] === 'string' ? obj[i] : JSON.stringify(obj[i])
- ret[k] = obj[i]
- }
- return ret
- } else {
- return obj
- }
-
- }
-
- constructor(options) {
-
- super({...options, html: html`
-
-
-
-
-
- `})
-
- this.inputs = PatchBay.normalizeArrayObject(this.getProp('inputs'))
- this.outputs = PatchBay.normalizeArrayObject(this.getProp('outputs'))
- this.inputsValues = Object.values(this.inputs)
- this.outputsValues = Object.values(this.outputs)
-
- this.inputsWidgets = []
- this.inputNodes = []
- this.outputNodes = []
-
- this.value = {}
-
- for (let k in this.inputs) {
- let w = parser.parse({
- data: {
- type: 'patchbaynode',
- comments: this.inputs[k], // TODO: using comment prop to smuggle input identifier, ok but could be more elegant
- id: this.getProp('id') + '/' + this.inputs[k],
- address: '#{@{parent.address} == "auto" ? "/" + @{parent.id} : @{parent.address}}',
- target: '@{parent.target}',
- ignoreDefaults: '@{parent.ignoreDefaults}',
- preArgs: '#{@{parent.preArgs} == "" ? @{this.comments} : Array.isArray(@{parent.preArgs}) ? @{parent.preArgs}.concat(@{this.comments}) : [@{parent.preArgs}, @{this.comments}]}',
- bypass: '@{parent.bypass}',
- label: k
- },
- parentNode: DOM.get(this.widget, '.inputs')[0],
- parent: this,
- meta: {not_editable: true}
- })
- this.inputsWidgets.push(w)
- this.inputNodes.push(w.container)
- this.value[k] = []
- }
-
- var outputs = DOM.get(this.widget, '.outputs')[0]
- for (let k in this.outputs) {
- var node = html`
-
- ${k}
-
- `
- outputs.appendChild(node)
- this.outputNodes.push(node)
- }
-
-
- this.connecting = []
- this.mousePosition = []
- this.dragging = false
-
- this.on('draginit', (e)=>{
- this.toggleConnection(e.target)
- if (e.target === this.canvas) {
- this.mousePosition = [e.offsetX, e.offsetY]
- } else {
- if (this.inputNodes.includes(e.target)) {
- this.mousePosition = [e.offsetX - e.target.offsetWidth, e.offsetY + e.target.offsetTop]
- } else {
- this.mousePosition = [e.offsetX + this.canvas.offsetWidth, e.offsetY + e.target.offsetTop]
- }
- }
- }, {element: this.widget})
-
- this.on('drag', (e)=>{
- if (!this.connecting.length) {
- this.toggleConnection(e.target)
- }
- this.mousePosition[0] += e.movementX
- this.mousePosition[1] += e.movementY
- this.dragging = true
- this.batchDraw()
- }, {element: this.widget})
-
- this.on('dragend', (e)=>{
-
- if (this.dragging) {
- // touch hover fix
- var node = e.isTouch ? document.elementFromPoint(e.clientX, e.clientY) : e.target
-
- this.mousePosition = []
- this.toggleConnection(node)
- }
- this.dragging = false
- }, {element: this.widget})
-
-
- this.on('value-changed',(e)=>{
-
- if (e.widget === this || e.widget.parent !== this) return
-
- var k = e.widget.getProp('label')
- this.value[k] = e.widget.getValue()
-
- this.changed(e.options)
-
- })
-
- }
-
- toggleConnection(node) {
-
- var input = this.inputNodes.indexOf(node),
- output = this.outputNodes.indexOf(node)
-
- if (input > -1 && input !== this.connecting[0]) {
- this.connecting[0] = input
- } else if (output > -1 && output !== this.connecting[1]) {
- this.connecting[1] = output
- } else {
- this.connecting = []
- }
-
- if (this.connecting[0] !== undefined && this.connecting[1] !== undefined) {
- this.inputsWidgets[this.connecting[0]].toggleValue(this.outputsValues[this.connecting[1]])
- this.connecting = []
- } else {
- this.batchDraw()
- }
-
- }
-
- draw() {
-
- this.clear()
-
- var x1 = 0,
- x2 = this.width,
- y1, y2,
- connections,
- i, j
-
- var lines = [],
- strongLines = []
-
- for (i = 0; i < this.inputsWidgets.length; i++) {
-
- connections = this.inputsWidgets[i].getValue()
-
- if (connections.length) {
-
- y1 = this.height / this.inputsValues.length * (i + 0.5)
-
- for (j = 0; j < connections.length; j++) {
-
- if (this.outputsValues.indexOf(connections[j]) > -1) {
-
- y2 = this.height / this.outputsValues.length * (this.outputsValues.indexOf(connections[j]) + 0.5)
-
- var line = [[x1, y1], [this.width / 2, y1, this.width / 2, y2 ,x2, y2]]
-
- if (this.connecting[0] === i || this.connecting[1] === this.outputsValues.indexOf(connections[j])) {
- strongLines.push(line)
- } else {
- lines.push(line)
- }
-
- }
-
- }
-
-
- }
-
- }
-
- if (this.connecting.length) {
-
- this.ctx.beginPath()
- this.ctx.fillStyle = this.cssVars.colorFill
- this.ctx.globalAlpha = this.cssVars.alphaFillOn
-
- var side = this.connecting[0] !== undefined ? 0 : 1,
- cx = side === 0 ? 0 : this.width,
- cy = this.height / (side === 0 ? this.inputsValues : this.outputsValues).length * (this.connecting[side] + 0.5)
-
- this.ctx.arc(cx, cy, 8 * PXSCALE, Math.PI * 2, false)
- this.ctx.fill()
- strongLines.push(null)
-
-
- if (this.mousePosition.length) {
- var [x3, y3] = this.mousePosition,
- centerx = Math.abs(cx - x3) / 2,
- bz1 = side ? cx - centerx : cx + centerx,
- bz2 = side ? x3 + centerx : x3 - centerx
-
- strongLines.push([[cx, cy], [bz1, cy, bz2, y3 ,x3, y3]])
-
- }
-
- }
-
-
- this.ctx.strokeStyle = this.cssVars.colorFill
- this.ctx.lineWidth = 2 * PXSCALE
- this.ctx.globalAlpha = strongLines.length ? this.cssVars.alphaFillOff : this.cssVars.alphaFillOn
-
- this.ctx.beginPath()
- for (i in lines) {
- this.ctx.moveTo(...lines[i][0])
- this.ctx.bezierCurveTo(...lines[i][1])
- }
- this.ctx.stroke()
-
- if (strongLines.length) {
-
- this.ctx.globalAlpha = this.cssVars.alphaFillOn
- this.ctx.beginPath()
- for (i in strongLines) {
- if (strongLines[i] === null) continue
- this.ctx.moveTo(...strongLines[i][0])
- this.ctx.bezierCurveTo(...strongLines[i][1])
- }
- this.ctx.stroke()
-
- }
-
-
- }
-
-}
-
-export {
- PatchBay,
- PatchBayNode
-}
diff --git a/src/client/widgets/containers/root.mjs b/src/client/widgets/containers/root.mjs
deleted file mode 100644
index c61cdea5..00000000
--- a/src/client/widgets/containers/root.mjs
+++ /dev/null
@@ -1,120 +0,0 @@
-import Panel from './panel.mjs'
-import StaticProperties from '../mixins/static_properties.mjs'
-import {updateMobileThemeColor} from '../../ui/utils.mjs'
-import {DOM} from '../../globals.mjs'
-
-var mainMenu
-;(async()=>{
- mainMenu = (await import('../../ui/main-menu.mjs')).default
-})()
-
-class Root extends StaticProperties(Panel, {visible: true, label: false, id: 'root'}) {
-
- static description() {
-
- return 'Main (unique) container'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- widgets: {
- visible: null,
- },
- geometry: {
- left: null,
- top: null,
- expand: null,
- },
- style: {
- colorFill: null,
- colorStroke: null,
- alphaStroke: null,
- alphaFillOff: null,
- lineWidth: null,
- _separator_root_style: 'Root style',
- hideMenu: {type: 'boolean', value: false, help: 'Set to `true` to hide the main menu button.'},
-
- },
- scripting: {
- onPreload: {type: 'script', value: '', editor: 'javascript', help: ['Script executed before any other widget is created. See documentation .']},
- }
- })
-
- }
-
- constructor(options) {
-
- options.root = true
- options.props.id = 'root'
-
- super(options)
-
- this.widget.classList.add('root')
- this.root = true
-
- this.checkMenuVisibility()
-
- DOM.each(this.widget, '> .navigation', (el)=>{
- el.classList.add('main')
- })
-
- }
-
- checkMenuVisibility() {
-
- if (this.getProp('hideMenu')) {
- mainMenu.container.style.display = 'none'
- } else {
- mainMenu.container.style.display = ''
- }
-
- }
-
- isVisible() {
-
- return true
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- if (super.onPropChanged(...arguments)) return true
-
- switch (propName) {
-
- case 'hideMenu':
- this.checkMenuVisibility()
- return
- case 'colorBg':
- updateMobileThemeColor(this)
-
- }
-
- }
-
-
- setContainerStyles(styles) {
-
- super.setContainerStyles(styles)
-
- this.container.classList.toggle('auto-height', this.getProp('height') === 'auto')
-
- }
-
- setCssVariables() {
-
- super.setCssVariables()
- updateMobileThemeColor(this)
-
- }
-
-}
-
-Root.dynamicProps = Root.prototype.constructor.dynamicProps.concat(
- 'hideMenu'
-)
-
-
-export default Root
diff --git a/src/client/widgets/containers/tab.mjs b/src/client/widgets/containers/tab.mjs
deleted file mode 100644
index 35f113c9..00000000
--- a/src/client/widgets/containers/tab.mjs
+++ /dev/null
@@ -1,114 +0,0 @@
-import Panel from './panel.mjs'
-import * as resize from '../../events/resize.mjs'
-import {iconify} from '../../ui/utils.mjs'
-
-class Tab extends Panel {
-
- static description() {
-
- return 'Tabbed panel widget.mjs'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- geometry: null,
- style: {
- _separator_tab_style: 'Tab style',
- label: {type: 'string|boolean', value: 'auto', help: [
- 'Set to `false` to hide completely',
- '- Insert icons using the prefix ^ followed by the icon\'s name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)',
- '- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal`',
- ]},
- colorStroke: null,
- alphaStroke: null,
- alphaFillOff: null,
- alphaFillOn: null,
- lineWidth: null
- }
- })
-
- }
-
- constructor(options) {
-
- super(options)
-
- this.container.classList.add('show')
-
- this.detached = false
-
- this.label = ''
- this.updateLabel()
-
- }
-
- updateLabel() {
-
- if (this.getProp('label') === false) {
- this.label = ''
- } else {
- this.label = this.getProp('label') == 'auto'?
- this.getProp('id'):
- iconify(String(this.getProp('label')).replace(/allow attribute',
- ]},
- },
- value: {
- value: {type: 'string', value: '', help: [
- 'External web page URL.',
- ]}
- },
- osc: {
- decimals: null,
- typeTags: null,
- bypass: null,
- ignoreDefaults: null
- }
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: html`
-
-
- `
- })
-
- if (!this.getProp('border')) this.container.classList.add('noborder')
-
- this.frame = DOM.get(this.widget, '.frame')[0]
-
- if (this.getProp('allow')) this.frame.setAttribute('allow', this.getProp('allow'))
-
- }
-
- setValue(v, options={}) {
-
- this.value = v
-
- if (this.value) {
- this.frame.setAttribute('src', this.value)
- } else {
- this.frame.setAttribute('src', '')
- }
-
- if (options.sync) this.changed(options)
-
- }
-
-
-}
-
-export default Frame
diff --git a/src/client/widgets/frames/html.mjs b/src/client/widgets/frames/html.mjs
deleted file mode 100644
index 283ec572..00000000
--- a/src/client/widgets/frames/html.mjs
+++ /dev/null
@@ -1,75 +0,0 @@
-import morph from 'nanomorph'
-import html from 'nanohtml'
-import Widget from '../common/widget.mjs'
-import StaticProperties from '../mixins/static_properties.mjs'
-import {DOM} from '../../globals.mjs'
-
-class Html extends StaticProperties(Widget, {bypass: true}) {
-
- static description() {
-
- return 'Simple HTML parser.'
-
- }
-
-
- static defaults() {
-
- return super.defaults().extend({
- osc: {
- decimals: null,
- typeTags: null,
- bypass: null,
- ignoreDefaults: null
- }
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: html`
-
-
-
- `})
-
- this.noValueState = true
-
- if (!this.getProp('border')) this.container.classList.add('noborder')
- this.frame = DOM.get(this.widget, '.frame')[0]
-
- if (this.getProp('html') !== '') this.updateHtmlLegacy()
-
- }
-
- updateHtml(){}
-
- updateHtmlLegacy(){
-
- var newHtml = this.frame.cloneNode(false)
-
- newHtml.innerHTML = this.getProp('html')
-
- morph(this.frame, newHtml)
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- if (super.onPropChanged(...arguments)) return true
-
- switch (propName) {
-
- case 'html':
- this.updateHtmlLegacy()
- return
-
- }
-
- }
-
-
-}
-
-export default Html
diff --git a/src/client/widgets/frames/image.mjs b/src/client/widgets/frames/image.mjs
deleted file mode 100644
index 9eae72c4..00000000
--- a/src/client/widgets/frames/image.mjs
+++ /dev/null
@@ -1,113 +0,0 @@
-import html from 'nanohtml'
-import Widget from '../common/widget.mjs'
-import {urlParser} from '../utils.mjs'
-import StaticProperties from '../mixins/static_properties.mjs'
-import {DOM} from '../../globals.mjs'
-
-export default class Image extends StaticProperties(Widget, {bypass: true}) {
-
- static description() {
-
- return 'Load a image (url or base64-encoded).'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- style: {
- _separator_image_style: 'Image style',
- size: {type: 'string', value: 'cover', choices: ['cover', 'contain', 'auto'], help: 'CSS background-size'},
- position: {type: 'string', value: 'center', choices: ['center', 'left', 'right', 'top', 'bottom', 'left top', 'left bottom', 'right top', 'right bottom'], help: 'CSS background-position'},
- repeat: {type: 'string', value: 'no-repeat', choices: ['no-repeat', 'repeat', 'repeat-x', 'repeat-y', 'space', 'round'], help: 'CSS background-repeat'},
- },
- class_specific: {
- cache: {type: 'boolean', value: true, help: [
- 'Set to false to disable image caching (forces file reload when updating or editing the widget).',
- 'When true, sending `reload` to the widget reloads its image without changing its value'
- ]}
- },
- value: {
- value: {type: 'string', value: '', help: [
- '- File `url` or `path` (relative to the session or theme file location by default, falling back to absolute path)',
- '- Base64 encoded image : `data:image/...`',
- '- Enter "qrcode" to display the server\'s address QR code'
- ]}
- },
- osc: {
- decimals: null,
- typeTags: null,
- bypass: null,
- ignoreDefaults: null
- }
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: html`
-
-
-
- `})
-
- if (!this.getProp('border')) this.container.classList.add('noborder')
- this.frame = DOM.get(this.widget, '.frame')[0]
-
- this.frame.style.setProperty('background-size', this.getProp('size'))
- this.frame.style.setProperty('background-position', this.getProp('position'))
- this.frame.style.setProperty('background-repeat', this.getProp('repeat'))
-
- }
-
- setValue(v, options={}) {
-
- if (typeof v !== 'string') return
-
- var s = v==null ? '' : '' + v,
- cache_query = ''
-
- if (!s.length) {
-
- this.value = String(this.getProp('default'))
-
- } else if (s != 'reload') {
-
- if (s.length > 1) this.value = s
-
- }
-
- if (typeof this.value === 'string' && this.value.length) {
-
- if ((s === 'reload' || !this.getProp('cache')) && this.value.indexOf('base64') === -1) {
- cache_query = (this.value.indexOf('?') != -1 ? '&' : '?') + Date.now()
- }
-
- }
-
- var url = this.value,
- parser = urlParser(url)
-
- // escape windows absolute file paths
- if (!parser.protocol.match(/http|data/)) url = url.replace(':', '_:_')
- url = url.replace(/\\/g, '\\\\')
-
-
- if (url) {
- this.frame.style.setProperty('background-image', `url("${url}${cache_query}")`)
- } else {
- this.frame.style.setProperty('background-image', '')
- }
-
- if (options.sync) this.changed(options)
-
- }
-
- onRemove() {
-
- super.onRemove()
-
- }
-
-}
diff --git a/src/client/widgets/frames/svg.mjs b/src/client/widgets/frames/svg.mjs
deleted file mode 100644
index 443cd3ef..00000000
--- a/src/client/widgets/frames/svg.mjs
+++ /dev/null
@@ -1,115 +0,0 @@
-import morph from 'nanomorph'
-import html from 'nanohtml'
-import Widget from '../common/widget.mjs'
-import StaticProperties from '../mixins/static_properties.mjs'
-import {DOM} from '../../globals.mjs'
-
-
-class Svg extends StaticProperties(Widget, {bypass: true}) {
-
- static description() {
-
- return 'Svg parser.'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- class_specific: {
- svg: {type: 'string', value: '', help: [
- 'Svg xml definition (will be wrapped in a `< svg />` element)',
- ]},
- },
- osc: {
- decimals: null,
- typeTags: null,
- bypass: null,
- ignoreDefaults: null
- }
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: html`
-
-
-
- `})
-
- this.noValueState = true
-
- this.frame = DOM.get(this.widget, '.frame')[0]
-
- this.height = undefined
- this.width = undefined
-
- this.on('resize', this.resizeHandleProxy.bind(this), {element: this.widget})
-
- if (!this.getProp('border')) this.container.classList.add('noborder')
-
- }
-
- updateSvg(force){
-
- if (!this.width || !this.height) return
-
- var svg = this.getProp('svg')
-
- this.frame.setAttribute('width', this.width)
- this.frame .setAttribute('height', this.height)
-
- var node = this.frame.cloneNode(false)
-
- node.innerHTML = svg
-
- if (force) {
- this.frame.innerHTML = node.innerHTML
- } else {
- morph(this.frame, node)
- }
-
- }
-
- resizeHandleProxy() {
-
- this.resizeHandle(...arguments)
-
- }
-
- resizeHandle(event){
-
- var {width, height} = event
-
- this.height = height
- this.width = width
-
- this.updateSvg(true)
-
- }
-
-
- onPropChanged(propName, options, oldPropValue) {
-
- if (super.onPropChanged(...arguments)) return true
-
- switch (propName) {
-
- case 'svg':
- this.updateSvg()
- return
-
- }
-
- }
-
-
-}
-
-Svg.dynamicProps = Svg.prototype.constructor.dynamicProps.concat(
- 'svg'
-)
-
-export default Svg
diff --git a/src/client/widgets/graphs/eq.mjs b/src/client/widgets/graphs/eq.mjs
deleted file mode 100644
index b3c0263c..00000000
--- a/src/client/widgets/graphs/eq.mjs
+++ /dev/null
@@ -1,293 +0,0 @@
-import {mapToScale} from '../utils.mjs'
-import Plot from './plot.mjs'
-import StaticProperties from '../mixins/static_properties.mjs'
-
-class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smooth:true}) {
-
- static description() {
-
- return 'Draws logarithmic frequency response from an array of filter objects.'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- widget: {
- interaction: {value: false}
- },
- class_specific: {
- 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", default: "peak")',
- '- `freq`: number (filter\'s resonant frequency, default: 1000)',
- '- `q`: number (Q factor, default: 1)',
- '- `gain`: number (default: 0)',
- '- `on`: boolean (default: true)',
- '- `poles`: if `type` is "highpass" or "lowpass", indicates the number of poles for the filter (if omitted or 0, a biquad filter with Q factor is used). Set to 1 for 6dB/octaves roll-off, 2 for 12dB/octaves, etc.',
- 'See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode'
-
- ]},
- pips: {type: 'boolean', value: true, help: 'Set to false to hide the scale'},
- rangeX: {type: 'object', value: {min: 20, max: 22000}, help: [
- 'Defines the min and max values for the x axis (in Hz, logarithmic scale)',
- 'The sampling frequency used to compute the response curve will be 2 * rangeX.max',
-
- ]},
- rangeY: {type: 'object', value: {min:-6, max:6}, help: 'Defines the min and max values for the y axis (in dB)'},
- origin: {type: 'number|boolean', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it'},
- logScaleX: null,
- logScaleY: null
- },
- osc: {
- decimals: null,
- typeTags: null,
- bypass: null,
- ignoreDefaults: null
- }
- })
-
- }
-
- constructor(options) {
-
- super(options)
-
- this.setupArrays()
- this.calcPending = true
- this.batchDraw()
-
- }
-
- setupArrays() {
-
- this.freqs = new Float32Array(this.width)
- this.value = new Float32Array(this.width).fill(0)
-
- var i,
- min = this.getProp('rangeX').min,
- max = this.getProp('rangeX').max,
- width = this.width
-
- for (i = 0; i < width; ++i) {
- this.freqs[i] = mapToScale(i, [0, width], [min, max], -1, true)
- }
-
- }
-
- calcResponse() {
-
- this.value.fill(0)
-
- for (let filter of this.getProp('filters')) {
-
- if (filter.on !== undefined && !filter.on) continue
-
- var poles = 1,
- type = filter.type
-
- if ((type === 'lowpass' || type === 'highpass') && filter.poles !== undefined && filter.poles !== 0) {
- poles = Math.max(parseInt(filter.poles), 1)
- type += '-1p'
- }
-
- biquadResponse({
- type: type || 'peak',
- gain: filter.gain || 0,
- frequency: filter.freq || 1000,
- q: filter.q || 1,
- poles,
- Fs: this.getProp('rangeX').max * 2
- }, this.freqs, this.value)
- }
-
- }
-
- draw() {
- if (this.calcPending) {
- this.calcResponse()
- this.calcPending = false
- }
- super.draw()
- }
-
- resizeHandle(event){
-
- super.resizeHandle(event)
- if (this.width !== this.value.length) {
- this.setupArrays()
- this.calcPending = true
- this.batchDraw()
- }
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- super.onPropChanged(...arguments)
-
- switch (propName) {
- case 'filters':
- this.calcPending = true
- this.batchDraw()
- return
-
- }
-
- }
-
-}
-
-Eq.dynamicProps = Eq.prototype.constructor.dynamicProps.concat(
- 'filters'
-)
-
-export default Eq
-
-
-// biquadResponse
-// Based on code by Nigel Redmon @ https://www.earlevel.com
-function biquadResponse(options, frequencyHz, filterResponse) {
-
- var {type, frequency, q, gain, Fs, poles} = options,
- len = frequencyHz.length,
- a0, a1, a2, b1, b2,norm,
- w, phi, y, i
-
- var V = Math.pow(10, Math.abs(gain) / 20)
- var K = Math.tan(Math.PI * frequency / Fs)
-
- switch (type) {
- case 'lowpass':
- norm = 1 / (1 + K / q + K * K)
- a0 = K * K * norm
- a1 = 2 * a0
- a2 = a0
- b1 = 2 * (K * K - 1) * norm
- b2 = (1 - K / q + K * K) * norm
- break
-
- case 'highpass':
- norm = 1 / (1 + K / q + K * K)
- a0 = 1 * norm
- a1 = -2 * a0
- a2 = a0
- b1 = 2 * (K * K - 1) * norm
- b2 = (1 - K / q + K * K) * norm
- break
-
- case 'lowpass-1p':
- // b1 = Math.exp(-2.0 * Math.PI * (frequency / Fs))
- // a0 = 1.0 - b1
- // b1 = -b1
- // a1 = a2 = b2 = 0
- // using lowpass 1p1z instead
- norm = 1 / (1 / K + 1)
- a0 = a1 = norm
- b1 = (1 - 1 / K) * norm
- a2 = b2 = 0
- break
-
- case 'highpass-1p':
- // b1 = -Math.exp(-2.0 * Math.PI * (0.5 - frequency / Fs))
- // a0 = 1.0 + b1
- // b1 = -b1
- // a1 = a2 = b2 = 0
- // using highpass 1p1z instead
- norm = 1 / (K + 1)
- a0 = norm
- a1 = -norm
- b1 = (K - 1) * norm
- a2 = b2 = 0
- break
-
- case 'bandpass':
- norm = 1 / (1 + K / q + K * K)
- a0 = K / q * norm
- a1 = 0
- a2 = -a0
- b1 = 2 * (K * K - 1) * norm
- b2 = (1 - K / q + K * K) * norm
- break
-
- case 'notch':
- norm = 1 / (1 + K / q + K * K)
- a0 = (1 + K * K) * norm
- a1 = 2 * (K * K - 1) * norm
- a2 = a0
- b1 = a1
- b2 = (1 - K / q + K * K) * norm
- break
-
- case 'peak':
- if (gain >= 0) {
- norm = 1 / (1 + 1/q * K + K * K)
- a0 = (1 + V/q * K + K * K) * norm
- a1 = 2 * (K * K - 1) * norm
- a2 = (1 - V/q * K + K * K) * norm
- b1 = a1
- b2 = (1 - 1/q * K + K * K) * norm
- }
- else {
- norm = 1 / (1 + V/q * K + K * K)
- a0 = (1 + 1/q * K + K * K) * norm
- a1 = 2 * (K * K - 1) * norm
- a2 = (1 - 1/q * K + K * K) * norm
- b1 = a1
- b2 = (1 - V/q * K + K * K) * norm
- }
- break
- case 'lowshelf':
- if (gain >= 0) {
- norm = 1 / (1 + Math.SQRT2 * K + K * K)
- a0 = (1 + Math.sqrt(2*V) * K + V * K * K) * norm
- a1 = 2 * (V * K * K - 1) * norm
- a2 = (1 - Math.sqrt(2*V) * K + V * K * K) * norm
- b1 = 2 * (K * K - 1) * norm
- b2 = (1 - Math.SQRT2 * K + K * K) * norm
- }
- else {
- norm = 1 / (1 + Math.sqrt(2*V) * K + V * K * K)
- a0 = (1 + Math.SQRT2 * K + K * K) * norm
- a1 = 2 * (K * K - 1) * norm
- a2 = (1 - Math.SQRT2 * K + K * K) * norm
- b1 = 2 * (V * K * K - 1) * norm
- b2 = (1 - Math.sqrt(2*V) * K + V * K * K) * norm
- }
- break
- case 'highshelf':
- if (gain >= 0) {
- norm = 1 / (1 + Math.SQRT2 * K + K * K)
- a0 = (V + Math.sqrt(2*V) * K + K * K) * norm
- a1 = 2 * (K * K - V) * norm
- a2 = (V - Math.sqrt(2*V) * K + K * K) * norm
- b1 = 2 * (K * K - 1) * norm
- b2 = (1 - Math.SQRT2 * K + K * K) * norm
- }
- else {
- norm = 1 / (V + Math.sqrt(2*V) * K + K * K)
- a0 = (1 + Math.SQRT2 * K + K * K) * norm
- a1 = 2 * (K * K - 1) * norm
- a2 = (1 - Math.SQRT2 * K + K * K) * norm
- b1 = 2 * (K * K - V) * norm
- b2 = (V - Math.sqrt(2*V) * K + K * K) * norm
- }
- break
- }
-
-
- for (i = 0; i < len; i++) {
-
- w = mapToScale(frequencyHz[i], [0, Fs / 2], [0, Math.PI], -1, false),
- phi = Math.pow(Math.sin(w / 2), 2),
- y = Math.log(Math.pow(a0 + a1 + a2, 2) - 4 * (a0 * a1 + 4 * a0 * a2 + a1 * a2) * phi + 16 * a0 * a2 * phi * phi) -
- Math.log(Math.pow(1 + b1 + b2, 2) - 4 * (b1 + 4 * b2 + b1 * b2) * phi + 16 * b2 * phi * phi)
-
- y = y * 10 / Math.LN10
-
- filterResponse[i] += y * poles
-
- }
-
-
-}
diff --git a/src/client/widgets/graphs/plot.mjs b/src/client/widgets/graphs/plot.mjs
deleted file mode 100644
index 6259a00e..00000000
--- a/src/client/widgets/graphs/plot.mjs
+++ /dev/null
@@ -1,257 +0,0 @@
-import html from 'nanohtml'
-import {mapToScale} from '../utils.mjs'
-import Canvas from '../common/canvas.mjs'
-import StaticProperties from '../mixins/static_properties.mjs'
-import {PXSCALE, JSON5} from '../../globals.mjs'
-
-export default class Plot extends StaticProperties(Canvas, {bypass: true}) {
-
- static description() {
-
- return 'XY coordinates plot.'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- widget: {
- interaction: {value: false}
- },
- style: {
- _separator_plot_style: 'Plot style',
- dots: {type: 'boolean', value: false, help: 'Draw dots on the line'},
- bars: {type: 'boolean', value: false, help: 'Set to `true` to use draw bars instead (disables `logScaleX` and forces `x axis` even spacing)'},
- pips:{type: 'boolean', value: true, help: 'Set to `false` to hide the scale'},
- },
- class_specific: {
- rangeX: {type: 'object', value: {min: 0, max: 1}, help: 'Defines the min and max values for the x axis'},
- rangeY: {type: 'object', value: {min: 0, max:1}, help: 'Defines the min and max values for the y axis'},
- logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale.'},
- logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale.'},
- origin: {type: 'number|boolean', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it'},
- },
- value: {
- value: {type: 'array|string', value: '', help: [
- '- `Array` of `y` values: `[y1, y2, ...]`',
- '- `Array` of `[x, y]` `array` values: `[[x1 , y1], [x2, y2], ...]`',
- '- `String` `array`: `"[y1, y2, ...]"` or `"[[x1 , y1], [x2, y2], ...]"`',
- '- `String` `object` to update specific coordinates only: `"{0: y1, 1: y2}"` or `"{0: [x1, y1], 1: [x2, y2]}"`',
- ]}
- },
- osc: {
- decimals: null,
- typeTags: null,
- bypass: null,
- ignoreDefaults: null
- }
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: html`
-
-
-
- `})
-
- this.value = []
- this.rangeX = this.getProp('rangeX') || {min:0,max:1}
- this.rangeY = this.getProp('rangeY') || {min:0,max:1}
- this.logScaleX = this.getProp('logScaleX')
- this.logScaleY = this.getProp('logScaleY')
- this.pips = {
- x : {
- min: Math.abs(this.rangeX.min)>=1000?this.rangeX.min/1000+'k':this.rangeX.min,
- max: Math.abs(this.rangeX.max)>=1000?this.rangeX.max/1000+'k':this.rangeX.max
- },
- y : {
- min: Math.abs(this.rangeY.min)>=1000?this.rangeY.min/1000+'k':this.rangeY.min,
- max: Math.abs(this.rangeY.max)>=1000?this.rangeY.max/1000+'k':this.rangeY.max
- }
- }
-
- }
-
- draw() {
-
- this.ctx.clearRect(0,0,this.width,this.height)
-
- if (this.getProp('bars')) {
- this.draw_bars()
- } else {
- var points = this.draw_line()
- if (this.getProp('dots')) {
- this.draw_dots(points)
- }
- }
-
- if (this.getProp('pips')) this.draw_pips()
-
- }
-
- draw_pips() {
-
- this.ctx.fillStyle = this.cssVars.colorText
- this.ctx.globalAlpha = this.cssVars.alphaPips
-
- var margin = this.cssVars.padding + this.cssVars.lineWidth
-
- if (margin < this.fontSize * 1.5) return
-
-
- if (this.pips.x) {
-
- this.ctx.textAlign = 'center'
- this.ctx.fillText(this.pips.x.min, margin, this.height - margin / 2)
- this.ctx.fillText(this.pips.x.max, this.width - margin, this.height - margin / 2)
-
- }
-
- if (this.pips.y) {
-
- this.ctx.textAlign = 'right'
- this.ctx.fillText(this.pips.y.min, margin / 2 + this.fontSize / 2, this.height - margin)
- this.ctx.fillText(this.pips.y.max, margin / 2 + this.fontSize / 2, margin)
-
- }
-
- }
-
- draw_line() {
-
- var points = [],
- padding = this.cssVars.padding + this.cssVars.lineWidth,
- length = this.value.length,
- x, y, i, previousValue, nx, ny
-
- for (i = 0; i < length; i++) {
-
- if (this.value[i].length) {
- points.push(mapToScale(this.value[i][0], [this.rangeX.min, this.rangeX.max], [padding, this.width - padding], -1, this.logScaleX, true))
- points.push(mapToScale(this.value[i][1], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true, true))
- } else {
-
- if (i < length - 2 && this.value[i] === previousValue && this.value[i+1] === previousValue) {
- continue
- }
- nx = mapToScale(i, [0, this.value.length - 1], [padding, this.width - padding], -1, this.logScaleX, true)
- ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true, true)
-
- if (x !== nx || y !== ny) {
- points.push(nx)
- points.push(ny)
- x = nx
- y = ny
- }
-
- previousValue = this.value[i]
-
- }
-
- }
-
- if (points.length < 4) return points
-
- this.ctx.beginPath()
-
- this.ctx.moveTo(points[0], points[1])
- for (i = 2; i < points.length - 2; i += 2) {
- this.ctx.lineTo(points[i], points[i + 1])
- }
- this.ctx.lineTo(points[i], points[i + 1])
-
- this.ctx.globalAlpha = 1
- this.ctx.lineWidth = 2 * PXSCALE
- this.ctx.strokeStyle = this.cssVars.colorWidget
- this.ctx.stroke()
-
- if (this.getProp('origin') !== false) {
-
- var origin = mapToScale(this.getProp('origin'), [this.rangeY.min, this.rangeY.max], [this.height - padding, padding], 0, this.getProp('logScaleY'), true)
-
- this.ctx.globalAlpha = this.cssVars.alphaFillOn
- this.ctx.fillStyle = this.cssVars.colorFill
- this.ctx.lineTo(this.width - padding, origin)
- this.ctx.lineTo(padding, origin)
- this.ctx.closePath()
- this.ctx.fill()
-
- }
-
- return points
-
- }
-
- draw_dots(points) {
-
- this.ctx.globalAlpha = 1
- this.ctx.fillStyle = this.cssVars.colorWidget
- this.ctx.strokeStyle = this.cssVars.colorBackground
- this.ctx.lineWidth = 2 * PXSCALE
- for (var i = 0; i < points.length; i += 2) {
- this.ctx.beginPath()
- this.ctx.arc(points[i], points[i + 1], 2 * PXSCALE, 0, 2*Math.PI)
- this.ctx.fill()
- this.ctx.stroke()
- }
-
- }
-
- draw_bars() {
-
- var padding = this.cssVars.padding,
- barWidth = Math.round((this.width - padding * 2) / this.value.length),
- offset = Math.round((this.width - barWidth * this.value.length) / 2)
-
-
- var origin = mapToScale(this.getProp('origin') !== false ? this.getProp('origin') : this.rangeY.min, [this.rangeY.min, this.rangeY.max],[this.height - padding, padding], 0, this.getProp('logScaleY'), true)
-
- this.ctx.beginPath()
-
- for (let i in this.value) {
- var y = mapToScale(this.value[i].length ? this.value[i][1] : this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], 0, this.logScaleY, true)
- this.ctx.rect(offset + i * barWidth, Math.min(y, origin), barWidth - PXSCALE, Math.abs(Math.min(y - origin)))
-
- }
-
- this.ctx.globalAlpha = 0.4
- this.ctx.fillStyle = this.cssVars.colorWidget
- this.ctx.fill()
-
- }
-
- setValue(v, options={}) {
-
- if (typeof v == 'string') {
- try {
- v = JSON5.parse(v)
- } catch(err) {}
- }
-
- if (typeof v == 'object' && v !== null) {
-
- if (Array.isArray(v)) {
-
- this.value = v
-
- } else {
-
- for (var i in v) {
- if (!isNaN(i)) this.value[i] = v[i]
- }
-
- }
-
- this.batchDraw()
-
- if (options.sync) this.changed(options)
-
- }
-
-
- }
-
-}
diff --git a/src/client/widgets/graphs/visualizer.mjs b/src/client/widgets/graphs/visualizer.mjs
deleted file mode 100644
index 7ab31d75..00000000
--- a/src/client/widgets/graphs/visualizer.mjs
+++ /dev/null
@@ -1,172 +0,0 @@
-import {clip} from '../utils.mjs'
-import Plot from './plot.mjs'
-import StaticProperties from '../mixins/static_properties.mjs'
-import canvasQueue from '../common/queue.mjs'
-import {CANVAS_FRAMERATE} from '../../globals.mjs'
-
-
-class Visualizer extends StaticProperties(Plot, {rangeX: {min: '', max: ''}, dots: false, smooth: false}) {
-
- static description() {
-
- return 'Display its value over time.'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- widget: {
- interaction: {value: false}
- },
- style: {
- bars: null,
- dots: null,
- },
- class_specific: {
- duration: {type: 'number', value: 1, help: 'Defines visualization duration in seconds'},
- framerate: {type: 'number', value: 30, help: 'Defines visualization framerate'},
- rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'},
- origin: {type: 'number', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it'},
- logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm\'s base.'},
- freeze: {type: 'boolean', value: false, help: 'Set to `true` to freeze current view and ignore incoming values'}
- },
- osc: {
- decimals: null,
- typeTags: null,
- bypass: null,
- ignoreDefaults: null
- }
- })
-
- }
-
- constructor(options) {
-
- super(options)
-
- this.fps = clip(this.getProp('framerate'), [1, CANVAS_FRAMERATE])
- this.length = Math.round(clip(this.fps * this.getProp('duration'), [8, 4096]))
- this.value = new Array(this.length).fill(this.rangeY.min)
- this.cancel = false
- this.looping = false
- this.clock = 0
- this.lastUpdate = 0
- this.watchDuration = 1000 * this.getProp('duration')
- this.ticks = 0
-
- this.boundLoop = this.loop.bind(this)
-
- }
-
- startLoop() {
-
- this.clock = Date.now()
- if (!this.looping && !this.getProp('freeze')) {
- this.lastUpdate = Date.now()
- canvasQueue.on('frame', this.boundLoop)
- if (!canvasQueue.running) canvasQueue.startLoop()
- this.looping = true
- this.ticks = 0
- }
- }
-
- stopLoop() {
-
- if (this.looping) {
-
- canvasQueue.off('frame', this.boundLoop)
- this.looping = false
-
- }
-
- }
-
- loop() {
-
- var t = Date.now()
-
- if (t - this.clock >= this.watchDuration) {
- this.stopLoop()
- }
-
- this.ticks += (t - this.lastUpdate) / (1000 / this.fps)
-
- if (Math.floor(this.ticks) > 0) {
- this.shiftData(Math.floor(this.ticks))
- this.ticks -= Math.floor(this.ticks)
- this.batchDraw()
- }
-
- this.lastUpdate = t
-
- }
-
- shiftData(n) {
-
- for (var i = 0; i < n; i++) {
- this.value.push(this.value[this.length - 1])
- this.value.splice(0,1)
- }
-
- }
-
- getValue() {
-
- return this.value[this.length - 1]
-
- }
-
- setValue(v, options={}) {
-
-
- if (typeof(v) === 'number') {
-
- this.value[this.length - 1] = v
- this.startLoop()
-
- if (options.sync) this.changed(options)
-
-
- } else if (Array.isArray(v) && v.length === this.length) {
-
- this.value = v
- this.startLoop()
-
- if (options.sync) this.changed(options)
-
-
- }
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- if (super.onPropChanged(...arguments)) return
-
- switch (propName) {
-
- case 'freeze':
- if (this.getProp('freeze')) this.stopLoop()
- else this.startLoop()
- return
-
- }
-
- }
-
- onRemove() {
-
- this.stopLoop()
- super.onRemove()
-
- }
-
-
-}
-
-Visualizer.dynamicProps = Visualizer.prototype.constructor.dynamicProps.concat(
- 'freeze'
-)
-
-export default Visualizer
diff --git a/src/client/widgets/index.mjs b/src/client/widgets/index.mjs
deleted file mode 100644
index 6ea652cf..00000000
--- a/src/client/widgets/index.mjs
+++ /dev/null
@@ -1,128 +0,0 @@
-// basics
-import button from './basics/button.mjs'
-import _switch from './basics/switch.mjs'
-import dropdown from './basics/dropdown.mjs'
-import menu from './basics/menu.mjs'
-import input from './basics/input.mjs'
-import textarea from './basics/textarea.mjs'
-import file from './basics/file.mjs'
-
-// containers
-import panel from './containers/panel.mjs'
-import folder from './containers/folder.mjs'
-import root from './containers/root.mjs'
-import tab from './containers/tab.mjs'
-import modal from './containers/modal.mjs'
-import clone from './containers/clone.mjs'
-import fragment from './containers/fragment.mjs'
-import matrix from './containers/matrix.mjs'
-import keyboard from './containers/keyboard.mjs'
-import {PatchBay as patchbay, PatchBayNode as patchbaynode} from './containers/patchbay.mjs'
-
-// frames
-import image from './frames/image.mjs'
-import svg from './frames/svg.mjs'
-import html from './frames/html.mjs'
-import frame from './frames/frame.mjs'
-
-// graphs
-import plot from './graphs/plot.mjs'
-import eq from './graphs/eq.mjs'
-import visualizer from './graphs/visualizer.mjs'
-
-// indicators
-import led from './indicators/led.mjs'
-import text from './indicators/text.mjs'
-
-// pads
-import xy from './pads/xy.mjs'
-import rgb from './pads/rgb.mjs'
-import multixy from './pads/multixy.mjs'
-import canvas from './pads/canvas.mjs'
-
-// sliders
-import fader from './sliders/fader.mjs'
-import knob from './sliders/knob.mjs'
-import encoder from './sliders/encoder.mjs'
-import range from './sliders/range.mjs'
-import scrollbar from './sliders/scrollbar.mjs'
-
-// scripts
-import script from './scripts/script-widget.mjs'
-import variable from './scripts/variable.mjs'
-
-export const widgets = {
-
- // basics
- button,
- switch: _switch,
- dropdown,
- menu,
- input,
- textarea,
- file,
-
- // containers
- panel,
- folder,
- root,
- tab,
- modal,
- clone,
- fragment,
- matrix,
- keyboard,
- patchbay,
- patchbaynode,
-
- // frames
- image,
- svg,
- html,
- frame,
-
- // graphs
- plot,
- eq,
- visualizer,
-
- // indicators
- led,
- text,
-
- // pads
- xy,
- rgb,
- multixy,
- canvas,
-
- // sliders
- fader,
- knob,
- encoder,
- range,
- scrollbar,
-
- // scripts
- script,
- variable,
-
-}
-
-export const categories = {
- 'Basics':['button', 'switch', 'dropdown', 'menu', 'input', 'textarea', 'file'],
- 'Containers':['panel', 'modal', 'clone', 'fragment', 'matrix', 'keyboard', 'patchbay', 'folder'],
- 'Frames':['frame', 'svg', 'html', 'image'],
- 'Graphs':['plot','eq','visualizer'],
- 'Indicators':['led', 'text'],
- 'Pads':['xy','rgb','multixy', 'canvas'],
- 'Sliders':['fader','knob', 'encoder', 'range', 'scrollbar'],
- 'Scripts':['script', 'variable'],
-}
-
-var defaults = {}
-for (var k in widgets) {
- defaults[k] = widgets[k].defaults()
- widgets[k]._defaults = defaults[k]._props()
-}
-export {defaults}
diff --git a/src/client/widgets/indicators/led.mjs b/src/client/widgets/indicators/led.mjs
deleted file mode 100644
index b3b87498..00000000
--- a/src/client/widgets/indicators/led.mjs
+++ /dev/null
@@ -1,103 +0,0 @@
-import html from 'nanohtml'
-import {mapToScale} from '../utils.mjs'
-import Widget from '../common/widget.mjs'
-
-export default class Led extends Widget {
-
- static description() {
-
- return 'Intensity display.'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- widget: {
- interaction: {value: false}
- },
- class_specific: {
- 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.'},
- },
- value: {
- value: {type: 'number|array|string', value: '', help: [
- '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',
- ]}
- },
- osc: {
- decimals: null,
- typeTags: null,
- ignoreDefaults: null
- }
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: html` `})
-
- this.setValueIntensity(this.getProp('mode') === 'intensity' ? this.getProp('range').min : this.getProp('range').max)
-
- }
-
- setValue(v, options={}) {
-
-
- var ret = this.getProp('mode') === 'intensity' ? this.setValueIntensity(v) : this.setValueColor(v)
-
-
- if (options.sync && ret !== false) this.changed(options)
- if (options.send) this.sendValue(null, {syncOnly: true})
-
- }
-
- setValueIntensity(v) {
-
- if (typeof v != 'number') return false
-
- this.value = v
- this.container.style.setProperty('--opacity', mapToScale(v, [this.getProp('range').min, this.getProp('range').max], [0, 1], -1, this.getProp('logScale'), true))
-
-
- }
-
- setValueColor(v) {
-
- var c = ''
-
- if (Array.isArray(v) && v.length >= 3) {
-
- 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] = 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]})`
-
- } else if (typeof v == 'string') {
-
- c = v
-
- } else {
-
- return false
-
- }
-
- this.value = v
-
- this.container .style.setProperty('--color-led', c)
-
- }
-
-}
diff --git a/src/client/widgets/indicators/text.mjs b/src/client/widgets/indicators/text.mjs
deleted file mode 100644
index 79b154a8..00000000
--- a/src/client/widgets/indicators/text.mjs
+++ /dev/null
@@ -1,70 +0,0 @@
-import html from 'nanohtml'
-import {iconify} from '../../ui/utils.mjs'
-import Widget from '../common/widget.mjs'
-
-export default class Text extends Widget {
-
- static description() {
-
- return 'Display text.'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- widget: {
- interaction: {value: false}
- },
- style: {
- _separator_text_style: 'Text style',
- vertical: {type: 'boolean', value: false, help: 'Set to `true` to display the text vertically'},
- wrap: {type: 'boolean|string', value: false, choices: [false, true, 'soft'], help: [
- 'Set to `true` to wrap long lines automatically. Set to `soft` to avoid breaking words.',
- ]},
- align: {type: 'string', value: 'center', choices: ['center', 'left', 'right', 'top', 'bottom', 'left top', 'left bottom', 'right top', 'right bottom'], help: 'Text alignment.'},
- },
- osc: {
- typeTags: null,
- ignoreDefaults: null
- }
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: html` `})
-
- this.text = this.widget.appendChild(html` `)
-
- if (this.getProp('vertical')) this.text.classList.add('vertical')
- if (this.getProp('align').includes('left')) this.text.classList.add('left')
- if (this.getProp('align').includes('right')) this.text.classList.add('right')
- if (this.getProp('align').includes('top')) this.text.classList.add('top')
- if (this.getProp('align').includes('bottom')) this.text.classList.add('bottom')
- if (this.getProp('wrap')) this.text.classList.add('wrap')
- if (this.getProp('wrap') === 'soft') this.text.classList.add('wrap-soft')
-
- this.setValue(this.getProp('default'))
-
- }
-
-
- setValue(v, options={}) {
-
- this.value = v === '' || v === null ? this.getProp('default') : v
-
- var s = String(this.getValue(true))
- if (s.indexOf('^') > -1) {
- this.text.innerHTML = iconify(s.replace(//g, '>').replace(/\n/g,' '))
- } else {
- this.text.textContent = s.replace(/\n/g,'\r\n')
- }
-
- if (options.sync) this.changed(options)
- if (options.send) this.sendValue(null, {syncOnly: true})
-
- }
-
-}
diff --git a/src/client/widgets/mixins/double_tap.mjs b/src/client/widgets/mixins/double_tap.mjs
deleted file mode 100644
index 8564e9c5..00000000
--- a/src/client/widgets/mixins/double_tap.mjs
+++ /dev/null
@@ -1,48 +0,0 @@
-import {normalizeDragEvent} from '../../events/utils.mjs'
-import {DOUBLE_TAP_TIME} from '../../globals.mjs'
-
-export default (self, callback, options={})=>{
-
- var lastTapTime = 0,
- lastTapX,
- lastTapY
-
- self.on(options.click ? 'click' : 'fast-click', (event)=>{
-
- if (event.capturedByEditor) return
-
- var tapTime = Date.now(),
- tapLength = tapTime - lastTapTime,
- eventData = options.click ? event : event.detail
-
- if (
-
- tapLength < DOUBLE_TAP_TIME &&
- Math.abs(lastTapX - eventData.pageX) < 20 &&
- Math.abs(lastTapY - eventData.pageY) < 20 &&
- (!options.click || event.pageX !== 0) // prevent fake click emitted with keyboard focus events
-
- ) {
-
- // execute callback at next cycle to ensure draginit events are resolved first
- // normalize event now or offset gets lost
- var e = normalizeDragEvent(event.detail)
- setTimeout(()=>{
- callback(e)
- }, 0)
- lastTapTime = 0
-
- // prevent touchend
- if (!options.click) event.detail.preventOriginalEvent = true
-
- } else {
-
- lastTapTime = tapTime
- lastTapX = eventData.pageX
- lastTapY = eventData.pageY
-
- }
-
- }, {element: options.element})
-
-}
diff --git a/src/client/widgets/mixins/static_properties.mjs b/src/client/widgets/mixins/static_properties.mjs
deleted file mode 100644
index 041ffe40..00000000
--- a/src/client/widgets/mixins/static_properties.mjs
+++ /dev/null
@@ -1,16 +0,0 @@
-let StaticProperties = (superclass, props) => class extends superclass {
-
- createPropsCache() {
-
- super.createPropsCache()
-
- for (var k in props) {
- this.cachedProps[k] = props[k]
- }
-
-
- }
-
-}
-
-export default StaticProperties
diff --git a/src/client/widgets/mixins/touch_state.mjs b/src/client/widgets/mixins/touch_state.mjs
deleted file mode 100644
index 941cc18a..00000000
--- a/src/client/widgets/mixins/touch_state.mjs
+++ /dev/null
@@ -1,45 +0,0 @@
-export default (self, options)=>{
-
- if (self.parent.preventChildrenTouchState) return
-
- self.touched = 0
- self.setValueTouchedQueue = undefined
-
- self.on('draginit',(e)=>{
- self.setValueTouchedQueue = undefined
-
- if (self.shouldDrag && !self.shouldDrag(e)) {
- e.cancelDragEvent = true
- return
- }
- self.touched += 1
- if (self.touched == 1) {
- self.trigger('touch', {stopPropagation: true, touch: 1})
- }
- }, options)
-
- self.on('dragend', (e)=>{
- if (self.touched == 1) {
- self.touched = 0
-
- if (self.setValueTouchedQueue !== undefined) {
- self.setValue(...self.setValueTouchedQueue)
- self.setValueTouchedQueue = undefined
- }
-
- self.trigger('touch', {stopPropagation: true, touch: 0})
-
- } else if (self.touched > 1){
- self.touched -= 1
- }
- }, options)
-
- self.onRemove = ()=>{
- if (self.touched > 0) {
- self.setValueTouchedQueue = undefined
- self.trigger('touch', {stopPropagation: true, touch: 0})
- }
- self.__proto__.onRemove.call(self)
- }
-
-}
diff --git a/src/client/widgets/pads/canvas.mjs b/src/client/widgets/pads/canvas.mjs
deleted file mode 100644
index 8b0c62e1..00000000
--- a/src/client/widgets/pads/canvas.mjs
+++ /dev/null
@@ -1,200 +0,0 @@
-import html from 'nanohtml'
-import Canvas from '../common/canvas.mjs'
-import Script from '../scripts/script.mjs'
-import widgetManager from '../../managers/widgets.mjs'
-
-class CanvasWidget extends Canvas {
-
- static description() {
-
- return 'Multitouch canvas widget with user-defined drawing functions and touch reactions.'
-
- }
-
- static defaults() {
-
- var defaults = super.defaults().extend({
- class_specific: {
- contextType: {type: 'string', value: '2d', choices: ['2d', 'webgl2'], help: 'Context type for the canvas'},
- valueLength: {type: 'number', value: 1, help:[
- 'Defines the number of values accepted by the widget (minimum 1). Incoming messages that don\'t comply will be ignored',
- 'When calling `set()` from a script, submitted value should be an array only if `valueLength` is greater than 1.'
- ]},
- autoClear: {type: 'boolean', value: true, help: [
- 'If set to `false`, the canvas context won\'t be cleared automatically and `ctx.clearRect()` will need to be called in `onDraw`. Ignored if `contextType` is different from `2d`.'
- ]},
- continuous: {type: 'boolean|number', value: false, help: [
- 'If set to `true`, `onDraw` will be called at each frame, otherwise it will be called only when the widget is touched and when it receives a value.',
- 'Can be a number between 1 and 60 to specify the framerate (default: 30 fps).'
- ]},
- }
- })
- defaults.scripting = {
- onCreate: {type: 'script', value: '', editor: 'javascript', help: ['Script executed when the widget is created. See documentation .']},
- onValue: {type: 'script', value: '', editor: 'javascript', help: ['Script executed whenever the widget\'s value updates. See documentation .']},
- onTouch: {type: 'script', value: '', editor:'javascript', help: ['Script executed when the widget is touched and released, and when the pointer moves when the widget is touched. See documentation .',]},
- onDraw: {type: 'script', value: '', editor:'javascript', help: ['Script executed when the widget is redrawn. See documentation .']},
- onResize: {type: 'script', value: '', editor:'javascript', help: ['Script executed when the widget is resized. See documentation .']},
- }
- return defaults
-
- }
-
- constructor(options) {
-
- super({...options, html: html`
-
-
-
- `})
-
- this.valueLength = Math.max(1, parseInt(this.getProp('valueLength')) || 1)
- this.value = this.valueLength > 1 ? Array(this.valueLength).fill(0) : 0
-
- if (this.getProp('onResize')) {
- this.scripts.onResize = new Script({
- widget: this,
- property: 'onResize',
- code: this.getProp('onResize'),
- context: {
- value: 0,
- width: 100,
- height: 100,
- cssVars: {}
- }
- })
- }
-
- if (this.getProp('onDraw')) {
- this.scripts.onDraw = new Script({
- widget: this,
- property: 'onDraw',
- code: this.getProp('onDraw'),
- context: {
- value: 0,
- width: 100,
- height: 100,
- ctx: {},
- cssVars: {}
- }
- })
- }
-
- if (this.getProp('onTouch')) {
-
- this.scripts.onTouch = new Script({
- widget: this,
- property: 'onTouch',
- code: this.getProp('onTouch'),
- context: {
- value: 0,
- width: 100,
- height: 100,
- event: {}
- }
- })
-
- this.on('draginit',(e)=>this.onTouch(e, 'start'), {element: this.container, multitouch: true})
- this.on('drag',(e)=>this.onTouch(e, 'move'), {element: this.container, multitouch: true})
- this.on('dragend',(e)=>this.onTouch(e, 'stop'), {element: this.container, multitouch: true})
-
- }
-
- if (this.getProp('continuous')) {
- var freq = parseInt(this.getProp('continuous')) || 30
- freq = Math.max(Math.min(60, freq), 1)
- this.drawInterval = setInterval(()=>{
- this.batchDraw()
- }, 1000/freq)
- }
-
- }
-
- onTouch(e, name) {
-
- var event = {...e}
- delete event.firstTarget
-
- event.targetName = event.target ? event.target.getAttribute('name') : ''
- event.targetTagName = event.target ? event.target.tagName : ''
-
- var w = widgetManager.getWidgetByElement(event.target)
- if (w) event.target = w === this ? 'this' : w.getProp('id')
- else event.target = null
-
- event.type = name
-
- this.scripts.onTouch.run({
- value: this.value,
- width: this.width,
- height: this.height,
- event: event,
- }, {sync: true, send: true})
-
- this.batchDraw()
-
- }
-
- setValue(v, options={}) {
-
- if (Array.isArray(v)) {
- if (v.length !== this.valueLength) return
- } else if (this.valueLength > 1) return
-
- this.value = v
-
- this.batchDraw()
-
- if (options.sync) this.changed(options)
- if (options.send) this.sendValue()
- if (options.defaultInit && this.script) this.script.setValue(this.value, {id: this.getProp('id')})
-
- }
-
-
- draw() {
-
- if (!this.getProp('onDraw')) return
-
- if (this.getProp('autoClear') && this.getProp('contextType') === '2d') {
- this.clear()
- this.ctx.beginPath()
- }
-
- this.scripts.onDraw.run({
- value: this.value,
- ctx: this.ctx,
- width: this.width,
- height: this.height,
- cssVars: this.cssVars
- }, {sync: false, send: false})
-
- }
-
- extraResizeHandle(event) {
-
- if (!this.getProp('onResize')) return
-
- this.scripts.onResize.run({
- value: this.value,
- width: this.width,
- height: this.height,
- cssVars: this.cssVars
- }, {sync: true, send: true})
-
- }
-
- onRemove() {
-
- clearInterval(this.drawInterval)
-
- super.onRemove()
-
- }
-
-}
-
-CanvasWidget.dynamicProps = CanvasWidget.prototype.constructor.dynamicProps.concat([
-])
-
-export default CanvasWidget
diff --git a/src/client/widgets/pads/multixy.mjs b/src/client/widgets/pads/multixy.mjs
deleted file mode 100644
index 9ee2b584..00000000
--- a/src/client/widgets/pads/multixy.mjs
+++ /dev/null
@@ -1,433 +0,0 @@
-import Pad from './pad.mjs'
-import Xy from './xy.mjs'
-import {clip} from '../utils.mjs'
-import doubleTap from '../mixins/double_tap.mjs'
-import touchstate from '../mixins/touch_state.mjs'
-import {PXSCALE} from '../../globals.mjs'
-
-
-var xyDefaults = Xy.defaults()._props()
-
-
-class MultiXy extends Pad {
-
- static description() {
-
- return 'Multi-point XY pad.'
-
- }
-
- static defaults() {
-
-
- var defaults = super.defaults().extend({
- style: {
- _separator_xy_style: 'Xy style',
- pointSize: {type: 'integer', value: 20, help: 'Defines the points\' default size (may be in %)'},
- ephemeral: {type: 'boolean', value: false, help: 'When set to `true`, the points will be drawn only while touched.'},
- pips: {type: 'boolean', value: true, help: 'Set to `false` to hide the scale'},
- },
- class_specific: {
- points: {type: 'integer|array', value: 2, help: [
- 'Defines the number of points on the pad',
- 'Can be an array of strings that will be used as labels for the points (ex: `[\'A\', \'B\']`)'
- ]},
- pointsAttr: {type: 'object', value: [], help: [
- 'Defines per-point properties that are otherwise inherited from the multixy. Must be an array of objects (one per point) that may contain the following keys:',
- '- visible (visibility and interactability)',
- '- colorFill (background color)',
- '- colorStroke (outline color)',
- '- colorText (label color)',
- '- color (shorthand for colorFill and colorStroke)',
- '- alphaFillOn (background opacity)',
- '- pointSize',
- '- label',
- '- clipX',
- '- clipY',
- '- axisLock'
- ]},
- snap: {type: 'boolean', value: false, help: [
- 'By default, the points are dragged from their initial position.',
- 'If set to `true`, touching anywhere on the widget\'s surface will make them snap to the touching coordinates',
- ]},
- spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its default value when released'},
- rangeX: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the x axis (see fader)'},
- rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis (see fader)'},
- logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale.'},
- logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale.'},
- stepsX: {type: 'number|array|string', value: false, help: 'Defines `steps` for the x axis (see fader)'},
- stepsY: {type: 'number|array|string', value: false, help: 'Defines `steps` for the x axis (see fader)'},
- axisLock: {type: 'string', value: '', choices: ['', 'x', 'y', 'auto'], help: [
- 'Restrict movements to one of the axes only.',
- 'When left empty, holding `Shift` while dragging will lock the pad according the first movement. `auto` will do the opposite.'
- ]},
- doubleTap: {type: 'boolean|string', value: false, choices: [false, true, 'script'], help: [
- 'Set to `true` to make the knob reset to its `default` value when receiving a double tap.',
- 'Can be an osc address, in which case the widget will just send an osc message with no value (but `preArgs` included).',
- 'If set to "script", `onTouch` will be called with `event.type` set to `doubleTap`. '
- ]},
- sensitivity: {type: 'number', value: 1, help: 'Defines the pad\'s sensitivity when `snap` is `false` '},
- }
- })
-
- defaults.scripting.onTouch = {type: 'script', value: '', editor:'javascript', help: ['Script executed when the widget is touched and released. See documentation .',]}
-
- return defaults
-
- }
-
- constructor(options) {
-
- super(options)
-
- this.npoints = Array.isArray(this.getProp('points')) ? this.getProp('points').length : parseInt(this.getProp('points'))
-
- if (isNaN(this.npoints) || this.npoints < 1) this.npoints = 1
-
- this.preventChildrenTouchState = true
- this.pads = []
-
- for (let i = 0; i < this.npoints; i++) {
- this.pads[i] = new Xy({props:{
- ...xyDefaults,
- snap:this.getProp('snap'),
- spring:this.getProp('spring'),
- ephemeral:this.getProp('ephemeral'),
- default:this.getProp('default').length === this.npoints * 2 ? [this.getProp('default')[i*2], this.getProp('default')[i*2 + 1]] : '',
- rangeX:this.getProp('rangeX'),
- rangeY:this.getProp('rangeY'),
- decimals:this.getProp('decimals'),
- logScaleX:this.getProp('logScaleX'),
- logScaleY:this.getProp('logScaleY'),
- stepsX:this.getProp('stepsX'),
- stepsY:this.getProp('stepsY'),
- axisLock:this.getProp('axisLock'),
- pointSize: 'auto',
- pips: false,
- sensitivity: this.getProp('sensitivity'),
- input:false
- }, parent: this})
- this.pads[i].canvas.classList.add('pad-' + i)
- this.widget.append(this.pads[i].canvas)
-
- }
-
- // tiny hack for pips until there's a proper range refactoring
- this.faders = this.pads[0].faders
-
- this.pointsAttr = []
- this.updatePadsAttr()
-
- this.padsCoords = []
- this.touchMap = {}
-
- this.on('dragend',(e)=>{
-
- var i = this.touchMap[e.pointerId]
-
- if (!i) return
-
- this.pads[i].touched = 0
- this.pads[i].trigger('dragend', e)
-
- this.trigger('touch', {stopPropagation: true, touch: [parseInt(this.touchMap[e.pointerId]), 0]})
-
- delete this.touchMap[e.pointerId]
-
- }, {element: this.widget, multitouch: true})
-
- touchstate(this, {element: this.widget, multitouch: true})
-
- this.on('draginit',(e)=>{
-
- var id
-
- if (!this.touchMap[e.pointerId]) {
-
- id = this.getPadIdFromCoords(e.offsetX, e.offsetY)
-
- this.touchMap[e.pointerId] = id
-
- }
-
- if (!id) return
-
- this.trigger('touch', {stopPropagation: true, touch: [parseInt(id), 1]})
-
- this.pads[id].trigger('draginit', e)
- this.pads[id].touched = 1
-
- }, {element: this.widget, multitouch: true})
-
- this.on('drag',(e)=>{
-
- var i = this.touchMap[e.pointerId]
-
- if (!i) return
-
- e.fingers = 1 // cancel mutlifinger inertia
-
- this.pads[i].trigger('drag', e)
-
- }, {element: this.widget, multitouch: true})
-
- this.on('value-changed',(e)=>{
- if (e.widget == this) return
- e.stopPropagation = true
- if (e.options.spring) e.options.dragged = true
- this.setValue(this.getValue(), e.options)
- })
-
- if (this.getProp('doubleTap')) {
-
- if (typeof this.getProp('doubleTap') === 'string' && this.getProp('doubleTap')[0] === '/') {
-
- doubleTap(this, ()=>{
- this.sendValue({v:null, address: this.getProp('doubleTap')})
- }, {element: this.widget})
-
- } else {
-
- doubleTap(this, (e) => {
- var id, ndiff, diff = Infinity
-
- for (var i in this.pads) {
- ndiff = Math.abs(e.offsetX - this.padsCoords[i][0]) + Math.abs(e.offsetY - (this.padsCoords[i][1] + this.height))
- if (ndiff < diff) {
- id = i
- diff = ndiff
- }
- }
-
- var pad = this.pads[id]
-
- if (this.getProp('doubleTap') == 'script') {
- this.scripts.onTouch.run({
- event: {type: 'doubleTap', handle: id},
- value: this.value
- }, {sync: true, send: true})
- } else {
- pad.setValue([pad.faders.x.getSpringValue(), pad.faders.y.getSpringValue()], { sync: true, send: true, spring: true, doubleTap: true })
- }
-
- }, { element: this.widget})
-
- }
-
- }
-
- var v = []
- for (let i = 0; i < this.npoints * 2; i = i + 2) {
- [v[i],v[i+1]] = this.pads[i/2].getValue()
- }
-
- this.setValue(v)
-
- }
-
- getPadIdFromCoords(x, y) {
-
- var ndiff, diff = -1,
- id
-
- for (var i in this.pads) {
-
- if (Object.values(this.touchMap).indexOf(i) != -1) continue
- if (!this.pads[i].getProp('visible')) continue
-
- ndiff = Math.abs(x - this.padsCoords[i][0]) + Math.abs(y - (this.padsCoords[i][1] + this.height))
-
- if (diff == -1 || ndiff < diff) {
- id = i
- diff = ndiff
- }
-
- }
-
- return id
-
- }
-
- extraResizeHandle(event){
-
- super.extraResizeHandle(event)
-
- for (var k in this.pads) {
- this.pads[k].width = this.width
- this.pads[k].height = this.height
- this.pads[k].padPadding = this.padPadding
- }
-
- this.updateHandlesPosition()
-
-
- }
-
- cacheCanvasStyle(style) {
-
- super.cacheCanvasStyle(style)
- for (var k in this.pads) {
- this.pads[k].cacheCanvasStyle()
- this.pads[k].batchDraw()
- }
- this.batchDraw()
-
- }
-
- setVisibility() {
-
- super.setVisibility()
- for (var k in this.pads) {
- this.pads[k].setVisibility()
- }
- this.batchDraw()
-
- }
-
- updateHandlesPosition() {
-
- for (var i=0;ix.js==n)
- if (cssVar) {
- this.pads[i].canvas.style.setProperty(cssVar.css, this.pointsAttr[i][n] == 'auto' ? '' : this.pointsAttr[i][n])
- }
-
- if (n == 'visible') {
- this.pads[i].canvas.style.setProperty('opacity', this.pointsAttr[i][n] ? 1 : 0)
- }
-
- }
- }
- }
-
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- if (super.onPropChanged(...arguments)) return true
-
- switch (propName) {
-
- case 'padding':
- for (let w of this.pads) {
- w.onPropChanged(propName)
- }
- return
-
- case 'colorText':
- case 'colorWidget':
- case 'colorFill':
- case 'colorStroke':
- case 'alphaStroke':
- case 'alphaFillOff':
- case 'alphaFillOn':
- case 'pointsAttr':
- case 'spring':
- case 'pointSize':
- case 'axisLock':
- this.updatePadsAttr(options)
- return
- }
-
- }
-
- onRemove() {
- for (var i in this.pads) {
- this.pads[i].onRemove()
- }
- super.onRemove()
- }
-
-}
-
-
-MultiXy.dynamicProps = MultiXy.prototype.constructor.dynamicProps.filter(n => n !== 'decimals').concat([
- 'pointsAttr',
-])
-
-export default MultiXy
diff --git a/src/client/widgets/pads/pad.mjs b/src/client/widgets/pads/pad.mjs
deleted file mode 100644
index 68660e64..00000000
--- a/src/client/widgets/pads/pad.mjs
+++ /dev/null
@@ -1,113 +0,0 @@
-import html from 'nanohtml'
-import Canvas from '../common/canvas.mjs'
-import {PXSCALE} from '../../globals.mjs'
-
-class Pad extends Canvas {
-
- constructor(options) {
-
- super({...options, value: [], html: html`
-
-
-
- `})
-
- }
-
- cacheCanvasStyle(style) {
-
- style = style || window.getComputedStyle(this.canvas)
-
- super.cacheCanvasStyle(style)
-
- this.padPadding = (this.cssVars.padding + this.cssVars.lineWidth) + 2 * PXSCALE
- this.pointSize = parseFloat(this.cssVars.pointSize) * (this.cssVars.pointSize.indexOf('%') > -1 ? this.width / 100 : PXSCALE)
-
- }
-
- drawPips() {
-
- var margin = this.padPadding,
- pipTexts = margin >= this.fontSize * 1.5
-
- this.ctx.lineWidth = PXSCALE
- this.ctx.fillStyle = this.cssVars.colorText
- this.ctx.strokeStyle = this.cssVars.colorStroke
- this.ctx.globalAlpha = this.cssVars.alphaPips
- this.ctx.beginPath()
-
- for (let i in this.faders.x.rangeKeys) {
-
- let pip = this.faders.x.rangeKeys[i],
- px = Math.round(0.5 * this.faders.x.percentToCoord(pip)) * 2
-
- if (parseInt(px) === px) px -= 0.5
-
- if (pipTexts) {
- this.ctx.textAlign = 'center'
- let label = this.faders.x.rangeLabels[i]
- this.ctx.fillText(label, px, this.height - margin / 2)
- }
-
- if (pip == 0 || pip == 100) continue
- this.ctx.moveTo(px, margin - PXSCALE)
- this.ctx.lineTo(px, this.height - margin + PXSCALE)
-
-
- }
- for (let i in this.faders.y.rangeKeys) {
-
- let pip = this.faders.y.rangeKeys[i],
- py = Math.round(0.5 * this.faders.y.percentToCoord(pip)) * 2
-
- if (parseInt(py) === py) py -= 0.5
-
- if (pipTexts) {
- this.ctx.textAlign = 'right'
- let label = this.faders.y.rangeLabels[i]
- this.ctx.fillText(label, margin / 2 + this.fontSize / 2, py)
- }
-
- if (pip == 0 || pip == 100) continue
- this.ctx.moveTo(margin - PXSCALE, py)
- this.ctx.lineTo(this.width - margin + PXSCALE, py)
-
-
- }
-
- this.ctx.globalAlpha = this.cssVars.alphaFillOn
- this.ctx.stroke()
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- var ret = super.onPropChanged(...arguments)
-
- switch (propName) {
- case 'pointSize':
- this.setCssVariables()
- return
- }
-
- return ret
-
-
- }
-
-}
-
-Pad.cssVariables = Pad.prototype.constructor.cssVariables.concat(
- {js: 'pointSize', css: '--point-size'},
-)
-
-Pad.dynamicProps = Pad.prototype.constructor.dynamicProps.filter(n => n !== 'decimals').concat([
- 'spring',
- 'axisLock',
- 'pointSize',
- 'label',
- 'clipX',
- 'clipY'
-])
-
-export default Pad
diff --git a/src/client/widgets/pads/rgb.mjs b/src/client/widgets/pads/rgb.mjs
deleted file mode 100644
index 4db285b4..00000000
--- a/src/client/widgets/pads/rgb.mjs
+++ /dev/null
@@ -1,310 +0,0 @@
-import html from 'nanohtml'
-import Widget from '../common/widget.mjs'
-import Xy from './xy.mjs'
-import Fader from '../sliders/fader.mjs'
-import {clip, mapToScale, hsbToRgb, rgbToHsb} from '../utils.mjs'
-import touchstate from '../mixins/touch_state.mjs'
-import {PXSCALE} from '../../globals.mjs'
-
-var faderDefaults = Fader.defaults()._props(),
- xyDefaults = Xy.defaults()._props()
-
-
-export default class Rgb extends Widget {
-
- static description() {
-
- return 'Color picker with optional alpha slider.'
-
- }
-
- static defaults() {
-
- var defaults = super.defaults().extend({
- class_specific: {
- snap: {type: 'boolean', value: false, help: [
- 'By default, the points are dragged from their initial position.',
- 'If set to `true`, touching anywhere on the widget\'s surface will make them snap to the touching coordinates',
- ]},
- spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its default value when released'},
- range: {type: 'object', value: {min: 0, max: 255}, help: 'Defines the widget\'s output scale.'},
- alpha:{type: 'boolean', value: false, help: 'Set to `true` to enable alpha channel'},
- rangeAlpha: {type: 'object', value: {min: 0, max: 1}, help: 'Defines the widget\'s output scale for the alpha channel.'},
- }
- })
-
- defaults.scripting.onTouch = {type: 'script', value: '', editor:'javascript', help: ['Script executed when the widget is touched and released. See documentation .',]}
-
- return defaults
-
- }
-
- constructor(options) {
-
- super({...options, value: [], html: html` `})
-
- this.container.classList.toggle('contains-alpha', this.getProp('alpha'))
-
- this.preventChildrenTouchState = true
-
- this.pad = new Xy({props:{
- ...xyDefaults,
- type: 'xy',
- label: false,
- snap:this.getProp('snap'),
- rangeX:{min:0,max:100},
- rangeY:{min:0,max:100},
- decimals:2,
- pointSize: 10,
- pips: false,
- }, parent: this, meta: {not_editable: true}})
- this.pad.sendValue = ()=>{}
- this.pad.container.classList.add('pad')
- this.widget.appendChild(this.pad.container)
- this.pad.on('value-changed',(e)=>{
- e.stopPropagation = true
- this.dragHandle()
- })
-
- this.hue = new HueFader({props:{
- ...faderDefaults,
- type: 'fader',
- design: 'compact',
- label: false,
- pips:false,
- horizontal:false,
- snap:this.getProp('snap'),
- range:{min:0,max:360},
- decimals:2
- }, parent: this, meta: {not_editable: true}})
- this.hue.container.classList.add('hue')
- this.widget.appendChild(this.hue.container)
- this.hue.on('value-changed',(e)=>{
- e.stopPropagation = true
- this.dragHandle(true)
- })
-
- if (this.getProp('alpha')) {
- this.alpha = new Fader({props:{
- ...faderDefaults,
- type: 'fader',
- design: 'compact',
- label:false,
- pips:false,
- horizontal:true,
- snap:this.getProp('snap'),
- range: this.getProp('rangeAlpha'),
- default: 255,
- input:false,
- decimals:2
- }, parent: this, meta: {not_editable: true}})
- this.alpha.container.classList.add('alpha')
- this.widget.appendChild(this.alpha.container)
- this.alpha.on('value-changed',(e)=>{
- e.stopPropagation = true
- this.dragAlphaHandle()
- })
- }
-
- var initValue = Array.isArray(this.getProp('default')) && this.getProp('default').length >= 3 ? this.getProp('default') : Array(3).fill(this.getProp('range').min)
- if (this.getProp('alpha') && initValue.length < 4) {
- initValue[3] = this.getProp('rangeAlpha').min
- }
-
- if (this.getProp('spring')) {
-
- this.on('dragend', (e)=>{
-
- e.stopPropagation = true
- this.setValue(initValue, {sync:true,send:true})
-
- }, {element: this.widget, ignoreCustomBindings: true})
-
- }
-
- touchstate(this, {element: this.widget, multitouch: true, ignoreCustomBindings: false})
-
- this.hsb = {h:0,s:0,b:0}
-
- this.setValue(initValue)
-
- }
-
- dragHandle(hue) {
- var h = this.hue.value,
- s = this.pad.value[0],
- b = this.pad.value[1]
-
- if (h != this.hsb.h ||s != this.hsb.s || b != this.hsb.b) {
-
- this.hsb.h = this.hue.value
- this.hsb.s = this.pad.value[0]
- this.hsb.b = this.pad.value[1]
-
- this.update({nohue:!hue})
-
- var rgb = hsbToRgb(this.hsb)
- for (var k in rgb) {
- rgb[k] = mapToScale(rgb[k], [0, 255], [this.getProp('range').min, this.getProp('range').max], -1)
- }
-
- if (rgb.r != this.value[0] || rgb.g != this.value[1] || rgb.b != this.value[2]) {
- this.setValue([rgb.r, rgb.g, rgb.b], {
- send: true,
- sync: true,
- dragged: true,
- nohue: !hue
- })
- }
- }
-
- }
-
- dragAlphaHandle() {
-
- var alpha = this.alpha.value
- if (alpha !== this.value[3]) {
- this.setValue([this.value[0], this.value[1], this.value[2], alpha], {
- send: true,
- sync: true,
- dragged: true,
- nohue: true
- })
- }
-
-
- }
-
- setValue(v, options={}) {
-
- if (!v || v.length < 3) return
- if (this.touched && !options.dragged) return this.setValueTouchedQueue = [v, options]
-
- var value = Array(this.getProp('alpha') ? 4 : 3)
-
- for (var i = 0; i < 3; i++) {
- value[i] = clip(v[i], [this.getProp('range').min, this.getProp('range').max])
- }
-
- if (value.length === 4) {
- value[3] = v[3] === undefined ? this.alpha.value : clip(v[3], [this.getProp('rangeAlpha').min, this.getProp('rangeAlpha').max])
- }
-
- var hsb = rgbToHsb({
- r: mapToScale(value[0], [this.getProp('range').min, this.getProp('range').max], [0, 255], -1),
- g: mapToScale(value[1], [this.getProp('range').min, this.getProp('range').max], [0, 255], -1),
- b: mapToScale(value[2], [this.getProp('range').min, this.getProp('range').max], [0, 255], -1)
- })
-
- if (!options.dragged) {
- this.pad.setValue([hsb.s, hsb.b])
- if (value.length === 4) this.alpha.setValue(value[3])
- }
-
- this.hsb = hsb
- this.value = value
-
-
- if (options.send) this.sendValue()
- if (options.sync) this.changed(options)
-
- this.update({dragged:options.dragged, nohue:options.nohue || (v[0]==v[1]&&v[1]==v[2])})
-
- }
-
- update(options={}) {
-
- if (!options.nohue && !options.dragged) {
- var hue = hsbToRgb({h:this.hsb.h,s:100,b:100}),
- hueStr = `rgb(${Math.round(hue.r)},${Math.round(hue.g)},${Math.round(hue.b)})`
- this.pad.container.style.setProperty('background-color', hueStr)
- this.hue.setValue(this.hsb.h, {sync: false, send:false, dragged:false})
- }
-
- }
-
-
- onPropChanged(propName, options, oldPropValue) {
-
- if (super.onPropChanged(...arguments)) return true
-
- switch (propName) {
-
- case 'colorText':
- case 'colorWidget':
- case 'colorFill':
- case 'colorStroke':
- case 'alphaStroke':
- case 'alphaFillOff':
- case 'alphaFillOn':
- for (var w of [this.hue, this.pad]) {
- w.onPropChanged(propName)
- }
- if (this.alpha) this.alpha.onPropChanged(propName)
- return
-
- }
-
- }
-
- setVisibility() {
-
- super.setVisibility()
-
- for (var w of [this.hue, this.pad]) {
- if (w) w.setVisibility()
- }
- if (this.alpha) this.alpha.setVisibility()
-
- }
-
- onRemove() {
- this.hue.onRemove()
- this.pad.onRemove()
- if (this.alpha) this.alpha.onRemove()
- super.onRemove()
- }
-
-}
-
-class HueFader extends Fader {
-
- draw() {
-
- var width = this.getProp('horizontal') ? this.height : this.width,
- height = !this.getProp('horizontal') ? this.height : this.width
-
- var percent = this.getProp('steps') ? this.valueToPercent(this.value) : this.percent,
- d = Math.round(this.percentToCoord(percent)),
- m = this.getProp('horizontal') ? this.height / 2 : this.width / 2,
- flat = this.getProp('mode') === 'flat'
-
- // sharp border trick
- if (width % 2 && parseInt(m) === m) m -= 0.5
-
- this.clear()
-
-
- this.ctx.strokeStyle = this.gaugeGradient || this.cssVars.colorFill
-
- if (flat) {
- this.ctx.lineWidth = Math.round(width - this.gaugePadding * 2)
- } else {
- this.ctx.lineWidth = 2 * PXSCALE
- }
-
-
- // flat knob
-
- this.ctx.globalAlpha = 1
- this.ctx.fillStyle = this.cssVars.colorFill
-
- this.ctx.beginPath()
- this.ctx.rect(this.gaugePadding, Math.min(d, height - 2 * PXSCALE), width - this.gaugePadding * 2, 2 * PXSCALE)
- this.ctx.fill()
-
- this.clearRect = [0, 0, width, height]
-
- }
-
-}
diff --git a/src/client/widgets/pads/xy.mjs b/src/client/widgets/pads/xy.mjs
deleted file mode 100644
index fdde2ccc..00000000
--- a/src/client/widgets/pads/xy.mjs
+++ /dev/null
@@ -1,329 +0,0 @@
-import Pad from './pad.mjs'
-import Fader from '../sliders/fader.mjs'
-import doubleTap from '../mixins/double_tap.mjs'
-import touchstate from '../mixins/touch_state.mjs'
-import {PXSCALE} from '../../globals.mjs'
-
-var faderDefaults = Fader.defaults()._props()
-
-export default class Xy extends Pad {
-
- static description() {
-
- return 'Two-dimensional slider.'
-
- }
-
- static defaults() {
-
- var defaults = super.defaults().extend({
- style: {
- _separator_xy_style: 'Xy style',
- pointSize: {type: 'integer', value: 20, help: 'Defines the points\' size (may be in %)'},
- ephemeral: {type: 'boolean', value: false, help: 'When set to `true`, the point will be drawn only while touched.'},
- pips: {type: 'boolean', value: true, help: 'Set to `false` to hide the scale'},
- label: {type: 'string', value: '', help: 'Text displayed in the handle'}
- },
- class_specific: {
- snap: {type: 'boolean', value: false, help: [
- 'By default, the points are dragged from their initial position.',
- 'If set to `true`, touching anywhere on the widget\'s surface will make them snap to the touching coordinates',
- ]},
- spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its default value when released'},
- rangeX: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the x axis (see fader)'},
- rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis (see fader)'},
- logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale.'},
- logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale.'},
- stepsX: {type: 'number|array|string', value: false, help: 'Defines `steps` for the x axis (see fader)'},
- stepsY: {type: 'number|array|string', value: false, help: 'Defines `steps` for the x axis (see fader)'},
- clipX: {type: 'object', value: '', help: 'Min and max boundaries for the x axis'},
- clipY: {type: 'object', value: '', help: 'Min and max boundaries for the y axis'},
- axisLock: {type: 'string', value: '', choices: ['', 'x', 'y', 'auto'], help: [
- 'Restrict movements to one of the axes only unless `Shift` is held.',
- 'When left empty, holding `Shift` while dragging will lock the pad according the first movement. `auto` will do the opposite.'
- ]},
- doubleTap: {type: 'boolean|string', value: false, choices: [false, true, 'script'], help: [
- 'Set to `true` to make the knob reset to its `default` value when receiving a double tap.',
- 'Can be an osc address, in which case the widget will just send an osc message with no value (but `preArgs` included).',
- 'If set to "script", `onTouch` will be called with `event.type` set to `doubleTap`. '
- ]},
- sensitivity: {type: 'number', value: 1, help: 'Defines the pad\'s sensitivity when `snap` is `false` '},
- }
- })
-
- defaults.scripting.onTouch = {type: 'script', value: '', editor:'javascript', help: ['Script executed when the widget is touched and released. See documentation .',]}
-
- return defaults
-
- }
-
- constructor(options) {
-
- super(options)
-
- this.preventChildrenTouchState = true
-
- this.faders = {
- x: new Fader({props:{
- ...faderDefaults,
- id:0,
- visible:false,
- horizontal:true,
- default:this.getProp('default').length === 2 ? this.getProp('default')[0] : '',
- snap:this.getProp('snap'),
- range:this.getProp('rangeX'),
- decimals:this.getProp('decimals'),
- logScale:this.getProp('logScaleX'),
- sensitivity: this.getProp('sensitivity'),
- steps: this.getProp('stepsX'),
- }, parent: this}),
- y: new Fader({props:{
- ...faderDefaults,
- id:1,
- visible:false,
- horizontal:false,
- default:this.getProp('default').length === 2 ? this.getProp('default')[1] : '',
- snap:this.getProp('snap'),
- range:this.getProp('rangeY'),
- decimals:this.getProp('decimals'),
- logScale:this.getProp('logScaleY'),
- sensitivity: this.getProp('sensitivity'),
- steps: this.getProp('stepsY'),
- }, parent: this}),
- }
-
- this.on('value-changed',(e)=>{
- if (e.widget == this) return
- e.stopPropagation = true
- })
-
- touchstate(this, {element: this.canvas})
-
- this.active = false
-
- this.autoAxisLock = ''
-
- this.on('draginit',(e)=>{
- this.active = true
- this.autoAxisLock = ''
- var axis = this.getProp('axisLock')
- if (axis !== '' && e.shiftKey) axis = ''
- if (axis !== 'y') this.faders.x.trigger('draginit', {...e, stopPropagation: true})
- if (axis !== 'x') this.faders.y.trigger('draginit', {...e, stopPropagation: true})
- this.dragHandle()
- }, {element: this.canvas})
-
- this.on('drag',(e)=>{
- var axis = this.getProp('axisLock')
- if (axis !== '' && e.shiftKey) axis = ''
- else if (e.shiftKey && axis === '' || !e.shiftKey && axis === 'auto') {
- if (this.autoAxisLock === '') {
- if (Math.abs(e.movementX) > Math.abs(e.movementY)) {
- this.autoAxisLock = 'x'
- } else if (Math.abs(e.movementY) > Math.abs(e.movementX)) {
- this.autoAxisLock = 'y'
- }
- }
- axis = this.autoAxisLock
- }
- if (axis !== 'y') this.faders.x.trigger('drag', e)
- if (axis !== 'x') this.faders.y.trigger('drag', e)
- this.dragHandle()
- }, {element: this.canvas})
-
- this.on('dragend', (e)=>{
- this.active = false
- var axis = this.getProp('axisLock')
- if (axis !== '' && e.shiftKey) axis = ''
- if (axis !== 'y') this.faders.x.trigger('dragend', {...e, stopPropagation: true})
- if (axis !== 'x') this.faders.y.trigger('dragend', {...e, stopPropagation: true})
- if (this.getProp('spring')) {
- this.setValue([this.faders.x.getSpringValue(),this.faders.y.getSpringValue()],{sync:true, send:true, spring:true})
- } else {
- if (this.getProp('clipX')) this.faders.x.setValue(this.value[0])
- if (this.getProp('clipY')) this.faders.y.setValue(this.value[1])
- this.batchDraw()
- }
- }, {element: this.canvas})
-
- if (this.getProp('doubleTap')) {
-
- if (typeof this.getProp('doubleTap') === 'string' && this.getProp('doubleTap')[0] === '/') {
-
- doubleTap(this, ()=>{
- this.sendValue({v:null, address: this.getProp('doubleTap')})
- }, {element: this.widget})
-
- } else if (this.getProp('doubleTap') == 'script') {
-
- doubleTap(this, ()=>{
- this.scripts.onTouch.run({
- event: {type: 'doubleTap'},
- value: this.value
- }, {sync: true, send: true})
- }, {element: this.widget})
-
-
- } else {
-
- doubleTap(this, ()=>{
- this.setValue([this.faders.x.getSpringValue(),this.faders.y.getSpringValue()],{sync:true, send:true, spring:true, doubleTap:true})
- }, {element: this.widget})
-
- }
-
- }
-
- this.setValue([0,0])
-
- }
-
- dragHandle(){
-
- var x = this.faders.x.value,
- y = this.faders.y.value
-
-
- if (x != this.value[0] || y != this.value[1]) {
- this.setValue([x, y],{send:true,sync:true,dragged:true})
- } else {
- this.batchDraw()
- }
-
- }
-
- extraResizeHandle(event){
-
- super.extraResizeHandle(event)
-
- for (var k in this.faders) {
- this.faders[k].width = this.width
- this.faders[k].height = this.height
- this.faders[k].gaugePadding = this.padPadding
- }
-
- }
-
-
- setValue(v, options={}) {
-
- if (!v || !v.length || v.length!=2) return
- if (this.touched && !options.dragged && !options.doubleTap) return this.setValueTouchedQueue = [v, options]
-
- if (!options.dragged) {
- this.clipValue(v)
- this.faders.x.setValue(v[0], {sync: false, send:false, dragged:false, doubleTap: options.doubleTap})
- this.faders.y.setValue(v[1], {sync: false, send:false, dragged:false, doubleTap: options.doubleTap})
- }
-
- this.value = [
- this.faders.x.value,
- this.faders.y.value
- ]
-
- this.clipValue(this.value)
-
- if (options.send) this.sendValue()
- if (options.sync) this.changed(options)
-
- this.batchDraw()
-
- }
-
- clipValue(v) {
-
- if (this.getProp('clipX')) {
- if (this.getProp('clipX').min !== undefined) v[0] = Math.max(this.getProp('clipX').min, v[0])
- if (this.getProp('clipX').max !== undefined) v[0] = Math.min(this.getProp('clipX').max, v[0])
- }
- if (this.getProp('clipY')) {
- if (this.getProp('clipY').min !== undefined) v[1] = Math.max(this.getProp('clipY').min, v[1])
- if (this.getProp('clipY').max !== undefined) v[1] = Math.min(this.getProp('clipY').max, v[1])
- }
-
- }
-
- draw() {
-
- if (!this.visible) return
-
- var pointSize = this.pointSize,
- x = this.faders.x.percentToCoord(this.faders.x.valueToPercent(this.value[0])),
- y = this.faders.y.percentToCoord(this.faders.y.valueToPercent(this.value[1])),
- ephemeral = this.getProp('ephemeral')
-
- this.clear()
-
- if (!ephemeral || this.active) {
- this.ctx.fillStyle = this.cssVars.colorFill
- this.ctx.globalAlpha = this.cssVars.alphaFillOn
- this.ctx.beginPath()
- this.ctx.arc(x, y, pointSize - 3 * PXSCALE, Math.PI * 2, false)
- this.ctx.fill()
- }
-
-
-
- if (this.getProp('pips')) this.drawPips()
- else {
- this.clearRect = [[x - pointSize - 2 * PXSCALE, y - pointSize - 2 * PXSCALE, (pointSize + 2 * PXSCALE) * 2, (pointSize + 2 * PXSCALE) * 2]]
- }
-
- if (!ephemeral || this.active) {
- this.ctx.strokeStyle = this.cssVars.colorStroke
- this.ctx.globalAlpha = this.active ? 1 : 0.75
- this.ctx.lineWidth = 1.5 * PXSCALE
- this.ctx.beginPath()
- this.ctx.arc(x, y, pointSize, Math.PI * 2, false)
- this.ctx.stroke()
-
- var t = this.getProp('label')
- if (t) {
- this.ctx.fillStyle = this.cssVars.colorText
- this.ctx.globalAlpha = 1
- this.ctx.textAlign = 'center'
- this.ctx.fillText(t, x + 0.5 * PXSCALE, y + PXSCALE)
-
- if (!this.getProp('pips')) {
- var length = this.fontSize * t.length
- this.clearRect.push([x - length / 2, y - this.fontSize / 2, length, this.fontSize + 2 * PXSCALE])
- }
-
- }
- }
-
-
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- if (super.onPropChanged(...arguments)) return true
-
- switch (propName) {
-
- case 'label':
- this.batchDraw()
- return
- case 'spring':
- if (this.getProp('spring') && !this.touched) {
- var x = this.faders.x.getSpringValue(),
- y = this.faders.y.getSpringValue()
- if (x !== this.value[0] || y !== this.value[1]) this.setValue([x, y], {...options})
- }
- return
-
- }
-
- }
-
-
- onRemove() {
-
- this.faders.x.onRemove()
- this.faders.y.onRemove()
- super.onRemove()
-
- }
-
-}
diff --git a/src/client/widgets/scripts/script-vm.mjs b/src/client/widgets/scripts/script-vm.mjs
deleted file mode 100644
index e5312e32..00000000
--- a/src/client/widgets/scripts/script-vm.mjs
+++ /dev/null
@@ -1,686 +0,0 @@
-import widgetManager from '../../managers/widgets.mjs'
-import stateManager from '../../managers/state.mjs'
-import cache from '../../managers/cache.mjs'
-import {deepCopy} from '../../utils.mjs'
-import {urlParser} from '../utils.mjs'
-import Vm from '../vm.mjs'
-import ipc from '../../ipc/index.mjs'
-import uiFilebrowser from '../../ui/ui-filebrowser.mjs'
-import uiFileUpload from '../../ui/ui-fileupload.mjs'
-import {setFOCUSABLE} from '../../globals.mjs'
-
-var toolbar
-setTimeout(async()=>{
- // use setTimeout to fix init order in safari...
- toolbar = (await import('../../ui/main-menu.mjs')).default
-})
-
-class ScriptVm extends Vm {
-
- constructor() {
-
- super()
-
- this.valueOptions = []
-
- }
-
- getValueOptions() {
-
- return this.valueOptions[this.valueOptions.length - 1] || {send: true, sync: true}
-
- }
-
- setValueOptions(options) {
-
- if (!options) this.valueOptions.pop()
- else this.valueOptions.push(options)
-
- }
-
- resolveId(id) {
-
- var widget = this.getWidget()
-
- if (id === 'this') return [widget]
- else if (id === 'parent' && widget.parent !== widgetManager) return [widget.parent]
- else return widgetManager.getWidgetById(id, widget.scopes)
-
- }
-
- checkContext(name) {
- if (this.widget.length === 0) throw name + '() cannot be called from outside the script property'
- }
-
- registerGlobals() {
-
- this.globals.set = (id, value, extraOptions = {send: true, sync: true})=>{
-
- this.checkContext('set')
-
- var widget = this.getWidget()
- var options = {},
- valueOptions = this.getValueOptions()
-
- for (var k in valueOptions) {
- if (k === 'widget') options[k] = valueOptions[k]
- else options[k] = deepCopy(valueOptions[k])
- }
-
- options.fromScript = widget.hash
-
- if (options.dragged) options.dragged = false
- if (options.local) options.local = false
-
- // if (id === options.id) options.sync = false // loop stop
- // if (this.getWidget() === options.widget) options.sync = false // loop stop
-
- if (extraOptions.send === false) options.send = false
- if (extraOptions.sync === false) options.sync = false
- if (extraOptions.script === false) options.script = false
- if (extraOptions.external === true) {
- options.fromExternal = true
- options.send = false
- }
-
- var widgets
- if (id.includes('*')) {
- widgets = this.resolveId(
- Object.keys(widgetManager.idRoute).filter(key => key.match(new RegExp('^' + id.replace(/\*/g, '.*') + '$')))
- ).filter(w => w !== widget)
- } else {
- widgets = this.resolveId(id).slice(0, 1)
- }
-
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- widgets[i].setValue(value, options)
-
- }
-
- }
-
- this.globals.setVar = (id, name, value)=>{
-
- this.checkContext('setVar')
-
- var widgets
- if (id.includes('*')) {
- var widget = this.getWidget()
- widgets = this.resolveId(
- Object.keys(widgetManager.idRoute).filter(key => key.match(new RegExp('^' + id.replace(/\*/g, '.*') + '$')))
- ).filter(w => w !== widget)
- } else {
- widgets = this.resolveId(id)
- }
-
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
-
- if (widgets[i].variables[name]) {
-
- widgets[i].variables[name].value = value
- widgets[i].variables[name].updated = 1
- widgets[i].updateProps(widgets[i].variables[name].propNames)
- widgets[i].variables[name].updated = 0
-
- } else {
-
- widgets[i].variables[name] = {value: value, propNames: []}
-
- }
-
- }
-
- }
-
- this.globals.send = (target, address, ...args)=>{
-
- this.checkContext('send')
-
- var options = this.getValueOptions()
-
- if (!options.send) return
-
- if (target && target[0] === '/') {
- args.unshift(address)
- address = target
- target = null
- }
-
- var overrides = {
- address,
- v: args,
- preArgs: []
- }
-
- if (target) overrides.target = Array.isArray(target) ? target : [target]
-
- var widget = this.getWidget()
-
- widget.sendValue(overrides, {force: true})
-
- }
-
- this.globals.get = (id)=>{
-
- this.checkContext('get')
-
- var widgets = this.resolveId(id)
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- if (widgets[i].getValue) {
-
- var v = widgets[i].getValue()
- if (v !== undefined) return v
-
- }
-
- }
-
- }
-
- this.globals.getVar = (id, name)=>{
-
- this.checkContext('getVar')
-
- var widgets = this.resolveId(id)
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- if (widgets[i].variables[name]) return deepCopy(widgets[i].variables[name].value)
-
- }
-
- }
-
- this.globals.getProp = (id, prop)=>{
-
- this.checkContext('getProp')
-
- var widgets = this.resolveId(id)
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- var v = widgets[i].getProp(prop)
- if (v !== undefined) return deepCopy(v)
-
- }
-
- }
-
- this.globals.updateProp = (id, prop)=>{
-
- this.checkContext('updateProp')
-
- var widgets = this.resolveId(id),
- widget = this.getWidget()
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- widgets[i].updateProps(Array.isArray(prop) ? prop : [prop], widget)
-
- }
-
- }
-
- this.globals.updateCanvas = (id)=>{
-
- this.checkContext('updateCanvas')
-
- var widgets = this.resolveId(id)
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- if (widgets[i].batchDraw) widgets[i].batchDraw()
-
- }
-
- }
-
- this.globals.getIndex = (id = 'this')=>{
-
- this.checkContext('getIndex')
-
- var widget = this.resolveId(id).pop()
- if (widget) return widget.parent.children.indexOf(widget)
-
- }
-
- this.globals.getScroll = (id)=>{
-
- this.checkContext('getScroll')
-
- var widgets = this.resolveId(id)
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- if (widgets[i].getProp('scroll')) return widgets[i].getScroll()
-
- }
-
- return []
-
- }
-
- this.globals.setScroll = (id, x, y)=>{
-
- this.checkContext('setScroll')
-
- var widgets = this.resolveId(id)
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- if (widgets[i].getProp('scroll')) widgets[i].setScroll(x, y, true, false)
-
- }
-
- }
-
- this.globals.scrollIntoView = (id, options)=>{
-
- this.checkContext('setScroll')
-
- var widgets = this.resolveId(id)
-
- for (var i = widgets.length - 1; i >= 0; i--) {
-
- if (widgets[i].container && widgets[i].isVisible()) {
- widgets[i].container.scrollIntoView(options)
- }
-
- }
-
- }
-
-
-
- this.globals.httpGet = (url, callback)=>{
-
- this.checkContext('httpGet')
-
- var parser = urlParser(url),
- err = (e)=>{console.error(e)}
-
- if (!parser.isLocal()) return err('httpGet error (' + url + '): non-local url')
-
- var xhr = new XMLHttpRequest()
- xhr.open('GET', url, true)
- xhr.onload = (e)=>{
- if (xhr.readyState === 4 && xhr.status === 200 && callback) {
- callback(xhr.responseText)
- }
- }
- xhr.onerror = (e)=>err(`httpGet error (${url}): ${xhr.status} ${xhr.statusText}`)
- xhr.send(null)
-
- }
-
- this.globals.stateGet = (filter)=>{
-
- this.checkContext('stateGet')
-
- if (filter) {
-
- filter = Array.isArray(filter) ? filter : [filter]
-
- var containers = filter.map(x=>this.resolveId(x)).reduce((a,b)=>a.concat(b), [])
-
- if (!containers.length) return
- filter = (widget)=>{
- return containers.some(x=>x.contains(widget) || x === widget)
- }
- }
-
- return deepCopy(stateManager.get(filter))
-
- }
-
- this.globals.stateSet = (state, extraOptions = {})=>{
-
- this.checkContext('stateSet')
-
- var options = this.getValueOptions()
- stateManager.set(state, extraOptions.send === false ? false : options.send)
-
- }
-
-
- this.globals.storage = {
-
- setItem: (k, v)=>{
- this.checkContext('storage.setItem')
- cache.set('script.' + k, v)
- },
- getItem: (k)=>{
- this.checkContext('storage.getItem')
- return cache.get('script.' + k)
- },
- removeItem: (k)=>{
- this.checkContext('storage.removeItem')
- cache.remove('script.' + k)
- },
- clear: ()=>{
- this.checkContext('storage.clear')
- cache.clear('script.')
- }
-
- }
-
- this.globals.setTimeout = (id, callback, timeout)=>{
-
- this.checkContext('setTimeout')
-
- if (typeof id === 'function') {
- timeout = callback
- callback = id
- id = undefined
- }
-
- var widget = this.getWidget(),
- options = this.getValueOptions()
-
-
- if (widget.timeouts[id] !== undefined) {
- clearTimeout(widget.timeouts[id])
- delete widget.timeouts[id]
- }
- widget.timeouts[id] = setTimeout(()=>{
- this.setWidget(widget)
- this.setValueOptions(options)
- try {
- callback()
- } catch(e) {
- widget.errorProp('script', 'setTimeout', e)
- }
- this.setWidget()
- this.setValueOptions()
- }, timeout)
-
- return id
-
- }
-
- this.globals.clearTimeout = (id)=>{
-
- this.checkContext('clearTimeout')
-
- var widget = this.getWidget()
-
- clearTimeout(widget.timeouts[id])
- delete widget.timeouts[id]
-
- }
-
- this.globals.setInterval = (id, callback, timeout)=>{
-
- this.checkContext('setInterval')
-
- if (typeof id === 'function') {
- timeout = callback
- callback = id
- id = undefined
- }
-
- var widget = this.getWidget(),
- options = this.getValueOptions()
-
-
- if (widget.intervals[id] !== undefined) clearTimeout(widget.intervals[id])
- delete widget.intervals[id]
-
- widget.intervals[id] = setInterval(()=>{
- this.setWidget(widget)
- this.setValueOptions(options)
- try {
- callback()
- } catch(e) {
- widget.errorProp('script', 'setInterval', e)
- }
- this.setWidget()
- this.setValueOptions()
- }, timeout)
-
- return id
-
- }
-
- this.globals.clearInterval = (id)=>{
-
- this.checkContext('clearInterval')
-
- var widget = this.getWidget()
-
- clearInterval(widget.intervals[id])
- delete widget.intervals[id]
-
- }
-
-
- this.globals.setFocus = (id)=>{
-
- this.checkContext('setFocus')
-
- if (id) {
- var widgets = this.resolveId(id)
-
- if (widgets.length) {
- if (widgets[0].focus) widgets[0].focus()
- }
- } else if (document.activeElement) {
- document.activeElement.blur()
- }
-
- // built-in client only: electron will call window.focus()
- console.debug('ELECTRON.FOCUS()')
-
- }
-
- this.globals.unfocus = ()=>{
-
- this.checkContext('unfocus')
-
- window.blur()
- // built-in client only: electron will call window.blur()
- console.debug('ELECTRON.BLUR()')
-
- }
-
- this.globals.setFocusable = (focusable)=>{
-
- this.checkContext('setFocusable')
- setFOCUSABLE(!!focusable)
- console.debug('ELECTRON.SETFOCUSABLE('+(focusable ? 1 : 0)+')')
-
- }
-
-
- function getToolbarActionById(id, entries) {
- for (var a of entries) {
- if (a.id == id) {
- return a
- }
- if (Array.isArray(a.action)) {
- var ret = getToolbarActionById(id, a.action)
- if (ret) return ret
- }
- }
- }
-
- this.globals.toolbar = (...args)=>{
-
- this.checkContext('toolbar')
-
- var options = this.getValueOptions()
-
- if (!options.send) return
-
- var action = toolbar.entries.filter(x=>!x.separator)
-
- if (typeof args[0] == 'string') {
-
- action = getToolbarActionById(args[0], action)
- if (action) action = action.action // get callback
- if (action && typeof action.class == 'function') {
- if (action.class().match(/disabled/)) action = null
- }
-
- } else {
-
- for (var i of args) {
- if (action[i]) action = action[i].action
- if (!Array.isArray(action)) break
- action = action.filter(x=>!x.separator)
- }
-
- }
-
- if (typeof action === 'function') action()
-
- }
-
- this.globals.getToolbar = (id)=>{
-
- this.checkContext('toolbar')
-
- var options = this.getValueOptions()
-
- if (!options.send) return
-
- var action = getToolbarActionById(id, toolbar.entries.filter(x=>!x.separator))
-
- if (action && typeof action.class == 'function') return action.class().split(' ').includes('on')
-
- }
-
- this.globals.openUrl = (url)=>{
-
- this.checkContext('openUrl')
-
- var options = this.getValueOptions()
-
- if (options.send) window.open(url, '_blank')
-
- }
-
- this.globals.runAs = (id, callback)=>{
-
- this.checkContext('runAs')
-
- var widgets = this.resolveId(id),
- widget = this.getWidget()
-
- if (widgets.length) {
-
- this.setWidget(widgets[0])
- try {
- callback()
- } catch(e) {
- widget.errorProp('script', 'runAs', e)
- }
- this.setWidget()
-
- }
-
- }
-
- this.globals.reload = (keepState = true)=>{
-
- this.checkContext('reload')
-
- var options = this.getValueOptions(),
- widget = this.getWidget()
-
- if (options.onCreate) {
- widget.errorProp('onCreate', '', 'reload() cannot be called from onCreate')
- } else if (options.send){
- if (keepState) ipc.trigger('reload')
- else window.location.href = window.location.href
- }
-
-
- }
-
- this.globals.Image = Image
-
- this.globals.getNavigator = ()=>{
- this.checkContext('getNavigator')
- return navigator
-
- }
-
-
- this.globals.browseFile = (options, callback)=>{
- this.checkContext('browseFile')
- if (typeof options === 'function') {
- callback = options
- options = {}
- }
-
-
- if (typeof callback === 'function') {
-
- var widget = this.getWidget(),
- valueOptions = this.getValueOptions()
-
- uiFilebrowser({
- extension: options.extention || '*',
- directory: options.directory || undefined,
- loadDir: !!options.allowDir,
- save: options.mode === 'save'
- }, (path)=>{
- this.setWidget(widget)
- this.setValueOptions(valueOptions)
- try {
- callback(path.join(path[0][0] === '/' ? '/' : '\\'))
- } catch(e) {
- widget.errorProp('script', 'browseFile', e)
- }
- this.setWidget()
- this.setValueOptions()
- })
- } else {
- widget.errorProp('script', 'browseFile', 'callback argument must be a function')
- }
- }
-
- this.globals.uploadFile = (options, callback)=>{
- this.checkContext('uploadFile')
- if (typeof options === 'function') {
- callback = options
- options = {}
- }
-
-
- if (typeof callback === 'function') {
-
- var widget = this.getWidget(),
- valueOptions = this.getValueOptions()
-
- uiFileUpload(options.types, (path, content)=>{
- this.setWidget(widget)
- this.setValueOptions(valueOptions)
- try {
- callback(content)
- } catch(e) {
- widget.errorProp('script', 'uploadFile', e)
- }
- this.setWidget()
- this.setValueOptions()
- }, (e)=>{
- widget.errorProp('script', 'uploadFile', e)
- })
- } else {
- widget.errorProp('script', 'browseFile', 'callback argument must be a function')
- }
- }
-
- super.registerGlobals()
-
- }
-
-}
-
-export default new ScriptVm()
diff --git a/src/client/widgets/scripts/script-widget.mjs b/src/client/widgets/scripts/script-widget.mjs
deleted file mode 100644
index 0db37429..00000000
--- a/src/client/widgets/scripts/script-widget.mjs
+++ /dev/null
@@ -1,127 +0,0 @@
-import Widget from '../common/widget.mjs'
-import keyboardJS from 'keyboardjs/dist/keyboard.min.js'
-import Script from './script.mjs'
-
-class ScriptWidget extends Widget {
-
- static description() {
-
- return 'Scripting widget utility with keyboard bindings.mjs'
-
- }
-
- static defaults() {
-
- var defaults = super.defaults()
- delete defaults.widget.visible
- delete defaults.widget.interaction
- delete defaults.geometry
- delete defaults.style
- defaults.scripting = {
- onCreate: {type: 'script', value: '', editor: 'javascript', help: ['Script executed when the widget is created. See documentation .']},
- onValue: {type: 'script', value: '', editor: 'javascript', help: ['Script executed when the widget\'s value updates. See documentation .']},
- onKeyboard: {type: 'script', value: '', editor:'javascript', help: 'Script executed whenever the widget receives a keyboard event if `keyBinding` is set). See documentation .'},
-
- _separator: 'Keyboard events',
-
- keyBinding: {type: 'string|array', value: '', help: [
- 'Key combo `string` or `array` of strings (see KeyboardJS documentation).',
- 'If the editor is enabled, some keys / combos will not work.',
- 'To process all keystroke events, write `[\'\']`'
- ]},
- keyRepeat: {type: 'boolean', value: true, help: 'Set to `false` to prevent keydown repeats when holding the key combo pressed'},
- keyType: {type: 'string', value: 'keydown', choices: ['keydown', 'keyup', 'both'], help: 'Determines which key event trigger the script\'s execution'},
-
- }
- return defaults
-
- }
-
- constructor(options) {
-
- super({...options, html: null})
-
- this.noValueState = true
-
-
- if (this.getProp('onKeyboard') && this.getProp('keyBinding')) {
-
- this.keyCb = this.keyboardCallback.bind(this)
-
- keyboardJS.withContext('global', ()=>{
-
- keyboardJS.bind(this.getProp('keyBinding'), this.keyCb, this.keyCb)
-
- })
-
- this.scripts.onKeyboard = new Script({
- widget: this,
- property: 'onKeyboard',
- code: this.getProp('onKeyboard'),
- context: {
- type: '',
- key: '',
- code: 0,
- ctrl: false,
- shift: false,
- alt: false,
- meta: false,
- }
- })
-
- }
-
- }
-
- setValue(v, options={}) {
-
- this.value = v
-
- if (options.sync) this.changed(options)
-
- }
-
- keyboardCallback(e) {
-
- if (e.catchedByEditor) return
-
- if (e.target && (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' || e.target.tagName === 'SELECT')) return
-
- if (this.getProp('keyType') !== 'both' && e.type !== this.getProp('keyType')) return
-
- if (e.type === 'keydown' && !this.getProp('keyRepeat')) e.preventRepeat()
-
- if (e.preventDefault) e.preventDefault()
-
- this.scripts.onKeyboard.run({
- type: e.type,
- key: e.key,
- code: e.code,
- ctrl: e.ctrlKey,
- shift: e.shiftKey,
- alt: e.altKey,
- meta: e.metaKey
- }, {send: true, sync: true})
-
- }
-
- onRemove() {
-
-
- if (this.getProp('onKeyboard') && this.getProp('keyBinding')) {
-
- keyboardJS.withContext('global', ()=>{
-
- keyboardJS.unbind(this.getProp('keyBinding'), this.keyCb, this.keyCb)
-
- })
-
- }
-
- super.onRemove()
-
- }
-
-}
-
-export default ScriptWidget
diff --git a/src/client/widgets/scripts/script.mjs b/src/client/widgets/scripts/script.mjs
deleted file mode 100644
index a43d9532..00000000
--- a/src/client/widgets/scripts/script.mjs
+++ /dev/null
@@ -1,69 +0,0 @@
-import scriptVm from './script-vm.mjs'
-
-var noop = ()=>{}
-
-class Script {
-
- constructor(options) {
-
- this.lock = false
- this.timeouts = {}
- this.intervals = {}
- this.widget = options.widget
- this.property = options.property
-
- if (!options.code) {
-
- this.script = noop
-
- } else {
-
- try {
- this.script = scriptVm.compile(options.code, options.context)
- } catch(err) {
- this.widget.errorProp(this.property, 'javascript', err)
- this.script = noop
- }
-
- }
-
- }
-
- run(context, options) {
-
- if (this.lock) return
-
- scriptVm.setValueOptions(options)
- scriptVm.setWidget(this.widget)
-
- this.lock = true
- var returnValue
- try {
- returnValue = this.script(context, this.widget.parsersLocalScope)
- } catch(err) {
- this.widget.errorProp(this.property, 'javascript', err)
- }
- this.lock = false
-
- scriptVm.setWidget()
- scriptVm.setValueOptions()
-
- return returnValue
-
- }
-
- onRemove() {
-
- for (let k in this.widget.timeouts) {
- clearTimeout(this.widget.timeouts[k])
- }
-
- for (let k in this.widget.intervals) {
- clearInterval(this.widget.intervals[k])
- }
-
- }
-
-}
-
-export default Script
diff --git a/src/client/widgets/scripts/variable.mjs b/src/client/widgets/scripts/variable.mjs
deleted file mode 100644
index 5bc448b4..00000000
--- a/src/client/widgets/scripts/variable.mjs
+++ /dev/null
@@ -1,41 +0,0 @@
-import Widget from '../common/widget.mjs'
-import StaticProperties from '../mixins/static_properties.mjs'
-
-export default class Variable extends StaticProperties(Widget, {interaction: false, visible: false}) {
-
- static description() {
-
- return 'Receives / stores a value, to be used in scripts (using the get function) or in properties (using the @{} syntax).'
-
- }
-
- static defaults() {
-
- return super.defaults().extend({
- widget: {
- visible: null,
- interaction: null
- },
- geometry: null,
- style: null,
- })
-
- }
-
- constructor(options) {
-
- super({...options, html: null})
-
- }
-
-
- setValue(v, options={}) {
-
- this.value = v
-
- if (options.sync) this.changed(options)
- if (options.send) this.sendValue(null, {syncOnly: true})
-
- }
-
-}
diff --git a/src/client/widgets/sliders/encoder.mjs b/src/client/widgets/sliders/encoder.mjs
deleted file mode 100644
index 5fe30ae6..00000000
--- a/src/client/widgets/sliders/encoder.mjs
+++ /dev/null
@@ -1,266 +0,0 @@
-import Knob from './knob.mjs'
-import StaticProperties from '../mixins/static_properties.mjs'
-
-export default class Encoder extends StaticProperties(Knob, {angle: 360, range: {min: 0, max: 1}, design: 'encoder'}) {
-
- static description() {
-
- return 'A knob that sends a relative direction information instead of an absolute value.'
-
- }
-
- static defaults() {
-
- var defaults = super.defaults().extend({
- style: {
- _separator_knob_style: null,
- design: null,
- pips: null,
- dashed: null,
- angle: null,
- colorKnob: null
- },
- class_specific: {
- origin: null,
- steps: null,
- spring: null,
- ticks: {type: 'number', value: '', help: 'Defines the granularity / verbosity of the encoder (number of step for a 360° arc)'},
- sensitivity: {type: 'number', value: 1, help: 'When set between 0 and 1, reduces the encoder\'s verbosity'},
- back: {type: '*', value: -1, help: 'Defines which value is sent when rotating the encoder anticlockwise'},
- forth: {type: '*', value: 1, help: 'Defines which value is sent when rotating the encoder clockwise'},
- release: {type: 'number', value: '', help: [
- 'Defines which value is sent when releasing the encoder:',
- '- Set to `null` to send send no argument in the osc message',
- '- Can be an `object` if the type needs to be specified'
- ]},
- mode: {type: 'string', value: 'circular', choices: ['circular', 'snap', 'vertical', 'horizontal'], help: [
- '- `circular`: relative move in circular motion',
- '- `snap`: snap to touch position and move in vertical motion',
- '- `vertical`: relative move in vertical motion',
- '- `horizontal`: relative move in horizontal motion',
- ]},
- doubleTap: {type: 'boolean', value: false, help: [
- 'Set to `true` to make the fader reset to its `default` value when receiving a double tap.',
- 'Can also be an osc address, in which case the widget will just send an osc message (`/ `)'
- ]},
- }
- })
-
- defaults.scripting.onValue.help.push(
- 'Additional variables:',
- '- `locals.speed`: encoder\'s speed (reduce `sensitivity` to increase averaging)',
- '- `locals.angle`: encoder\'s angle in degrees'
- )
-
- return defaults
-
- }
-
- constructor(options) {
-
- super(options)
-
- this.previousPercent = 50
- this.percent = 50
- this.ignoredValues = 0
- this.speed = []
- this.setValue(this.getProp('release'), {dragged: true})
-
- }
-
- angleToPercent(angle, snap) {
-
- // knob.js without clipping
- if (snap) return super.angleToPercent(angle)
-
- var percent = angle - (360 - this.maxAngle) / 2 / this.maxAngle * 100
- if (percent < 0) percent += 100
- else if (percent > 100) percent -= 100
-
- return percent
-
- }
-
- percentToAngle(percent, snap) {
-
- // knob.js without clipping
- if (snap) return super.percentToAngle(percent)
-
- return 2 * Math.PI * percent / 100 * (this.maxAngle / 360) // angle relative to maxAngle
- + Math.PI / 2 // quarter circle offset
- + Math.PI * (1 - this.maxAngle / 360) // centering offset depending on maxAngle
-
- }
-
-
- draginitHandle(e) {
-
- // knob.js without clipping + extra case for snap
-
- this.lastOffsetX = e.offsetX
- this.lastOffsetY = e.offsetY
-
- if (this.getProp('mode') === 'snap') {
-
- this.setPercent(this.angleToPercent(this.coordsToAngle(e.offsetX, e.offsetY), true))
-
- }
-
-
-
- }
-
- dragHandle(e) {
-
- // knob.js without clipping + extra case for snap
- var inertia = e.fingers > 1 || e.ctrlKey ? 10 : e.inertia
-
- if ((this.getProp('mode') === 'vertical' && !e.traversing)) {
- // vertical
- this.setPercent(this.percent - 100 * (e.movementY / inertia * this.getProp('sensitivity')) / this.minDimension)
-
- } else if ((this.getProp('mode') === 'horizontal' && !e.traversing)) {
- // horizontal
- this.setPercent(this.percent + 100 * (e.movementX / inertia * this.getProp('sensitivity')) / this.minDimension)
-
- } else {
- // snap or circular
- var offsetX = this.lastOffsetX + e.movementX,
- offsetY = this.lastOffsetY + e.movementY
-
- var diff = this.angleToPercent(this.coordsToAngle(offsetX, offsetY), true) - this.angleToPercent(this.coordsToAngle(this.lastOffsetX, this.lastOffsetY), true)
- if (Math.abs(diff) < 50 && diff !== 0) {
- diff = diff * this.getProp('sensitivity') / inertia
- this.setPercent(this.percent + diff)
- }
-
- this.lastOffsetX = offsetX
- this.lastOffsetY = offsetY
-
- }
-
- }
-
- dragendHandle(e, data, traversing) {
-
- this.ignoredValues = 0
-
- if (this.getProp('release') === '') return
-
- this.previousPercent = 50
- this.percent = 50
- this.speed = []
- this.setValue(this.getProp('release'), {sync: true, send: true, dragged: true})
-
- }
-
- mousewheelHandle(e) {
-
- if (e.wheelDeltaX) return
-
- e.preventDefault()
- e.stopPropagation()
-
- var direction = e.wheelDelta / Math.abs(e.wheelDelta),
- increment = e.ctrlKey?0.25:1
-
- this.setPercent(this.percent + Math.max(increment, 10 / Math.pow(10, this.decimals + 1)) * direction)
-
- }
-
- setPercent(percent) {
-
- this.previousPercent = this.percent
- this.percent = percent
-
- if (this.getProp('ticks')) {
-
- var div = 100 / this.getProp('ticks'),
- p = Math.round(this.percent / div) * div,
- pp = Math.round(this.previousPercent / div) * div
-
- if (p === pp) return
-
- } else {
-
- if (this.percent === this.previousPercent) return
-
- }
-
- var dir = this.percent > this.previousPercent
-
- if (
- (this.percent >= 0 && this.percent < 25 && this.previousPercent > 75 && this.previousPercent <= 100) ||
- (this.previousPercent >= 0 && this.previousPercent < 25 && this.percent > 75 && this.percent <= 100)
-
- ) dir = !dir
-
- var val = dir ? this.getProp('forth') : this.getProp('back')
-
- this.speed.push(Math.abs(this.percent - this.previousPercent))
-
- this.setValue(val, {
- sync: true,
- send: true,
- dragged: true,
- })
-
- }
-
- getSpringValue() {
-
- return this.getProp('release')
-
- }
-
- setValue(v,options={}) {
-
- if (options.fromLocal && v === this.getProp('release')) {
- this.percent = 50
- this.previousPercent = 50
- } else if (
- !options.dragged &&
- (v !== this.getProp('forth') && v !== this.getProp('back') && (this.getProp('release') === '' && v !== this.getProp('release')))
-
- ) return
-
-
- // sensitivity = ignore value updates
- var sensitivityIgnore = false
- if (this.getProp('sensitivity') < 1) {
- if (v != this.getProp('release')) {
- this.ignoredValues += 1
- if (this.ignoredValues <= 1 / this.getProp('sensitivity')) {
- sensitivityIgnore = true
- } else {
- this.ignoredValues = 0
- }
- }
- }
-
-
- this.value = v
-
- this.batchDraw()
-
- if (sensitivityIgnore) return
-
- if (!options.dragged && options.widget && options.widget instanceof Encoder) {
- this.percent = options.widget.percent
- }
-
- if (this.speed && this.speed.length) {
- var s = this.speed.reduce((a,c)=>a+c) / this.speed.length
- this.speed = []
- this.parsersLocalScope.speed = s
- } else {
- this.parsersLocalScope.speed = 0
- }
- this.parsersLocalScope.angle = Math.abs(this.percent % 100 / 100 * 360)
-
- if (options.send) this.sendValue()
- if (options.sync) this.changed(options)
-
- }
-
-}
diff --git a/src/client/widgets/sliders/fader.mjs b/src/client/widgets/sliders/fader.mjs
deleted file mode 100644
index 180f6a99..00000000
--- a/src/client/widgets/sliders/fader.mjs
+++ /dev/null
@@ -1,555 +0,0 @@
-import {clip} from '../utils.mjs'
-import Slider from './slider.mjs'
-import {PXSCALE, CANVAS_SCALING} from '../../globals.mjs'
-
-class Fader extends Slider {
-
- static description() {
-
- return 'Vertical / horizontal slider.'
-
- }
-
- static defaults() {
-
- var defaults = super.defaults(Fader).extend({
- style: {
- _separator_fader_style: 'Fader style',
- design: {type: 'string', value: 'default', choices: ['default', 'round', 'compact'], help: 'Design style'},
- knobSize: {type: 'number', value: 'auto', help: 'Fader knob size'},
- colorKnob: {type: 'string', value: 'auto', help: 'Fader knob color. Must be a valid css color.'},
- horizontal: {type: 'boolean', value: false, help: 'Set to `true` to display the fader horizontally'},
- pips: {type: 'boolean', value: false, help: 'Set to `true` to show range breakpoints (ignored if `design` is `compact`)'},
- dashed: {type: 'boolean|array', value: false, help: 'Set to `true` to display a dashed gauge. Can be set as an `array` of two numbers : `[dash_size, gap_size]`'},
- gradient: {type: 'array|object', value: [], help: [
- 'When set, the meter\'s gauge will be filled with a linear color gradient',
- '- each item must be a CSS color string.',
- '- as an `object`: each key must be a number between 0 and 1',
- '- each item must be a CSS color string.',
- 'Examples: `[\'blue\', \'red\']`, {\'0\': \'blue\', \'0.9\': \'blue\', \'1\': \'red\'} '
- ]},
- },
- class_specific: {
- snap: {type: 'boolean', value: false, help: 'By default, dragging the widget will modify it\'s value starting from its last value. Setting this to `true` will make it snap directly to the mouse/touch position'},
- touchZone: {type: 'string', value: 'all', choices: ['all', 'knob', 'gauge'], help: [
- 'Restrict interaction to a part of the widget:',
- '- `all`: touching the widget anywhere will start an interaction',
- '- `knob`: touching the knob will start an interaction',
- '- `gauge`: touching anywhere in the knob\'s moving range will start an interaction',
- 'This setting is ignored in containers with `traversing` set to `true`'
- ]},
- spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its `default` value when released'},
- doubleTap: {type: 'boolean|string', value: false, choices: [false, true, 'script'], help: [
- 'Set to `true` to make the knob reset to its `default` value when receiving a double tap.',
- 'Can be an osc address, in which case the widget will just send an osc message with no value (but `preArgs` included).',
- 'If set to "script", `onTouch` will be called with `event.type` set to `doubleTap`. '
- ]},
- range: {type: 'object', value: {min:0,max:1}, help: [
- 'Defines the breakpoints of the fader\'s scale:',
- '- keys can be percentages and/or `min` / `max`',
- '- values can be `number` or `object` if a custom label is needed',
- 'Example: (`{min:{"-inf": 0}, "50%": 0.25, max: {"+inf": 1}}`)'
- ]},
- logScale: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale. Set to `-1` for exponential scale.'},
- sensitivity: {type: 'number', value: 1, help: 'Defines the fader\'s sensitivity when `snap` is `false` '},
- steps: {type: 'number|array|string', value: '', help: [
- 'Restricts the widget\'s value:',
- '- `number`: define a number of evenly spaced steps',
- '- `array` of numbers: use arbitrary values as steps',
- '- `auto`: use values defined in `range`'
- ]},
- origin: {type: 'number', value: 'auto', help: 'Defines the starting point\'s value of the fader\'s gauge'},
- }
- })
-
- defaults.scripting.onTouch = {type: 'script', value: '', editor:'javascript', help: ['Script executed when the widget is touched and released. See documentation .',]}
- defaults.style.borderRadius= {type: 'number', value: 'auto', help: 'Border radius expressed as a number (same for all corners, applies only for compact design).'}
-
- return defaults
-
- }
-
- constructor(options) {
-
- super(options)
-
- this.container.classList.toggle('horizontal', this.getProp('horizontal'))
-
- this.gaugeGradient = null
- this.shouldDrawPips = false
-
- var dashed = this.getProp('dashed')
- this.dashed = dashed ? Array.isArray(dashed) ? dashed.map(x=>parseFloat(x)) : [1, 1] : false
-
- }
-
- draginitHandle(e) {
-
- super.draginitHandle(...arguments)
-
- if (!e.traversing && !this.shouldDrag(e)) {
- e.cancelDragEvent = true
- return
- }
-
- this.percent = clip(this.percent,[0,100])
-
- if (!(e.traversing || this.getProp('snap')) || e.ctrlKey) return
-
- this.percent = this.getProp('horizontal')?
- (e.offsetX - this.gaugePadding) / (this.width - this.gaugePadding * 2) * 100:
- (this.height - e.offsetY - this.gaugePadding) / (this.height - this.gaugePadding * 2) * 100
-
- this.setValue(this.percentToValue(this.percent), {send: true, sync: true, dragged: true})
-
- }
-
- dragHandle(e, data) {
-
- super.dragHandle(...arguments)
-
- var padding = this.gaugePadding
- if (this.getProp('design') === 'compact') padding += this.cssVars.knobSize / 2
- var inertia = e.fingers > 1 || e.ctrlKey ? 10 : e.inertia
- this.percent = this.getProp('horizontal')?
- this.percent + ( e.movementX / (this.width - padding * 2)) * 100 / inertia * this.getProp('sensitivity'):
- this.percent + (-e.movementY / (this.height - padding * 2)) * 100 / inertia * this.getProp('sensitivity')
-
- this.setValue(this.percentToValue(this.percent), {send:true,sync:true,dragged:true})
-
- }
-
- shouldDrag(e, testZone) {
-
- var zone = testZone || this.getProp('touchZone'),
- design = this.getProp('design'),
- horizontal = this.getProp('horizontal'),
- snap = this.getProp('snap')
-
- if (zone == 'all') return true
- if (e.type == 'wheel' && zone == 'knob') zone = 'gauge'
- if (design == 'compact' && zone == 'gauge') return true
-
- var x = e.offsetX,
- y = e.offsetY,
- percent = this.steps ? this.valueToPercent(this.value) : this.percent,
- d = Math.round(this.percentToCoord(percent)),
- m = horizontal ? this.height / 2 : this.width / 2,
- knobHeight = this.cssVars.knobSize,
- knobWidth = knobHeight * .6,
- height = !horizontal ? this.height : this.width
-
- if (design == 'round') knobWidth = knobHeight
- if (design == 'compact') {
- knobWidth = this.width
- // knob position range depends on knob size in compact mode
- d = d / (height - this.gaugePadding) * (height-this.gaugePadding - knobHeight)
- }
- if (horizontal) [knobWidth, knobHeight] = [knobHeight, knobWidth]
-
- // add extra tolerance pixels
- knobWidth += 2 * PXSCALE
- knobHeight += 2 * PXSCALE
-
- var knobX = (horizontal ? d : m) - knobWidth / 2,
- knobY = (horizontal ? m : d) - knobHeight / 2,
- condition
-
- if (horizontal) {
- if (design == 'compact') knobX += knobWidth / 2
- condition = ((x >= knobX && x <= knobX + knobWidth) || (zone == 'gauge' || snap)) &&
- y >= knobY && y <= knobY + knobHeight
- } else {
- if (design == 'compact') knobY += knobHeight / 2
- condition = x >= knobX && x <= knobX + knobWidth &&
- ((y >= knobY && y <= knobY + knobHeight) || (zone == 'gauge' || snap))
- }
-
- if (condition) {
- return true
- } else {
- return false
- }
-
- }
-
- percentToCoord(percent) {
-
- if (this.getProp('horizontal')) {
- return clip(percent / 100,[0,1]) * (this.width - this.gaugePadding * 2) + this.gaugePadding
- } else {
- return (this.height - this.gaugePadding) - clip(percent / 100, [0,1]) * (this.height - this.gaugePadding * 2)
- }
-
- }
-
- extraResizeHandle(event) {
-
- var ratio = CANVAS_SCALING * this.scaling
-
- super.extraResizeHandle(event)
-
- if (this.getProp('horizontal')){
-
- this.ctx.setTransform(1, 0, 0, 1, 0, 0)
- this.ctx.rotate(-Math.PI/2)
- this.ctx.translate(-this.height * ratio, 0)
-
- if (ratio != 1) this.ctx.scale(ratio, ratio)
-
- }
-
- if (this.getProp('gradient')) {
-
- var colors = this.getProp('gradient')
-
- if (
- (Array.isArray(colors) && colors.length > 1) ||
- (typeof colors === 'object' && Object.keys(colors).length > 1)
- ) {
-
- var grad = this.ctx.createLinearGradient(this.gaugePadding, this.getProp('horizontal') ? this.gaugePadding : this.height - this.gaugePadding, this.gaugePadding, this.getProp('horizontal') ? this.width - this.gaugePadding : this.gaugePadding)
-
- try {
- if (Array.isArray(colors)) {
-
- for (var i in colors) {
- grad.addColorStop(i / (colors.length - 1), colors[i])
- }
- this.gaugeGradient = grad
-
- } else {
-
- for (var k in colors) {
- if (!isNaN(k)) {
- grad.addColorStop(clip(k, [0, 1]), colors[k])
- }
- }
- this.gaugeGradient = grad
-
- }
- } catch(err) {
- this.errorProp('gradient', '', err)
- }
-
- }
-
- }
-
- }
-
- cacheCanvasStyle(style) {
-
- super.cacheCanvasStyle(style)
-
- if (this.getProp('pips') && this.getProp('design') !== 'compact') this.shouldDrawPips = true
-
- }
-
-
- draw() {
-
- var width = this.getProp('horizontal') ? this.height : this.width,
- height = !this.getProp('horizontal') ? this.height : this.width
-
- var percent = this.steps ? this.valueToPercent(this.value) : this.percent,
- d = Math.round(this.percentToCoord(percent)),
- o = Math.round(this.percentToCoord(this.valueToPercent(this.originValue))),
- m = this.getProp('horizontal') ? this.height / 2 : this.width / 2,
- dashed = this.dashed,
- compact = this.getProp('design') === 'compact',
- knobHeight = this.cssVars.knobSize, knobWidth = knobHeight * .6
-
- this.clear()
-
- if (this.getProp('pips') && !compact) m -= 10 * PXSCALE
-
- // sharp border trick
- if (compact) {
- if (width % 2 && parseInt(m) === m) m -= 0.5
- } else {
- if (width % 2 && parseInt(m) !== m) m -= 0.5
- }
-
-
- this.ctx.strokeStyle = this.gaugeGradient || this.cssVars.colorFill
-
- if (compact) {
- this.ctx.lineWidth = Math.round(width - this.gaugePadding * 2)
- } else {
- this.ctx.lineWidth = this.cssVars.lineWidth
- }
-
-
- if (dashed) this.ctx.setLineDash([PXSCALE * dashed[0], PXSCALE * dashed[1]])
-
-
- if (this.cssVars.alphaFillOff) {
- // gaugo off
- this.ctx.globalAlpha = this.cssVars.alphaFillOff
- this.ctx.beginPath()
- this.ctx.moveTo(m, height - this.gaugePadding)
- this.ctx.lineTo(m, this.gaugePadding)
- this.ctx.stroke()
- }
-
-
- if (this.cssVars.alphaFillOn) {
- // gaugo on
- this.ctx.globalAlpha = this.cssVars.alphaFillOn
- this.ctx.beginPath()
- this.ctx.moveTo(m, o)
- this.ctx.lineTo(m, d)
- this.ctx.stroke()
- }
-
- if (dashed) this.ctx.setLineDash([])
-
- if (compact) {
-
- // flat knob
-
- this.ctx.globalAlpha = this.cssVars.alphaKnob || 1
- this.ctx.fillStyle = this.cssVars.colorKnob
-
- this.ctx.beginPath()
- // adjust position to keep knob within gauge boundaries
- d = (d - this.gaugePadding ) / (height - this.gaugePadding * 2 ) * (height - this.gaugePadding * 2 - knobHeight) + this.gaugePadding
- this.ctx.rect(this.gaugePadding, d, width - this.gaugePadding * 2, knobHeight)
- this.ctx.fill()
-
- let x, y, w, h,
- rad = PXSCALE * this.cssVars.borderRadius
-
- // border radius: clip gauge & knob
- if (rad > 0) {
- rad = Math.min(Math.min(height, width) / 2, rad)
- x = this.gaugePadding
- y = this.gaugePadding
- w = width - this.gaugePadding * 2
- h = height - this.gaugePadding * 2
- this.ctx.beginPath()
- this.ctx.moveTo(x + rad, y)
- this.ctx.arcTo(x + w, y, x + w, y + h, rad)
- this.ctx.arcTo(x + w, y + h, x, y + h, rad)
- this.ctx.arcTo(x, y + h, x, y, rad)
- this.ctx.arcTo(x, y, x + w, y, rad)
- this.ctx.closePath()
-
- var tmpOp = this.ctx.globalCompositeOperation
- this.ctx.globalCompositeOperation = 'destination-in'
- this.ctx.fillStyle = '#ffffff'
- this.ctx.globalAlpha = 1
- this.ctx.fill()
- this.ctx.globalCompositeOperation = tmpOp
- }
-
- // stroke
- if (this.cssVars.lineWidth) {
-
- this.ctx.globalAlpha = this.cssVars.alphaStroke
- this.ctx.strokeStyle = this.cssVars.colorStroke
-
- // draw stroke
- x = 0.5 * this.cssVars.lineWidth
- y = 0.5 * this.cssVars.lineWidth
- w = width - this.cssVars.lineWidth
- h = height - this.cssVars.lineWidth
-
- this.ctx.beginPath()
- if (rad > 0) {
- this.ctx.moveTo(x + rad, y)
- this.ctx.arcTo(x + w, y, x + w, y + h, rad)
- this.ctx.arcTo(x + w, y + h, x, y + h, rad)
- this.ctx.arcTo(x, y + h, x, y, rad)
- this.ctx.arcTo(x, y, x + w, y, rad)
- } else {
- this.ctx.moveTo(x, y)
- this.ctx.lineTo(x + w, y)
- this.ctx.lineTo(x + w, y + h)
- this.ctx.lineTo(x, y + h)
- }
-
- this.ctx.closePath()
- this.ctx.lineWidth = this.cssVars.lineWidth
- this.ctx.stroke()
-
- }
-
-
-
- this.clearRect = [0, 0, width, height]
-
-
- } else if (this.getProp('design') === 'default') {
-
-
- if (this.cssVars.alphaStroke) {
-
- this.ctx.globalAlpha = 1
- this.ctx.fillStyle = this.cssVars.colorBg
-
- this.ctx.beginPath()
- this.ctx.rect(m - knobWidth / 2, d - knobHeight / 2, knobWidth, knobHeight)
- this.ctx.fill()
-
-
- this.ctx.globalAlpha = this.cssVars.alphaStroke
- this.ctx.strokeStyle = this.cssVars.colorKnob
-
- this.ctx.beginPath()
- this.ctx.lineWidth = PXSCALE
- this.ctx.rect(m - knobWidth / 2 + 0.5 * PXSCALE, d - knobHeight / 2 + 0.5 * PXSCALE, knobWidth - PXSCALE, knobHeight - PXSCALE)
- this.ctx.stroke()
-
- }
-
- this.ctx.globalAlpha = 1
- this.ctx.fillStyle = this.cssVars.colorKnob
-
- this.ctx.beginPath()
- this.ctx.rect(m - knobWidth / 6, d, knobWidth / 3, PXSCALE)
- this.ctx.fill()
-
- var clearWidth = Math.max(knobWidth, this.cssVars.lineWidth)
- this.clearRect = [m - clearWidth / 2 - PXSCALE, this.gaugePadding - knobHeight / 2 - PXSCALE, clearWidth + 2 * PXSCALE, height - 2 * this.gaugePadding + knobHeight + 2 * PXSCALE]
-
- } else {
-
- this.ctx.globalAlpha = 1
- this.ctx.fillStyle = this.cssVars.colorKnob
-
- this.ctx.beginPath()
- this.ctx.arc(m, d, knobHeight / 6, 0, 2 * Math.PI)
- this.ctx.fill()
-
-
- if (this.cssVars.alphaStroke) {
- this.ctx.globalAlpha = this.cssVars.alphaStroke
- this.ctx.fillStyle = this.cssVars.colorKnob
-
- this.ctx.beginPath()
- this.ctx.arc(m, d, knobHeight / 2, 0, 2 * Math.PI)
- this.ctx.fill()
- }
-
- this.clearRect = [m - knobHeight / 2 - PXSCALE, this.gaugePadding - knobHeight / 2 - PXSCALE, knobHeight + 2 * PXSCALE, height - 2 * this.gaugePadding + knobHeight + 2 * PXSCALE]
-
- }
-
- if (this.shouldDrawPips) {
- this.drawPips()
- this.shouldDrawPips = false
- }
-
- if (this.pips && this.pips.width && this.pips.height) {
- this.ctx.globalAlpha = 1
- this.ctx.drawImage(this.pips, 0, 0)
- if (!compact) this.clearRect = [this.clearRect, [m + knobWidth / 2, 0, 12 * PXSCALE + this.pipsTextSize, height]]
- }
-
-
- }
-
- drawPips() {
-
- this.pips = this.pips || this.canvas.cloneNode()
- this.pips.width = this.getProp('horizontal') ? this.height : this.width
- this.pips.height = !this.getProp('horizontal') ? this.height : this.width
- this.pipsTextSize = this.fontSize
-
-
- var ctx = this.pips.getContext('2d',{
- desynchronized: true,
- lowLatency: true,
- alpha: true,
- preserveDrawingBuffer: true
- })
-
- ctx.font = this.fontWeight + ' ' + this.fontSize + 'px ' + this.fontFamily
- ctx.textBaseline = this.ctx.textBaseline
- ctx.textAlign = this.ctx.textAlign
-
- var width = this.getProp('horizontal') ? this.height : this.width,
- height = !this.getProp('horizontal') ? this.height : this.width,
- m = this.getProp('horizontal') ? this.height / 2 : this.width / 2,
- compact = this.getProp('design') === 'compact'
-
- if (width % 2 && parseInt(m) !== m) m -= 0.5
-
- if (!compact) m -= 16 * PXSCALE - this.cssVars.knobSize * .3 * PXSCALE
-
-
- ctx.lineWidth = this.fontSize / 11
- ctx.fillStyle = this.cssVars.colorText
- ctx.strokeStyle = this.cssVars.colorFill
-
- var i = 0
-
- for (var pip of this.rangeKeys) {
-
- let d = Math.round(this.percentToCoord(pip)),
- y = compact ? Math.min(d, height - this.gaugePadding - PXSCALE) : d,
- pipWidth = 4 * PXSCALE
-
- y += 0.5
-
-
- ctx.globalAlpha = this.cssVars.alphaPips
-
- ctx.beginPath()
-
- ctx.moveTo(m + 7 * PXSCALE, y)
- ctx.lineTo(m + 7 * PXSCALE + pipWidth, y)
- ctx.stroke()
-
-
- var textX = m + 10 * PXSCALE + pipWidth + 4 * PXSCALE,
- textY = y
-
- ctx.globalAlpha = this.cssVars.alphaPipsText
-
-
- if (this.getProp('horizontal')) {
-
- ctx.save()
- ctx.translate(textX + 3 * PXSCALE, textY)
- ctx.rotate(Math.PI/2)
- ctx.textAlign = 'center'
- ctx.fillText(this.rangeLabels[i], 0, 0)
- ctx.restore()
-
- } else {
-
- this.pipsTextSize = Math.max(this.pipsTextSize , ctx.measureText(this.rangeLabels[i]).width)
- ctx.fillText(this.rangeLabels[i], textX, textY)
-
- }
-
-
- i++
-
- }
-
-
- }
-
- onRemove() {
-
- if (this.pips) {
- this.pips.width = 0
- this.pips.height = 0
- }
- super.onRemove()
-
- }
-
-}
-
-
-Fader.cssVariables = Fader.prototype.constructor.cssVariables.concat(
- {js: 'knobSize', css: '--knob-size', toCss: x=>parseFloat(x) + 'rem', toJs: x=>parseFloat(x) * PXSCALE},
- {js: 'colorKnob', css: '--color-knob'},
-)
-
-export default Fader
diff --git a/src/client/widgets/sliders/knob.mjs b/src/client/widgets/sliders/knob.mjs
deleted file mode 100644
index a364e1ff..00000000
--- a/src/client/widgets/sliders/knob.mjs
+++ /dev/null
@@ -1,435 +0,0 @@
-import {clip} from '../utils.mjs'
-import Slider from './slider.mjs'
-import {PXSCALE} from '../../globals.mjs'
-
-class Knob extends Slider {
-
- static description() {
-
- return 'Rotative knob slider.'
-
- }
-
- static defaults() {
-
- var defaults = super.defaults(Knob).extend({
- style: {
- _separator_knob_style: 'Knob style',
- design: {type: 'string', value: 'default', choices: ['default', 'solid', 'line', 'encoder'], help: [
- 'Design style',
- 'Note: "solid" design uses "colorStroke" for the central knob color.'
- ]},
- colorKnob: {type: 'string', value: 'auto', help: 'Knob color. Must be a valid css color.'},
- pips: {type: 'boolean', value: false, help: 'Set to `true` to show the scale\'s breakpoints'},
- dashed: {type: 'boolean|array', value: false, help: 'Set to `true` to display a dashed gauge. Can be set as an `array` of two numbers : `[dash_size, gap_size]`'},
- angle: {type: 'number', value: 270, help: 'Defines the angle\'s width of the knob, in degrees'},
- },
- class_specific: {
- mode: {type: 'string', value: 'vertical', choices: ['vertical', 'horizontal', 'circular', 'snap', 'snap-alt'], help: [
- '- `vertical`: relative move in vertical motion',
- '- `horizontal`: relative move in horizontal motion',
- '- `circular`: relative move in circular motion',
- '- `snap`: snap to touch position',
- '- `snap-alt`: alternative snap mode that allow jumping from `range.min` to `range.max`. `sensitivity` is ignored with this mode.',
- ]},
- spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its `default` value when released'},
- doubleTap: {type: 'boolean|string', value: false, choices: [false, true, 'script'], help: [
- 'Set to `true` to make the knob reset to its `default` value when receiving a double tap.',
- 'Can be an osc address, in which case the widget will just send an osc message with no value (but `preArgs` included).',
- 'If set to "script", `onTouch` will be called with `event.type` set to `doubleTap`. '
- ]},
- range: {type: 'object', value: {min:0,max:1}, help: [
- 'Defines the breakpoints of the fader\'s scale:',
- '- keys can be percentages and/or `min` / `max`',
- '- values can be `number` or `object` if a custom label is needed',
- 'Example: (`{min:{"-inf": 0}, "50%": 0.25, max: {"+inf": 1}}`)'
- ]},
- logScale: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale. Set to `-1` for exponential scale.'},
- sensitivity: {type: 'number', value: 1, help: 'Defines the knob\'s sensitivity when `mode` is not `snap` '},
- steps: {type: 'string|number|array', value: '', help: [
- 'Restricts the widget\'s value:',
- '- `number`: define a number of evenly spaced steps',
- '- `array` of numbers: use arbitrary values as steps',
- '- `auto`: use values defined in `range`'
- ]},
- origin: {type: 'number', value: 'auto', help: 'Defines the starting point\'s value of the knob\'s gauge'},
- }
- })
-
- defaults.scripting.onTouch = {type: 'script', value: '', editor:'javascript', help: ['Script executed when the widget is touched and released. See documentation .',]}
-
- return defaults
-
- }
-
- constructor(options) {
-
- super(options)
-
- this.lastOffsetX = 0
- this.lastOffsetY = 0
- this.minDimension = 0
-
- this.maxAngle = this.getProp('angle')
-
- if (this.getProp('pips')) {
-
- this.widget.classList.add('has-pips')
- this.pipTexts = {}
- for (var k in this.rangeKeys) {
- this.pipTexts[this.rangeKeys[k]]=this.rangeLabels[k]
- }
-
- }
-
- }
-
- draginitHandle(e) {
-
- this.percent = clip(this.percent,[0,100])
-
- this.lastOffsetX = e.offsetX
- this.lastOffsetY = e.offsetY
-
- if (this.getProp('mode') === 'snap' || this.getProp('mode') === 'snap-alt') {
-
- this.percent = this.angleToPercent(this.coordsToAngle(e.offsetX, e.offsetY))
-
- this.setValue(this.percentToValue(this.percent), {send:true,sync:true,dragged:true})
-
- }
-
-
- }
-
- dragHandle(e) {
-
- var inertia = e.fingers > 1 || e.ctrlKey ? 10 : e.inertia
-
- if ((this.getProp('mode') === 'vertical' && !e.traversing)) {
- // vertical
- this.percent = -100 * (e.movementY / inertia * this.getProp('sensitivity')) / this.minDimension + this.percent
-
- } else if ((this.getProp('mode') === 'horizontal' && !e.traversing)) {
- // horizontal
- this.percent = 100 * (e.movementX / inertia * this.getProp('sensitivity')) / this.minDimension + this.percent
-
- } else {
- // snap or circular
- var offsetX = this.lastOffsetX + e.movementX,
- offsetY = this.lastOffsetY + e.movementY
-
- if (this.getProp('mode') === 'snap-alt'){
- this.percent = this.angleToPercent(this.coordsToAngle(offsetX, offsetY))
- } else {
- var diff = this.angleToPercent(this.coordsToAngle(offsetX, offsetY), true) - this.angleToPercent(this.coordsToAngle(this.lastOffsetX, this.lastOffsetY), true)
- if (Math.abs(diff) < 50 && diff !== 0) this.percent += (diff * 360 / this.maxAngle) * this.getProp('sensitivity') / inertia
- }
-
- this.lastOffsetX = offsetX
- this.lastOffsetY = offsetY
-
- }
-
-
- // this.percent = clip(this.percent,[0,100])
-
- this.setValue(this.percentToValue(this.percent), {send:true,sync:true,dragged:true})
-
- }
-
- coordsToAngle(x,y) {
-
- var xToCenter = x - this.width /2,
- yToCenter = y - this.height / 2,
- angle = Math.atan2(-yToCenter, -xToCenter) * 180 / Math.PI + 90
-
- return angle<0?360+angle:angle
-
- }
-
- angleToPercent(angle, ignoreMaxAngle=false) {
-
- return ignoreMaxAngle ?
- clip(angle, [0, 360]) / 360 * 100
- : clip(angle - (360 - this.maxAngle) / 2, [0, this.maxAngle]) / this.maxAngle * 100
-
- }
-
- percentToAngle(percent) {
-
- percent = clip(percent, [0, 100])
-
- return 2 * Math.PI * percent / 100 * (this.maxAngle / 360) // angle relative to maxAngle
- + Math.PI / 2 // quarter circle offset
- + Math.PI * (1 - this.maxAngle / 360) // centering offset depending on maxAngle
-
- }
-
- extraResizeHandle(event) {
-
- super.extraResizeHandle(event)
-
- this.minDimension = Math.min(this.width, this.height)
-
- }
-
- draw() {
-
- var percent = this.steps ? this.valueToPercent(this.value) : this.percent,
- o = this.percentToAngle(this.valueToPercent(this.originValue)),
- d = this.percentToAngle(percent),
- min = this.percentToAngle(0),
- max = this.percentToAngle(100),
- dashed = this.getProp('dashed'),
- pips = this.getProp('pips'),
- minRadius = this.minDimension / 6 - (pips ? this.fontSize * 0.75 : 0) - this.cssVars.lineWidth / 2,
- maxRadius = this.minDimension / 2 - (pips ? this.fontSize * 2 : 0) - this.cssVars.lineWidth / 2
-
- if (dashed) dashed = Array.isArray(dashed) ? dashed.map(x=>parseFloat(x)) : [1.5, 1.5]
-
- var gaugeWidth = maxRadius - minRadius,
- gaugeRadius = maxRadius - gaugeWidth / 2
-
- this.clear()
-
- switch (this.getProp('design')) {
- case 'default':
- {
- if (this.minDimension < 40) {
- minRadius /= 2
- gaugeWidth = maxRadius - minRadius
- gaugeRadius = maxRadius - gaugeWidth / 2
- }
-
- // fill
- this.ctx.strokeStyle = this.cssVars.colorFill
- this.ctx.lineWidth = gaugeWidth - this.gaugePadding * 2
-
- if (dashed) this.ctx.setLineDash(dashed)
-
- 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([])
-
-
- // stroke
- if (this.cssVars.lineWidth) {
- this.ctx.globalAlpha = this.cssVars.alphaStroke
- this.ctx.strokeStyle = this.cssVars.colorStroke
- this.ctx.lineWidth = this.cssVars.lineWidth
-
- 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.colorKnob
- this.ctx.lineWidth = this.cssVars.lineWidth + .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()
- break
- }
- case 'solid':
- {
- // center
-
- this.ctx.globalAlpha = this.cssVars.alphaStroke
- this.ctx.fillStyle = this.cssVars.colorKnob
-
- this.ctx.beginPath()
- this.ctx.arc(this.width / 2, this.height / 2, maxRadius / 1.25, 0, 2 * Math.PI)
- this.ctx.fill()
-
- // fill
- this.ctx.strokeStyle = this.cssVars.colorFill
- this.ctx.lineWidth = this.cssVars.lineWidth
-
- if (dashed) this.ctx.setLineDash(dashed)
-
- 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 (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([])
-
- // knob
-
- this.ctx.globalAlpha = 1
- this.ctx.strokeStyle = this.cssVars.colorBg
- this.ctx.lineWidth = this.cssVars.lineWidth + .5 * PXSCALE
-
- let r1 = minRadius,
- r2 = maxRadius / 1.25 + PXSCALE ,
- 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()
- break
- }
- case 'line':
- {
- // fill
- this.ctx.strokeStyle = this.cssVars.colorFill
- this.ctx.lineWidth = this.cssVars.lineWidth
-
- if (dashed) this.ctx.setLineDash(dashed)
-
- 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 (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([])
-
- // knob
-
- this.ctx.globalAlpha = 1
- this.ctx.strokeStyle = this.cssVars.colorKnob
- this.ctx.lineWidth = this.cssVars.lineWidth
-
- let r1 = minRadius * 1.5,
- r2 = maxRadius + this.cssVars.lineWidth / 2 - 0.5 * PXSCALE,
- 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()
- break
- }
- case 'encoder':
- {
- let angle = 2 * Math.PI / 16
-
- // fill
- this.ctx.globalAlpha = this.cssVars.alphaFill
- this.ctx.strokeStyle = this.cssVars.colorFill
- this.ctx.lineWidth = gaugeWidth - this.gaugePadding * 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 - angle, max + angle)
- 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, d - angle, d + angle)
- this.ctx.stroke()
- }
-
- // stroke
- if (this.cssVars.lineWidth) {
-
- this.ctx.globalAlpha = this.cssVars.alphaStroke
- this.ctx.strokeStyle = this.cssVars.colorStroke
- this.ctx.lineWidth = this.cssVars.lineWidth
-
- 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()
-
- }
-
- break
- }
- }
-
-
- // pips
-
- if (pips) {
-
- this.ctx.lineWidth = this.fontSize / 11 * 1.5
- this.ctx.strokeStyle = this.cssVars.colorStroke
- this.ctx.globalAlpha = this.cssVars.alphaPips
-
- for (var pip of this.rangeKeys) {
-
- let r1 = maxRadius + this.cssVars.lineWidth / 2 + 2 * PXSCALE,
- r2 = r1 + 4 * PXSCALE,
- a = 2 * Math.PI - this.percentToAngle(pip)
-
-
- 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()
-
- }
- var radius = maxRadius + (this.fontSize + this.cssVars.lineWidth / 2 + 2 * PXSCALE)
- this.ctx.fillStyle = this.cssVars.colorText
- this.ctx.globalAlpha = this.cssVars.alphaPipsText
- for (var p in this.pipTexts) {
- if (this.pipTexts[p] === undefined || (this.maxAngle === 360 && p === '100')) continue
- let angle = this.percentToAngle(p),
- size = this.ctx.measureText(this.pipTexts[p]),
- x = this.width / 2 + radius * Math.cos(angle) - size.width / 2,
- y = this.height / 2 + radius * Math.sin(angle)
- this.ctx.fillText(this.pipTexts[p], x, y)
- }
-
- }
-
- }
-
-}
-
-Knob.cssVariables = Knob.prototype.constructor.cssVariables.concat(
- {js: 'colorKnob', css: '--color-knob'}
-)
-
-export default Knob
diff --git a/src/client/widgets/sliders/range.mjs b/src/client/widgets/sliders/range.mjs
deleted file mode 100644
index 55f5097c..00000000
--- a/src/client/widgets/sliders/range.mjs
+++ /dev/null
@@ -1,423 +0,0 @@
-import html from 'nanohtml'
-import {clip} from '../utils.mjs'
-import Fader from './fader'
-import {PXSCALE} from '../../globals.mjs'
-
-var faderDefaults = Fader.defaults()._props()
-
-var rangePassedProps = ['horizontal', 'snap', 'steps', 'spring', 'range', 'decimals', 'logScale', 'sensitivity']
-
-class SubFader extends Fader {
-
- getProp(propName) {
-
- if (rangePassedProps.includes(propName)) {
-
- return this.parent.getProp(propName)
-
- } else {
-
- return super.getProp(propName)
-
- }
-
- }
-
-}
-
-class Range extends Fader {
-
- static description() {
-
- return 'A fader with two heads for setting a range.'
-
- }
-
- static defaults() {
-
- return super.defaults(Fader).extend({
- class_specific: {
- origin: null,
- }
- })
- }
-
- constructor(options) {
-
- options.multitouch = true
-
- super({...options, value: [], html: html`
-
- `})
-
- this.preventChildrenTouchState = true
-
- this.faders = [
- new SubFader({props:{
- ...faderDefaults,
- pips:false,
- visible: false,
- default:this.getProp('default').length === 2 ? this.getProp('default')[0] : this.getProp('range').min,
- origin:this.getProp('default').length === 2 ? this.getProp('default')[0] : this.getProp('range').min,
- }, parent: this}),
- new SubFader({props:{
- ...faderDefaults,
- pips:false,
- visible: false,
- default:this.getProp('default').length === 2 ? this.getProp('default')[1] : this.getProp('range').max,
- origin:this.getProp('default').length === 2 ? this.getProp('default')[1] : this.getProp('range').max,
- }, parent: this})
- ]
-
-
- this.on('value-changed',(e)=>{
-
- if (e.widget == this) return
-
- e.stopPropagation = true
-
- var v = [
- this.faders[0].getValue(),
- this.faders[1].getValue()
- ]
-
- this.setValue(v, e.options)
-
- })
-
- this.touchMap = {}
-
-
- this.originValue = this.faders.map(f => f.originValue)
- this.setValue(this.getSpringValue())
-
- }
-
- extraResizeHandle(event){
-
- super.extraResizeHandle(event)
-
- for (var f of this.faders) {
- f.width = this.width
- f.height = this.height
- f.gaugePadding = this.gaugePadding
- }
-
- }
-
- draginitHandle(e) {
-
- var id
-
- if (!this.touchMap[e.pointerId]) {
-
- var ndiff, diff = -1
-
- for (var i in this.faders) {
-
- if (Object.values(this.touchMap).indexOf(i) != -1) continue
-
- var coord = this.faders[i].percentToCoord(this.faders[i].valueToPercent(this.faders[i].value)) - (this.getProp('horizontal') ? -1 : 1) * (i == 0 ? -20 : 20)
-
- ndiff = this.getProp('horizontal')?
- Math.abs(e.offsetX - coord) :
- Math.abs(e.offsetY - coord)
-
- if (diff == -1 || ndiff < diff) {
- id = i
- diff = ndiff
- }
-
- }
-
- this.touchMap[e.pointerId] = id
-
-
- } else if (e.traversing) {
-
- id = this.touchMap[e.pointerId]
-
- }
-
- if (!id) return
-
- this.trigger('touch', {stopPropagation: true, touch: [parseInt(id), 1]})
-
- for (var f of this.faders) {
- f.percent = clip(f.percent,[
- f.valueToPercent(f.rangeValsMin),
- f.valueToPercent(f.rangeValsMax)
- ])
- }
-
-
- e.stopPropagation = true
- this.faders[id].trigger('draginit', e)
- this.faders[id].touched = 1
-
- }
-
- dragHandle(e) {
-
- var i = this.touchMap[e.pointerId]
-
- if (!i) return
-
- e.fingers = 1 // cancel multifinger inertia
-
- if (e.shiftKey) {
- this.faders[0].trigger('drag', e)
- this.faders[1].trigger('drag', e)
- } else {
- this.faders[i].trigger('drag', e)
- }
-
- }
-
- dragendHandle(e) {
-
- var i = this.touchMap[e.pointerId]
-
- if (!i) return
-
- e.stopPropagation = true
- this.faders[i].touched = 0
- this.faders[i].trigger('dragend', e)
-
-
- this.trigger('touch', {stopPropagation: true, touch: [parseInt(i), 0]})
-
- delete this.touchMap[e.pointerId]
-
- }
-
- setValue(v, options={}) {
-
- if (!this.faders) return // prevent Fader.constructor
- if (!v || !v.length || v.length!=2) return
-
- this.faders[0].rangeValsMax = v[1]
- this.faders[1].rangeValsMin = v[0]
-
- if (!options.dragged || options.fromScript) {
- var opt = {
- ...options,
- send: false,
- sync: false
- }
- this.faders[0].setValue(v[0], opt)
- this.faders[1].setValue(v[1], opt)
- }
- this.value = [
- this.faders[0].getValue(),
- this.faders[1].getValue()
- ]
-
-
- if (options.send) this.sendValue()
- if (options.sync) this.changed(options)
-
- this.batchDraw()
-
- }
-
- draw() {
-
-
- var width = this.getProp('horizontal') ? this.height : this.width,
- height = !this.getProp('horizontal') ? this.height : this.width,
- fader = this.faders[0]
-
- var d = Math.round(fader.percentToCoord(fader.valueToPercent(this.faders[this.getProp('horizontal')?0:1].value))),
- d2 = Math.round(fader.percentToCoord(fader.valueToPercent(this.faders[this.getProp('horizontal')?1:0].value))),
- m = this.getProp('horizontal') ? this.height / 2 : this.width / 2,
- dashed = this.dashed,
- compact = this.getProp('design') === 'compact',
- knobHeight = this.cssVars.knobSize, knobWidth = knobHeight * .6
-
- this.clear()
-
- if (this.getProp('pips') && !compact) m -= 10 * PXSCALE
-
- // sharp border trick
- if (compact) {
- if (width % 2 && parseInt(m) === m) m -= 0.5
- } else {
- if (width % 2 && parseInt(m) !== m) m -= 0.5
- }
-
-
- this.ctx.strokeStyle = this.gaugeGradient || this.cssVars.colorFill
-
- if (compact) {
- this.ctx.lineWidth = Math.round(width - this.gaugePadding * 2)
- } else {
- this.ctx.lineWidth = this.cssVars.lineWidth
- }
-
-
- if (dashed) this.ctx.setLineDash([PXSCALE * dashed[0], PXSCALE * dashed[1]])
-
-
- if (this.cssVars.alphaFillOff) {
- // gaugo off
- this.ctx.globalAlpha = this.cssVars.alphaFillOff
- this.ctx.beginPath()
- this.ctx.moveTo(m, height - this.gaugePadding)
- this.ctx.lineTo(m, this.gaugePadding)
- this.ctx.stroke()
- }
-
-
- if (this.cssVars.alphaFillOn) {
- // gaugo on
- this.ctx.globalAlpha = this.cssVars.alphaFillOn
- this.ctx.beginPath()
- this.ctx.moveTo(m, d)
- this.ctx.lineTo(m, d2)
- this.ctx.stroke()
- }
-
- if (dashed) this.ctx.setLineDash([])
-
- if (compact) {
-
- // stroke
-
- this.ctx.globalAlpha = this.cssVars.alphaStroke
- this.ctx.strokeStyle = this.cssVars.colorStroke
-
- this.ctx.beginPath()
- this.ctx.moveTo(0, 0)
- this.ctx.lineTo(width, 0)
- this.ctx.lineTo(width, height)
- this.ctx.lineTo(0, height)
- this.ctx.closePath()
- this.ctx.lineWidth = 2 * this.cssVars.lineWidth
- this.ctx.stroke()
-
-
- // flat knob
-
- this.ctx.globalAlpha = 1
- this.ctx.fillStyle = this.cssVars.colorKnob
-
- this.ctx.beginPath()
- d = (d - this.gaugePadding ) / (height - this.gaugePadding * 2 ) * (height - this.gaugePadding * 2 - knobHeight) + this.gaugePadding
- this.ctx.rect(this.gaugePadding, d, width - this.gaugePadding * 2, knobHeight)
- this.ctx.fill()
-
- // extra knob
- this.ctx.beginPath()
- d2 = (d2 - this.gaugePadding ) / (height - this.gaugePadding * 2 ) * (height - this.gaugePadding * 2 - knobHeight) + this.gaugePadding
- this.ctx.rect(this.gaugePadding, d2, width - this.gaugePadding * 2, knobHeight)
- this.ctx.fill()
-
-
- this.clearRect = [0, 0, width, height]
-
-
- } else if (this.getProp('design') === 'default') {
-
- for (let _d of [d, d2]) {
-
- if (this.cssVars.alphaStroke) {
-
- this.ctx.globalAlpha = 1
- this.ctx.fillStyle = this.cssVars.colorBg
-
- this.ctx.beginPath()
- this.ctx.rect(m - knobWidth / 2, _d - knobHeight / 2, knobWidth, knobHeight)
- this.ctx.fill()
-
- this.ctx.globalAlpha = this.cssVars.alphaStroke
- this.ctx.strokeStyle = this.cssVars.colorKnob
- this.ctx.lineWidth = PXSCALE
-
- this.ctx.beginPath()
- this.ctx.rect(m - knobWidth / 2 + 0.5 * PXSCALE, _d - knobHeight / 2 + 0.5 * PXSCALE, knobWidth - PXSCALE, knobHeight - PXSCALE)
- this.ctx.stroke()
-
- }
-
- this.ctx.globalAlpha = 1
- this.ctx.fillStyle = this.cssVars.colorKnob
-
- this.ctx.beginPath()
- this.ctx.rect(m - knobWidth / 6, _d, knobWidth / 3, PXSCALE)
- this.ctx.fill()
-
- }
-
- this.clearRect = [m - knobWidth / 2 - PXSCALE, this.gaugePadding - knobHeight / 2 - PXSCALE, knobWidth + 2 * PXSCALE, height - 2 * this.gaugePadding + knobHeight + 2 * PXSCALE]
-
- } else {
-
- this.ctx.globalAlpha = 1
- this.ctx.fillStyle = this.cssVars.colorKnob
-
- this.ctx.beginPath()
- this.ctx.arc(m, d, knobHeight / 6, 0, 2 * Math.PI)
- this.ctx.fill()
-
- // extra knob
- this.ctx.beginPath()
- this.ctx.arc(m, d2, knobHeight / 6, 0, 2 * Math.PI)
- this.ctx.fill()
-
-
- if (this.cssVars.alphaStroke) {
- this.ctx.globalAlpha = this.cssVars.alphaStroke
- this.ctx.fillStyle = this.cssVars.colorKnob
-
- this.ctx.beginPath()
- this.ctx.arc(m, d, knobHeight / 2, 0, 2 * Math.PI)
- this.ctx.fill()
-
- // extra knob
- this.ctx.beginPath()
- this.ctx.arc(m, d2, knobHeight / 2, 0, 2 * Math.PI)
- this.ctx.fill()
- }
-
- this.clearRect = [m - knobHeight / 2 - PXSCALE, this.gaugePadding - knobHeight / 2 - PXSCALE, knobHeight + 2 * PXSCALE, height - 2 * this.gaugePadding + knobHeight + 2 * PXSCALE]
-
- }
-
- if (this.shouldDrawPips) {
- this.drawPips()
- this.shouldDrawPips = false
- }
-
- if (this.pips && this.pips.width && this.pips.height) {
- this.ctx.globalAlpha = 1
- this.ctx.drawImage(this.pips, 0, 0)
- if (!compact) this.clearRect = [this.clearRect, [m + knobWidth / 2, 0, 12 * PXSCALE + this.pipsTextSize, height]]
- }
-
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- if (super.onPropChanged(...arguments)) return true
-
- if (rangePassedProps.includes(propName)) {
- for (var f of this.faders) {
- f.onPropChanged(...arguments)
- }
- }
-
- }
-
- onRemove() {
-
- this.faders[0].onRemove()
- this.faders[1].onRemove()
- super.onRemove()
-
- }
-
-}
-
-export default Range
diff --git a/src/client/widgets/sliders/scrollbar.mjs b/src/client/widgets/sliders/scrollbar.mjs
deleted file mode 100644
index e3dafd9f..00000000
--- a/src/client/widgets/sliders/scrollbar.mjs
+++ /dev/null
@@ -1,350 +0,0 @@
-import fastdom from 'fastdom'
-import Fader from './fader.mjs'
-import StaticProperties from '../mixins/static_properties.mjs'
-import {clip} from '../utils.mjs'
-import widgetManager from '../../managers/widgets.mjs'
-import {PXSCALE} from '../../globals.mjs'
-
-export default class Scrollbar extends StaticProperties(Fader, {
- range: {min: 0, max: 1},
- touchZone: 'all',
- snap: false,
- design: 'compact',
- sensitivity: 1
-}) {
-
- static defaults() {
-
- return super.defaults().extend({
- style: {
- _separator_fader_style: 'Scrollbar style',
- design: null,
- knobSize: null,
- pips: null,
- },
- class_specific: {
- snap: null,
- touchZone: null,
- spring: null,
- doubleTap: null,
- range: null,
- logScale: null,
- steps: null,
- origin: null,
- sensitivity: null,
- widgetId: {type: 'string', value: '', help: '`id` of the container widget to control'},
- }
- })
-
- }
-
- constructor(options) {
-
- super(options)
-
- this.scrollTarget = null
- this.targetRank = null
- this.thumbSize = 1
-
- if (!this.getProp('horizontal')) {
- // invert vertical fader
- this.rangeVals[0] = 1
- this.rangeVals[1] = 0
- this.setValue(this.getSpringValue())
- }
-
-
- widgetManager.on('widget-created', (e)=>{
-
- // if in a non-scoped context we don't watch for a closer target once we have one
- if (!this.scopes.length && this.scrollTarget) return
-
- var {id, widget} = e
- if (id.includes(this.getProp('widgetId')) && widget.getProp('scroll')) {
-
- this.getScrollTarget()
- }
-
- }, {context: this})
-
- this.getScrollTarget()
-
- }
-
- getScrollTarget() {
-
- var scopes = this.scopes.length ? this.scopes : [''],
- target = null,
- rank = 0
-
- for (var scope of scopes) {
- var widgets = widgetManager.getWidgetById(this.getProp('widgetId'), scope)
- .filter(w=>w.getProp('scroll'))
- target = widgets[0]
-
- if (!target) {
- rank++
- continue
- }
-
- if (rank < this.targetRank || this.targetRank == null) {
- this.unbindTarget()
- this.bindTarget(target, rank)
- }
-
- return
-
- }
-
- }
-
- draginitHandle(e) {
-
- // super.draginitHandle(...arguments)
-
- if (!e.traversing && !this.shouldDrag(e)) {
- e.cancelDragEvent = true
- return
- }
-
- this.percent = clip(this.percent,[0,100])
-
- // snap when not touching the knob zone
- if (this.shouldDrag(e, 'knob')) return
-
- this.percent = this.getProp('horizontal')?
- (e.offsetX - this.gaugePadding) / (this.width - this.gaugePadding * 2) * 100:
- (this.height - e.offsetY - this.gaugePadding) / (this.height - this.gaugePadding * 2) * 100
-
- this.setValue(this.percentToValue(this.percent), {send: true, sync: true, dragged: true})
-
- }
-
-
- mousewheelHandle(e) {
-
- e.preventDefault()
- e.stopPropagation()
-
- if (!this.scrollTarget) return
-
- var increment
- if (this.getProp('horizontal')) {
- increment = e.deltaY / this.scrollTarget.scrollWidth * 100
- } else {
- increment = -e.deltaY / this.scrollTarget.scrollHeight * 100
- }
-
- this.percent = clip(this.percent + increment, [0,100])
- this.setValue(this.percentToValue(this.percent), {sync: true, send: true, dragged: true})
-
- }
-
- cacheCanvasStyle(style){
-
- super.cacheCanvasStyle(style)
-
- var size = this.getProp('horizontal') ? this.width : this.height
- this.cssVars.knobSize = Math.max(this.thumbSize * size, 30)
- this.cssVars.alphaKnob = 0.25
-
- }
-
-
- unbindTarget() {
-
- if (!this.scrollTarget) return
-
- this.scrollTarget.off(undefined, undefined, this)
-
- this.scrollTarget = null
- this.targetRank = null
- }
-
- bindTarget(target, rank) {
-
- if (!target) return
-
- this.scrollTarget = target
- this.targetRank = rank
-
- this.scrollTarget.on('widget-removed', (e)=>{
- if (this.scrollTarget === e.widget) {
- this.unbindTarget()
- }
- }, {context: this})
-
- fastdom.measure(()=>{
- if (!this.scrollTarget) return
- this.scrollTarget.on('scroll', this.targetScroll.bind(this))
- this.scrollTarget.on('resize', ()=>{
- if (this.scrollTarget) {
- this.scrollTarget.trigger('scroll', {})
- this.targetScroll({}, true)
- }
- }, {element: this.scrollTarget.widget})
- this.targetScroll({}, true)
- })
-
- }
-
- targetScroll(e, init) {
-
- if (!this.scrollTarget || (e && e.locked)) return
-
- var index = this.getProp('horizontal') ? 0 : 1,
- size = this.getProp('horizontal') ? this.width : this.height
-
- this.thumbSize = this.scrollTarget.scrollThumb[index]
- this.cssVars.knobSize = Math.max(this.thumbSize * size, 30)
-
- if (init && this.value) {
- // panel (re)createed: restore scroll state
- this.setValue(this.value, {fromScrollEvent: false, send: false, sync: false})
- } else if (this.scrollTarget.scroll[index] != this.value) {
- // panel scrolling: update scroll state
- this.setValue(this.scrollTarget.scroll[index], {fromScrollEvent: true, send: !init, sync: !init})
- }
-
- }
-
-
- setValue(v, options={}) {
-
- super.setValue(v, options)
-
- if (!options.fromScrollEvent && this.scrollTarget) {
- if (this.getProp('horizontal')) {
- this.scrollTarget.setScroll(this.value, undefined, true)
- } else {
- this.scrollTarget.setScroll(undefined, this.value, true)
- }
- }
-
- }
-
- draw() {
-
- var width = this.getProp('horizontal') ? this.height : this.width,
- height = !this.getProp('horizontal') ? this.height : this.width
-
- var percent = this.steps ? this.valueToPercent(this.value) : this.percent,
- d = Math.round(this.percentToCoord(percent)),
- m = this.getProp('horizontal') ? this.height / 2 : this.width / 2,
- dashed = this.dashed,
- knobHeight = this.cssVars.knobSize
-
- this.clear()
-
- // sharp border trick
- if (width % 2 && parseInt(m) === m) m -= 0.5
-
-
- this.ctx.strokeStyle = this.gaugeGradient || this.cssVars.colorFill
-
- this.ctx.lineWidth = Math.round(width - this.gaugePadding * 2)
-
-
- if (dashed) this.ctx.setLineDash([PXSCALE * dashed[0], PXSCALE * dashed[1]])
-
-
- if (this.cssVars.alphaFillOff) {
- // gaugo off
- this.ctx.globalAlpha = this.cssVars.alphaFillOff
- this.ctx.beginPath()
- this.ctx.moveTo(m, height - this.gaugePadding)
- this.ctx.lineTo(m, this.gaugePadding)
- this.ctx.stroke()
- }
-
-
- if (dashed) this.ctx.setLineDash([])
-
- // flat knob
-
- this.ctx.globalAlpha = this.cssVars.alphaFillOn
- this.ctx.fillStyle = this.cssVars.colorKnob
-
- this.ctx.beginPath()
- // adjust position to keep knob within gauge boundaries
- d = (d - this.gaugePadding ) / (height - this.gaugePadding * 2 ) * (height - this.gaugePadding * 2 - knobHeight) + this.gaugePadding
- if (this.cssVars.borderRadius > 0 && this.ctx.roundRect) {
- this.ctx.roundRect(this.gaugePadding, d, width - this.gaugePadding * 2, knobHeight, PXSCALE * this.cssVars.borderRadius)
- } else {
- this.ctx.rect(this.gaugePadding, d, width - this.gaugePadding * 2, knobHeight)
- }
- this.ctx.fill()
-
- let x, y, w, h,
- rad = PXSCALE * this.cssVars.borderRadius
-
- // border radius: clip gauge & knob
- if (rad > 0) {
- rad = Math.min(Math.min(height, width) / 2, rad)
- x = this.gaugePadding
- y = this.gaugePadding
- w = width - this.gaugePadding * 2
- h = height - this.gaugePadding * 2
- this.ctx.beginPath()
- this.ctx.moveTo(x + rad, y)
- this.ctx.arcTo(x + w, y, x + w, y + h, rad)
- this.ctx.arcTo(x + w, y + h, x, y + h, rad)
- this.ctx.arcTo(x, y + h, x, y, rad)
- this.ctx.arcTo(x, y, x + w, y, rad)
- this.ctx.closePath()
-
- var tmpOp = this.ctx.globalCompositeOperation
- this.ctx.globalCompositeOperation = 'destination-in'
- this.ctx.fillStyle = '#ffffff'
- this.ctx.globalAlpha = 1
- this.ctx.fill()
- this.ctx.globalCompositeOperation = tmpOp
- }
-
- // stroke
- if (this.cssVars.lineWidth) {
-
- this.ctx.globalAlpha = this.cssVars.alphaStroke
- this.ctx.strokeStyle = this.cssVars.colorStroke
-
- // draw stroke
- x = 0.5 * this.cssVars.lineWidth
- y = 0.5 * this.cssVars.lineWidth
- w = width - this.cssVars.lineWidth
- h = height - this.cssVars.lineWidth
-
- this.ctx.beginPath()
- if (rad > 0) {
- this.ctx.moveTo(x + rad, y)
- this.ctx.arcTo(x + w, y, x + w, y + h, rad)
- this.ctx.arcTo(x + w, y + h, x, y + h, rad)
- this.ctx.arcTo(x, y + h, x, y, rad)
- this.ctx.arcTo(x, y, x + w, y, rad)
- } else {
- this.ctx.moveTo(x, y)
- this.ctx.lineTo(x + w, y)
- this.ctx.lineTo(x + w, y + h)
- this.ctx.lineTo(x, y + h)
- }
-
- this.ctx.closePath()
- this.ctx.lineWidth = this.cssVars.lineWidth
- this.ctx.stroke()
-
- }
-
-
-
- this.clearRect = [0, 0, width, height]
-
-
- }
-
- onRemove(){
-
- this.unbindTarget()
- super.onRemove()
-
- }
-
-}
diff --git a/src/client/widgets/sliders/slider.mjs b/src/client/widgets/sliders/slider.mjs
deleted file mode 100644
index e3ac837f..00000000
--- a/src/client/widgets/sliders/slider.mjs
+++ /dev/null
@@ -1,320 +0,0 @@
-import html from 'nanohtml'
-import {clip, mapToScale} from '../utils.mjs'
-import Canvas from '../common/canvas.mjs'
-import touchstate from '../mixins/touch_state.mjs'
-import doubleTap from '../mixins/double_tap'
-
-class Slider extends Canvas {
-
- constructor(options) {
-
- super({...options, html: html`
-
- `})
-
- this.container.classList.add('design-' + this.getProp('design'))
-
- this.percent = 0
-
- this.gaugePadding = 0
-
- this.rangeKeys = Object.keys(this.getProp('range')).sort((a,b)=>{
- if (a === 'min' || b === 'max') return -1
- else if (a === 'max' || b === 'min') return 1
- else return parseFloat(a) - parseFloat(b)
- })
- this.rangeVals = []
- this.rangeLabels = []
-
- for (var i in this.rangeKeys) {
- var k = this.rangeKeys[i],
- key = k == 'min' ? 0 : k == 'max' ? 100 : parseFloat(k),
- val = typeof this.getProp('range')[k] === 'object' && this.getProp('range')[k] !== null ?
- this.getProp('range')[k][Object.keys(this.getProp('range')[k])[0]]:
- this.getProp('range')[k]
-
- if (isNaN(val) || val === null || val === undefined) val = 0
-
- var label = typeof this.getProp('range')[k] === 'object' && this.getProp('range')[k] !== null ?
- Object.keys(this.getProp('range')[k])[0]:
- val
-
- if (Math.abs(label) >= 1000) label = Math.round(label / 1000) + 'k'
-
- this.rangeKeys[i] = key
- this.rangeVals.push(val)
- this.rangeLabels.push(label)
- }
-
- this.rangeValsMax = Math.max(...this.rangeVals),
- this.rangeValsMin = Math.min(...this.rangeVals)
-
- this.originValue = this.getProp('origin')=='auto'?
- this.rangeValsMin:
- clip(this.getProp('origin'), [this.rangeValsMin,this.rangeValsMax])
-
- if (this.getProp('doubleTap')) {
-
- if (typeof this.getProp('doubleTap') === 'string' && this.getProp('doubleTap')[0] === '/') {
-
- doubleTap(this, (e)=>{
- if (!this.shouldDrag(e)) return
- this.sendValue({v:null, address: this.getProp('doubleTap')})
- }, {element: this.widget})
-
- }
- if (this.getProp('doubleTap') == 'script') {
-
- doubleTap(this, (e)=>{
- if (!this.shouldDrag(e)) return
- this.scripts.onTouch.run({
- event: {type: 'doubleTap'},
- value: this.value
- }, {sync: true, send: true})
- }, {element: this.widget})
-
-
- } else {
-
- doubleTap(this, (e)=>{
- if (!this.shouldDrag(e)) return
- this.setValue(this.getSpringValue(),{sync:true, send:true, fromLocal:true, doubleTap:true})
- }, {element: this.widget})
-
- }
-
- }
-
-
- touchstate(this, {element: this.widget, multitouch: options.multitouch})
-
- this.on('draginit', this.draginitHandleProxy.bind(this), {element:this.widget, multitouch: options.multitouch})
- this.on('drag', this.dragHandleProxy.bind(this), {element:this.widget, multitouch: options.multitouch})
- this.on('dragend', this.dragendHandleProxy.bind(this), {element:this.widget, multitouch: options.multitouch})
- this.on('wheel',this.mousewheelHandleProxy.bind(this), {element: this.widget})
-
- this.steps = null
- this.setSteps()
-
- this.setValue(this.getSpringValue())
-
- }
-
- shouldDrag(e) {
-
- return true
-
- }
-
- mousewheelHandleProxy() {
-
- this.mousewheelHandle(...arguments)
-
- }
-
- draginitHandleProxy() {
-
- this.draginitHandle(...arguments)
-
- }
-
- dragHandleProxy() {
-
- this.dragHandle(...arguments)
-
- }
-
- dragendHandleProxy() {
-
- this.dragendHandle(...arguments)
-
- }
-
- mousewheelHandle(e) {
-
- if (e.deltaX || this.getProp('spring') || !this.shouldDrag(e)) return
-
- e.preventDefault()
- e.stopPropagation()
-
- var direction = e.deltaY > 0 ? -1 : 1,
- increment = e.ctrlKey ? 0.25 : 1
-
- if (this.steps) {
- var i = this.steps.indexOf(this.value),
- val
- if (i === -1) {
- val = this.steps.reduce((a, b) => {
- let aDiff = Math.abs(a - this.value),
- bDiff = Math.abs(b - this.value)
-
- if (aDiff == bDiff) {
- return (direction ? a > b : b > a) ? a : b
- } else {
- return bDiff < aDiff && ((b - this.value) > 0 != e.deltaY > 0)? b : a
- }
- })
- }
- else if (i < this.steps.length) {
- val = this.steps[i + direction]
- }
- if (val !== undefined) this.setValue(val, {sync: true, send: true, fromLocal: true})
- } else {
- this.percent = clip(this.percent + Math.max(increment,10/Math.pow(10,this.decimals + 1)) * direction, [0,100])
- this.setValue(this.percentToValue(this.percent), {sync: true, send: true, dragged: true})
- }
-
- }
-
- draginitHandle(e, data, traversing) {
-
- }
-
- dragHandle(e, data, traversing) {
-
- }
-
- dragendHandle(e, data, traversing) {
-
- if (this.getProp('spring')) {
- this.setValue(this.getSpringValue(),{sync:true,send:true,fromLocal:true})
- }
-
- }
-
- cacheCanvasStyle(style) {
-
- super.cacheCanvasStyle(style)
-
- this.gaugePadding = this.cssVars.padding + this.cssVars.lineWidth
-
- }
-
-
-
- getSpringValue() {
-
- return this.getProp('default') !== '' ? this.getProp('default') : this.originValue
-
- }
-
-
- percentToValue(percent) {
-
- var h = clip(percent,[0,100])
- for (var i=0;i= this.rangeKeys[i]) {
- return mapToScale(h, [this.rangeKeys[i], this.rangeKeys[i + 1]], [this.rangeVals[i], this.rangeVals[i + 1]], -1, this.getProp('logScale'))
- }
- }
-
- }
-
- valueToPercent(value) {
-
- for (var i=0;i this.rangeVals[i] && value <= this.rangeVals[i+1] && value >= this.rangeVals[i]) ||
- (this.rangeVals[i+1] < this.rangeVals[i] && value >= this.rangeVals[i+1] && value <= this.rangeVals[i])
- ) {
- return mapToScale(value, [this.rangeVals[i], this.rangeVals[i + 1]], [this.rangeKeys[i], this.rangeKeys[i + 1]], -1, this.getProp('logScale'), true)
- }
- }
-
- }
-
- setValue(v,options={}) {
-
- if (typeof v != 'number') return
- if (
- this.touched &&
- !options.dragged &&
- !options.doubleTap &&
- options.fromScript !== this.hash
- ) return this.setValueTouchedQueue = [v, options]
-
- var value = clip(v,[this.rangeValsMin,this.rangeValsMax])
-
- if ((options.dragged || options.fromLocal) && this.value.toFixed(this.decimals) == value.toFixed(this.decimals)) options.send = false
-
- this.value = value
-
- if (this.steps) {
-
- var diff = this.steps.map(x => Math.abs(x - this.value)),
- index = diff.indexOf(Math.min(...diff)),
- val = this.steps[index]
-
- if (!isNaN(val)) this.value = clip(val, [this.rangeValsMin,this.rangeValsMax])
-
- }
-
- if (!options.dragged || options.fromScript) this.percent = this.valueToPercent(this.value)
-
- this.batchDraw()
-
- if (options.send) this.sendValue()
- if (options.sync) this.changed(options)
-
- }
-
- setSteps() {
-
- if (this.getProp('steps')) {
- var steps = this.getProp('steps')
- if (steps === 'auto') {
- this.steps = this.rangeVals
- } else if (typeof steps === 'number' && Math.round(steps) > 0) {
- steps = Math.round(steps)
- this.steps = Array(steps).fill(0).map((x, i) => i / (steps - 1) * (this.rangeValsMax - this.rangeValsMin) + this.rangeValsMin)
- } else if (Array.isArray(steps) && steps.every(x=>typeof x === 'number')) {
- this.steps = steps
- } else {
- this.steps = null
- }
- } else {
- this.steps = null
- }
-
- }
-
- onPropChanged(propName, options, oldPropValue) {
-
- if (super.onPropChanged(...arguments)) return true
-
- switch (propName) {
-
- case 'steps':
- this.setSteps()
- return
- case 'spring':
- if (this.getProp('spring') && !this.touched) this.setValue(this.getSpringValue(), {...options})
- return
- case 'colorKnob':
- case 'knobSize':
- this.setCssVariables()
- return
-
- }
-
- }
-
- onRemove() {
-
- super.onRemove()
-
- }
-
-}
-
-Slider.dynamicProps = Slider.prototype.constructor.dynamicProps
- .concat([
- 'steps',
- 'spring',
- 'sensitivity',
- 'default',
- 'colorKnob',
- 'knobSize'
- ])
-
-export default Slider
diff --git a/src/client/widgets/utils.mjs b/src/client/widgets/utils.mjs
deleted file mode 100644
index 62482c86..00000000
--- a/src/client/widgets/utils.mjs
+++ /dev/null
@@ -1,156 +0,0 @@
-import balanced from 'balanced-match'
-
-export function clip(value,range) {
-
- value = parseFloat(value)
-
- if (isNaN(value)) value = range[0]
-
- return Math.max(Math.min(range[0], range[1]), Math.min(value, Math.max(range[0], range[1])))
-
-}
-
-// map a value from a scale to another
-// value: number
-// rangeIn: [number, number]
-// rangeOut: [number, number]
-// decimals: number (-1 to bypass)
-// log: true, or manual log scale (max log value)
-// revertLog: boolean
-export function mapToScale(value, rangeIn, rangeOut, decimals, log, revertlog, noClip) {
-
- // clip in
- if (!noClip) {
- value = clip(value,[rangeIn[0], rangeIn[1]])
- }
-
-
- // normalize
- value = (value - rangeIn[0]) / (rangeIn[1] - rangeIn[0])
-
- // log scale
- if (log) {
-
- var logScale = revertlog ? Math.abs(rangeIn[1] - rangeIn[0]) :
- Math.abs(rangeOut[1] - rangeOut[0])
-
- if (log !== true && log !== -1) logScale = Math.abs(log)
- else if (logScale >= 100) logScale /= 10
- else logScale = Math.max(logScale, 10)
-
- if (log < 0) revertlog = !revertlog
-
- value = revertlog ?
- Math.log(value * (logScale - 1) + 1) / Math.log(logScale) :
- Math.pow(logScale, value) / (logScale - 1) - 1 / (logScale - 1)
-
- }
-
- // scale out
- value = value * (rangeOut[1] - rangeOut[0]) + rangeOut[0]
-
- // clip out
- if (!noClip) {
- value = clip(value, [rangeOut[0], rangeOut[1]])
- }
-
- // decimals
- if (decimals !== -1) value = parseFloat(value.toFixed(decimals))
-
- return value
-
-}
-
-export function hsbToRgb(hsb) {
- var rgb = {}
- var h = hsb.h
- var s = hsb.s*255/100
- var v = hsb.b*255/100
- if(s == 0) {
- rgb.r = rgb.g = rgb.b = v
- } else {
- var t1 = v
- var t2 = (255-s)*v/255
- var t3 = (t1-t2)*(h%60)/60
- if(h==360) h = 0
- if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
- else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
- else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
- else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
- else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
- else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
- else {rgb.r=0; rgb.g=0; rgb.b=0}
- }
- return rgb
-}
-
-export function rgbToHsb(rgb) {
- var hsb = {h: 0, s: 0, b: 0}
- var min = Math.min(rgb.r, rgb.g, rgb.b)
- var max = Math.max(rgb.r, rgb.g, rgb.b)
- var delta = max - min
- hsb.b = max
- hsb.s = max != 0 ? 255 * delta / max : 0
- if (hsb.s != 0) {
- if (rgb.r == max) hsb.h = (rgb.g - rgb.b) / delta
- else if (rgb.g == max) hsb.h = 2 + (rgb.b - rgb.r) / delta
- else hsb.h = 4 + (rgb.r - rgb.g) / delta
- } else hsb.h = 0
- hsb.h *= 60
- if (hsb.h < 0) hsb.h += 360
- hsb.s *= 100/255
- hsb.b *= 100/255
- return hsb
-}
-
-
-var urlParser = (()=>{
-
- var parser = document.createElement('a'),
- localUrlRe = /(^127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$)|(^10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$)|(^172\.1[6-9]{1}[0-9]{0,1}\.[0-9]{1,3}\.[0-9]{1,3}$)|(^172\.2[0-9]{1}[0-9]{0,1}\.[0-9]{1,3}\.[0-9]{1,3}$)|(^172\.3[0-1]{1}[0-9]{0,1}\.[0-9]{1,3}\.[0-9]{1,3}$)|(^192\.168\.[0-9]{1,3}\.[0-9]{1,3}$)/
-
- parser.isLocal = ()=>{
- return parser.hostname.match(localUrlRe)
- }
-
- return (url)=>{
- parser.href = url
- return parser
- }
-
-})()
-
-export {urlParser}
-
-export function balancedReplace(tag, open, close, string, replacement) {
-
- var start, lastStart = -1
-
- while ((start = string.indexOf(tag + open)) >= 0 && lastStart !== start) {
-
- var substring = string.slice(start + tag.length),
- b = balanced(open, close, substring)
-
- if (b) {
-
- if (typeof replacement === 'function') {
-
- substring = b.pre + replacement(b.body) + b.post
-
- } else {
-
- substring = b.pre + replacement + b.post
-
- }
-
- string = string.slice(0, start) + substring
-
- }
-
- lastStart = start
-
- }
-
- return string
-
-}
diff --git a/src/client/widgets/vm.mjs b/src/client/widgets/vm.mjs
deleted file mode 100644
index 389dceaa..00000000
--- a/src/client/widgets/vm.mjs
+++ /dev/null
@@ -1,152 +0,0 @@
-import {deepCopy} from '../utils.mjs'
-import {ENV, IP} from '../globals.mjs'
-
-var sessionManager
-setTimeout(async()=>{
- // use setTimeout to fix init order in safari...
- sessionManager = (await import('../managers/session/index.mjs')).default
-})
-
-
-var globals
-
-class Vm {
-
- constructor() {
-
- this.widget = []
-
- if (!globals) {
- globals = {
- screen: {
- get width() {return screen.width},
- get height() {return screen.height},
- get orientation() {
- return (screen.orientation || {}).type || window.orientation
- }
- },
- env: deepCopy(ENV),
- ip: IP,
- url: document.location.host,
- platform: navigator.platform,
- clipboard: navigator.clipboard,
- get session() {
- return sessionManager.sessionPath
- }
- }
- }
-
- this.sandbox = document.createElement('iframe')
- this.sandbox.style.display = 'none'
- this.sandbox.sandbox = 'allow-same-origin'
-
- // attach sandbox
- document.documentElement.appendChild(this.sandbox)
-
- // sandboxed function prototype
- this.safeFunctionProto = this.sandbox.contentWindow.Function
-
- // block requests
- this.sandbox.contentWindow.document.open()
- this.sandbox.contentWindow.document.write(' ')
- this.sandbox.contentWindow.document.close()
-
- // global context
- this.globals = {}
- this.globals.console = {
- ...console,
- log: (...msg)=>{
- msg = msg.map(m => typeof m == 'object' ? JSON.stringify(m, this.jsonReplacer) : m)
- this.getWidget().log(msg.join(' '))
- }
- }
-
- this.globals.setTimeout =
- this.globals.setInterval = ()=>{
- throw 'setTimeout and setInterval can\'t be used in the JS sandbox'
- }
-
- this.registerGlobals()
-
- // detach sandbox
- document.documentElement.removeChild(this.sandbox)
-
- }
-
- setWidget(widget) {
-
- if (!widget) this.widget.pop()
- else this.widget.push(widget)
-
- }
-
- getWidget() {
-
- return this.widget[this.widget.length - 1]
-
- }
-
- registerGlobals() {
-
- this.globals.globals = globals
-
- for (var k in this.globals) {
- this.sandbox.contentWindow[k] = this.globals[k]
- }
-
- }
-
- compile(code, defaultContext) {
-
- if (typeof code !== 'string') code = String(code)
-
- // var contextInit = 'var locals = locals;',
- var contextInit = '"use strict";',
- contextKeys = ['__VARS'],
- contextValues = [{}]
-
- // detached context + reading global navigator == crash electron
- if (code.indexOf('navigator') !== -1) {
- contextInit += 'var navigator;'
- }
-
- if (defaultContext) {
- for (var k in defaultContext) {
- contextInit += `var ${k} = ${k} === undefined ? ${JSON.stringify(defaultContext[k])} : ${k};`
- contextKeys.push(k)
- contextValues.push(defaultContext[k])
- }
- }
-
- code = contextInit + code.replace(/(VAR_[0-9]+)/g, '__VARS.$1')
-
- var compiledCode = new this.safeFunctionProto(...contextKeys, 'locals', code)
-
- return (context, locals)=>{
-
- var __contextValues = deepCopy(contextValues)
- var __VARS = __contextValues[0]
- for (var k in context) {
- var index = contextKeys.indexOf(k)
- if (index !== -1) {
- __contextValues[index] = context[k]
- } else {
- __VARS[k] = context[k]
- }
- }
-
- __contextValues.push(locals)
-
- return compiledCode.apply('this', __contextValues)
-
- }
-
- }
-
- jsonReplacer(key, value) {
- return value instanceof HTMLElement ? `<${value.tagName}#${value.id}>` : value
- }
-
-}
-
-export default Vm
diff --git a/src/docs/client-shim.mjs b/src/docs/client-shim.mjs
deleted file mode 100644
index dc87e8ca..00000000
--- a/src/docs/client-shim.mjs
+++ /dev/null
@@ -1,92 +0,0 @@
-// Dirty browser window shim
-import * as DOM from '../client/dom.mjs'
-
-// eslint-disable-next-line no-global-assign
-document = {
- createElement: x=>({
- ownerDocument: document,
- addEventListener: ()=>{},
- style: {setProperty: ()=>{}},
- nodeName: '',
- childNodes: [],
- setAttribute: ()=>{},
- appendChild: ()=>{},
- lastChild: {},
- toString: ()=>' ',
- removeChild: ()=>{},
- getPropertyValue: ()=>{},
- contentWindow: {
- document: {
- open: ()=>{},
- close: ()=>{},
- write: ()=>{},
- }
- },
- }),
- getElementById: ()=>document.createElement(),
- createTextNode: x=>({
- nodeValue: '',
- nodeName: '',
- childNodes: [],
- setAttribute: ()=>{},
- appendChild: ()=>{},
- lastChild: {},
- toString: ()=>' '
- }),
- createElementNS: x=>[],
- addEventListener: ()=>{},
- createRange: ()=>{
- return {
- createContextualFragment:()=>{return {
- firstChild: {
- querySelectorAll: x=>[]
- }
- }},
- selectNode: ()=>{}
- }
- },
- body: {
- appendChild: ()=>{},
- addEventListener: ()=>{}
- },
- location: {search: ''},
-}
-document.documentElement = document.createElement()
-
-// eslint-disable-next-line no-global-assign
-window = {
- screen: {width: 800, height: 600},
- addEventListener: ()=>{},
- location: {search: ''},
- Image: Function,
- document: document,
- NodeList: Array,
- WebSocket: Object,
- localStorage: {
- getItem(){return null}
- },
- sessionStorage: {
- getItem(){return null},
- setItem(){},
- },
- getComputedStyle: ()=>document.createElement(),
- MutationObserver: class MutationObserver{},
- ELECTRON_NOGPU: false,
- CANVAS_FRAMERATE: 1,
- LANG: 'en',
- ENV: {id: ''},
- IP: '',
- DOM
-}
-
-if (!global.navigator) {
- // defined as getter since node 22
- window.navigator = {
- platform:'',
- userAgent: ''
- }
-}
-
-Object.assign(global, window)
-
-console.debug = ()=>{}
diff --git a/src/docs/widgets-reference.mjs b/src/docs/widgets-reference.mjs
deleted file mode 100644
index d4178ff3..00000000
--- a/src/docs/widgets-reference.mjs
+++ /dev/null
@@ -1,120 +0,0 @@
-import './client-shim.mjs'
-import baseClass from '../client/widgets/common/widget.mjs'
-import * as widgets from '../client/widgets/index.mjs'
-
-// Here we go
-var base = baseClass.defaults(),
- doc = ['']
-
-
-doc.push(`
-
-## Common
-
-??? api "Generic properties
"
- Properties shared by all widgets
-
- `
-)
-
-for (let categoryName in base) {
- doc.push(`\n
-
- === "${categoryName}"
-
- | property | type |default | description |
- | --- | --- | --- | --- |`
- )
- let notEmpty = false
-
- for (let propName in base[categoryName]) {
-
- let prop = base[categoryName][propName],
- permalink = propName
-
- if (propName === '_props' || propName[0] === '_') continue
-
- let help = Array.isArray(prop.help) ? prop.help.join(' ').replace(/ -/g, '-') : prop.help || '',
- dynamic = baseClass.dynamicProps.includes(propName) ? ' ' : ''
-
- if (prop.choices) {
- if (help) help += ' '
- help += 'Choices: ' + prop.choices.map(x=>'`' + x + '`').join(', ')
- }
-
- doc.push(`
- | ${propName}${dynamic} | \`${prop.type.replace(/\|/g,'\`| \`')}\` | ${(JSON.stringify(prop.value, null, ' ') || '').replace(/\n/g,' ').replace('{','\\{')} | ${help} |`
- )
- notEmpty = true
-
- }
- if (!notEmpty) doc.pop()
-
-}
-
-for (var k in widgets.categories) {
- var category = widgets.categories[k]
- if (k == 'Containers') {
- category.push('root')
- category.push('tab')
- }
-
- doc.push(`
-## ${k}`
- )
-
- for (var kk in category) {
- var type = category[kk],
- defaults = widgets.widgets[type].defaults(),
- description = widgets.widgets[type].description()
-
- doc.push(`
-
-??? api "${type}
"
- ${description}`
-
- )
-
- for (let categoryName in defaults) {
- doc.push(`\n
- === "${categoryName == 'class_specific' ? type : categoryName}"
-
- | property | type |default | description |
- | --- | --- | --- | --- |`
- )
- let notEmpty = false
-
- for (let propName in defaults[categoryName]) {
-
- let prop = defaults[categoryName][propName],
- permalink = type + '_' + propName
-
-
- if (propName === '_props' || propName[0] === '_' || JSON.stringify(prop) == JSON.stringify((base[categoryName]||{})[propName])) continue
-
- let help = Array.isArray(prop.help) ? prop.help.join(' ').replace(/ -/g, '-') : prop.help || '',
- dynamic = widgets.widgets[type].dynamicProps.includes(propName) ? ' ' : ''
-
- if (prop.choices) {
- if (help) help += ' '
- help += 'Choices: ' + prop.choices.map(x=>'`' + x + '`').join(', ')
- }
- doc.push(`
- | ${propName}${dynamic} | \`${prop.type.replace(/\|/g,'\`| \`')}\` | ${(JSON.stringify(prop.value, null, ' ') || '').replace(/\n/g,' ').replace('{','\\{')} | ${help} |`
- )
- notEmpty = true
- }
-
- if (!notEmpty) doc.pop()
-
-
-
- }
-
-
- }
-}
-
-console.log(doc.join(''))
-
-process.exit(0) // avoid setTimeout errors in required modules
diff --git a/src/html/client.html b/src/html/client.html
deleted file mode 100644
index 48ea3ece..00000000
--- a/src/html/client.html
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/html/launcher.html b/src/html/launcher.html
deleted file mode 100644
index 6945d250..00000000
--- a/src/html/launcher.html
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/index.js b/src/index.js
deleted file mode 100644
index 3680c66b..00000000
--- a/src/index.js
+++ /dev/null
@@ -1 +0,0 @@
-require('./server/')
diff --git a/src/launcher/index.mjs b/src/launcher/index.mjs
deleted file mode 100644
index 745bd104..00000000
--- a/src/launcher/index.mjs
+++ /dev/null
@@ -1,5 +0,0 @@
-import '../client/globals.mjs'
-import '../client/events/event-emitter.mjs'
-import '../client/ui/ui-workspace.mjs'
-import '../client/ui/zoom.mjs'
-import './main.mjs'
diff --git a/src/launcher/main.mjs b/src/launcher/main.mjs
deleted file mode 100644
index 2dcdeaac..00000000
--- a/src/launcher/main.mjs
+++ /dev/null
@@ -1,47 +0,0 @@
-import html from 'nanohtml'
-import semver from 'semver'
-import {ipcRenderer} from 'electron'
-import terminal from './terminal.mjs'
-import settings from './settings.mjs'
-import './toolbar.mjs'
-import {DOM, PACKAGE} from '../client/globals.mjs'
-
-DOM.get(document, '#osc-greeting-header')[0].appendChild(html`${PACKAGE.productName} v${PACKAGE.version} `)
-
-if (settings.remote.read('checkForUpdates') && navigator.onLine) {
-
- var request = new XMLHttpRequest()
- request.open('GET', 'https://framagit.org/api/v4/projects/jean-emmanuel%2Fopen-stage-control/releases', true)
-
- request.onload = function() {
- if (request.status >= 200 && request.status < 400) {
-
- var data = JSON.parse(request.responseText).filter(x=>!x.name.match(/alpha|beta/)),
- current = 'v' + PACKAGE.version,
- latest = data[0].name
-
- if (semver.gt(latest, current)) {
- terminal.log(`(INFO) A new version is available : ${latest} `, 'info')
- } else if (semver.gt(current, latest)) {
- terminal.log(`(WARNING) Using development version ${current}`, 'warning')
- }
-
- }
- }
-
- request.send()
-
-}
-
-if (settings.remote.read('alwaysOnTop')) {
-
- settings.remote.getCurrentWindow().setAlwaysOnTop(true)
-
-}
-
-
-if (settings.remote.read('autoStart')) {
-
- ipcRenderer.send('start')
-
-}
diff --git a/src/launcher/settings.mjs b/src/launcher/settings.mjs
deleted file mode 100644
index 61a62073..00000000
--- a/src/launcher/settings.mjs
+++ /dev/null
@@ -1,264 +0,0 @@
-import html from 'nanohtml'
-import raw from 'nanohtml/raw'
-import {ipcRenderer} from 'electron'
-import remote from '@electron/remote'
-import {icon} from '../client/ui/utils.mjs'
-import terminal from './terminal.mjs'
-import {DOM} from '../client/globals.mjs'
-
-var {dialog} = remote.require('electron'),
- fs = remote.require('fs'),
- {settings} = remote.getGlobal('launcherSharedGlobals'),
- options_remote = settings.read('options')
-
-class Settings {
-
- constructor() {
-
- this.remote = settings
- this.container = DOM.get('#osc-container')[0].appendChild(html` `)
- this.names = []
- this.options = {}
- this.configPath = null
- for (var i in options_remote) {
- this.options[i] = options_remote[i]
- }
-
- this.create()
- this.write(true)
-
- ipcRenderer.on('server-starting', ()=>{
- this.disable()
- })
- ipcRenderer.on('server-stopped', ()=>{
- this.enable()
- })
-
- }
-
- save() {
-
- if (!this.configPath) return this.saveAs()
- fs.writeFile(this.configPath, JSON.stringify(this.options), (err, fdata)=>{
-
- if (err) console.error(err)
- else terminal.log('(INFO) Config saved in ' + this.configPath)
-
- })
-
- }
-
- saveAs() {
-
- dialog.showSaveDialog({
- title: 'Open File',
- filters:[{name: 'OSC Config (.config)', extensions: ['config']}],
- properties: ['openFile']
- }).then((file)=>{
- if (file.canceled || !file.filePath) return
- this.configPath = file.filePath
- if (this.configPath.split('.').pop() !== 'config') this.configPath += '.config'
- this.save()
- })
-
- }
-
- load() {
-
- dialog.showOpenDialog({
- title: 'Open File',
- filters:[{name: 'OSC Config (.config)', extensions: ['config']}],
- properties: ['openFile']
- }).then((file)=>{
- if (file.canceled || !file.filePaths.length) return
- this.options = JSON.parse(fs.readFileSync(file.filePaths[0], 'utf-8'))
- this.create()
- this.write()
- terminal.log('(INFO) Config loaded from ' + file.filePaths[0])
- this.configPath = file.filePaths[0]
- })
-
- }
-
-
- write(tmp) {
-
- for (var i in this.options) {
- if (this.options[i] === '' || !this.names.includes(i)) {
- delete this.options[i]
- }
- }
-
- settings.write('options', this.options, tmp)
-
- }
-
-
- create() {
-
- this.container.innerHTML = ''
-
- for (let k in settings.options) {
-
- if (settings.options[k].launcher === false) continue
-
- let data = settings.options[k],
- name = data.alias || k,
- field = html` `,
- label = field.appendChild(html`${name} `),
- input = field.appendChild(html` `),
- toggle, browse, reset
-
- this.names.push(name)
-
- let value = this.options[name] === undefined ? '' : this.options[name],
- strValue = Array.isArray(value) ? value.map(x=>x.includes(' ') ? '"'+x+'"' : x).join(' ') : value
-
-
- label.addEventListener('click', (e)=>{
- terminal.log(`(HELP) --${name}: ${data.describe}`, 'help')
- })
-
- if (data.type === 'boolean') {
-
- toggle = field.appendChild(html`
- ${raw(icon('check'))}
- `)
- toggle.addEventListener('click', (e)=>{
- input.value = toggle.classList.toggle('on')
- DOM.dispatchEvent(input, 'change')
- })
-
- }
-
- if (data.file) {
-
- browse = field.appendChild(html`
- ${raw(icon('folder-open'))}
- `)
-
- browse.addEventListener('click', (e)=>{
- e.preventDefault()
- dialog.showOpenDialog({
- title: 'Open ' + (data.file.folder ? 'folder' : 'file'),
- filters:[{name: data.file.name, extensions: data.file.extensions}],
- properties: data.file.folder ? ['openDirectory'] : ['openFile']
- }).then((file)=>{
- input.value = file.filePaths
- DOM.dispatchEvent(input, 'change')
- })
- })
-
- field.addEventListener('drop', (e) => {
- e.preventDefault()
- e.stopPropagation()
- let paths = []
- for (var f of event.dataTransfer.files) {
- if (f.path.includes(' ')) {
- paths.push('"' + f.path + '"')
- } else {
- paths.push(f.path)
- }
- }
- input.value = paths.join(' ')
- DOM.dispatchEvent(input, 'change')
- })
-
- }
-
- reset = field.appendChild(html`
- ${raw(icon('times'))}
- `)
- reset.addEventListener('click', ()=>{
- input.value = ''
- DOM.dispatchEvent(input, 'change')
- })
-
- input.value = strValue
-
- this.container.appendChild(field)
-
- input.addEventListener('change', (e)=>{
- let v = input.value.trim(),
- fail = false
-
- try {
- if (data.type == 'boolean') {
- v = v && v !== 'false' ? true : ''
- input.value = v
- toggle.classList.toggle('on', v)
- } else if (v && data.type === 'array'){
- v = v.replace(/("[^"]*"|'[^']*')/g, (m)=>{
- return m.substr(1, m.length - 2).replace(/\s/g, '_SPaCE_')
- })
- v = v.split(' ')
- v = v.map(x=>x.replace(/_SPaCE_/g, ' '))
- } else if (v && data.type == 'number'){
- v = parseFloat(v)
- }
- } catch (err) {
- fail = err
- }
-
- if (fail || v !== '' && data.check && data.check(v, this.options) !== true) {
- let error = `(ERROR) --${name}: ${fail || data.check(v, this.options)}`
- field.classList.add('error')
- if (field.getAttribute('data-error') !== error) {
- terminal.log(error, 'error')
- field.setAttribute('data-error', error)
- }
- } else {
- field.classList.remove('error')
- field.removeAttribute('data-error')
- this.options[name] = v
- }
-
- if (data.restart && !field.classList.contains('restart') && v != value) {
- field.classList.add('restart')
- field.classList.add('warning')
- terminal.log(`(WARNING) --${name}: The launcher must be restarted for this change to take effect.`, 'warning')
- } else if (data.restart && field.classList.contains('restart') && v == value) {
- field.classList.remove('restart')
- field.classList.remove('warning')
- }
-
-
- if (!e.detail || !e.detail.stop) {
- DOM.each(this.container, 'input', (el)=>{
- if (el === input) return
- DOM.dispatchEvent(el, 'change', {stop: true})
- })
- this.write()
- }
-
- })
-
- }
-
- DOM.each(this.container, 'input', (el)=>{
- DOM.dispatchEvent(el, 'change', {stop: true})
- })
-
- }
-
- disable() {
-
- this.container.classList.add('disabled')
- DOM.each(this.container, 'input', (el)=>{
- el.setAttribute('disabled', true)
- })
-
- }
-
- enable() {
-
- this.container.classList.remove('disabled')
- DOM.each(this.container, 'input', (el)=>{
- el.removeAttribute('disabled')
- })
-
- }
-
-}
-
-export default new Settings()
diff --git a/src/launcher/terminal.mjs b/src/launcher/terminal.mjs
deleted file mode 100644
index 9c382675..00000000
--- a/src/launcher/terminal.mjs
+++ /dev/null
@@ -1,73 +0,0 @@
-import {ipcRenderer} from 'electron'
-import ansiHTML from 'ansi-html'
-import html from 'nanohtml'
-import {DOM} from '../client/globals.mjs'
-
-ansiHTML.setColors({
- magenta: 'B48EAD',
- cyan: '81A1C1',
-})
-
-class Terminal {
-
- constructor(options) {
-
- this.content = DOM.get(options.selector)[0]
- this.autoSroll = true
- this.length = 0
- this.maxLength = 500
-
- ipcRenderer.on('stdout', (e, msg)=>{
- this.log(ansiHTML(msg), 'log')
- })
-
- ipcRenderer.on('stderr', (e, msg)=>{
- if (msg.includes('\n at') && msg.split('\n at').length > 2) {
- msg = msg.replace('\n at', ''
- }
- this.log(ansiHTML(msg), 'error')
- })
-
- this.content.addEventListener('click', (e)=>{
- if (e.target.classList.contains('trace-button')) {
- e.target.parentNode.classList.toggle('show')
- }
- })
-
- }
-
- log(message, iclass = '') {
-
- var node = html`
`
- node.innerHTML = message
-
- this.content.appendChild(node)
-
- if (++this.length > this.maxLength) this.purge()
-
- if (this.autoSroll) {
- node.scrollIntoView()
- }
-
- }
-
- purge() {
-
- var children = [...this.content.children]
- for (var i = 0; i < this.maxLength / 2; i++) {
- this.content.removeChild(children[i])
- }
- this.length = this.maxLength / 2 + 1
-
- }
-
- clear() {
-
- this.content.innerHTML = ''
- this.length = 0
-
- }
-
-}
-
-export default new Terminal({selector: '#osc-terminal'})
diff --git a/src/launcher/toolbar.mjs b/src/launcher/toolbar.mjs
deleted file mode 100644
index a6677b4d..00000000
--- a/src/launcher/toolbar.mjs
+++ /dev/null
@@ -1,253 +0,0 @@
-import {ipcRenderer} from 'electron'
-import remote from '@electron/remote'
-import keyboardJS from 'keyboardjs/dist/keyboard.min.js'
-import terminal from './terminal.mjs'
-import settings from './settings.mjs'
-import {DOM, PXSCALE} from '../client/globals.mjs'
-
-
-
-var {Menu, MenuItem} = remote.require('electron'),
- menu = new Menu(),
- {midiList, midiRestart, openDocs} = remote.getGlobal('launcherSharedGlobals'),
- serverStarting = false,
- serverStart = ()=>{
- if (serverStarting) return
- ipcRenderer.send('start')
- },
- serverStop = ()=>{
- if (!serverStarting) return
- ipcRenderer.send('stop')
- },
- showQRCode = ()=>{
- ipcRenderer.send('showQRCode')
- }
-
-var start = new MenuItem({
- label: 'Start',
- click: serverStart,
- accelerator: 'f5'
-})
-var stop = new MenuItem({
- label: 'Stop',
- click: serverStop,
- accelerator: 'f6'
-})
-var qrcode = new MenuItem({
- label: 'Show QR code',
- click: showQRCode,
- accelerator: 'f7'
-})
-var newWindow = new MenuItem({
- label: 'New window',
- visible: false,
- click: ()=>{
- ipcRenderer.send('openClient')
- },
- accelerator: 'CmdOrCtrl + n'
-})
-menu.append(start)
-menu.append(stop)
-menu.append(qrcode)
-menu.append(newWindow)
-menu.append(new MenuItem({
- type: 'separator'
-}))
-menu.append(new MenuItem({
- label: 'Load',
- click: ()=>{
- settings.load()
- },
- accelerator: 'CmdOrCtrl + o'
-}))
-menu.append(new MenuItem({
- label: 'Save',
- click: ()=>{
- settings.save()
- },
- accelerator: 'CmdOrCtrl + s'
-}))
-menu.append(new MenuItem({
- label: 'Save as...',
- click: ()=>{
- settings.saveAs()
- },
- accelerator: 'CmdOrCtrl + shift + s'
-}))
-menu.append(new MenuItem({
- type: 'separator'
-}))
-
-menu.append(new MenuItem({type: 'submenu' , label: 'MIDI', submenu: [
- new MenuItem({
- label: 'List devices',
- click: ()=>{
- midiList()
- },
- accelerator: 'ctrl + m'
- }),
- new MenuItem({
- label: 'Restart backend',
- id: 'midiRestart',
- click: ()=>{
- midiRestart()
- },
- enabled: false
- }),
-
-]}))
-menu.append(new MenuItem({type: 'submenu' , label: 'Console', submenu: [
- new MenuItem({
- label: 'Clear',
- click: ()=>{
- terminal.clear()
- },
- accelerator: 'CmdOrCtrl + l'
- }),
- new MenuItem({
- label: 'Autoscroll',
- type: 'checkbox',
- checked: true,
- click: function(e){
- terminal.autoSroll = e.checked
- }
- }),
- new MenuItem({
- label: 'Check for updates at startup',
- type: 'checkbox',
- checked: settings.remote.read('checkForUpdates'),
- click: (e)=>{
- settings.remote.write('checkForUpdates', e.checked)
- }
- })
-]}))
-menu.append(new MenuItem({type: 'submenu' , label: 'Launcher', submenu: [
- new MenuItem({
- label: 'Autostart',
- type: 'checkbox',
- checked: settings.remote.read('autoStart'),
- click: (e)=>{
- settings.remote.write('autoStart', e.checked)
- remote.getCurrentWindow().setAlwaysOnTop(e.checked)
- }
- }),
- new MenuItem({
- label: 'Always on top',
- type: 'checkbox',
- checked: settings.remote.read('alwaysOnTop'),
- click: (e)=>{
- settings.remote.write('alwaysOnTop', e.checked)
- remote.getCurrentWindow().setAlwaysOnTop(e.checked)
- }
- }),
- new MenuItem({
- label: 'Use tray icon',
- type: 'checkbox',
- checked: settings.remote.read('useTray'),
- click: (e)=>{
- settings.remote.write('useTray', e.checked)
- }
- }),
- new MenuItem({
- label: 'Start minimized',
- type: 'checkbox',
- checked: settings.remote.read('startMinimized'),
- click: (e)=>{
- settings.remote.write('startMinimized', e.checked)
- }
- }),
-]}))
-menu.append(new MenuItem({
- type: 'separator'
-}))
-// menu.append(new MenuItem({
-// label: 'Restart',
-// click: ()=>{
-// app.relaunch()
-// app.exit(0)
-// }
-// }))
-menu.append(new MenuItem({
- label: 'Documentation',
- click: ()=>{
- openDocs()
- }
-}))
-
-if (settings.remote.read('useTray')) {
- menu.append(new MenuItem({
- label: 'Hide',
- click: ()=>{
- ipcRenderer.send('hide')
- }
- }))
-}
-
-menu.append(new MenuItem({
- role: 'Quit'
-}))
-
-
-function bindShortcuts(menu) {
-
- for (let m of menu.items) {
-
- if (m.type === 'submenu') {
-
- bindShortcuts(m.submenu)
-
- } else if (m.accelerator && m.click) {
-
- keyboardJS.bind(m.accelerator.replace('CmdOrCtrl', 'mod'), (e)=>{
- m.click()
- })
-
- }
-
- }
-
-}
-
-bindShortcuts(menu)
-
-class Toolbar {
-
- constructor() {
-
- this.container = DOM.get('osc-toolbar#menu')[0]
- this.startButton = DOM.get('osc-toolbar#start')[0]
-
- this.container.addEventListener('click', (e)=>{
- this.container.classList.add('on')
- start.visible = !serverStarting
- stop.visible = !!serverStarting
- qrcode.visible = !!serverStarting
- newWindow.visible = !!serverStarting
- menu.getMenuItemById('midiRestart').enabled = !!serverStarting
-
- menu.popup({window: remote.getCurrentWindow(), x: parseInt(PXSCALE), y: parseInt(40 * PXSCALE)})
- })
-
- menu.on('menu-will-close', ()=>{
- this.container.classList.remove('on')
- })
-
- this.startButton.addEventListener('click', (e)=>{
- if (!serverStarting) serverStart()
- else serverStop()
- })
-
- ipcRenderer.on('server-starting', ()=>{
- serverStarting = true
- this.startButton.classList.add('started')
- })
- ipcRenderer.on('server-stopped', ()=>{
- serverStarting = false
- this.startButton.classList.remove('started')
- })
-
- }
-
-}
-
-export default new Toolbar()
diff --git a/src/scss/colors/nord.scss b/src/scss/colors/nord.scss
deleted file mode 100644
index 488b8fa4..00000000
--- a/src/scss/colors/nord.scss
+++ /dev/null
@@ -1,235 +0,0 @@
-// Copyright (c) 2016-present Arctic Ice Studio
-// Copyright (c) 2016-present Sven Greb
-
-// Project: Nord
-// Version: 0.2.0
-// Repository: https://github.com/arcticicestudio/nord
-// License: MIT
-// References:
-// http://sass-lang.com
-// http://sassdoc.com
-
-////
-/// An arctic, north-bluish color palette.
-/// Created for the clean- and minimal flat design pattern to achieve a optimal focus and readability for code syntax
-/// highlighting and UI.
-/// It consists of a total of sixteen, carefully selected, dimmed pastel colors for a eye-comfortable, but yet colorful
-/// ambiance.
-///
-/// @author Arctic Ice Studio
-////
-
-/// Base component color of "Polar Night".
-///
-/// Used for texts, backgrounds, carets and structuring characters like curly- and square brackets.
-///
-/// @access public
-/// @example scss - SCSS
-/// /* For dark ambiance themes */
-/// .background {
-/// background-color: $nord0;
-/// }
-/// /* For light ambiance themes */
-/// .text {
-/// color: $nord0;
-/// }
-/// @group polarnight
-/// @since 0.1.0
-$nord0: #2e3440;
-
-/// Lighter shade color of the base component color.
-///
-/// Used as a lighter background color for UI elements like status bars.
-///
-/// @access public
-/// @group polarnight
-/// @see $nord0
-/// @since 0.1.0
-$nord1: #3b4252;
-
-/// Lighter shade color of the base component color.
-///
-/// Used as line highlighting in the editor.
-/// In the UI scope it may be used as selection- and highlight color.
-///
-/// @access public
-/// @example scss - SCSS
-/// /* Code Syntax Highlighting scope */
-/// .editor {
-/// &.line {
-/// background-color: $nord2;
-/// }
-/// }
-///
-/// /* UI scope */
-/// button {
-/// &:selected {
-/// background-color: $nord2;
-/// }
-/// }
-/// @group polarnight
-/// @see $nord0
-/// @since 0.1.0
-$nord2: #434c5e;
-
-/// Lighter shade color of the base component color.
-///
-/// Used for comments, invisibles, indent- and wrap guide marker.
-/// In the UI scope used as pseudoclass color for disabled elements.
-///
-/// @access public
-/// @example scss - SCSS
-/// /* Code Syntax Highlighting scope */
-/// .editor {
-/// &.indent-guide,
-/// &.wrap-guide {
-/// &.marker {
-/// color: $nord3;
-/// }
-/// }
-/// }
-/// .comment,
-/// .invisible {
-/// color: $nord3;
-/// }
-///
-/// /* UI scope */
-/// button {
-/// &:disabled {
-/// background-color: $nord3;
-/// }
-/// }
-/// @group polarnight
-/// @see $nord0
-/// @since 0.1.0
-$nord3: #4c566a;
-
-/// Base component color of "Snow Storm".
-///
-/// Main color for text, variables, constants and attributes.
-/// In the UI scope used as semi-light background depending on the theme shading design.
-///
-/// @access public
-/// @example scss - SCSS
-/// /* For light ambiance themes */
-/// .background {
-/// background-color: $nord4;
-/// }
-/// /* For dark ambiance themes */
-/// .text {
-/// color: $nord4;
-/// }
-/// @group snowstorm
-/// @since 0.1.0
-$nord4: #d8dee9;
-
-/// Lighter shade color of the base component color.
-///
-/// Used as a lighter background color for UI elements like status bars.
-/// Used as semi-light background depending on the theme shading design.
-///
-/// @access public
-/// @group snowstorm
-/// @see $nord4
-/// @since 0.1.0
-$nord5: #e5e9f0;
-
-/// Lighter shade color of the base component color.
-///
-/// Used for punctuations, carets and structuring characters like curly- and square brackets.
-/// In the UI scope used as background, selection- and highlight color depending on the theme shading design.
-///
-/// @access public
-/// @group snowstorm
-/// @see $nord4
-/// @since 0.1.0
-$nord6: #eceff4;
-
-/// Bluish core color.
-///
-/// Used for classes, types and documentation tags.
-///
-/// @access public
-/// @group frost
-/// @since 0.1.0
-$nord7: #8fbcbb;
-
-/// Bluish core accent color.
-///
-/// Represents the accent color of the color palette.
-/// Main color for primary UI elements and methods/functions.
-///
-/// Can be used for
-/// - Markup quotes
-/// - Markup link URLs
-///
-/// @access public
-/// @group frost
-/// @since 0.1.0
-$nord8: #88c0d0;
-
-/// Bluish core color.
-///
-/// Used for language-specific syntactic/reserved support characters and keywords, operators, tags, units and
-/// punctuations like (semi)colons,commas and braces.
-///
-/// @access public
-/// @group frost
-/// @since 0.1.0
-$nord9: #81a1c1;
-
-/// Bluish core color.
-///
-/// Used for markup doctypes, import/include/require statements, pre-processor statements and at-rules (`@`).
-///
-/// @access public
-/// @group frost
-/// @since 0.1.0
-$nord10: #5e81ac;
-
-/// Colorful component color.
-///
-/// Used for errors, git/diff deletion and linter marker.
-///
-/// @access public
-/// @group aurora
-/// @since 0.1.0
-$nord11: #bf616a;
-
-/// Colorful component color.
-///
-/// Used for annotations.
-///
-/// @access public
-/// @group aurora
-/// @since 0.1.0
-$nord12: #d08770;
-
-/// Colorful component color.
-///
-/// Used for escape characters, regular expressions and markup entities.
-/// In the UI scope used for warnings and git/diff renamings.
-///
-/// @access public
-/// @group aurora
-/// @since 0.1.0
-$nord13: #ebcb8b;
-
-/// Colorful component color.
-///
-/// Main color for strings and attribute values.
-/// In the UI scope used for git/diff additions and success visualizations.
-///
-/// @access public
-/// @group aurora
-/// @since 0.1.0
-$nord14: #a3be8c;
-
-/// Colorful component color.
-///
-/// Used for numbers.
-///
-/// @access public
-/// @group aurora
-/// @since 0.1.0
-$nord15: #b48ead;
diff --git a/src/scss/index.scss b/src/scss/index.scss
deleted file mode 100644
index 6bb35dec..00000000
--- a/src/scss/index.scss
+++ /dev/null
@@ -1,99 +0,0 @@
-@import 'reset';
-@import 'mixins';
-@import 'themes/default';
-@import 'ui';
-@import 'widgets';
-
-
-input,
-textarea,
-{
- caret-color: var(--color-widget);
-}
-
-input:focus::selection,
-textarea:focus::selection,
-{
- background:var(--color-widget);
- color: var(--color-text);
-}
-input {
- cursor: text;
-}
-
-
-
-
-.fa {
- font-weight: 900;
-}
-
-html, body {
-
- position: absolute;
- top:0;
- left:0;
- right:0;
- bottom:0;
-
- overflow:hidden;
- overscroll-behavior: none;
- background-color: var(--color-background);
-}
-
-html{
- // global pixel scaling
- font-size: 1px;
-
- // prevent android's auto font-resize
- max-height: 999999px;
-
- // prevent pinch-zoom
- touch-action:none;
-}
-
-body {
- color: var(--color-text);
- white-space:nowrap;
- opacity:1;
- cursor: default;
- font-family: $font;
- font-size:11rem;
- line-height:100%;
- font-weight: 400;
- // text-transform: uppercase;
- letter-spacing: 1rem;
- text-rendering: optimizeSpeed;
-
-}
-
-
-.error-stack {
- > span {
- background: none!important;
- color: inherit!important;
- }
- padding:10rem;
- user-select:text;
- cursor: text;
- * {
- user-select:text;
- cursor: text;
- }
- overflow:auto;
- white-space:pre;
- font-family: $font-mono;
- font-weight:bold;
-}
-
-.translation-missing {
- color: #ff00ff;
-}
-
-.fa-osc:before {
- content:"\f111";
- color: transparent;
- background-image: url(../assets/favicon.png?__OSC_ASSET__=1);
- background-size: contain;
- background-repeat: no-repeat;
-}
diff --git a/src/scss/mixins.scss b/src/scss/mixins.scss
deleted file mode 100644
index 5de3094e..00000000
--- a/src/scss/mixins.scss
+++ /dev/null
@@ -1,32 +0,0 @@
-@mixin pseudo-stroke($z: 0) {
- &:before {
- content:"";
- position: absolute;
- border: var(--line-width) solid var(--color-stroke);
- opacity: var(--alpha-stroke);
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- pointer-events: none;
- z-index: $z;
- border-radius: inherit;
- }
-}
-
-@mixin pseudo-fill($z: 0) {
- &:after {
- content:"";
- position: absolute;
- background: var(--color-fill);
- opacity: var(--alpha-fill);
- top: var(--line-width);
- left: var(--line-width);
- right: var(--line-width);
- bottom: var(--line-width);
- pointer-events: none;
- margin: var(--widget-padding);
- z-index: $z;
- border-radius: inherit;
- }
-}
diff --git a/src/scss/themes/default.scss b/src/scss/themes/default.scss
deleted file mode 100644
index 1001ec15..00000000
--- a/src/scss/themes/default.scss
+++ /dev/null
@@ -1,42 +0,0 @@
-$font: 'Roboto';
-$font-mono: 'Roboto Mono';
-$font-menu: sans-serif;
-
-
-@import '../colors/nord';
-
-:root {
-
- --nav-height: 40rem;
- --grid-width: 10;
-
-
- --color-background: #21252b;
- --color-ui-foreground: hsl(219, 14%, 23%);
- --color-ui-background: hsl(217, 14%, 19%);
- --color-ui-button: #{$nord1};
- --color-accent: #6db5fd;
-
- --color-text: #{$nord4};
- --color-text-solid: #{$nord6};
-
-
- --color-accent: #6db5fd;
- --color-error: #{$nord11};
- --color-warning: #{$nord13};
- --color-success: #{$nord14};
-
- --color-context-menu: #{$nord6};
- --color-context-menu-text: #{$nord1};
-
-
- --line-width: 1rem;
-
- --alpha-scrollbar: 0.25;
- --alpha-scrollbar-on: 0.75;
-
- --color-grid: rgba(0,0,0, 0.1);
- --color-notification: #{rgba(black, 0.8)};
- --color-widget: var(--color-accent);
-
-}
diff --git a/src/scss/themes/nord.scss b/src/scss/themes/nord.scss
deleted file mode 100644
index 4615906e..00000000
--- a/src/scss/themes/nord.scss
+++ /dev/null
@@ -1,9 +0,0 @@
-@import 'default';
-
-:root {
- --color-background: #{$nord0};
- --color-ui-foreground: #{$nord2};
- --color-ui-background: #{$nord1};
- --color-ui-button: #{$nord3};
- --color-accent: #{$nord8};
-}
diff --git a/src/scss/themes/orange.scss b/src/scss/themes/orange.scss
deleted file mode 100644
index 712e486e..00000000
--- a/src/scss/themes/orange.scss
+++ /dev/null
@@ -1,9 +0,0 @@
-@import 'default';
-
-:root {
- --color-background: #404040;
- --color-ui-foreground: #505050;
- --color-ui-background: #4A4A4A;
- --color-ui-button: #606060;
- --color-accent: #d98533;
-}
diff --git a/src/scss/ui.scss b/src/scss/ui.scss
deleted file mode 100644
index 107ca9d5..00000000
--- a/src/scss/ui.scss
+++ /dev/null
@@ -1,17 +0,0 @@
-@import 'ui/button';
-@import 'ui/scrollbars';
-@import 'ui/workspaces';
-@import 'ui/notifications';
-@import 'ui/grid';
-@import 'ui/inspector';
-@import 'ui/console';
-@import 'ui/tree';
-@import 'ui/dragresize';
-@import 'ui/selectarea';
-@import 'ui/contextmenu';
-@import 'ui/modal';
-@import 'ui/filebrowser';
-@import 'ui/loading';
-@import 'ui/toolbar';
-@import 'ui/launcher';
-@import 'ui/keyboard';
diff --git a/src/scss/ui/button.scss b/src/scss/ui/button.scss
deleted file mode 100644
index 2f2bb9be..00000000
--- a/src/scss/ui/button.scss
+++ /dev/null
@@ -1,20 +0,0 @@
-.btn {
- background: var(--color-ui-button);
- border: 1rem solid var(--color-background);
- display: block;
- padding: 0 15rem;
- position: relative;
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
- text-align: center;
- padding-top: 1rem;
- cursor: pointer;
- &.disabled {
- pointer-events: none;
- opacity: 0.5;
- }
- &.active {
- color: var(--color-accent)
- }
-}
diff --git a/src/scss/ui/console.scss b/src/scss/ui/console.scss
deleted file mode 100644
index 492f8e60..00000000
--- a/src/scss/ui/console.scss
+++ /dev/null
@@ -1,196 +0,0 @@
-$padding: 8rem;
-
-#osc-console {
- background: var(--color-background);
- osc-panel-header {
- background: var(--color-ui-foreground);
- border-top: 1rem solid var(--color-background);
- }
- .toggle-button {
- border-bottom: none;
- }
-
- display: flex;
- position: relative;
- flex-direction: column;
- ::-webkit-scrollbar-thumb, ::-webkit-scrollbar-track-piece {
- border-left-color: var(--color-background)!important;
- border-top-color: var(--color-background)!important;
- }
-
- .actions {
- position: absolute;
- right: 0;
- padding: $padding;
-
- div {
- cursor: pointer;
- color: var(--color-text);
- opacity: 0.25;
- &:hover {
- opacity: 0.5
- }
- }
- i {
- pointer-events: none;
- }
- }
- osc-panel-content {
- display: flex;
- flex-direction: column;
- font-family: $font-mono;
- }
-
-}
-
-.editor-disabled #osc-console.minimized {
- &:after {
- // disable hover trap
- display: none;
- }
- > .toggle-button {
- // disable toggle button
- display: none;
- }
-}
-
-osc-console {
- height: 100%;
- padding: $padding 0;
- overflow-y: auto;
- border-bottom: 1rem dotted rgba(255,255,255,0.2);
- user-select: text;
-}
-
-.editor-enabled osc-console:focus {
- outline: 1rem dotted var(--color-accent);
- outline-offset: -1rem;
-}
-
-osc-console-message {
-
- user-select: text;
- cursor: text;
- display: block;
- white-space: pre-line;
- position: relative;
- padding-left: $padding + 18rem;
- padding-right: $padding;
- padding-bottom: 6rem;
- border-bottom: 1rem dotted rgba(255,255,255,0.1);
- &:before {
- font-family: FontAwesome;
- width: 12rem;
- display: inline-block;
- text-align: center;
- position: absolute;
- left: $padding;
- }
- &.log:before {
- content: "\f105\f105"
- }
- &.error {
- color: var(--color-error);
- &:before {
- content: "x"
- }
- }
- &.input {
- &:before {
- content: "\f105\f105";
- }
- }
- &.output {
- &:before {
- content: "\f104\f104"
- }
-
- &.undefined {
- // color: var(--color-text)
- opacity: 0.5;
- border-bottom: 1rem dotted rgba(255,255,255,0.20);
- }
-
- &.value {
- color: var(--color-accent);
- opacity: 1;
- }
- }
-
-
- margin-bottom: 4rem;
-
- &:last-child {
- margin-bottom: 0;
- }
-
- .edit-widget {
- cursor: pointer;
- display: inline-block;
- position: relative;
- // padding: 2rem;
- border-radius: 2rem;
- &.editing {
- background: var(--color-ui-foreground);
- }
- &[data-widget="CONSOLE"] {
- cursor: default;
- background: none;
- padding: 1rem;
- }
- }
- * {
- user-select: inherit;
- }
-
- flex:1;
-}
-
-osc-console-input {
- display: block;
- $field-height: 24rem;
- padding-left: 10rem;
-
- &:before {
- content: "\f105\f105";
- font-family: FontAwesome;
- width: 16rem;
- display: inline-block;
- text-align: center;
- position: absolute;
- left: 0;
- line-height: $field-height - 6rem;
- padding: 4rem 6rem;
- color: var(--color-accent);
- }
- textarea {
- font-family: $font-mono;
-
- line-height: $field-height - 6rem;
- padding: 4rem 16rem;
- flex: 1;
- overflow-x: auto;
- overflow-y: hidden;
- resize: none;
- white-space: pre;
- display: block;
- background: var(--color-background);
- width: 100%;
- 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/contextmenu.scss b/src/scss/ui/contextmenu.scss
deleted file mode 100644
index b4c4e3f4..00000000
--- a/src/scss/ui/contextmenu.scss
+++ /dev/null
@@ -1,114 +0,0 @@
-$line-height: 30rem;
-
-.context-menu {
-
- --widget-padding: 0rem;
- --alpha-fill: 1;
-
- position:fixed;
- z-index: 9999999;
- background: var(--color-context-menu);
- box-shadow: 0 0 0 0.5rem rgba(0, 0, 0, 0.15) inset;
- text-transform: none;
- color: var(--color-context-menu-text);
- font-weight: 500;
- font-size: 13rem;
- line-height: $line-height;
- font-family: $font-menu;
- letter-spacing: normal;
- padding-top: 3rem;
- padding-bottom: 3rem;
-
- .context-menu {
- position: absolute;
- left:100%;
- top:-3rem;
- opacity:0;
- pointer-events: none;
- margin-left: -1rem;
- &:before {
- content:"";
- position: absolute;
- top:0;
- bottom:0;
- left:-2rem;
- width:2rem;
- }
- }
- > .item {
- padding-left: 30rem;
- padding-right: 30rem;
- position:relative;
- cursor: pointer;
- display: flex;
- flex-direction: row;
- i {
- position: absolute;
- left: 10rem;
- width: 10rem;
- text-align: center;
- line-height: $line-height - 2;
- font-size: 9rem;
- pointer-events: none;
- }
- &.focus {
- > .context-menu {
- pointer-events: auto;
- opacity: 1;
- }
- @include pseudo-fill($z: -1);
- color: var(--color-context-menu);
- }
- &.has-sub:before {
- content:"\f105";
- display: block;
- font-family: FontAwesome;
- text-align: right;
- margin-right: -20rem;
- position: relative;
- flex: 1;
- order: 1;
- margin-left: 10rem;
- }
- &.disabled {
- pointer-events: none;
- opacity: 0.5;
- }
- &.toggle:before {
- content: "";
- display: block;
- font-family: FontAwesome;
- position: absolute;
- width: 10rem;
- height: 10rem;
- left: 10rem;
- top: 8rem;
- border: 1rem solid;
- opacity: 0.75;
- line-height: 10rem;
- font-size: 8rem;
- text-align: right;
- }
- &.toggle.on:before {
- content:"\f00c";
- }
- .shortcut {
- display: inline-block;
- margin-left: 20rem;
- margin-right: -20rem;
- position: relative;
- text-align: right;
- position: relative;
- flex: 1;
- text-transform: capitalize;
- opacity: 0.5;
- pointer-events: none;
- }
- }
- .separator{
- margin: 2rem 1rem;
- height: 1rem;
- background-color: var(--color-context-menu-text);
- opacity: 0.15;
- }
-}
diff --git a/src/scss/ui/dragresize.scss b/src/scss/ui/dragresize.scss
deleted file mode 100644
index 2710ce16..00000000
--- a/src/scss/ui/dragresize.scss
+++ /dev/null
@@ -1,104 +0,0 @@
-#drag-resize {
-
- --color-fill: var(--color-accent);
- --color-stroke: var(--color-accent);
-
- position: absolute;
- z-index: 99999999;
-
- top: var(--top);
- left: var(--left);
-
- &:before {
- content:"";
- position: absolute;
- top:0;left:0;
- width: calc(var(--width) - 2rem);
- height: calc(var(--height) - 2rem);
- border: 1rem solid var(--color-accent);
- opacity: 0.2;
- pointer-events: none;
- }
-
- .helper {
-
- position: absolute;
- top:0;
- left:0;
- width: var(--width);
- height: var(--height);
- pointer-events: none;
- --alpha-fill: 0.5;
- --widget-padding: -1rem;
- opacity: 0.5;
- display: none;
- border: 1rem solid var(--color-stroke);
- @include pseudo-fill();
- }
-
- &.dragging .helper {
- display: block;
- }
-
- &.copying {
- --color-accent: var(--color-warning);
- }
-
- .handle {
-
- $size: 10rem;
-
- position: absolute;
- background: var(--color-fill);
- width: $size;
- height: $size;
- border: 2rem solid transparent;
- background-clip: content-box;
- // opacity: 0.75;
-
- &.nw {
- cursor: move;
- }
-
- &.e {
-
- top: calc(var(--height) / 2);
- left: var(--width);
- margin-left: -$size;
- margin-top: -$size / 2;
- cursor: e-resize;
-
- }
-
- &.se {
-
- top: var(--height);
- left: var(--width);
- margin-left: -$size;
- margin-top: -$size;
- cursor: se-resize;
-
- }
-
- &.s {
-
- top: var(--height);
- left: calc(var(--width) / 2);
- margin-left: -$size / 2;
- margin-top: -$size;
- cursor: s-resize;
-
- }
-
- &.full {
- width: var(--width);
- height: var(--height);
- top: 0;
- left: 0;
- opacity: 0.1;
- z-index: 1;
- margin:0;
- }
- }
-
-}
diff --git a/src/scss/ui/filebrowser.scss b/src/scss/ui/filebrowser.scss
deleted file mode 100644
index 13884578..00000000
--- a/src/scss/ui/filebrowser.scss
+++ /dev/null
@@ -1,99 +0,0 @@
-$padding: 8rem;
-
-.file-browser {
- display: flex;
- flex-direction: column;
- flex: 1;
- overflow: hidden;
-
- .ariane {
- height: 40rem;
- flex-shrink: 0;
- line-height: 40rem;
- padding-left: $padding + 2rem;
- padding-right: $padding + 2rem;
- background: var(--color-ui-button);
- overflow-x: auto;
- overflow-y: hidden;
- --scrollbar-size: 4rem;
- }
- .file-list {
- overflow-y: auto;
- flex:1;
- background: var(--color-background);
- padding: 0 $padding;
- margin: 1rem 0;
- }
- .file {
- position: relative;
- height: 40rem;
- line-height: 40rem;
- input {
- position: absolute;
- width:100%;
- height: 100%;
- opacity: 0;
- cursor: pointer;
- }
- .label {
- position: absolute;
- width:100%;
- height: 100%;
- pointer-events: none;
- white-space: nowrap;
- span {
- display: block;
- width: 100%;
- text-overflow: ellipsis;
- overflow: hidden;
- }
- }
- input:checked + .label {
- color: var(--color-widget);
- &:before {
- content:"";
- position: absolute;
- left:-$padding;
- right:-$padding;
- height: 100%;
- background: var(--color-widget);
- opacity: 0.1;
- }
- }
- }
- .file-actions {
- display: flex;
- flex-direction: row;
- align-items: flex-end;
- justify-content: stretch;
- height: 42rem + $padding * 2;
- line-height: 38rem;
- flex-shrink: 0;
- // border: $padding solid var(--color-ui-foreground);
- padding: $padding;
- background: var(--color-ui-foreground);
- .btn {
- margin: 1rem;
- margin-left: $padding;
- text-overflow: clip;
- min-width: 0;
- background: var(--color-ui-button);
- }
- i {
- pointer-events: none;
- }
- .save-as {
- flex:1;
- border: 0;
- margin: 1rem;
- padding: 0 10rem;
- font-size: 120%;
- position: relative;
- background: var(--color-background);
- min-width: 0;
- &[disabled] {
- visibility: hidden;
- }
- }
- }
-}
diff --git a/src/scss/ui/grid.scss b/src/scss/ui/grid.scss
deleted file mode 100644
index 112a4bc4..00000000
--- a/src/scss/ui/grid.scss
+++ /dev/null
@@ -1,22 +0,0 @@
-.editor-enabled {
- &:not(.no-grid) {
- .root-container,
- .tab-container,
- .modal-container,
- .panel-container {
- > inner {
- background-image: linear-gradient(to bottom, var(--color-grid) 1rem, transparent 1rem),
- linear-gradient(to right, var(--color-grid) 1rem, transparent 1rem);
- --size: calc(var(--grid-width) * 1rem);
- background-size: var(--size) var(--size);
- background-attachment: local;
- background-position: 0rem 0;
- }
- }
- }
-
- .widget:not(.not-editable) {
- pointer-events: initial!important;
- }
-
-}
diff --git a/src/scss/ui/inspector.scss b/src/scss/ui/inspector.scss
deleted file mode 100644
index e668e72d..00000000
--- a/src/scss/ui/inspector.scss
+++ /dev/null
@@ -1,810 +0,0 @@
-$header-height: 28rem;
-$field-height: 24rem;
-$label-width: 94rem;
-$padding: 8rem;
-$radius: 3rem;
-
-osc-panel-container.right.editor-breakout {
- osc-panel-inner {
- contain: initial;
- }
- .resize-handle {
- display: none;
- }
-}
-
-#osc-inspector {
-
- select, input, textarea {
- -webkit-appearance:none;
- -moz-appearance:none;
- appearance:none;
- -webkit-user-select: auto;
- -moz-user-select: auto;
- user-select: auto;
- }
-
-
- --widget-padding: -1rem;
-
- .lock {
- osc-inspector-field {
- filter: saturate(0);
- pointer-events: none;
- opacity: 0.65;
- }
- osc-inspector-field[name=lock] {
- filter: none;
- pointer-events: auto;
- opacity: 1.0;
- }
- }
-
- .toolbar {
- display: flex;
- flex-direction: row;
- padding: $padding / 2;
- height: 46rem;
- position: relative;
- top:0;
- z-index: 21;
- background: var(--color-ui-background);
- border-bottom:1rem solid var(--color-background);
- .btn {
- margin: $padding / 2;
- padding: 0 8rem 1rem;
- align-items: center;
- justify-content: center;
- display: flex;
- span{
- overflow: hidden;
- text-overflow: ellipsis;
- }
- i {
- pointer-events: none;
- }
- &[data-action="toggle-grid"] {
- color: var(--color-accent)
- }
- &[data-action="reset-selection"] i:after {
- content: "";
- position: absolute;
- border-left: 1.5rem solid;
- left: 50%;
- top: 50%;
- margin-top: -8rem;
- margin-left: -1rem;
- height: 16rem;
- transform: rotate(45deg);
- }
- }
- [data-action="selected-id"] {
- flex: 1;
- cursor: default;
- }
- }
-
- overflow: hidden;
- > .content {
- overflow: auto;
- flex:1;
- height: calc(100% - 46rem);
- box-shadow: 0 1rem 0 0 inset rgba(white, 0.025);
-
- }
-
-}
-
-body.no-grid #osc-inspector .toolbar .btn[data-action="toggle-grid"] {
- color: inherit;
-}
-
-
-
-osc-inspector-field {
-
- display: flex;
- flex-direction: row;
- line-height: $field-height;
- margin-top: -1rem;
- position: relative;
-
- &:after {
- content:"";
- position: absolute;
- left:$label-width;
- top:0;
- right: 1rem;
- border-top:1rem solid var(--color-ui-background);
- z-index: 1;
- // opacity: 0.5;
- }
-
- --widget-padding: -1rem;
-
- > label {
- width: $label-width;
- text-transform: none;
- padding-left: 4rem;
- padding-right: 4rem;
- line-height: $field-height;
- height: $field-height;
- cursor: pointer;
- background: var(--color-ui-foreground);
- border:1rem solid var(--color-background);
- border-right: none;
- border-top-left-radius: inherit;
- border-bottom-left-radius: inherit;
- }
-
- &.has-editor {
-
- flex-direction: column;
- height: auto;
- border-radius: $radius;
-
- > label {
- border:1rem solid var(--color-background);
- border-bottom: none;
- width: 100%;
- position: relative;
- border-top-left-radius: inherit;
- border-top-right-radius: inherit;
- border-bottom-left-radius: 0;
- border-bottom-right-radius: 0;
- }
- .btn {
- position: absolute;
- top:3rem;
- background: var(--color-ui-button);
- line-height: $field-height - 6;
- box-shadow: 0 0 1rem 0 var(--color-background);
- border: 0;
- }
- .fullscreen {
- right:3rem;
- width: 24rem;
- padding-left: 0;
- padding-right: 0;
- border-top-right-radius: inherit;
- }
- .help {
- right:30rem;
- }
- &:after {
- content:none;
- }
-
- &.fullscreen {
- position: fixed;
- width:auto;
- height: auto;
- top:0;
- left:0;
- right:0;
- bottom:0;
- padding: 50rem;
- margin: 0;
- z-index: 99;
- background: rgba(black, 0.3);
- > label:before {
- content: var(--prefix);
- }
- &.dirty label:after{
- content: "*"
- }
- .btn {
- margin-top: 50rem;
- margin-right: 50rem;
- &.fullscreen {
- color: var(--color-accent);
- }
- }
- .ace_editor {
- height: 100%!important;
- }
- }
- }
- .ace_editor {
- min-height: $field-height;
- border-bottom-left-radius: inherit;
- border-bottom-right-radius: inherit;
- }
- > textarea, > input {
- 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);
- cursor: text;
-
- &:last-child{
- border-top-right-radius: inherit;
- border-bottom-right-radius: inherit;
- }
-
- user-select: initial;
-
- // hide scrollbar to preserve height
- scrollbar-width: thin;
- &[rows="1"] {
- scrollbar-width: none;
- }
-
-
- }
-
-
- .computed-value {
- position: absolute;
- right: 4rem;
- text-align: right;
- pointer-events: none;
- opacity: 0.5;
- font-style: italic;
- margin-top: 1rem;
- }
-
-}
-
-osc-inspector-field .ace_editor {
-
- color: var(--color-text);
- font-size: inherit;
- background: var(--color-background);
- line-height: 1.3;
- border: 1rem solid var(--color-background);
-
- .ace_gutter {
- background: var(--color-background);
- color: #6a6f7a;
- border-right: 1rem solid var(--color-ui-background);
- line-height: 1.5
- }
- .ace_print-margin {
- display: none;
- }
- .ace_mobile-menu {
- display: none;
- }
-
- .ace_cursor {
- color: var(--color-accent);
- border-right-width: 2rem;
- }
- .ace_hidden-cursors .ace_cursor {
- opacity: 0;
- }
- .ace_marker-layer .ace_selection {
- background: #3d4350
- }
- .ace_multiselect .ace_selection.ace_start {
- box-shadow: 0 0 3rem 0 #282c34;
- border-radius: 2rem
- }
- .ace_marker-layer .ace_step {
- background: #c6dbae
- }
- .ace_marker-layer .ace_bracket {
- border: none;
- border-radius: 0;
- margin-top: 1rem;
- border-bottom: 1rem solid var(--color-accent)
- }
- .ace_marker-layer .ace_active-line {
- background: rgba(white, 0.05);
- }
- .ace_gutter-active-line {
- background-color: rgba(white, 0.05);
- z-index: 99
- }
- .ace_marker-layer .ace_selected-word {
- border: none;
- border-bottom: 1rem solid rgba(white, 0.2);
- background: none;
- }
- .ace_fold {
- background-color: #61afef;
- border-color: #abb2bf
- }
- .ace_keyword {
- color: #c678dd
- }
- .ace_keyword.ace_operator {
- color: #c678dd
- }
- .ace_keyword.ace_other.ace_unit {
- color: #d19a66
- }
- .ace_constant.ace_language {
- color: #d19a66
- }
- .ace_constant.ace_numeric {
- color: #d19a66
- }
- .ace_constant.ace_character {
- color: #56b6c2
- }
- .ace_constant.ace_other {
- color: #56b6c2
- }
- .ace_support.ace_function {
- color: #61afef
- }
- .ace_support.ace_constant {
- color: #d19a66
- }
- .ace_support.ace_class {
- color: #e5c07b
- }
- .ace_support.ace_type {
- color: #e5c07b
- }
- .ace_storage {
- color: #c678dd
- }
- .ace_storage.ace_type {
- color: #c678dd
- }
- .ace_invalid {
- color: #fff;
- background-color: #f2777a
- }
- .ace_invalid.ace_deprecated {
- color: #272b33;
- background-color: #d27b53
- }
- .ace_string {
- color: #98c379
- }
- .ace_string.ace_regexp {
- color: #e06c75
- }
- .ace_comment {
- font-style: italic;
- color: #5c6370
- }
- .ace_variable {
- color: #e06c75
- }
- .ace_variable.ace_parameter {
- color: #d19a66
- }
- .ace_meta.ace_tag {
- color: #e06c75
- }
- .ace_entity.ace_other.ace_attribute-name {
- color: #e06c75
- }
- .ace_entity.ace_name.ace_function {
- color: #61afef
- }
- .ace_entity.ace_name.ace_tag {
- color: #e06c75
- }
- .ace_markup.ace_heading {
- color: #98c379
- }
- .ace_indent-guide {
- background: none;
- border-right: 1rem solid rgba(white, 0.05);
- margin-left: -1rem;
- }
- .ace_tooltip {
- left:$padding + 1!important;
- max-width: 80%;
- white-space: pre-wrap;
- background: var(--color-context-menu);
- color: var(--color-context-menu-text);
- font-family: $font;
- box-shadow: 0 0 0 0.5rem rgba(0, 0, 0, 0.15) inset;
- border: none;
- border-radius: 0;
- }
- .ace_gutter {
- .ace_info {
- background: linear-gradient(rgba(black, 0.5), rgba(black, 0.5)), var(--color-text)!important;
- color: var(--color-background);
- }
- .ace_warning {
- background: linear-gradient(rgba(black, 0.5), rgba(black, 0.5)), var(--color-warning);
- color: var(--color-background);
- }
- .ace_error {
- background: linear-gradient(rgba(black, 0.4), rgba(black, 0.4)), var(--color-error);
- color: var(--color-background);
- }
- }
-}
-
-
-osc-inspector-category {
-
- margin-top: 1rem;
- display: block;
- padding: 0 8rem;
-
- &:first-child {
- margin-top: 0
- }
-
- .category-header {
- position: relative;
- cursor: pointer;
- height: $header-height;
- line-height: $header-height - 1;
- // padding: 0 8rem;
- // position: sticky;
- // top:46rem;z-index: 20;
- // background: var(--color-ui-background);
- font-weight: 500;
- @include pseudo-fill($z: -1);
- &:after {
- left:-($padding - 1);
- right:-($padding - 1);
- }
-
- &:before {
- position: relative;
- font-family: FontAwesome;
- content: "\f054";
- width: $field-height;
- text-align: left;
- display: inline-block;
- transform-origin: 2rem 3rem;
- width: 8rem;
- margin-right: 8rem;
- top:1rem;
- }
-
- &:focus, &:active {
- text-decoration: underline
- }
-
- }
-
- .separator {
- height: $header-height;
- line-height: $header-height - 1;
- margin: $padding 0;
- position: relative;
- padding: 0 ($padding - 4);
- font-weight: 500;
- &:before {
- position: relative;
- font-family: FontAwesome;
- content: "\f078";
- // color: var(--color-background);
- width: $field-height;
- text-align: left;
- display: inline-block;
- transform-origin: 2rem 3rem;
- width: 8rem;
- margin-right: 12rem;
- top: 1rem;
- }
- &:after {
- content: "";
- position: absolute;
- height: 100%;
- left:-($padding);
- right:-($padding);
- background: var(--color-ui-foreground);
- border-top:1rem solid var(--color-background);
- border-bottom:1rem solid var(--color-background);
- z-index: -1;
- }
- }
-
- osc-inspector-field, .separator {
- display: none;
- }
- --alpha-fill: 1;
- --color-fill: var(--color-ui-button);
-
- &.expanded {
- // --alpha-fill: 1;
- --alpha-fill: 0.5;
- --color-fill: var(--color-widget);
-
- .category-header:before {
- content: "\f078";
- }
- osc-inspector-field {
- display: flex;
- }
- .separator {
- display: block
- }
- }
-
- osc-inspector-field.first-child,
- .category-header + osc-inspector-field {
- margin-top: $padding + 1;
- &:after {
- content: none;
- }
- osc-inspector-checkbox {
- border-top: 0;
- }
- osc-inspector-color:after {
- top:0;
- }
- border-top-left-radius: $radius;
- border-top-right-radius: $radius;
- .color-picker {
- margin-top: 2rem;
- }
- }
- osc-inspector-field.last-child,
- osc-inspector-field:last-child {
- margin-bottom: 8rem;
-
- osc-inspector-checkbox {
- border-bottom: none;
- }
-
- border-bottom-left-radius: $radius;
- border-bottom-right-radius: $radius;
- }
-}
-
-osc-inspector-checkbox {
-
- --widget-padding: 1rem;
- --color-fill: var(--color-ui-button);
- --alpha-fill: 1;
-
- line-height: $field-height;
- height: $field-height;
- width: $field-height;
- cursor: pointer;
- background: var(--color-background);
- text-align: center;
- display: flex;
- align-items: center;
- justify-content: center;
- border-top: 1rem solid var(--color-background);
- border-bottom: 1rem solid var(--color-background);
- border-top-right-radius: inherit;
- border-bottom-right-radius: inherit;
-
- i {
- // color: transparent;
- opacity: 0.5;
- margin-top: -1rem;
- margin-left: 1rem;
- pointer-events: none;
- font-size: 10rem;
- }
- position: relative;
- @include pseudo-fill($z: -1);
- z-index: 1;
-
- &.on {
- --color-fill: var(--color-widget);
- --alpha-fill: 0.5;
-
- i {
- opacity: 1;
- color: var(--color-text-solid);
- }
- }
-
-}
-
-osc-inspector-select {
- position: relative;
- font-family: $font-mono;
- line-height: inherit;
- padding: 0;
- overflow: hidden;
- height: $field-height;
- width: $field-height;
- background: var(--color-background);
- cursor: pointer;
-
- select {
- background: var(--color-background);
- // width: 100%;
- line-height: $field-height - 8rem;
- padding: 4rem 6rem;
-
- position: absolute;
- right:2rem;
- width: 127rem;
- opacity: 0;
- optgroup {
- background: var(--color-ui-foreground);
- font-weight: bold;
- option {
- background: var(--color-background);
- color: var(--color-text);
- margin-left: -4rem;
- font-weight: normal;
- text-indent: -10rem;
- margin: 0;
- }
- }
- }
- &:after{
- content:"\f107";
- font-family: FontAwesome;
- position: absolute;
- line-height: $field-height;
- height: $field-height;
- width: $field-height;
- text-align: center;
- right:0;
- top:1rem;
- font-size: 16rem;
- pointer-events: none;
- }
-}
-
-
-osc-inspector-color {
- padding: 0;
- border: 0;
- box-shadow: 0;
- outline: 0;
- position: relative;
- font-family: $font-mono;
- line-height: inherit;
- overflow: hidden;
- height: $field-height;
- width: $field-height;
- background: var(--color-background);
- border-top-right-radius: inherit;
- border-bottom-right-radius: inherit;
-
- cursor: pointer;
-
-
-
- --color-fill: var(--color-picker-value);
- --alpha-fill: 1;
- --widget-padding: 2rem;
- @include pseudo-fill();
- &:after {
- border: 1rem solid var(--color-ui-button);
- right: 0;
- left: 0;
- }
-}
-
-.color-picker {
- position: absolute;
- z-index: 99;
- height: calc(var(--sidepanel-size) - #{$label-width} - #{$field-height * 2});
- min-height: 111rem;
- max-height: 227rem;
- top: 0;
- right: 22rem;
- left: $label-width;
- margin: 3rem 2rem;
- display: flex;
- flex-direction: column;
- $padding: 2rem;
- border: 1rem solid var(--color-ui-button);
- overflow: hidden;
- --point-size: 10rem;
- .widget {
- background: var(--color-ui-background);
- flex: 1;
- width: auto;
- --widget-padding: 0rem;
- inner {
- padding: 1rem;
- }
- .hue {
- margin-left: 1rem;
- width: 16rem;
- --knob-size: 1rem;
- }
- .alpha {
- margin-top: 0.5rem;
- left:0;
- margin-left: 0;
- border:0;
- }
- .hue:after {
- left:0;
- right:0;
- }
- }
-
-}
-
-.inspector-help {
-
- width: 100%;
- padding: 8rem;
- background: var(--color-background);
- overflow: auto;
-
- p {
- }
- .error {
- color: red;
- margin-top: 10rem;
- }
- em {
- font-style: italic;
- }
- code {
- color: var(--color-accent);
- padding: 4rem;
- background: rgba(black, 0.2);
- display: inline-block;
- user-select: auto;
- cursor: auto;
- ::selection{/* reset */}
- }
- a {
- text-decoration: underline;
- cursor: pointer;
- }
- .pre {
- white-space: pre;
- vertical-align: text-top;
- margin-top: -4rem;
- position: relative;
- padding: 5rem;
- user-select: text;
- }
-
- .header p {
- margin-bottom: 2rem;
- user-select: text;
- }
- .description {
- border-top: 2rem solid var(--color-ui-foreground);
- margin-top: 10rem;
- padding-top: 10rem;
- white-space: normal;
- * {
- user-select: text;
- }
- }
-
- .computed {
- border-top: 2rem solid var(--color-ui-foreground);
- margin-top: 10rem;
- padding-top: 10rem;
-
- }
-
- .kbd {
- background: var(--color-ui-button);
- padding: 4rem;
- display: inline-block;
- margin-bottom: 2rem;
- }
-
- thead tr {
- text-align: left;
- font-weight: 500;
- height: 30rem;
- }
-}
-
-
-.editor-enabled.local-zoom-in .root-container,
-.editor-enabled.local-zoom-out .root-container {
- transform-origin: top left;
- transform: scale(var(--local-zoom));
- min-width: calc(100% / var(--local-zoom));
- min-height: calc(100% / var(--local-zoom));
-}
-
-.editor-enabled.local-zoom-out .root-container.auto-height{
- transform-origin: center left;
-
-}
diff --git a/src/scss/ui/keyboard.scss b/src/scss/ui/keyboard.scss
deleted file mode 100644
index fd188868..00000000
--- a/src/scss/ui/keyboard.scss
+++ /dev/null
@@ -1,185 +0,0 @@
-osc-keyboard {
- --spacing: 2rem;
- --max-height: 300rem;
- --max-width: 1200rem;
-
- height:calc(33% + 40rem);
- z-index: 100;
- position: fixed;
- bottom: 0;
- left:0;
- right: 0;
- backdrop-filter: blur(12px);
- @supports not (backdrop-filter: blur(12px)) {
- background: var(--color-ui-background);
- }
- display: none;
- flex-direction: column;
- padding: var(--spacing);
- align-items: center;
- background: rgba(black, 0.25);
- max-height: var(--max-height);
- border-top: 1rem solid var(--color-background);
-
- @keyframes keyboard-in {
- from {opacity: 0}
- to {opacity: 1}
- }
- @keyframes caret-blink {
- to {visibility: hidden}
- }
-
- animation: keyboard-in 0.25s forwards;
-
- .textarea {
- height: auto;
- overflow-y: auto;
- width: 100%;
- height: 40rem;
- background: transparent;
- padding: 14rem 20rem 4rem;
- resize: none;
- text-align: center;
- vertical-align: middle;
- font: inherit;
- margin-top:var(---spacing);
- position: relative;
- pointer-events: auto;
- cursor: text;
- char {
- margin: 0 0.25rem;
- position: relative;
- }
- .newline + char:before, char:first-child:before {
- content: " ";
- display: block;
- position: absolute;
- left: -100rem;
- width: 100rem;
- }
- .newline:before, char:last-child:before {
- content: " ";
- display: block;
- position: absolute;
- top: 0;
- right: -100rem;
- width: 100rem;
- }
- .caret {
- &:after {
- content: "";
- height: 10rem;
- box-shadow: 0 0 0 1rem var(--color-accent);
- position: relative;
- animation: caret-blink 1.2s steps(2, start) infinite;
- pointer-events: none;
- }
-
- }
- .select {
- background: var(--color-accent);
- box-shadow: 0 0 0 1rem var(--color-accent);
- color: var(--color-background);
- }
- &.first-char-caret {
- &:before {
- content: "";
- height: 10rem;
- position: absolute;
- box-shadow: 0 0 0 1rem var(--color-accent);
- animation: caret-blink 1.2s steps(2, start) infinite;
- }
- }
- }
-
- .row {
- flex-direction: row;
- display: flex;
- flex: 1;
- max-width: var(--max-width);
- width: 100%;
- &:last-child .key {
- margin-bottom: 0;
- }
- &:first-child {
- height: 40rem;
- min-height: 40rem;
- flex-shrink: 0;
- overflow: hidden;
- margin-bottom: var(--spacing);
- }
- }
- key {
- background: rgba(white, 0.05);
- border-color: var(--color-ui-background);
- flex: 1;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- position: relative;
- --alpha-fill: 0.1;
- --color-fill: var(--color-accent);
- --widget-padding: -1rem;
- @include pseudo-fill($z: 1);
- margin-right: var(--spacing);
- margin-bottom: var(--spacing);
- &:last-child{
- margin-right: 0;
- }
- span {
- pointer-events: none;
- align-items: center;
- justify-content: center;
- &.display-default {
- display: flex;
- }
- &.display-shift {
- display: none;
- }
- }
-
- &.active {
- --alpha-fill: 0.3!important;
- }
- }
-
- .enter {
- --alpha-fill: 0.15;
- }
-
- .tab, .shift {
- flex: 1.5;
- }
-
- .enter, .right-shift, .lock, .bksp {
- flex: 2;
- }
-
- .sep {
- display: none;
- }
- .sep ~ key {
- flex-shrink: 0;
- flex-grow: 0;
- min-width: 5%;
- --alpha-fill: 0.15;
-
- }
-
- &.shift {
- key {
- .display-shift {
- display: flex;
- }
- .display-default {
- display: none;
- }
- }
- }
- @media screen and (max-width: 800px) {
- key {
- font-size: 80%
- }
- }
-
-}
diff --git a/src/scss/ui/launcher.scss b/src/scss/ui/launcher.scss
deleted file mode 100644
index 78b05ee2..00000000
--- a/src/scss/ui/launcher.scss
+++ /dev/null
@@ -1,239 +0,0 @@
-#osc-launcher {
-
- osc-panel-header {
- background-color: var(--color-ui-foreground);
- --alpha-fill: .75;
- text-align: left;
- justify-content: center;
- .spacer {
- flex: 1;
- }
- span {
- opacity: 0.5;
- position: absolute;
- right: 12rem;
- }
- flex-shrink: 0;
- }
-
- flex-direction: column;
-
- osc-panel-container.main {
- background-color: var(--color-ui-foreground);
- min-height: 0;
- min-height: 40rem;
- osc-panel-content {
- padding: 8rem;
- background-color: var(--color-ui-foreground);
- }
- }
- osc-panel-content {
- overflow-y: auto;
- flex: 1;
- }
-
- osc-panel-container.bottom {
- flex: 1;
- padding: 12rem 8rem;
- min-height: 100rem;
-
- &.minimized {
- padding: 0;
- }
-
- border-top: 2rem solid var(--color-ui-foreground);
- max-height: calc(100% - var(--nav-height));
- background-color: var(--color-background);
- osc-panel-inner {
- background-color: var(--color-background);
- }
-
- // --color-background: --color-ui-foreground; // scrollbar
- }
-
- osc-panel-inner {
- contain: layout style;
- }
-
-}
-
-osc-settings {
-
- display: grid;
- grid-template-columns: repeat(2, 1fr);
-
-}
-osc-settings-field {
- display: flex;
- flex-direction: row;
- // margin: 1rem;
- margin-top:-1rem;
- line-height: 22rem;
- position: relative;
- &:after {
- content:"";
- position: absolute;
- left:100rem;
- top:0;
- right: 0;
- border-top:1rem solid var(--color-ui-foreground);
- z-index: 11;
- }
- &:nth-child(2n) {
- margin-left: 8rem;
- }
- &:nth-child(2), &:nth-child(1) {
- margin-top:0;
- osc-settings-checkbox, osc-settings-reset, osc-settings-file {
- border-top: 0;
- }
- &:after {
- content: none;
- }
- }
- &:nth-last-child(2), &:nth-last-child(1) {
- osc-settings-checkbox, osc-settings-reset, osc-settings-file {
- border-bottom: 0;
- }
- }
- label {
- width: 100rem;
- // text-align: right;
- background: var(--color-ui-background);
- border:1rem solid var(--color-background);
- border-right: none;
- // margin-right: 8rem;
- padding: 0 4rem;
- position: relative;
- line-height: 22rem;
- height: 24rem;
- cursor: help;
- span {
- opacity: 0.5;
- }
- }
- input {
- appearance: none;
- background: var(--color-background);
- flex: 1;
- padding: 0 4rem;
- width: 100rem;
- }
- [disabled], [disabled] ~ * {
- pointer-events: none;
- opacity: 0.75!important;
-
- }
-
- &.error label {
- color: var(--color-error);
- }
- &.restart label:after {
- content: "";
- position: absolute;
- top:1rem;
- left:4rem;
- right:-4rem;
- bottom:0;
- background: var(--color-warning);
- opacity: 0.25;
- border-radius: 4rem;
- }
-}
-
-osc-settings-checkbox, osc-settings-reset, osc-settings-file {
- @extend osc-inspector-checkbox;
-
- i {
- color: var(--color-text);
- opacity: 0.75;
- }
- &:hover i {
- opacity: 1;
- }
- &.on {
- --alpha-fill: 0.5;
- i {
- color: var(--color-text-solid);
- opacity: 1;
- }
- }
- &:last-child {
- margin-left: -1rem;
- border-left: 0;
- }
-}
-
-#osc-terminal {
- flex: 1;
- line-height: 18rem;
- user-select:text;
- cursor: auto;
-
- > div {
- margin: 0 12rem;
- }
-
-
- * {
- user-select:text;
- cursor: auto;
- white-space: pre-wrap;
- }
- .log span {
- background: transparent!important
- }
- .help {
- font-style: italic;
- color: var(--color-accent);
- }
-
- .warning {
- color: var(--color-warning);
- }
-
- .error {
- color: var(--color-error);
- }
-
- .trace {
- position: relative;
- height: 18rem;
- overflow: hidden;
- &.show {
- height: auto;
- .trace-button:before {
- content: "\f078";
- }
- }
- }
- .trace-button {
- &:before {
- content: "\f054";
- font-size: 10rem;
- font-family: FontAwesome;
- }
- position: absolute;
- left: 0;
- margin-top: -1rem;
- cursor: pointer;
- user-select: none;
- }
-
- .qrcode svg {
- width: 120rem;
- margin-top: 5rem;
- margin-left: 15rem;
- path[fill="#ffffff"] {
- fill: var(--color-text)!important;
- }
- path[stroke="#000000"] {
- stroke: var(--color-background)!important;
- }
- }
-
- a {
- text-decoration: underline;
- cursor: pointer;
- }
-}
diff --git a/src/scss/ui/loading.scss b/src/scss/ui/loading.scss
deleted file mode 100644
index 4623731c..00000000
--- a/src/scss/ui/loading.scss
+++ /dev/null
@@ -1,39 +0,0 @@
-
-#loading {
- position: fixed;
- top:50%;
- left:50%;
- margin-left:-15rem;
- margin-top:-15rem;
- text-align: center;
-}
-
-.spinner {
- display: block;
- margin: 0 auto;
- height:36rem;
- width:36rem;
- border-radius: 50%;
- position: relative;
- margin: 20rem auto;
-
-
- &:after {
- content:"";
- position: absolute;
- left:-3rem;
- top:-3rem;
- right:-3rem;
- bottom:-3rem;
- border:4rem solid var(--color-ui-foreground);
- border-top: 2rem solid var(--color-widget);
- transform: rotateZ(0deg);
- animation: spin .5s linear infinite;
- border-radius: 50%;
- }
-}
-
-@keyframes spin {
- 0% {transform: rotateZ(0deg);}
- 100% {transform: rotateZ(360deg);}
-}
diff --git a/src/scss/ui/modal.scss b/src/scss/ui/modal.scss
deleted file mode 100644
index 014a925e..00000000
--- a/src/scss/ui/modal.scss
+++ /dev/null
@@ -1,109 +0,0 @@
-$padding: 8rem;
-
-@keyframes popup-backdrop-fade-in {
- 0% {opacity: 0}
- 100% {opacity: .03}
-}
-
-.popup {
-
- &:before {
-
- content: "";
- position: fixed;
- top:0rem;
- left:0;
- right:0;
- bottom:0;
- background: black;
- opacity: .3;
- // pointer-events: none;
- // animation: popup-backdrop-fade-in .25s forwards;
-
- }
-
- // backdrop-filter: blur(1rem);
-
- position: fixed;
- top:0;
- left:0;
- right:0;
- bottom:0;
- align-items:center;
- justify-content: center;
- z-index: 99999999;
- display: none;
- padding: 20rem;
-
- &.show {
- display: flex;
- }
-
- .popup-title {
- position: relative;
- min-height: var(--nav-height);
- height: var(--nav-height);
- display: flex;
- padding:0 $padding * 2 - 1;
- align-items: center;
- background: var(--color-ui-foreground);
- .title {
- flex:1;
- overflow: hidden;
- }
- > i {
- display: block;
- margin-right: 10rem;
- }
- &.closable {
- padding-right: 0;
- }
- .popup-label {
- flex:1;
- overflow: hidden;
- }
- .closer {
- height: var(--nav-height);
- width: var(--nav-height);
- flex-shrink: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- i {
- pointer-events: none;
- }
- }
- }
- .popup-wrapper {
- background: var(--color-background);
- display: flex;
- flex-direction: column;
- align-items: stretch;
- width:auto;
- position: relative;
- overflow: hidden;
-
- max-width: 100%;
- max-height: 100%;
- width: var(--width, 540rem);
- height: var(--height, auto);
-
- .popup-content {
- flex:1;
- width: auto;
- // padding: 2rem $padding $padding;
- min-height: 0;
- display: flex;
- }
-
- .message {
- white-space: normal;
- line-height: 150%;
- background: var(--color-background);
- padding: $padding;
- overflow-x: auto;
- }
-
- }
-}
diff --git a/src/scss/ui/notifications.scss b/src/scss/ui/notifications.scss
deleted file mode 100644
index b9393516..00000000
--- a/src/scss/ui/notifications.scss
+++ /dev/null
@@ -1,57 +0,0 @@
-#notifications {
- position: fixed;
- bottom:0;
- right:0;
- display: flex;
- flex-direction: column-reverse;
- z-index: 9999999;
- padding:10rem;
- width:300rem;
- &:empty {
- display: none;
- }
- .toast {
- animation: toast_fade-in 0.2s forwards;
- transform-origin: bottom;
- background: var(--color-notification);
- transition: all 0.2s;
- overflow: hidden;
- margin-top: 10rem;
- display: flex;
- flex-direction: row;
- align-items: center;
- &.remove {
- animation: toast_fade-out 0.2s forwards;
- height: 0!important;
- margin-top: 0!important;
- }
- i {
- margin-left: 10rem;
- font-size: 14rem;
- min-width: 30rem;
- color: var(--color-accent);
- }
- &.error {
- i {
- color: red;
- }
- }
- .content {
- padding: 10rem;
- white-space: pre-line;
- text-transform: none;
- line-height: normal;
- }
- }
-
-}
-
-@keyframes toast_fade-in {
- from {opacity: 0; transform: rotateX(90deg)}
- to {opacity: 1; transform: rotateX(0)}
-}
-
-@keyframes toast_fade-out {
- from {opacity: 1; transform: rotateX(0)}
- to {opacity: 0; transform: rotateX(90deg)}
-}
diff --git a/src/scss/ui/scrollbars.scss b/src/scss/ui/scrollbars.scss
deleted file mode 100644
index 1bf8f473..00000000
--- a/src/scss/ui/scrollbars.scss
+++ /dev/null
@@ -1,4 +0,0 @@
-* {
- scrollbar-color: var(--color-scrollbar) var(--color-background);
- scrollbar-width: normal;
-}
diff --git a/src/scss/ui/selectarea.scss b/src/scss/ui/selectarea.scss
deleted file mode 100644
index 7d5f0ea6..00000000
--- a/src/scss/ui/selectarea.scss
+++ /dev/null
@@ -1,72 +0,0 @@
-.select-area {
-
- position:fixed;
- z-index:999999;
- border: 1rem solid var(--color-accent);
- pointer-events: none;
- &:after {
- content:"";
- position: absolute;
- top:0;left:0;
- right:0;bottom:0;
- background: var(--color-accent);
- opacity: 0.2;
- }
- &.hidden {
- display: none;
- }
-
-}
-
-.widget.editing:after,
-.tablink.editing:after,
-.modal-container.editing > .popup > .popup-wrapper:after {
- content:"";
- z-index: 999!important;
- position: absolute;
- top:0;
- left:0;
- right:0;
- bottom:0;
-
- border-style: solid;
-
- -webkit-border-image: linear-gradient(to right, var(--color-accent) 10rem, rgba(0, 0, 0, 0) 10rem, rgba(0, 0, 0, 0) calc(100% - 10rem), var(--color-accent) calc(100% - 10rem)) 1 / 1rem;
- -webkit-mask-image: linear-gradient(to bottom, white 10rem, rgba(0, 0, 0, 0) 10rem, rgba(0, 0, 0, 0) calc(100% - 10rem), white calc(100% - 10rem));
-
- border-image: linear-gradient(to right, var(--color-accent) 10rem, rgba(0, 0, 0, 0) 10rem, rgba(0, 0, 0, 0) calc(100% - 10rem), var(--color-accent) calc(100% - 10rem)) 1 / 1rem;
- mask-image: linear-gradient(to bottom, white 10rem, rgba(0, 0, 0, 0) 10rem, rgba(0, 0, 0, 0) calc(100% - 10rem), white calc(100% - 10rem));
-
- pointer-events: none;
- box-shadow: none!important;
- opacity: 1!important;
-}
-
-
-
-.widget.editing.editor-blink:after,
-.modal-container.editing.editor-blink > .popup > .popup-wrapper:after {
- display: block!important;
- -webkit-mask-image: none;
- mask-image: none;
- background-color: var(--color-accent);
- opacity: 0.5!important;
- animation: editor-blink 0.51s steps(3) infinite;
-}
-
-@keyframes editor-blink {
- from {--color-accent: var(--color-warning)}
- to {--color-accent: transparent}
-}
-
-
-.editor-hide-selection {
- #drag-resize {
- display: none;
- }
- .widget.editing:after,
- .tablink.editing:after,
- .modal-container.editing > .popup > .popup-wrapper:after {
- display: none;
- }
-}
diff --git a/src/scss/ui/toolbar.scss b/src/scss/ui/toolbar.scss
deleted file mode 100644
index 802a0ece..00000000
--- a/src/scss/ui/toolbar.scss
+++ /dev/null
@@ -1,43 +0,0 @@
-osc-toolbar {
- --size: 34rem;
- position: absolute;
- top: 0;
- left: -1rem;
- height:var(--size);
- width:var(--size);
- max-width:var(--size);
- min-width:var(--size);
- text-align: center;
- z-index: 99999999;
- cursor: pointer;
- &:after {
- content:"\f0c9";
- width: 3rem;
- display: inline-block;
- overflow: hidden;
- font-size:13rem;
- font-family: FontAwesome;
- line-height: calc(var(--size) + 6rem);
- }
-
- &.on {
- &:after {
- color: var(--color-widget);
- }
- }
-}
-
-osc-toolbar#start {
-
- left: var(--size);
- &:after {
- font-size: 11rem;
- content: "\f04b";
- width: auto;
- margin-top:-1rem;
- }
- &.started:after {
- content: "\f04d";
- }
-
-}
diff --git a/src/scss/ui/tree.scss b/src/scss/ui/tree.scss
deleted file mode 100644
index 3acb8b0d..00000000
--- a/src/scss/ui/tree.scss
+++ /dev/null
@@ -1,214 +0,0 @@
-#osc-tree {
-
- --alpha-fill: 0.5;
- --widget-padding: -1rem;
-
- $padding: 8rem;
- $radius: 3rem;
- $line-height: 28rem;
- $field-height: 30rem;
- padding-right: 0;
-
- text-transform: none;
- line-height: $line-height;
-
- display: flex;
- flex-direction: column;
- overflow: hidden;
-
- .tree {
- width: 100%;
- flex: 1;
- position: relative;
- overflow: auto;
- padding-left:$padding + 4rem;
- padding-right:$padding;
- border-top:1rem solid var(--color-background);
- box-shadow: 0 1rem 0 0 inset rgba(white, 0.025);
- padding-top:1rem;
-
- &::-webkit-scrollbar-thumb, &::-webkit-scrollbar-track-piece {
- border-color: var(--color-background)!important;
- }
-
- }
-
- ol {
-
- list-style: none;
- position: relative;
- padding-left: 16rem;
- display: inline-block;
- min-width: 100%;
-
- ol:before {
- content: "";
- position: absolute;
- top: 0;
- bottom: $line-height / 2 - 1;
- left: -12rem;
- border-left: 1rem solid var(--color-stroke);
- opacity: 0.25;
- pointer-events: none;
- }
- }
-
- li {
-
- position: relative;user-select: none;
- > ol {
- // display: none;
- display: block;
- height: 0rem;
-
- > li {
- display: none;
- }
- }
- &.expanded > ol {
- display: block;
- // min-height: 8rem;
- opacity: 1;
- height: auto;
- > li {
- display: list-item;
- }
-
- }
-
- &.sortable-ghost {
- height: 2rem;
- margin-bottom: 6rem;
- margin-top: 4rem;
- color: transparent;
- overflow: hidden;
- display: list-item!important
- }
-
- > i {
- position: relative;
- top: 1rem;
- left: -2rem;
- margin-right: 2rem;
- pointer-events: none;
- }
-
- li:before {
- content: "";
- position: absolute;
- top: $line-height / 2;
- left: -27rem;
- width: 16rem;
- border-bottom: 1rem solid var(--color-stroke);
- opacity: 0.25;
- pointer-events: none;
- }
- .container:before {
- width: 8rem;
- }
-
- &.invisible {
- opacity: 0.5;
- font-style: italic;
- // &:after {
- // content: "\f070";
- // font-family: FontAwesome;
- // width: 12rem;
- // display: block;
- // position: absolute;
- // right: -12rem;
- // }
- }
- .fa-lock {
- position: relative;
- margin-left: 4rem;
- top:0;
- font-size: 80%;
- opacity: 0.8;
- }
-
- }
-
- .toggle {
- &:before {
- content: "\f054";
- font-family: FontAwesome;
- width: 20rem;
- display: block;
- position: absolute;
- left: -21rem;
- font-style: normal;
- text-align: center;
- }
- cursor: pointer;
- }
-
- .container.expanded > .toggle:before {
- content: "\f078";
- }
-
- .editing {
- z-index: 1;
- @include pseudo-fill($z: -1);
- &:after {
- left: calc(-1 * var(--depth) * 20rem - #{$padding});
- right: 1rem - $padding;
- bottom: auto;
- height: $line-height;
- top: 0;
- }
-
- &.editor-blink:after {
- animation: tree-editor-blink 0.51s steps(3) infinite;
- }
- @keyframes tree-editor-blink {
- from {--color-fill: var(--color-warning)}
- to {--color-fill: inherit}
- }
- }
-
- .contains-editing:not(.expanded):not(.editing) {
- z-index: 1;
- @include pseudo-fill($z: -1);
- &:after {
- left: calc(-1 * var(--depth) * 20rem - #{$padding});
- right: 1rem - $padding;
- bottom: auto;
- height: $line-height;
- opacity: 0.1;
- }
- }
-
-
- .filter {
- display: block;
- font-family: $font;
- // line-height: $field-height;
- padding: 0 $padding;
- top: 0;
- z-index: 2;
- background: var(--color-background);
- border: 1rem solid var(--color-background);
- margin: $padding;
- border-radius: $radius;
- }
-
- .filter-active .filter-hide {
- display:none;
- }
-
- .fragment-mode-warning {
- color: var(--color-warning);
- padding: 0 $padding;
- text-align: center;
- line-height: $field-height;
- background: var(--color-ui-foreground);
- border-bottom: 1rem solid var(--color-background);
- display: none;
- }
-
-}
-
-.fragment-mode .fragment-mode-warning {
- display: block!important;
-}
diff --git a/src/scss/ui/workspaces.scss b/src/scss/ui/workspaces.scss
deleted file mode 100644
index 7db8b4c0..00000000
--- a/src/scss/ui/workspaces.scss
+++ /dev/null
@@ -1,390 +0,0 @@
-osc-workspace {
-
- background: var(--color-ui-foreground);
-
- --color-fill: var(--color-widget);
- --color-stroke: var(--color-widget);
-
- // optimize layout recalc
- position: fixed;
- top:0;
- left:0;
- right:0;
- bottom:0;
-
- display: flex;
- flex-direction: row;
-
- &.vertical {
- flex-direction: column;
- }
- &.horizontal {
- flex-direction: row;
- }
-
-}
-
-osc-panel-container {
-
- background: var(--color-ui-background);
-
- position: relative;
- display:flex;
- flex-direction: column;
-
- &.vertical {
- flex-direction: column;
- }
- &.horizontal {
- flex-direction: row;
- }
-
- &.center {
- flex: 1;
- z-index: 1;
- min-width: 100rem;
- }
-
- &.left, &.right {
- z-index: 2;
- min-width: 0;
- width: 0;
- box-shadow: 0 0 0 1rem var(--color-background);
-
- &.minimized {
- box-shadow: none;
- }
-
- &:after {
- // hover trap to display toggle-button when closed
- content: "";
- position: absolute;
- top: 0;
- bottom: 0;
- width: 1rem;
- z-index: 1;
- }
-
- ::-webkit-scrollbar-thumb, ::-webkit-scrollbar-track-piece {
- border-color: var(--color-ui-foreground)!important;
- }
-
- }
- &.left:after {
- right: -1rem;
- }
- &.right:after {
- left: -1rem;
- }
-
- &.bottom, &.top {
- z-index: 2;
- min-height: 0;
- height: 0;
- &:after {
- // hover trap to display toggle-button when closed
- content: "";
- position: absolute;
- top: -1rem;
- height: 1rem;
- left: 0;
- right: 0;
- z-index: 1;
- }
- &.top:after {
- bottom: -1rem;
- top: auto;
- }
- }
-
- .resize-handle {
- position: absolute;
- top: 0;
- bottom: 0;
- width: 4rem;
- cursor: ew-resize;
- z-index: 4;
- &.right {
- left: 0;
- }
- &.left {
- right: 0;
- }
- &.bottom {
- top:0;
- left:0;
- right:0;
- height: 4rem;
- width: auto;
- cursor: ns-resize;
- }
- &.top {
- top: auto;
- bottom:0;
- left:0;
- right:0;
- height: 4rem;
- width: auto;
- cursor: ns-resize;
- }
- }
-
- .toggle-button {
-
- position: absolute;
- top: 50%;
- height: 50rem;
- width: 25rem;
- margin-top: -25rem;
- cursor: pointer;
- background: var(--color-ui-background);
- font-size: 14rem;
- z-index: 2;
- transition: transform 0.2s ease-out 0.1s, border-color 0.1s ease-out 0.1s;
- will-change: transform;
-
- border-style: solid;
- border-width: 1rem;
- border-color: transparent;
-
- &:after {
- font-family: FontAwesome;
- line-height: 50rem;
- width: 25rem;
- text-align: center;
- display: block;
- opacity: 0;
- transition: opacity 0.2s ease-out 0s;
- }
-
- &.left {
- border-top-right-radius: 25rem;
- border-bottom-right-radius: 25rem;
- right: -25rem;
- transform: translateX(-25rem);
- border-left-width: 0;
- &:after {
- content:"\f104";
- margin-left: -4rem;
- }
- }
- &.right {
- border-top-left-radius: 25rem;
- border-bottom-left-radius: 25rem;
- left: -25rem;
- transform: translateX(25rem);
- border-right-width: 0;
-
-
- &:after {
- content:"\f105";
- margin-left: 4rem;
- }
- }
-
- &.bottom {
- border-top-left-radius: 25rem;
- border-top-right-radius: 25rem;
- top: -25rem;
- height: 25rem;
- width: 50rem;
- left: 50%;
- margin-left: -25rem;
- margin-top: 0;
- cursor: pointer;
- transform: translateY(25rem);
-
- &:after {
- content:"\f107";
- margin-top: 2rem;
- width: 50rem;
- height: 25rem;
- line-height: 25rem;
-
- }
- }
-
- &.top {
- border-bottom-left-radius: 25rem;
- border-bottom-right-radius: 25rem;
- top: auto;
- bottom: -25rem;
- height: 25rem;
- width: 50rem;
- left: 50%;
- margin-left: -25rem;
- margin-top: 0;
- cursor: pointer;
- transform: translateY(- 25rem);
-
- &:after {
- content:"\f106";
- margin-bottom: 2rem;
- width: 50rem;
- height: 25rem;
- line-height: 25rem;
-
- }
- }
-
- }
-
- &:hover > .toggle-button, .toggle-button:hover {
- transition: transform 0.2s ease-out 0s, border-color 0.3s ease-out 0s;
- transform: translateX(0) translateY(0);
- border-color: var(--color-background);
- &:after {
- transition: opacity 0.1s ease-in 0.1s;
- opacity: 1;
- }
- }
-
- &.minimized .toggle-button {
- &.left:after {
- content:"\f105";
- }
- &.right:after {
- content:"\f104";
- }
- &.bottom:after {
- content:"\f106";
- }
- &.top:after {
- content:"\f107";
- }
- }
-
- &.disabled {
- pointer-events: none;
- }
-
- &.disabled .toggle-button {
- display: none;
- }
-
- &.minimized osc-panel-inner {
- display: none;
- }
-
-}
-
-osc-modal-container {
-
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
-
-}
-
-osc-panel-inner {
-
- display: flex;
- flex-direction: column;
- flex: 1;
- overflow: hidden;
- z-index: 3;
- min-width: 0;
- position: relative;
- contain: strict;
-
-}
-
-// @keyframes test{
-// 0% {
-// transform: scaleX(0);
-// opacity: 0;
-// }
-// 100% {
-// transform: scaleX(1);
-// opacity: var(--alpha-fill);
-// }
-// }
-//
-// osc-panel-container:not(.disabled) osc-panel-header:before {
-// animation: test 0.1s forwards;
-//
-// }
-
-osc-panel-header {
-
- --alpha-fill: 0.5;
-
- display: flex;
- height: var(--nav-height);
- align-items: center;
- align-items: center;
- justify-content: center;
- position:relative;
- letter-spacing: 1rem;
- font-size: 109%;
- font-weight: 500;
- text-overflow: ellipsis;
- padding: 0 8rem;
- flex-shrink: 0;
- background: var(--color-ui-foreground);
-
- &:before {
- content: "";
- position: absolute;
- left: 0rem;
- right: 0rem;
- bottom: 0rem;
- // opacity: var(--alpha-fill);
- height: 1rem;
- background: var(--color-background);
- z-index: 101;
- }
-
-}
-
-osc-panel-content {
-
-
- flex: 1;
- overflow-y: auto;
-
- &.left, &.right {
- &::-webkit-scrollbar-thumb, &::-webkit-scrollbar-track-piece {
- border-right: 1rem solid var(--color-ui-foreground);
- }
- }
-
-
-}
-
-#main {
- flex: 1;
- min-height: 40rem;
- contain: strict;
-}
-
-#osc-greeting-header {
- --alpha-fill: 0.75;
- span {
- opacity: 0.5;
- position: absolute;
- right: 12rem;
- }
- &.hidden {
- display: none;
- + #osc-container {
- // optimize layout recalc
- position: absolute;
- top:0;
- left:0;
- right:0;
- bottom:0;
- background: rgba(black, 0.35);
- }
- }
-
- &:before {
- bottom: 0;
- }
-}
-
-#osc-container {
- background: var(--color-background);
- overflow: auto;
-}
diff --git a/src/scss/widgets.scss b/src/scss/widgets.scss
deleted file mode 100644
index 01c432b0..00000000
--- a/src/scss/widgets.scss
+++ /dev/null
@@ -1,92 +0,0 @@
-.widget {
- font-weight: 500;
-
- overflow: hidden;
- position:relative;
- vertical-align:top;
-
- display: inline-flex;
- flex-direction: column;
- align-items: stretch;
-
- max-width: 100%;
- max-height: 100%;
- width: 100rem;
- height: 100rem;
-
-
- contain: strict;
- @supports not (contain: strict) {
- transform: rotateZ(0); // force new stacking context
- }
-
- -webkit-tap-highlight-color:transparent;
-
- // transform-origin: top left;
-
- --line-width: 1rem;
- --widget-padding: 1rem;
-
- --color-stroke:var(--color-widget);
- --color-fill:var(--color-widget);
-
- --alpha-stroke: 0.5;
- --alpha-fill-off: 0.0;
- --alpha-fill-on: 0.25;
- --alpha-fill: var(--alpha-fill-off);
-
- --alpha-pips: 0.5;
- --alpha-pips-text: 0.7;
- --border-radius: 0;
-
- border-radius: var(--border-radius);
-
-
- color: var(--color-text);
-
- background-color: transparent;
- background-clip: content-box;
-
-
- &.absolute-position {
- position: absolute;
- z-index: 10;
- }
-
- canvas {
- flex: 1;
- height: auto;
- min-height: 0;
- min-width: 0;
- }
-
- > inner {
- overflow: hidden;
- position: relative;
- flex: 1;
- border-radius: inherit;
- }
-
- &.no-interaction {
- pointer-events: none;
- > * {
- pointer-events: none
- }
- }
-
- .html {
- text-align: center;
- line-height: 30rem;
- min-height: 0;
- }
-
-}
-
-
-@import 'widgets/basics';
-@import 'widgets/containers';
-@import 'widgets/graphs';
-@import 'widgets/frames';
-@import 'widgets/indicators';
-@import 'widgets/pads';
-@import 'widgets/sliders';
diff --git a/src/scss/widgets/basics.scss b/src/scss/widgets/basics.scss
deleted file mode 100644
index 8d7c3cbd..00000000
--- a/src/scss/widgets/basics.scss
+++ /dev/null
@@ -1,790 +0,0 @@
-.button-container {
- width: 90rem;
- height: 60rem;
-}
-.menu-container,
-.dropdown-container,
-.input-container,
-.file-container {
- width: 90rem;
- height: 30rem;
-}
-
-
-@keyframes osc-button-pulse {
- 0% {opacity: var(--alpha-fill-on);}
- 100% {opacity: var(--alpha-fill-off);}
-}
-
-.button-container {
-
- --alpha-fill-off: .15;
- --alpha-fill-on: .75;
- --widget-padding: -1rem;
- --color-text-on: var(--color-background);
-
- inner {
-
- position: absolute;
- top:0;
- left:0;
- right:0;
- bottom:0;
- margin: var(--widget-spacing);
- padding: var(--widget-padding);
- pointer-events: none;
-
-
- @include pseudo-stroke($z: -1);
- @include pseudo-fill($z: -1);
-
- }
-
- label {
- display: flex;
- justify-content: center;
- align-items: center;
- white-space: pre;
- overflow: hidden;
- text-align: center;
- word-wrap: break-word;
- height: 100%;
- width: 100%;
- border: 2rem solid transparent;
-
- &.wrap {
- white-space: pre-wrap;
- word-break: break-all;
- }
- &.wrap-soft {
- word-break: normal
- }
- &.vertical {
- transform: rotate(180deg);
- text-overflow: ellipsis;
- -webkit-writing-mode:vertical-rl;
- writing-mode:vertical-rl;
- i {
- transform: rotate(180deg);
- writing-mode: initial;
- }
- }
- }
-
- &.on {
-
- --alpha-fill:var(--alpha-fill-on);
- color: var(--color-text-on);
-
- }
-
- // &.active {
- //
- // color: var(--color-text-on);
- //
- // }
-
- &.pulse inner:after {
- animation: osc-button-pulse .15s 1 forwards;
- }
-
-}
-
-.switch-container {
-
- --alpha-fill-off: .15;
- --alpha-fill-on: 0.75;
- --alpha-fill: var(--alpha-fill-off);
- --color-text-on: var(--color-background);
-
- @include pseudo-stroke();
- &:before {
- margin: var(--widget-spacing);
- }
-
- inner {
- position: relative;
- display: flex;
- flex-direction: column;
- --widget-spacing: calc(var(--widget-padding) / 2);
- margin: calc(var(--widget-spacing) + var(--line-width));
-
-
- }
-
- &.padding-0 inner {
- // style fix for padding == -1
- margin: 0;
-
- }
-
- &.layout-horizontal inner {
-
- flex-direction: row;
-
- }
-
- &.layout-grid inner {
-
- display:grid;
-
- }
-
-
- value {
-
- position: relative;
- z-index: 1;
- padding: 4rem;
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- text-overflow: clip;
- overflow: hidden;
-
- white-space: pre;
- text-align: center;
- word-wrap: break-word;
-
-
- @include pseudo-fill($z: -1);
- &:after {
- --line-width: 1rem;
- margin: calc(var(--widget-spacing) - 1rem);
- }
-
- &.on {
- --alpha-fill: var(--alpha-fill-on);
-
- color: var(--color-text-on);
- }
- * {
- pointer-events: none;
- }
- }
-
- &.layout-vertical value:first-child {
- border-top-left-radius: inherit;
- border-top-right-radius: inherit;
- }
- &.layout-vertical value:last-child {
- border-bottom-left-radius: inherit;
- border-bottom-right-radius: inherit;
- }
- &.layout-horizontal value:first-child {
- border-bottom-left-radius: inherit;
- border-top-left-radius: inherit;
- }
- &.layout-horizontal value:last-child {
- border-bottom-right-radius: inherit;
- border-top-right-radius: inherit;
- }
-
- &.wrap value {
- white-space: pre-wrap;
- word-break: break-all;
- }
-
- &.wrap-soft value {
- word-break: normal
- }
-
-}
-
-// @keyframes menu-widget-fade {
-// 0% {
-// transform: scale(0)
-// }
-// 100% {
-// transform: scale(1)
-// }
-// }
-
-.menu-container {
-
- --alpha-fill-off: .15;
- --alpha-fill-on: .75;
- --alpha-fill-hover: calc(var(--alpha-fill-on) / 2);
- --widget-padding: 1rem;
- --text-padding: calc(var(--widget-padding) + 8rem);
-
- &.no-icon .text {
- padding-left: var(--widget-padding);
- padding-right: var(--widget-padding);
- }
-
- // z-index: initial!important;
- // contain: style size;
-
- --size: 300rem;
- --grid-columns: 2;
-
- --parent-scroll-x: 0;
- --parent-scroll-y: 0;
-
- overflow: hidden;
-
-
- &.on {
- z-index: 9999999999999!important;
- contain: size;
- overflow: visible;
-
- // modal-breakout
- @supports not (contain: strict) {
- transform: none!important; // cancel new stacking context
- }
- }
-
-
- inner {
- display: flex;
- flex-direction: row;
- justify-content: center;
- align-items: center;
- position: relative;
- @include pseudo-stroke();
- @include pseudo-fill($z: -1);
-
- &.text-align-right .text {
- justify-content: flex-end;
- }
- &.text-align-left .text{
- justify-content: flex-start;
- }
-
-
- &.menu-align-h-right {
- justify-content: flex-end;
- }
- &.menu-align-h-left{
- justify-content: flex-start;
- }
- &.menu-align-v-top {
- align-items: flex-start;
- }
- &.menu-align-v-bottom{
- align-items: flex-end;
- }
-
- }
-
- .text {
- flex: 1;
- height: 100%;
- text-align: center;
- display: flex;
- justify-content: center;
- align-items: center;
- padding-left: var(--text-padding);
- white-space: pre;
- overflow: hidden;
- text-align: center;
- word-wrap: break-word;
- }
- .icon {
- order: 1;
- display: block;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 30rem;
- height: calc(100% - 2rem);
- font-family: FontAwesome;
- font-size: 120%;
- margin: 1rem 0;
- margin-right: var(--widget-padding);
- z-index: 1;
- &:after {
- content:"\f107";
- }
- }
-
-
- menu {
-
- // animation: menu-widget-fade .1s forwards;
- position: fixed;
- z-index: 999999999;
-
- transform: translate(calc(-1 * var(--parent-scroll-x)), calc(-1 * var(--parent-scroll-y)));
-
- overflow: hidden;
-
- background: var(--color-background);
-
- @include pseudo-stroke($z: 2);
- &:before {
- border-width: var(--line-width);
- }
-
-
- .item {
- white-space: pre;
- z-index: 1;
- overflow: hidden;
- div {
- text-align: center;
- pointer-events: none;
- }
-
- }
-
- }
-
- &.circular menu {
-
- border-radius: 100%;
- width:var(--size);
- height:var(--size);
-
-
- &:after {
- content:"";
- position: absolute;
- width: calc(var(--size) / 4 - 12rem);
- height: calc(var(--size) / 4 - 12rem);
- top:50%;
- left: 50%;
- margin-left: calc(-1 * var(--size) / 8 + 6rem);
- margin-top: calc(-1 * var(--size) / 8 + 6rem);
- background: var(--color-background);
- box-shadow: 0 0 0 2rem var(--color-background), 0 0 0 3rem var(--color-stroke);
- border-radius: 100%;
- z-index: 10;
- opacity: var(--alpha-stroke);
- }
-
- .item {
- top: calc(-1 * var(--size) / 2);
- left: calc(-1 * var(--size) / 2);
- width: 100%;
- height: 100%;
- transform-origin: 100% 100%;
- position: absolute;
- box-shadow: 0 0 0 2rem var(--color-background);
-
-
- div {
- position: absolute;
- bottom: 0;
- right: 0;
- &:before {
- content:"";
- position: absolute;
- width: calc(var(--size) / 4);
- height: calc(var(--size) / 4);
- left: calc(-1 * var(--size) / 8);
- top: calc(-1 * var(--size) / 8);
- border-radius: 100%;
- pointer-events: none;
- box-shadow: 0 0 0 calc(var(--size) / 2.7 - 2rem) var(--color-fill);
- opacity: 0.075;
- }
- }
-
- &.on {
- color: var(--color-background);
- }
-
- &.on div:before {
- opacity: var(--alpha-fill-on)!important;
- }
- &.active div:before {
- opacity: var(--alpha-fill-hover);
- }
-
-
- span {
- position: absolute;
- top: calc(-1 * var(--size) / 3);
- width: calc(var(--size) / 2);
- margin-left: calc(-1 * var(--size) / 4);
- }
-
- }
-
-
- }
-
- &.box menu {
-
- width:var(--size-box-w);
- height:var(--size-box-h);
- border-radius: inherit;
- display: flex;
-
- flex-direction: row;
- padding: calc(var(--widget-padding) / 2 + var(--line-width));
-
- .item {
- position: relative;
- margin: calc(var(--widget-padding) / 2);
-
-
- div {
- @include pseudo-fill($z: -1);
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100%;
- flex: 1;
- &:after {
- opacity: 0.075;
- margin: 0;
- top:0;left:0;right:0;bottom:0;
- }
- }
-
- &.on {
- color: var(--color-background);
- div:after {
- opacity: var(--alpha-fill-on)!important;
- }
- }
-
- &.active {
- div:after, div:after {
- opacity: var(--alpha-fill-hover);
- }
- }
-
-
- }
-
- }
-
- &.grid.on menu {
-
- display: grid;
- grid-template-columns: repeat(var(--grid-columns), 1fr);
-
- .item {
- border-radius: inherit;
- }
- }
-
- &.vertical menu {
-
- flex-direction: column;
-
- .item:first-child {
- border-top-left-radius: inherit;
- border-top-right-radius: inherit;
- }
- .item:last-child {
- border-bottom-left-radius: inherit;
- border-bottom-right-radius: inherit;
- }
-
- }
-
- &.horizontal menu {
-
- .item:first-child {
- border-bottom-left-radius: inherit;
- border-top-left-radius: inherit;
- }
- .item:last-child {
- border-bottom-right-radius: inherit;
- border-top-right-radius: inherit;
- }
-
- }
-}
-
-
-.dropdown-container {
-
- --alpha-fill-off: .15;
- --alpha-fill-on: .75;
- --widget-padding: 1rem;
- --text-padding: calc(var(--widget-padding) + 8rem);
-
- // z-index: initial!important;
- // contain: style size;
-
- --size: 300rem;
- --grid-columns: 2;
- overflow: hidden;
-
- &.no-icon .text {
- padding-left: var(--widget-padding);
- padding-right: var(--widget-padding);
- }
-
- &.on {
- z-index: 9999999999999!important;
- contain: layout;
- overflow: visible;
- }
-
-
- inner {
- display: flex;
- flex-direction: row;
- justify-content: center;
- align-items: stretch;
- position: relative;
- @include pseudo-stroke();
- @include pseudo-fill($z: -1);
-
- &.right .text {
- justify-content: flex-end;
- }
- &.left .text{
- justify-content: flex-start;
- }
- }
-
- .text {
- flex: 1;
- text-align: center;
- display: flex;
- justify-content: center;
- align-items: center;
- padding-left: var(--text-padding);
- white-space: pre;
- overflow: hidden;
- text-align: center;
- word-wrap: break-word;
- }
- .icon {
- order: 1;
- display: block;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 30rem;
- font-family: FontAwesome;
- font-size: 120%;
- margin-right: var(--widget-padding);
- &:after {
- content:"\f107";
- }
- }
-
- select {
- position: absolute;
- top:0;
- left:0;
- right:0;
- bottom:0;
- width: 100%;
- -webkit-appearance:none;
- -moz-appearance:none;
- appearance:none;
- background: var(--color-background);
- opacity: 0;
- }
- option.on {
- background: var(--color-fill)
- }
-}
-
-.editor-enabled {
- .dropdown-container select {
- // prevent input focus when selecting
- pointer-events: none;
- }
- .clone-container.editing .dropdown-container select,
- .dropdown-container.editing select {
- // prevent input focus when selecting
- pointer-events: auto;
- }
-}
-
-
-
-.input-container {
-
- --alpha-fill-off: 0.05;
- --text-padding: calc(var(--widget-padding) + 8rem);
-
- inner {
- position: relative;
- @include pseudo-stroke();
- @include pseudo-fill(0.05);
- justify-content: center;
- align-items: center;
- display: flex;
- padding: var(--widget-padding);
- text-align: center;
- &.right {
- text-align: right;
- }
- &.left {
- text-align: left;
- }
-
- padding: 0 var(--text-padding);
-
- }
-
- input + canvas {
- display: none;
- width: 0;
- }
-
- canvas {
- flex:1;
- max-width: 100%;
- height: 100%;
- }
-
- input {
- display: block;
- flex:1;
- max-width: 100%;
- font: inherit;
- border:0;
- padding:0;
- background: transparent;
- border-radius: inherit;
- text-align:inherit;
- vertical-align: top;
- letter-spacing: 1rem;
- caret-color: var(--color-fill);
- height: 100%;
- -webkit-appearance:none;
- -moz-appearance:none;
- appearance:none;
- -webkit-user-select: auto;
- -moz-user-select: auto;
- user-select: auto;
- &:focus {
- color:var(--color-fill);
- }
- &:focus::selection {
- background: var(--color-fill);
- color: var(--color-text);
- }
-
- &::-webkit-outer-spin-button,
- &::-webkit-inner-spin-button {
- -webkit-appearance: none;
- margin: 0;
- }
-
- &[type="number"] {
- -moz-appearance: textfield;
- }
-
- }
-
-}
-
-.textarea-container {
-
- --alpha-fill-off: 0.05;
- --widget-padding: 2rem;
-
- inner {
- position: relative;
- @include pseudo-stroke();
- @include pseudo-fill(0.05);
- justify-content: center;
- align-items: center;
- display: flex;
- padding: var(--widget-padding);
- text-align: center;
- &.right {
- text-align: right;
- }
- &.left {
- text-align: left;
- }
-
- }
- textarea {
- background: none;
- width: 100%;
- height: 100%;
- resize: none;
- padding: var(--widget-padding);
- -webkit-appearance:none;
- -moz-appearance:none;
- appearance:none;
- -webkit-user-select: auto;
- -moz-user-select: auto;
- user-select: auto;
- }
-}
-
-.editor-enabled {
- .textarea-container textarea,
- .input-container inner {
- // prevent input focus when selecting
- pointer-events: none;
- }
- .clone-container.editing .textarea-container textarea,
- .textarea-container.editing textarea,
- .clone-container.editing .input-container inner,
- .input-container.editing inner {
- // prevent input focus when selecting
- pointer-events: auto;
- }
-}
-
-
-.file-container {
-
- --alpha-fill-off: .15;
- --alpha-fill-on: .75;
- --widget-padding: 1rem;
- --text-padding: calc(var(--widget-padding) + 8rem);
-
- inner {
- flex:1;
- display: flex;
- flex-direction: row;
- justify-content: center;
- align-items: stretch;
- position: relative;
- @include pseudo-stroke();
- @include pseudo-fill($z: -1);
-
- &.right .text {
- justify-content: flex-end;
- }
- &.left .text{
- justify-content: flex-start;
- }
- }
-
- .text {
- flex: 1;
- text-align: center;
- display: flex;
- justify-content: center;
- align-items: center;
- padding-left: var(--text-padding);
- min-width: 0;
- overflow: hidden;
- }
-
- &.hide-path .text {
- display: none;
- }
-
- .icon {
- order: 1;
- display: block;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 30rem;
- font-family: FontAwesome;
- font-size: 120%;
- margin-right: var(--widget-padding);
- &:after {
- content:"\f07c";
- }
- }
-
- &.save .icon:after {
- content:"\f0c7";
- }
-
-}
diff --git a/src/scss/widgets/containers.scss b/src/scss/widgets/containers.scss
deleted file mode 100644
index f10598c4..00000000
--- a/src/scss/widgets/containers.scss
+++ /dev/null
@@ -1,757 +0,0 @@
-.panel-container {
- width: 200rem;
- height: 200rem;
-}
-.modal-container {
- width: 90rem;
- height: 60rem;
-}
-.keyboard-container {
- width: 220rem;
- height: 90rem;
-}
-.patchbay-container {
- width: 240rem;
- height: 160rem;
-}
-
-
-.widget-panel-base {
-
- --widget-padding: 4rem;
-
- background-color: var(--color-background);
-
-
- > inner {
- overflow: auto;
- scroll-behavior: auto!important; // smooth mode breaks scrollbar widget
- }
-
-
-
- &.hidden-scroll > inner {
- scrollbar-width: none;
- }
-
- &.no-scroll > inner {
- overflow: hidden;
- }
-
- &.contains-widgets {
-
- > inner {
- --widget-spacing: calc(var(--widget-padding) / 2);
- margin: var(--widget-spacing);
- }
-
- &.no-inner-padding > inner {
- margin: calc(var(--widget-spacing) * -1);
- }
-
- > inner > .widget {
- padding: var(--widget-spacing);
- }
-
- &.layout-default > inner {
- display: block;
- }
- &.layout-horizontal > inner {
- display: flex;
- flex-direction: row;
- align-items: stretch;
- > .widget {
- top:auto!important;
- left:auto!important;
- position: relative!important;
- height: auto!important;
- min-height: auto!important;
- max-height: 100%;
- }
- > .flex-expand {
- flex: 1
- }
- }
-
- &.layout-horizontal.layout-contain > inner > .widget {
- min-width: auto!important;
- max-width: 100%;
- }
-
- &.layout-vertical > inner,
- &.layout-vertical .folder-container > inner {
- display: flex;
- flex-direction: column;
- align-items: stretch;
- > .widget {
- top:auto!important;
- left:auto!important;
- position: relative!important;
- width: auto!important;
- min-width: auto!important;
- max-width: 100%;
- }
- > .flex-expand {
- flex: 1
- }
- }
- &.layout-vertical.layout-contain > inner > .widget {
- min-height: auto!important;
- max-height: 100%;
- }
-
- &.layout-grid > inner,
- &.layout-grid .folder-container > inner {
- display: grid;
- > .widget {
- top:auto!important;
- left:auto!important;
- position: relative!important;
- height: auto!important;
- width: auto!important;
- min-height: auto!important;
- max-height: auto!important;
- min-width: auto!important;
- max-width: auto!important;
- }
- }
-
- }
-
-
- &.contains-tabs {
-
- > inner {
-
- --widget-spacing: 0;
-
- display: flex;
- flex-direction: column;
- // overflow: hidden;
-
- > .widget {
- flex: 1;
- width: 100%;
- height: auto;
- padding: 0;
- }
- }
-
- &.tabs-left > inner {
- flex-direction: row;
- }
-
- &.tabs-right > inner {
- flex-direction: row-reverse;
- }
-
- &.tabs-bottom > inner {
- flex-direction: column-reverse;
- }
-
- &.tabs-hidden > inner > .navigation {
- display: none;
- }
-
- }
-
-}
-
-.tab-container {
- @extend .widget-panel-base;
-
- // --widget-padding: 0rem;
- --alpha-fill-on: 0.75;
-
- width: 100%;
- height: 100%;
- background-color: var(--color-background);
-
- &:not(.show) {
- display:none
- }
-
-}
-.tab-container.editing {
- z-index: initial!important;
- &:after {
- display:none;
- }
-}
-.tablink.editing:after {
- margin: 2rem 2rem 4rem;
-}
-.tabs-left > .tablink.editing:after,
-.tabs-right > .tablink.editing:after {
- margin: 2rem 4rem 2rem 2rem;
-}
-
-
-.panel-container {
-
- @extend .widget-panel-base;
-
- --alpha-fill-on: 0.75;
-
- @include pseudo-stroke($z: 1);
- &:before {
- margin: var(--widget-spacing);
- }
-
- &.contains-tabs {
- > inner {
- margin: calc(var(--line-width));
- }
- }
-
- &.contains-widgets {
-
- > inner {
- margin: calc(var(--widget-spacing) + var(--line-width));
- }
-
- &.no-inner-padding > inner {
- margin: calc(var(--widget-spacing) * -1);
- }
- }
-
-
-}
-
-.folder-container {
- display: contents;
- overflow: visible;
- contain: unset;
- min-width: 0;
- width: 0;
- min-height: 0;
- height: 0;
- padding: 0;
- margin: 0;
- > inner {
- display: contents!important;
- padding: 0;
- }
-}
-
-.root-container {
-
- @extend .widget-panel-base;
-
- --alpha-fill-on: 0.75;
-
- width: 100%;
- height: 100%;
-
- // optimize layout recalc
- &.auto-height {
- position: absolute;
- top:0;
- left:0;
- right:0;
- bottom:0;
- }
-
- > inner {
- margin: var(--widget-spacing);
-
- // optimize layout recalc
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- }
-
- margin: auto;
-
-}
-
-.root-container.editing {
- &:after {
- display:none;
- }
-}
-
-
-
-.navigation {
-
- background-color: var(--color-ui-foreground);
-
- height:var(--nav-height);
- flex-shrink:0;
- display: flex;
- // padding-bottom: 1rem;
- position: relative;
- border-bottom: 1rem solid var(--color-background);
-
- &:before {
- content:"";
- position: absolute;
- // border-bottom: 1rem solid var(--color-stroke);
- opacity: var(--alpha-stroke);
- left: 0;
- right: 0;
- bottom: 0;
- }
-
- div {
-
- // --color-stroke:var(--color-widget);
- --color-fill:var(--color-widget);
-
- color: var(--color-text);
-
- line-height:calc(var(--nav-height) - 1rem);
- display:flex;
- min-width:0;
- flex: 1 1 100%;
- cursor:pointer;
- height:100%;
- align-items: center;
- align-items: center;
- justify-content: center;
- position:relative;
- letter-spacing: 1rem;
- font-size: 109%;
- text-overflow: ellipsis;
- padding: 0 8rem;
- overflow: hidden!important;
- white-space: pre-wrap;
- text-align: center;
-
- border-right: 1rem solid var(--color-background);
-
- i {
- pointer-events: none;
- position: relative;
- }
-
- &.on {
- z-index: 1;overflow: visible;
- background: var(--color-ui-background);
- &:before {
- content: "";
- position: absolute;
- left: 0rem;
- right: 0rem;
- bottom: 0rem;
- opacity: var(--alpha-fill-on);
- height: 2rem;
- background: var(--color-fill);
- z-index: 101;
- }
-
-
- }
- }
- &.tabs-top, &.bottom {
- div {
- &:last-child {
- border-right: 0;
- }
- &:first-child:before {
- margin-left: 1rem;
- }
- &:last-child:before {
- margin-right: 1rem;
- }
- }
- }
-
-
- &.tabs-left, &.tabs-right {
- flex-direction: column;
- height: 100%;
- padding-bottom: 0;
- border-bottom: none;
- // padding-right: 1rem;
- border-right: 1rem solid var(--color-background);
-
- div {
- height: 100%;
- padding: 0 12rem;
- line-height: normal;
- border-right: none;
- border-bottom: 1rem solid var(--color-background);
-
- // justify-content: flex-start;
- // text-align: left;
-
- &.on:before {
- content: "";
- position: absolute;
- left: auto;
- top: 0rem;
- right: 0rem;
- bottom: 0rem;
- opacity: var(--alpha-fill-on);
- width: 2rem;
- height: auto;
- background: var(--color-fill);
- z-index: 101;
- }
-
- &:last-child {
- border-bottom:0
- }
- &:first-child:before {
- margin-top: 1rem;
- }
- &:last-child:before {
- margin-bottom: 1rem;
- }
- }
- }
-}
-
-
-.clone-container, .fragment-container {
-
- &.empty {
- @include pseudo-stroke();
- &:before {
- margin: var(--widget-spacing);
- }
- }
-
- &:before {
- content: none
- }
-
- > .clone,
- > .fragment {
-
- --widget-spacing: 0;
- flex: 1;
- position: relative;
-
- > .widget {
- border:0!important;
- box-shadow: none!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;
- max-width: initial!important;
- padding: 0!important;
- }
- }
-
- &.modal-breakout {
- overflow: visible;
- }
-}
-
-
-
-.modal-container {
-
- --widget-padding: -1rem;
- --popup-padding: 4rem;
-
- --color-text-on: var(--color-background);
- --alpha-fill-off: 0.15;
- --alpha-fill-on: .75;
-
- > .toggle {
-
- // --widget-padding: -1rem;
-
- position: absolute;
- top:0;
- left:0;
- right:0;
- bottom:0;
- margin: var(--widget-spacing);
- flex: 1;
- display: flex;
- flex-direction: column;
- border-radius: inherit;
-
- @include pseudo-stroke();
- @include pseudo-fill($z: -1);
-
- }
-
- > label {
- display: flex;
- justify-content: center;
- align-items: center;
- white-space: pre;
- overflow: hidden;
- text-align: center;
- word-wrap: break-word;
- height: 100%;
- width: 100%;
- border: 2rem solid transparent;
- }
-
- &.on {
-
- > .toggle {
- --alpha-fill:var(--alpha-fill-on);
- z-index: 1;
- }
- > label {
- color: var(--color-text-on);
- z-index: 2;
- }
-
- overflow: visible;
-
- contain: size;
- @supports not (contain: strict) {
- transform: none; // cancel new stacking context
- }
-
- }
-
-
-
-
-
-
- > inner {
- display: none;
- }
-
- &.no-inner-padding > .popup > .popup-wrapper > .popup-content > inner {
- margin: calc(var(--widget-spacing) * -1);
- }
- &.modal-breakout > .popup > .popup-wrapper > .popup-content {
- @extend .modal-breakout;
- }
-
-
- > .popup {
- padding:0;
- z-index: 9999999999999!important;
-
- > .popup-wrapper {
- width: var(--width, 100%);
- height: var(--height, 100%);
-
- > .popup-content {
- // contain:unset; // == no restrain
- padding: 0;
- --widget-padding: var(--popup-padding);
-
- &:before {
- content: none;
- }
-
- > inner {
- margin: var(--widget-spacing);
- }
- }
- }
-
- &.no-label > .popup-wrapper > .popup-title {
- display: none;
- }
-
- &.x-positionned {
- justify-content: flex-start;
- > .popup-wrapper {
- left: var(--left);
- }
- }
- &.y-positionned {
- align-items:flex-start;
- > .popup-wrapper {
- top: var(--top);
- }
- }
-
- }
-
- --parent-scroll-x:0;
- --parent-scroll-y:0;
- &.relative {
- > .popup {
- left: auto;
- right: auto;
- top: auto;
- bottom: auto;
- width: var(--width, 100%);
- height: var(--height, 100%);
- margin-top: calc(-1 * var(--widget-spacing) - var(--parent-scroll-y));
- margin-left: calc(-1 * var(--widget-spacing) - var(--parent-scroll-x));
- padding: var(--widget-spacing);
- align-items:flex-start;
- justify-content: flex-start;
- }
- }
-
-}
-
-.modal-breakout {
- z-index: initial!important;
- contain: size!important;
- @supports not (contain: strict) {
- transform: none!important; // cancel new stacking context
- }
-}
-
-
-
-.matrix-container {
-
- @extend .panel-container;
-
-
- &.layout-vertical, &.layout-horizontal {
- > inner > .widget {
- flex: 1;
- }
- }
-
-}
-
-
-.patchbaynode-container {
-
- justify-content: center;
- flex: 1;
- background: transparent;
-
-}
-.patchbay-container {
-
- --alpha-fill-on: .75;
- --alpha-fill-off: 0.25;
-
- inner {
- display: flex;
- flex-direction: row;
-
- @include pseudo-stroke();
- padding: var(--widget-padding);
-
- canvas {
- flex: 1;
- width: 0;
- }
- .nodes {
- display: flex;
- flex-direction: column;
- align-items:stretch;
- margin-bottom: var(--line-width);
- width: 25%;
- }
-
- .inputs, .outputs {
- position: relative;
- @include pseudo-stroke();
- top: var(--line-width);
- margin-top: -1rem;
- height: calc(100% - var(--line-width) * 2 + 2rem);
- }
-
- .inputs:before {
- border-width: 0 var(--line-width) 0 0;
- }
- .outputs:before {
- border-width: 0 0 0 var(--line-width);
- }
- }
-
- label {
- display: flex;
- justify-content: center;
- align-items: center;
- white-space: pre;
- line-height: 100%;
- overflow: hidden;
- text-align: center;
- word-wrap: break-word;
- height: 100%;
- width: 100%;
- border: 2rem solid transparent;
- pointer-events: none;
- }
-
-}
-
-
-.keyboard-container {
-
- --widget-padding: 0rem;
- --alpha-fill-off: 0;
- --alpha-fill-on: .75;
-
- --color-key-on: var(--color-fill);
- --alpha-key-off: var(--alpha-fill-off);
- --alpha-key-on: var(--alpha-fill-on);
- --color-white-key: #ccc;
- --color-black-key: #1A1A1A;
-
- --widget-keypad: calc(var(--widget-padding) + var(--line-width));
-
- > inner {
-
- padding: calc(var(--widget-padding) + var(--line-width));
- flex: 1;
- @include pseudo-stroke($z: 2);
- position: relative;
- display: flex;
- flex-direction: row;
- overflow: hidden;
- }
-
- .key {
-
- --alpha-fill-off: var(--alpha-key-off);
- --alpha-fill-on: var(--alpha-key-on);
- --line-width: 0!important;
- inner {
- margin: 1rem 0.5rem!important;
- --widget-padding: -1rem;
- &:before {
- content: none;
- }
- &:after {
- background: var(--color-key-on);
- z-index: 1;
- }
- }
- }
-
- .white {
- flex: 1;
- width: auto;
- min-width: auto;
- height: auto;
- inner {
- background: var(--color-white-key);
- }
- }
-
- .black {
- position: absolute;
- z-index: 1;
-
- left: calc((100% - var(--widget-keypad) * 2) / var(--nkeys) * var(--rank));
- width: calc(100% / var(--nkeys) * 0.6);
- margin-left: calc(100% / var(--nkeys) * -0.3 + var(--widget-keypad));
- height: calc((100% - var(--widget-keypad) * 2) * 0.65);
-
- inner {
- margin-left: 0!important;
- margin-right: 0!important;
- margin-bottom: 0!important;
- background: var(--color-black-key);
- }
- }
-
-}
diff --git a/src/scss/widgets/frames.scss b/src/scss/widgets/frames.scss
deleted file mode 100644
index 781e6d5c..00000000
--- a/src/scss/widgets/frames.scss
+++ /dev/null
@@ -1,34 +0,0 @@
-.image-container,
-.html-container,
-.svg-container,
-.frame-container {
-
- width: 120rem;
- height: 120rem;
-
- inner {
- position: relative;
- flex: 1;
- display: flex;
- padding: calc(var(--widget-spacing) + var(--line-width));
- background-clip: content-box;
- @include pseudo-stroke();
- }
-
- .frame {
- position: relative;
- width: 100%;
- flex: 1;
- }
-
-}
-
-.frame-container {
- iframe[src=""] {
- pointer-events: none;
- }
-}
-
-.editor-enabled .frame-container iframe {
- pointer-events: none;
-}
diff --git a/src/scss/widgets/graphs.scss b/src/scss/widgets/graphs.scss
deleted file mode 100644
index 016b2c4f..00000000
--- a/src/scss/widgets/graphs.scss
+++ /dev/null
@@ -1,27 +0,0 @@
-.eq-container,
-.visualizer-container,
-.plot-container {
-
- width: 200rem;
- height: 200rem;
-
- --alpha-fill-off: 0.05;
- --alpha-fill-on: 0.1;
- --widget-padding: 20rem;
-
- inner {
- position: relative;
- flex: 1;
- display: flex;
-
- @include pseudo-fill($z: -1);
- @include pseudo-stroke();
- // padding: var(--widget-padding);
- }
-
- canvas {
- // margin: var(--widget-padding);
- width: 100%;
- }
-
-}
diff --git a/src/scss/widgets/indicators.scss b/src/scss/widgets/indicators.scss
deleted file mode 100644
index f6b8a3c2..00000000
--- a/src/scss/widgets/indicators.scss
+++ /dev/null
@@ -1,105 +0,0 @@
-.led-container {
-
- width: 30rem;
- height: 30rem;
-
- --color-led: var(--color-fill);
- --alpha-fill-off: 0;
- --alpha-fill-on: 1;
-
- will-change: --opacity;
-
- inner {
-
-
- --color-fill: var(--color-led);
- --alpha-fill: calc(var(--alpha-fill-off) + var(--opacity) * (var(--alpha-fill-on) - var(--alpha-fill-off)));
-
- position: relative;
- flex: 1;
- padding: --widget-padding;
-
- @include pseudo-stroke();
- @include pseudo-fill();
-
- &:before, &:after {
- border-radius: var(--border-radius);
- will-change: opacity;
- }
- }
-
-}
-
-.text-container {
-
- width: 90rem;
- height: 60rem;
-
- --alpha-stroke: 0;
- --alpha-fill-off: 0.1;
- --alpha-fill-on: 1;
- --widget-padding: -1rem;
- --text-padding: calc(var(--widget-padding) + 8rem);
-
- inner {
- @include pseudo-stroke();
- @include pseudo-fill($z: -1);
-
- padding: var(--widget-padding);
-
- display: flex;
- width: 100%;
-
- }
-
- label {
-
- opacity: var(--alpha-fill-on);
- width: 100%;
- height: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
- white-space: pre;
- line-height: 100%;
- overflow: hidden;
- text-align: center;
- word-wrap: break-word;
- padding: var(--text-padding);
-
- &.right {
- text-align: right;
- justify-content: flex-end;
- }
- &.left {
- text-align: left;
- justify-content: flex-start;
- }
- &.top {
- align-items: flex-start;
- }
- &.bottom {
- align-items: flex-end;
- }
- &.wrap {
- white-space: pre-wrap;
- word-break: break-all;
- }
- &.wrap-soft {
- word-break: normal
- }
- &.vertical {
- transform: rotate(180deg);
- text-overflow: ellipsis;
- -webkit-writing-mode:vertical-rl;
- writing-mode:vertical-rl;
- i {
- transform: rotate(180deg);
- writing-mode: initial;
- }
- }
- i {
- margin-top: -1rem;
- }
- }
-}
diff --git a/src/scss/widgets/pads.scss b/src/scss/widgets/pads.scss
deleted file mode 100644
index edc88ea2..00000000
--- a/src/scss/widgets/pads.scss
+++ /dev/null
@@ -1,157 +0,0 @@
-.xy-container,
-.multixy-container,
-.rgb-container,
-.canvas-container {
- width: 200rem;
- height: 200rem;
-}
-
-.xy-container, .multixy-container {
-
- --alpha-fill-off: 0.05;
- --alpha-fill: var(--alpha-fill-off);
- --widget-padding: 20rem;
-
- inner {
- position: relative;
- flex: 1;
- display: flex;
-
- @include pseudo-fill($z: -1);
- @include pseudo-stroke();
- }
-
- canvas {
- width: 100%;
- text-align: center;
- }
-
-}
-
-.multixy-container {
-
- --point-size: 20rem;
-
- canvas {
- position: absolute;
- top: 0;
- left: 0;
- height: 100%;
- width: 100%;
- pointer-events: none;
- }
-
-}
-
-.rgb-container {
-
- --widget-padding: 4rem;
-
- > inner {
-
- display: grid;
-
- @include pseudo-stroke($z: 1);
-
- --widget-spacing: calc(var(--widget-padding) / 2);
-
- padding: calc(var(--line-width) + var(--widget-spacing));
-
- grid-template:
- "a a b" auto / 1fr;
-
- }
-
- &.contains-alpha > inner {
- grid-template:
- "a a b" auto
- "c c c" calc(20rem + var(--widget-spacing) * 2) / 1fr;
- }
-
- .widget {
- height: auto;
- width: auto;
- margin: var(--widget-spacing);
- --widget-padding: 2rem;
- --line-width: 0;
- }
-
- .pad {
- grid-area: a;
-
- background-color: red;
- background-image: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,1) 100%), linear-gradient(to right, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
- --color-fill: black;
- --color-stroke: white;
- --alpha-fill-off: 1;
- --alpha-fill-on: 1;
- --alpha-stroke: 1;
- inner {
- &:after, &:before {
- content: none;
- }
- }
- }
-
- .hue {
- grid-area: b;
- width: 20rem;
-
- --color-fill: white;
- // --color-stroke: white;
- --alpha-fill-off: 0.5;
- --alpha-fill-on: 0;
- --alpha-stroke: 0;
- --widget-padding: 0rem;
-
- &:after {
- content:"";
- position: absolute;
- top: 0;
- left: 2rem;
- right: 2rem;
- bottom: 0;
- background: linear-gradient(to bottom, #F00, #FF0080, #F0F, #8000FF, #00F, #0080FF, #0FF, #00FF80, #0F0, #80FF00, #FF0, #FF8000, #F00) repeat scroll 0% 0%;
- opacity: 0.75;
- z-index: -1;
- }
- }
-
- .alpha {
- grid-area: c;
- height: auto!important;
- width: auto!important;
- --alpha-stroke: 0;
- --alpha-fill-off: 0.1;
- --alpha-fill-on: 0.25;
- --widget-padding: 0rem;
- }
-
-}
-
-
-.canvas-container {
-
- --alpha-fill-off: 0.05;
- --alpha-fill-on: 0.75;
- --alpha-fill: var(--alpha-fill-off);
- --widget-padding: 0rem;
- .html {
- pointer-events: auto;
- }
-
- inner {
- position: relative;
- flex: 1;
- display: flex;
-
- @include pseudo-fill($z: -1);
- @include pseudo-stroke();
- }
-
- canvas {
- width: 100%;
- text-align: center;
- }
-
-}
diff --git a/src/scss/widgets/sliders.scss b/src/scss/widgets/sliders.scss
deleted file mode 100644
index a5f4b6fe..00000000
--- a/src/scss/widgets/sliders.scss
+++ /dev/null
@@ -1,77 +0,0 @@
-.fader-container,
-.scrollbar-container,
-.knob-container,
-.encoder-container,
-.range-container {
-
- --color-knob: var(--color-fill);
-
- canvas {
- image-rendering: pixelated;
- width: 100%;
- height: auto;
- }
-
-}
-
-.scrollbar-container,
-.fader-container,
-.range-container {
-
- width: 50rem;
- height: 200rem;
-
- --widget-padding: 1rem;
- --knob-size: 1rem;
- --line-width: 1rem;
-
- canvas {
- text-align: left;
- }
-
- &.horizontal {
- width: 200rem;
- height: 50rem;
- }
-
- &.design-default {
- --knob-size: 20rem;
- --widget-padding: 10rem;
- --alpha-stroke: 0.5;
- --alpha-fill-off: 0.25;
- --alpha-fill-on: 1;
- --line-width: 2rem
- }
-
- &.design-round {
- --knob-size: 20rem;
- --widget-padding: 10rem;
- --alpha-stroke: 0.25;
- --alpha-fill-off: 0.25;
- --alpha-fill-on: 1;
- --line-width: 2rem
- }
-
-}
-
-.knob-container,
-.encoder-container {
-
- width: 100rem;
- height: 100rem;
-
- --widget-padding: 1rem;
- --alpha-stroke: 0.75;
-
- &.design-solid, &.design-line {
- --alpha-fill-off: 0.25;
- --alpha-fill-on: 1;
- --line-width: 2rem;
- }
-
-}
-
-.scrollbar-container {
- --alpha-fill-off: 0;
- --alpha-fill-on: var(--alpha-scrollbar);
-}
diff --git a/src/server/electron/electron-app.mjs b/src/server/electron/electron-app.mjs
deleted file mode 100644
index eac5e9b0..00000000
--- a/src/server/electron/electron-app.mjs
+++ /dev/null
@@ -1,137 +0,0 @@
-import {app, Menu, shell, BrowserWindow} from 'electron'
-import semver from 'semver'
-import * as settings from '../node/settings.mjs'
-
-app.setPath('userData', settings.configPath)
-
-app.commandLine.appendSwitch('--ignore-certificate-errors')
-
-app.commandLine.appendSwitch('--touch-events')
-
-if (settings.read('disable-vsync')) {
- app.commandLine.appendSwitch('--disable-gpu-vsync')
-}
-
-if (settings.read('disable-gpu')) {
- app.disableHardwareAcceleration()
- app._noGpu = true
-}
-
-if (settings.read('force-gpu')) {
- app.commandLine.appendSwitch('--ignore-gpu-blacklist')
-}
-
-// Workaround bug in electron 36 + gnome: https://github.com/electron/electron/issues/46538
-if (process.platform === 'linux') {
- app.commandLine.appendSwitch('gtk-version', '3')
-}
-
-if (semver.gt(settings.infos.version, settings.read('version') || '0.0.0')) {
- // set temporary flag to clean electron browser cache in case of update
- settings.write('clearCache', true, true)
-}
-
-
-var template = [{
- label: 'Edit',
- submenu: [
- {role: 'undo', accelerator: 'CmdOrCtrl+Z'},
- {role: 'redo', accelerator: 'Shift+CmdOrCtrl+Z'},
- {type: 'separator'},
- {role: 'cut', accelerator: 'CmdOrCtrl+X'},
- {role: 'copy', accelerator: 'CmdOrCtrl+C'},
- {role: 'paste', accelerator: 'CmdOrCtrl+V'},
- {role: 'selectall', accelerator: 'CmdOrCtrl+A'}
- ]
-}]
-
-if (process.platform === 'darwin') {
- // Add app menu (macOs)
- template.unshift({
- label: settings.infos.productName,
- submenu: [
- {
- label: 'Hide ' + settings.infos.productName,
- accelerator: 'Command+H',
- role: 'hide'
- },
- {
- label: 'Hide Others',
- accelerator: 'Command+Alt+H',
- role: 'hideothers'
- },
- {
- label: 'Show All',
- role: 'unhide'
- },
- {
- type: 'separator'
- },
- {
- label: 'Quit',
- accelerator: 'CmdOrCtrl+Q',
- click: ()=>app.quit()
- }
- ]
- })
- template.push(
- {
- label: 'Window',
- role: 'window',
- submenu: [
- {
- label: 'Minimize',
- accelerator: 'CmdOrCtrl+M',
- role: 'minimize'
- },
- {
- type: 'separator'
- },
- {
- label: 'Close',
- accelerator: 'CmdOrCtrl+W',
- click: ()=>{
- var win = BrowserWindow.getFocusedWindow()
- if (win) win.close()
- }
- },
- {
- type: 'separator'
- },
- {
- label: 'Bring All to Front',
- role: 'front'
- },
- ]
- },
- {
- label: 'Help',
- role: 'help',
- submenu: [
- {
- label: 'Documentation',
- click: ()=>shell.openExternal(settings.infos.homepage)
- },
- {
- type: 'separator'
- },
- {
- label: 'Report an Issue',
- click: ()=>shell.openExternal(settings.infos.repository.url + '/issues')
- }
- ]
- }
- )
-}
-
-
-app.on('ready',()=>{
- var menu = Menu.buildFromTemplate(template)
- Menu.setApplicationMenu(menu)
-})
-
-app.on('window-all-closed', function() {
- app.quit()
-})
-
-export default app
diff --git a/src/server/electron/electron-window.mjs b/src/server/electron/electron-window.mjs
deleted file mode 100644
index 5dc78b27..00000000
--- a/src/server/electron/electron-window.mjs
+++ /dev/null
@@ -1,217 +0,0 @@
-import path from 'path'
-import {BrowserWindow, dialog, shell, screen, Menu, MenuItem} from 'electron'
-import shortcut from 'electron-localshortcut'
-import app from './electron-app.mjs'
-import * as settings from '../node/settings.mjs'
-
-export default function(options={}) {
-
- var window
-
- window = new BrowserWindow({
- title: options.title || settings.infos.productName,
- icon: path.resolve(__dirname + '/../../assets/logo.png'),
- backgroundColor: '#21252B',
- type: options.type,
- useContentSize: true,
- darkTheme: true,
- autoHideMenuBar: true,
- webPreferences: {
- nodeIntegration: !!options.node,
- contextIsolation: !options.node,
- enableRemoteModule: !!options.node
- },
- show: false,
- })
-
-
-
- // default geometry
- var currentScreen = screen.getDisplayNearestPoint(screen.getCursorScreenPoint()),
- screenSize = currentScreen.size,
- width = options.width || screenSize.width,
- height = options.height || screenSize.height,
- bounds = currentScreen.bounds,
- x = Math.ceil(bounds.x + ((bounds.width - width) / 2)),
- y = Math.ceil(bounds.y + ((bounds.height - height) / 2)),
- geometry = {x, y, width, height}
-
- // retrieve last geometry
- if (settings.read('geometry') && settings.read('geometry')[options.id]) {
- var last_geometry = settings.read('geometry')[options.id],
- mScreen = screen.getDisplayMatching(geometry)
- if (intersectionArea(geometry, mScreen.bounds) > 20000) {
- // don't load geometry if the window is not visible enough
- Object.assign(geometry, last_geometry)
- }
- }
-
- if (options.id === 'client') {
- if (settings.read('client-position')) {
- [x, y] = settings.read('client-position').split(',').map(x=>parseInt(x))
- Object.assign(geometry, {x, y})
- }
-
- if (settings.read('client-size')) {
- [width, height] = settings.read('client-size').split(',').map(x=>parseInt(x))
- Object.assign(geometry, {width, height})
- }
- }
-
- window.setBounds(geometry)
-
- window.once('ready-to-show', ()=>{
- if (options.id === 'launcher' && settings.read('startMinimized')) {
- if (settings.read('useTray') || process.platform === 'darwin') {
- window.hide()
- } else {
- window.show()
- window.minimize()
- }
- } else {
- window.show()
- }
- })
-
- if (options.id === 'launcher' && process.platform === 'darwin' && settings.read('startMinimized')) {
- app.on('activate', ()=>{
- if (!window.isDestroyed()) window.show()
- })
- }
-
- window.webContents.once('page-title-updated', ()=>{
- if (options.fullscreen) {
- window.webContents.executeJavaScript('window.ELECTRON_FULLSCREEN()', true)
- }
- if (app._noGpu) {
- window.webContents.executeJavaScript(`
- window.ELECTRON_NOGPU = true
- `)
- }
- })
-
-
- window.webContents.on('will-prevent-unload', (event)=>{
- var choice = dialog.showMessageBoxSync(window, {
- type: 'question',
- buttons: ['Yes', 'No'],
- title: 'Are you sure ?',
- message: 'Unsaved data will be lost. Are you sure you want to quit?',
- defaultId: 0,
- cancelId: 1
- })
- if (choice === 0) {
- event.preventDefault()
- }
- })
-
-
- window.webContents.on('certificate-error', function(event, url, error, certificate, callback) {
- if (error === 'net::ERR_CERT_AUTHORITY_INVALID') {
- // self signed certificate is ok
- event.preventDefault()
- callback(true)
- }
- })
-
- window.webContents.on('login', function(event, request, authInfo, callback) {
- event.preventDefault()
- var [name, pwd] = settings.read('authentication').split(':')
- callback(name, pwd)
- })
-
- // window.webContents.on('will-navigate', (event)=>event.preventDefault())
- window.webContents.on('new-window', (event, url)=>{
- event.preventDefault()
- shell.openExternal(url)
- })
-
-
- window.webContents.on('console-message', (event)=>{
-
- if (event.level === 0 && event.message === 'ELECTRON.BLUR()') window.blur()
- if (event.level === 0 && event.message === 'ELECTRON.FOCUS()') window.focus()
- if (event.level === 0 && event.message === 'ELECTRON.SETFOCUSABLE(1)') {
- window.setFocusable(true)
- window.focus()
- }
- if (event.level === 0 && event.message === 'ELECTRON.SETFOCUSABLE(0)') {
- window.setFocusable(false)
- window.blur()
- }
-
- })
-
- window.webContents.setVisualZoomLevelLimits(1, 1)
-
- window.on('closed', function() {
- window = null
- })
-
- window.setMenu(null)
-
- window.loadURL(options.address)
-
- if (process.platform === 'linux') {
- // already registered in app menu on macOs
- // already bound to alt+f4 on windows
- window.webContents.on('before-input-event', (e, input)=>{
- // using before-input-event because electron-localshortcut
- // gets azerty keyboards wrong (ctrl + z would also be caught)
- if ((input.key === 'w' || input.key === 'W') && input.control && input.type === 'keyDown') {
- window.close()
- }
- })
- }
-
- window.on('close', function() {
- // save geometry
- var geometry = settings.read('geometry') || {}
- geometry[options.id] = window.getBounds()
- settings.write('geometry', geometry, false, true)
- })
-
- var menu = new Menu()
- menu.append(new MenuItem({role: 'cut'}))
- menu.append(new MenuItem({role: 'copy'}))
- menu.append(new MenuItem({role: 'paste'}))
- window.webContents.on('context-menu', (e, data) => {
- menu.items[0].enabled = data.editFlags.canPaste
- menu.items[1].enabled = data.editFlags.canCopy
- menu.items[2].enabled = data.editFlags.canPaste
- menu.popup({window: window, x: e.x, y: e.y })
- }, false)
-
- if (options.shortcuts && !settings.read('read-only')) {
-
- shortcut.register(window,'CmdOrCtrl+R',function(){
- window.reload()
- })
-
- shortcut.register(window,'F12',function(){
- window.toggleDevTools()
- })
-
- } else {
- shortcut.register(window,'CmdOrCtrl+R',function(e){
- return false
- })
- }
-
- window.setFocusable(!options.noFocus)
-
-
- return window
-
-}
-
-
-function intersectionArea(a, b) {
- // intersectionArea between two rectangles
-
- var width = Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x),
- height = Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y)
-
- return width * height
-
-}
diff --git a/src/server/electron/index.mjs b/src/server/electron/index.mjs
deleted file mode 100644
index 1f9179a4..00000000
--- a/src/server/electron/index.mjs
+++ /dev/null
@@ -1,319 +0,0 @@
-import sourceMap from 'source-map-support'
-import {fork} from 'child_process'
-import path from 'path'
-import {ipcMain} from 'electron'
-import electronRemote from '@electron/remote/main'
-import * as settings from '../node/settings.mjs'
-import DocsServer from '../node/docs-server'
-import app from './electron-app.mjs'
-import window from './electron-window'
-import createTray from './tray.mjs'
-import midi from '../node/midi.mjs'
-import qrcode from '../node/qrcode.mjs'
-
-var dev = process.argv[0].includes('node_modules'),
- docsServer,
- launcher = null,
- tray = null,
- clientWindows = [],
- serverProcess = null
-
-sourceMap.install({handleUncaughtExceptions: false})
-
-function openDocs() {
-
- if (!docsServer) docsServer = new DocsServer()
-
- docsServer.open()
-
-}
-
-
-function openClient() {
-
- var address = settings.appAddresses()[0]
-
- function launch() {
- var win = window({
- address:address,
- shortcuts:true,
- fullscreen: settings.read('fullscreen'),
- noFocus: settings.read('client-options') && settings.read('client-options').some(x=>x.match(/nofocus=1/i)),
- id: 'client'
- })
- win.on('error', ()=>{
- console.log('ERR')
- })
- if (settings.read('clearCache')) {
- // clear browser cache and reload
- win.webContents.session.clearCache().then(()=>{
- settings.write('version', settings.infos.version)
- win.webContents.reload()
- })
- }
- clientWindows.push(win)
- }
-
-
- if (app.isReady()) {
- launch()
- } else {
- app.on('ready',function(){
- launch()
- })
- }
-
-}
-
-function startServerProcess() {
-
- var args = [ '--no-gui']
-
- for (var k in settings.read('options')) {
- args.push('--' + k)
- var val = settings.read(k)
- if (typeof val === 'object') {
- args = args.concat(val)
- } else if (typeof val !== 'boolean') {
- args.push(val)
- }
- }
-
- serverProcess = fork(app.getAppPath(), args, {stdio: 'pipe', env: {...process.env, OSC_SERVER_PROCESS: 1, ELECTRON_RUN_AS_NODE: 1}})
-
- var cb = (data)=>{
- if (data.indexOf('(INFO) Server started') > -1) {
- if (!settings.read('no-gui')) openClient()
- if (!settings.read('no-qrcode')) setTimeout(()=>{
- qrcode(launcher ? 'svg' : 'terminal', (qrstring)=>{
- if (launcher) {
- launcher.webContents.send('stdout', qrstring)
- } else {
- console.log(qrstring)
- }
- })
- })
- serverProcess.stdout.off('data', cb)
- }
- }
- serverProcess.stdout.on('data', cb)
-
- serverProcess.stdout.on('data', (data) => {
- console.log(String(data).trim())
- })
-
- serverProcess.stderr.on('data', (data) => {
- var str = String(data).trim()
- if (str.includes('--debug')) return
- console.error(str)
- })
-
-
-
- serverProcess.on('message', (data) => {
- var [command, args] = data
- if (command === 'settings.write') {
- settings.write(args[0], args[1], false)
- }
- })
-
- serverProcess.on('close', (code) => {
- console.log('(INFO) Server stopped')
- serverProcess = null
- if (global.defaultClient) global.defaultClient.close()
- })
-
- if (launcher) {
- serverProcess.on('close', (code) => {
- if (!launcher.isDestroyed()) launcher.webContents.send('server-stopped')
- })
- launcher.webContents.send('server-starting')
- }
-
-}
-
-function stopServerProcess() {
-
- if (settings.read('no-gui')) {
- if (serverProcess) serverProcess.kill('SIGINT')
- serverProcess = null
- return
- }
-
- var toClose = clientWindows.filter(w=>w && !w.isDestroyed()),
- closed = 0
-
- if (toClose.length === 0 && serverProcess) {
- serverProcess.kill('SIGINT')
- serverProcess = null
- }
-
- for (var w of toClose) {
- w.on('closed', ()=>{
- closed++
- if (closed === toClose.length) {
- clientWindows = []
- if (serverProcess) {
- serverProcess.kill('SIGINT')
- serverProcess = null
- }
- }
- })
- w.close()
- }
-
-}
-
-function startLauncher() {
-
- global.launcherSharedGlobals = {
- settings: settings,
- openDocs: openDocs,
- midiList: midi.list,
- midiRestart: ()=>{
- if (serverProcess) {
- serverProcess.send('midiRestart')
- }
- }
- }
- var address = 'file://' + path.resolve(__dirname + '/../../launcher/' + 'index.html')
-
- // @electron/remote won't work without this hack
- process.mainModule = {require}
- electronRemote.initialize()
-
- app.on('ready', function(){
-
- launcher = window({address:address, shortcuts:dev, width:680, height:(40 + 200 + 20 + 24 * Object.keys(settings.options).filter(x=>settings.options[x].launcher !== false).length / 2), node:true, id: 'launcher'})
-
- electronRemote.enable(launcher.webContents)
-
- if (settings.read('useTray')) {
-
- tray = createTray({
- window: launcher,
- openClient: openClient,
- app: app,
- startServer: startServerProcess,
- stopServer: stopServerProcess
- })
-
- launcher.on('will-close', (e)=>{
- if (clientWindows.some(w=>w && !w.isDestroyed()) || serverProcess) {
- launcher.hide()
- e.preventDefault()
- }
- })
-
- }
-
-
- launcher.on('close', (e)=>{
- if (tray && (clientWindows.some(w=>w && !w.isDestroyed()) || serverProcess)) {
- launcher.hide()
- e.preventDefault()
- return
- }
- process.stdout.write = stdoutWrite
- process.stderr.write = stderrWrite
- if (process.log) process.log = processLog
- if (tray) tray.destroy()
- })
-
- })
-
- let processLog = process.log,
- stdoutWrite = process.stdout.write,
- stderrWrite = process.stderr.write
-
- if (process.log) {
- process.log = function(string, encoding, fd) {
- processLog.apply(process, arguments)
- launcher.webContents.send('stdout', string)
- }
- }
-
- process.stdout.write = function(string, encoding, fd) {
- stdoutWrite.apply(process.stdout, arguments)
- launcher.webContents.send('stdout', string)
- }
-
- process.stderr.write = function(string, encoding, fd) {
- stderrWrite.apply(process.stderr, arguments)
- launcher.webContents.send('stderr', string)
- }
-
- ipcMain.on('start',function(e, options){
-
- startServerProcess()
-
- })
-
- ipcMain.on('stop',function(e, options){
-
- stopServerProcess()
-
- })
-
- ipcMain.on('openClient',function(e, options){
-
- openClient()
-
- })
-
- ipcMain.on('showQRCode',function(e, options){
-
- qrcode('svg', (qrstring)=>{
- launcher.webContents.send('stdout', qrstring)
- })
-
- })
-
-
- ipcMain.on('hide',function(e, options){
-
- launcher.hide()
-
- })
-}
-
-
-if (settings.read('docs')) {
-
- openDocs()
-
-} else {
-
- // normal mode:
- // - electron process: launcher and/or built-in client(s)
- // - node process: server (node mode in a forked process)
-
- app.on('ready', ()=>{
- process.on('SIGINT', function() {
- if (serverProcess) {
- serverProcess.kill('SIGINT')
- serverProcess = null
- }
- process.exit(0)
- })
- })
-
- app.on('before-quit',()=>{
- if (serverProcess) {
- serverProcess.kill('SIGINT')
- serverProcess = null
- }
- })
-
-
- if (settings.cli) {
-
- startServerProcess()
-
- } else {
-
- startLauncher()
-
- }
-
-}
diff --git a/src/server/electron/tray.mjs b/src/server/electron/tray.mjs
deleted file mode 100644
index 3e17cedb..00000000
--- a/src/server/electron/tray.mjs
+++ /dev/null
@@ -1,92 +0,0 @@
-import {Menu, Tray, ipcMain} from 'electron'
-import * as settings from '../node/settings.mjs'
-
-var tray = null,
- contextMenu = null,
- isServerRunning = false
-
-export default function(options = {}) {
-
- var icon = __dirname + '/../../assets/logo.png'
- if (process.platform === 'darwin') {
- icon = __dirname + '/../../assets/logo_tray.png'
- }
-
- tray = new Tray(icon)
- contextMenu = Menu.buildFromTemplate([
- {
- label: 'Show launcher',
- id: 'show',
- click: ()=>{
- options.window.show()
- }
- },
- {
- label: 'Hide launcher',
- id: 'hide',
- click: ()=>{
- options.window.hide()
- }
- },
- {
- label: 'Start server',
- id: 'start',
- click: ()=>{
- ipcMain.emit('start')
- }
- },
- {
- label: 'Stop server',
- id: 'stop',
- click: ()=>{
- ipcMain.emit('stop')
- }
- },
- {
- label: 'New client window',
- id: 'new',
- click: ()=> {
- if (isServerRunning) {
- options.openClient()
- }
- }
- },
- {
- type: 'separator'
- },
- {
- label: 'Quit',
- click: ()=>{
- options.app.quit()
- }
- },
- ])
-
- tray.setContextMenu(contextMenu)
- tray.setToolTip(settings.infos.productName)
-
- function updateMenu(){
- contextMenu.getMenuItemById('start').visible = !isServerRunning
- contextMenu.getMenuItemById('stop').visible = isServerRunning
- contextMenu.getMenuItemById('show').visible = !options.window.isVisible()
- contextMenu.getMenuItemById('hide').visible = options.window.isVisible()
- contextMenu.getMenuItemById('new').visible = isServerRunning
- tray.setContextMenu(contextMenu)
- }
-
- ipcMain.on('start', function(e, options) {
- isServerRunning = true
- updateMenu()
- })
-
- ipcMain.on('stop', function(e, options) {
- isServerRunning = false
- updateMenu()
- })
-
- options.window.on('show', updateMenu)
- options.window.on('hide', updateMenu)
-
- return tray
-
-}
diff --git a/src/server/index.js b/src/server/index.js
deleted file mode 100644
index e8f3279d..00000000
--- a/src/server/index.js
+++ /dev/null
@@ -1,15 +0,0 @@
-var runtime = 'node'
-
-if (!process.argv.includes('-n') && !process.argv.includes('--no-gui')
- && process.versions.electron && !process.env.ELECTRON_RUN_AS_NODE)
-{
- try {
- var electron = require('electron')
- electron.dialog.showErrorBox = (title, err)=>{
- console.error(title + ': ' + err)
- }
- runtime = 'electron'
- } catch {}
-}
-
-require(`./${runtime}/`)
diff --git a/src/server/node/address.mjs b/src/server/node/address.mjs
deleted file mode 100644
index 013c8ac0..00000000
--- a/src/server/node/address.mjs
+++ /dev/null
@@ -1,10 +0,0 @@
-import {networkInterfaces} from 'os'
-
-export default (proto, port)=>{
- var address = Object.values(networkInterfaces())
- .reduce((a,b)=>a.concat(b), [])
- .filter(i=>i.family === 'IPv4')
- .map(i=>i.address + ':')
-
- return address.map(x=>proto + x + port)
-}
diff --git a/src/server/node/auth.mjs b/src/server/node/auth.mjs
deleted file mode 100644
index b1fcad0d..00000000
--- a/src/server/node/auth.mjs
+++ /dev/null
@@ -1,23 +0,0 @@
-import httpAuth from 'http-auth'
-import * as settings from './settings.mjs'
-
-var auth = null
-
-if (settings.read('authentication')) {
-
- var [name, pwd] = settings.read('authentication').split(':')
-
- auth = httpAuth.basic(
- {
- realm: 'Open Stage Control'
- },
- (username, password, callback) => {
- // Custom authentication method.
- callback(username === name && password === pwd)
- }
- )
-
-}
-
-
-export default auth
diff --git a/src/server/node/custom-module.mjs b/src/server/node/custom-module.mjs
deleted file mode 100644
index 5169cd61..00000000
--- a/src/server/node/custom-module.mjs
+++ /dev/null
@@ -1,267 +0,0 @@
-import fs from 'fs'
-import vm from 'vm'
-import chokidar from 'chokidar'
-import path from 'path'
-import {Module} from 'module'
-import * as settings from './settings.mjs'
-
-var modulePathExtended = false,
- loadedModules = {},
- globalObject = {}
-
-class CustomModule {
-
- constructor(file, context, parent=null, mainModule=null) {
-
- this.module = {exports: null}
- this.init = null
- this.oscInFilter = null
- this.oscOutFilter = null
-
- this.mainModule = mainModule
-
- this.parent = parent
- this.submodule = !!parent
-
- this.filename = this.submodule ? file : path.resolve(file)
-
- this.timeouts = []
- this.intervals = []
- this.submodules = {}
-
-
- this.context = this.submodule ? {
- ...context,
- require: this.require.bind(this),
- } : {
- ...context,
- loadJSON: (url, errorCallback)=>{
- try {
- url = path.resolve(path.dirname(this.filename), url)
- var content = fs.readFileSync(url, 'utf8')
- if (content[0] === '\ufeff') content = content.slice(1) // remove BOM
- return JSON.parse(content)
- } catch(e) {
- if (typeof(errorCallback) === 'function') {
- errorCallback(e)
- } else {
- console.error('(ERROR, CUSTOM MODULE) could not load json file from ' + url)
- console.error(e.message)
- }
- }
- },
- saveJSON: (url, data, errorCallback)=>{
- url = path.resolve(path.dirname(this.filename), url)
- try {
- return fs.writeFileSync(url, JSON.stringify(data, null, ' '))
- } catch(e) {
- if (typeof(errorCallback) === 'function') {
- errorCallback(e)
- } else {
- console.error('(ERROR, CUSTOM MODULE) could not save json file to ' + url)
- console.error(e.message)
- }
- }
- },
- console: console,
- settings: {
- read: settings.read,
- appAddresses: settings.appAddresses,
- },
- setTimeout: this.setTimeout.bind(this),
- clearTimeout: this.clearTimeout.bind(this),
- setInterval: this.setInterval.bind(this),
- clearInterval: this.clearInterval.bind(this),
- require: this.require.bind(this),
- nativeRequire: require,
- process: process,
- global: globalObject
- }
-
- if (!this.submodule && !modulePathExtended) {
- process.env.NODE_PATH += path.delimiter + path.resolve(path.dirname(this.filename))
- process.env.NODE_PATH += path.delimiter + path.resolve(path.dirname(this.filename), 'node_modules')
- Module._initPaths()
- modulePathExtended = true
- }
-
- this.load()
-
- this.watcher = chokidar.watch(this.filename, {awaitWriteFinish: {stabilityThreshold: 200}}).on('change', ()=>{
- if (this.submodule) {
- console.log('(INFO) Submodule changed: ' + this.filename)
- this.mainModule.reload()
- } else {
- console.log('(INFO) Custom module changed: ' + this.filename)
- this.reload()
- }
- })
-
- }
-
- load() {
-
- if (loadedModules[this.filename]) {
- this.module.exports = loadedModules[this.filename].module.exports
- return true
- }
-
- var code
-
- try {
- code = fs.readFileSync(this.filename, {encoding: 'utf8', flag: 'rs'}) // flag 'rs' to avoid cache issue on windows
- } catch(err) {
- console.error(`(ERROR, CUSTOM MODULE) Module not found: ${this.filename}`)
- return false
- }
-
- var context = vm.createContext({
- ...this.context,
- __dirname: path.resolve(path.dirname(this.filename)),
- __filename: path.resolve(this.filename),
- module: this.module
- })
-
-
- try {
- loadedModules[this.filename] = this
- vm.runInContext(code, context, {
- filename: this.filename
- })
- } catch(err) {
- loadedModules[this.filename] = null
- console.error('(ERROR, CUSTOM MODULE) Error while loading module')
- console.log(err)
- return false
- }
-
- if (typeof this.module.exports === 'object' && this.module.exports !== null) {
- this.init = this.module.exports.init || null
- this.oscInFilter = this.module.exports.oscInFilter || null
- this.oscOutFilter = this.module.exports.oscOutFilter || null
- }
-
- return true
-
- }
-
- unload() {
-
- if (!loadedModules[this.filename]) return
- loadedModules[this.filename] = null
-
- if (this.module.exports && this.module.exports.unload) {
- try {
- this.module.exports.unload()
- } catch(e) {
- console.error('(ERROR, CUSTOM MODULE) Error while calling unload()')
- console.error(e)
- }
- }
-
- this.module = {exports: null}
- this.init = null
- this.oscInFilter = null
- this.oscOutFilter = null
-
- for (let timeout of this.timeouts) {
- clearTimeout(timeout)
- }
-
- for (let interval of this.intervals) {
- clearInterval(interval)
- }
-
- this.timeouts = []
- this.intervals = []
-
- for (let name of this.context.app.eventNames()) {
- this.context.app.removeAllListeners(name)
- }
-
- for (let name in this.submodules) {
- this.submodules[name].unload()
- }
- this.submodules = {}
-
- if (this.submodule) {
- this.watcher.close()
- }
-
- }
-
- reload() {
-
- this.unload()
- console.log('(INFO) Reloading custom module...')
- if (this.load()) {
- console.log('(INFO) Custom module reloaded successfully')
-
- if (this.module.exports && this.module.exports.reload) {
- try {
- this.module.exports.reload()
- } catch(e) {
- console.error('(ERROR, CUSTOM MODULE) Error while calling custom module reload function')
- console.error(e)
- }
- }
- } else {
- console.error('(ERROR, CUSTOM MODULE) Failed to reload custom module')
- this.unload()
- }
- }
-
- stop() {
-
- if (this.module.exports && this.module.exports.stop) {
- try {
- this.module.exports.stop()
- } catch(e) {
- console.error('(ERROR, CUSTOM MODULE) Error while calling custom module stop function')
- console.error(e)
- }
- }
- }
-
- setTimeout(fn, t) {
- var timeout = setTimeout(fn, t)
- this.timeouts.push(timeout)
- return timeout
- }
-
- setInterval(fn, t) {
- var interval = setInterval(fn, t)
- this.intervals.push(interval)
- return interval
- }
-
- clearTimeout(timeout) {
- clearTimeout(timeout)
- if (this.timeouts.includes(timeout)) {
- this.timeouts.splice(this.timeouts.indexOf(timeout), 1)
- }
- }
-
- clearInterval(interval) {
- clearInterval(interval)
- if (this.intervals.includes(interval)) {
- this.intervals.splice(this.intervals.indexOf(interval), 1)
- }
- }
-
- require(filename) {
-
- if (!path.isAbsolute(filename)) {
- filename = path.resolve(path.dirname(this.filename), filename)
- }
-
- this.submodules[filename] = loadedModules[filename] || new CustomModule(filename, this.context, this, this.mainModule || this)
-
- return this.submodules[filename].module.exports
-
- }
-
-}
-
-
-export default CustomModule
diff --git a/src/server/node/docs-server.mjs b/src/server/node/docs-server.mjs
deleted file mode 100644
index 4de0c842..00000000
--- a/src/server/node/docs-server.mjs
+++ /dev/null
@@ -1,90 +0,0 @@
-import {EventEmitter} from 'events'
-import http from 'http'
-import send from 'send'
-import path from 'path'
-import fs from 'fs'
-import open from 'open'
-import address from './address.mjs'
-
-class DocsServer extends EventEmitter {
-
- constructor() {
-
- super(...arguments)
-
- this.baseUrl = path.resolve(__dirname + '/../docs')
- this.home = '/docs/getting-started/introduction/'
- this.server = null
- this.started = false
- this.port = 0
-
- this.available = true
- if (!fs.existsSync(path.join(this.baseUrl, 'index.html'))) {
- console.error('(ERROR, DOCS) Documentation assets not found in the app\'s directory.')
- this.available = false
- }
-
-
-
- }
-
- start() {
-
- if (this.started || !this.available) return
-
- this.server = http.createServer(this.route.bind(this))
- this.server.on('error', (e)=>{
- console.error(`(ERROR, DOCS) ${e.message}`)
- })
- this.server.listen(0).on('listening', ()=>{
- this.port = this.server.address().port
- console.log('(INFO) Documentation server started, docs available at \n ' + address('http://', this.port).join('\n '))
- this.emit('ready')
-
- })
- this.started = true
-
- }
-
- open() {
-
- if (!this.started || !this.port) {
- this.start()
- this.on('ready', ()=>{
- open(address('http://', this.port)[0] + this.home)
- console.log('(INFO) Opening documentation with default browser...')
- })
- } else {
- open(address('http://', this.port)[0] + this.home)
- console.log('(INFO) Opening documentation with default browser...')
- }
-
- }
-
- route(req, res) {
-
- var url = req.url.replace(this.baseUrl, '').split('?')[0]
-
- if (url[url.length-1] === '/') url += 'index.html'
-
- if (url.indexOf('/fonts') === 0) url = '../assets' + url
-
- url = path.join(this.baseUrl, url)
-
-
- if (!fs.existsSync(url)) {
- if (url.indexOf('index.html') !== -1) {
- return send(req, path.join(this.baseUrl, '/404.html')).pipe(res)
- } else {
- res.writeHead(403)
- res.end()
- }
- } else {
- return send(req, url).pipe(res)
- }
-
- }
-
-}
-
-export default DocsServer
diff --git a/src/server/node/fragment-manager.mjs b/src/server/node/fragment-manager.mjs
deleted file mode 100644
index d1c5e03d..00000000
--- a/src/server/node/fragment-manager.mjs
+++ /dev/null
@@ -1,81 +0,0 @@
-import chokidar from 'chokidar'
-
-class FragmentManager {
-
- constructor(callbacks, ipcServer, webServer) {
-
- this.ipcServer = ipcServer
- this.webServer = webServer
- this.callbacks = callbacks
-
- this.fragments = {} // fragment files contents
- this.watchers = {} // fragment files watchers
- this.clients = {} // client ids for each watched fragment file
-
- }
-
- read(path, raw, clientId, then) {
-
- this.callbacks.fileRead({path: path, raw: raw}, clientId, true, (result)=>{
- this.fragments[path] = result
- then(result)
- }, (error)=>{
- this.ipcServer.send('errorLog', `Could not open fragment file:\n ${error}`, clientId)
- this.ipcServer.send('fragmentLoad', {path: path, notFound: true})
- this.deleteFragment(path)
- })
-
- }
-
- loadFragment(data, clientId) {
-
- var path = data.path
- var resolvedPath = this.webServer.resolvePath(path, clientId)
-
- if (!resolvedPath) {
- this.ipcServer.send('fragmentLoad', {path: path, notFound: true})
- return
- }
-
- if (!this.clients[resolvedPath]) this.clients[resolvedPath] = []
- if (!this.clients[resolvedPath].includes(clientId)) this.clients[resolvedPath].push(clientId)
-
- if (!this.fragments[resolvedPath]) {
-
- this.fragments[resolvedPath] = 'LOADING'
-
- this.read(resolvedPath, data.raw, clientId, (result)=>{
- this.ipcServer.send('fragmentLoad', {path: path, fileContent: this.fragments[resolvedPath], raw: data.raw}, clientId)
- })
-
- this.watchers[resolvedPath] = chokidar.watch(resolvedPath, {awaitWriteFinish: {stabilityThreshold: 200}}).on('change', ()=>{
- this.read(resolvedPath, data.raw, clientId, (result)=>{
- for (let id of this.clients[resolvedPath]) {
- this.ipcServer.send('fragmentLoad', {path: path, fileContent: this.fragments[resolvedPath], raw: data.raw}, id)
- }
- })
- }).on('unlink', ()=>{
- this.deleteFragment(resolvedPath)
- })
-
- } else if (this.fragments[resolvedPath] !== 'LOADING') {
-
- this.ipcServer.send('fragmentLoad', {path: path, fileContent: this.fragments[resolvedPath], raw: data.raw}, clientId)
-
- }
-
- }
-
- deleteFragment(path) {
-
- this.watchers[path].close()
- delete this.clients[path]
- delete this.fragments[path]
- delete this.fragments[path]
-
- }
-
-}
-
-
-export default FragmentManager
diff --git a/src/server/node/index.mjs b/src/server/node/index.mjs
deleted file mode 100644
index 01c83bd5..00000000
--- a/src/server/node/index.mjs
+++ /dev/null
@@ -1,46 +0,0 @@
-import sourceMap from 'source-map-support'
-import * as settings from './settings.mjs'
-import qrcode from './qrcode.mjs'
-import zeroconf from './zeroconf.mjs'
-import DocsServer from './docs-server.mjs'
-import OscServer from './osc/index.mjs'
-import WebServer from './server.mjs'
-import IpcServer from './ipc/server.mjs'
-
-
-sourceMap.install({handleUncaughtExceptions: false})
-
-process.on('uncaughtException', (err)=>{
- console.error('(ERROR) A JavaScript error occurred in the main process:')
- console.error(err.stack)
-})
-
-
-if (settings.read('docs')) {
-
- var docsServer = new DocsServer()
- docsServer.open()
-
-} else {
-
- var webServer = new WebServer(),
- oscServer = new OscServer(),
- ipcServer = new IpcServer(webServer, oscServer)
-
- webServer.start(ipcServer)
- oscServer.start(ipcServer)
-
- process.on('SIGINT', function() {
- webServer.stop()
- oscServer.stop()
- zeroconf.unpublishAll()
- process.exit(0)
- })
-
- if (!process.env.OSC_SERVER_PROCESS) webServer.on('serverStarted', ()=>{
- if (!settings.read('no-qrcode')) {
- qrcode('terminal', (qr)=>console.log(qr))
- }
- })
-
-}
diff --git a/src/server/node/ipc/callbacks.mjs b/src/server/node/ipc/callbacks.mjs
deleted file mode 100644
index 0d887fbc..00000000
--- a/src/server/node/ipc/callbacks.mjs
+++ /dev/null
@@ -1,579 +0,0 @@
-import path from 'path'
-import fs from 'fs'
-import child_process from 'child_process'
-import * as settings from '../settings.mjs'
-import {deepCopy, resolveHomeDir} from '../utils.mjs'
-import FragmentManager from '../fragment-manager.mjs'
-
-export default class Callbacks {
-
- constructor(ipcServer, webServer, oscServer) {
-
- this.oscServer = oscServer
- this.ipcServer = ipcServer
- this.webServer = webServer
-
- this.fragmentManager = new FragmentManager(this, ipcServer, webServer)
-
- this.clipboardContent = {clipboard: null, idClipboard: null}
- this.widgetHashTable = {}
- }
-
- getEvents() {
-
- return Object.getOwnPropertyNames(this.__proto__)
- .filter(x=>!['constructor', 'getEvents'].includes(x))
- .filter(x=>typeof this[x] == 'function')
-
- }
-
- open(data, clientId) {
- // client connected
-
- this.ipcServer.send('connected', null, clientId)
-
- var recentSessions = settings.read('recentSessions')
-
- this.ipcServer.send('sessionList', recentSessions, clientId)
- this.ipcServer.send('clipboard', this.clipboardContent, clientId)
- this.ipcServer.send('serverTargets', settings.read('send'), clientId)
-
- if (settings.read('load') && !data.hotReload) return this.sessionOpen({path: settings.read('load')}, clientId)
-
- }
-
- close(data, clientId) {
- // client disconnected
-
- }
-
- created(data, clientId) {
- // client created or reconnected
-
- if (!this.widgetHashTable[clientId]) {
- this.widgetHashTable[clientId] = {CONSOLE: {typeTags: ''}}
- }
-
- }
-
- destroyed(data, clientId) {
- // client removed (timeout)
-
- // clear osc data cache
- if (this.widgetHashTable[clientId]) delete this.widgetHashTable[clientId]
-
- }
-
- clipboard(data, clientId) {
- // shared clipboard
-
- this.clipboardContent = data
- this.ipcServer.send('clipboard', data, null, clientId)
-
- }
-
- sessionAddToHistory(data) {
-
- var recentSessions = settings.read('recentSessions')
-
- fs.lstat(data, (err, stats)=>{
-
- if (err || !stats.isFile()) return
-
- // add session to history
- recentSessions.unshift(path.resolve(data))
- // remove doubles from history
- recentSessions = recentSessions.filter(function(elem, index, self) {
- return index == self.indexOf(elem)
- })
-
- // history size limit
- if (recentSessions.length > 10) recentSessions = recentSessions.slice(0, 10)
-
- // save history
- settings.write('recentSessions', recentSessions)
-
- this.ipcServer.send('sessionList', recentSessions)
-
- })
- }
-
- sessionRemoveFromHistory(data) {
-
- var recentSessions = settings.read('recentSessions')
- if (recentSessions.indexOf(data) > -1) {
- recentSessions.splice(recentSessions.indexOf(data),1)
- settings.write('recentSessions',recentSessions)
- this.ipcServer.send('sessionList', recentSessions)
- }
-
- }
-
- sessionSetPath(data, clientId) {
- // store client's current session file path
-
- if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
-
- if (!settings.read('read-only')) {
- this.sessionAddToHistory(data.path)
- }
-
- this.ipcServer.clients[clientId].sessionPath = data.path
-
- this.ipcServer.send('setTitle', path.basename(data.path), clientId)
-
- }
-
- sessionOpen(data, clientId) {
- // attempt to read session file
-
- if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
-
- this.fileRead(data, clientId, true, (result)=>{
-
- this.ipcServer.clients[clientId].sessionPath = data.path // for resolving local file requests
- this.ipcServer.send('sessionOpen', {path: data.path, fileContent: result}, clientId)
-
- }, (error)=>{
-
- this.ipcServer.send('error', `Could not open session file:\n ${error}`, clientId)
-
- })
-
- }
-
- fragmentLoad(data, clientId) {
- // attempt to read session file
-
- if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
-
- this.fragmentManager.loadFragment(data, clientId)
-
- }
-
- sessionOpened(data, clientId) {
- // session file opened successfully
-
- if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
-
- if (settings.read('state')) {
- var send = true
- for (var id in this.ipcServer.clients) {
- // only make the client send its osc state if there are no other active clients
- if (id !== clientId && this.ipcServer.clients[id].connected()) {
- send = false
- }
- }
-
- var stateContent = fs.readFileSync(settings.read('state'), 'utf8')
- if (stateContent[0] === '\ufeff') stateContent = stateContent.slice(1) // remove BOM
- var state = {
- state: JSON.parse(stateContent),
- send: send
- }
- this.ipcServer.send('stateLoad', state, clientId)
- }
-
- if (data.sync) this.ipcServer.send('stateSend', null, null, clientId)
-
- this.sessionSetPath({path: data.path}, clientId)
-
- }
-
- fileRead(data, clientId, ok, callback, errorCallback) {
- // private function
-
- if (!ok) return
-
- if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
-
- data.path = resolveHomeDir(data.path)
-
- if (!path.isAbsolute(data.path) && settings.read('remote-root')) data.path = path.resolve(resolveHomeDir(settings.read('remote-root')), data.path)
-
- fs.readFile(data.path, 'utf8', (err, result)=>{
-
- var error
-
- if (err) {
- error = err
- } else {
- try {
- if (result[0] === '\ufeff') result = result.slice(1) // remove BOM
- result = data.raw ? result : JSON.parse(result)
- callback(result)
- } catch(err) {
- error = err
- }
- }
-
- if (error && errorCallback) errorCallback(error)
-
- })
-
- }
-
- fileSave(data, clientId, ok, callback) {
- // private function
-
- if (!ok) return
-
- if (!data.path || settings.read('remote-saving') && !RegExp(settings.read('remote-saving')).test(this.ipcServer.clients[clientId].address)) {
-
- return this.ipcServer.send('notify', {
- icon: 'save',
- locale: 'remotesave_forbidden',
- class: 'error'
- }, clientId)
-
- }
-
- if (data.path) {
-
- if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
-
- data.path = resolveHomeDir(data.path)
-
- if (!path.isAbsolute(data.path) && settings.read('remote-root')) data.path = path.resolve(settings.read('remote-root'), data.path)
-
- var root = resolveHomeDir(settings.read('remote-root'))
- if (root && !path.normalize(data.path).includes(path.normalize(root))) {
- console.error('(ERROR) Could not save: path outside of remote-root')
- return this.ipcServer.send('notify', {
- class: 'error',
- locale: 'remotesave_fail',
- message: ' (Could not save: path outside of remote-root)'
- }, clientId)
- }
-
- try {
- JSON.parse(data.session)
- } catch(e) {
- return console.error('(ERROR) Could not save: invalid file')
- }
-
- fs.writeFile(data.path, data.session, (err, fdata)=>{
-
- if (err) return this.ipcServer.send('notify', {
- class: 'error',
- locale: 'remotesave_fail',
- message: ' (' + err.message + ')'
- }, clientId)
-
-
- this.ipcServer.send('notify', {
- icon: 'save',
- locale: 'remotesave_success',
- class: 'session-save',
- message: ' ('+ path.basename(data.path) +')'
- }, clientId)
-
- callback()
-
- })
-
- }
-
- }
-
- stateOpen(data, clientId) {
- // attempt to open state file
-
- if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
-
- this.fileRead(data, clientId, true, (result)=>{
-
- this.ipcServer.send('stateLoad', {state: result, path: data.path, send: true}, clientId)
-
- }, (error)=>{
-
- this.ipcServer.send('error', `Could not open state file:\n ${error}`, clientId)
-
- })
-
- }
-
- sessionSave(data, clientId) {
- // save session file (.json)
-
- if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
-
- if (!path.basename(data.path).match(/.*\.json$/)) return console.error('(ERROR) Sessions must be saved as .json files')
-
- if (data.backup) {
- var newpath, i = 0
- for (;;) {
- newpath = data.path.replace(/\.json$/, '-backup' + String(i).padStart(3, 0) + '.json')
- if (fs.existsSync(newpath)) i++
- else {
- data.path = newpath
- break
- }
- }
- }
-
-
- this.fileSave(data, clientId, true, ()=>{
-
- console.log('(INFO) Session file saved in '+ data.path)
-
- if (!data.backup) this.ipcServer.send('sessionSaved', clientId)
-
- // reload session in other clients
- for (var id in this.ipcServer.clients) {
- if (id !== clientId && this.ipcServer.clients[id].sessionPath === data.path) {
- this.sessionOpen({path: data.path}, id)
- }
- }
-
- if (!data.backup) this.sessionSetPath({path: data.path}, clientId)
-
- })
-
- }
-
- stateSave(data, clientId) {
- // save state file (.json)
-
- if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
-
- if (!path.basename(data.path).match(/.*\.state/)) return console.error('(ERROR) Statesaves must be saved as .state files')
-
- this.fileSave(data, clientId, true, ()=>{
-
- console.log('(INFO) State file saved in '+ data.path)
-
- })
-
- }
-
- syncOsc(shortdata, clientId) {
- // sync osc (or midi) message with other clients
-
- // if widget hash is provided, look for cached data
- if (!(this.widgetHashTable[clientId] && this.widgetHashTable[clientId][shortdata.h])) return
-
- var value = shortdata.v,
- data = shortdata.h ? this.widgetHashTable[clientId][shortdata.h] : {}
-
- data = deepCopy(data)
- for (var k in shortdata) {
- data[k] = shortdata[k]
- }
-
- // only rawTarget will be used
- delete data.target
-
- data.args = data.preArgs ? data.preArgs.concat(value) : [value]
-
- if (!data.noSync) this.ipcServer.send('receiveOsc', data, null, clientId)
-
-
- }
-
- sendOsc(shortdata, clientId) {
- // send osc (or midi) message and sync with other clients
- // shortdata
- // {
- // h: 'widget_uuid',
- // v: widget_value,
- // ... // target, preArgs, address, typeTags
- // // override cached data
- // // required if data.h is not provided
- // }
-
-
- // if widget hash is provided, look for cached data
- if (shortdata.h && !(this.widgetHashTable[clientId] && this.widgetHashTable[clientId][shortdata.h])) return
-
- var value = shortdata.v,
- data = shortdata.h ? this.widgetHashTable[clientId][shortdata.h] : {}
-
- data = deepCopy(data)
- for (var k in shortdata) {
- data[k] = shortdata[k]
- }
-
- if (data.target) {
-
- var targets = []
-
- if (!shortdata.i && settings.read('send') && !shortdata.target) Array.prototype.push.apply(targets, settings.read('send'))
- if (data.target) Array.prototype.push.apply(targets, data.target)
-
- data.args = data.preArgs ? data.preArgs.concat(value) : [value]
-
- for (var i in targets) {
-
- if (targets[i] === 'self') {
- this.ipcServer.send('receiveOsc',data,clientId)
- continue
- } else if (targets[i] === null) {
- continue
- }
-
- var host = targets[i].split(':')[0],
- port = targets[i].split(':')[1]
-
- if (port) {
-
- this.oscServer.send(host, port, data.address, data.args, data.typeTags, clientId)
-
- }
-
- }
-
- }
-
- if (!data.noSync) this.ipcServer.send('receiveOsc', data, null, clientId)
-
- }
-
- addWidget(data, clientId) {
- // cache widget osc data to reduce bandwidth usage
- // data
- // {
- // hash: 'widget_uuid',
- // data: {
- // target: ['host:port', ...],
- // preArgs: [arg1, ...],
- // address: '/address',
- // typeTags: 'iif' // one letter per arg typetag
- // }
- // }
- // preArgs, target and typeTags can be empty strings
-
- if (!this.widgetHashTable[clientId][data.hash]) {
- this.widgetHashTable[clientId][data.hash] = {}
- }
-
- var cache = this.widgetHashTable[clientId][data.hash],
- widgetData = data.data
-
- for (var k in widgetData) {
- if ((k === 'target' || k === 'preArgs')) {
- if (widgetData[k] !== '') {
- cache[k] = Array.isArray(widgetData[k]) ? widgetData[k] : [widgetData[k]]
- } else {
- cache[k] = []
- }
- } else {
- cache[k] = widgetData[k]
- }
- }
-
- // store raw target for client sync widget matching
- cache._rawTarget = widgetData.target
-
- }
-
- removeWidget(data, clientId) {
- // clear widget osc data
-
- delete this.widgetHashTable[clientId][data.hash]
-
- }
-
- reload(data) {
- // (dev) hot reload
- this.ipcServer.send('reload')
-
- }
-
- reloadCss() {
- // (dev) hot css reload
- this.ipcServer.send('reloadCss')
- }
-
- log(data) {
- console.log(data)
- }
-
- error(data) {
- console.error(data)
- }
-
- errorLog(data) {
- console.error(data)
- }
-
- errorPopup(data) {
- this.ipcServer.send('error', data)
- }
-
- listDir(data, clientId) {
- // remote file browser backend
-
- if (data.path) {
- // path is requested
- data.path[0] = resolveHomeDir(data.path[0])
- } else if (settings.read('last-dir') && fs.existsSync(settings.read('last-dir'))) {
- // attempt to use last visited directory
- data.path = [settings.read('last-dir')]
- } else {
- // default directory fallback
- data.path = [resolveHomeDir('~/')]
- }
-
- var p = path.resolve(...data.path),
- root = resolveHomeDir(settings.read('remote-root'))
-
- if (root && !path.normalize(p).includes(path.normalize(root))) p = root
-
-
- if (process.platform === 'win32' && !root) {
- // Drive list hack on windows
- if (data.path.length === 2 && data.path[1] === '..' && (data.path[0].match(/^[A-Z]:\\$/) || data.path[0] === '\\')) {
-
- child_process.exec('(get-wmiobject win32_volume | ? { $_.DriveType -eq 3 } | % { get-psdrive $_.DriveLetter[0] }).Root -join " "', {shell: 'powershell.exe'}, (error, stdout) => {
-
- if (error) {
-
- this.ipcServer.send('notify', {class: 'error', message: 'Failed to list available drives (see server console).'}, clientId)
- console.error('(ERROR) Failed to list available drives.')
- console.error(error.stack)
-
- } else {
-
- this.ipcServer.send('listDir', {
- path: '\\',
- files: stdout.split(' ')
- .filter(value => /[A-Za-z]:/.test(value))
- .map(value => {return {name: value.trim(), folder: true}})
- }, clientId)
-
- }
- })
- return
- }
- }
-
- fs.readdir(p, (err, files)=>{
- if (err) {
- this.ipcServer.send('notify', {class: 'error', message: err.message}, clientId)
- throw err
- } else {
- var extRe = data.extension ? new RegExp('.*\\.' + data.extension + '$') : /.*/
- var list = files.filter(x=>x[0] !== '.').map((x)=>{
- var folder = false
- try {
- folder = fs.statSync(path.resolve(p, x)).isDirectory()
- } catch(e) {}
- return {
- name: x,
- folder
- }
- })
- list = list.filter(x=>x.folder || x.name.match(extRe))
- this.ipcServer.send('listDir', {
- path: p,
- files: list,
- root: root
- }, clientId)
- settings.write('last-dir', p, false, false)
- }
- })
-
- }
-
-}
diff --git a/src/server/node/ipc/client.mjs b/src/server/node/ipc/client.mjs
deleted file mode 100644
index 5e17545e..00000000
--- a/src/server/node/ipc/client.mjs
+++ /dev/null
@@ -1,126 +0,0 @@
-import {EventEmitter} from 'events'
-
-var hearbeatInterval = 25000,
- hearbeatTimeout = 5000,
- dieTimeout = 60000
-
-class Client extends EventEmitter {
-
- constructor(ws, id, address) {
-
- super()
-
- this.id = id
-
- this.address = address.replace('::ffff:', '')
-
- this.socket = null
-
- this.sessionPath = ''
-
- this.queue = []
-
- this.hearbeat = undefined
- this.hearbeatTimeout = undefined
- this.on('pong', ()=>{
- this.hearbeatTimeout = clearTimeout(this.hearbeatTimeout)
- })
- this.on('ping', ()=>{
- this.socket.send('["pong"]')
- })
-
- this.dieTimeout = undefined
-
- this.open(ws)
-
- }
-
- open(ws) {
-
- this.socket = ws
-
- this.socket.onmessage = (e)=>{
- this.receive(e.data)
- }
-
- this.socket.onclose = this.socket.onerror = ()=>{
- if (!this.connected()) this.close()
- }
-
- this.dieTimeout = clearTimeout(this.dieTimeout)
-
- this.hearbeat = setInterval(()=>{
- if (!this.connected()) return
- this.socket.send('["ping"]')
- this.hearbeatTimeout = setTimeout(()=>{
- if (this.connected()) this.socket.close()
- }, hearbeatTimeout)
- }, hearbeatInterval)
-
- this.emit('created')
-
- }
-
- close() {
-
- this.hearbeat = clearInterval(this.hearbeat)
- this.hearbeatTimeout = clearTimeout(this.hearbeatTimeout)
- this.dieTimeout = clearTimeout(this.dieTimeout)
-
- this.dieTimeout = setTimeout(()=>{
-
- this.emit('destroyed')
-
- }, dieTimeout)
-
- }
-
- connected() {
-
- return this.socket.readyState == this.socket.OPEN
-
- }
-
- receive(message) {
-
- if (typeof message == 'string') {
-
- var packet = JSON.parse(message)
-
- if (Array.isArray(packet) && typeof packet[0] == 'string') {
-
- this.emit(packet[0], packet[1])
-
- }
-
- }
-
- }
-
- send(packet) {
-
- // see IpcServer.send
-
- if (this.connected()) {
- this.socket.send(packet)
- } else {
- this.queue.push(packet)
- }
-
- }
-
- flush(){
-
- for (var i in this.queue) {
-
- if (this.connected()) this.socket.send(this.queue[i])
-
- }
-
- this.queue = []
-
- }
-
-}
-
-export default Client
diff --git a/src/server/node/ipc/server.mjs b/src/server/node/ipc/server.mjs
deleted file mode 100644
index b3d707fb..00000000
--- a/src/server/node/ipc/server.mjs
+++ /dev/null
@@ -1,92 +0,0 @@
-import {WebSocketServer} from 'ws'
-import Client from './client.mjs'
-import * as settings from '../settings.mjs'
-import Callbacks from './callbacks.mjs'
-
-class IpcServer {
-
- constructor(webServer, oscServer) {
-
- this.clients = {}
- this.webServer = webServer
- this.oscServer = oscServer
- this.server = new WebSocketServer({server: webServer.server})
- this.callbacks = new Callbacks(this, webServer, oscServer)
-
-
- this.server.on('connection', (socket, req)=>{
- var url = req.url.split('/'),
- auth = url.pop().replace('_', '/'),
- id = url.pop()
-
- if (settings.read('authentication')) {
- if (settings.read('authentication') !== Buffer.from(auth, 'base64').toString()) {
- console.log(`(WARNING) Client connexion refused for ${req.connection.remoteAddress} (authentication failed)`)
- socket.close()
- return
- }
- }
-
-
- if (!id) return
-
- id = decodeURI(id)
-
- if (!this.clients[id]) {
-
- var client = new Client(socket, id, req.connection.remoteAddress)
- this.clients[id] = client
-
- var customModule = settings.read('custom-module')
- for (let name of this.callbacks.getEvents()) {
- client.on(name, (data)=>{
- if (customModule) {
- oscServer.customModuleEventEmitter.emit(name, data, {address: client.address, id: client.id})
- }
- this.callbacks[name](data, client.id)
- })
- }
-
- client.on('destroyed', ()=>{
- delete this.clients[id]
- })
-
- } else {
-
- this.clients[id].open(socket)
- this.clients[id].flush()
-
- }
-
- this.clients[id].emit('created')
-
- })
-
- }
-
- send(event, data, id, except) {
-
- var packet = JSON.stringify([event, data])
-
- if (id) {
- // send to a single client
- if (this.clients[id]){
- this.clients[id].send(packet)
- }
-
- } else {
- // send to all clients except one if specified
- for (let id in this.clients) {
- if (id != except) {
- this.clients[id].send(packet)
- }
- }
-
- }
-
- }
-
-
-}
-
-export default IpcServer
diff --git a/src/server/node/midi.mjs b/src/server/node/midi.mjs
deleted file mode 100644
index 9cb7ee17..00000000
--- a/src/server/node/midi.mjs
+++ /dev/null
@@ -1,203 +0,0 @@
-import {PythonShell} from 'python-shell'
-import fs from 'fs'
-import path from 'path'
-import {EventEmitter} from 'events'
-import * as settings from './settings.mjs'
-
-
-var scriptPath = __dirname.includes('server/node') ?
- path.resolve(__dirname, '../python') : // src folder structure
- path.resolve(__dirname, './python') // app folder structure with rollup chunking
-
-var midiBinaries = {
- x64: {
- linux: 'osc-midi-linux',
- darwin: 'osc-midi-osx',
- win32: 'osc-midi-windows.exe'
- },
- arm64:{
- darwin: 'osc-midi-osx',
- }
-}
-
-var expectMidiBinaries = fs.existsSync(path.resolve(scriptPath, './.expect-midi-bin')),
- expectMidiBinariesError = false
-
-var pythonPathOverride
-if (midiBinaries[process.arch] && midiBinaries[process.arch][process.platform]) {
- var p = path.resolve(scriptPath, midiBinaries[process.arch][process.platform])
- if (fs.existsSync(p)) {
- pythonPathOverride = p
- } else if (expectMidiBinaries) {
- expectMidiBinariesError = true
- }
-}
-
-class MidiConverter extends EventEmitter{
-
- constructor() {
-
- super()
-
- if (expectMidiBinariesError) MidiConverter.midiBinariesError()
-
- this.running = false
- this.restarting = false
- this.py = {}
-
- this.start()
-
-
- process.on('message', (m) => {
- if (m == 'midiRestart') {
- this.restart()
- }
- })
-
- }
-
- start() {
-
- if (this.running) return
-
- this.py = new PythonShell('midi.py', Object.assign({
- args: [
- '--params',
- settings.read('debug') ? 'debug' : '',
- ...settings.read('midi')
- ],
- pythonPath: MidiConverter.getPythonPath()
- }, {scriptPath, mode:'text'}))
-
- this.py.childProcess.on('error', (e)=>{
- if (e.code === 'ENOENT') {
- console.error(`(ERROR, MIDI) Could not find python binary: ${e.message.replace(/spawn (.*) ENOENT/, '$1')}`)
- } else {
- console.error(`(ERROR, MIDI) ${e.message}`)
- }
- })
-
- this.py.childProcess.on('exit', (code)=>{
- if (code === null && !this.restarting) console.error('(ERROR, MIDI) Midi bridge process crashed')
- this.running = false
- this.emit('stopped')
- })
-
- this.running = true
-
- }
-
- stop() {
-
- if (this.running) this.py.childProcess.kill()
-
- }
-
- restart() {
-
- if (this.running) {
- this.restarting = true
- this.once('stopped', ()=>{
- this.start()
- this.restarting = false
- })
- this.stop()
- }
- }
-
- send(data) {
-
- if (!this.running) return
-
- var args = []
- for (let i in data.args) {
- args.push(data.args[i].value)
- }
-
- this.py.send(JSON.stringify([data.port, data.address, ...args]))
-
- }
-
-
-
- init(receiveOsc) {
-
- this.receiveOsc = receiveOsc
- this.py.on('message', (message)=>{
- MidiConverter.parseIpc(message, this)
- })
-
- }
-
- static parseIpc(message, instance) {
-
- // console.log(message)
- var name, data
- try {
- [name, data] = JSON.parse(message)
- } catch (err) {
- if (settings.read('debug')) console.error(`(ERROR, MIDI) Unparsed python log:\n ${message}`)
- }
- if (name == 'log') {
- if (data.indexOf('ERROR') > -1) {
- console.error(data)
- } else {
- console.log(data)
- }
- } else if (name == 'debug') {
- if (data.indexOf('in:') === 0) {
- console.log('\x1b[36m(DEBUG, MIDI)', data, '\x1b[0m')
- } else if (data.indexOf('out:') === 0) {
- console.log('\x1b[35m(DEBUG, MIDI)', data, '\x1b[0m')
- } else {
- console.log('(DEBUG, MIDI) ' + data)
- }
- } else if (name == 'osc') {
- instance.receiveOsc(data)
- } else if (name == 'error') {
- console.error('(ERROR, MIDI) ' + data)
- }
-
- }
-
- static list() {
-
- if (expectMidiBinariesError) MidiConverter.midiBinariesError()
-
- PythonShell.run('midi.py', Object.assign({pythonPath: MidiConverter.getPythonPath(), args: ['--params', 'list-only']}, {scriptPath, mode:'text'}), function(e, results) {
- if (e) {
- if (e.code === 'ENOENT') {
- console.error(`(ERROR, MIDI) Could not find python binary: ${e.message.replace(/spawn (.*) ENOENT/, '$1')}`)
- } else {
- console.error(`(ERROR, MIDI) ${e.message}`)
- }
- }
-
- for (let r of results) {
- MidiConverter.parseIpc(r)
- }
- })
-
- }
-
- 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
-
- }
-
- static midiBinariesError() {
-
- console.error(`(ERROR, MIDI) Could not find midi binary file ${p}\nIt may have been deleted by your antivirus.`)
- console.log('(INFO, MIDI) Falling back to python implementation (see https://openstagecontrol.ammd.net/docs/midi/midi-configuration/).')
- expectMidiBinariesError = false
-
- }
-
-}
-
-export default MidiConverter
diff --git a/src/server/node/options.mjs b/src/server/node/options.mjs
deleted file mode 100644
index 37358895..00000000
--- a/src/server/node/options.mjs
+++ /dev/null
@@ -1,110 +0,0 @@
-import fs from 'fs'
-
-export default {
- 's': {alias: 'send', type: 'array', describe: 'default targets for all widgets (ip: port / domain: port / midi: port_name pairs)',
- check: (s)=>{
- return s.some(item=>!item.match(/^[^:]*:[0-9]{4,5}$/) && !item.match(/^midi:.*$/)) ?
- 'Targets must be ip:port or hostname:port pairs (port must be >= 1024) or midi:port_name pairs' : true
- }
- },
- 'l': {alias: 'load', type: 'string', file: {name: 'OSC Session (.json)', extensions: ['json']}, describe: 'session file to load (.json)',
- check: (arg)=>{
- return fs.existsSync(arg) ? true : 'Session file not found: ' + arg
- }
- },
- 'state': {type: 'string', file: {name: 'OSC State (.state)', extensions: ['state']}, describe: 'state file to load (.state)',
- check: (arg)=>{
- return fs.existsSync(arg) ? true : 'State file not found: ' + arg
- }
- },
- 'c': {alias: 'custom-module', type: 'string', file: {name: 'OSC Custom module (.js)', extensions: ['js']}, describe: 'custom module file to load (.js)\n WARNING: custom module can access the file system, use at your own risk.',
- check: (arg)=>{
- return fs.existsSync(arg) ? true : 'Custom module file not found: ' + arg
- },
- },
- 'p': {alias: 'port', type: 'number', describe: 'http port of the server (default to 8080)',
- check: (p)=>{
- return (!isNaN(p) && p > 1023 && parseInt(p)===p) ?
- true : 'Port must be an integer >= 1024'
- }
- },
- 'o': {alias: 'osc-port', type: 'number', describe: 'osc input port (default to --port)',
- check: (o)=>{
- return (!isNaN(o) && o > 1023 && parseInt(o)===o) ?
- true : 'Port must be an integer >= 1024'
- }
- },
- 'tcp-port': {type: 'number', describe: 'tcp server input port',
- check: (t, argv)=>{
- var h = argv['port']
- if (t === h) return 'Tcp input port must different from --port'
- return (!isNaN(t) && t > 1023 && parseInt(t)===t) ?
- true : 'Port must be an integer >= 1024'
- }
- },
- 'tcp-targets': {type: 'array', describe: 'tcp servers to connect to (ip: port pairs), does not substitute for --send',
- check: (s, argv)=>{
- if (!argv['tcp-port']) return '--tcp-port must be set'
- return s.some(item=>!item.match(/^[^:]*:[0-9]{4,5}$/)) ?
- 'Targets must be ip:port or hostname:port pairs (port must be >= 1024)' : true
- }
- },
- 'm': {alias: 'midi', type: 'array', describe: 'midi router settings',
- check: (o)=>{
- var err = o.filter(item=>!item.match(/^(list|debug|jack|sysex|mtc|rpn|nrpn|active_sensing|note_off_velocity|no_auto_note_off|pc_offset|path=(.*)|[^:]+:(virtual|[^,]+,[^,]+))$/))
- return err.length ? `Invalid option${err.length > 1 ? 's' : ''}: ${err.join(', ')}` : true
- }
- },
- 'd': {alias: 'debug', type: 'boolean', describe: 'log received osc messages in the console'},
- 'n': {alias: 'no-gui', type: 'boolean', describe: 'disable default gui'},
- 'fullscreen': {type: 'boolean', describe: 'launch in fullscreen mode (only affects the default client gui)'},
- 't': {alias: 'theme', type: 'array', file: {name: 'css file (.css)', extensions: ['css']}, describe: 'theme name or path (multiple values allowed)'},
- 'client-options': {type: 'array', describe: 'client options (opt=value pairs)',
- check: (o)=>{
- return o.some(item=>!item.match(/^[^=]*=[^=]*$/)) ?
- 'Options must be key=value pairs' : true
- }
- },
- 'disable-vsync': {type: 'boolean', describe: 'disable gui\'s vertical synchronization', restart: true},
- 'force-gpu': {type: 'boolean', describe: 'ignore chrome\'s gpu blacklist', restart: true},
- 'read-only': {type: 'boolean', describe: 'disable session editing and session history changes'},
- 'remote-saving': {type: 'string', describe: 'disable remote session saving for hosts that don\'t match the regular expression',
- check: (r, argv)=>{
- var msg = true
- try {
- RegExp(r)
- } catch (e) {
- msg = e
- }
- return msg
- }
- },
- 'remote-root': {type: 'string', describe: 'set remote file browsing root folder', file: {folder: true}},
- 'authentication': {type: 'string', describe: 'restrict access to "user:password" (remote clients will be prompted for these credentials)',
- check: (a, argv)=>{
- return a.match(/[^:]*:[^:]+/) ? true : 'Auth must be a user:password pair.'
- }
- },
- 'instance-name': {type: 'string', describe: 'used to differentiate multiple instances in a zeroconf network'},
- 'use-ssl': {type: 'boolean', describe: 'set to true to use HTTPS protocol instead of HTTP (a self-signed certificate will be created)'},
-
- // cli only
- 'disable-gpu': {type: 'boolean', describe: 'disable hardware acceleration', launcher: false},
- 'inspect': {type: 'boolean', describe: 'enable node/electron inspector', launcher: false},
- 'cache-dir': {type: 'string', describe: 'override default cache directory', launcher: false},
- 'config-file': {type: 'string', describe: 'override default config file (defaults to cache-dir/config.json)', launcher: false},
- 'docs': {type: 'boolean', describe: 'serve documentation website locally and open it with the system\'s default browser', launcher: false},
- 'client-position': {type: 'string', describe: 'position of the client window ("x,y" pair of integers)', launcher: false,
- check: (s)=>{
- return !s.match(/^[0-9]+,[0-9]+$/) ?
- 'Position must a x,y pair of integers' : true
- }
- },
- 'client-size': {type: 'string', describe: 'size of the client window ("width,height" pair of integers)', launcher: false,
- check: (s)=>{
- return !s.match(/^[0-9]+,[0-9]+$/) ?
- 'Size must a x,y pair of integers' : true
- }
- },
- 'no-qrcode': {type: 'boolean', describe: 'disable qrcode when the server starts', launcher: false}
-}
diff --git a/src/server/node/osc/index.mjs b/src/server/node/osc/index.mjs
deleted file mode 100644
index 4b0444c0..00000000
--- a/src/server/node/osc/index.mjs
+++ /dev/null
@@ -1,281 +0,0 @@
-import {EventEmitter} from 'events'
-import * as settings from '../settings.mjs'
-import OscUDPServer from './udp.mjs'
-import OscTCPServer from './tcp.mjs'
-import CustomModule from '../custom-module.mjs'
-import MidiServer from '../midi.mjs'
-
-export default class OscServer {
-
- constructor(){
-
- this.oscUDPServer = new OscUDPServer()
- this.oscTCPServer = new OscTCPServer()
- this.tcpInPort = settings.read('tcp-port')
- this.midiServer = settings.read('midi') ? new MidiServer() : null
-
- this.debug = settings.read('debug')
-
- this.customModuleEventEmitter = new EventEmitter()
- this.customModule = settings.read('custom-module') ? new CustomModule(settings.read('custom-module'), {
- app: this.customModuleEventEmitter,
- restartMidiBackend: ()=>{if (this.midiServer) this.midiServer.restart()},
- tcpServer: this.oscTCPServer,
- sendOsc: this.sendOsc.bind(this),
- receiveOsc: this.receiveOsc.bind(this),
- send: (host, port, address, ...args)=>{
- if (host.indexOf(':') > -1) {
- args.unshift(address)
- address = port
- var split = host.split(':')
- host = split[0]
- port = parseInt(split[1])
- }
-
- this.sendOsc({host, port, address, args:args.map(x=>this.parseArg(x))})
- },
- receive: (host, port, address, ...args)=>{
- if (host[0] === '/') {
- // host and port can be skipped
- if (address !== undefined) args.unshift(address)
- if (port !== undefined) args.unshift(port)
- address = host
- host = port = undefined
- } else if (host.indexOf(':') > -1) {
- args.unshift(address)
- address = port
- var split = host.split(':')
- host = split[0]
- port = parseInt(split[1])
- }
- var lastArg = args[args.length - 1],
- options = {}
- if (typeof lastArg === 'object' && lastArg !== null && lastArg.clientId !== undefined) {
- options = args.pop()
- }
- this.receiveOsc({host, port, address, args:args.map(x=>this.parseArg(x, null, true)), cm: 1}, options.clientId)
- },
- }) : {}
-
- }
-
- parseArg(arg, type, allowObjects = false){
-
- if (arg === null) return null
-
- if (typeof arg === 'object' && arg.type && arg.type.length === 1) return arg
-
- if (type && type[0].match(/[bhtdscrmifTFNI]/)) {
-
- type = type[0]
-
- switch (type) {
- case 'i':
- return {type: type, value: parseInt(arg)}
- case 'd':
- case 'f':
- return {type: type, value: parseFloat(arg)}
- case 'T':
- case 'F':
- case 'N':
- return {type: type}
- default:
- return {type: type, value: arg}
-
-
- }
-
- }
-
- switch (typeof arg) {
- case 'number':
- return {type: 'f', value: arg}
- case 'boolean':
- return {type: arg ? 'T' : 'F', value: arg}
- case 'string':
- return {type: 's', value: arg}
- default:
- if (allowObjects) {
- // Allow js objects in args when receiving from a custom module
- // they will eventually be serialized (as json) with the rest of
- // the ws message but the client will de-serialize it automatically
- // note: type "o" is off-spec, but we don't use typetag in this case anyway
- return {type: 'o', value: arg}
- } else {
- return {type: 's', value: JSON.stringify(arg)}
- }
- }
- }
-
- sendOsc(data){
-
- if (!data) return
-
- if (data.host == 'midi') {
-
- if (this.midiServer) this.midiServer.send(data)
-
- } else {
-
- if (typeof data.address !== 'string' || data.address[0] !== '/') {
- console.error('(ERROR, OSC) Malformed address: ' + data.address)
- return
- }
-
- if (isNaN(parseInt(data.port))) {
- console.error('(ERROR, OSC) Invalid port: ' + data.port)
- return
- }
-
- if (this.tcpInPort && this.oscTCPServer.clients[data.host] && this.oscTCPServer.clients[data.host][data.port]) {
-
- this.oscTCPServer.clients[data.host][data.port].send({
- address: data.address,
- args: data.args
- })
-
- } else {
-
- this.oscUDPServer.send({
- address: data.address,
- args: data.args
- }, data.host, data.port)
-
- }
-
- if (this.debug) {
- console.log('\x1b[35m(DEBUG, OSC) Out: ', `{ address: '${data.address}', args: `, data.args, '} To: ' + data.host + ':' + data.port, '\x1b[0m')
- }
-
- }
-
-
- }
-
- receiveOsc(data, clientId){
-
- if (!data) return
-
- for (var i in data.args) {
- data.args[i] = data.args[i].value
- }
-
- if (data.args.length==1) data.args = data.args[0]
-
- this.ipcServer.send('receiveOsc', data, clientId)
-
- if (this.debug) console.log('\x1b[36m(DEBUG, OSC) In: ', {address:data.address, args: data.args}, 'From: ' + data.host + ':' + data.port, '\x1b[0m')
-
- }
-
-
- oscInFilter(data){
- if (this.customModule.oscInFilter) {
- try {
- return this.customModule.oscInFilter(data)
- } catch(e) {
- console.error('(ERROR, CUSTOM MODULE)', e)
- return data
- }
- } else {
- return data
- }
- }
- oscOutFilter(data){
- if (this.customModule.oscOutFilter) {
- try {
- return this.customModule.oscOutFilter(data)
- } catch(e) {
- console.error('(ERROR, CUSTOM MODULE)', e)
- return data
- }
- } else {
- return data
- }
- }
-
- oscInHandler(msg, timetag, info){
- var data = this.oscInFilter({address: msg.address, args: msg.args, host: info.address, port: info.port})
- if (!data) return
- this.receiveOsc(data)
- }
-
- oscInHandlerWrapper(msg, timetag, info) {
- var delay = timetag? Math.max(0,timetag.native - Date.now()) : 0
- if (delay) {
- setTimeout(()=>{
- this.oscInHandler(msg, timetag, info)
- }, delay)
- } else {
- this.oscInHandler(msg, timetag, info)
- }
- }
-
- start(ipcServer){
-
- this.ipcServer = ipcServer
-
- if (this.midiServer) this.midiServer.init((data)=>{
-
- data = this.oscInFilter({address: data.address, args: data.args, host: data.host, port: data.port})
-
- if (!data) return
-
- this.receiveOsc(data)
-
- })
-
- this.oscUDPServer.on('message', this.oscInHandlerWrapper.bind(this))
- this.oscUDPServer.start()
-
- if (settings.read('tcp-port')) {
- this.oscTCPServer.on('message', this.oscInHandlerWrapper.bind(this))
- this.oscTCPServer.start()
- }
-
- if (this.customModule.init) {
- try {
- this.customModule.init()
- } catch(e) {
- console.error('(ERROR, CUSTOM MODULE)', e)
- }
- }
-
- }
-
- stop() {
-
- if (this.customModule.stop) this.customModule.stop()
- if (this.midiServer) this.midiServer.stop()
-
- }
-
- send(host, port, address, args, typeTags, clientId) {
- // public send function
-
- var message = []
-
- if (!Array.isArray(args)) args = [args]
-
- if (typeof args === 'object' && args !== null) {
-
- var typeTag,
- arg
-
- for (var i = 0; i < args.length; i++) {
-
- if (typeTags && typeTags[i]) typeTag = typeTags[i]
- arg = this.parseArg(args[i], typeTag)
-
- if (arg !== null) message.push(arg)
-
- }
- }
-
- var data = this.oscOutFilter({address:address, args: message, host: host, port: port, clientId: clientId})
-
- this.sendOsc(data)
-
- }
-
-}
diff --git a/src/server/node/osc/osc.mjs b/src/server/node/osc/osc.mjs
deleted file mode 100644
index 4dc68d46..00000000
--- a/src/server/node/osc/osc.mjs
+++ /dev/null
@@ -1,7 +0,0 @@
-import osc from 'osc/src/osc.js'
-import transports from 'osc/src/platforms/osc-node.js'
-
-osc.UDPPort = transports.UDPPort
-osc.TCPSocketPort = transports.TCPSocketPort
-
-export default osc
diff --git a/src/server/node/osc/tcp.mjs b/src/server/node/osc/tcp.mjs
deleted file mode 100644
index b1096257..00000000
--- a/src/server/node/osc/tcp.mjs
+++ /dev/null
@@ -1,150 +0,0 @@
-import {EventEmitter} from 'events'
-import net from 'net'
-import * as settings from '../settings.mjs'
-import osc from './osc.mjs'
-import zeroconf from '../zeroconf'
-
-class OscTCPClient extends EventEmitter {
-
- constructor(options) {
-
- super()
-
- this.options = options
- this.remoteAddress = options.address
- this.remotePort = options.port
-
- this.open()
-
- }
-
- open() {
-
- this.port = new osc.TCPSocketPort(this.options)
-
- this.port.on('error', (err)=>{
- console.error('(ERROR, TCP)', err)
- })
-
- this.port.on('close', (hadErr)=>{
- console.log(`(TCP) Connection closed (${this.remoteAddress}:${this.remotePort})`)
- if (!this.options.socket) {
- console.log(`(TCP) Attempting reconnection in 5s (${this.remoteAddress}:${this.remotePort})`)
- this.reconnect()
- } else {
- this.emit('die')
- }
- })
-
- this.port.on('message', (msg, timetag)=>{
- this.emit('message', msg, timetag, {address: this.remoteAddress, port: this.remotePort})
- })
-
- this.port.on('ready', ()=>{
- console.log(`(TCP) Connection established (${this.remoteAddress}:${this.remotePort})`)
- })
-
- if (!this.options.socket) {
-
- this.port.open()
-
- } else {
-
- this.port.emit('ready')
-
- }
-
- }
-
- reconnect() {
-
- setTimeout(()=>{
- this.open()
- }, 5000)
-
- }
-
- send(msg) {
-
- this.port.send(msg)
-
- }
-
-
-
-}
-
-export default class OscTCPServer extends EventEmitter {
-
- constructor() {
-
- super()
-
- this.port = settings.read('tcp-port')
- this.targets = settings.read('tcp-targets')
-
- this.clients = {}
-
- this.server = net.createServer(this.bindSocket.bind(this))
- }
-
- bindSocket(socket) {
-
- this.addClient(new OscTCPClient({
- metadata: true,
- socket: socket,
- address: socket.remoteAddress.replace('::ffff:', ''),
- port: socket.remotePort
- }))
-
- }
-
- addClient(client) {
-
- this.clients[client.remoteAddress] = this.clients[client.remoteAddress] || {}
- this.clients[client.remoteAddress][client.remotePort] = client
-
- client.on('message', (msg, timetag, info)=>{
- this.emit('message', msg, timetag, info)
- })
-
- client.on('die', (hadError)=>{
- if (this.clients[client.remoteAddress]) delete this.clients[client.remoteAddress][client.remotePort]
- })
-
- }
-
-
- start() {
-
-
- this.server.listen({port: this.port})
-
- for (var i in this.targets) {
-
- this.addClient(new OscTCPClient({
- metadata: true,
- address: this.targets[i].split(':')[0],
- port: this.targets[i].split(':')[1]
- }))
-
- }
-
- zeroconf.publish({
- name: settings.infos.productName + (settings.read('instance-name') ? ' (' + settings.read('instance-name') + ')' : ''),
- protocol: 'tcp',
- type: 'osc',
- port: this.port
- }).on('error', (e)=>{
- console.error(`Error: Zeroconf: ${e.message}`)
- })
-
- }
-
- stop() {
-
- this.server.close()
-
- }
-
-}
diff --git a/src/server/node/osc/udp.mjs b/src/server/node/osc/udp.mjs
deleted file mode 100644
index cf056f4e..00000000
--- a/src/server/node/osc/udp.mjs
+++ /dev/null
@@ -1,48 +0,0 @@
-import osc from './osc.mjs'
-import * as settings from '../settings.mjs'
-import zeroconf from '../zeroconf.mjs'
-
-export default class OscUDPServer {
-
- constructor() {
-
- this.port = settings.read('osc-port') || settings.read('port') || 8080
-
- this.server = new osc.UDPPort({
- localAddress: '0.0.0.0',
- localPort: this.port,
- metadata: true,
- broadcast: true
- })
-
- this.server.on('error', function(e) {
- if (e.code === 'EADDRINUSE') {
- console.error(`(ERROR, UDP) could not open port ${this.port} (already in use) `)
- } else {
- console.error('(ERROR, UDP)', e)
- }
- })
-
- this.on = this.server.on.bind(this.server)
- this.send = this.server.send.bind(this.server)
- }
-
- start() {
-
- this.server.open()
-
- zeroconf.publish({
- name: settings.infos.productName + (settings.read('instance-name') ? ' (' + settings.read('instance-name') + ')' : ''),
- protocol: 'udp',
- type: 'osc',
- port: this.port
- })
-
- }
-
- stop() {
-
- this.server.close()
-
- }
-}
diff --git a/src/server/node/qrcode.mjs b/src/server/node/qrcode.mjs
deleted file mode 100644
index b9565315..00000000
--- a/src/server/node/qrcode.mjs
+++ /dev/null
@@ -1,39 +0,0 @@
-import QRCode from 'qrcode'
-import * as settings from './settings.mjs'
-
-export default function qrcode(mode, callback){
-
- var qrstring = '',
- promises = []
-
- if (mode == 'file') {
- promises.push(QRCode.toString(settings.appAddresses().pop(), {type:'svg', small: true, margin: 1}))
- } else {
- for (var add of settings.appAddresses().filter(a=>!a.includes('127.0.0.1') && !a.includes('localhost'))) {
- if (mode == 'svg') {
- promises.push(QRCode.toString(add,{type:'svg', small: true, margin: 1}))
- } else if (mode == 'terminal') {
- promises.push(QRCode.toString(add,{type:'terminal', small: true}))
- }
- }
- }
-
- Promise.all(promises).then(values=>{
- for (var qr of values) {
- if (mode === 'svg') {
- qrstring += '' + qr + '
'
- if (values.length > 1) {
- qrstring += '(' + add + ')'
- }
- } else {
- qrstring += '\n' + qr.replace(/^/gm, ' ' + '')
- if (values.length > 1) {
- qrstring += ' (' + add + ')'
- }
- }
- }
- callback(qrstring)
- })
-
-
-}
diff --git a/src/server/node/server.mjs b/src/server/node/server.mjs
deleted file mode 100644
index 3f7684fc..00000000
--- a/src/server/node/server.mjs
+++ /dev/null
@@ -1,311 +0,0 @@
-import http from 'http'
-import https from 'https'
-import {EventEmitter} from 'events'
-import path from 'path'
-import fs from 'fs'
-import send from 'send'
-import replaceStream from 'replacestream'
-import * as settings from './settings.mjs'
-import './ssl.mjs'
-import auth from './auth.mjs'
-import theme from './theme.mjs'
-import zeroconf from './zeroconf.mjs'
-import qrcode from './qrcode.mjs'
-import {resolveHomeDir} from './utils.mjs'
-
-class WebServer extends EventEmitter {
-
- constructor() {
-
- super()
-
- this.ipcServer = null
-
- this.qrcode = ''
- this.prod = !process.argv[0].includes('node_modules'),
- this.debug = settings.read('debug'),
- this.remoteRoot = settings.read('remote-root')
-
- var route = auth ? auth.check(this.httpRoute.bind(this)) : this.httpRoute.bind(this)
- if (settings.read('use-ssl')) {
- this.server = https.createServer(settings.read('ssl-certificate'), route)
- } else {
- this.server = http.createServer(route)
- }
-
- // file request resolution directories
- // add theme dirs
- this.resolveDirs = theme.files.map(x=>path.dirname(x)),
- // dedupe
- this.resolveDirs = this.resolveDirs.filter((x, index)=>{return this.resolveDirs.indexOf(x) === index})
- // add remote root or absolute
- this.resolveDirs.push(this.remoteRoot || '')
-
- if (!this.prod) {
- // add src root folder for debugging
- this.resolveDirs.push(path.resolve(__dirname + '/../../../'))
- }
-
- this.ignoredNotFound = [
- '/apple-touch-icon-precomposed.png',
- '/favicon.ico',
- '/apple-touch-icon.png'
- ]
-
-
- }
-
- start(ipcServer) {
-
- this.ipcServer = ipcServer
-
-
- theme.on('update', ()=>{
- ipcServer.send('reloadCss')
- })
-
- this.server.listen(settings.read('port') || 8080)
-
- var proto = settings.read('use-ssl') ? https : http
- proto.get(settings.appAddresses()[0] + '/osc-ping', {
- auth: settings.read('authentication'),
- rejectUnauthorized: false
- },()=>{}).on('error', ()=>{this.httpCheck(false)})
-
- this.httpCheckTimeout = setTimeout(()=>{this.httpCheck(false)}, 5000)
-
- zeroconf.publish({
- name: settings.infos.productName + (settings.read('instanceName') ? ' (' + settings.read('instanceName') + ')' : ''),
- type: 'http',
- port: settings.read('port') || 8080
- }).on('error', (e)=>{
- console.error(`(ERROR, ZEROCONF) ${e.message}`)
- })
-
- this.server.on('error', (e)=>{
- if (e.code === 'EADDRINUSE') {
- console.error(`(ERROR, HTTP) Could not open port ${this.port} (already in use) `)
- } else {
- console.error(`(ERROR, HTTP) ${e.message}`)
- }
- })
-
- }
-
- stop() {
-
- this.server.close()
-
- }
-
- resolvePath(url, clientId) {
-
- var sessionPath
-
- if (this.ipcServer.clients[clientId]) {
- sessionPath = path.dirname(this.ipcServer.clients[clientId].sessionPath)
- }
-
- url = resolveHomeDir(url)
- url = url.split('?')[0]
-
- for (var i = sessionPath ? -1 : 0; i < this.resolveDirs.length; i++) {
- var p = i === -1 ? sessionPath : this.resolveDirs[i]
-
- if (i == this.resolveDirs.length - 1 && this.remoteRoot) {
- // strip out remote-root path from request url when resolving against it
- url = url.replace(settings.read('remote-root'), '')
- }
-
- p = path.resolve(path.join(p, url))
-
- if (fs.existsSync(p)) return p
- }
-
- if (this.debug && !this.ipcServer.clients[clientId]) {
- // safari seems to be picky with cookies
- if (clientId === undefined) console.log(`(DEBUG, HTTP) Could not resolve requested url ${url} (client id not found in http cookies)`)
- // this should never happen, but just in case...
- // it happens when importing css file from theme
- else console.log(`(DEBUG, HTTP) Requested url ${url} not resolved against session path (unregistered client id ${clientId})`)
- }
-
- return false
-
- }
-
- sendFile(req, res, path) {
-
- var fpath = path.split('?')[0]
- var stats = fs.statSync(fpath)
- if (!stats || !stats.isFile()) {
- throw `File "${fpath}" not found.`
- }
- var lastModified = new Date(stats.mtime)
- lastModified.setMilliseconds(0)
- res.setHeader('Cache-Control', 'no-cache')
- res.setHeader('Last-Modified', lastModified.toUTCString())
- if (
- req.headers['if-modified-since'] && new Date(req.headers['if-modified-since']).getTime() >= lastModified.getTime()
- ) {
- res.statusCode = 304
- res.end()
- return
- }
- return send(req, fpath).pipe(res)
- }
-
- httpRoute(req, res) {
-
- var url = req.url
-
- if (url === '/qrcode'){
-
- // qrcode image
-
- res.setHeader('Content-Type', 'image/svg+xml')
- let str = this.qrcode,
- buf = Buffer.from && Buffer.from !== Uint8Array.from ? Buffer.from(str) : new Buffer(str)
- res.write(buf)
- res.end()
-
- } else if (url === '/' || url.indexOf('/?') === 0) {
-
- // index.html
-
- var ip = req.connection.remoteAddress.replace('::ffff:', '')
-
- var clientOptions = {}
- if (settings.read('client-options')) {
- for (var o of settings.read('client-options')) {
- if (!o.includes('=')) continue
- var [k, v] = o.split('=')
- clientOptions[k] = v
- }
- }
- res.setHeader('Cache-Control', 'no-store')
- fs.createReadStream(path.resolve(__dirname + '/../../client/index.html'))
- .pipe(replaceStream('