Compare commits

...

177 commits

Author SHA1 Message Date
1af30141d0 package: make sure entrypoint.sh is runnable in docker container 2026-11-15 02:10:46 +01:00
d81da1acd3 ci: forgejo docker build 2026-11-15 02:01:00 +01:00
c97416b2c3 package: docker init 2026-11-15 01:16:56 +01:00
jean-emmanuel
c3d993e46a docs: bump version 2026-11-08 01:40:00 +01:00
jean-emmanuel
f1dd12c601 misc: lint 2026-11-08 01:39:12 +01:00
jean-emmanuel
82edcfe282 log: 1.31.2 changes 2026-11-08 01:37:19 +01:00
jean-emmanuel
cd4e3b35bb editor: fix call stack overflow caused by commit c1720b4a 2026-11-08 01:24:26 +01:00
jean-emmanuel
2790b7d86e server: serve dev files for client src debugging 2026-11-08 00:30:32 +01:00
jean-emmanuel
a47050e7ad server: send state open error to appropriate client instead of all 2026-10-21 10:09:40 +02:00
jean-emmanuel
9eab8ce38b server: send session open error to appropriate client instead of all 2026-10-21 10:08:07 +02:00
jean-emmanuel
dd3ca188ab server: ipc: deduplicate packet serialization when sending to multiple clients 2026-10-21 10:06:26 +02:00
jean-emmanuel
aec5ba9d9c canvas: allow onResize to send and trigger widget synchronization and scripts 2026-10-06 09:10:36 +02:00
jean-emmanuel
000714d22b image: ensure default value is a string 2026-09-08 16:36:09 +02:00
jean-emmanuel
3263cf2ff1 server: fix allowed extension regexp, explicitely allow mjs src files 2026-08-30 17:18:27 +02:00
jean-emmanuel
db85c42989 docs: 1.31.1 2026-08-30 16:09:07 +02:00
jean-emmanuel
a73e2755dc clone: regression causing error when some widgets have a non-string id 2026-08-30 16:04:29 +02:00
jean-emmanuel
aee968cba9 package: v1.31.0 2026-08-24 14:21:48 +02:00
jean-emmanuel
dcfde67d71 console: only hint focus when editor is enabled 2026-08-24 10:59:52 +02:00
jean-emmanuel
81d5e84044 console: visually indicate focus and blur with escape key 2026-08-24 10:49:43 +02:00
jean-emmanuel
883fb811e8 client: make console message area focusable and prevent editor kbd shortcuts when focused 2026-08-24 10:40:19 +02:00
jean-emmanuel
54d32c4c3f log: scrollbar init fix 2026-08-14 12:52:42 +02:00
jean-emmanuel
e7baf46890 scrollbar: rm debug log 2026-08-14 12:50:26 +02:00
jean-emmanuel
ce0ae02c8b scrollbar: fix initial value in vertical mode 2026-08-14 12:50:05 +02:00
jean-emmanuel
efe5629396 log: typo 2026-08-14 12:37:43 +02:00
jean-emmanuel
7c38dedcc7 log: latest changes 2026-08-14 09:31:49 +02:00
jean-emmanuel
af6cc4b911 tray: keep alive when closing if the server is running 2026-08-14 09:31:11 +02:00
jean-emmanuel
64642274d8 mac: quit app when last window is destroyed 2026-08-14 09:30:29 +02:00
jean-emmanuel
af1a8a8715 log: fix typo 2026-08-13 19:52:20 +02:00
jean-emmanuel
6605f1d2b3 log: phrasing 2026-08-13 19:50:34 +02:00
jean-emmanuel
4d1b8e924a scope: rename property, and log new feature 2026-08-13 19:29:25 +02:00
jean-emmanuel
d69d3b7f13 scope: tweakedy tweakeda fonk 2026-08-13 19:14:29 +02:00
jean-emmanuel
83090d2e06 scrollbar: typo 2026-08-13 18:09:18 +02:00
jean-emmanuel
83456acbff scopes: fix some issues in clone and adapt scrollbar 2026-08-13 18:08:29 +02:00
jean-emmanuel
08b837ff98 scope: continue implementation, adjust clone target acquire mechanism, add scoped linkId 2026-08-13 17:50:57 +02:00
jean-emmanuel
0e8c77a700 widgets: fix widget removal from linkId table when '<<' or '>>' prefixes are present 2026-08-13 16:55:33 +02:00
jean-emmanuel
a36811954d widgets: amend not_editable clean 2026-08-13 15:17:52 +02:00
jean-emmanuel
39c9d4a46d scoping: first id scoping implementation 2026-08-12 16:10:31 +02:00
jean-emmanuel
593ec4c53d widget: clean not-editable css class 2026-08-12 16:09:43 +02:00
jean-emmanuel
8c22384ddb widgets: better not_editable widget flag implementation 2026-08-09 10:30:11 +02:00
jean-emmanuel
7981b6fdd6 osc: avoid object serialization from custom module to client 2026-08-06 12:43:23 +02:00
jean-emmanuel
27d87f2238 stacktrace: missing indentation 2026-07-09 09:08:11 +02:00
jean-emmanuel
c49a731134 midi: fix unrecognized no_auto_note_off option 2026-07-08 11:38:57 +02:00
jean-emmanuel
ac7b0323e2 package: 1.30.4 2026-07-06 17:50:13 +02:00
jean-emmanuel
fe5bbb4713 AI: update policy 2026-07-06 17:45:35 +02:00
jean-emmanuel
e44cf615b5 clone: fix @{parent} bindings 2026-07-06 17:37:56 +02:00
jean-emmanuel
cdea67809f Merge branch 'master' of framagit.org:jean-emmanuel/open-stage-control 2026-07-04 14:34:09 +02:00
jean-emmanuel
79c04cc69a editor: fix moving/resing widgets inside folders when using percent units 2026-07-04 14:05:32 +02:00
jean-emmanuel
045be39e87 knob: add encoder design (& DRY) 2026-06-22 10:02:20 +02:00
jean-emmanuel
c1d692ffba knob: add encoder design (& DRY) 2026-06-20 23:04:18 +02:00
jean-emmanuel
c40d30aa2b encoder: add horizontal mode 2026-06-20 19:08:43 +02:00
jean-emmanuel
d22f850598 notificaion: support icon transform suffixes (use utils.icons()) 2026-06-07 16:20:37 +02:00
jean-emmanuel
7e7c3f43e7 ai: let's make things clear 2026-05-20 09:50:38 +02:00
jean-emmanuel
614b0c237f docs: remove git bug tracker 2026-05-10 19:09:43 +02:00
jean-emmanuel
b89d254386 docs: fix rpm dl link 2026-04-28 18:53:22 +02:00
jean-emmanuel
26a3d4ce60 docs: bump v 2026-04-28 18:49:00 +02:00
jean-emmanuel
a7708f6cd5 package: v1.30.3 2026-04-28 18:28:58 +02:00
jean-emmanuel
ed722923d9 log: tcp regression 2026-04-28 18:27:40 +02:00
jean-emmanuel
9d7087b6e7 Merge branch 'fix/tcp-server-on-binding' into 'master'
fix: tcp incoming messages being silently dropped

See merge request jean-emmanuel/open-stage-control!886
2026-04-28 16:25:11 +00:00
Xavier
e163308e35 fix: tcp incoming messages being silently dropped 2026-04-28 16:25:10 +00:00
jean-emmanuel
19a86aa31b docs: axisLock in multixy.pointsAttr 2026-04-23 15:21:33 +02:00
jean-emmanuel
c84bbee02e scrollbar: methodize target scroll handler and watch for target resize 2026-04-23 11:14:41 +02:00
jean-emmanuel
7fc5372ca1 scripting: add scrollIntoView() 2026-04-23 10:14:03 +02:00
jean-emmanuel
22068ab47e log: update 2026-04-21 16:43:51 +02:00
jean-emmanuel
6dbbc9318d plot, eq: unclip line on y axis 2026-04-21 16:43:12 +02:00
jean-emmanuel
9d79e857f8 scripting: add fileUpload function 2026-04-09 14:59:03 +02:00
jean-emmanuel
892cbd6886 eq: easy optimisation (don't compute response more than needed) 2026-04-07 12:47:19 +02:00
jean-emmanuel
3407568b5f knob: add horizontal mode 2026-03-30 19:11:10 +02:00
jean-emmanuel
51e33c0230 file: remember last visited directory per widget 2026-03-26 18:44:25 +01:00
jean-emmanuel
dfe45cac01 file: dedupe leading "/" when no root is set 2026-03-26 18:44:20 +01:00
jean-emmanuel
d9c23bc672 eq: doc typo 2026-03-03 09:46:14 +01:00
jean-emmanuel
013b7faf9e fader/range: fix compact mode drawing mistake 2026-03-03 09:10:27 +01:00
jean-emmanuel
8bec0552d4 scrollbar: fix drawing issue 2026-03-03 08:29:24 +01:00
jean-emmanuel
3730aa7199 scrollbar: prevent another error 2026-03-03 08:29:09 +01:00
jean-emmanuel
e4311271e9 misc: detailed comment 2026-03-02 17:28:18 +01:00
jean-emmanuel
43d18647b2 linux: workaround gtk conflict 2026-03-02 16:36:46 +01:00
jean-emmanuel
12508f8994 docs: bump version 2026-03-02 13:57:38 +01:00
jean-emmanuel
e2c48bd6ac script: escape html elements in widget log to avoid cyclic json error 2026-03-02 11:21:18 +01:00
jean-emmanuel
3d12e85e56 scrollbar: prevent error 2026-03-02 10:53:45 +01:00
jean-emmanuel
a0fed34edb misc: space 2026-03-02 10:49:41 +01:00
jean-emmanuel
27e3e6f1b3 client: add noWarning option 2026-03-02 10:48:36 +01:00
jean-emmanuel
91fb688d9d button: amend click doc 2026-03-02 10:41:38 +01:00
jean-emmanuel
99578d3be5 log: update 2026-03-02 10:38:56 +01:00
jean-emmanuel
6b37c4521e button: add click option & add missing move events to onTouch 2026-03-02 10:37:29 +01:00
jean-emmanuel
b016724d04 modal, file: add click option 2026-03-02 10:28:05 +01:00
jean-emmanuel
9961fb73b4 menu: use click event in *toggle modes 2026-03-02 10:27:42 +01:00
jean-emmanuel
270eb77802 log: modal click handler fix 2026-03-01 11:44:56 +01:00
jean-emmanuel
84474499c7 modal: use draginit as click handler (allows preventing touch event from parent container) 2026-03-01 11:23:09 +01:00
jean-emmanuel
bfc1d182be patchbay: interaction and rendering issues + use draginit instead of fast-click 2026-03-01 11:12:40 +01:00
jean-emmanuel
e682455872 log: rgb fix 2026-02-10 13:07:47 +01:00
jean-emmanuel
09aa7e8a63 rgb: don't break pad styling when updating hue (use correct method to update styles) 2026-02-05 13:28:14 +01:00
jean-emmanuel
3da569700a code editor: add content changed hint 2026-01-22 12:04:50 +01:00
jean-emmanuel
daa4fbfecf code editor: keep fullscreen code editor focused and opened upon validation 2026-01-22 11:57:37 +01:00
jean-emmanuel
5bf5ab8754 editor: preserve code editor undo history between consecutive edits of a same widget's property 2026-01-22 10:52:20 +01:00
jean-emmanuel
c59c4a8065 widgets: resolveProp: preserve numbers and booleans as strings in object values 2026-01-20 10:01:22 +01:00
jean-emmanuel
4c008099ca docs: update browser requirements 2026-01-09 18:52:24 +01:00
jean-emmanuel
08d4139844 server: define sendFile as server method once and for all 2026-01-09 09:41:36 +01:00
jean-emmanuel
a425d8156c server: fix @imports from theme (don't serve it from osc_asset dir to let imports load from user locations) 2026-01-09 09:28:32 +01:00
jean-emmanuel
750f89b6ce docs: fix biuld for node 22 2026-01-08 22:56:39 +01:00
jean-emmanuel
bf72d38fcf docs: bump 2026-01-08 22:53:26 +01:00
jean-emmanuel
11af5edc70 package: 1.30.1 2026-01-08 22:42:00 +01:00
jean-emmanuel
0bfbf59f0f custom module: fix nativeRequire resolve path (somehow broke during esm migration) 2026-01-08 22:40:29 +01:00
jean-emmanuel
b8c59db5f3 server: fix user asset loading from folder named "assets" (or "client"). This also makes osc asset urls more clear 2026-01-08 21:24:58 +01:00
jean-emmanuel
c3f526070f log: electron version 2026-01-07 00:49:43 +01:00
jean-emmanuel
d0a76d4ce3 server: don't use path.resove on assets (fails on windows) and fix regexp 2026-01-03 10:07:49 +01:00
jean-emmanuel
665515b626 widget: fix typo 2025-12-30 18:17:43 +01:00
jean-emmanuel
2758a79ff5 widget: last minute regression in updateProps 2025-12-30 18:04:18 +01:00
jean-emmanuel
43ac672d94 docs: new downloads 2025-12-30 17:55:42 +01:00
jean-emmanuel
1aa3fbfef5 script-vm: fix setTimeout/setInterval override 2025-12-30 17:34:05 +01:00
jean-emmanuel
f4af775a98 package: 1.30 2025-12-30 17:08:29 +01:00
jean-emmanuel
8cf854af2e noop: rename internal event for better clarity 2025-12-29 18:38:53 +01:00
jean-emmanuel
4627fa9c02 log: value state/prop change 2025-12-29 14:03:19 +01:00
jean-emmanuel
5b3d3e671c widget: amend c1720b4a52 to keep things as unchanged as possible 2025-12-29 13:56:32 +01:00
jean-emmanuel
c1720b4a52 widget: updateProps: add a special case for value property, when edited (remotely or from the editor), check against the value state instead to decide whether to update the state or not. The regular behavior that works well for other properties is otherwise confusing for the value as it is not ovious to the user that there are two values (the property and the state) 2025-12-29 13:47:13 +01:00
jean-emmanuel
80e5b048ea switch: make values prop dynamic 2025-12-29 12:50:34 +01:00
jean-emmanuel
414195c621 editor: rename changedProps vars and flag to editedProps to disambiguate 2025-12-29 12:40:14 +01:00
jean-emmanuel
c3002b99c3 value events: remove some useless flags 2025-12-29 10:55:51 +01:00
jean-emmanuel
93d3b159ca package: beta10 2025-12-28 12:47:52 +01:00
jean-emmanuel
3613dd9901 log 1.29.9 backport 2025-12-27 11:38:05 +01:00
jean-emmanuel
5ea192d5d4 build: regenerate package lock to fix dependency fetching 2025-12-26 23:36:07 +01:00
jean-emmanuel
9abfb85739 editor: fix regression in code editor making global variables unrecognized 2025-12-23 16:41:56 +01:00
jean-emmanuel
5785a5e026 misc: lint 2025-12-19 12:20:51 +01:00
jean-emmanuel
2a4412e726 client: don't request storage access at all, it's not needed for toplevel site 2025-12-19 09:14:37 +01:00
jean-emmanuel
89b68c8009 client: log full error if storage access is denied 2025-12-19 08:17:08 +01:00
jean-emmanuel
eddcbe5cd2 docs: link typo 2025-12-18 09:47:25 +01:00
jean-emmanuel
5070ec8421 package: update lock file 2025-12-17 12:54:18 +01:00
jean-emmanuel
eff4ddea8a package: move some gh links 2025-12-17 12:53:44 +01:00
jean-emmanuel
1b3ab562da launcher: update download link 2025-12-17 12:13:52 +01:00
jean-emmanuel
4857a20b61 launcher: query new repo instead of gh 2025-12-17 12:12:36 +01:00
jean-emmanuel
6de4b1ac5c repo: rm github files 2025-12-17 11:54:46 +01:00
jean-emmanuel
db5d087425 readme: update link 2025-12-17 11:53:20 +01:00
jean-emmanuel
7ab8bcd78a docs: update contributors list 2025-12-17 11:38:46 +01:00
jean-emmanuel
d93b880330 docs: more links 2025-12-17 11:27:50 +01:00
jean-emmanuel
199b6241aa log: escape double brackets for mkdocs macros 2025-12-17 11:19:48 +01:00
jean-emmanuel
70be6fedfa docs: update bug tracker url 2025-12-17 11:19:31 +01:00
jean-emmanuel
618fb3b01f docs: framagit migration 2025-12-17 11:16:37 +01:00
jean-emmanuel
dc85311b54 deps: ditch osc.js fork 2025-12-17 10:03:34 +01:00
jean-emmanuel
6bd1293959 log: update 2025-12-16 12:36:23 +01:00
jean-emmanuel
422c84d42e package: beta 9 2025-12-16 12:34:09 +01:00
jean-emmanuel
37b305eaea client: delay access storage denial error log 2025-12-16 12:24:32 +01:00
jean-emmanuel
b27d381324 client: better storage access error log 2025-12-16 12:21:52 +01:00
jean-emmanuel
3777b1fcbb client: make app more resilient to storage access denial 2025-12-16 12:16:20 +01:00
jean-emmanuel
8af432933c ipc: fix an old regression preventing uuid from being reused 2025-12-16 10:30:12 +01:00
jean-emmanuel
55d5f440be ipc: dedupe 'connected' response to 'open' request (no functionnal effect) 2025-12-15 13:00:36 +01:00
jean-emmanuel
ce48146bdb launcher: fix regression 2025-12-15 09:41:33 +01:00
jean-emmanuel
e4eae76bdf midi: implement backend restart feature 2025-12-15 09:41:17 +01:00
jean-emmanuel
31f4119442 scripting: calling setFocus() without if now unfocuses active element 2025-12-14 14:41:05 +01:00
jean-emmanuel
42b71ef6fc package: beta 8 2025-12-13 19:27:21 +01:00
jean-emmanuel
d4cd2ec666 imports: use some black magic **** to please safari/ios and fix dynamic imports order 2025-12-13 19:24:10 +01:00
jean-emmanuel
9b58f4e365 server: more reliable url check for client assets requests 2025-12-13 11:44:35 +01:00
jean-emmanuel
b064b8f3a8 button: add onTouch 2025-12-13 11:30:10 +01:00
jean-emmanuel
934550c942 events: make sure event.offsetX/Y works the same for touch & mouse 2025-12-13 11:20:58 +01:00
jean-emmanuel
58c1fc3c32 client: init timeout should not be needed anymore; preload js modules asap if supported 2025-12-12 18:32:31 +01:00
jean-emmanuel
8737385a0e package: rm debug line 2025-12-12 18:31:36 +01:00
jean-emmanuel
7cda8e4670 package: raise min chromium version, to remove some polyfills and speed up loading time 2025-12-12 13:22:28 +01:00
jean-emmanuel
a441bd628b iframe: remove useless error string from the past 2025-12-11 19:56:33 +01:00
jean-emmanuel
fa15187c2c client: extra safe chunk loading before notifying server 2025-12-11 15:04:42 +01:00
jean-emmanuel
45dd19494f package: beta 7 2025-12-10 17:22:59 +01:00
jean-emmanuel
3bba80d2f0 client: ensure html no-cache policy 2025-12-10 17:21:51 +01:00
jean-emmanuel
fab78f98a4 scripting: add getToolbar() and make toolbar() accept string id 2025-12-10 09:50:05 +01:00
jean-emmanuel
67669d4ff2 package-lock: update 2025-12-10 09:49:42 +01:00
jean-emmanuel
6f46a813cc docs: fullscreen and wakelock don't always require user interaction to work 2025-12-10 09:04:56 +01:00
jean-emmanuel
dc023def19 client: update toolbar toggle when user agent releases the wakelock by itself 2025-12-10 08:59:30 +01:00
jean-emmanuel
02cc18395a misc: lint 2025-12-09 22:17:45 +01:00
jean-emmanuel
931827fc72 server: silence not found errors for apple requests 2025-12-09 22:05:40 +01:00
jean-emmanuel
891239658c ios: use 3rd party to better detect iOS versions and mobile devices 2025-12-09 21:59:50 +01:00
jean-emmanuel
972ecdfae3 server: issue a warning when a cached/expired version of the app is requested 2025-12-09 12:31:26 +01:00
jean-emmanuel
92ef3b7ac1 server/client: tidy up cache control, enforce server validation and remove version from build assets file names 2025-12-09 12:17:26 +01:00
jean-emmanuel
71293de694 docs: scription: set() external flag implies send:false, not sync:false 2025-12-05 17:53:50 +01:00
jean-emmanuel
acf5f74ea2 client: ensure a proper init order for server-client communication 2025-12-04 17:56:12 +01:00
jean-emmanuel
dc7ac2bcd3 electron: prevent possible error when stopping server 2025-11-10 23:27:21 +01:00
jean-emmanuel
3451feef24 package: update 2025-11-09 09:52:16 +01:00
jean-emmanuel
0a6dd34575 package: see if electron 36 solves some mac issues 2025-11-09 09:51:19 +01:00
jean-emmanuel
1129fe42cf build: chmod 2025-11-05 09:38:47 +01:00
jean-emmanuel
e18ad7774c package: beta3 2025-11-05 09:37:35 +01:00
jean-emmanuel
e7a864d84e input: numeric: select all content when focused (doesn't work on all browsers though) 2025-11-05 09:13:48 +01:00
jean-emmanuel
2a4c9d96fe xy: add clipX and clipY proprties (allows multixy to set per-pads anges limits) 2025-11-01 13:57:32 +01:00
jean-emmanuel
9e60de7243 misc: all recent node versions are supported 2025-10-24 21:13:51 +02:00
106 changed files with 5315 additions and 5477 deletions

3
.dockerignore Normal file
View file

@ -0,0 +1,3 @@
node_modules
app
sessions

View file

@ -0,0 +1,24 @@
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}}

3
.github/FUNDING.yml vendored
View file

@ -1,3 +0,0 @@
# These are supported funding model platforms
patreon: openstagecontrol

View file

@ -1,23 +0,0 @@
---
name: Bug report
about: Report a bug in Open Stage Control
title: '[Bug]'
---
<!--
/!\ Don't forget to add a title /!\
Please provide as much contextual informations as possible:
- Open Stage Control version (or commit if built from sources)
- Operating system
- Open Stage Control options
- Client type (built-in or external browser) and version
- Session file (can be uploaded after adding the .txt extension)
- Custom module
- Server logs (from the terminal or the launcher's console)
- Client logs (hit F12 in chromium/chrome to open the console)
- Screenshot
-->

View file

@ -1,5 +0,0 @@
---
name: Feature request
about: Suggest an idea for Open Stage Control
title: '[Feature] '
---

5
.github/SUPPORT.md vendored
View file

@ -1,5 +0,0 @@
## How do I get help ?
- If you found a bug, open a bug report
- If you have a suggestion, open a feature request
- If you have a question or want to share your experience with other users, please use the dedicated forum at https://openstagecontrol.discourse.group/

1
.gitignore vendored
View file

@ -14,3 +14,4 @@ properties-reference.md
# packaging
dist/
sessions/

7
AI_POLICY.md Normal file
View file

@ -0,0 +1,7 @@
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.

View file

@ -1,5 +1,87 @@
# 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
@ -8,6 +90,7 @@
- prevent changing editor zoom level when it's disabled
- fader: fix touchZone == knob for compact design
- separator labels missing in inspector
- make the client app more robust to restrictive browser settings (cookie must still be enabled for the app to fully work)
- widgets
- the html property is no longer restricted / sanitized
@ -18,23 +101,44 @@
- root/panel/modal/tab: support setting `scroll` to `hidden` (hides scrollbars and allows scrolling)
- add new `scrollbar` widget that connects to a scrolling container widget and acts as it scrollbar
- input: add `noCanvas` option to avoid blurry text under some circumstances
- xy: add `clipX` and `clipY` proprties (allows multixy to set per-pads anges limits)
- button: add `onTouch` script
- switch: make `values` property dynamic
- editor
- selecting a widget automatically shows it in the widget tree if it's not minimized
- submitting an unchanged value for the `value` property will now affect the value state of the widget even if the property content itself did not change
- scripting
- user scripts are longer protected against infinite loop and the main window object may be reached (it's not supported to break out of scripting context, but resources are no longer wasted to prevent it)
- `toolbar()` can now target menu actions by id instead of index
- `getToolbar()` function added (returns the state of a menu entry toggle)
- calling `setFocus()` without argument now unfocuses current active element
- midi
- add `no_auto_note_off` option
- add `Restart backend` action to the launcher's menu
- add `restartMidiBackend()` function to custom module context
- breaking change
- dropped support for iOS 10.3
- macOS Catalina or above is now required (the node package will work on older system)
- minimum chromium version requirement raised to 70
- macOS 11 (Big Sur) or above is now required (the node package will work on older system)
- scrollbars are no longer emulated on iOS
- scrollbar styling is now done using only the standard css scrollbar-* properties) to be more in line with system scrollbars in general
- panels no longer use their value to set/get their scrolling state, nor do they sync scrolling automatically. Instead there's now a dedicated scrollbar widget that can be used for this.
- misc
- now using electron v36.9.5
## 1.29.9
- build
- fix building from sources now that open stage control is not hosted on github
- scripting
- user scripts are longer protected against infinite loop
## 1.29.8
- bug fixes
@ -955,7 +1059,7 @@
- advanced syntaxes
- new syntax for creating and using custom variables in properties: `VAR{name, default}`
- `JS{}` blocks don't require 2 brackets anymore (`JS{{}}` still works)
- `JS{}` blocks don't require 2 brackets anymore (`JS\{\{}}` still works)
- scripting
- add `getVar()` and `setVar()` for reading and modifying custom variables. This allows modifying properties directly from scripts (if they contain `VAR{}` blocks).
@ -1026,7 +1130,7 @@
- add option for receiving note off with velocity
- misc
- v0->v1 session conversion: remove `JS{{}}` in script property
- v0->v1 session conversion: remove `JS\{\{}}` in script property
## 1.9.0
@ -1628,14 +1732,14 @@ As of this version, packages except the `node` package are bundled with a midi b
- scripting (general)
- removed MathJS language
- reuse #{} syntax as as shorthand for JS{{}} (one liner, implicit return)
- reuse #{} syntax as as shorthand for JS\{\{}} (one liner, implicit return)
- added `locals` variable, a variable store scoped to the widget
- renamed `global` to `globals`
- expose environment variables in `globals`: `url`, `env` (query parameters), `platform`, `screen` (width/height)
- script widget
- always hidden except in project tree
- `script` property must not be wrapped in a JS{{}} block anymore
- `script` property must not be wrapped in a JS\{\{}} block anymore
- added `stateGet` and `stateSet` functions
- added `storage` object, proxy to the document's localStorage object (allows storing data that persist after refresh/close (cleared with the browser's cache)
- added `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` function proxies with an extra `id` argument (they clear automatically when called multiple times and upon widget removal. `id` is scoped to the widget)

29
Dockerfile Normal file
View file

@ -0,0 +1,29 @@
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"]

View file

@ -11,5 +11,11 @@ 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](ttps://github.com/jean-emmanuel/open-stage-control/blob/master/LICENSE) license.
This program is a free software released under the [GNU/GPL3](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/LICENSE) license.

49
basesession.json Normal file
View file

@ -0,0 +1,49 @@
{
"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": []
}
}

8
docker-compose.yml Normal file
View file

@ -0,0 +1,8 @@
services:
app:
build: .
volumes:
- ./sessions:/sessions
ports:
- 8080:8080

10
entrypoint.sh Normal file
View file

@ -0,0 +1,10 @@
#!/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

8149
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,7 @@
"name": "open-stage-control",
"productName": "Open Stage Control",
"description": "Libre and modular OSC / MIDI controller",
"version": "1.30.0-beta2",
"version": "1.31.2",
"author": {
"name": "Jean-Emmanuel Doucet",
"email": "jean-emmanuel@ammd.net"
@ -15,7 +15,7 @@
],
"repository": {
"type": "git",
"url": "https://github.com/jean-emmanuel/open-stage-control"
"url": "https://framagit.org/jean-emmanuel/open-stage-control"
},
"homepage": "http://openstagecontrol.ammd.net/",
"license": "GPL-3.0",
@ -33,7 +33,7 @@
"ansi-html": "0.0.9",
"babelify": "10.0.0",
"balanced-match": "2.0.0",
"bonjour": "github:jean-emmanuel/bonjour",
"bonjour": "git+https://framagit.org/jean-emmanuel/bonjour.git",
"chokidar": "3.5.3",
"chroma-js": "2.4.2",
"core-js": "3.22.5",
@ -58,7 +58,7 @@
"nodemon": "2.0.16",
"nosleep.js": "0.12.0",
"open": "8.4.0",
"osc": "github:jean-emmanuel/osc.js",
"osc": "2.4.5",
"python-shell": "3.0.1",
"qrcode": "1.5.1",
"replacestream": "4.0.3",
@ -74,13 +74,14 @@
"sortablejs": "1.15.0",
"source-map-support": "0.5.21",
"stacktrace-js": "2.0.2",
"ua-parser-js": "2.0.7",
"ws": "8.6.0",
"yargs": "17.5.1"
},
"optionalDependencies": {
"electron": "32.3.3",
"electron": "36.9.5",
"electron-installer-debian": "3.1.0",
"electron-installer-redhat": "github:jean-emmanuel/electron-installer-redhat"
"electron-installer-redhat": "git+https://framagit.org/jean-emmanuel/electron-installer-redhat.git"
},
"scripts": {
"postinstall": "echo '\\033[36m=> Dependencies installed successfully. Run \"npm run build\" to build the assets.\\033[0m\n'",
@ -104,6 +105,6 @@
"test": "npm run lint && npm run build"
},
"engines": {
"node": ">=16 <=20"
"node": ">=16"
}
}

View file

@ -19,6 +19,7 @@ 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:

View file

@ -1,19 +1,17 @@
## License
Copyleft © Jean-Emmanuel Doucet 2014-2025.
This program is a free software released under the [GNU/GPL3](https://github.com/jean-emmanuel/open-stage-control/blob/master/LICENSE) license.
This program is a free software released under the [GNU/GPL3](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/LICENSE) license.
## Dependencies
Open Stage Control relies on several other free softwares:
Open Stage Control relies on several other free softwares listed in [package.json](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/package.json).
https://github.com/jean-emmanuel/open-stage-control/network/dependencies
The default theme is based on [Nord](https://www.nordtheme.com/), some UI components are inspired by the [Atom](https://atom.io/) text editor.
The default theme was based on [Nord](https://www.nordtheme.com/), some UI components were inspired by the text editor formerly known as Atom (now [Pulsar](https://pulsar-edit.dev/)).
## Contributors
https://github.com/jean-emmanuel/open-stage-control/graphs/contributors
[Jean-Emmanuel](https://framagit.org/jean-emmanuel), [MartinHN](https://github.com/MartinHN), [Eric Theise](https://github.com/erictheise), [danielappelt](https://github.com/erictheise), [ritschwumm](https://github.com/ritschwumm), [matthijskooijman](https://github.com/matthijskooijman), [WillyKaze](https://github.com/WillyKaze), [stefanboca](https://github.com/stefanboca), [pixelnerve](https://github.com/pixelnerve), [AdamAdamsMusic](https://github.com/AdamAdamsMusic), [wicast](https://github.com/wicast), [kdallafior](https://github.com/kdallafior), [brunetton](https://github.com/brunetton), [cyberic99](https://github.com/cyberic99), [kdejaeger](https://github.com/kdejaeger), [trebmuh](https://github.com/trebmuh), [MagnusReichel](https://github.com/MagnusReichel), [jpcima](https://github.com/jpcima), [t1st3](https://github.com/t1st3")
## Infrastructure supports

View file

@ -76,7 +76,7 @@ The module is executed in a restricted context, only a few globals are available
----
#### `app`
[`Event Emitter`](https://nodejs.org/api/events.html#events_class_eventemitter), useful for monitoring the events sent by the different clients. Event names can be found in [callbacks.js](https://github.com/jean-emmanuel/open-stage-control/blob/master/src/server/callbacks.js), callbacks are called with 2 arguments: `data` (object) and `client` (object: `{address, id}`)
[`Event Emitter`](https://nodejs.org/api/events.html#events_class_eventemitter), useful for monitoring the events sent by the different clients. Event names can be found in [callbacks.js](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/src/server/node/ipc/callbacks.mjs), callbacks are called with 2 arguments: `data` (object) and `client` (object: `{address, id}`)
----
@ -153,7 +153,7 @@ This function can be used to load native node modules or locally installed modul
#### `tcpServer`
Raw access to the server's [TCP backend](https://github.com/jean-emmanuel/open-stage-control/blob/master/src/server/osc/tcp.js). Can be used to monitor the state of TCP connections:
Raw access to the server's [TCP backend](https://framagit.org/jean-emmanuel/open-stage-control/-/blob/master/src/server/node/osc/tcp.mjs). Can be used to monitor the state of TCP connections:
```js
for (var ip in tcpServer.clients) {
@ -167,6 +167,10 @@ for (var ip in tcpServer.clients) {
```
#### `restartMidiBackend()`
This function can be used to restart the midi backend (if already running) without restarting the server
#### Other javascript globals
- `console`

View file

@ -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 `60` and higher
- Chromium / Chrome: version `75` and higher
iOS devices must be of version `10.3` or higher.
iOS devices must be of version `11` or higher.
## Installation

View file

@ -2,7 +2,7 @@ Running the app from the sources slightly differs from using prebuilt binaries:
## Requirements
- [Node.js](https://nodejs.org/en/#download) (v16)
- [Node.js](https://nodejs.org/en/#download)
- [git](https://git-scm.com/downloads)
@ -12,7 +12,7 @@ Running the app from the sources slightly differs from using prebuilt binaries:
**Download**
```bash
git clone https://github.com/jean-emmanuel/open-stage-control
git clone https://framagit.org/jean-emmanuel/open-stage-control.git
cd open-stage-control/
# uncomment next line if you want the latest release
# instead of the current development version

View file

@ -7,7 +7,9 @@
- New window: open a new client window (hidden when stopped)
- Load: load server configuration from file
- Save / Save as: save server configuration to file
- List MIDI devices: list available MIDI devices in the console
- MIDI
- List devices: list available MIDI devices in the console
- Restart backend: restart midi backend without restarting the server
- Console:
- Clear: clear console
- Autoscroll: enable/disable console autoscroll

View file

@ -2,7 +2,7 @@
The canvas widget allows creating custom widgets with user-defined drawings and touch reactions.
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.
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.
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 `script` property (except the event-specific ones), plus the following:
This script has access to the same variables and functions as the `onValue` 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 `script` prope
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 `script` property (except the event-specific ones), plus the following:
This script has access to the same variables and functions as the `onValue` property (except the event-specific ones), plus the following:
- `value`: widget value
- `width`: canvas width in pixels
@ -67,11 +67,13 @@ This script has access to the same variables and functions as the `script` prope
- `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 `script` property (except the event-specific ones), plus the following:
This script has access to the same variables and functions as the `onValue` property (except the event-specific ones), plus the following:
- `value`: widget value
- `width`: canvas width in pixels

View file

@ -123,6 +123,8 @@ 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.
@ -161,7 +163,7 @@ Returns the value of the first matching widget. If the returned value is an obje
- `sync: false`: prevents widgets from triggering synchronization and scripts
- `script: false`: prevents scripts but not synchronization
- `send: false`: prevents widgets from sending osc messages
- `external: true`: simulates a value coming from an osc/midi message (implies `sync: false` automatically)
- `external: true`: simulates a value coming from an osc/midi message (implies `send: false` automatically)
Sets the value of the first matching widget. If `ìd` contains wildcards, affects all matching widgets **except** the emitting widget.
@ -303,7 +305,7 @@ Reference:
- `id` (optional): widget `id` as a string
Gives focus to a widget (ie input widget).
Gives focus to a widget (ie input widget). If `id` is omitted or falsy, currently focused element will be unfocused.
*Built-in client only*: tells the operating system to give the focus to the client window
@ -328,10 +330,6 @@ Gives focus to a widget (ie input widget).
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)`
@ -341,26 +339,50 @@ Scrollable panels expose their scroll position normalized between 0 and 1 with t
Sets the scroll state of a container.
**Deprecated**
----
#### `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.
Scrollable panels expose their scroll position normalized between 0 and 1 with their value.
----
#### `toolbar(i1, i2, ...)`
- `iX`: menu entry index
#### `toolbar(id)`
- `id` menu entry id (string)
Triggers toolbar action at specified index.
Triggers toobar action if currently available (ie accessible from the menu). `id` can be one of the following:
!!! example "Examples"
- `session-new`,`session-open`, `session-save`, `session-save-as`, `session-fragment`, `session-backup`, `session-import`, `session-export`
- `state-store`, `state-recall`, `state-send`, `state-open`, `state-save`, `state-save-as`, `state-import`, `state-export`
- `editor-enabled`, `editor-grid`, `editor-tree`, `editor-inspector`, `editor-percents`
- `console-enabled`, `console-clear`
- `fullscreen`, `notifictions`, `prevent-sleep`, `virtual-keyboard`
Some actions will only be triggered if initiated with a physical user interaction, check the console for errors if it doesn't work as expected.
=== "Legacy syntax: `toolbar(i1, i2, ...)`"
- `iX`: menu entry index
Triggers toolbar action at specified index.
!!! example "Examples"
- `toolbar(0, 0)` -> Open a new session
- `toolbar(4)` -> Toggle full screen
Actions will only be triggered if initiated with a user interaction. Fullscreen cannot be toggled with a simulated interaction (i.e. using `/SET`)
----
#### `getToolbar(id)`
- `id` menu entry id (string)
Returns `true` if the toolbar entry exists and is currently activated.
#### `openUrl(url)`
- `url`: http(s) url
@ -397,10 +419,19 @@ Returns the instance of [Navigator](https://developer.mozilla.org/en-US/docs/Web
#### `browseFile(options, callback)`
Opens the file file browser and pass selected file to a callback function (does not create nor read files by itself).
Opens the server 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)

View file

@ -3,66 +3,20 @@
!!! tip ""
[*Click here*](/docs/getting-started/introduction/#installation) to read the installation guide.
<a href="https://github.com/jean-emmanuel/open-stage-control/releases/latest"> Open Stage Control <span id="osc-version"span></a>
<a href="https://framagit.org/jean-emmanuel/open-stage-control/-/releases/v{{config.latest_release}}">
Open Stage Control v{{config.latest_release}}
</a>
<div id="osc-assets">Loading assets...</div>
<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}}_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>
<li><a href="/packages/open-stage-control_{{config.latest_release}}_osx-x64.zip"><i class="fa fa-download"></i>MacOS x64</a></li>
<li><a href="/packages/open-stage-control_{{config.latest_release}}_osx-arm64.zip"><i class="fa fa-download"></i>MacOS arm64</a></li>
<li><a href="/packages/open-stage-control_{{config.latest_release}}_win32-x64.zip"><i class="fa fa-download"></i>Windows (64-bit)</a></li>
<script>
var oReq = new XMLHttpRequest();
oReq.addEventListener('load', reqListener);
oReq.open('GET', 'https://api.github.com/repos/jean-emmanuel/open-stage-control/releases/latest')
oReq.send()
function text(id, str) {
var el = typeof id === 'string' ? document.getElementById(id) : id
el.textContent = str
}
var names = {
'x86_64.rpm': 'GNU/Linux RPM (64-bit)',
'amd64.deb': 'GNU/Linux Debian (64-bit)',
'linux-x64.zip': 'GNU/Linux (64-bit)',
'node.zip': 'Node.js',
'osx.zip': 'MacOS',
'win32-x64.zip': 'Windows (64-bit)'
}
function reqListener () {
var data = JSON.parse(this.responseText)
var date = new Date(data.published_at)
text('osc-version', data.tag_name + ' (' + date.toLocaleDateString() + ')')
var list = document.createElement('ul')
for (var i in data.assets) {
var item = document.createElement('li'),
link = document.createElement('a'),
name = data.assets[i].name
for (var k in names) {
if (name.includes(k)) {
name = names[k]
break
}
}
link.innerHTML = '<i class="fa fa-download"></i> ' + name + ' <span class="download-size">(' + (data.assets[i].size / 1024 / 1024).toFixed(0) + 'M)</span>'
link.href = data.assets[i].browser_download_url
item.appendChild(link)
list.appendChild(item)
}
var assets = document.getElementById('osc-assets')
assets.innerHTML = ''
assets.appendChild(list)
}
</script>
</ul>
<style>
@ -98,7 +52,7 @@ li i {
<div>
<a
href="https://openstagecontrol.ammd.net/docs/changelog/"
href="/docs/changelog/"
class="md-button md-button-small"
>
Read the Changelog

View file

@ -11,7 +11,7 @@
font-style: normal;
font-weight: 900;
font-display: block;
src: url("./fa-solid-900.woff2?__OSC_ASSET__=1") format("woff2"); }
src: url("./fa-solid-900.woff2") format("woff2"); }
.fa,
.fas,

View file

@ -2,14 +2,14 @@
font-family: 'Roboto';
font-style: normal;
font-weight: 700;
src: url('./Roboto-Bold.woff2?__OSC_ASSET__=1') format('woff2');
src: url('./Roboto-Bold.woff2') format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src: url('./Roboto-Medium.woff2?__OSC_ASSET__=1') format('woff2');
src: url('./Roboto-Medium.woff2') format('woff2');
}
@ -17,19 +17,19 @@
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url('./Roboto-Regular.woff2?__OSC_ASSET__=1') format('woff2');
src: url('./Roboto-Regular.woff2') format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 100;
src: url('./Roboto-Light.woff2?__OSC_ASSET__=1') format('woff2');
src: url('./Roboto-Light.woff2') format('woff2');
}
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-weight: 500;
src: url('./roboto-mono.woff?__OSC_ASSET__=1') format('woff');
src: url('./roboto-mono.woff') format('woff');
}

View file

@ -1,10 +1,11 @@
site_name: Open Stage Control
repo_name: open-stage-control
repo_url: https://github.com/jean-emmanuel/open-stage-control
repo_url: https://framagit.org/jean-emmanuel/open-stage-control
edit_uri: tree/master/resources/docs/
copyright: "Copyleft © Jean-Emmanuel Doucet @ <a href='http://ammd.net'>AMMD</a> (<a href='https://github.com/jean-emmanuel/open-stage-control/blob/master/LICENSE'>GNU/GPLv3</a>)"
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
theme:
name: 'material'
@ -63,9 +64,6 @@ nav:
- Remote control: docs/remote-control.md
- Credits: docs/credits.md
- Changelog: docs/changelog.md
- Bug Tracker:
- 'Bug Tracker': 'https://github.com/jean-emmanuel/open-stage-control/issues'
- Community:
- 'Community forums': 'https://openstagecontrol.discourse.group'
@ -96,3 +94,7 @@ markdown_extensions:
- pymdownx.tabbed:
alternate_style: true
- pymdownx.details
plugins:
- macros

View file

@ -15,8 +15,8 @@ module.exports = {
output: [
{
dir: 'app/client/',
chunkFileNames: `[name]-${package.version}.js`,
entryFileNames: `[name]-${package.version}.js`,
chunkFileNames: `[name].js`,
entryFileNames: `[name].js`,
format: 'es',
sourcemap: true,
sourcemapExcludeSources: true
@ -44,7 +44,7 @@ module.exports = {
{
targets: {
ios: '11',
chrome: '61'
chrome: '70'
},
useBuiltIns: 'usage',
corejs: 3,

0
scripts/dist_packages.sh Normal file → Executable file
View file

View file

@ -13,7 +13,7 @@ module.exports = {
output: [
{
dir: 'app/launcher/',
chunkFileNames: `[name]-${package.version}.js`,
chunkFileNames: `[name].js`,
format: 'commonjs',
sourcemap: true,
sourcemapExcludeSources: true,

View file

@ -12,7 +12,7 @@ packager({
name: appData.name,
platform: all ? ['linux', 'win32', 'darwin'] : process.env.PLATFORM,
arch: process.env.ARCH || 'x64',
electronVersion: process.env.ARCH === 'armv7l' ? '1.7.11' : require('../package.json').optionalDependencies.electron,
electronVersion: process.env.ELECTRON_VERSION || require('../package.json').optionalDependencies.electron,
overwrite: true,
out: path.resolve(__dirname + '/../dist'),
icon: path.resolve(__dirname + '/../resources/images/logo'),

View file

@ -16,7 +16,7 @@ module.exports = {
output: [
{
dir: 'app/server/',
chunkFileNames: `[name]-${package.version}.js`,
chunkFileNames: `[name].js`,
format: 'commonjs',
sourcemap: true,
sourcemapExcludeSources: true,

View file

@ -35,7 +35,7 @@ var handleClick = function(event) {
if (!targetWidget) return
while (targetWidget._not_editable && targetWidget.parent) {
while (targetWidget.meta.not_editable && targetWidget.parent) {
targetWidget = targetWidget.parent
}

View file

@ -14,16 +14,15 @@ var scrollState = {}
function updateWidget(widget, options={}) {
if (options.changedProps) {
if (options.editedProps) {
// alternate routine for small edits
var propNames = options.changedProps
var propNames = options.editedProps
if (
// if non dynamic props have changed, skip this and use rebuild routine
!propNames.some(n => !widget.isDynamicProp(n))
) {
var edited = widget.updateProps(options.changedProps, null, {fromEditor: true}) || widget
var edited = widget.updateProps(options.editedProps, null, {fromEditor: true}) || widget
editor.widgetTree.updateTree(editor.selectedWidgets)
@ -110,7 +109,8 @@ function updateWidget(widget, options={}) {
variables: widget.variables,
hash: widget.hash,
children: children,
index: index
index: index,
meta: widget.meta
})
newWidget.container.parentNode.replaceChild(newWidget.container, widget.container)

View file

@ -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} from '../widgets/index.mjs'
import {defaults, widgets} from '../widgets/index.mjs'
import UiSelectArea from '../ui/ui-selectarea.mjs'
import UiInspector from '../ui/ui-inspector.mjs'
import UiTree from '../ui/ui-tree.mjs'
@ -55,12 +55,12 @@ class Editor {
try {
newWidgets.push(updateWidget(w, {changedProps: [propName], preventSelect: this.selectedWidgets.length > 1}))
newWidgets.push(updateWidget(w, {editedProps: [propName], preventSelect: this.selectedWidgets.length > 1}))
} catch (e) {
w.props[propName] = previousValue
updateWidget(w, {changedProps: [propName], preventSelect: this.selectedWidgets.length > 1})
updateWidget(w, {editedProps: [propName], preventSelect: this.selectedWidgets.length > 1})
if (uiConsole.minimized) notifications.add({
class: 'error',
@ -282,7 +282,7 @@ class Editor {
if (
this.inspector.helpModalOpened ||
e && e.target && e.target.tagName.match(/INPUT|TEXTAREA|SELECT/)
e && e.target && e.target.tagName.match(/INPUT|TEXTAREA|SELECT|OSC-CONSOLE/)
) return
if (e) e.preventDefault()
@ -401,7 +401,7 @@ class Editor {
} else if (e.key === 'ArrowRight') {
if (curWidget.children[0] && !curWidget.children[0]._not_editable) {
if (curWidget.children[0] && !curWidget.children[0].meta.not_editable) {
toSelect = curWidget.children[0]
}
@ -905,6 +905,17 @@ 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
@ -916,7 +927,7 @@ class Editor {
var newWidgets = [],
area = this.widgetDragResize,
changedProps = []
editedProps = []
for (var i = 0; i < this.selectedWidgets.length; i++) {
@ -934,20 +945,20 @@ 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 / w.container.parentNode.offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
w.props.width = (100 * PXSCALE * newWidth / this.getWidgetParentContainer(w).offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
} else {
w.props.width = newWidth
}
changedProps.push('width')
editedProps.push('width')
if (this.selectedWidgets.length > 1) {
var newLeft = Math.max(nL, GRIDWIDTH) / PXSCALE
if (typeof w.props.left === 'string' && w.props.left.indexOf('%') > -1) {
w.props.left = (100 * PXSCALE * newLeft / w.container.parentNode.offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
w.props.left = (100 * PXSCALE * newLeft / this.getWidgetParentContainer(w).offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
} else if (w.props.left !== 'auto'){
w.props.left = newLeft
}
changedProps.push('left')
editedProps.push('left')
}
}
@ -955,24 +966,24 @@ 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 / w.container.parentNode.offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
w.props.height = (100 * PXSCALE * newHeight / this.getWidgetParentContainer(w).offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
} else {
w.props.height = newHeight
}
changedProps.push('height')
editedProps.push('height')
if (this.selectedWidgets.length > 1) {
var newTop = Math.max(nT, GRIDWIDTH) / PXSCALE
if (typeof w.props.top === 'string' && w.props.top.indexOf('%') > -1) {
w.props.top = (100 * PXSCALE * newTop / w.container.parentNode.offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
w.props.top = (100 * PXSCALE * newTop / this.getWidgetParentContainer(w).offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
} else if (w.props.top !== 'auto'){
w.props.top = newTop
}
changedProps.push('top')
editedProps.push('top')
}
}
if (w.props.width !== undefined || w.props.height !== undefined) newWidgets.push(updateWidget(w, {changedProps: changedProps, preventSelect: this.selectedWidgets.length > 1}))
if (w.props.width !== undefined || w.props.height !== undefined) newWidgets.push(updateWidget(w, {editedProps: editedProps, preventSelect: this.selectedWidgets.length > 1}))
}
@ -998,18 +1009,18 @@ 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 / w.container.parentNode.offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
w.props.top = (100 * PXSCALE * newTop / this.getWidgetParentContainer(w).offsetHeight).toFixed(2).replace(/\.?0+$/, '') + '%'
} else {
w.props.top = newTop
}
var newLeft = Math.max(parseInt(w.container.offsetLeft) / PXSCALE + deltaX, 0)
if (typeof w.props.left === 'string' && w.props.left.indexOf('%') > -1) {
w.props.left = (100 * PXSCALE * newLeft / w.container.parentNode.offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
w.props.left = (100 * PXSCALE * newLeft / this.getWidgetParentContainer(w).offsetWidth).toFixed(2).replace(/\.?0+$/, '') + '%'
} else {
w.props.left = newLeft
}
newWidgets.push(updateWidget(w, {changedProps: ['top', 'left'], preventSelect: this.selectedWidgets.length > 1}))
newWidgets.push(updateWidget(w, {editedProps: ['top', 'left'], preventSelect: this.selectedWidgets.length > 1}))
}
@ -1024,7 +1035,9 @@ class Editor {
pushHistory(indexes) {
this.unsavedSession = true
if (!ENV.noWarning) {
this.unsavedSession = true
}
if (this.historyState > -1) {
this.history.splice(0, this.historyState + 1)
@ -1097,7 +1110,7 @@ class Editor {
if (indexes) {
options = {...indexes}
} else {
options.changedProps = Object.keys(subpatch)
options.editedProps = Object.keys(subpatch)
options.reuseChildren = false
}

View file

@ -1,9 +1,10 @@
import {DOM} from '../globals.mjs'
var zoom
;(async()=>{
setTimeout(async()=>{
// use setTimeout to fix init order in safari...
zoom = (await import('../ui/zoom.mjs')).default
})()
})
// impot cssTransformCoords from './transform-coords.mjs'
@ -12,7 +13,7 @@ const Touch = window.Touch || class Touch {}
export function fix(e) {
var localZoom = zoom.editor.enabled ? zoom.localZoom : 1
var localZoom = zoom.editor && zoom.editor.enabled ? zoom.localZoom : 1
return {
@ -66,7 +67,7 @@ export function normalizeDragEvent(event, previousEvent) {
resetEventOffset(event, event.target)
} else if (event.isTouch && previousEvent) {
} else if (previousEvent) {
event.offsetX = previousEvent.offsetX + event.movementX
event.offsetY = previousEvent.offsetY + event.movementY

View file

@ -9,29 +9,17 @@ import * as backup from './backup.mjs'
uiLoading(locales('loading_server'))
function init() {
setTimeout(()=>{
ipc.init()
document.title = TITLE
ipc.send('open', {hotReload: backup.exists})
window.onunload = ()=>{
ipc.send('close')
}
backup.load()
ipc.init(()=>{
}, 100)
document.title = TITLE
}
ipc.send('open', {hotReload: backup.exists})
if (document.requestStorageAccess) {
document.requestStorageAccess().then(init, init)
} else {
init()
}
window.onunload = ()=>{
ipc.send('close')
}
backup.load()
})

View file

@ -4,13 +4,19 @@ import cache from '../managers/cache.mjs'
import {ENV} from '../globals.mjs'
var notifications, locales, callbacks
;(async()=>{
var loadDeps = (async()=>{
notifications = (await import('../ui/notifications.mjs')).default
locales = (await import('../locales/index.mjs')).default
callbacks = (await import('./callbacks.mjs')).default
// wait for other js chunks too since we'll connect to the server once this provise resolves
await import('../editor/context-menu.mjs')
await import('../remote-control.mjs')
await import('../ui/ui-keyboard.mjs')
})()
var uuid, localUuid = ENV.id || cache.get('osc.uuid', false)
var uuid, localUuid = ENV.id || cache.get('uuid', false)
if (localUuid) {
uuid = localUuid
} else {
@ -49,24 +55,30 @@ class Ipc extends EventEmitter {
document.cookie = 'client_id=' + uuid + ';samesite=strict'
try {
this.open()
} catch(e) {
console.warn('Could not open a WebSocket connection')
console.log(e)
}
}
init() {
init(callback) {
for (let i in callbacks) {
let callback = callbacks[i]
this.on(i, (data)=>{
callback(data)
})
}
loadDeps.then(()=>{
for (let i in callbacks) {
let callback = callbacks[i]
this.on(i, (data)=>{
callback(data)
})
}
try {
this.open()
} catch(e) {
console.warn('Could not open a WebSocket connection')
console.log(e)
}
callback()
})
}

View file

@ -4,17 +4,33 @@ class Cache {
set(key, value, persistent = true) {
var storage = persistent ? localStorage : sessionStorage
try {
var storage = persistent ? localStorage : sessionStorage
storage.setItem(keyPrefix + key, JSON.stringify(value))
} catch(e){
console.error(`Could not write to ${persistent ? 'localStorage' : 'sessionStorage'}: ${e}`)
console.debug(e)
}
storage.setItem(keyPrefix + key, JSON.stringify(value))
}
get(key, persistent = true) {
var storage = persistent ? localStorage : sessionStorage
try {
return JSON.parse(storage.getItem(keyPrefix + key))
var storage = persistent ? localStorage : sessionStorage
return JSON.parse(storage.getItem(keyPrefix + key))
} catch(e){
console.error(`Could not read from ${persistent ? 'localStorage' : 'sessionStorage'}: ${e}`)
console.debug(e)
return null
}
}

View file

@ -65,7 +65,7 @@ var StateManager = class StateManager {
if (widgets[j].setValue && !widgets[j].noValueState) {
widgets[j].setValue(value, {send:send, sync:true, fromState:true})
widgets[j].setValue(value, {send:send, sync:true})
}
@ -226,7 +226,7 @@ var StateManager = class StateManager {
if (this.valueStateQueue[id] !== undefined) {
for (let w of widgetManager.getWidgetById(id)) {
if (w.noValueState) continue
w.setValue(this.valueStateQueue[id], {sync: true, fromState:true, fromEdit: true})
w.setValue(this.valueStateQueue[id], {sync: true, script: false})
}
}
}
@ -235,7 +235,7 @@ var StateManager = class StateManager {
if (this.valueNewPropQueue[id] != this.valueOldPropQueue[id]) {
for (let w of widgetManager.getWidgetById(id)) {
if (w.noValueState) continue
w.setValue(w.getProp('value'), {sync: true, fromState:true})
w.setValue(w.getProp('value'), {sync: true})
}
}
}

View file

@ -38,6 +38,8 @@ 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++
@ -117,6 +119,8 @@ 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]] = []
@ -180,7 +184,9 @@ 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))
linkId = linkId.map(x=>String(x).replace(/^<<\s*/, '')).filter(x=>x.indexOf('>>') < 0)
// scopable; prefix linkId with the closest (most restrictive) scope
if (widget.scopes.length) linkId = linkId.map(x => x + widget.scopes[0])
for (var i in linkId) {
if (linkId[i] && this.linkIdRoute[linkId[i]] && this.linkIdRoute[linkId[i]].indexOf(hash) != -1) this.linkIdRoute[linkId[i]].splice(this.linkIdRoute[linkId[i]].indexOf(hash), 1)
}
@ -260,7 +266,22 @@ class WidgetManager extends EventEmitter {
}
getWidgetById(id) {
getWidgetById(id, scope) {
/*
scopable: return matching widgets only for the closest scope with results
*/
if (scope && scope.length) {
if (!Array.isArray(scope)) scope = [scope]
for (var prefix of scope) {
var prefixedId = Array.isArray(id) ? id.map(i=>prefix + i) : prefix + id
var widgets = this.getWidgetBy(prefixedId, this.idRoute)
if (widgets.length) return widgets
}
return []
}
return this.getWidgetBy(id, this.idRoute)

View file

@ -45,7 +45,8 @@ var Parser = class Parser {
index,
hash,
locals,
variables
variables,
meta
} = options
var props = data
@ -89,7 +90,8 @@ var Parser = class Parser {
children,
hash,
locals,
variables
variables,
meta
})
widgetManager.addWidget(widget)

View file

@ -31,7 +31,7 @@ var callbacks = {
updateWidget(widget, {
reuseChildren: !(newdata.widgets || newdata.tabs),
changedProps: Object.keys(newdata)
editedProps: Object.keys(newdata)
})
}
@ -61,7 +61,7 @@ var callbacks = {
updateWidget(widget, {
reuseChildren: !(newdata.widgets || newdata.tabs),
changedProps: Object.keys(newdata)
editedProps: Object.keys(newdata)
})
}

View file

@ -1,16 +1,12 @@
import StackTrace from 'stacktrace-js'
import ipc from './ipc/index.mjs'
var uiConsole
;(async()=>{
uiConsole = (await import('./ui/ui-console.mjs')).default
})()
import uiConsole from './ui/ui-console.mjs'
window.onerror = function(msg,url,row,col, error) {
StackTrace.fromError(error).then((stackframes)=>{
var stringifiedStack = stackframes.join('\n')
var stringifiedStack = ' ' + stackframes.join('\n ')
uiConsole.log('error', `${msg}\n${stringifiedStack}`)
ipc.send('errorLog', `(ERROR, CLIENT) ${msg}\n${stringifiedStack}`)

View file

@ -5,10 +5,10 @@ import './notifications.mjs'
import './ui-workspace.mjs'
import './main-menu.mjs'
import './ui-console.mjs'
import {updateMobileThemeColor} from './utils.mjs'
import {updateMobileThemeColor, device} from './utils.mjs'
updateMobileThemeColor()
if (!navigator.userAgent.match(/Android|iPhone|iPad|iPod/i)) {
if (!device.is('mobile') && !device.is('tablet')) {
import('./ui-keyboard.mjs')
}

View file

@ -1,18 +1,15 @@
import {DOM} from '../globals.mjs'
import {device, os} from './utils.mjs'
var iOS = (device.is('mobile') || device.is('tablet')) && os.is('ios')
// Prevent iOS Pull-To-Refresh
var iOS13 = (
navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1 // safari iPad
|| navigator.userAgent.match(/iPhone OS (1[3-9])/) // iPhone
|| navigator.userAgent.match(/i(Pad|Phone); CPU OS 1[3-9]/) // chrome iPad
) ? 13 : 0,
iOS = iOS13 || navigator.platform.match(/iPhone|iPod|iPad/)
if (iOS && !iOS13) {
if (iOS && parseInt(os.version.split('.')[0]) < 13) {
// prevent overscroll
// breaks scrolling on iOS13 (besides it doesn't seem to be needed)
// breaks scrolling on iOS <= 13 (besides it doesn't seem to be needed)
var supportsPassiveOption = false
try {
@ -59,6 +56,4 @@ if (iOS) {
}
}
if (iOS13) document.body.classList.add('iOS13')
export default iOS

View file

@ -10,6 +10,8 @@ import stateManager from '../managers/state.mjs'
import {leftUiSidePanel, rightUiSidePanel} from '../ui/index.mjs'
import uiConsole from '../ui/ui-console.mjs'
import {READ_ONLY, KIOSK, VIRTUAL_KEYBOARD, setVIRTUAL_KEYBOARD} from '../globals.mjs'
import {device} from './utils.mjs'
var recentSessions = [{label: locales('file_open_recent_wait'), class: 'disabled'}]
var menuEntries = [
@ -21,6 +23,7 @@ var menuEntries = [
{
label: locales('session_new'),
action: sessionManager.create.bind(sessionManager),
id: 'session-new'
},
{
separator: true
@ -29,6 +32,7 @@ var menuEntries = [
label: locales('file_open'),
action: sessionManager.browse.bind(sessionManager),
shortcut: 'mod + o',
id: 'session-open'
},
{
label: locales('file_open_recent'),
@ -42,18 +46,21 @@ var menuEntries = [
label: locales('file_save'),
action: sessionManager.save.bind(sessionManager),
shortcut: 'mod + s',
class: ()=>{return sessionManager.session === null ? 'disabled' :''}
class: ()=>{return sessionManager.session === null ? 'disabled' :''},
id: 'session-save'
},
{
label: locales('file_save_as'),
action: sessionManager.saveAs.bind(sessionManager),
shortcut: 'mod + shift + s',
class: ()=>{return sessionManager.session === null ? 'disabled' :''}
class: ()=>{return sessionManager.session === null ? 'disabled' :''},
id: 'session-save-as'
},
{
label: locales('fragment_mode'),
class: ()=>{return 'toggle ' + (sessionManager.saveMode === 'fragment' ? 'on' : 'off')},
action: ()=>{sessionManager.setSaveMode(sessionManager.saveMode === 'session' ? 'fragment' : 'session')}
action: ()=>{sessionManager.setSaveMode(sessionManager.saveMode === 'session' ? 'fragment' : 'session')},
id: 'session-fragment'
},
{
separator: true
@ -62,7 +69,8 @@ var menuEntries = [
label: locales('file_backup'),
action: sessionManager.saveBackup.bind(sessionManager),
shortcut: 'mod + b',
class: ()=>{return sessionManager.session === null || !sessionManager.sessionPath ? 'disabled' :''}
class: ()=>{return sessionManager.session === null || !sessionManager.sessionPath ? 'disabled' :''},
id: 'session-backup'
},
{
separator: true
@ -70,11 +78,13 @@ var menuEntries = [
{
label: locales('file_import'),
action: sessionManager.import.bind(sessionManager),
id: 'session-import'
},
{
label: locales('file_export'),
action: sessionManager.export.bind(sessionManager),
class: ()=>{return sessionManager.session === null ? 'disabled' :''}
class: ()=>{return sessionManager.session === null ? 'disabled' :''},
id: 'session-export'
},
]
@ -86,12 +96,14 @@ var menuEntries = [
action: [
{
label: locales('state_store'),
action: stateManager.quickSave.bind(stateManager)
action: stateManager.quickSave.bind(stateManager),
id: 'state-store'
},
{
label: locales('state_recall'),
class: ()=>{return stateManager.quickState === null ? 'disabled' : ''},
action: stateManager.quickLoad.bind(stateManager)
action: stateManager.quickLoad.bind(stateManager),
id: 'state-recall'
},
{
label: locales('state_send'),
@ -101,7 +113,8 @@ var menuEntries = [
icon: 'sliders-h',
message: locales('state_sendsuccess')
})
}
},
id: 'state-send'
},
{
separator: true
@ -109,14 +122,17 @@ var menuEntries = [
{
label: locales('file_open'),
action: stateManager.browse.bind(stateManager),
id: 'state-open'
},
{
label: locales('file_save'),
action: stateManager.save.bind(stateManager),
id: 'state-save'
},
{
label: locales('file_save_as'),
action: stateManager.saveAs.bind(stateManager),
id: 'state-save-as'
},
{
separator: true
@ -124,10 +140,12 @@ var menuEntries = [
{
label: locales('file_import'),
action: stateManager.import.bind(stateManager),
id: 'state-import'
},
{
label: locales('file_export'),
action: stateManager.export.bind(stateManager),
id: 'state-export'
},
]
},
@ -143,7 +161,8 @@ var menuEntries = [
if (editor.enabled) editor.disable()
else editor.enable()
},
shortcut: 'mod + e'
shortcut: 'mod + e',
id: 'editor-enabled'
},
{
separator: true
@ -152,22 +171,22 @@ var menuEntries = [
label: locales('editor_grid'),
class: ()=>{return 'toggle ' + (editor.grid ? 'on' : 'off')},
action: editor.toggleGrid.bind(editor),
shortcut: 'mod + g'
shortcut: 'mod + g',
id: 'editor-grid'
},
{
label: locales('editor_tree'),
class: ()=>{return 'toggle ' + (leftUiSidePanel.minimized ? 'off' : 'on')},
action: ()=>{return leftUiSidePanel.minimized ? leftUiSidePanel.restore() : leftUiSidePanel.minimize()},
shortcut: 'mod + t'
shortcut: 'mod + t',
id: 'editor-tree'
},
{
label: locales('editor_inspector'),
class: ()=>{return 'toggle ' + (rightUiSidePanel.minimized ? 'off' : 'on')},
action: ()=>{return rightUiSidePanel.minimized ? rightUiSidePanel.restore() : rightUiSidePanel.minimize()},
shortcut: 'mod + i'
shortcut: 'mod + i',
id: 'editor-inspector'
},
{
separator: true
@ -175,7 +194,8 @@ var menuEntries = [
{
label: locales('editor_percents'),
class: ()=>{return 'toggle ' + (editor.usePercents ? 'on' : 'off')},
action: ()=>{editor.usePercents = !editor.usePercents}
action: ()=>{editor.usePercents = !editor.usePercents},
id: 'editor-percents'
}
]
},
@ -194,7 +214,8 @@ var menuEntries = [
uiConsole.minimize()
}
},
shortcut: 'mod + k'
shortcut: 'mod + k',
id: 'console-enabled'
},
{
separator: true
@ -202,7 +223,9 @@ var menuEntries = [
{
label: locales('console_clear'),
action: uiConsole.clear.bind(uiConsole),
shortcut: 'mod + l'
shortcut: 'mod + l',
id: 'console-clear'
},
]
},
@ -216,19 +239,21 @@ var menuEntries = [
action: ()=>{
if (fullscreen.isEnabled) fullscreen.toggle()
},
shortcut: 'f11'
shortcut: 'f11',
id: 'fullscreen'
},
{
label: locales('notifications'),
class: ()=>{return 'toggle ' + (notifications.visible ? 'on' : 'off')},
action: ()=>{
notifications.setVisibility(!notifications.visible)
}
},
id: 'notifications'
}
]
if (navigator.userAgent.match(/Android|iPhone|iPad|iPod/i)) {
if (device.is('mobile') || device.is('tablet')) {
var noSleep = new NoSleep(),
@ -244,6 +269,9 @@ if (navigator.userAgent.match(/Android|iPhone|iPad|iPod/i)) {
if ('wakeLock' in navigator) {
navigator.wakeLock.request('screen').then((l)=>{
wakeLock = l
wakeLock.addEventListener('release', ()=>{
noSleepState = false
})
}).catch((err)=>{
console.error(`Could not acquire wake lock:\n${err.name}, ${err.message}`)
wakeLock = null
@ -259,7 +287,8 @@ if (navigator.userAgent.match(/Android|iPhone|iPad|iPod/i)) {
noSleep.disable()
}
}
}
},
id: 'prevent-sleep'
})
} else {
@ -269,7 +298,8 @@ if (navigator.userAgent.match(/Android|iPhone|iPad|iPod/i)) {
class: ()=>{return 'toggle ' + (VIRTUAL_KEYBOARD ? 'on' : 'off')},
action: ()=>{
setVIRTUAL_KEYBOARD(!VIRTUAL_KEYBOARD)
}
},
id: 'virtual-keyboard'
})
}

View file

@ -1,7 +1,9 @@
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
@ -21,7 +23,7 @@ class Toast {
var toast = html`
<div class="toast ${data.class || ''}" data-id="${data.id}">
<i class="fa fa-fw fa-${data.icon || (data.class === 'error' ? 'exclamation' : 'bell')}"></i>
${raw(icon(data.icon || (data.class === 'error' ? 'exclamation' : 'bell')))}
<div class="content"></div>
</div>
`

View file

@ -20,7 +20,7 @@ var scriptGlobals = scriptVm.globals,
const ace = window.ace
ace.config.set('basePath', '/client/ace/')
ace.config.set('basePath', '/__APP_DIR__/client/ace/')
function setCommandEnabled(editor, name, enabled) {
var command = editor.commands.byName[name]
@ -133,7 +133,6 @@ class CodeEditor {
var editor = this.editor,
input = this.input
editor.fullscreen = false
input.style.display = 'none'
input._ace_input = editor.textarea
input.tabIndex = -1
@ -141,11 +140,8 @@ class CodeEditor {
editor.setValue(input.value)
editor.textarea.osc_input = input
editor.textarea.tabIndex = 0
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)
}
this.field.classList.remove('dirty')
editor.removeAllListeners('focus')
this.editor.on('focus', (e)=>{
@ -159,12 +155,8 @@ class CodeEditor {
this.editor.on('change', (e)=>{
this.input.value = this.editor.getValue()
this.editor.dirty = true
})
setTimeout(()=>{
var pos = this.editor.getCursorPosition()
if (pos.row === undefined || pos.column === undefined) {
this.editor.gotoLine(0)
if (this.editor.fullscreen) {
this.field.classList.add('dirty')
}
})
@ -172,16 +164,32 @@ class CodeEditor {
setCommandEnabled(this.editor, 'indent', false)
setCommandEnabled(this.editor, 'outdent', 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)
setTimeout(()=>{
if (this.pos) {
this.editor.moveCursorTo(this.pos.row, this.pos.column)
} else {
var pos = this.editor.getCursorPosition()
if (pos.row === undefined || pos.column === undefined) {
this.editor.gotoLine(0)
}
}
this.typing = 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.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})
@ -207,6 +215,7 @@ class CodeEditor {
if (this.language === 'javascript') {
let globals = {}
if (this.name === 'onKeyboard') {
globals = {type: true, key: true, code: true, ctrl: true, shift: true, alt: true, meta: true}
} else if (this.name === 'onCreate') {
@ -223,6 +232,9 @@ class CodeEditor {
globals = {value: true, height: true, width: true, cssVars: true}
}
for (var k in scriptGlobals) {
globals[k] = true
}
globals.locals = true
globals.console = true
@ -230,7 +242,7 @@ class CodeEditor {
globals.this = false
if (this.syntaxChecker !== false) editor.getSession().$worker.send('changeOptions', [{
globals: {...scriptGlobals, ...globals}
globals: globals
}])
}
@ -238,9 +250,18 @@ class CodeEditor {
field.appendChild(this.helpBtn)
field.appendChild(this.fsBtn)
editor.getSession().getUndoManager().reset()
editor.resize()
editor.selection.setRange({start:0,end:0})
if (this.hash !== widget.hash) {
// preserve undo history if widget is the same
editor.getSession().getUndoManager().reset()
this.hash = widget.hash
this.pos = null
} else if (editor.fullscreen) {
this.fullscreen()
}
editor.resize()
}

View file

@ -22,8 +22,7 @@ class ColorPicker extends UiWidget {
alphaStroke: 0,
snap: true,
alpha: true
}, parent: this})
this.rgb.container.classList.add('not-editable')
}, parent: this, meta: {not_editable: true}})
this.container = html`
<div class="color-picker">

View file

@ -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></osc-console>`)
this.messages = this.content.appendChild(html`<osc-console tabIndex="-1"></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,14 +59,13 @@ class UiConsole extends UiSidePanel {
console._clear()
}
this.widget = new Widget({props: {id: 'CONSOLE'}, parent: widgetManager})
this.widget = new Widget({props: {id: 'CONSOLE'}, parent: widgetManager, meta: {not_editable: true}})
this.script = new Script({
widget: this.widget,
property: '',
code: 'var navigator; return eval(input_code)',
context: {input_code: ''}
})
this.widget._not_editable = true
this.widget.hash = 'CONSOLE'
this.input.addEventListener('keydown', (event)=>{
@ -106,6 +105,12 @@ class UiConsole extends UiSidePanel {
this.inputSize()
})
this.messages.addEventListener('keydown', (event)=>{
if (event.key == 'Escape') {
this.messages.blur()
}
})
if (!READ_ONLY) this.enable()
}

View file

@ -9,7 +9,7 @@ import UiModal from './ui-modal.mjs'
import {DOM} from '../globals.mjs'
export default function UiFilebrowser(options, callback) {
export default function UiFilebrowser(options, callback, closeCallback) {
var save = options.save,
saveInputFocus = undefined,
@ -143,11 +143,9 @@ export default function UiFilebrowser(options, callback) {
document.addEventListener('keydown', keyDownHandler)
ipc.on('listDir', (data)=>{
path = data.path
root = data.root
ariane.textContent = path.replace(root, '/')
ariane.textContent = root ? path.replace(root, '/') : path
files = data.files.filter(x=>x.folder || x.name.match(extRe))
@ -201,6 +199,7 @@ export default function UiFilebrowser(options, callback) {
document.removeEventListener('keydown', keyDownHandler)
document.removeEventListener('keyup', keyUpHandler)
keyboardJS.setContext(previousKbContext)
if (closeCallback) closeCallback(path)
})
browser.appendChild(ariane)

View file

@ -12,7 +12,9 @@ export default function uiFileUpload(types, ok, error) {
if (SINGLETON) CONTAINER.removeChild(SINGLETON)
SINGLETON = html`<input type="file" accept="${types}" style="position:absolute;opacity:0;pointer-events:none;"/>`
SINGLETON = html`<input type="file" style="position:absolute;opacity:0;pointer-events:none;"/>`
if (types) SINGLETON.accept = types
CONTAINER.appendChild(SINGLETON)
@ -24,9 +26,9 @@ export default function uiFileUpload(types, ok, error) {
uiLoading(locales('loading_upload'))
reader.onerror = reader.onabort = function() {
reader.onerror = reader.onabort = function(e) {
uiLoading(false)
error()
error(e)
}
reader.onload = function(e) {

View file

@ -228,9 +228,9 @@ class UiTree extends UiWidget {
treeRect = this.wrapper.getBoundingClientRect()
if (nodeRect.top < treeRect.top) {
node.scrollIntoView({block: 'start'});
node.scrollIntoView({block: 'start'})
} else if (nodeRect.bottom > treeRect.bottom) {
node.scrollIntoView({block: 'nearest'});
node.scrollIntoView({block: 'nearest'})
}
this.wrapper.scrollLeft = (node.depth - 1) * 20
}

View file

@ -1,7 +1,12 @@
import chroma from 'chroma-js'
import fastdom from 'fastdom'
import {UAParser} from 'ua-parser-js'
import {DOM} from '../globals.mjs'
var {device, os} = UAParser().withFeatureCheck()
export {device, os}
export function icon(i) {
var iclass = i.split('.').join(' fa-')
return `<i class="fa fa-fw fa-${iclass}"></i>`

View file

@ -45,12 +45,16 @@ 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).',
'From a script property, feedback messages can be simulated with:',
'`set("widget_id", value, {external: true})`'
]},
},
scripting: {
onTouch: {type: 'script', value: '', editor:'javascript', help: ['Script executed when the panel is touched and released, and when the pointer moves when the widget is touched. See <a href="https://openstagecontrol.ammd.net/docs/widgets/canvas/">documentation</a>.',]},
}
})
@ -84,9 +88,14 @@ class Button extends Widget {
}, {element: this.widget})
}
if (this.getProp('onTouch')) {
this.on('draginit',(e)=>this.onTouch(e, 'start'), {element: this.container})
}
var mode = this.getProp('mode'),
tap = mode === 'momentary' || mode === 'tap',
push = mode === 'push' || tap
push = mode === 'push' || tap,
click = this.getProp('click') && mode !== 'push'
if (push) {
@ -104,11 +113,11 @@ class Button extends Widget {
if (tap) this.container.classList.add('active')
}, {element: this.container})
}, {element: this.container, click: click})
} else {
this.on('draginit',(e)=>{
this.on(click ? 'click': 'draginit',(e)=>{
if (this.touchActive) return
@ -160,11 +169,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})
}, {element: this.container, click: click})
} else {
this.on('draginit',(e)=>{
this.on(click ? 'click': 'draginit',(e)=>{
if (this.touchActive) return
@ -210,7 +219,8 @@ class Button extends Widget {
ignoreDefaults: true,
},
parentNode: this.widget,
parent: this
parent: this,
meta: {...this.meta}
})
this.decoupledValue.on('value-changed', (e)=>{
this.container.classList.toggle('on', this.decoupledValue.value)
@ -219,8 +229,25 @@ 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})
}
}
onTouch(e, name) {
var event = {...e}
event.type = name
this.scripts.onTouch.run({
value: this.value,
event: event
}, {sync: true, send: true})
}
get value() {

View file

@ -84,8 +84,6 @@ class Dropdown extends MenuBase {
`)
}
this.setValue(this.value)
}
setValue(v,options={}) {
@ -121,7 +119,6 @@ class Dropdown extends MenuBase {
case 'values':
this.parseValues()
this.setValue(this.value)
return
case 'label':
this.setLabel()

View file

@ -19,6 +19,7 @@ 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'},
@ -44,19 +45,20 @@ 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('fast-click', (e)=>{
this.on(this.getProp('click') ? 'click' : 'fast-click', (e)=>{
if (e.capturedByEditor === true) return
uiFilebrowser({
extension: ext.replace(/^\.?(.*)$/, '$1'),
directory: this.getProp('directory') === 'auto' ? undefined : this.getProp('directory'),
directory: this.getProp('directory') === 'auto' ? this.lastDir : this.getProp('directory'),
loadDir: this.getProp('allowDir'),
save: this.getProp('mode') === 'save'
}, (path, root)=>{
@ -70,6 +72,8 @@ export default class File extends Widget {
send: true
})
}, (path)=>{
this.lastDir = path
})
}, {element: this.widget})

View file

@ -126,11 +126,9 @@ class Input extends Canvas {
}
if (!this.getProp('numeric')) {
setTimeout(()=>{
this.input.setSelectionRange(0, this.input.value.length)
})
}
setTimeout(()=>{
this.input.select()
})
}

View file

@ -96,7 +96,7 @@ class Menu extends MenuBase {
doubleTap(this, (e)=>{
if (this.opened) return
this.open(e)
}, {element: this.widget})
}, {element: this.widget, click: this.mode.includes('toggle')})
this.on('draginit',(e)=>{
@ -113,7 +113,7 @@ class Menu extends MenuBase {
} else {
this.on('draginit',(e)=>{
this.on(this.mode.includes('toggle') ? 'click' : 'draginit',(e)=>{
if (this.opened && this.mode.includes('toggle')) {

View file

@ -108,6 +108,8 @@ class Switch extends MenuBase {
super.parseValues()
this.widget.innerHTML = ''
for (var i = 0; i < this.values.length; i++) {
this.widget.appendChild(html`
@ -116,6 +118,8 @@ class Switch extends MenuBase {
}
this.setValue(this.value)
}
setValue(v, options={}) {
@ -135,6 +139,19 @@ class Switch extends MenuBase {
}
onPropChanged(propName, options, oldPropValue) {
var ret = super.onPropChanged(...arguments)
switch (propName) {
case 'values':
this.parseValues()
}
return ret
}
setCssVariables() {
super.setCssVariables()
@ -144,6 +161,10 @@ class Switch extends MenuBase {
}
}
Switch.dynamicProps = Switch.prototype.constructor.dynamicProps.concat(
'values'
)
Switch.cssVariables = Switch.prototype.constructor.cssVariables.concat(
{js: 'colorTextOn', css: '--color-text-on'}
)

View file

@ -16,13 +16,14 @@ import {PXSCALE, JSON5} from '../../globals.mjs'
var updateWidget = ()=>{},
uiConsole, widgetTree, widgetDragResize, sessionManager
;(async()=>{
setTimeout(async()=>{
// use setTimeout to fix init order in safari...
updateWidget = (await import('../../editor/data-workers.mjs')).updateWidget
uiConsole = (await import('../../ui/ui-console.mjs')).default
widgetTree = (await import('../../editor/index.mjs')).default.widgetTree
widgetDragResize = (await import('../../editor/index.mjs')).default.widgetDragResize
sessionManager = (await import('../../managers/session/index.mjs')).default
})()
})
var vm = new Vm()
@ -37,10 +38,6 @@ var OSCProps = [
'bypass'
]
setTimeout(()=>{
})
class Widget extends EventEmitter {
static description() {
@ -192,9 +189,11 @@ 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
@ -244,7 +243,7 @@ class Widget extends EventEmitter {
context: {value: 0, id: '', touch: undefined}
})
this.on('value-changed', (e)=>{
if (e.widget === this && this.mounted && !e.options.fromEdit && e.options.script !== false) {
if (e.widget === this && this.mounted && e.options.script !== false) {
this.scripts.onValue.run({
value: e.options.widget ? e.options.widget.value : this.value,
id: e.options.id || e.id
@ -393,6 +392,24 @@ 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
@ -419,6 +436,25 @@ 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 = {}
@ -523,10 +559,29 @@ 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)
}
@ -570,7 +625,7 @@ class Widget extends EventEmitter {
}
resolveProp(propName, propValue, storeLinks=true, originalWidget, originalPropName, context) {
resolveProp(propName, propValue, storeLinks=true, originalWidget, originalPropName, context, recursive) {
propValue = propValue !== undefined ? propValue : deepCopy(this.props[propName])
originalWidget = originalWidget || this
@ -617,7 +672,7 @@ class Widget extends EventEmitter {
var widgets = id == 'parent' && this.parent ?
[this.parent] : id == 'this' ? [this] :
widgetManager.getWidgetById(id)
widgetManager.getWidgetById(id, this.scopes)
if (!widgets.length) {
var parent = this.parent
@ -631,7 +686,7 @@ class Widget extends EventEmitter {
}
// ignore clone wrapper in @parent stack (https://github.com/jean-emmanuel/open-stage-control/issues/379)
// ignore clone wrapper in @parent stack (https://framagit.org/jean-emmanuel/open-stage-control/-/work_items/379)
if (widgets[0] === this.parent && this.parent !== widgetManager && this.parent.getProp('type') === 'clone') widgets = [this.parent.parent]
if (storeLinks) {
@ -889,7 +944,14 @@ class Widget extends EventEmitter {
propValue = propValue.replace(new RegExp(k, 'g'), v)
}
if (isJSON(propValue) && (propName !== 'label' || propValue === 'false')) {
if (
// json heuristic
isJSON(propValue) &&
// allow "false" string in label
(propName !== 'label' || propValue === 'false') &&
// don't coerce booleans and numbers as strings in objects
(!recursive || (isNaN(propValue) && propValue != 'true' && propValue != 'false'))
) {
try {
propValue = JSON.parse(propValue)
} catch (err) {}
@ -897,12 +959,30 @@ 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)
propValue[k] = this.resolveProp(propName, propValue[k], storeLinks, originalWidget, originalPropName, context, true)
}
}
return propValue
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
}
@ -936,8 +1016,10 @@ class Widget extends EventEmitter {
let propValue = this.resolveProp(propName, undefined, false),
oldPropValue = this.getProp(propName)
if (!deepEqual(oldPropValue, propValue)) {
if (
!deepEqual(oldPropValue, propValue) ||
(options && options.fromEditor && propName == 'value' && !this.areEquivalentValueProps(propValue, oldPropValue))
) {
if (!this.isDynamicProp(propName)) {
if (this.constructor._defaults[propName] === undefined) {
@ -968,7 +1050,6 @@ class Widget extends EventEmitter {
}
}
}
@ -1003,7 +1084,7 @@ class Widget extends EventEmitter {
// emit prop-changed event if not already
// to make sure an advanced syntax changes don't go unnoticed by clone
var unNotified = propNames.filter(n => !changedProps.includes(n))
widgetManager.trigger('prop-changed-maybe', {
widgetManager.trigger('prop-src-changed', {
id: this.getProp('id'),
props: unNotified,
widget: this,
@ -1131,7 +1212,7 @@ class Widget extends EventEmitter {
id = this.getProp('id') || this.props.id,
widget = this // used for edit link in console
while (widget._not_editable && widget.parent !== widgetManager) {
while (widget.meta.not_editable && widget.parent !== widgetManager) {
// ignore non editable
widget = widget.parent
}
@ -1170,6 +1251,7 @@ 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)
}

View file

@ -23,6 +23,11 @@ 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,
@ -47,8 +52,11 @@ 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')
@ -62,34 +70,18 @@ class Clone extends Container() {
parent = parent.parent
}
this.bindTarget(this.getCloneTarget())
if (this.cloneTarget) this.createClone(true)
this.getCloneTarget()
// global listener to catch cloneTarget's creation if no target is locked
widgetManager.on('widget-created', (e)=>{
if (this.cloneTarget) return
// if in a non-scoped context we don't watch for a closer target once we have one
if (!this.scopes.length && this.cloneTarget) return
var {id, widget} = e
if (id === this.getProp('widgetId') && this.isValidCloneTarget(widget)) {
if (String(id).includes(this.getProp('widgetId')) && this.isValidCloneTarget(widget)) {
var clone = this.children[0]
this.unbindTarget()
if (!clone) {
this.updateContainer(false)
this.bindTarget(widget)
this.createClone()
} else {
this.bindTarget(widget)
this.updateClone()
}
this.getCloneTarget()
}
@ -114,16 +106,7 @@ class Clone extends Container() {
widgetManager.on('prop-changed', onPropChanged, {context: this})
// see common/widget.js @ updateProps()
widgetManager.on('prop-changed-maybe', onPropChanged, {context: this})
this.on('widget-created', (e)=>{
if (e.widget !== this) {
e.widget.container.classList.add('not-editable')
e.widget._not_editable = true
}
})
widgetManager.on('prop-src-changed', onPropChanged, {context: this})
}
@ -132,32 +115,53 @@ 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 widgets = widgetManager.getWidgetById(this.getProp('widgetId'))
.filter(el=>this.isValidCloneTarget(el))
var scopes = this.scopes.length ? this.scopes : [''],
target = null,
rank = 0
if (widgets.length === 0) return null
if (widgets.length === 1) {
return widgets[0]
}
for (var scope of scopes) {
var widgets = widgetManager.getWidgetById(this.getProp('widgetId'), scope)
.filter(w=>this.isValidCloneTarget(w))
target = 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
if (!target) {
rank++
continue
}
}
return target
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
}
}
@ -180,7 +184,12 @@ class Clone extends Container() {
parser.parse({
data: data,
parentNode: this.widget,
parent: this
parent: this,
meta: {
not_editable: true,
clone: true,
scopable: true
}
})
this.updateContainer(!init)
@ -196,14 +205,16 @@ class Clone extends Container() {
this.cloneTarget.off(undefined, undefined, this)
this.cloneTarget = null
this.targetRank = null
}
bindTarget(target) {
bindTarget(target, rank) {
if (!target) return
this.cloneTarget = target
this.targetRank = rank
// listen for cloneTarget's deletion
// if it is just edited, its recreation will be caught by the global 'widget-created' event handler
@ -216,18 +227,14 @@ class Clone extends Container() {
// listen for cloneTarget's content updates
this.cloneTarget.on('widget-created', (e)=>{
var {widget} = e,
parent = widget.parent
var {widget} = e
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
// 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()
}
this.updateClone()
}, {context: this})
}
@ -287,10 +294,6 @@ 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) {
@ -312,10 +315,7 @@ class Clone extends Container() {
switch (propName) {
case 'widgetId':
this.unbindTarget()
this.updateContainer(false)
this.bindTarget(this.getCloneTarget())
if (this.cloneTarget) this.createClone()
this.getCloneTarget()
return
case 'props':
if (this.children[0]) this.updateClone()

View file

@ -29,6 +29,11 @@ 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,
@ -51,20 +56,13 @@ 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')) {
@ -123,7 +121,12 @@ class Fragment extends Container() {
parser.parse({
data: data,
parentNode: this.widget,
parent: this
parent: this,
meta: {
not_editable: true,
fragment: true,
scopable: true
}
})
this.updateContainer(!init)
@ -146,10 +149,6 @@ 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) {

View file

@ -135,12 +135,11 @@ class Keyboard extends Panel {
var key = parser.parse({
data: data,
parentNode: this.widget,
parent: this
parent: this,
meta: {not_editable: true}
})
key._index = i - start
key.container.classList.add('not-editable')
key._not_editable = true
key.container.classList.add('key')
if (pattern[i % 12] == 'w') {

View file

@ -82,12 +82,11 @@ class Matrix extends Panel {
var widget = parser.parse({
data: data,
parentNode: this.widget,
parent: this
parent: this,
meta: {not_editable: true}
})
widget._index = i
widget.container.classList.add('not-editable')
widget._not_editable = true
this.value[i] = widget.getValue()
@ -161,12 +160,11 @@ class Matrix extends Panel {
var widget = parser.parse({
data: data,
parentNode: this.widget,
parent: this
parent: this,
meta: {not_editable: true}
})
widget._index = i
widget.container.classList.add('not-editable')
widget._not_editable = true
}
@ -209,9 +207,6 @@ 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
}

View file

@ -18,7 +18,8 @@ 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'},
doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the modal require a double tap to open instead of a single tap (allows scrolling when touching the modal button)'},
click: {type: 'boolean', value: false, help: 'Set to `true` to make the modal open/close upon click event instead of tap (allows scrolling when touching the modal button)'},
},
geometry: {
_separator_modal_geometry: 'Modal geometry',
@ -93,28 +94,21 @@ class Modal extends Panel {
var closer = DOM.get(this.popup, '.closer')[0]
this.on('fast-click',(e)=>{
this.on(this.getProp('click') ? 'click' : 'draginit',(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})
} 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})
}, {element: this.toggle, click: this.getProp('click')})
}
this.escapeKeyHandler = ((e)=>{
if (e.key == 'Escape') this.setValue(0, {sync:true, send:true})
}).bind(this)

View file

@ -156,7 +156,8 @@ class Panel extends Container() {
parentNode: this.widget,
parent: this,
tab: true,
index: i
index: i,
meta: {...this.meta}
})
}
}
@ -198,7 +199,8 @@ class Panel extends Container() {
data: this.getProp('widgets')[i],
parentNode: this.widget,
parent: this,
index: i
index: i,
meta: {...this.meta}
})
}
}

View file

@ -178,10 +178,9 @@ class PatchBay extends Container(Canvas) {
label: k
},
parentNode: DOM.get(this.widget, '.inputs')[0],
parent: this
parent: this,
meta: {not_editable: true}
})
w.container.classList.add('not-editable')
w._not_editable = true
this.inputsWidgets.push(w)
this.inputNodes.push(w.container)
this.value[k] = []
@ -200,31 +199,42 @@ class PatchBay extends Container(Canvas) {
this.connecting = []
this.mousePosition = []
this.dragging = false
this.on('fast-click', (e)=>{
this.on('draginit', (e)=>{
this.toggleConnection(e.target)
e.stopPropagation()
if (e.target === this.canvas) {
this.mousePosition = [e.offsetX, e.offsetY]
} else {
if (this.inputNodes.includes(e.target)) {
this.mousePosition = [e.offsetX - e.target.offsetWidth, e.offsetY + e.target.offsetTop]
} else {
this.mousePosition = [e.offsetX + this.canvas.offsetWidth, e.offsetY + e.target.offsetTop]
}
}
}, {element: this.widget})
this.mousePosition = []
this.on('drag', (e)=>{
if (!this.connecting.length) {
this.toggleConnection(e.target)
}
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.mousePosition[0] += e.movementX
this.mousePosition[1] += e.movementY
this.dragging = true
this.batchDraw()
}, {element: this.widget})
this.on('dragend', (e)=>{
if (this.mousePosition.length) {
if (this.dragging) {
// touch hover fix
var node = e.isTouch ? document.elementFromPoint(e.clientX, e.clientY) : e.target
this.mousePosition = []
this.toggleConnection(e.target)
this.toggleConnection(node)
}
this.dragging = false
}, {element: this.widget})

View file

@ -1,6 +1,5 @@
import Widget from '../common/widget'
import html from 'nanohtml'
import locales from '../../locales/index.mjs'
import StaticProperties from '../mixins/static_properties.mjs'
import {DOM} from '../../globals.mjs'
@ -49,10 +48,6 @@ class Frame extends StaticProperties(Widget, {bypass: true}) {
if (this.getProp('allow')) this.frame.setAttribute('allow', this.getProp('allow'))
this.errorText = html`<span>${locales('iframe_unauthorized')}<span>`
this.errorTextMounted = false
}
setValue(v, options={}) {
@ -61,16 +56,8 @@ class Frame extends StaticProperties(Widget, {bypass: true}) {
if (this.value) {
this.frame.setAttribute('src', this.value)
this.widget.classList.remove('error')
if (this.errorTextMounted) {
this.widget.removeChild(this.errorText)
this.errorTextMounted = false
}
} else {
this.frame.setAttribute('src', '')
this.widget.classList.add('error')
this.widget.appendChild(this.errorText)
this.errorTextMounted = true
}
if (options.sync) this.changed(options)

View file

@ -70,7 +70,7 @@ export default class Image extends StaticProperties(Widget, {bypass: true}) {
if (!s.length) {
this.value = this.getProp('default')
this.value = String(this.getProp('default'))
} else if (s != 'reload') {

View file

@ -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/otaves 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/octaves roll-off, 2 for 12dB/octaves, etc.',
'See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode'
]},
@ -53,20 +53,31 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo
super(options)
this.calcResponse()
this.setupArrays()
this.calcPending = true
this.batchDraw()
}
setupArrays() {
this.freqs = new Float32Array(this.width)
this.value = new Float32Array(this.width).fill(0)
var i,
min = this.getProp('rangeX').min,
max = this.getProp('rangeX').max,
width = this.width
for (i = 0; i < width; ++i) {
this.freqs[i] = mapToScale(i, [0, width], [min, max], -1, true)
}
}
calcResponse() {
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)
}
this.value.fill(0)
for (let filter of this.getProp('filters')) {
@ -85,31 +96,29 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo
gain: filter.gain || 0,
frequency: filter.freq || 1000,
q: filter.q || 1,
poles, Fs
}, frequencyHz, filterResponse)
poles,
Fs: this.getProp('rangeX').max * 2
}, this.freqs, this.value)
}
this.setValue(filterResponse, {sync: true})
}
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)
draw() {
if (this.calcPending) {
this.calcResponse()
this.calcPending = false
}
super.draw()
}
resizeHandle(event){
super.resizeHandle(event)
if (this.width !== this.value.length) this.calcResponse()
if (this.width !== this.value.length) {
this.setupArrays()
this.calcPending = true
this.batchDraw()
}
}
@ -119,7 +128,8 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo
switch (propName) {
case 'filters':
this.calcResponse()
this.calcPending = true
this.batchDraw()
return
}
@ -141,7 +151,8 @@ function biquadResponse(options, frequencyHz, filterResponse) {
var {type, frequency, q, gain, Fs, poles} = options,
len = frequencyHz.length,
a0, a1, a2, b1, b2,norm
a0, a1, a2, b1, b2,norm,
w, phi, y, i
var V = Math.pow(10, Math.abs(gain) / 20)
var K = Math.tan(Math.PI * frequency / Fs)
@ -264,15 +275,15 @@ function biquadResponse(options, frequencyHz, filterResponse) {
break
}
for (var i = 0; i < len; i++) {
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)
for (i = 0; i < len; i++) {
w = mapToScale(frequencyHz[i], [0, Fs / 2], [0, Math.PI], -1, false),
phi = Math.pow(Math.sin(w / 2), 2),
y = Math.log(Math.pow(a0 + a1 + a2, 2) - 4 * (a0 * a1 + 4 * a0 * a2 + a1 * a2) * phi + 16 * a0 * a2 * phi * phi) -
Math.log(Math.pow(1 + b1 + b2, 2) - 4 * (b1 + 4 * b2 + b1 * b2) * phi + 16 * b2 * phi * phi)
y = y * 10 / Math.LN10
// if (y == -Infinity) y = -200
filterResponse[i] += y * poles

View file

@ -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))
points.push(mapToScale(this.value[i][1], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true, true))
} else {
if (i < length - 2 && this.value[i] === previousValue && this.value[i+1] === previousValue) {
continue
}
nx = mapToScale(i, [0, this.value.length - 1], [padding, this.width - padding], -1, this.logScaleX, true)
ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true)
ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true, true)
if (x !== nx || y !== ny) {
points.push(nx)

View file

@ -180,7 +180,7 @@ class CanvasWidget extends Canvas {
width: this.width,
height: this.height,
cssVars: this.cssVars
}, {sync: false, send: false})
}, {sync: true, send: true})
}

View file

@ -41,7 +41,10 @@ class MultiXy extends Pad {
'- color (shorthand for colorFill and colorStroke)',
'- alphaFillOn (background opacity)',
'- pointSize',
'- label'
'- label',
'- clipX',
'- clipY',
'- axisLock'
]},
snap: {type: 'boolean', value: false, help: [
'By default, the points are dragged from their initial position.',
@ -361,7 +364,7 @@ class MultiXy extends Pad {
a.label = legacyLabels ? this.getProp('points')[i] : String(i)
}
for (var n of ['visible', 'axisLock', 'spring', 'colorFill', 'colorStroke', 'colorText', 'alphaFillOn', 'pointSize', 'label']) {
for (var n of ['visible', 'axisLock', 'spring', 'colorFill', 'colorStroke', 'colorText', 'alphaFillOn', 'pointSize', 'label', 'clipX', 'clipY']) {
this.pointsAttr[i][n] = a[n] === undefined ? this.getProp(n) : a[n]
if (this.pads[i].cachedProps[n] !== this.pointsAttr[i][n]) {

View file

@ -105,7 +105,9 @@ Pad.dynamicProps = Pad.prototype.constructor.dynamicProps.filter(n => n !== 'dec
'spring',
'axisLock',
'pointSize',
'label'
'label',
'clipX',
'clipY'
])
export default Pad

View file

@ -57,9 +57,9 @@ export default class Rgb extends Widget {
decimals:2,
pointSize: 10,
pips: false,
}, parent: this})
}, parent: this, meta: {not_editable: true}})
this.pad.sendValue = ()=>{}
this.pad.container.classList.add('not-editable', 'pad')
this.pad.container.classList.add('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})
this.hue.container.classList.add('not-editable', 'hue')
}, parent: this, meta: {not_editable: true}})
this.hue.container.classList.add('hue')
this.widget.appendChild(this.hue.container)
this.hue.on('value-changed',(e)=>{
e.stopPropagation = true
@ -97,8 +97,8 @@ export default class Rgb extends Widget {
default: 255,
input:false,
decimals:2
}, parent: this})
this.alpha.container.classList.add('not-editable', 'alpha')
}, parent: this, meta: {not_editable: true}})
this.alpha.container.classList.add('alpha')
this.widget.appendChild(this.alpha.container)
this.alpha.on('value-changed',(e)=>{
e.stopPropagation = true
@ -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.setAttribute('style',`background-color:${hueStr}`)
this.pad.container.style.setProperty('background-color', hueStr)
this.hue.setValue(this.hsb.h, {sync: false, send:false, dragged:false})
}

View file

@ -36,6 +36,8 @@ export default class Xy extends Pad {
logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale.'},
stepsX: {type: 'number|array|string', value: false, help: 'Defines `steps` for the x axis (see fader)'},
stepsY: {type: 'number|array|string', value: false, help: 'Defines `steps` for the x axis (see fader)'},
clipX: {type: 'object', value: '', help: 'Min and max boundaries for the x axis'},
clipY: {type: 'object', value: '', help: 'Min and max boundaries for the y axis'},
axisLock: {type: 'string', value: '', choices: ['', 'x', 'y', 'auto'], help: [
'Restrict movements to one of the axes only unless `Shift` is held.',
'When left empty, holding `Shift` while dragging will lock the pad according the first movement. `auto` will do the opposite.'
@ -138,6 +140,8 @@ export default class Xy extends Pad {
if (this.getProp('spring')) {
this.setValue([this.faders.x.getSpringValue(),this.faders.y.getSpringValue()],{sync:true, send:true, spring:true})
} else {
if (this.getProp('clipX')) this.faders.x.setValue(this.value[0])
if (this.getProp('clipY')) this.faders.y.setValue(this.value[1])
this.batchDraw()
}
}, {element: this.canvas})
@ -207,6 +211,7 @@ export default class Xy extends Pad {
if (this.touched && !options.dragged && !options.doubleTap) return this.setValueTouchedQueue = [v, options]
if (!options.dragged) {
this.clipValue(v)
this.faders.x.setValue(v[0], {sync: false, send:false, dragged:false, doubleTap: options.doubleTap})
this.faders.y.setValue(v[1], {sync: false, send:false, dragged:false, doubleTap: options.doubleTap})
}
@ -216,6 +221,8 @@ export default class Xy extends Pad {
this.faders.y.value
]
this.clipValue(this.value)
if (options.send) this.sendValue()
if (options.sync) this.changed(options)
@ -223,13 +230,26 @@ export default class Xy extends Pad {
}
clipValue(v) {
if (this.getProp('clipX')) {
if (this.getProp('clipX').min !== undefined) v[0] = Math.max(this.getProp('clipX').min, v[0])
if (this.getProp('clipX').max !== undefined) v[0] = Math.min(this.getProp('clipX').max, v[0])
}
if (this.getProp('clipY')) {
if (this.getProp('clipY').min !== undefined) v[1] = Math.max(this.getProp('clipY').min, v[1])
if (this.getProp('clipY').max !== undefined) v[1] = Math.min(this.getProp('clipY').max, v[1])
}
}
draw() {
if (!this.visible) return
var pointSize = this.pointSize,
x = this.faders.x.percentToCoord(this.faders.x.valueToPercent(this.faders.x.value)),
y = this.faders.y.percentToCoord(this.faders.y.valueToPercent(this.faders.y.value)),
x = this.faders.x.percentToCoord(this.faders.x.valueToPercent(this.value[0])),
y = this.faders.y.percentToCoord(this.faders.y.valueToPercent(this.value[1])),
ephemeral = this.getProp('ephemeral')
this.clear()

View file

@ -6,12 +6,14 @@ 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
;(async()=>{
setTimeout(async()=>{
// use setTimeout to fix init order in safari...
toolbar = (await import('../../ui/main-menu.mjs')).default
})()
})
class ScriptVm extends Vm {
@ -42,7 +44,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)
else return widgetManager.getWidgetById(id, widget.scopes)
}
@ -52,9 +54,7 @@ class ScriptVm extends Vm {
registerGlobals() {
super.registerGlobals()
this.sandbox.contentWindow.set = (id, value, extraOptions = {send: true, sync: true})=>{
this.globals.set = (id, value, extraOptions = {send: true, sync: true})=>{
this.checkContext('set')
@ -101,7 +101,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.setVar = (id, name, value)=>{
this.globals.setVar = (id, name, value)=>{
this.checkContext('setVar')
@ -136,7 +136,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.send = (target, address, ...args)=>{
this.globals.send = (target, address, ...args)=>{
this.checkContext('send')
@ -164,7 +164,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.get = (id)=>{
this.globals.get = (id)=>{
this.checkContext('get')
@ -183,7 +183,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.getVar = (id, name)=>{
this.globals.getVar = (id, name)=>{
this.checkContext('getVar')
@ -197,7 +197,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.getProp = (id, prop)=>{
this.globals.getProp = (id, prop)=>{
this.checkContext('getProp')
@ -212,7 +212,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.updateProp = (id, prop)=>{
this.globals.updateProp = (id, prop)=>{
this.checkContext('updateProp')
@ -227,7 +227,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.updateCanvas = (id)=>{
this.globals.updateCanvas = (id)=>{
this.checkContext('updateCanvas')
@ -240,7 +240,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.getIndex = (id = 'this')=>{
this.globals.getIndex = (id = 'this')=>{
this.checkContext('getIndex')
@ -249,7 +249,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.getScroll = (id)=>{
this.globals.getScroll = (id)=>{
this.checkContext('getScroll')
@ -265,7 +265,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.setScroll = (id, x, y)=>{
this.globals.setScroll = (id, x, y)=>{
this.checkContext('setScroll')
@ -279,7 +279,25 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.httpGet = (url, callback)=>{
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')
@ -300,7 +318,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.stateGet = (filter)=>{
this.globals.stateGet = (filter)=>{
this.checkContext('stateGet')
@ -320,7 +338,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.stateSet = (state, extraOptions = {})=>{
this.globals.stateSet = (state, extraOptions = {})=>{
this.checkContext('stateSet')
@ -330,7 +348,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.storage = {
this.globals.storage = {
setItem: (k, v)=>{
this.checkContext('storage.setItem')
@ -351,7 +369,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.setTimeout = (id, callback, timeout)=>{
this.globals.setTimeout = (id, callback, timeout)=>{
this.checkContext('setTimeout')
@ -385,7 +403,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.clearTimeout = (id)=>{
this.globals.clearTimeout = (id)=>{
this.checkContext('clearTimeout')
@ -396,7 +414,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.setInterval = (id, callback, timeout)=>{
this.globals.setInterval = (id, callback, timeout)=>{
this.checkContext('setInterval')
@ -429,7 +447,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.clearInterval = (id)=>{
this.globals.clearInterval = (id)=>{
this.checkContext('clearInterval')
@ -441,7 +459,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.setFocus = (id)=>{
this.globals.setFocus = (id)=>{
this.checkContext('setFocus')
@ -451,6 +469,8 @@ class ScriptVm extends Vm {
if (widgets.length) {
if (widgets[0].focus) widgets[0].focus()
}
} else if (document.activeElement) {
document.activeElement.blur()
}
// built-in client only: electron will call window.focus()
@ -458,7 +478,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.unfocus = ()=>{
this.globals.unfocus = ()=>{
this.checkContext('unfocus')
@ -468,7 +488,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.setFocusable = (focusable)=>{
this.globals.setFocusable = (focusable)=>{
this.checkContext('setFocusable')
setFOCUSABLE(!!focusable)
@ -476,7 +496,20 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.toolbar = (...args)=>{
function getToolbarActionById(id, entries) {
for (var a of entries) {
if (a.id == id) {
return a
}
if (Array.isArray(a.action)) {
var ret = getToolbarActionById(id, a.action)
if (ret) return ret
}
}
}
this.globals.toolbar = (...args)=>{
this.checkContext('toolbar')
@ -486,17 +519,43 @@ class ScriptVm extends Vm {
var action = toolbar.entries.filter(x=>!x.separator)
for (var i of args) {
if (action[i]) action = action[i].action
if (!Array.isArray(action)) break
action = action.filter(x=>!x.separator)
if (typeof args[0] == 'string') {
action = getToolbarActionById(args[0], action)
if (action) action = action.action // get callback
if (action && typeof action.class == 'function') {
if (action.class().match(/disabled/)) action = null
}
} else {
for (var i of args) {
if (action[i]) action = action[i].action
if (!Array.isArray(action)) break
action = action.filter(x=>!x.separator)
}
}
if (typeof action === 'function') action()
}
this.sandbox.contentWindow.openUrl = (url)=>{
this.globals.getToolbar = (id)=>{
this.checkContext('toolbar')
var options = this.getValueOptions()
if (!options.send) return
var action = getToolbarActionById(id, toolbar.entries.filter(x=>!x.separator))
if (action && typeof action.class == 'function') return action.class().split(' ').includes('on')
}
this.globals.openUrl = (url)=>{
this.checkContext('openUrl')
@ -506,7 +565,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.runAs = (id, callback)=>{
this.globals.runAs = (id, callback)=>{
this.checkContext('runAs')
@ -527,7 +586,7 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.reload = (keepState = true)=>{
this.globals.reload = (keepState = true)=>{
this.checkContext('reload')
@ -544,16 +603,16 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.Image = Image
this.globals.Image = Image
this.sandbox.contentWindow.getNavigator = ()=>{
this.globals.getNavigator = ()=>{
this.checkContext('getNavigator')
return navigator
}
this.sandbox.contentWindow.browseFile = (options, callback)=>{
this.globals.browseFile = (options, callback)=>{
this.checkContext('browseFile')
if (typeof options === 'function') {
callback = options
@ -587,18 +646,38 @@ class ScriptVm extends Vm {
}
}
this.globals.uploadFile = (options, callback)=>{
this.checkContext('uploadFile')
if (typeof options === 'function') {
callback = options
options = {}
}
this.globals = {}
for (var imports of ['set', 'get', 'getProp', 'getIndex', 'updateProp', 'send', 'httpGet', 'stateGet', 'stateSet', 'storage',
'setInterval', 'clearInterval', 'setTimeout', 'cthislearTimeout', 'setFocus', 'unfocus' , 'setFocusable', 'setScroll', 'getScroll', 'toolbar',
'openUrl', 'getVar', 'setVar', 'runAs', 'reload', 'Image', 'updateCanvas', 'getNavigator', 'browseFile']) {
this.globals[imports] = true
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')
}
}
for (var k in this.sandbox.contentWindow) {
if (window[k] === undefined) this.globals[k] = true
}
super.registerGlobals()
}

View file

@ -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}}) {
export default class Encoder extends StaticProperties(Knob, {angle: 360, range: {min: 0, max: 1}, design: 'encoder'}) {
static description() {
@ -33,10 +33,11 @@ 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'], help: [
mode: {type: 'string', value: 'circular', choices: ['circular', 'snap', 'vertical', 'horizontal'], help: [
'- `circular`: relative move in circular motion',
'- `snap`: snap to touch position and move in vertical motion',
'- `vertical`: relative move in vertical motion',
'- `horizontal`: relative move in horizontal motion',
]},
doubleTap: {type: 'boolean', value: false, help: [
'Set to `true` to make the fader reset to its `default` value when receiving a double tap.',
@ -116,7 +117,11 @@ 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 / this.height) * this.getProp('sensitivity') / inertia)
this.setPercent(this.percent - 100 * (e.movementY / inertia * this.getProp('sensitivity')) / this.minDimension)
} else if ((this.getProp('mode') === 'horizontal' && !e.traversing)) {
// horizontal
this.setPercent(this.percent + 100 * (e.movementX / inertia * this.getProp('sensitivity')) / this.minDimension)
} else {
// snap or circular
@ -258,64 +263,4 @@ 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()
}
}
}

View file

@ -313,7 +313,8 @@ class Fader extends Slider {
this.ctx.fillStyle = this.cssVars.colorKnob
this.ctx.beginPath()
d = d / (height - this.gaugePadding) * (height-this.gaugePadding - knobHeight)
// adjust position to keep knob within gauge boundaries
d = (d - this.gaugePadding ) / (height - this.gaugePadding * 2 ) * (height - this.gaugePadding * 2 - knobHeight) + this.gaugePadding
this.ctx.rect(this.gaugePadding, d, width - this.gaugePadding * 2, knobHeight)
this.ctx.fill()

View file

@ -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'], help: [
design: {type: 'string', value: 'default', choices: ['default', 'solid', 'line', 'encoder'], help: [
'Design style',
'Note: "solid" design uses "colorStroke" for the central knob color.'
]},
@ -25,8 +25,9 @@ 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', 'circular', 'snap', 'snap-alt'], help: [
mode: {type: 'string', value: 'vertical', choices: ['vertical', 'horizontal', 'circular', 'snap', 'snap-alt'], help: [
'- `vertical`: relative move in vertical motion',
'- `horizontal`: relative move in horizontal motion',
'- `circular`: relative move in circular motion',
'- `snap`: snap to touch position',
'- `snap-alt`: alternative snap mode that allow jumping from `range.min` to `range.max`. `sensitivity` is ignored with this mode.',
@ -109,6 +110,10 @@ 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,
@ -188,153 +193,199 @@ class Knob extends Slider {
this.clear()
if (this.getProp('design') === 'default') {
switch (this.getProp('design')) {
case 'default':
{
if (this.minDimension < 40) {
minRadius /= 2
gaugeWidth = maxRadius - minRadius
gaugeRadius = maxRadius - gaugeWidth / 2
}
if (this.minDimension < 40) {
minRadius /= 2
gaugeWidth = maxRadius - minRadius
gaugeRadius = maxRadius - gaugeWidth / 2
}
// fill
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = gaugeWidth - this.gaugePadding * 2
// fill
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = gaugeWidth - this.gaugePadding * 2
if (dashed) this.ctx.setLineDash(dashed)
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
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.moveTo(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a))
this.ctx.lineTo(r2 * Math.cos(a) + this.width / 2, this.height / 2 - r2 * Math.sin(a))
this.ctx.stroke()
break
}
case 'solid':
{
// center
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.fillStyle = this.cssVars.colorKnob
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius / 1.25, 0, 2 * Math.PI)
this.ctx.fill()
// fill
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = this.cssVars.lineWidth
if (dashed) this.ctx.setLineDash(dashed)
if (this.cssVars.alphaFillOff) {
this.ctx.globalAlpha = this.cssVars.alphaFillOff
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, min, max)
this.ctx.stroke()
}
if (this.cssVars.alphaFillOn) {
this.ctx.globalAlpha = this.cssVars.alphaFillOn
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, o, d, o > d)
this.ctx.stroke()
}
if (dashed) this.ctx.setLineDash([])
// knob
this.ctx.globalAlpha = 1
this.ctx.strokeStyle = this.cssVars.colorBg
this.ctx.lineWidth = this.cssVars.lineWidth + .5 * PXSCALE
let r1 = minRadius,
r2 = maxRadius / 1.25 + PXSCALE ,
a = 2 * Math.PI - d
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI)
this.ctx.moveTo(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a))
this.ctx.lineTo(r2 * Math.cos(a) + this.width / 2, this.height / 2 - r2 * Math.sin(a))
this.ctx.stroke()
break
}
case 'line':
{
// fill
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = this.cssVars.lineWidth
if (dashed) this.ctx.setLineDash(dashed)
// knob
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()
}
this.ctx.globalAlpha = 1
this.ctx.strokeStyle = this.cssVars.colorKnob
this.ctx.lineWidth = this.cssVars.lineWidth + .5 * PXSCALE
if (this.cssVars.alphaFillOn) {
this.ctx.globalAlpha = this.cssVars.alphaFillOn
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, o, d, o > d)
this.ctx.stroke()
}
let r1 = minRadius + this.gaugePadding,
r2 = maxRadius - this.gaugePadding,
a = 2 * Math.PI - d
if (dashed) this.ctx.setLineDash([])
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()
// knob
} else if (this.getProp('design') === 'solid') {
this.ctx.globalAlpha = 1
this.ctx.strokeStyle = this.cssVars.colorKnob
this.ctx.lineWidth = this.cssVars.lineWidth
// center
let r1 = minRadius * 1.5,
r2 = maxRadius + this.cssVars.lineWidth / 2 - 0.5 * PXSCALE,
a = 2 * Math.PI - d
this.ctx.globalAlpha = this.cssVars.alphaStroke
this.ctx.fillStyle = this.cssVars.colorKnob
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius / 1.25, 0, 2 * Math.PI)
this.ctx.fill()
// fill
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = this.cssVars.lineWidth
if (dashed) this.ctx.setLineDash(dashed)
if (this.cssVars.alphaFillOff) {
this.ctx.globalAlpha = this.cssVars.alphaFillOff
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, min, max)
this.ctx.moveTo(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a))
this.ctx.lineTo(r2 * Math.cos(a) + this.width / 2, this.height / 2 - r2 * Math.sin(a))
this.ctx.stroke()
break
}
case 'encoder':
{
let angle = 2 * Math.PI / 16
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()
// 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 (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()
}
@ -364,7 +415,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
var angle = this.percentToAngle(p),
let angle = this.percentToAngle(p),
size = this.ctx.measureText(this.pipTexts[p]),
x = this.width / 2 + radius * Math.cos(angle) - size.width / 2,
y = this.height / 2 + radius * Math.sin(angle)

View file

@ -301,16 +301,15 @@ 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 *= compactAdjust
d = (d - this.gaugePadding ) / (height - this.gaugePadding * 2 ) * (height - this.gaugePadding * 2 - knobHeight) + this.gaugePadding
this.ctx.rect(this.gaugePadding, d, width - this.gaugePadding * 2, knobHeight)
this.ctx.fill()
// extra knob
this.ctx.beginPath()
d2 *= compactAdjust
d2 = (d2 - this.gaugePadding ) / (height - this.gaugePadding * 2 ) * (height - this.gaugePadding * 2 - knobHeight) + this.gaugePadding
this.ctx.rect(this.gaugePadding, d2, width - this.gaugePadding * 2, knobHeight)
this.ctx.fill()

View file

@ -43,36 +43,60 @@ 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 (this.scrollTarget) return
// if in a non-scoped context we don't watch for a closer target once we have one
if (!this.scopes.length && this.scrollTarget) return
var {id, widget} = e
if (id.includes(this.getProp('widgetId')) && widget.getProp('scroll')) {
if (id === this.getProp('widgetId') && widget.getProp('scroll')) {
this.unbindTarget()
this.bindTarget(widget)
this.getScrollTarget()
}
}, {context: this})
var widgets = widgetManager.getWidgetById(this.getProp('widgetId'))
for (var widget of widgets) {
if (widget.getProp('scroll')) {
this.unbindTarget()
this.bindTarget(widget)
break
}
}
this.getScrollTarget()
}
getScrollTarget() {
var scopes = this.scopes.length ? this.scopes : [''],
target = null,
rank = 0
for (var scope of scopes) {
var widgets = widgetManager.getWidgetById(this.getProp('widgetId'), scope)
.filter(w=>w.getProp('scroll'))
target = widgets[0]
if (!target) {
rank++
continue
}
if (rank < this.targetRank || this.targetRank == null) {
this.unbindTarget()
this.bindTarget(target, rank)
}
return
}
}
draginitHandle(e) {
@ -102,6 +126,8 @@ 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
@ -132,46 +158,57 @@ export default class Scrollbar extends StaticProperties(Fader, {
this.scrollTarget.off(undefined, undefined, this)
this.scrollTarget = null
this.targetRank = null
}
bindTarget(target) {
bindTarget(target, rank) {
if (!target) return
this.scrollTarget = target
this.targetRank = rank
this.scrollTarget.on('widget-removed', (e)=>{
if (this.scrollTarget === e.widget) {
this.unbindTarget()
}
}, {context: this})
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(()=>{
this.scrollTarget.on('scroll', onScroll)
onScroll({}, true)
if (!this.scrollTarget) return
this.scrollTarget.on('scroll', this.targetScroll.bind(this))
this.scrollTarget.on('resize', ()=>{
if (this.scrollTarget) {
this.scrollTarget.trigger('scroll', {})
this.targetScroll({}, true)
}
}, {element: this.scrollTarget.widget})
this.targetScroll({}, true)
})
}
targetScroll(e, init) {
if (!this.scrollTarget || (e && e.locked)) return
var index = this.getProp('horizontal') ? 0 : 1,
size = this.getProp('horizontal') ? this.width : this.height
this.thumbSize = this.scrollTarget.scrollThumb[index]
this.cssVars.knobSize = Math.max(this.thumbSize * size, 30)
if (init && this.value) {
// panel (re)createed: restore scroll state
this.setValue(this.value, {fromScrollEvent: false, send: false, sync: false})
} else if (this.scrollTarget.scroll[index] != this.value) {
// panel scrolling: update scroll state
this.setValue(this.scrollTarget.scroll[index], {fromScrollEvent: true, send: !init, sync: !init})
}
}
setValue(v, options={}) {
super.setValue(v, options)
@ -229,7 +266,8 @@ export default class Scrollbar extends StaticProperties(Fader, {
this.ctx.fillStyle = this.cssVars.colorKnob
this.ctx.beginPath()
d = d / (height - this.gaugePadding) * (height-this.gaugePadding - knobHeight)
// adjust position to keep knob within gauge boundaries
d = (d - this.gaugePadding ) / (height - this.gaugePadding * 2 ) * (height - this.gaugePadding * 2 - knobHeight) + this.gaugePadding
if (this.cssVars.borderRadius > 0 && this.ctx.roundRect) {
this.ctx.roundRect(this.gaugePadding, d, width - this.gaugePadding * 2, knobHeight, PXSCALE * this.cssVars.borderRadius)
} else {

View file

@ -17,10 +17,12 @@ 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) {
export function mapToScale(value, rangeIn, rangeOut, decimals, log, revertlog, noClip) {
// clip in
value = clip(value,[rangeIn[0], rangeIn[1]])
if (!noClip) {
value = clip(value,[rangeIn[0], rangeIn[1]])
}
// normalize
@ -48,7 +50,9 @@ export function mapToScale(value, rangeIn, rangeOut, decimals, log, revertlog) {
value = value * (rangeOut[1] - rangeOut[0]) + rangeOut[0]
// clip out
value = clip(value, [rangeOut[0], rangeOut[1]])
if (!noClip) {
value = clip(value, [rangeOut[0], rangeOut[1]])
}
// decimals
if (decimals !== -1) value = parseFloat(value.toFixed(decimals))

View file

@ -2,9 +2,10 @@ import {deepCopy} from '../utils.mjs'
import {ENV, IP} from '../globals.mjs'
var sessionManager
;(async()=>{
setTimeout(async()=>{
// use setTimeout to fix init order in safari...
sessionManager = (await import('../managers/session/index.mjs')).default
})()
})
var globals
@ -51,6 +52,20 @@ class Vm {
this.sandbox.contentWindow.document.close()
// global context
this.globals = {}
this.globals.console = {
...console,
log: (...msg)=>{
msg = msg.map(m => typeof m == 'object' ? JSON.stringify(m, this.jsonReplacer) : m)
this.getWidget().log(msg.join(' '))
}
}
this.globals.setTimeout =
this.globals.setInterval = ()=>{
throw 'setTimeout and setInterval can\'t be used in the JS sandbox'
}
this.registerGlobals()
// detach sandbox
@ -73,19 +88,11 @@ class Vm {
registerGlobals() {
this.sandbox.contentWindow.console = {
...console,
log: (...msg)=>{
msg = msg.map(m => typeof m == 'object' ? JSON.stringify(m) : m)
this.getWidget().log(msg.join(' '))
}
}
this.globals.globals = globals
this.sandbox.contentWindow.setTimeout =
this.sandbox.contentWindow.setInterval = ()=>{
throw 'setTimeout and setInterval can\'t be used in the JS sandbox'
for (var k in this.globals) {
this.sandbox.contentWindow[k] = this.globals[k]
}
this.sandbox.contentWindow.globals = globals
}
@ -136,6 +143,10 @@ class Vm {
}
jsonReplacer(key, value) {
return value instanceof HTMLElement ? `&lt;${value.tagName}#${value.id}&gt;` : value
}
}
export default Vm

View file

@ -60,10 +60,6 @@ window = {
location: {search: ''},
Image: Function,
document: document,
navigator: {
platform:'',
userAgent: ''
},
NodeList: Array,
WebSocket: Object,
localStorage: {
@ -81,7 +77,16 @@ window = {
ENV: {id: ''},
IP: '',
DOM
}
if (!global.navigator) {
// defined as getter since node 22
window.navigator = {
platform:'',
userAgent: ''
}
}
Object.assign(global, window)
console.debug = ()=>{}

View file

@ -20,10 +20,10 @@ doc.push(`
for (let categoryName in base) {
doc.push(`\n
=== "${categoryName}"
=== "${categoryName}"
| property | type |default | description |
| --- | --- | --- | --- |`
| property | type |default | description |
| --- | --- | --- | --- |`
)
let notEmpty = false

View file

@ -2,20 +2,25 @@
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="cache-control" content="no-store" />
<meta name="viewport" content="width=device-width, user-scalable=no"/>
<meta name="mobile-web-app-capable" content="yes">
<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="/assets/logo.png?__OSC_ASSET__=1&version=${version}" />
<link rel="stylesheet" type="text/css" href="/assets/open-stage-control.css?__OSC_ASSET__=1&version=${version}" hot-reload/>
<link rel="stylesheet" type="text/css" href="/theme.css?__OSC_ASSET__=1&version=${version}" hot-reload/>
<link rel="stylesheet" type="text/css" href="/assets/fonts/fontawesome.min.css?__OSC_ASSET__=1&version=${version}"/>
<link rel="stylesheet" type="text/css" href="/assets/fonts/fa-solid.css?__OSC_ASSET__=1&version=${version}"/>
<link rel="stylesheet" type="text/css" href="/assets/fonts/roboto.css?__OSC_ASSET__=1&version=${version}"/>
<link rel="shortcut icon" href="/assets/favicon.png?__OSC_ASSET__=1&version=${version}"/>
<script src="/client/ace/ace.js?__OSC_ASSET__=1&version=${version}"></script>
<script type="module" defer src="/client/index-${version}.js"></script>
<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" />
</head>
<body class="editor-disabled" spellcheck="false">

View file

@ -11,16 +11,17 @@ DOM.get(document, '#osc-greeting-header')[0].appendChild(html`${PACKAGE.productN
if (settings.remote.read('checkForUpdates') && navigator.onLine) {
var request = new XMLHttpRequest()
request.open('GET', 'https://api.github.com/repos/jean-emmanuel/open-stage-control/tags', true)
request.open('GET', 'https://framagit.org/api/v4/projects/jean-emmanuel%2Fopen-stage-control/releases', true)
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var data = JSON.parse(request.responseText),
var data = JSON.parse(request.responseText).filter(x=>!x.name.match(/alpha|beta/)),
current = 'v' + PACKAGE.version,
latest = data[0].name
if (semver.gt(latest, current)) {
terminal.log(`(INFO) A new version is available : <a target="_blank" href="https://github.com/jean-emmanuel/open-stage-control/releases">${latest}</a>`, 'info')
terminal.log(`(INFO) A new version is available : <a target="_blank" href="https://openstagecontrol.ammd.net/download/">${latest}</a>`, 'info')
} else if (semver.gt(current, latest)) {
terminal.log(`(WARNING) Using development version ${current}`, 'warning')
}

View file

@ -9,7 +9,7 @@ import {DOM, PXSCALE} from '../client/globals.mjs'
var {Menu, MenuItem} = remote.require('electron'),
menu = new Menu(),
{midilist, openDocs} = remote.getGlobal('launcherSharedGlobals'),
{midiList, midiRestart, openDocs} = remote.getGlobal('launcherSharedGlobals'),
serverStarting = false,
serverStart = ()=>{
if (serverStarting) return
@ -77,13 +77,25 @@ menu.append(new MenuItem({
menu.append(new MenuItem({
type: 'separator'
}))
menu.append(new MenuItem({
label: 'List MIDI Devices',
click: ()=>{
midilist()
},
accelerator: 'ctrl + m'
}))
menu.append(new MenuItem({type: 'submenu' , label: 'MIDI', submenu: [
new MenuItem({
label: 'List devices',
click: ()=>{
midiList()
},
accelerator: 'ctrl + m'
}),
new MenuItem({
label: 'Restart backend',
id: 'midiRestart',
click: ()=>{
midiRestart()
},
enabled: false
}),
]}))
menu.append(new MenuItem({type: 'submenu' , label: 'Console', submenu: [
new MenuItem({
label: 'Clear',
@ -211,6 +223,8 @@ class Toolbar {
stop.visible = !!serverStarting
qrcode.visible = !!serverStarting
newWindow.visible = !!serverStarting
menu.getMenuItemById('midiRestart').enabled = !!serverStarting
menu.popup({window: remote.getCurrentWindow(), x: parseInt(PXSCALE), y: parseInt(40 * PXSCALE)})
})

View file

@ -62,6 +62,11 @@ 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;

View file

@ -190,6 +190,9 @@ osc-inspector-field {
> label:before {
content: var(--prefix);
}
&.dirty label:after{
content: "*"
}
.btn {
margin-top: 50rem;
margin-right: 50rem;

View file

@ -21,6 +21,11 @@ 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)
@ -126,9 +131,7 @@ app.on('ready',()=>{
})
app.on('window-all-closed', function() {
if (process.platform !== 'darwin') {
app.quit()
}
app.quit()
})
export default app

View file

@ -143,7 +143,7 @@ function stopServerProcess() {
var toClose = clientWindows.filter(w=>w && !w.isDestroyed()),
closed = 0
if (toClose.length === 0) {
if (toClose.length === 0 && serverProcess) {
serverProcess.kill('SIGINT')
serverProcess = null
}
@ -169,7 +169,12 @@ function startLauncher() {
global.launcherSharedGlobals = {
settings: settings,
openDocs: openDocs,
midilist: midi.list
midiList: midi.list,
midiRestart: ()=>{
if (serverProcess) {
serverProcess.send('midiRestart')
}
}
}
var address = 'file://' + path.resolve(__dirname + '/../../launcher/' + 'index.html')
@ -194,7 +199,7 @@ function startLauncher() {
})
launcher.on('will-close', (e)=>{
if (clientWindows.some(w=>w && !w.isDestroyed())) {
if (clientWindows.some(w=>w && !w.isDestroyed()) || serverProcess) {
launcher.hide()
e.preventDefault()
}
@ -204,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

View file

@ -2,7 +2,7 @@ import fs from 'fs'
import vm from 'vm'
import chokidar from 'chokidar'
import path from 'path'
import {globalPaths} from 'module'
import {Module} from 'module'
import * as settings from './settings.mjs'
var modulePathExtended = false,
@ -79,10 +79,9 @@ class CustomModule {
}
if (!this.submodule && !modulePathExtended) {
globalPaths.push(
path.resolve(path.dirname(this.filename)),
path.resolve(path.dirname(this.filename), 'node_modules')
)
process.env.NODE_PATH += path.delimiter + path.resolve(path.dirname(this.filename))
process.env.NODE_PATH += path.delimiter + path.resolve(path.dirname(this.filename), 'node_modules')
Module._initPaths()
modulePathExtended = true
}

View file

@ -30,7 +30,7 @@ export default class Callbacks {
open(data, clientId) {
// client connected
this.ipcServer.send('connected')
this.ipcServer.send('connected', null, clientId)
var recentSessions = settings.read('recentSessions')
@ -136,7 +136,7 @@ export default class Callbacks {
}, (error)=>{
this.ipcServer.send('error', `Could not open session file:\n ${error}`)
this.ipcServer.send('error', `Could not open session file:\n ${error}`, clientId)
})
@ -287,7 +287,7 @@ export default class Callbacks {
}, (error)=>{
this.ipcServer.send('error', `Could not open state file:\n ${error}`)
this.ipcServer.send('error', `Could not open state file:\n ${error}`, clientId)
})

View file

@ -97,9 +97,9 @@ class Client extends EventEmitter {
}
send(event, data) {
send(packet) {
var packet = JSON.stringify([event, data])
// see IpcServer.send
if (this.connected()) {
this.socket.send(packet)

View file

@ -66,12 +66,22 @@ class IpcServer {
send(event, data, id, except) {
var clients = id ? [this.clients[id]] : this.clients
var packet = JSON.stringify([event, data])
for (var k in clients) {
if (!except || this.clients[k] != this.clients[except]) {
if (clients[k]) clients[k].send(event, data)
if (id) {
// send to a single client
if (this.clients[id]){
this.clients[id].send(packet)
}
} else {
// send to all clients except one if specified
for (let id in this.clients) {
if (id != except) {
this.clients[id].send(packet)
}
}
}
}

Some files were not shown because too many files have changed in this diff Show more