From 891239658c358a765c888eaef8cd2475091750a1 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 9 Dec 2025 21:59:50 +0100 Subject: [PATCH 001/163] ios: use 3rd party to better detect iOS versions and mobile devices --- package.json | 1 + src/client/ui/init.mjs | 4 ++-- src/client/ui/ios.mjs | 17 ++++++----------- src/client/ui/main-menu.mjs | 4 +++- src/client/ui/utils.mjs | 5 +++++ 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index c43af4a3..ca1ae01b 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "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" }, diff --git a/src/client/ui/init.mjs b/src/client/ui/init.mjs index d3d38539..072a3341 100644 --- a/src/client/ui/init.mjs +++ b/src/client/ui/init.mjs @@ -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') } diff --git a/src/client/ui/ios.mjs b/src/client/ui/ios.mjs index 8a5f8d7d..6c040b6e 100644 --- a/src/client/ui/ios.mjs +++ b/src/client/ui/ios.mjs @@ -1,18 +1,15 @@ import {DOM} from '../globals.mjs' +import {device, os} from './utils.mjs' + + +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 diff --git a/src/client/ui/main-menu.mjs b/src/client/ui/main-menu.mjs index 5dfd22c0..3349c687 100644 --- a/src/client/ui/main-menu.mjs +++ b/src/client/ui/main-menu.mjs @@ -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 = [ @@ -228,7 +230,7 @@ var menuEntries = [ ] -if (navigator.userAgent.match(/Android|iPhone|iPad|iPod/i)) { +if (device.is('mobile') || device.is('tablet')) { var noSleep = new NoSleep(), diff --git a/src/client/ui/utils.mjs b/src/client/ui/utils.mjs index b73a99db..c23afcc7 100644 --- a/src/client/ui/utils.mjs +++ b/src/client/ui/utils.mjs @@ -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 `` From 931827fc7214b2e5c162a3c4bd60eafb5b4f1c78 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 9 Dec 2025 22:05:40 +0100 Subject: [PATCH 002/163] server: silence not found errors for apple requests --- src/server/node/server.mjs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/server/node/server.mjs b/src/server/node/server.mjs index df07e4fb..f70306a2 100644 --- a/src/server/node/server.mjs +++ b/src/server/node/server.mjs @@ -41,6 +41,12 @@ class WebServer extends EventEmitter { // add remote root or absolute this.resolveDirs.push(this.remoteRoot || '') + this.ignoredNotFound = [ + '/apple-touch-icon-precomposed.png', + '/favicon.ico', + '/apple-touch-icon.png' + ] + } @@ -255,7 +261,10 @@ class WebServer extends EventEmitter { } catch(e) {} } - console.error(`(ERROR, HTTP) File not found: ${url}`) + if (!this.ignoredNotFound.includes(url)) { + console.error(`(ERROR, HTTP) File not found: ${url}`) + } + res.writeHead(404) res.end() From 02cc18395a87e8cb884ef5caa447502421fc2718 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 9 Dec 2025 22:17:45 +0100 Subject: [PATCH 003/163] misc: lint --- src/client/ui/ios.mjs | 2 +- src/client/ui/ui-tree.mjs | 4 ++-- src/server/node/server.mjs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/ui/ios.mjs b/src/client/ui/ios.mjs index 6c040b6e..c9f3267e 100644 --- a/src/client/ui/ios.mjs +++ b/src/client/ui/ios.mjs @@ -2,7 +2,7 @@ import {DOM} from '../globals.mjs' import {device, os} from './utils.mjs' -iOS = (device.is('mobile') || device.is('tablet')) && os.is('ios') +var iOS = (device.is('mobile') || device.is('tablet')) && os.is('ios') // Prevent iOS Pull-To-Refresh diff --git a/src/client/ui/ui-tree.mjs b/src/client/ui/ui-tree.mjs index 669a6366..42afb6c4 100644 --- a/src/client/ui/ui-tree.mjs +++ b/src/client/ui/ui-tree.mjs @@ -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 } diff --git a/src/server/node/server.mjs b/src/server/node/server.mjs index f70306a2..395ff92e 100644 --- a/src/server/node/server.mjs +++ b/src/server/node/server.mjs @@ -140,7 +140,7 @@ class WebServer extends EventEmitter { var lastModified = new Date(stats.mtime) lastModified.setMilliseconds(0) res.setHeader('Cache-Control', 'no-cache') - res.setHeader("Last-Modified", lastModified.toUTCString()) + res.setHeader('Last-Modified', lastModified.toUTCString()) if ( req.headers['if-modified-since'] && new Date(req.headers['if-modified-since']).getTime() >= lastModified.getTime() ) { From dc023def19968eba657b57f1373848713c66fdb4 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 10 Dec 2025 08:59:30 +0100 Subject: [PATCH 004/163] client: update toolbar toggle when user agent releases the wakelock by itself --- src/client/ui/main-menu.mjs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client/ui/main-menu.mjs b/src/client/ui/main-menu.mjs index 3349c687..d746f662 100644 --- a/src/client/ui/main-menu.mjs +++ b/src/client/ui/main-menu.mjs @@ -246,6 +246,9 @@ if (device.is('mobile') || device.is('tablet')) { 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 From 6f46a813cc9327dae4a93384023d86284affb023 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 10 Dec 2025 09:04:56 +0100 Subject: [PATCH 005/163] docs: fullscreen and wakelock don't always require user interaction to work --- resources/docs/docs/widgets/scripting.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/docs/docs/widgets/scripting.md b/resources/docs/docs/widgets/scripting.md index 498991c2..4223a9ef 100644 --- a/resources/docs/docs/widgets/scripting.md +++ b/resources/docs/docs/widgets/scripting.md @@ -357,8 +357,7 @@ Triggers toolbar action at specified index. - `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`) - + 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. ---- #### `openUrl(url)` From 67669d4ff277341af840f05fd29955e61ee8e03f Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 10 Dec 2025 09:49:42 +0100 Subject: [PATCH 006/163] package-lock: update --- package-lock.json | 92 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index e1321848..8082e04a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "open-stage-control", - "version": "1.30.0-beta4", + "version": "1.30.0-beta6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "open-stage-control", - "version": "1.30.0-beta4", + "version": "1.30.0-beta6", "hasInstallScript": true, "license": "GPL-3.0", "dependencies": { @@ -64,6 +64,7 @@ "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" }, @@ -4466,6 +4467,25 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/detect-europe-js": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/detect-europe-js/-/detect-europe-js-0.1.2.tgz", + "integrity": "sha512-lgdERlL3u0aUdHocoouzT10d9I89VVhk0qNRmll7mXdGfJT1/wqZ2ZLA4oJAjeACPY5fT1wsbq2AT+GkuInsow==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/faisalman" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/ua-parser-js" + }, + { + "type": "paypal", + "url": "https://paypal.me/faisalman" + } + ] + }, "node_modules/detect-libc": { "version": "2.0.1", "license": "Apache-2.0", @@ -6783,6 +6803,25 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-standalone-pwa": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-standalone-pwa/-/is-standalone-pwa-0.1.1.tgz", + "integrity": "sha512-9Cbovsa52vNQCjdXOzeQq5CnCbAcRk05aU62K20WO372NrTv0NxibLFCK6lQ4/iZEFdEA3p3t2VNOn8AJ53F5g==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/faisalman" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/ua-parser-js" + }, + { + "type": "paypal", + "url": "https://paypal.me/faisalman" + } + ] + }, "node_modules/is-string": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.1.1.tgz", @@ -9914,6 +9953,55 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/ua-is-frozen": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ua-is-frozen/-/ua-is-frozen-0.1.2.tgz", + "integrity": "sha512-RwKDW2p3iyWn4UbaxpP2+VxwqXh0jpvdxsYpZ5j/MLLiQOfbsV5shpgQiw93+KMYQPcteeMQ289MaAFzs3G9pw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/faisalman" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/ua-parser-js" + }, + { + "type": "paypal", + "url": "https://paypal.me/faisalman" + } + ] + }, + "node_modules/ua-parser-js": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-2.0.7.tgz", + "integrity": "sha512-CFdHVHr+6YfbktNZegH3qbYvYgC7nRNEUm2tk7nSFXSODUu4tDBpaFpP1jdXBUOKKwapVlWRfTtS8bCPzsQ47w==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/ua-parser-js" + }, + { + "type": "paypal", + "url": "https://paypal.me/faisalman" + }, + { + "type": "github", + "url": "https://github.com/sponsors/faisalman" + } + ], + "dependencies": { + "detect-europe-js": "^0.1.2", + "is-standalone-pwa": "^0.1.1", + "ua-is-frozen": "^0.1.2" + }, + "bin": { + "ua-parser-js": "script/cli.js" + }, + "engines": { + "node": "*" + } + }, "node_modules/unbox-primitive": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.1.0.tgz", From fab78f98a408f08d1383bae2e49a5d7fe2c98ea9 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 10 Dec 2025 09:50:05 +0100 Subject: [PATCH 007/163] scripting: add getToolbar() and make toolbar() accept string id --- CHANGELOG.md | 2 + resources/docs/docs/widgets/scripting.md | 30 +++++++++-- src/client/ui/main-menu.mjs | 69 ++++++++++++++++-------- src/client/widgets/scripts/script-vm.mjs | 51 +++++++++++++++--- 4 files changed, 119 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5672035d..ca2a837c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ - 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) - midi - add `no_auto_note_off` option diff --git a/resources/docs/docs/widgets/scripting.md b/resources/docs/docs/widgets/scripting.md index 4223a9ef..ee65c8a8 100644 --- a/resources/docs/docs/widgets/scripting.md +++ b/resources/docs/docs/widgets/scripting.md @@ -347,19 +347,39 @@ Scrollable panels expose their scroll position normalized between 0 and 1 with t ---- -#### `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 - 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. + ---- +#### `getToolbar(id)` +- `id` menu entry id (string) + +Returns `true` if the toolbar entry exists and is currently activated. + #### `openUrl(url)` - `url`: http(s) url diff --git a/src/client/ui/main-menu.mjs b/src/client/ui/main-menu.mjs index d746f662..5c9cce09 100644 --- a/src/client/ui/main-menu.mjs +++ b/src/client/ui/main-menu.mjs @@ -23,6 +23,7 @@ var menuEntries = [ { label: locales('session_new'), action: sessionManager.create.bind(sessionManager), + id: 'session-new' }, { separator: true @@ -31,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'), @@ -44,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 @@ -64,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 @@ -72,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' }, ] @@ -88,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'), @@ -103,7 +113,8 @@ var menuEntries = [ icon: 'sliders-h', message: locales('state_sendsuccess') }) - } + }, + id: 'state-send' }, { separator: true @@ -111,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 @@ -126,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' }, ] }, @@ -145,7 +161,8 @@ var menuEntries = [ if (editor.enabled) editor.disable() else editor.enable() }, - shortcut: 'mod + e' + shortcut: 'mod + e', + id: 'editor-enabled' }, { separator: true @@ -154,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 @@ -177,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' } ] }, @@ -196,7 +214,8 @@ var menuEntries = [ uiConsole.minimize() } }, - shortcut: 'mod + k' + shortcut: 'mod + k', + id: 'console-enabled' }, { separator: true @@ -204,7 +223,9 @@ var menuEntries = [ { label: locales('console_clear'), action: uiConsole.clear.bind(uiConsole), - shortcut: 'mod + l' + shortcut: 'mod + l', + id: 'console-clear' + }, ] }, @@ -218,14 +239,16 @@ 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' } ] @@ -264,7 +287,8 @@ if (device.is('mobile') || device.is('tablet')) { noSleep.disable() } } - } + }, + id: 'prevent-sleep' }) } else { @@ -274,7 +298,8 @@ if (device.is('mobile') || device.is('tablet')) { class: ()=>{return 'toggle ' + (VIRTUAL_KEYBOARD ? 'on' : 'off')}, action: ()=>{ setVIRTUAL_KEYBOARD(!VIRTUAL_KEYBOARD) - } + }, + id: 'virtual-keyboard' }) } diff --git a/src/client/widgets/scripts/script-vm.mjs b/src/client/widgets/scripts/script-vm.mjs index b0df5601..bd185b75 100644 --- a/src/client/widgets/scripts/script-vm.mjs +++ b/src/client/widgets/scripts/script-vm.mjs @@ -476,6 +476,19 @@ class ScriptVm extends Vm { } + + 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.sandbox.contentWindow.toolbar = (...args)=>{ this.checkContext('toolbar') @@ -486,16 +499,42 @@ 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.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.sandbox.contentWindow.openUrl = (url)=>{ this.checkContext('openUrl') @@ -591,8 +630,8 @@ class ScriptVm extends Vm { 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']) { + 'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'setFocus', 'unfocus' , 'setFocusable', 'setScroll', 'getScroll', 'toolbar', + 'getToolbar', 'openUrl', 'getVar', 'setVar', 'runAs', 'reload', 'Image', 'updateCanvas', 'getNavigator', 'browseFile']) { this.globals[imports] = true } From 3bba80d2f07ba2c53ea6952f5fd7e2b7a9aa4969 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 10 Dec 2025 17:21:51 +0100 Subject: [PATCH 008/163] client: ensure html no-cache policy --- src/html/client.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/html/client.html b/src/html/client.html index 24ae5908..10b17768 100644 --- a/src/html/client.html +++ b/src/html/client.html @@ -2,6 +2,7 @@ + From 45dd19494f9d2196929de1e1ea726d88faed70a6 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 10 Dec 2025 17:22:59 +0100 Subject: [PATCH 009/163] package: beta 7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ca1ae01b..95a7b532 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "open-stage-control", "productName": "Open Stage Control", "description": "Libre and modular OSC / MIDI controller", - "version": "1.30.0-beta6", + "version": "1.30.0-beta7", "author": { "name": "Jean-Emmanuel Doucet", "email": "jean-emmanuel@ammd.net" From fa15187c2c2d72f354198cd18e80db083dc73e41 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Thu, 11 Dec 2025 15:04:42 +0100 Subject: [PATCH 010/163] client: extra safe chunk loading before notifying server --- src/client/ipc/index.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/client/ipc/index.mjs b/src/client/ipc/index.mjs index b702384d..ae8d7c7b 100644 --- a/src/client/ipc/index.mjs +++ b/src/client/ipc/index.mjs @@ -9,6 +9,11 @@ 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) From a441bd628b21022be1493d55dd5642a77ef2422b Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Thu, 11 Dec 2025 19:56:06 +0100 Subject: [PATCH 011/163] iframe: remove useless error string from the past --- src/client/widgets/frames/frame.mjs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/client/widgets/frames/frame.mjs b/src/client/widgets/frames/frame.mjs index 7257bbf4..f0b72397 100644 --- a/src/client/widgets/frames/frame.mjs +++ b/src/client/widgets/frames/frame.mjs @@ -49,10 +49,6 @@ class Frame extends StaticProperties(Widget, {bypass: true}) { if (this.getProp('allow')) this.frame.setAttribute('allow', this.getProp('allow')) - this.errorText = html`${locales('iframe_unauthorized')}` - this.errorTextMounted = false - - } setValue(v, options={}) { @@ -61,16 +57,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) From 7cda8e4670767297ee3885924c05c79b3df45cc2 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 12 Dec 2025 13:22:28 +0100 Subject: [PATCH 012/163] package: raise min chromium version, to remove some polyfills and speed up loading time --- CHANGELOG.md | 1 + scripts/client.rollup.config.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca2a837c..52a1e417 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ - breaking change - dropped support for iOS 10.3 + - minimum chromium version requirement raised to 70 - macOS 11 (Big Sur) or above is now required (the node package will work on older system) - scrollbars are no longer emulated on iOS - scrollbar styling is now done using only the standard css scrollbar-* properties) to be more in line with system scrollbars in general diff --git a/scripts/client.rollup.config.js b/scripts/client.rollup.config.js index 2a708795..0b3c3953 100644 --- a/scripts/client.rollup.config.js +++ b/scripts/client.rollup.config.js @@ -42,9 +42,10 @@ module.exports = { presets: [[ '@babel/preset-env', { + debug: true, targets: { ios: '11', - chrome: '61' + chrome: '70' }, useBuiltIns: 'usage', corejs: 3, From 8737385a0e6492f9154050616a25cf0ff60c9326 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 12 Dec 2025 18:31:36 +0100 Subject: [PATCH 013/163] package: rm debug line --- scripts/client.rollup.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/client.rollup.config.js b/scripts/client.rollup.config.js index 0b3c3953..c23b26ae 100644 --- a/scripts/client.rollup.config.js +++ b/scripts/client.rollup.config.js @@ -42,7 +42,6 @@ module.exports = { presets: [[ '@babel/preset-env', { - debug: true, targets: { ios: '11', chrome: '70' From 58c1fc3c325232c314dcedcd05b64d530eb86c03 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 12 Dec 2025 18:32:31 +0100 Subject: [PATCH 014/163] client: init timeout should not be needed anymore; preload js modules asap if supported --- src/client/index.mjs | 20 ++++++++------------ src/html/client.html | 4 ++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/client/index.mjs b/src/client/index.mjs index fef5d21a..ff95ffbc 100644 --- a/src/client/index.mjs +++ b/src/client/index.mjs @@ -11,24 +11,20 @@ uiLoading(locales('loading_server')) function init() { - setTimeout(()=>{ - - ipc.init(()=>{ + ipc.init(()=>{ - document.title = TITLE + document.title = TITLE - ipc.send('open', {hotReload: backup.exists}) + ipc.send('open', {hotReload: backup.exists}) - window.onunload = ()=>{ - ipc.send('close') - } + window.onunload = ()=>{ + ipc.send('close') + } - backup.load() + backup.load() - }) - - }, 100) + }) } diff --git a/src/html/client.html b/src/html/client.html index 10b17768..135a6e23 100644 --- a/src/html/client.html +++ b/src/html/client.html @@ -17,6 +17,10 @@ + + + + From 934550c942548d122b89200f405a624d19b065c2 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sat, 13 Dec 2025 11:20:58 +0100 Subject: [PATCH 015/163] events: make sure event.offsetX/Y works the same for touch & mouse --- src/client/events/utils.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/events/utils.mjs b/src/client/events/utils.mjs index b673fe4d..03981977 100644 --- a/src/client/events/utils.mjs +++ b/src/client/events/utils.mjs @@ -66,7 +66,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 From b064b8f3a8510126fc31ed76afd606ecfebace1e Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sat, 13 Dec 2025 11:30:10 +0100 Subject: [PATCH 016/163] button: add onTouch --- CHANGELOG.md | 1 + src/client/widgets/basics/button.mjs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52a1e417..7b3b3962 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - 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 - editor - selecting a widget automatically shows it in the widget tree if it's not minimized diff --git a/src/client/widgets/basics/button.mjs b/src/client/widgets/basics/button.mjs index 22890c90..ae048a66 100644 --- a/src/client/widgets/basics/button.mjs +++ b/src/client/widgets/basics/button.mjs @@ -51,6 +51,9 @@ class Button extends Widget { 'From a script property, feedback messages can be simulated with:', '`set("widget_id", value, {external: true})`' ]}, + }, + scripting: { + onTouch: {type: 'script', value: '', editor:'javascript', help: ['Script executed when the panel is touched and released, and when the pointer moves when the widget is touched. See documentation.',]}, } }) @@ -84,6 +87,10 @@ 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 @@ -219,8 +226,24 @@ class Button extends Widget { } + if (this.getProp('onTouch')) { + 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() { From 9b58f4e365375da2100502fafdb3e3ec722414c4 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sat, 13 Dec 2025 11:44:35 +0100 Subject: [PATCH 017/163] server: more reliable url check for client assets requests --- src/server/node/server.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/server/node/server.mjs b/src/server/node/server.mjs index 395ff92e..ccf7c71a 100644 --- a/src/server/node/server.mjs +++ b/src/server/node/server.mjs @@ -187,8 +187,7 @@ class WebServer extends EventEmitter { } else { if ( - url.indexOf('/assets/') == 0 || - url.indexOf('/client/') == 0 + path.resolve(url).match(/^\/assets|client\//) ) { // osc asset files From d4cd2ec666c0040c880afbfd2ba34468f689c2eb Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sat, 13 Dec 2025 19:24:10 +0100 Subject: [PATCH 018/163] imports: use some black magic **** to please safari/ios and fix dynamic imports order --- src/client/events/utils.mjs | 5 +++-- src/client/stacktrace.mjs | 6 +----- src/client/widgets/common/widget.mjs | 9 +++------ src/client/widgets/scripts/script-vm.mjs | 5 +++-- src/client/widgets/vm.mjs | 5 +++-- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/client/events/utils.mjs b/src/client/events/utils.mjs index 03981977..d8a783a0 100644 --- a/src/client/events/utils.mjs +++ b/src/client/events/utils.mjs @@ -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' diff --git a/src/client/stacktrace.mjs b/src/client/stacktrace.mjs index e476d21a..274128fe 100644 --- a/src/client/stacktrace.mjs +++ b/src/client/stacktrace.mjs @@ -1,10 +1,6 @@ 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) { diff --git a/src/client/widgets/common/widget.mjs b/src/client/widgets/common/widget.mjs index 4e3c9b81..a2ceda03 100644 --- a/src/client/widgets/common/widget.mjs +++ b/src/client/widgets/common/widget.mjs @@ -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() { diff --git a/src/client/widgets/scripts/script-vm.mjs b/src/client/widgets/scripts/script-vm.mjs index bd185b75..b4dc8b39 100644 --- a/src/client/widgets/scripts/script-vm.mjs +++ b/src/client/widgets/scripts/script-vm.mjs @@ -9,9 +9,10 @@ import uiFilebrowser from '../../ui/ui-filebrowser.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 { diff --git a/src/client/widgets/vm.mjs b/src/client/widgets/vm.mjs index 82ad43ba..294b9e53 100644 --- a/src/client/widgets/vm.mjs +++ b/src/client/widgets/vm.mjs @@ -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 From 42b71ef6fc55b04e53e429ce5da6f6e795488e78 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sat, 13 Dec 2025 19:27:21 +0100 Subject: [PATCH 019/163] package: beta 8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 95a7b532..fbc63eb3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "open-stage-control", "productName": "Open Stage Control", "description": "Libre and modular OSC / MIDI controller", - "version": "1.30.0-beta7", + "version": "1.30.0-beta8", "author": { "name": "Jean-Emmanuel Doucet", "email": "jean-emmanuel@ammd.net" From 31f4119442d89dbb3aa541d547ab28ed515155bc Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sun, 14 Dec 2025 14:41:05 +0100 Subject: [PATCH 020/163] scripting: calling setFocus() without if now unfocuses active element --- CHANGELOG.md | 1 + resources/docs/docs/widgets/scripting.md | 2 +- src/client/widgets/scripts/script-vm.mjs | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b3b3962..2d48c2cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - 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 diff --git a/resources/docs/docs/widgets/scripting.md b/resources/docs/docs/widgets/scripting.md index ee65c8a8..45c94034 100644 --- a/resources/docs/docs/widgets/scripting.md +++ b/resources/docs/docs/widgets/scripting.md @@ -303,7 +303,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 diff --git a/src/client/widgets/scripts/script-vm.mjs b/src/client/widgets/scripts/script-vm.mjs index b4dc8b39..9f862b54 100644 --- a/src/client/widgets/scripts/script-vm.mjs +++ b/src/client/widgets/scripts/script-vm.mjs @@ -452,6 +452,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() From e4eae76bdfc17de16cf9c0b393b8874e082d550a Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 15 Dec 2025 09:41:17 +0100 Subject: [PATCH 021/163] midi: implement backend restart feature --- CHANGELOG.md | 2 + .../docs/docs/custom-module/custom-module.md | 4 ++ .../docs/docs/user-interface/launcher.md | 4 +- src/launcher/toolbar.mjs | 30 ++++++++--- src/server/electron/index.mjs | 7 ++- src/server/node/midi.mjs | 54 ++++++++++++++++--- src/server/node/osc/index.mjs | 1 + 7 files changed, 84 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d48c2cb..e994ee36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ - 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 diff --git a/resources/docs/docs/custom-module/custom-module.md b/resources/docs/docs/custom-module/custom-module.md index 3615e4fc..8bb3081f 100644 --- a/resources/docs/docs/custom-module/custom-module.md +++ b/resources/docs/docs/custom-module/custom-module.md @@ -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` diff --git a/resources/docs/docs/user-interface/launcher.md b/resources/docs/docs/user-interface/launcher.md index 304aa33b..87ba9d67 100644 --- a/resources/docs/docs/user-interface/launcher.md +++ b/resources/docs/docs/user-interface/launcher.md @@ -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 diff --git a/src/launcher/toolbar.mjs b/src/launcher/toolbar.mjs index 8c80fc9d..a6677b4d 100644 --- a/src/launcher/toolbar.mjs +++ b/src/launcher/toolbar.mjs @@ -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)}) }) diff --git a/src/server/electron/index.mjs b/src/server/electron/index.mjs index 567c34f8..f75f121d 100644 --- a/src/server/electron/index.mjs +++ b/src/server/electron/index.mjs @@ -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') diff --git a/src/server/node/midi.mjs b/src/server/node/midi.mjs index 6ff6048d..9cb7ee17 100644 --- a/src/server/node/midi.mjs +++ b/src/server/node/midi.mjs @@ -1,10 +1,11 @@ import {PythonShell} from 'python-shell' import fs from 'fs' import path from 'path' +import {EventEmitter} from 'events' import * as settings from './settings.mjs' -var scriptPath = __dirname.includes('server/node') ? +var scriptPath = __dirname.includes('server/node') ? path.resolve(__dirname, '../python') : // src folder structure path.resolve(__dirname, './python') // app folder structure with rollup chunking @@ -32,12 +33,33 @@ if (midiBinaries[process.arch] && midiBinaries[process.arch][process.platform]) } } -class MidiConverter { +class MidiConverter extends EventEmitter{ constructor() { + super() + if (expectMidiBinariesError) MidiConverter.midiBinariesError() + this.running = false + this.restarting = false + this.py = {} + + this.start() + + + process.on('message', (m) => { + if (m == 'midiRestart') { + this.restart() + } + }) + + } + + start() { + + if (this.running) return + this.py = new PythonShell('midi.py', Object.assign({ args: [ '--params', @@ -55,12 +77,32 @@ class MidiConverter { } }) - this.running = true this.py.childProcess.on('exit', (code)=>{ - if (code === null) console.error('(ERROR, MIDI) Midi bridge process crashed') + if (code === null && !this.restarting) console.error('(ERROR, MIDI) Midi bridge process crashed') this.running = false + this.emit('stopped') }) + this.running = true + + } + + stop() { + + if (this.running) this.py.childProcess.kill() + + } + + restart() { + + if (this.running) { + this.restarting = true + this.once('stopped', ()=>{ + this.start() + this.restarting = false + }) + this.stop() + } } send(data) { @@ -76,11 +118,7 @@ class MidiConverter { } - stop() { - this.py.childProcess.kill() - - } init(receiveOsc) { diff --git a/src/server/node/osc/index.mjs b/src/server/node/osc/index.mjs index a3f27274..89870658 100644 --- a/src/server/node/osc/index.mjs +++ b/src/server/node/osc/index.mjs @@ -19,6 +19,7 @@ export default class OscServer { this.customModuleEventEmitter = new EventEmitter() this.customModule = settings.read('custom-module') ? new CustomModule(settings.read('custom-module'), { app: this.customModuleEventEmitter, + restartMidiBackend: ()=>{if (this.midiServer) this.midiServer.restart()}, tcpServer: this.oscTCPServer, sendOsc: this.sendOsc.bind(this), receiveOsc: this.receiveOsc.bind(this), From ce48146bdb90c4fbf07a0f869cd99cf150d82a1c Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 15 Dec 2025 09:41:33 +0100 Subject: [PATCH 022/163] launcher: fix regression --- src/client/events/utils.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/events/utils.mjs b/src/client/events/utils.mjs index d8a783a0..850191a7 100644 --- a/src/client/events/utils.mjs +++ b/src/client/events/utils.mjs @@ -13,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 { From 55d5f440be1b169451d06e2c4b85b8ecee60a9cb Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 15 Dec 2025 13:00:36 +0100 Subject: [PATCH 023/163] ipc: dedupe 'connected' response to 'open' request (no functionnal effect) --- src/server/node/ipc/callbacks.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/node/ipc/callbacks.mjs b/src/server/node/ipc/callbacks.mjs index 2d5ce884..2376fee3 100644 --- a/src/server/node/ipc/callbacks.mjs +++ b/src/server/node/ipc/callbacks.mjs @@ -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') From 8af432933cd4f945f5272cc0975eb7e5f71b8fb2 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 16 Dec 2025 10:30:12 +0100 Subject: [PATCH 024/163] ipc: fix an old regression preventing uuid from being reused --- src/client/ipc/index.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/ipc/index.mjs b/src/client/ipc/index.mjs index ae8d7c7b..9a3d4275 100644 --- a/src/client/ipc/index.mjs +++ b/src/client/ipc/index.mjs @@ -16,7 +16,7 @@ var loadDeps = (async()=>{ 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 { From 3777b1fcbbddebb6b791daa989e6e3fac34e47f1 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 16 Dec 2025 12:16:20 +0100 Subject: [PATCH 025/163] client: make app more resilient to storage access denial --- src/client/index.mjs | 5 +- src/client/managers/cache.mjs | 22 +++++-- src/client/ui/ui-code-editor.mjs | 5 +- src/client/widgets/scripts/script-vm.mjs | 75 ++++++++++-------------- src/client/widgets/vm.mjs | 14 +++-- 5 files changed, 67 insertions(+), 54 deletions(-) diff --git a/src/client/index.mjs b/src/client/index.mjs index ff95ffbc..e9599d3a 100644 --- a/src/client/index.mjs +++ b/src/client/index.mjs @@ -29,7 +29,10 @@ function init() { } if (document.requestStorageAccess) { - document.requestStorageAccess().then(init, init) + document.requestStorageAccess().then(init, ()=>{ + console.error('Could not obtain storage access, the app might not work correctly unless the browser\'s settings are updated') + init() + }) } else { init() } diff --git a/src/client/managers/cache.mjs b/src/client/managers/cache.mjs index 0d4a2b1e..b28ae0a7 100644 --- a/src/client/managers/cache.mjs +++ b/src/client/managers/cache.mjs @@ -4,17 +4,31 @@ 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'}`) + } - 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'}`) + return null + } } diff --git a/src/client/ui/ui-code-editor.mjs b/src/client/ui/ui-code-editor.mjs index ceac60c2..b0f91a5d 100644 --- a/src/client/ui/ui-code-editor.mjs +++ b/src/client/ui/ui-code-editor.mjs @@ -207,6 +207,9 @@ class CodeEditor { if (this.language === 'javascript') { let globals = {} + for (var k in scriptGlobals) { + globals[k] = true + } if (this.name === 'onKeyboard') { globals = {type: true, key: true, code: true, ctrl: true, shift: true, alt: true, meta: true} } else if (this.name === 'onCreate') { @@ -230,7 +233,7 @@ class CodeEditor { globals.this = false if (this.syntaxChecker !== false) editor.getSession().$worker.send('changeOptions', [{ - globals: {...scriptGlobals, ...globals} + globals: globals }]) } diff --git a/src/client/widgets/scripts/script-vm.mjs b/src/client/widgets/scripts/script-vm.mjs index 9f862b54..4170bedc 100644 --- a/src/client/widgets/scripts/script-vm.mjs +++ b/src/client/widgets/scripts/script-vm.mjs @@ -53,9 +53,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') @@ -102,7 +100,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.setVar = (id, name, value)=>{ + this.globals.setVar = (id, name, value)=>{ this.checkContext('setVar') @@ -137,7 +135,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.send = (target, address, ...args)=>{ + this.globals.send = (target, address, ...args)=>{ this.checkContext('send') @@ -165,7 +163,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.get = (id)=>{ + this.globals.get = (id)=>{ this.checkContext('get') @@ -184,7 +182,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.getVar = (id, name)=>{ + this.globals.getVar = (id, name)=>{ this.checkContext('getVar') @@ -198,7 +196,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.getProp = (id, prop)=>{ + this.globals.getProp = (id, prop)=>{ this.checkContext('getProp') @@ -213,7 +211,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.updateProp = (id, prop)=>{ + this.globals.updateProp = (id, prop)=>{ this.checkContext('updateProp') @@ -228,7 +226,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.updateCanvas = (id)=>{ + this.globals.updateCanvas = (id)=>{ this.checkContext('updateCanvas') @@ -241,7 +239,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.getIndex = (id = 'this')=>{ + this.globals.getIndex = (id = 'this')=>{ this.checkContext('getIndex') @@ -250,7 +248,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.getScroll = (id)=>{ + this.globals.getScroll = (id)=>{ this.checkContext('getScroll') @@ -266,7 +264,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.setScroll = (id, x, y)=>{ + this.globals.setScroll = (id, x, y)=>{ this.checkContext('setScroll') @@ -280,7 +278,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.httpGet = (url, callback)=>{ + this.globals.httpGet = (url, callback)=>{ this.checkContext('httpGet') @@ -301,7 +299,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.stateGet = (filter)=>{ + this.globals.stateGet = (filter)=>{ this.checkContext('stateGet') @@ -321,7 +319,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.stateSet = (state, extraOptions = {})=>{ + this.globals.stateSet = (state, extraOptions = {})=>{ this.checkContext('stateSet') @@ -331,7 +329,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.storage = { + this.globals.storage = { setItem: (k, v)=>{ this.checkContext('storage.setItem') @@ -352,7 +350,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.setTimeout = (id, callback, timeout)=>{ + this.globals.setTimeout = (id, callback, timeout)=>{ this.checkContext('setTimeout') @@ -386,7 +384,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.clearTimeout = (id)=>{ + this.globals.clearTimeout = (id)=>{ this.checkContext('clearTimeout') @@ -397,7 +395,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.setInterval = (id, callback, timeout)=>{ + this.globals.setInterval = (id, callback, timeout)=>{ this.checkContext('setInterval') @@ -430,7 +428,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.clearInterval = (id)=>{ + this.globals.clearInterval = (id)=>{ this.checkContext('clearInterval') @@ -442,7 +440,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.setFocus = (id)=>{ + this.globals.setFocus = (id)=>{ this.checkContext('setFocus') @@ -461,7 +459,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.unfocus = ()=>{ + this.globals.unfocus = ()=>{ this.checkContext('unfocus') @@ -471,7 +469,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.setFocusable = (focusable)=>{ + this.globals.setFocusable = (focusable)=>{ this.checkContext('setFocusable') setFOCUSABLE(!!focusable) @@ -492,7 +490,7 @@ class ScriptVm extends Vm { } } - this.sandbox.contentWindow.toolbar = (...args)=>{ + this.globals.toolbar = (...args)=>{ this.checkContext('toolbar') @@ -524,7 +522,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.getToolbar = (id)=>{ + this.globals.getToolbar = (id)=>{ this.checkContext('toolbar') @@ -538,7 +536,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.openUrl = (url)=>{ + this.globals.openUrl = (url)=>{ this.checkContext('openUrl') @@ -548,7 +546,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.runAs = (id, callback)=>{ + this.globals.runAs = (id, callback)=>{ this.checkContext('runAs') @@ -569,7 +567,7 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.reload = (keepState = true)=>{ + this.globals.reload = (keepState = true)=>{ this.checkContext('reload') @@ -586,16 +584,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 @@ -629,18 +627,7 @@ class ScriptVm extends Vm { } } - - this.globals = {} - - for (var imports of ['set', 'get', 'getProp', 'getIndex', 'updateProp', 'send', 'httpGet', 'stateGet', 'stateSet', 'storage', - 'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'setFocus', 'unfocus' , 'setFocusable', 'setScroll', 'getScroll', 'toolbar', - 'getToolbar', 'openUrl', 'getVar', 'setVar', 'runAs', 'reload', 'Image', 'updateCanvas', 'getNavigator', 'browseFile']) { - this.globals[imports] = true - } - - for (var k in this.sandbox.contentWindow) { - if (window[k] === undefined) this.globals[k] = true - } + super.registerGlobals() } diff --git a/src/client/widgets/vm.mjs b/src/client/widgets/vm.mjs index 294b9e53..4a8b2cbd 100644 --- a/src/client/widgets/vm.mjs +++ b/src/client/widgets/vm.mjs @@ -52,6 +52,7 @@ class Vm { this.sandbox.contentWindow.document.close() // global context + this.globals = {} this.registerGlobals() // detach sandbox @@ -74,7 +75,7 @@ class Vm { registerGlobals() { - this.sandbox.contentWindow.console = { + this.globals.console = { ...console, log: (...msg)=>{ msg = msg.map(m => typeof m == 'object' ? JSON.stringify(m) : m) @@ -82,11 +83,16 @@ class Vm { } } - this.sandbox.contentWindow.setTimeout = - this.sandbox.contentWindow.setInterval = ()=>{ + this.globals.setTimeout = + this.globals.setInterval = ()=>{ throw 'setTimeout and setInterval can\'t be used in the JS sandbox' } - this.sandbox.contentWindow.globals = globals + + this.globals.globals = globals + + for (var k in this.globals) { + this.sandbox.contentWindow[k] = this.globals[k] + } } From b27d38132451fd2972af77343b336b00828566f2 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 16 Dec 2025 12:21:52 +0100 Subject: [PATCH 026/163] client: better storage access error log --- src/client/managers/cache.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/client/managers/cache.mjs b/src/client/managers/cache.mjs index b28ae0a7..1d1cee77 100644 --- a/src/client/managers/cache.mjs +++ b/src/client/managers/cache.mjs @@ -11,7 +11,8 @@ class Cache { storage.setItem(keyPrefix + key, JSON.stringify(value)) } catch(e){ - console.error(`Could not write to ${persistent ? 'localStorage' : 'sessionStorage'}`) + console.error(`Could not write to ${persistent ? 'localStorage' : 'sessionStorage'}: ${e}`) + console.debug(e) } @@ -26,7 +27,8 @@ class Cache { return JSON.parse(storage.getItem(keyPrefix + key)) } catch(e){ - console.error(`Could not read from ${persistent ? 'localStorage' : 'sessionStorage'}`) + console.error(`Could not read from ${persistent ? 'localStorage' : 'sessionStorage'}: ${e}`) + console.debug(e) return null } From 37b305eaea97eabe79a1dd507e8ed9e37b42e555 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 16 Dec 2025 12:24:32 +0100 Subject: [PATCH 027/163] client: delay access storage denial error log --- src/client/index.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/index.mjs b/src/client/index.mjs index e9599d3a..c1d5753c 100644 --- a/src/client/index.mjs +++ b/src/client/index.mjs @@ -30,8 +30,10 @@ function init() { if (document.requestStorageAccess) { document.requestStorageAccess().then(init, ()=>{ - console.error('Could not obtain storage access, the app might not work correctly unless the browser\'s settings are updated') init() + setTimeout(()=>{ + console.error('Could not obtain storage access, the app might not work correctly unless the browser\'s settings are updated') + }, 1000) }) } else { init() From 422c84d42e810c52ac5367a48b94ba619b3e53b9 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 16 Dec 2025 12:34:09 +0100 Subject: [PATCH 028/163] package: beta 9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fbc63eb3..f01c25e6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "open-stage-control", "productName": "Open Stage Control", "description": "Libre and modular OSC / MIDI controller", - "version": "1.30.0-beta8", + "version": "1.30.0-beta9", "author": { "name": "Jean-Emmanuel Doucet", "email": "jean-emmanuel@ammd.net" From 6bd129395934222c19707b5b962a3177fb38c1d6 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 16 Dec 2025 12:36:23 +0100 Subject: [PATCH 029/163] log: update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e994ee36..7fd92d82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,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 From dc85311b5431f2eecd9a03c7cca935084719e151 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 17 Dec 2025 10:03:34 +0100 Subject: [PATCH 030/163] deps: ditch osc.js fork --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f01c25e6..11645825 100644 --- a/package.json +++ b/package.json @@ -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", From 618fb3b01fe75e42e4ee47bbfb35a2f8199bc9da Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 17 Dec 2025 11:16:37 +0100 Subject: [PATCH 031/163] docs: framagit migration --- resources/docs/download.md | 72 ++++++---------------------------- resources/mkdocs.yml | 5 +++ src/docs/client-shim.mjs | 2 + src/docs/widgets-reference.mjs | 6 +-- 4 files changed, 23 insertions(+), 62 deletions(-) diff --git a/resources/docs/download.md b/resources/docs/download.md index 58b5fb88..5b6b50c7 100644 --- a/resources/docs/download.md +++ b/resources/docs/download.md @@ -3,66 +3,20 @@ !!! tip "" [*Click here*](/docs/getting-started/introduction/#installation) to read the installation guide. - Open Stage Control + + Open Stage Control v{{config.latest_release}} + -
Loading assets...
+
    +
  • GNU/Linux RPM (64-bit)
  • +
  • GNU/Linux Debian (64-bit)
  • +
  • GNU/Linux (64-bit)
  • +
  • Node.js
  • +
  • MacOS x64
  • +
  • MacOS arm64
  • +
  • Windows (64-bit)
  • - +