Compare commits
No commits in common. "master" and "v1.30.0-hotfix2" have entirely different histories.
master
...
v1.30.0-ho
69 changed files with 635 additions and 1719 deletions
|
|
@ -1,3 +0,0 @@
|
|||
node_modules
|
||||
app
|
||||
sessions
|
||||
|
|
@ -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}}
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -14,4 +14,3 @@ properties-reference.md
|
|||
|
||||
# packaging
|
||||
dist/
|
||||
sessions/
|
||||
|
|
@ -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.
|
||||
85
CHANGELOG.md
85
CHANGELOG.md
|
|
@ -1,87 +1,5 @@
|
|||
# Changelog
|
||||
|
||||
## 1.31.2
|
||||
|
||||
- bug fixes
|
||||
- editor: fix regression (1.30.0) causing errors when editing the value property
|
||||
|
||||
- widgets
|
||||
- canvas: allow `onResize` to send and trigger widget synchronization and scripts
|
||||
|
||||
## 1.31.1
|
||||
|
||||
- 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
|
||||
|
|
@ -128,9 +46,6 @@
|
|||
- 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
|
||||
|
|
|
|||
29
Dockerfile
29
Dockerfile
|
|
@ -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"]
|
||||
|
|
@ -11,11 +11,5 @@ Open Stage Control
|
|||
|
||||
----
|
||||
|
||||
Docker additions by Rik Berkelder.
|
||||
|
||||
mount `/sessions` directory. default session file is created and loaded there.
|
||||
|
||||
---
|
||||
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -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": []
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
services:
|
||||
app:
|
||||
build: .
|
||||
volumes:
|
||||
- ./sessions:/sessions
|
||||
ports:
|
||||
- 8080:8080
|
||||
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
test -f "$LOAD" || cp "basesession.json" "$LOAD"
|
||||
|
||||
exec node app/index.js \
|
||||
--port $PORT \
|
||||
--osc-port $OSC_PORT \
|
||||
--send $SEND \
|
||||
--load $LOAD \
|
||||
--read-only=$READ_ONLY
|
||||
563
package-lock.json
generated
563
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "open-stage-control",
|
||||
"version": "1.31.2",
|
||||
"version": "1.30.0-beta9",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "open-stage-control",
|
||||
"version": "1.31.2",
|
||||
"version": "1.30.0-beta9",
|
||||
"hasInstallScript": true,
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
|
|
@ -2024,178 +2024,6 @@
|
|||
"@parcel/watcher-win32-x64": "2.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-android-arm64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.1.tgz",
|
||||
"integrity": "sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-darwin-arm64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.1.tgz",
|
||||
"integrity": "sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-darwin-x64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.1.tgz",
|
||||
"integrity": "sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-freebsd-x64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.1.tgz",
|
||||
"integrity": "sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-arm-glibc": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.1.tgz",
|
||||
"integrity": "sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-arm-musl": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.1.tgz",
|
||||
"integrity": "sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-arm64-glibc": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.1.tgz",
|
||||
"integrity": "sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-arm64-musl": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.1.tgz",
|
||||
"integrity": "sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-x64-glibc": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.1.tgz",
|
||||
|
|
@ -2215,89 +2043,6 @@
|
|||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-linux-x64-musl": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.1.tgz",
|
||||
"integrity": "sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-win32-arm64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.1.tgz",
|
||||
"integrity": "sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-win32-ia32": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.1.tgz",
|
||||
"integrity": "sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/watcher-win32-x64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.1.tgz",
|
||||
"integrity": "sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-babel": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-6.1.0.tgz",
|
||||
|
|
@ -2432,228 +2177,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/rollup-android-arm-eabi": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.50.1.tgz",
|
||||
"integrity": "sha512-HJXwzoZN4eYTdD8bVV22DN8gsPCAj3V20NHKOs8ezfXanGpmVPR7kalUHd+Y31IJp9stdB87VKPFbsGY3H/2ag==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-android-arm64": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.50.1.tgz",
|
||||
"integrity": "sha512-PZlsJVcjHfcH53mOImyt3bc97Ep3FJDXRpk9sMdGX0qgLmY0EIWxCag6EigerGhLVuL8lDVYNnSo8qnTElO4xw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-darwin-arm64": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.50.1.tgz",
|
||||
"integrity": "sha512-xc6i2AuWh++oGi4ylOFPmzJOEeAa2lJeGUGb4MudOtgfyyjr4UPNK+eEWTPLvmPJIY/pgw6ssFIox23SyrkkJw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-darwin-x64": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.50.1.tgz",
|
||||
"integrity": "sha512-2ofU89lEpDYhdLAbRdeyz/kX3Y2lpYc6ShRnDjY35bZhd2ipuDMDi6ZTQ9NIag94K28nFMofdnKeHR7BT0CATw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-freebsd-arm64": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.50.1.tgz",
|
||||
"integrity": "sha512-wOsE6H2u6PxsHY/BeFHA4VGQN3KUJFZp7QJBmDYI983fgxq5Th8FDkVuERb2l9vDMs1D5XhOrhBrnqcEY6l8ZA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-freebsd-x64": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.50.1.tgz",
|
||||
"integrity": "sha512-A/xeqaHTlKbQggxCqispFAcNjycpUEHP52mwMQZUNqDUJFFYtPHCXS1VAG29uMlDzIVr+i00tSFWFLivMcoIBQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm-gnueabihf": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.50.1.tgz",
|
||||
"integrity": "sha512-54v4okehwl5TaSIkpp97rAHGp7t3ghinRd/vyC1iXqXMfjYUTm7TfYmCzXDoHUPTTf36L8pr0E7YsD3CfB3ZDg==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm-musleabihf": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.50.1.tgz",
|
||||
"integrity": "sha512-p/LaFyajPN/0PUHjv8TNyxLiA7RwmDoVY3flXHPSzqrGcIp/c2FjwPPP5++u87DGHtw+5kSH5bCJz0mvXngYxw==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm64-gnu": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.50.1.tgz",
|
||||
"integrity": "sha512-2AbMhFFkTo6Ptna1zO7kAXXDLi7H9fGTbVaIq2AAYO7yzcAsuTNWPHhb2aTA6GPiP+JXh85Y8CiS54iZoj4opw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm64-musl": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.50.1.tgz",
|
||||
"integrity": "sha512-Cgef+5aZwuvesQNw9eX7g19FfKX5/pQRIyhoXLCiBOrWopjo7ycfB292TX9MDcDijiuIJlx1IzJz3IoCPfqs9w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-loongarch64-gnu": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.50.1.tgz",
|
||||
"integrity": "sha512-RPhTwWMzpYYrHrJAS7CmpdtHNKtt2Ueo+BlLBjfZEhYBhK00OsEqM08/7f+eohiF6poe0YRDDd8nAvwtE/Y62Q==",
|
||||
"cpu": [
|
||||
"loong64"
|
||||
],
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-ppc64-gnu": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.50.1.tgz",
|
||||
"integrity": "sha512-eSGMVQw9iekut62O7eBdbiccRguuDgiPMsw++BVUg+1K7WjZXHOg/YOT9SWMzPZA+w98G+Fa1VqJgHZOHHnY0Q==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-riscv64-gnu": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.50.1.tgz",
|
||||
"integrity": "sha512-S208ojx8a4ciIPrLgazF6AgdcNJzQE4+S9rsmOmDJkusvctii+ZvEuIC4v/xFqzbuP8yDjn73oBlNDgF6YGSXQ==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-riscv64-musl": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.50.1.tgz",
|
||||
"integrity": "sha512-3Ag8Ls1ggqkGUvSZWYcdgFwriy2lWo+0QlYgEFra/5JGtAd6C5Hw59oojx1DeqcA2Wds2ayRgvJ4qxVTzCHgzg==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-s390x-gnu": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.50.1.tgz",
|
||||
"integrity": "sha512-t9YrKfaxCYe7l7ldFERE1BRg/4TATxIg+YieHQ966jwvo7ddHJxPj9cNFWLAzhkVsbBvNA4qTbPVNsZKBO4NSg==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-x64-gnu": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.50.1.tgz",
|
||||
|
|
@ -2666,74 +2189,6 @@
|
|||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-x64-musl": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.50.1.tgz",
|
||||
"integrity": "sha512-nEvqG+0jeRmqaUMuwzlfMKwcIVffy/9KGbAGyoa26iu6eSngAYQ512bMXuqqPrlTyfqdlB9FVINs93j534UJrg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-openharmony-arm64": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.50.1.tgz",
|
||||
"integrity": "sha512-RDsLm+phmT3MJd9SNxA9MNuEAO/J2fhW8GXk62G/B4G7sLVumNFbRwDL6v5NrESb48k+QMqdGbHgEtfU0LCpbA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openharmony"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-win32-arm64-msvc": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.50.1.tgz",
|
||||
"integrity": "sha512-hpZB/TImk2FlAFAIsoElM3tLzq57uxnGYwplg6WDyAxbYczSi8O2eQ+H2Lx74504rwKtZ3N2g4bCUkiamzS6TQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-win32-ia32-msvc": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.50.1.tgz",
|
||||
"integrity": "sha512-SXjv8JlbzKM0fTJidX4eVsH+Wmnp0/WcD8gJxIZyR6Gay5Qcsmdbi9zVtnbkGPG8v2vMR1AD06lGWy5FLMcG7A==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-win32-x64-msvc": {
|
||||
"version": "4.50.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.50.1.tgz",
|
||||
"integrity": "sha512-StxAO/8ts62KZVRAm4JZYq9+NqNsV7RvimNK+YM7ry//zebEH6meuugqW/P5OFUCjyQgui+9fUxT6d5NShvMvA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@serialport/binding-mock": {
|
||||
"version": "10.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@serialport/binding-mock/-/binding-mock-10.2.2.tgz",
|
||||
|
|
@ -5363,20 +4818,6 @@
|
|||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "open-stage-control",
|
||||
"productName": "Open Stage Control",
|
||||
"description": "Libre and modular OSC / MIDI controller",
|
||||
"version": "1.31.2",
|
||||
"version": "1.30.0",
|
||||
"author": {
|
||||
"name": "Jean-Emmanuel Doucet",
|
||||
"email": "jean-emmanuel@ammd.net"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ Client options can be set either with the server's `--client-options` option, or
|
|||
| virtualKeyboard | 1 / 0 | 0 | (desktop only) set to 1 to enable the virtual keyboard by default |
|
||||
| notifications | 1 / 0 | 1 | set to 0 to hide notifications by default |
|
||||
| title | string | '' | replace window title |
|
||||
| noWarning | 1 / 0 | 0 | set to 0 to disable unsaved session warnings |
|
||||
|
||||
Example:
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ The **server** can run on all [platforms supported by Electron](https://www.elec
|
|||
The **client** is compatible with the following browsers:
|
||||
|
||||
- Firefox: version `75` and higher
|
||||
- Chromium / Chrome: version `75` and higher
|
||||
- Chromium / Chrome: version `60` and higher
|
||||
|
||||
iOS devices must be of version `11` or higher.
|
||||
iOS devices must be of version `10.3` or higher.
|
||||
|
||||
|
||||
## Installation
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
The canvas widget allows creating custom widgets with user-defined drawings and touch reactions.
|
||||
|
||||
It has dedicated scripting properties (`onTouch`, `onDraw` and `onResize`) that work like the `onValue` property : they are used to defined scripts that will be executed when specific events occurs.
|
||||
It has two special properties, `touch` and `draw`, that work like the `script` property : they are used to defined scripts that will be executed when specific events occurs.
|
||||
|
||||
This widget requires a good understanding of the javascript [Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API) and of the javascript programming language in general.
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ If this property is enabled, the widget will be redrawn at a fixed rate even if
|
|||
|
||||
This script is executed when the widget is touched, when it is released, and during the movement of the pointer while the widget is touched.
|
||||
|
||||
This script has access to the same variables and functions as the `onValue` property (except the event-specific ones), plus the following:
|
||||
This script has access to the same variables and functions as the `script` property (except the event-specific ones), plus the following:
|
||||
|
||||
- `value`: widget value
|
||||
- `width`: canvas width in pixels
|
||||
|
|
@ -59,7 +59,7 @@ This script has access to the same variables and functions as the `onValue` prop
|
|||
|
||||
This script is executed when the widget should be redrawn, which is when it's touched and when it receives a value.
|
||||
|
||||
This script has access to the same variables and functions as the `onValue` property (except the event-specific ones), plus the following:
|
||||
This script has access to the same variables and functions as the `script` property (except the event-specific ones), plus the following:
|
||||
|
||||
- `value`: widget value
|
||||
- `width`: canvas width in pixels
|
||||
|
|
@ -67,13 +67,11 @@ This script has access to the same variables and functions as the `onValue` prop
|
|||
- `ctx`: [canvas rendering context](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D) of the widget
|
||||
- `cssVars`: object containing the computed value of some of the widget's style properties such as `colorWidget`, `alphaFill`, `padding`, etc
|
||||
|
||||
In this script, all osc messages emissions are prevented and changing the value of a widget won't trigger widget synchronisation / scripts / advanced syntaxes updates.
|
||||
|
||||
### `onResize`
|
||||
|
||||
This script is executed when the widget has resized, before it is redrawn.
|
||||
|
||||
This script has access to the same variables and functions as the `onValue` property (except the event-specific ones), plus the following:
|
||||
This script has access to the same variables and functions as the `script` property (except the event-specific ones), plus the following:
|
||||
|
||||
- `value`: widget value
|
||||
- `width`: canvas width in pixels
|
||||
|
|
|
|||
|
|
@ -123,8 +123,6 @@ The following variables are available in this context:
|
|||
|
||||
This script is specific to the root widget, it's called before any other widget is created and can be used to create global variables / functions accessible in other scripts.
|
||||
|
||||
In this script, all osc messages emissions are prevented and changing the value of a widget won't trigger widget synchronisation / scripts / advanced syntaxes updates.
|
||||
|
||||
## Available variables
|
||||
|
||||
The following variables and functions are accessible in this context.
|
||||
|
|
@ -330,6 +328,10 @@ Gives focus to a widget (ie input widget). If `id` is omitted or falsy, currentl
|
|||
|
||||
Returns the scroll position of a container as a `[x, y]` array.
|
||||
|
||||
**Deprecated**
|
||||
|
||||
Scrollable panels expose their scroll position normalized between 0 and 1 with their value.
|
||||
|
||||
----
|
||||
|
||||
#### `setScroll(id, x, y)`
|
||||
|
|
@ -339,14 +341,9 @@ Returns the scroll position of a container as a `[x, y]` array.
|
|||
|
||||
Sets the scroll state of a container.
|
||||
|
||||
----
|
||||
|
||||
#### `scrollIntoView(id, option)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget.
|
||||
- `option`: `alignToTop` or `options` argument as defined in https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
|
||||
|
||||
Scroll containers to make widget(s) visible.
|
||||
**Deprecated**
|
||||
|
||||
Scrollable panels expose their scroll position normalized between 0 and 1 with their value.
|
||||
|
||||
----
|
||||
|
||||
|
|
@ -419,19 +416,10 @@ Returns the instance of [Navigator](https://developer.mozilla.org/en-US/docs/Web
|
|||
|
||||
#### `browseFile(options, callback)`
|
||||
|
||||
Opens the server file browser and pass selected file to a callback function (does not create nor read files by itself).
|
||||
Opens the file file browser and pass selected file to a callback function (does not create nor read files by itself).
|
||||
|
||||
- `options`: object with the following keys:
|
||||
- `extension`: allowed extension (default: "*")
|
||||
- `directory`: starting directory for browser (default: user's home)
|
||||
- `allowDir`: allow choosing a directory instead of a file (default: false)
|
||||
- `mode`: "save" or "open"
|
||||
- `callback`: function called with 1 argument (file path)
|
||||
|
||||
#### `uploadFile(options, callback)`
|
||||
|
||||
Opens the client file upload prompt and pass the raw content of selected file to a callback function.
|
||||
|
||||
- `options`: object with the following keys:
|
||||
- `types`: equivalent of HTML attribute [`accept`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/accept)
|
||||
- `callback`: function called with 1 argument (file content)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="/packages/open-stage-control-{{config.latest_release}}-1.x86_64.rpm"><i class="fa fa-download"></i>GNU/Linux RPM (64-bit)</a></li>
|
||||
<li><a href="/packages/open-stage-control-{{config.latest_release}}.1.x86_64.rem"><i class="fa fa-download"></i>GNU/Linux RPM (64-bit)</a></li>
|
||||
<li><a href="/packages/open-stage-control_{{config.latest_release}}_amd64.deb"><i class="fa fa-download"></i>GNU/Linux Debian (64-bit)</a></li>
|
||||
<li><a href="/packages/open-stage-control_{{config.latest_release}}_linux-x64.zip"><i class="fa fa-download"></i>GNU/Linux (64-bit)</a></li>
|
||||
<li><a href="/packages/open-stage-control_{{config.latest_release}}_node.zip"><i class="fa fa-download"></i>Node.js</a></li>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ edit_uri: tree/master/resources/docs/
|
|||
copyright: "Copyleft © Jean-Emmanuel Doucet @ <a href='http://ammd.net'>AMMD</a> (<a href='https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/LICENSE'>GNU/GPLv3</a>)"
|
||||
site_description: "Libre and modular OSC / MIDI controller"
|
||||
site_dir: '../app/docs/'
|
||||
latest_release: 1.31.2
|
||||
latest_release: 1.30.0
|
||||
|
||||
theme:
|
||||
name: 'material'
|
||||
|
|
@ -64,6 +64,9 @@ nav:
|
|||
- Remote control: docs/remote-control.md
|
||||
- Credits: docs/credits.md
|
||||
- Changelog: docs/changelog.md
|
||||
|
||||
- Bug Tracker:
|
||||
- 'Bug Tracker': 'https://framagit.org/jean-emmanuel/open-stage-control/-/issues'
|
||||
- Community:
|
||||
- 'Community forums': 'https://openstagecontrol.discourse.group'
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ var handleClick = function(event) {
|
|||
|
||||
if (!targetWidget) return
|
||||
|
||||
while (targetWidget.meta.not_editable && targetWidget.parent) {
|
||||
while (targetWidget._not_editable && targetWidget.parent) {
|
||||
targetWidget = targetWidget.parent
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,8 +109,7 @@ function updateWidget(widget, options={}) {
|
|||
variables: widget.variables,
|
||||
hash: widget.hash,
|
||||
children: children,
|
||||
index: index,
|
||||
meta: widget.meta
|
||||
index: index
|
||||
})
|
||||
|
||||
newWidget.container.parentNode.replaceChild(newWidget.container, widget.container)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ 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 {defaults} 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'
|
||||
|
|
@ -282,7 +282,7 @@ class Editor {
|
|||
|
||||
if (
|
||||
this.inspector.helpModalOpened ||
|
||||
e && e.target && e.target.tagName.match(/INPUT|TEXTAREA|SELECT|OSC-CONSOLE/)
|
||||
e && e.target && e.target.tagName.match(/INPUT|TEXTAREA|SELECT/)
|
||||
) return
|
||||
|
||||
if (e) e.preventDefault()
|
||||
|
|
@ -401,7 +401,7 @@ class Editor {
|
|||
|
||||
} else if (e.key === 'ArrowRight') {
|
||||
|
||||
if (curWidget.children[0] && !curWidget.children[0].meta.not_editable) {
|
||||
if (curWidget.children[0] && !curWidget.children[0]._not_editable) {
|
||||
toSelect = curWidget.children[0]
|
||||
}
|
||||
|
||||
|
|
@ -905,17 +905,6 @@ class Editor {
|
|||
|
||||
}
|
||||
|
||||
/* 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
|
||||
|
|
@ -945,7 +934,7 @@ class Editor {
|
|||
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+$/, '') + '%'
|
||||
w.props.width = (100 * PXSCALE * newWidth / w.container.parentNode.offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
|
||||
} else {
|
||||
w.props.width = newWidth
|
||||
}
|
||||
|
|
@ -954,7 +943,7 @@ class Editor {
|
|||
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+$/, '') + '%'
|
||||
w.props.left = (100 * PXSCALE * newLeft / w.container.parentNode.offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
|
||||
} else if (w.props.left !== 'auto'){
|
||||
w.props.left = newLeft
|
||||
}
|
||||
|
|
@ -966,7 +955,7 @@ class Editor {
|
|||
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+$/, '') + '%'
|
||||
w.props.height = (100 * PXSCALE * newHeight / w.container.parentNode.offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
|
||||
} else {
|
||||
w.props.height = newHeight
|
||||
}
|
||||
|
|
@ -975,7 +964,7 @@ class Editor {
|
|||
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+$/, '') + '%'
|
||||
w.props.top = (100 * PXSCALE * newTop / w.container.parentNode.offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
|
||||
} else if (w.props.top !== 'auto'){
|
||||
w.props.top = newTop
|
||||
}
|
||||
|
|
@ -1009,13 +998,13 @@ class Editor {
|
|||
|
||||
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+$/, '') + '%'
|
||||
w.props.top = (100 * PXSCALE * newTop / w.container.parentNode.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+$/, '') + '%'
|
||||
w.props.left = (100 * PXSCALE * newLeft / w.container.parentNode.offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
|
||||
} else {
|
||||
w.props.left = newLeft
|
||||
}
|
||||
|
|
@ -1035,9 +1024,7 @@ class Editor {
|
|||
|
||||
pushHistory(indexes) {
|
||||
|
||||
if (!ENV.noWarning) {
|
||||
this.unsavedSession = true
|
||||
}
|
||||
this.unsavedSession = true
|
||||
|
||||
if (this.historyState > -1) {
|
||||
this.history.splice(0, this.historyState + 1)
|
||||
|
|
|
|||
|
|
@ -38,8 +38,6 @@ class WidgetManager extends EventEmitter {
|
|||
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++
|
||||
|
|
@ -119,8 +117,6 @@ class WidgetManager extends EventEmitter {
|
|||
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]] = []
|
||||
|
|
@ -184,9 +180,7 @@ class WidgetManager extends EventEmitter {
|
|||
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])
|
||||
linkId = linkId.map(x=>String(x))
|
||||
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)
|
||||
}
|
||||
|
|
@ -266,22 +260,7 @@ class WidgetManager extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
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 []
|
||||
}
|
||||
getWidgetById(id) {
|
||||
|
||||
return this.getWidgetBy(id, this.idRoute)
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ var Parser = class Parser {
|
|||
index,
|
||||
hash,
|
||||
locals,
|
||||
variables,
|
||||
meta
|
||||
variables
|
||||
} = options
|
||||
|
||||
var props = data
|
||||
|
|
@ -90,8 +89,7 @@ var Parser = class Parser {
|
|||
children,
|
||||
hash,
|
||||
locals,
|
||||
variables,
|
||||
meta
|
||||
variables
|
||||
})
|
||||
|
||||
widgetManager.addWidget(widget)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ window.onerror = function(msg,url,row,col, error) {
|
|||
|
||||
StackTrace.fromError(error).then((stackframes)=>{
|
||||
|
||||
var stringifiedStack = ' ' + stackframes.join('\n ')
|
||||
var stringifiedStack = stackframes.join('\n')
|
||||
|
||||
uiConsole.log('error', `${msg}\n${stringifiedStack}`)
|
||||
ipc.send('errorLog', `(ERROR, CLIENT) ${msg}\n${stringifiedStack}`)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
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
|
||||
|
|
@ -23,7 +21,7 @@ class Toast {
|
|||
|
||||
var toast = html`
|
||||
<div class="toast ${data.class || ''}" data-id="${data.id}">
|
||||
${raw(icon(data.icon || (data.class === 'error' ? 'exclamation' : 'bell')))}
|
||||
<i class="fa fa-fw fa-${data.icon || (data.class === 'error' ? 'exclamation' : 'bell')}"></i>
|
||||
<div class="content"></div>
|
||||
</div>
|
||||
`
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ var scriptGlobals = scriptVm.globals,
|
|||
|
||||
|
||||
const ace = window.ace
|
||||
ace.config.set('basePath', '/__APP_DIR__/client/ace/')
|
||||
ace.config.set('basePath', '/client/ace/')
|
||||
|
||||
function setCommandEnabled(editor, name, enabled) {
|
||||
var command = editor.commands.byName[name]
|
||||
|
|
@ -133,6 +133,7 @@ class CodeEditor {
|
|||
var editor = this.editor,
|
||||
input = this.input
|
||||
|
||||
editor.fullscreen = false
|
||||
input.style.display = 'none'
|
||||
input._ace_input = editor.textarea
|
||||
input.tabIndex = -1
|
||||
|
|
@ -140,8 +141,11 @@ class CodeEditor {
|
|||
editor.setValue(input.value)
|
||||
editor.textarea.osc_input = input
|
||||
editor.textarea.tabIndex = 0
|
||||
|
||||
this.field.classList.remove('dirty')
|
||||
editor.selection.setRange({start:0,end:0})
|
||||
if (!this.widget || widget.hash !== this.widget.hash) {
|
||||
// preserve active line if widget is the same
|
||||
editor.gotoLine(0)
|
||||
}
|
||||
|
||||
editor.removeAllListeners('focus')
|
||||
this.editor.on('focus', (e)=>{
|
||||
|
|
@ -155,8 +159,12 @@ class CodeEditor {
|
|||
this.editor.on('change', (e)=>{
|
||||
this.input.value = this.editor.getValue()
|
||||
this.editor.dirty = true
|
||||
if (this.editor.fullscreen) {
|
||||
this.field.classList.add('dirty')
|
||||
})
|
||||
|
||||
setTimeout(()=>{
|
||||
var pos = this.editor.getCursorPosition()
|
||||
if (pos.row === undefined || pos.column === undefined) {
|
||||
this.editor.gotoLine(0)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -164,32 +172,16 @@ class CodeEditor {
|
|||
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.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 = 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.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})
|
||||
|
|
@ -250,19 +242,10 @@ class CodeEditor {
|
|||
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.getSession().getUndoManager().reset()
|
||||
editor.resize()
|
||||
|
||||
|
||||
}
|
||||
|
||||
fullscreen() {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ class ColorPicker extends UiWidget {
|
|||
alphaStroke: 0,
|
||||
snap: true,
|
||||
alpha: true
|
||||
}, parent: this, meta: {not_editable: true}})
|
||||
}, parent: this})
|
||||
this.rgb.container.classList.add('not-editable')
|
||||
|
||||
this.container = html`
|
||||
<div class="color-picker">
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class UiConsole extends UiSidePanel {
|
|||
this.header = DOM.get(this.container, 'osc-panel-header')[0]
|
||||
|
||||
this.header.appendChild(html`<label>${locales('console')}</label>`)
|
||||
this.messages = this.content.appendChild(html`<osc-console tabIndex="-1"></osc-console>`)
|
||||
this.messages = this.content.appendChild(html`<osc-console></osc-console>`)
|
||||
|
||||
this.inputWrapper = this.content.appendChild(html`<osc-console-input></osc-console-inpu>`)
|
||||
this.input = this.inputWrapper.appendChild(html`<textarea rows="1"></textarea>`)
|
||||
|
|
@ -59,13 +59,14 @@ class UiConsole extends UiSidePanel {
|
|||
console._clear()
|
||||
}
|
||||
|
||||
this.widget = new Widget({props: {id: 'CONSOLE'}, parent: widgetManager, meta: {not_editable: true}})
|
||||
this.widget = new Widget({props: {id: 'CONSOLE'}, parent: widgetManager})
|
||||
this.script = new Script({
|
||||
widget: this.widget,
|
||||
property: '',
|
||||
code: 'var navigator; return eval(input_code)',
|
||||
context: {input_code: ''}
|
||||
})
|
||||
this.widget._not_editable = true
|
||||
this.widget.hash = 'CONSOLE'
|
||||
|
||||
this.input.addEventListener('keydown', (event)=>{
|
||||
|
|
@ -105,12 +106,6 @@ class UiConsole extends UiSidePanel {
|
|||
this.inputSize()
|
||||
})
|
||||
|
||||
this.messages.addEventListener('keydown', (event)=>{
|
||||
if (event.key == 'Escape') {
|
||||
this.messages.blur()
|
||||
}
|
||||
})
|
||||
|
||||
if (!READ_ONLY) this.enable()
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import UiModal from './ui-modal.mjs'
|
|||
import {DOM} from '../globals.mjs'
|
||||
|
||||
|
||||
export default function UiFilebrowser(options, callback, closeCallback) {
|
||||
export default function UiFilebrowser(options, callback) {
|
||||
|
||||
var save = options.save,
|
||||
saveInputFocus = undefined,
|
||||
|
|
@ -143,9 +143,11 @@ export default function UiFilebrowser(options, callback, closeCallback) {
|
|||
document.addEventListener('keydown', keyDownHandler)
|
||||
|
||||
ipc.on('listDir', (data)=>{
|
||||
|
||||
path = data.path
|
||||
root = data.root
|
||||
ariane.textContent = root ? path.replace(root, '/') : path
|
||||
|
||||
ariane.textContent = path.replace(root, '/')
|
||||
|
||||
files = data.files.filter(x=>x.folder || x.name.match(extRe))
|
||||
|
||||
|
|
@ -199,7 +201,6 @@ export default function UiFilebrowser(options, callback, closeCallback) {
|
|||
document.removeEventListener('keydown', keyDownHandler)
|
||||
document.removeEventListener('keyup', keyUpHandler)
|
||||
keyboardJS.setContext(previousKbContext)
|
||||
if (closeCallback) closeCallback(path)
|
||||
})
|
||||
|
||||
browser.appendChild(ariane)
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ export default function uiFileUpload(types, ok, error) {
|
|||
|
||||
if (SINGLETON) CONTAINER.removeChild(SINGLETON)
|
||||
|
||||
SINGLETON = html`<input type="file" style="position:absolute;opacity:0;pointer-events:none;"/>`
|
||||
|
||||
if (types) SINGLETON.accept = types
|
||||
SINGLETON = html`<input type="file" accept="${types}" style="position:absolute;opacity:0;pointer-events:none;"/>`
|
||||
|
||||
CONTAINER.appendChild(SINGLETON)
|
||||
|
||||
|
|
@ -26,9 +24,9 @@ export default function uiFileUpload(types, ok, error) {
|
|||
|
||||
uiLoading(locales('loading_upload'))
|
||||
|
||||
reader.onerror = reader.onabort = function(e) {
|
||||
reader.onerror = reader.onabort = function() {
|
||||
uiLoading(false)
|
||||
error(e)
|
||||
error()
|
||||
}
|
||||
|
||||
reader.onload = function(e) {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ class Button extends Widget {
|
|||
'- `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).',
|
||||
|
|
@ -94,8 +93,7 @@ class Button extends Widget {
|
|||
|
||||
var mode = this.getProp('mode'),
|
||||
tap = mode === 'momentary' || mode === 'tap',
|
||||
push = mode === 'push' || tap,
|
||||
click = this.getProp('click') && mode !== 'push'
|
||||
push = mode === 'push' || tap
|
||||
|
||||
if (push) {
|
||||
|
||||
|
|
@ -113,11 +111,11 @@ class Button extends Widget {
|
|||
|
||||
if (tap) this.container.classList.add('active')
|
||||
|
||||
}, {element: this.container, click: click})
|
||||
}, {element: this.container})
|
||||
|
||||
} else {
|
||||
|
||||
this.on(click ? 'click': 'draginit',(e)=>{
|
||||
this.on('draginit',(e)=>{
|
||||
|
||||
if (this.touchActive) return
|
||||
|
||||
|
|
@ -169,11 +167,11 @@ class Button extends Widget {
|
|||
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})
|
||||
}, {element: this.container})
|
||||
|
||||
} else {
|
||||
|
||||
this.on(click ? 'click': 'draginit',(e)=>{
|
||||
this.on('draginit',(e)=>{
|
||||
|
||||
if (this.touchActive) return
|
||||
|
||||
|
|
@ -219,8 +217,7 @@ class Button extends Widget {
|
|||
ignoreDefaults: true,
|
||||
},
|
||||
parentNode: this.widget,
|
||||
parent: this,
|
||||
meta: {...this.meta}
|
||||
parent: this
|
||||
})
|
||||
this.decoupledValue.on('value-changed', (e)=>{
|
||||
this.container.classList.toggle('on', this.decoupledValue.value)
|
||||
|
|
@ -230,7 +227,6 @@ class Button extends Widget {
|
|||
}
|
||||
|
||||
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})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ export default class File extends Widget {
|
|||
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'},
|
||||
|
|
@ -45,20 +44,19 @@ export default class File extends Widget {
|
|||
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)=>{
|
||||
this.on('fast-click', (e)=>{
|
||||
|
||||
if (e.capturedByEditor === true) return
|
||||
|
||||
uiFilebrowser({
|
||||
extension: ext.replace(/^\.?(.*)$/, '$1'),
|
||||
directory: this.getProp('directory') === 'auto' ? this.lastDir : this.getProp('directory'),
|
||||
directory: this.getProp('directory') === 'auto' ? undefined : this.getProp('directory'),
|
||||
loadDir: this.getProp('allowDir'),
|
||||
save: this.getProp('mode') === 'save'
|
||||
}, (path, root)=>{
|
||||
|
|
@ -72,8 +70,6 @@ export default class File extends Widget {
|
|||
send: true
|
||||
})
|
||||
|
||||
}, (path)=>{
|
||||
this.lastDir = path
|
||||
})
|
||||
}, {element: this.widget})
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class Menu extends MenuBase {
|
|||
doubleTap(this, (e)=>{
|
||||
if (this.opened) return
|
||||
this.open(e)
|
||||
}, {element: this.widget, click: this.mode.includes('toggle')})
|
||||
}, {element: this.widget})
|
||||
|
||||
this.on('draginit',(e)=>{
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ class Menu extends MenuBase {
|
|||
|
||||
} else {
|
||||
|
||||
this.on(this.mode.includes('toggle') ? 'click' : 'draginit',(e)=>{
|
||||
this.on('draginit',(e)=>{
|
||||
|
||||
if (this.opened && this.mode.includes('toggle')) {
|
||||
|
||||
|
|
|
|||
|
|
@ -189,11 +189,9 @@ class Widget extends EventEmitter {
|
|||
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
|
||||
|
||||
|
|
@ -392,24 +390,6 @@ class Widget extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
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
|
||||
|
|
@ -436,25 +416,6 @@ class Widget extends EventEmitter {
|
|||
|
||||
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 = {}
|
||||
|
|
@ -559,29 +520,10 @@ class Widget extends EventEmitter {
|
|||
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)
|
||||
}
|
||||
|
|
@ -625,7 +567,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
resolveProp(propName, propValue, storeLinks=true, originalWidget, originalPropName, context, recursive) {
|
||||
resolveProp(propName, propValue, storeLinks=true, originalWidget, originalPropName, context) {
|
||||
|
||||
propValue = propValue !== undefined ? propValue : deepCopy(this.props[propName])
|
||||
originalWidget = originalWidget || this
|
||||
|
|
@ -672,7 +614,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
var widgets = id == 'parent' && this.parent ?
|
||||
[this.parent] : id == 'this' ? [this] :
|
||||
widgetManager.getWidgetById(id, this.scopes)
|
||||
widgetManager.getWidgetById(id)
|
||||
|
||||
if (!widgets.length) {
|
||||
var parent = this.parent
|
||||
|
|
@ -686,7 +628,7 @@ class Widget extends EventEmitter {
|
|||
}
|
||||
|
||||
|
||||
// ignore clone wrapper in @parent stack (https://framagit.org/jean-emmanuel/open-stage-control/-/work_items/379)
|
||||
// ignore clone wrapper in @parent stack (https://github.com/jean-emmanuel/open-stage-control/issues/379)
|
||||
if (widgets[0] === this.parent && this.parent !== widgetManager && this.parent.getProp('type') === 'clone') widgets = [this.parent.parent]
|
||||
|
||||
if (storeLinks) {
|
||||
|
|
@ -944,14 +886,7 @@ class Widget extends EventEmitter {
|
|||
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'))
|
||||
) {
|
||||
if (isJSON(propValue) && (propName !== 'label' || propValue === 'false')) {
|
||||
try {
|
||||
propValue = JSON.parse(propValue)
|
||||
} catch (err) {}
|
||||
|
|
@ -959,31 +894,13 @@ class Widget extends EventEmitter {
|
|||
|
||||
} else if (propValue != null && typeof propValue == 'object') {
|
||||
for (let k in propValue) {
|
||||
propValue[k] = this.resolveProp(propName, propValue[k], storeLinks, originalWidget, originalPropName, context, true)
|
||||
propValue[k] = this.resolveProp(propName, propValue[k], storeLinks, originalWidget, originalPropName, context)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
|
|
@ -1018,8 +935,9 @@ class Widget extends EventEmitter {
|
|||
|
||||
if (
|
||||
!deepEqual(oldPropValue, propValue) ||
|
||||
(options && options.fromEditor && propName == 'value' && !this.areEquivalentValueProps(propValue, oldPropValue))
|
||||
(options && options.fromEditor && propName == 'value' && !deepEqual(oldPropValue, this.value))
|
||||
) {
|
||||
|
||||
if (!this.isDynamicProp(propName)) {
|
||||
|
||||
if (this.constructor._defaults[propName] === undefined) {
|
||||
|
|
@ -1212,7 +1130,7 @@ class Widget extends EventEmitter {
|
|||
id = this.getProp('id') || this.props.id,
|
||||
widget = this // used for edit link in console
|
||||
|
||||
while (widget.meta.not_editable && widget.parent !== widgetManager) {
|
||||
while (widget._not_editable && widget.parent !== widgetManager) {
|
||||
// ignore non editable
|
||||
widget = widget.parent
|
||||
}
|
||||
|
|
@ -1251,7 +1169,6 @@ class Widget extends EventEmitter {
|
|||
}
|
||||
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)
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,6 @@ class Clone extends Container() {
|
|||
|
||||
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,
|
||||
|
|
@ -52,11 +47,8 @@ class Clone extends Container() {
|
|||
|
||||
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')
|
||||
|
|
@ -70,18 +62,34 @@ class Clone extends Container() {
|
|||
parent = parent.parent
|
||||
}
|
||||
|
||||
this.getCloneTarget()
|
||||
this.bindTarget(this.getCloneTarget())
|
||||
if (this.cloneTarget) this.createClone(true)
|
||||
|
||||
// global listener to catch cloneTarget's creation if no target is locked
|
||||
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
|
||||
if (this.cloneTarget) return
|
||||
|
||||
var {id, widget} = e
|
||||
|
||||
if (String(id).includes(this.getProp('widgetId')) && this.isValidCloneTarget(widget)) {
|
||||
if (id === this.getProp('widgetId') && this.isValidCloneTarget(widget)) {
|
||||
|
||||
this.getCloneTarget()
|
||||
var clone = this.children[0]
|
||||
|
||||
this.unbindTarget()
|
||||
|
||||
if (!clone) {
|
||||
|
||||
this.updateContainer(false)
|
||||
this.bindTarget(widget)
|
||||
this.createClone()
|
||||
|
||||
} else {
|
||||
|
||||
this.bindTarget(widget)
|
||||
this.updateClone()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -108,6 +116,15 @@ class Clone extends Container() {
|
|||
// see common/widget.js @ updateProps()
|
||||
widgetManager.on('prop-src-changed', onPropChanged, {context: this})
|
||||
|
||||
this.on('widget-created', (e)=>{
|
||||
|
||||
if (e.widget !== this) {
|
||||
e.widget.container.classList.add('not-editable')
|
||||
e.widget._not_editable = true
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
getCloneTarget() {
|
||||
|
|
@ -115,54 +132,33 @@ class Clone extends Container() {
|
|||
// 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
|
||||
var widgets = widgetManager.getWidgetById(this.getProp('widgetId'))
|
||||
.filter(el=>this.isValidCloneTarget(el))
|
||||
|
||||
if (widgets.length === 0) return null
|
||||
if (widgets.length === 1) {
|
||||
return widgets[0]
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
||||
function isCreatedByAClone(wi){
|
||||
var parent = wi.parent
|
||||
return parent && parent.getProp('type') === 'clone'
|
||||
}
|
||||
|
||||
var target = widgets[0]
|
||||
for (var w of widgets) {
|
||||
if (!isCreatedByAClone(w)) {
|
||||
target = w
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return target
|
||||
|
||||
}
|
||||
|
||||
isValidCloneTarget(widget) {
|
||||
|
|
@ -184,12 +180,7 @@ class Clone extends Container() {
|
|||
parser.parse({
|
||||
data: data,
|
||||
parentNode: this.widget,
|
||||
parent: this,
|
||||
meta: {
|
||||
not_editable: true,
|
||||
clone: true,
|
||||
scopable: true
|
||||
}
|
||||
parent: this
|
||||
})
|
||||
|
||||
this.updateContainer(!init)
|
||||
|
|
@ -205,16 +196,14 @@ class Clone extends Container() {
|
|||
this.cloneTarget.off(undefined, undefined, this)
|
||||
|
||||
this.cloneTarget = null
|
||||
this.targetRank = null
|
||||
|
||||
}
|
||||
|
||||
bindTarget(target, rank) {
|
||||
bindTarget(target) {
|
||||
|
||||
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
|
||||
|
|
@ -227,14 +216,18 @@ class Clone extends Container() {
|
|||
// listen for cloneTarget's content updates
|
||||
this.cloneTarget.on('widget-created', (e)=>{
|
||||
|
||||
var {widget} = e
|
||||
var {widget} = e,
|
||||
parent = widget.parent
|
||||
|
||||
// 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()
|
||||
while (parent !== this.cloneTarget && parent !== widgetManager) {
|
||||
// if updated widget is in a nested clone, ignore it:
|
||||
// it will be handled by the nested clone that targets it
|
||||
if (parent.getProp('type') === 'clone') return
|
||||
parent = parent.parent
|
||||
}
|
||||
|
||||
this.updateClone()
|
||||
|
||||
}, {context: this})
|
||||
|
||||
}
|
||||
|
|
@ -294,6 +287,10 @@ class Clone extends Container() {
|
|||
|
||||
this.container.classList.remove('empty')
|
||||
|
||||
for (var w of this.getAllChildren()) {
|
||||
w.container.classList.add('not-editable')
|
||||
}
|
||||
|
||||
if (checkResize) resize.check(this.widget)
|
||||
|
||||
} else if (this.cloneClass.length) {
|
||||
|
|
@ -315,7 +312,10 @@ class Clone extends Container() {
|
|||
switch (propName) {
|
||||
|
||||
case 'widgetId':
|
||||
this.getCloneTarget()
|
||||
this.unbindTarget()
|
||||
this.updateContainer(false)
|
||||
this.bindTarget(this.getCloneTarget())
|
||||
if (this.cloneTarget) this.createClone()
|
||||
return
|
||||
case 'props':
|
||||
if (this.children[0]) this.updateClone()
|
||||
|
|
|
|||
|
|
@ -29,11 +29,6 @@ class Fragment extends Container() {
|
|||
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,
|
||||
|
|
@ -56,13 +51,20 @@ class Fragment extends Container() {
|
|||
|
||||
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')
|
||||
|
||||
this.on('widget-created', (e)=>{
|
||||
|
||||
if (e.widget !== this) {
|
||||
e.widget.container.classList.add('not-editable')
|
||||
e.widget._not_editable = true
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
sessionManager.on('fragment-updated', (e)=>{
|
||||
var {path} = e
|
||||
if (path === this.getProp('file') || path === this.getProp('fallback')) {
|
||||
|
|
@ -121,12 +123,7 @@ class Fragment extends Container() {
|
|||
parser.parse({
|
||||
data: data,
|
||||
parentNode: this.widget,
|
||||
parent: this,
|
||||
meta: {
|
||||
not_editable: true,
|
||||
fragment: true,
|
||||
scopable: true
|
||||
}
|
||||
parent: this
|
||||
})
|
||||
|
||||
this.updateContainer(!init)
|
||||
|
|
@ -149,6 +146,10 @@ class Fragment extends Container() {
|
|||
|
||||
this.container.classList.remove('empty')
|
||||
|
||||
for (var w of this.getAllChildren()) {
|
||||
w.container.classList.add('not-editable')
|
||||
}
|
||||
|
||||
if (checkResize) resize.check(this.widget)
|
||||
|
||||
} else if (this.fragmentClass.length) {
|
||||
|
|
|
|||
|
|
@ -135,11 +135,12 @@ class Keyboard extends Panel {
|
|||
var key = parser.parse({
|
||||
data: data,
|
||||
parentNode: this.widget,
|
||||
parent: this,
|
||||
meta: {not_editable: true}
|
||||
parent: this
|
||||
})
|
||||
|
||||
key._index = i - start
|
||||
key.container.classList.add('not-editable')
|
||||
key._not_editable = true
|
||||
key.container.classList.add('key')
|
||||
|
||||
if (pattern[i % 12] == 'w') {
|
||||
|
|
|
|||
|
|
@ -82,11 +82,12 @@ class Matrix extends Panel {
|
|||
var widget = parser.parse({
|
||||
data: data,
|
||||
parentNode: this.widget,
|
||||
parent: this,
|
||||
meta: {not_editable: true}
|
||||
parent: this
|
||||
})
|
||||
|
||||
widget._index = i
|
||||
widget.container.classList.add('not-editable')
|
||||
widget._not_editable = true
|
||||
|
||||
this.value[i] = widget.getValue()
|
||||
|
||||
|
|
@ -160,11 +161,12 @@ class Matrix extends Panel {
|
|||
var widget = parser.parse({
|
||||
data: data,
|
||||
parentNode: this.widget,
|
||||
parent: this,
|
||||
meta: {not_editable: true}
|
||||
parent: this
|
||||
})
|
||||
|
||||
widget._index = i
|
||||
widget.container.classList.add('not-editable')
|
||||
widget._not_editable = true
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -207,6 +209,9 @@ class Matrix extends Panel {
|
|||
Object.assign(this.children[i].props, data)
|
||||
|
||||
this.children[i].updateProps(Object.keys(data), this, options)
|
||||
// this.children[i] might have been recreated
|
||||
this.children[i].container.classList.add('not-editable')
|
||||
this.children[i]._not_editable = true
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ class Modal extends Panel {
|
|||
|
||||
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)'},
|
||||
doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the modal require a double tap to open instead of a single tap'},
|
||||
},
|
||||
geometry: {
|
||||
_separator_modal_geometry: 'Modal geometry',
|
||||
|
|
@ -94,21 +93,28 @@ class Modal extends Panel {
|
|||
|
||||
var closer = DOM.get(this.popup, '.closer')[0]
|
||||
|
||||
this.on(this.getProp('click') ? 'click' : 'draginit',(e)=>{
|
||||
this.on('fast-click',(e)=>{
|
||||
if ((e.target === this.popup || e.target === closer) && this.value == 1) {
|
||||
e.detail.preventOriginalEvent = true
|
||||
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')})
|
||||
}, {element: this.toggle})
|
||||
} else {
|
||||
this.on('fast-click',(e)=>{
|
||||
if (e.capturedByEditor === true) return
|
||||
if (e.target === this.toggle) {
|
||||
e.detail.preventOriginalEvent = true
|
||||
this.setValue(1, {sync:true, send:true})
|
||||
}
|
||||
}, {element: this.container})
|
||||
}
|
||||
|
||||
|
||||
this.escapeKeyHandler = ((e)=>{
|
||||
if (e.key == 'Escape') this.setValue(0, {sync:true, send:true})
|
||||
}).bind(this)
|
||||
|
|
|
|||
|
|
@ -156,8 +156,7 @@ class Panel extends Container() {
|
|||
parentNode: this.widget,
|
||||
parent: this,
|
||||
tab: true,
|
||||
index: i,
|
||||
meta: {...this.meta}
|
||||
index: i
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -199,8 +198,7 @@ class Panel extends Container() {
|
|||
data: this.getProp('widgets')[i],
|
||||
parentNode: this.widget,
|
||||
parent: this,
|
||||
index: i,
|
||||
meta: {...this.meta}
|
||||
index: i
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,9 +178,10 @@ class PatchBay extends Container(Canvas) {
|
|||
label: k
|
||||
},
|
||||
parentNode: DOM.get(this.widget, '.inputs')[0],
|
||||
parent: this,
|
||||
meta: {not_editable: true}
|
||||
parent: this
|
||||
})
|
||||
w.container.classList.add('not-editable')
|
||||
w._not_editable = true
|
||||
this.inputsWidgets.push(w)
|
||||
this.inputNodes.push(w.container)
|
||||
this.value[k] = []
|
||||
|
|
@ -199,42 +200,31 @@ class PatchBay extends Container(Canvas) {
|
|||
|
||||
|
||||
this.connecting = []
|
||||
this.mousePosition = []
|
||||
this.dragging = false
|
||||
|
||||
this.on('draginit', (e)=>{
|
||||
this.on('fast-click', (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]
|
||||
}
|
||||
}
|
||||
e.stopPropagation()
|
||||
}, {element: this.widget})
|
||||
|
||||
|
||||
this.mousePosition = []
|
||||
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
|
||||
if (e.target === this.canvas) {
|
||||
this.mousePosition = [e.offsetX, e.offsetY]
|
||||
} else if (this.mousePosition.length) {
|
||||
this.mousePosition[0] += e.movementX
|
||||
this.mousePosition[1] += e.movementY
|
||||
}
|
||||
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
|
||||
|
||||
if (this.mousePosition.length) {
|
||||
this.mousePosition = []
|
||||
this.toggleConnection(node)
|
||||
this.toggleConnection(e.target)
|
||||
}
|
||||
this.dragging = false
|
||||
}, {element: this.widget})
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ export default class Image extends StaticProperties(Widget, {bypass: true}) {
|
|||
|
||||
if (!s.length) {
|
||||
|
||||
this.value = String(this.getProp('default'))
|
||||
this.value = this.getProp('default')
|
||||
|
||||
} else if (s != 'reload') {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo
|
|||
'- `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.',
|
||||
'- `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/otaves roll-off, 2 for 12dB/octaves, etc.',
|
||||
'See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode'
|
||||
|
||||
]},
|
||||
|
|
@ -53,31 +53,20 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo
|
|||
|
||||
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)
|
||||
}
|
||||
this.calcResponse()
|
||||
|
||||
}
|
||||
|
||||
calcResponse() {
|
||||
|
||||
this.value.fill(0)
|
||||
var resolution = this.width,
|
||||
frequencyHz = new Float32Array(resolution),
|
||||
filterResponse = new Float32Array(resolution).fill(0),
|
||||
Fs = this.getProp('rangeX').max * 2
|
||||
|
||||
for (let i = 0; i < resolution; ++i) {
|
||||
frequencyHz[i] = mapToScale(i, [0, this.width], [this.getProp('rangeX').min, this.getProp('rangeX').max], -1, true)
|
||||
}
|
||||
|
||||
for (let filter of this.getProp('filters')) {
|
||||
|
||||
|
|
@ -96,29 +85,31 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo
|
|||
gain: filter.gain || 0,
|
||||
frequency: filter.freq || 1000,
|
||||
q: filter.q || 1,
|
||||
poles,
|
||||
Fs: this.getProp('rangeX').max * 2
|
||||
}, this.freqs, this.value)
|
||||
poles, Fs
|
||||
}, frequencyHz, filterResponse)
|
||||
}
|
||||
|
||||
this.setValue(filterResponse, {sync: true})
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
draw() {
|
||||
if (this.calcPending) {
|
||||
this.calcResponse()
|
||||
this.calcPending = false
|
||||
}
|
||||
super.draw()
|
||||
setValue(v, options={}) {
|
||||
|
||||
if (!(v instanceof Float32Array) && !(Array.isArray(v)) || v.length !== this.width) return
|
||||
|
||||
this.value = v
|
||||
this.batchDraw()
|
||||
|
||||
if (options.sync) this.changed(options)
|
||||
|
||||
}
|
||||
|
||||
resizeHandle(event){
|
||||
|
||||
super.resizeHandle(event)
|
||||
if (this.width !== this.value.length) {
|
||||
this.setupArrays()
|
||||
this.calcPending = true
|
||||
this.batchDraw()
|
||||
}
|
||||
if (this.width !== this.value.length) this.calcResponse()
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -128,8 +119,7 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo
|
|||
|
||||
switch (propName) {
|
||||
case 'filters':
|
||||
this.calcPending = true
|
||||
this.batchDraw()
|
||||
this.calcResponse()
|
||||
return
|
||||
|
||||
}
|
||||
|
|
@ -151,8 +141,7 @@ 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
|
||||
a0, a1, a2, b1, b2,norm
|
||||
|
||||
var V = Math.pow(10, Math.abs(gain) / 20)
|
||||
var K = Math.tan(Math.PI * frequency / Fs)
|
||||
|
|
@ -275,15 +264,15 @@ function biquadResponse(options, frequencyHz, filterResponse) {
|
|||
break
|
||||
}
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
|
||||
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)
|
||||
var 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
|
||||
// if (y == -Infinity) y = -200
|
||||
|
||||
filterResponse[i] += y * poles
|
||||
|
||||
|
|
|
|||
|
|
@ -131,14 +131,14 @@ export default class Plot extends StaticProperties(Canvas, {bypass: true}) {
|
|||
|
||||
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))
|
||||
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))
|
||||
} 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)
|
||||
ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true)
|
||||
|
||||
if (x !== nx || y !== ny) {
|
||||
points.push(nx)
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ class CanvasWidget extends Canvas {
|
|||
width: this.width,
|
||||
height: this.height,
|
||||
cssVars: this.cssVars
|
||||
}, {sync: true, send: true})
|
||||
}, {sync: false, send: false})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ class MultiXy extends Pad {
|
|||
'- pointSize',
|
||||
'- label',
|
||||
'- clipX',
|
||||
'- clipY',
|
||||
'- axisLock'
|
||||
'- clipY'
|
||||
]},
|
||||
snap: {type: 'boolean', value: false, help: [
|
||||
'By default, the points are dragged from their initial position.',
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ export default class Rgb extends Widget {
|
|||
decimals:2,
|
||||
pointSize: 10,
|
||||
pips: false,
|
||||
}, parent: this, meta: {not_editable: true}})
|
||||
}, parent: this})
|
||||
this.pad.sendValue = ()=>{}
|
||||
this.pad.container.classList.add('pad')
|
||||
this.pad.container.classList.add('not-editable', 'pad')
|
||||
this.widget.appendChild(this.pad.container)
|
||||
this.pad.on('value-changed',(e)=>{
|
||||
e.stopPropagation = true
|
||||
|
|
@ -76,8 +76,8 @@ export default class Rgb extends Widget {
|
|||
snap:this.getProp('snap'),
|
||||
range:{min:0,max:360},
|
||||
decimals:2
|
||||
}, parent: this, meta: {not_editable: true}})
|
||||
this.hue.container.classList.add('hue')
|
||||
}, parent: this})
|
||||
this.hue.container.classList.add('not-editable', 'hue')
|
||||
this.widget.appendChild(this.hue.container)
|
||||
this.hue.on('value-changed',(e)=>{
|
||||
e.stopPropagation = true
|
||||
|
|
@ -97,8 +97,8 @@ export default class Rgb extends Widget {
|
|||
default: 255,
|
||||
input:false,
|
||||
decimals:2
|
||||
}, parent: this, meta: {not_editable: true}})
|
||||
this.alpha.container.classList.add('alpha')
|
||||
}, parent: this})
|
||||
this.alpha.container.classList.add('not-editable', 'alpha')
|
||||
this.widget.appendChild(this.alpha.container)
|
||||
this.alpha.on('value-changed',(e)=>{
|
||||
e.stopPropagation = true
|
||||
|
|
@ -217,7 +217,7 @@ export default class Rgb extends Widget {
|
|||
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.pad.container.setAttribute('style',`background-color:${hueStr}`)
|
||||
this.hue.setValue(this.hsb.h, {sync: false, send:false, dragged:false})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ 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
|
||||
|
|
@ -44,7 +43,7 @@ class ScriptVm extends Vm {
|
|||
|
||||
if (id === 'this') return [widget]
|
||||
else if (id === 'parent' && widget.parent !== widgetManager) return [widget.parent]
|
||||
else return widgetManager.getWidgetById(id, widget.scopes)
|
||||
else return widgetManager.getWidgetById(id)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -279,24 +278,6 @@ class ScriptVm extends Vm {
|
|||
|
||||
}
|
||||
|
||||
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')
|
||||
|
|
@ -646,37 +627,6 @@ class ScriptVm extends Vm {
|
|||
}
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
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'}) {
|
||||
export default class Encoder extends StaticProperties(Knob, {angle: 360, range: {min: 0, max: 1}}) {
|
||||
|
||||
static description() {
|
||||
|
||||
|
|
@ -33,11 +33,10 @@ export default class Encoder extends StaticProperties(Knob, {angle: 360, range:
|
|||
'- 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: [
|
||||
mode: {type: 'string', value: 'circular', choices: ['circular', 'snap', 'vertical'], 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.',
|
||||
|
|
@ -117,11 +116,7 @@ export default class Encoder extends StaticProperties(Knob, {angle: 360, range:
|
|||
|
||||
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)
|
||||
this.setPercent(this.percent + (-100 * e.movementY / this.height) * this.getProp('sensitivity') / inertia)
|
||||
|
||||
} else {
|
||||
// snap or circular
|
||||
|
|
@ -263,4 +258,64 @@ export default class Encoder extends StaticProperties(Knob, {angle: 360, range:
|
|||
|
||||
}
|
||||
|
||||
draw() {
|
||||
|
||||
var percent = this.percent,
|
||||
d = this.percentToAngle(percent),
|
||||
angle = 2 * Math.PI / 16,
|
||||
min = this.percentToAngle(0),
|
||||
max = this.percentToAngle(100),
|
||||
minRadius = this.minDimension / 6,
|
||||
maxRadius = this.minDimension / 2 - this.cssVars.lineWidth,
|
||||
gaugeWidth = maxRadius - minRadius,
|
||||
gaugeRadius = maxRadius - gaugeWidth / 2
|
||||
|
||||
this.clear()
|
||||
|
||||
if (this.minDimension < 40) {
|
||||
minRadius /= 2
|
||||
gaugeWidth = maxRadius - minRadius
|
||||
gaugeRadius = maxRadius - gaugeWidth / 2
|
||||
}
|
||||
|
||||
// fill
|
||||
this.ctx.globalAlpha = this.cssVars.alphaFill
|
||||
this.ctx.strokeStyle = this.cssVars.colorFill
|
||||
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, 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, 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()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -313,8 +313,7 @@ class Fader extends Slider {
|
|||
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
|
||||
d = d / (height - this.gaugePadding) * (height-this.gaugePadding - knobHeight)
|
||||
this.ctx.rect(this.gaugePadding, d, width - this.gaugePadding * 2, knobHeight)
|
||||
this.ctx.fill()
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Knob extends Slider {
|
|||
var defaults = super.defaults(Knob).extend({
|
||||
style: {
|
||||
_separator_knob_style: 'Knob style',
|
||||
design: {type: 'string', value: 'default', choices: ['default', 'solid', 'line', 'encoder'], help: [
|
||||
design: {type: 'string', value: 'default', choices: ['default', 'solid', 'line'], help: [
|
||||
'Design style',
|
||||
'Note: "solid" design uses "colorStroke" for the central knob color.'
|
||||
]},
|
||||
|
|
@ -25,9 +25,8 @@ class Knob extends Slider {
|
|||
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: [
|
||||
mode: {type: 'string', value: 'vertical', choices: ['vertical', '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.',
|
||||
|
|
@ -110,10 +109,6 @@ class Knob extends Slider {
|
|||
// 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,
|
||||
|
|
@ -193,199 +188,153 @@ class Knob extends Slider {
|
|||
|
||||
this.clear()
|
||||
|
||||
switch (this.getProp('design')) {
|
||||
case 'default':
|
||||
{
|
||||
if (this.minDimension < 40) {
|
||||
minRadius /= 2
|
||||
gaugeWidth = maxRadius - minRadius
|
||||
gaugeRadius = maxRadius - gaugeWidth / 2
|
||||
}
|
||||
if (this.getProp('design') === 'default') {
|
||||
|
||||
// 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
|
||||
if (this.minDimension < 40) {
|
||||
minRadius /= 2
|
||||
gaugeWidth = maxRadius - minRadius
|
||||
gaugeRadius = maxRadius - gaugeWidth / 2
|
||||
}
|
||||
case 'solid':
|
||||
{
|
||||
// center
|
||||
|
||||
// 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.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.strokeStyle = this.cssVars.colorStroke
|
||||
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.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI)
|
||||
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()
|
||||
}
|
||||
// knob
|
||||
|
||||
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()
|
||||
}
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.strokeStyle = this.cssVars.colorKnob
|
||||
this.ctx.lineWidth = this.cssVars.lineWidth + .5 * PXSCALE
|
||||
|
||||
if (dashed) this.ctx.setLineDash([])
|
||||
let r1 = minRadius + this.gaugePadding,
|
||||
r2 = maxRadius - this.gaugePadding,
|
||||
a = 2 * Math.PI - d
|
||||
|
||||
// knob
|
||||
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()
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.strokeStyle = this.cssVars.colorKnob
|
||||
this.ctx.lineWidth = this.cssVars.lineWidth
|
||||
} else if (this.getProp('design') === 'solid') {
|
||||
|
||||
let r1 = minRadius * 1.5,
|
||||
r2 = maxRadius + this.cssVars.lineWidth / 2 - 0.5 * PXSCALE,
|
||||
a = 2 * Math.PI - d
|
||||
// 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.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.arc(this.width / 2, this.height / 2, maxRadius, min, max)
|
||||
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
|
||||
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()
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
// 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()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -415,7 +364,7 @@ class Knob extends Slider {
|
|||
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),
|
||||
var 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)
|
||||
|
|
|
|||
|
|
@ -301,15 +301,16 @@ class Range extends Fader {
|
|||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.fillStyle = this.cssVars.colorKnob
|
||||
var compactAdjust = 1 / (height - this.gaugePadding) * (height-this.gaugePadding - knobHeight)
|
||||
|
||||
this.ctx.beginPath()
|
||||
d = (d - this.gaugePadding ) / (height - this.gaugePadding * 2 ) * (height - this.gaugePadding * 2 - knobHeight) + this.gaugePadding
|
||||
d *= compactAdjust
|
||||
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
|
||||
d2 *= compactAdjust
|
||||
this.ctx.rect(this.gaugePadding, d2, width - this.gaugePadding * 2, knobHeight)
|
||||
this.ctx.fill()
|
||||
|
||||
|
|
|
|||
|
|
@ -43,61 +43,37 @@ export default class Scrollbar extends StaticProperties(Fader, {
|
|||
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
|
||||
if (this.scrollTarget) return
|
||||
|
||||
var {id, widget} = e
|
||||
if (id.includes(this.getProp('widgetId')) && widget.getProp('scroll')) {
|
||||
|
||||
this.getScrollTarget()
|
||||
if (id === this.getProp('widgetId') && widget.getProp('scroll')) {
|
||||
this.unbindTarget()
|
||||
this.bindTarget(widget)
|
||||
}
|
||||
|
||||
}, {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) {
|
||||
var widgets = widgetManager.getWidgetById(this.getProp('widgetId'))
|
||||
for (var widget of widgets) {
|
||||
if (widget.getProp('scroll')) {
|
||||
this.unbindTarget()
|
||||
this.bindTarget(target, rank)
|
||||
this.bindTarget(widget)
|
||||
break
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
draginitHandle(e) {
|
||||
|
||||
// super.draginitHandle(...arguments)
|
||||
|
|
@ -126,8 +102,6 @@ export default class Scrollbar extends StaticProperties(Fader, {
|
|||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
if (!this.scrollTarget) return
|
||||
|
||||
var increment
|
||||
if (this.getProp('horizontal')) {
|
||||
increment = e.deltaY / this.scrollTarget.scrollWidth * 100
|
||||
|
|
@ -158,57 +132,46 @@ export default class Scrollbar extends StaticProperties(Fader, {
|
|||
this.scrollTarget.off(undefined, undefined, this)
|
||||
|
||||
this.scrollTarget = null
|
||||
this.targetRank = null
|
||||
}
|
||||
|
||||
bindTarget(target, rank) {
|
||||
bindTarget(target) {
|
||||
|
||||
if (!target) return
|
||||
|
||||
this.scrollTarget = target
|
||||
this.targetRank = rank
|
||||
|
||||
this.scrollTarget.on('widget-removed', (e)=>{
|
||||
if (this.scrollTarget === e.widget) {
|
||||
this.unbindTarget()
|
||||
}
|
||||
}, {context: this})
|
||||
var onScroll = (e, init)=>{
|
||||
|
||||
if (!this.scrollTarget || 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})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
this.scrollTarget.on('scroll', onScroll)
|
||||
onScroll({}, 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)
|
||||
|
|
@ -266,8 +229,7 @@ export default class Scrollbar extends StaticProperties(Fader, {
|
|||
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
|
||||
d = d / (height - this.gaugePadding) * (height-this.gaugePadding - knobHeight)
|
||||
if (this.cssVars.borderRadius > 0 && this.ctx.roundRect) {
|
||||
this.ctx.roundRect(this.gaugePadding, d, width - this.gaugePadding * 2, knobHeight, PXSCALE * this.cssVars.borderRadius)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -17,12 +17,10 @@ export function clip(value,range) {
|
|||
// 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) {
|
||||
export function mapToScale(value, rangeIn, rangeOut, decimals, log, revertlog) {
|
||||
|
||||
// clip in
|
||||
if (!noClip) {
|
||||
value = clip(value,[rangeIn[0], rangeIn[1]])
|
||||
}
|
||||
value = clip(value,[rangeIn[0], rangeIn[1]])
|
||||
|
||||
|
||||
// normalize
|
||||
|
|
@ -50,9 +48,7 @@ export function mapToScale(value, rangeIn, rangeOut, decimals, log, revertlog, n
|
|||
value = value * (rangeOut[1] - rangeOut[0]) + rangeOut[0]
|
||||
|
||||
// clip out
|
||||
if (!noClip) {
|
||||
value = clip(value, [rangeOut[0], rangeOut[1]])
|
||||
}
|
||||
value = clip(value, [rangeOut[0], rangeOut[1]])
|
||||
|
||||
// decimals
|
||||
if (decimals !== -1) value = parseFloat(value.toFixed(decimals))
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class Vm {
|
|||
this.globals.console = {
|
||||
...console,
|
||||
log: (...msg)=>{
|
||||
msg = msg.map(m => typeof m == 'object' ? JSON.stringify(m, this.jsonReplacer) : m)
|
||||
msg = msg.map(m => typeof m == 'object' ? JSON.stringify(m) : m)
|
||||
this.getWidget().log(msg.join(' '))
|
||||
}
|
||||
}
|
||||
|
|
@ -143,10 +143,6 @@ class Vm {
|
|||
|
||||
}
|
||||
|
||||
jsonReplacer(key, value) {
|
||||
return value instanceof HTMLElement ? `<${value.tagName}#${value.id}>` : value
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Vm
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ window = {
|
|||
location: {search: ''},
|
||||
Image: Function,
|
||||
document: document,
|
||||
navigator: {
|
||||
platform:'',
|
||||
userAgent: ''
|
||||
},
|
||||
NodeList: Array,
|
||||
WebSocket: Object,
|
||||
localStorage: {
|
||||
|
|
@ -77,14 +81,7 @@ window = {
|
|||
ENV: {id: ''},
|
||||
IP: '',
|
||||
DOM
|
||||
}
|
||||
|
||||
if (!global.navigator) {
|
||||
// defined as getter since node 22
|
||||
window.navigator = {
|
||||
platform:'',
|
||||
userAgent: ''
|
||||
}
|
||||
}
|
||||
|
||||
Object.assign(global, window)
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@
|
|||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<meta name="theme-color" content="black">
|
||||
<link rel="apple-touch-icon" href="/__APP_DIR__/assets/logo.png" />
|
||||
<link rel="stylesheet" type="text/css" href="/__APP_DIR__/assets/open-stage-control.css" hot-reload/>
|
||||
<link rel="stylesheet" type="text/css" href="/__APP_THEME__.css" hot-reload/>
|
||||
<link rel="stylesheet" type="text/css" href="/__APP_DIR__/assets/fonts/fontawesome.min.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="/__APP_DIR__/assets/fonts/fa-solid.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="/__APP_DIR__/assets/fonts/roboto.css"/>
|
||||
<link rel="shortcut icon" href="/__APP_DIR__/assets/favicon.png"/>
|
||||
<script src="/__APP_DIR__/client/ace/ace.js"></script>
|
||||
<script type="module" defer src="/__APP_DIR__/client/index.js"></script>
|
||||
<link rel="modulepreload" href="/__APP_DIR__/client/callbacks.js" />
|
||||
<link rel="modulepreload" href="/__APP_DIR__/client/context-menu.js" />
|
||||
<link rel="modulepreload" href="/__APP_DIR__/client/remote-control.js" />
|
||||
<link rel="modulepreload" href="/__APP_DIR__/client/ui-keyboard.js" />
|
||||
<link rel="apple-touch-icon" href="/assets/logo.png" />
|
||||
<link rel="stylesheet" type="text/css" href="/assets/open-stage-control.css" hot-reload/>
|
||||
<link rel="stylesheet" type="text/css" href="/assets/theme.css" hot-reload/>
|
||||
<link rel="stylesheet" type="text/css" href="/assets/fonts/fontawesome.min.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="/assets/fonts/fa-solid.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="/assets/fonts/roboto.css"/>
|
||||
<link rel="shortcut icon" href="/assets/favicon.png"/>
|
||||
<script src="/client/ace/ace.js"></script>
|
||||
<script type="module" defer src="/client/index.js"></script>
|
||||
<link rel="modulepreload" href="/client/callbacks.js" />
|
||||
<link rel="modulepreload" href="/client/context-menu.js" />
|
||||
<link rel="modulepreload" href="/client/remote-control.js" />
|
||||
<link rel="modulepreload" href="/client/ui-keyboard.js" />
|
||||
</head>
|
||||
|
||||
<body class="editor-disabled" spellcheck="false">
|
||||
|
|
|
|||
|
|
@ -62,11 +62,6 @@ osc-console {
|
|||
user-select: text;
|
||||
}
|
||||
|
||||
.editor-enabled osc-console:focus {
|
||||
outline: 1rem dotted var(--color-accent);
|
||||
outline-offset: -1rem;
|
||||
}
|
||||
|
||||
osc-console-message {
|
||||
|
||||
user-select: text;
|
||||
|
|
|
|||
|
|
@ -190,9 +190,6 @@ osc-inspector-field {
|
|||
> label:before {
|
||||
content: var(--prefix);
|
||||
}
|
||||
&.dirty label:after{
|
||||
content: "*"
|
||||
}
|
||||
.btn {
|
||||
margin-top: 50rem;
|
||||
margin-right: 50rem;
|
||||
|
|
|
|||
|
|
@ -21,11 +21,6 @@ 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)
|
||||
|
|
@ -131,7 +126,9 @@ app.on('ready',()=>{
|
|||
})
|
||||
|
||||
app.on('window-all-closed', function() {
|
||||
app.quit()
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
export default app
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ function startLauncher() {
|
|||
})
|
||||
|
||||
launcher.on('will-close', (e)=>{
|
||||
if (clientWindows.some(w=>w && !w.isDestroyed()) || serverProcess) {
|
||||
if (clientWindows.some(w=>w && !w.isDestroyed())) {
|
||||
launcher.hide()
|
||||
e.preventDefault()
|
||||
}
|
||||
|
|
@ -209,7 +209,7 @@ function startLauncher() {
|
|||
|
||||
|
||||
launcher.on('close', (e)=>{
|
||||
if (tray && (clientWindows.some(w=>w && !w.isDestroyed()) || serverProcess)) {
|
||||
if (tray && clientWindows.some(w=>w && !w.isDestroyed()) && serverProcess) {
|
||||
launcher.hide()
|
||||
e.preventDefault()
|
||||
return
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import fs from 'fs'
|
|||
import vm from 'vm'
|
||||
import chokidar from 'chokidar'
|
||||
import path from 'path'
|
||||
import {Module} from 'module'
|
||||
import {globalPaths} from 'module'
|
||||
import * as settings from './settings.mjs'
|
||||
|
||||
var modulePathExtended = false,
|
||||
|
|
@ -79,9 +79,10 @@ class CustomModule {
|
|||
}
|
||||
|
||||
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()
|
||||
globalPaths.push(
|
||||
path.resolve(path.dirname(this.filename)),
|
||||
path.resolve(path.dirname(this.filename), 'node_modules')
|
||||
)
|
||||
modulePathExtended = true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ export default class Callbacks {
|
|||
|
||||
}, (error)=>{
|
||||
|
||||
this.ipcServer.send('error', `Could not open session file:\n ${error}`, clientId)
|
||||
this.ipcServer.send('error', `Could not open session file:\n ${error}`)
|
||||
|
||||
})
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ export default class Callbacks {
|
|||
|
||||
}, (error)=>{
|
||||
|
||||
this.ipcServer.send('error', `Could not open state file:\n ${error}`, clientId)
|
||||
this.ipcServer.send('error', `Could not open state file:\n ${error}`)
|
||||
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -97,9 +97,9 @@ class Client extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
send(packet) {
|
||||
send(event, data) {
|
||||
|
||||
// see IpcServer.send
|
||||
var packet = JSON.stringify([event, data])
|
||||
|
||||
if (this.connected()) {
|
||||
this.socket.send(packet)
|
||||
|
|
|
|||
|
|
@ -66,22 +66,12 @@ class IpcServer {
|
|||
|
||||
send(event, data, id, except) {
|
||||
|
||||
var packet = JSON.stringify([event, data])
|
||||
var clients = id ? [this.clients[id]] : this.clients
|
||||
|
||||
if (id) {
|
||||
// send to a single client
|
||||
if (this.clients[id]){
|
||||
this.clients[id].send(packet)
|
||||
for (var k in clients) {
|
||||
if (!except || this.clients[k] != this.clients[except]) {
|
||||
if (clients[k]) clients[k].send(event, data)
|
||||
}
|
||||
|
||||
} else {
|
||||
// send to all clients except one if specified
|
||||
for (let id in this.clients) {
|
||||
if (id != except) {
|
||||
this.clients[id].send(packet)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ export default {
|
|||
},
|
||||
'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|[^,]+,[^,]+))$/))
|
||||
var err = o.filter(item=>!item.match(/^(list|debug|jack|sysex|mtc|rpn|nrpn|active_sensing|note_off_velocity|pc_offset|path=(.*)|[^:]+:(virtual|[^,]+,[^,]+))$/))
|
||||
return err.length ? `Invalid option${err.length > 1 ? 's' : ''}: ${err.join(', ')}` : true
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -53,13 +53,13 @@ export default class OscServer {
|
|||
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)
|
||||
this.receiveOsc({host, port, address, args:args.map(x=>this.parseArg(x)), cm: 1}, options.clientId)
|
||||
},
|
||||
}) : {}
|
||||
|
||||
}
|
||||
|
||||
parseArg(arg, type, allowObjects = false){
|
||||
parseArg(arg, type){
|
||||
|
||||
if (arg === null) return null
|
||||
|
||||
|
|
@ -95,15 +95,7 @@ export default class OscServer {
|
|||
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)}
|
||||
}
|
||||
return {type: 's', value: JSON.stringify(arg)}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ export default class OscTCPServer extends EventEmitter {
|
|||
this.clients = {}
|
||||
|
||||
this.server = net.createServer(this.bindSocket.bind(this))
|
||||
this.on = this.server.on.bind(this.server)
|
||||
}
|
||||
|
||||
bindSocket(socket) {
|
||||
|
|
|
|||
|
|
@ -41,11 +41,6 @@ class WebServer extends EventEmitter {
|
|||
// 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',
|
||||
|
|
@ -134,35 +129,31 @@ class WebServer extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
res.sendFile = (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)
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
@ -171,8 +162,6 @@ class WebServer extends EventEmitter {
|
|||
|
||||
} else if (url === '/' || url.indexOf('/?') === 0) {
|
||||
|
||||
// index.html
|
||||
|
||||
var ip = req.connection.remoteAddress.replace('::ffff:', '')
|
||||
|
||||
var clientOptions = {}
|
||||
|
|
@ -195,94 +184,99 @@ class WebServer extends EventEmitter {
|
|||
</script></body>`))
|
||||
.pipe(res)
|
||||
|
||||
} else if (url.indexOf('__APP_THEME__.css') != -1) {
|
||||
|
||||
// user theme(s)
|
||||
|
||||
res.setHeader('Content-Type', 'text/css')
|
||||
|
||||
var etag = settings.read('theme') ? theme.hash : 'empty-theme'
|
||||
res.setHeader('Cache-Control', 'no-cache')
|
||||
res.setHeader('ETag', etag)
|
||||
if (req.headers['if-none-match'] && req.headers['if-none-match'] === etag) {
|
||||
res.statusCode = 304
|
||||
res.end()
|
||||
return
|
||||
}
|
||||
|
||||
if (settings.read('theme')) {
|
||||
let str = theme.get(),
|
||||
buf = Buffer.from && Buffer.from !== Uint8Array.from ? Buffer.from(str) : new Buffer(str)
|
||||
res.write(buf)
|
||||
} else {
|
||||
res.write('')
|
||||
}
|
||||
res.end()
|
||||
|
||||
} else if (url.match(/^\/+__APP_DIR__\//)) {
|
||||
|
||||
// osc asset files
|
||||
|
||||
try {
|
||||
this.sendFile(req, res, path.resolve(__dirname + '/../../' + url.replace('__APP_DIR__/', '')))
|
||||
return true
|
||||
} catch(e) {}
|
||||
|
||||
|
||||
console.error(`(ERROR, HTTP) File not found: ${url}`)
|
||||
|
||||
if (url.match(/\/client\/index.*\.js/)) {
|
||||
console.warn('(WARNING) It seems a client attempted to load an older version of the app,',
|
||||
'this may occur when using a homescreen bookmark on mobile devices.',
|
||||
'If that\'s the case, please delete it and browse to the app\'s url again.')
|
||||
}
|
||||
|
||||
res.writeHead(404)
|
||||
res.end()
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
// user files
|
||||
if (
|
||||
url.match(/^\/+(assets|client)\//)
|
||||
) {
|
||||
|
||||
// windows absolute path fix
|
||||
url = url.replace('_:_', ':') // escaped drive colon
|
||||
url = url.replace(/^\/([^/]*:)/, '$1') // strip leading slash
|
||||
// osc asset files
|
||||
|
||||
if (url.match(/\.(svg|jpg|jpeg|png|apng|gif|webp|tiff|xbm|bmp|ico|ttf|otf|woff|woff2|html|css|js)(\?[0-9]*)?$/i) ||
|
||||
url.match(/\.mjs$/) && !this.prod) {
|
||||
if (url.indexOf('theme.css') != -1) {
|
||||
|
||||
// Resolution order: session path, theme path, absolute path
|
||||
var id
|
||||
if (req.headers.cookie) {
|
||||
id = (req.headers.cookie.match(/client_id=([^;]+)/) || [])[1]
|
||||
}
|
||||
res.setHeader('Content-Type', 'text/css')
|
||||
|
||||
var resolvedPath = this.resolvePath(decodeURI(url), id)
|
||||
var etag = settings.read('theme') ? theme.hash : 'empty-theme'
|
||||
res.setHeader('Cache-Control', 'no-cache')
|
||||
res.setHeader('ETag', etag)
|
||||
if (req.headers['if-none-match'] && req.headers['if-none-match'] === etag) {
|
||||
res.statusCode = 304
|
||||
res.end()
|
||||
return
|
||||
}
|
||||
|
||||
if (settings.read('theme')) {
|
||||
let str = theme.get(),
|
||||
buf = Buffer.from && Buffer.from !== Uint8Array.from ? Buffer.from(str) : new Buffer(str)
|
||||
res.write(buf)
|
||||
} else {
|
||||
res.write('')
|
||||
}
|
||||
res.end()
|
||||
|
||||
} else {
|
||||
|
||||
if (resolvedPath) {
|
||||
try {
|
||||
this.sendFile(req, res, resolvedPath)
|
||||
res.sendFile(path.resolve(__dirname + '/../../' + url))
|
||||
return true
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
if (!this.ignoredNotFound.includes(url)) {
|
||||
|
||||
console.error(`(ERROR, HTTP) File not found: ${url}`)
|
||||
|
||||
if (url.match(/\/client\/index.*\.js/)) {
|
||||
console.warn('(WARNING) It seems a client attempted to load an older version of the app,',
|
||||
'this may occur when using a homescreen bookmark on mobile devices.',
|
||||
'If that\'s the case, please delete it and browse to the app\'s url again.')
|
||||
}
|
||||
|
||||
res.writeHead(404)
|
||||
res.end()
|
||||
|
||||
}
|
||||
|
||||
res.writeHead(404)
|
||||
res.end()
|
||||
|
||||
} else if (url.includes('/osc-ping')) {
|
||||
this.httpCheck(true)
|
||||
} else {
|
||||
res.writeHead(403)
|
||||
res.end()
|
||||
|
||||
// user files
|
||||
|
||||
// windows absolute path fix
|
||||
url = url.replace('_:_', ':') // escaped drive colon
|
||||
url = url.replace(/^\/([^/]*:)/, '$1') // strip leading slash
|
||||
|
||||
if (url.match(/.(svg|jpg|jpeg|png|apng|gif|webp|tiff|xbm|bmp|ico|ttf|otf|woff|woff2|html|css|js)(\?[0-9]*)?$/i)) {
|
||||
|
||||
// Resolution order: session path, theme path, absolute path
|
||||
var id
|
||||
if (req.headers.cookie) {
|
||||
id = (req.headers.cookie.match(/client_id=([^;]+)/) || [])[1]
|
||||
}
|
||||
|
||||
var resolvedPath = this.resolvePath(decodeURI(url), id)
|
||||
|
||||
if (resolvedPath) {
|
||||
try {
|
||||
res.sendFile(resolvedPath)
|
||||
return true
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
if (!this.ignoredNotFound.includes(url)) {
|
||||
console.error(`(ERROR, HTTP) File not found: ${url}`)
|
||||
}
|
||||
|
||||
res.writeHead(404)
|
||||
res.end()
|
||||
|
||||
} else if (url.includes('/osc-ping')) {
|
||||
this.httpCheck(true)
|
||||
} else {
|
||||
res.writeHead(403)
|
||||
res.end()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
httpCheck(ok, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue