From 0666d4677e599bdae084c402ae0170659171528d Mon Sep 17 00:00:00 2001 From: wicast Date: Tue, 8 Jul 2025 11:00:47 +0800 Subject: [PATCH 1/7] feat: add tray icon --- src/server/index.js | 10 +++++++ src/server/tray.js | 69 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 src/server/tray.js diff --git a/src/server/index.js b/src/server/index.js index ed1ef705..50e47f7b 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -5,6 +5,7 @@ var dev = process.argv[0].includes('node_modules'), docsServer, app = null, launcher = null, + tray = null, clientWindows = [], serverProcess = null, node = false @@ -221,6 +222,15 @@ function startLauncher() { process.stderr.write = stderrWrite if (process.log) process.log = processLog }) + + tray = require('./tray')({ + window: launcher, + openClient: openClient, + app: app, + startServer: startServerProcess, + stopServer: stopServerProcess + }) + }) let processLog = process.log, diff --git a/src/server/tray.js b/src/server/tray.js new file mode 100644 index 00000000..cca4275c --- /dev/null +++ b/src/server/tray.js @@ -0,0 +1,69 @@ +var { Menu, Tray, ipcMain } = require('electron') + +var tray = null, + contextMenu = null, + hideInTray = false, + isServerRunning = false + +module.exports = function (options = {}) { + + ipcMain.on('start', function (e, options) { + isServerRunning = true + resetMenu(isServerRunning) + }) + + ipcMain.on('stop', function (e, options) { + isServerRunning = false + resetMenu(isServerRunning) + }) + + tray = new Tray(__dirname + '/../assets/logo.png') + contextMenu = Menu.buildFromTemplate([ + { + label: 'Open/Hide', click: () => { + if (hideInTray) { + options.window.show() + hideInTray = false + } else { + options.window.hide() + hideInTray = true + } + } + }, + { + label: 'Start/Stop', + click: () => { + console.log(isServerRunning) + if (isServerRunning) { + ipcMain.emit('stop'); + } else { + ipcMain.emit('start'); + } + } + }, + { + label: 'New Window', click: () => { + if (isServerRunning) { + options.openClient() + } + }, + enabled: isServerRunning + }, + { type: 'separator' }, + { label: 'Quit', click: () => { void options.app.quit(); } }, + ]); + tray.setContextMenu(contextMenu) + tray.setToolTip('Open Stage Control') + + return tray + +} + +function resetMenu(isServerRunning) { + contextMenu.items.forEach(item => { + if (item.label === 'New Window') { + item.enabled = isServerRunning + } + }) + tray.setContextMenu(contextMenu) +} \ No newline at end of file From a89f24d2f138c661520688727449f73aa51df9fe Mon Sep 17 00:00:00 2001 From: wicast Date: Tue, 8 Jul 2025 11:53:37 +0800 Subject: [PATCH 2/7] fix: macos tray icon size --- resources/images/logo_16x16.png | Bin 0 -> 931 bytes scripts/copy-assets.js | 4 ++++ src/server/tray.js | 7 +++++-- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 resources/images/logo_16x16.png diff --git a/resources/images/logo_16x16.png b/resources/images/logo_16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..d6670a2ac34cfa2d5830bb546baad96b4dd95e9e GIT binary patch literal 931 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Lb6AYF9SoB8UsT^3j@P1pisjL z28L1t28LG&3=CE?7#PG0=IjczVPIg?3GfMVRaDhhR0AR%MHMXtC3Sfvbp>S&AgQRT zqoAw_6bEt@R5XFgAf%F-E=UUysc3<;fTXmbNJUG}*3TiK(Ys`xo~^&Sp^aDZ+?2(S z6Xx6u@7|xXk&#nhy)dK=QZLsi$@z%fKYSsi4u zsLzLm>#t$pLB z0MG8Ij4hS^nwe8vxLF-jS;KC9`(N)OJ|q9VP4PTSW`+YBVirc|6zVX~JXMprcH!&Z zuUzrxDhiW}SKrJsy?xs{wDDQx;>&kUeJHJ8;Bot1NvRH#5JNMC9x#cD!C{XNHG{0 z7@6uCnClu?gculG8CY5wT51~@SQ!|kU2U&N(U6;;l9^VCTZ4Fq{b8U64Y&;@nYpRO zC5gEOXnITxt&EHzmYmEfJr2|(3DOgspH@mmtT}V`<;yx PP!WTttDnm{r-UW|_M$kQ literal 0 HcmV?d00001 diff --git a/scripts/copy-assets.js b/scripts/copy-assets.js index 73ad3e70..65c2df23 100644 --- a/scripts/copy-assets.js +++ b/scripts/copy-assets.js @@ -14,6 +14,10 @@ var cpr = require('cpr'), ['../node_modules/ace-builds/src-min/worker-javascript.js', '../app/client/workers/worker-javascript.js'], ] +if (process.platform === 'darwin') { + files.push(['../resources/images/logo_16x16.png', '../app/assets/logo_16x16.png']) +} + for (var i in files) { cpr(...files[i].map(f => path.resolve(__dirname + '/' + f)), { overwrite: true diff --git a/src/server/tray.js b/src/server/tray.js index cca4275c..79e63542 100644 --- a/src/server/tray.js +++ b/src/server/tray.js @@ -17,7 +17,11 @@ module.exports = function (options = {}) { resetMenu(isServerRunning) }) - tray = new Tray(__dirname + '/../assets/logo.png') + var icon = __dirname + '/../assets/logo.png' + if (process.platform === 'darwin') { + var icon = __dirname + '/../assets/logo_16x16.png' + } + tray = new Tray(icon) contextMenu = Menu.buildFromTemplate([ { label: 'Open/Hide', click: () => { @@ -33,7 +37,6 @@ module.exports = function (options = {}) { { label: 'Start/Stop', click: () => { - console.log(isServerRunning) if (isServerRunning) { ipcMain.emit('stop'); } else { From b23c062e07f04a3e7ea0d0af0cd0309429356d48 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 27 Jun 2025 09:55:19 +0200 Subject: [PATCH 3/7] docs: update --- README.md | 2 +- resources/docs/docs/credits.md | 2 +- .../docs/docs/widgets/properties-reference.md | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 280b04ee..cecaf628 100644 --- a/README.md +++ b/README.md @@ -11,5 +11,5 @@ Open Stage Control ---- -Copyleft © Jean-Emmanuel Doucet @ [AMMD](http://ammd.net) 2014-2022. +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. diff --git a/resources/docs/docs/credits.md b/resources/docs/docs/credits.md index bbdeb473..73425ad7 100644 --- a/resources/docs/docs/credits.md +++ b/resources/docs/docs/credits.md @@ -1,6 +1,6 @@ ## License -Copyleft © Jean-Emmanuel Doucet @ [AMMD](http://ammd.net) 2014-2022. +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. ## Dependencies diff --git a/resources/docs/docs/widgets/properties-reference.md b/resources/docs/docs/widgets/properties-reference.md index 7f997a2c..9898b64f 100644 --- a/resources/docs/docs/widgets/properties-reference.md +++ b/resources/docs/docs/widgets/properties-reference.md @@ -776,10 +776,12 @@ | --- | --- | --- | --- | |
snap#
| `boolean` | false | By default, the points are dragged from their initial position.

If set to `true`, touching anywhere on the widget's surface will make them snap to the touching coordinates | |
spring#
| `boolean` | false | When set to `true`, the widget will go back to its default value when released | - |
rangeX#
| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the x axis | - |
rangeY#
| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis | + |
rangeX#
| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the x axis (see fader) | + |
rangeY#
| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis (see fader) | |
logScaleX#
| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale. | |
logScaleY#
| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale. | + |
stepsX#
| `number`|
`array`|
`string` | false | Defines `steps` for the x axis (see fader) | + |
stepsY#
| `number`|
`array`|
`string` | false | Defines `steps` for the x axis (see fader) | |
axisLock#
| `string` | "" | 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.

Choices: ``, `x`, `y`, `auto` | |
doubleTap#
| `boolean`|
`string` | false | Set to `true` to make the knob reset to its `default` value when receiving a double tap.

Can be an osc address, in which case the widget will just send an osc message with no value (but `preArgs` included).

If set to "script", `onTouch` will be called with `event.type` set to `doubleTap`.

Choices: `false`, `true`, `script` | |
sensitivity#
| `number` | 1 | Defines the pad's sensitivity when `snap` is `false` | @@ -830,10 +832,12 @@ |
pointsAttr#
| `object` | [] | Defines per-point properties that are otherwise inherited from the multixy. Must be an array of objects (one per point) that may contain the following keys:
- visible (visibility and interactability)
- colorFill (background color)
- colorStroke (outline color)
- colorText (label color)
- color (shorthand for colorFill and colorStroke)
- alphaFillOn (background opacity)
- pointSize
- label | |
snap#
| `boolean` | false | By default, the points are dragged from their initial position.

If set to `true`, touching anywhere on the widget's surface will make them snap to the touching coordinates | |
spring#
| `boolean` | false | When set to `true`, the widget will go back to its default value when released | - |
rangeX#
| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the x axis | - |
rangeY#
| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis | + |
rangeX#
| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the x axis (see fader) | + |
rangeY#
| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis (see fader) | |
logScaleX#
| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale. | |
logScaleY#
| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale. | + |
stepsX#
| `number`|
`array`|
`string` | false | Defines `steps` for the x axis (see fader) | + |
stepsY#
| `number`|
`array`|
`string` | false | Defines `steps` for the x axis (see fader) | |
axisLock#
| `string` | "" | Restrict movements to one of the axes only.

When left empty, holding `Shift` while dragging will lock the pad according the first movement. `auto` will do the opposite.

Choices: ``, `x`, `y`, `auto` | |
doubleTap#
| `boolean`|
`string` | false | Set to `true` to make the knob reset to its `default` value when receiving a double tap.

Can be an osc address, in which case the widget will just send an osc message with no value (but `preArgs` included).

If set to "script", `onTouch` will be called with `event.type` set to `doubleTap`.

Choices: `false`, `true`, `script` | |
sensitivity#
| `number` | 1 | Defines the pad's sensitivity when `snap` is `false` | @@ -859,7 +863,7 @@ | property | type |default | description | | --- | --- | --- | --- | |
valueLength#
| `number` | 1 | Defines the number of values accepted by the widget (minimum 1). Incoming messages that don't comply will be ignored

When calling `set()` from a script, submitted value should be an array only if `valueLength` is greater than 1. | - |
autoClear#
| `boolean` | true | If set to `false`, the canvas context won't be cleared automatically and `ctx.clear()` will need to be called in `onDraw`. | + |
autoClear#
| `boolean` | true | If set to `false`, the canvas context won't be cleared automatically and `ctx.clearRect()` will need to be called in `onDraw`. | |
continuous#
| `boolean`|
`number` | false | If set to `true`, `onDraw` will be called at each frame, otherwise it will be called only when the widget is touched and when it receives a value.

Can be a number between 1 and 60 to specify the framerate (default: 30 fps). | === "scripting" From 55618fe5c37e1b75c93ede40e749381ace161045 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 27 Jun 2025 09:55:32 +0200 Subject: [PATCH 4/7] package: 1.29.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fa6a7cf4..b819dbcb 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.29.5", + "version": "1.29.6", "author": { "name": "Jean-Emmanuel Doucet", "email": "jean-emmanuel@ammd.net" From bde7039d257abef965ceb74720b52c90026dacd1 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 8 Jul 2025 09:43:48 +0200 Subject: [PATCH 5/7] build: use sass instead of node-sass to fix mac builds --- package.json | 2 +- scripts/build-css.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index b819dbcb..d60c7d7d 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ "nanomorph": "5.4.3", "node-forge": "1.3.1", "node-mouse": "0.0.2", - "node-sass": "9.0.0", "nodemon": "2.0.16", "nosleep.js": "0.12.0", "open": "8.4.0", @@ -67,6 +66,7 @@ "qrcode": "1.5.1", "replacestream": "4.0.3", "sanitize-html": "1.27.5", + "sass": "1.89.2", "scope-css": "1.2.1", "screenfull": "5.2.0", "semver": "7.3.7", diff --git a/scripts/build-css.js b/scripts/build-css.js index 0e697159..c828cdb5 100644 --- a/scripts/build-css.js +++ b/scripts/build-css.js @@ -1,4 +1,4 @@ -var sass = require('node-sass'), +var sass = require('sass'), path = require('path'), fs = require('fs') @@ -10,7 +10,8 @@ fs.readdirSync(indir + '/themes/').forEach(file => { if (file.includes('.scss') && file !== 'default.scss') { let result = sass.renderSync({ file: indir + '/themes/' + file, - outputStyle: 'compressed' + outputStyle: 'compressed', + silenceDeprecations: ['mixed-decls', 'slash-div', 'import', 'legacy-js-api'] }) fs.writeFileSync(outdir + '/themes/' + file.split('/').pop().replace('scss', 'css'), result.css) @@ -22,7 +23,8 @@ var result = sass.renderSync({ file: indir + '/index.scss', outFile: outdir + '/open-stage-control.css', outputStyle: 'compressed', - sourceMap: true + sourceMap: true, + silenceDeprecations: ['mixed-decls', 'slash-div', 'import', 'legacy-js-api'] }) fs.writeFileSync(outdir + '/open-stage-control.css', result.css) From aa2d5029bec0960d8eae3387ad777cd319528ea5 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 8 Jul 2025 09:44:50 +0200 Subject: [PATCH 6/7] package-lock: update --- package-lock.json | 399 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 388 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index f0a6aed4..4a480a40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "open-stage-control", - "version": "1.29.1", + "version": "1.29.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "open-stage-control", - "version": "1.29.1", + "version": "1.29.6", "hasInstallScript": true, "license": "GPL-3.0", "dependencies": { @@ -57,6 +57,7 @@ "qrcode": "1.5.1", "replacestream": "4.0.3", "sanitize-html": "1.27.5", + "sass": "^1.89.2", "scope-css": "1.2.1", "screenfull": "5.2.0", "semver": "7.3.7", @@ -3011,6 +3012,300 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/@parcel/watcher": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz", + "integrity": "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==", + "hasInstallScript": true, + "optional": true, + "dependencies": { + "detect-libc": "^1.0.3", + "is-glob": "^4.0.3", + "micromatch": "^4.0.5", + "node-addon-api": "^7.0.0" + }, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "@parcel/watcher-android-arm64": "2.5.1", + "@parcel/watcher-darwin-arm64": "2.5.1", + "@parcel/watcher-darwin-x64": "2.5.1", + "@parcel/watcher-freebsd-x64": "2.5.1", + "@parcel/watcher-linux-arm-glibc": "2.5.1", + "@parcel/watcher-linux-arm-musl": "2.5.1", + "@parcel/watcher-linux-arm64-glibc": "2.5.1", + "@parcel/watcher-linux-arm64-musl": "2.5.1", + "@parcel/watcher-linux-x64-glibc": "2.5.1", + "@parcel/watcher-linux-x64-musl": "2.5.1", + "@parcel/watcher-win32-arm64": "2.5.1", + "@parcel/watcher-win32-ia32": "2.5.1", + "@parcel/watcher-win32-x64": "2.5.1" + } + }, + "node_modules/@parcel/watcher-android-arm64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.1.tgz", + "integrity": "sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-arm64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.1.tgz", + "integrity": "sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-x64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.1.tgz", + "integrity": "sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-freebsd-x64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.1.tgz", + "integrity": "sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-glibc": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.1.tgz", + "integrity": "sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-musl": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.1.tgz", + "integrity": "sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-glibc": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.1.tgz", + "integrity": "sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-musl": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.1.tgz", + "integrity": "sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-glibc": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.1.tgz", + "integrity": "sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-musl": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.1.tgz", + "integrity": "sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-arm64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.1.tgz", + "integrity": "sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-ia32": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.1.tgz", + "integrity": "sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-x64": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.1.tgz", + "integrity": "sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher/node_modules/detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==", + "optional": true, + "bin": { + "detect-libc": "bin/detect-libc.js" + }, + "engines": { + "node": ">=0.10" + } + }, "node_modules/@serialport/binding-abstract": { "version": "9.2.4", "license": "MIT", @@ -3907,10 +4202,11 @@ "license": "MIT" }, "node_modules/braces": { - "version": "3.0.2", - "license": "MIT", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -6168,8 +6464,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "license": "MIT", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -6964,6 +7261,11 @@ "version": "1.0.1", "license": "ISC" }, + "node_modules/immutable": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.3.tgz", + "integrity": "sha512-+chQdDfvscSF1SJqv2gn4SRO2ZyS3xL3r7IW/wWEEzrzLisnOlKiQu5ytC/BVNcS15C39WT2Hg/bjKjDMcu+zg==" + }, "node_modules/import-fresh": { "version": "3.3.0", "license": "MIT", @@ -7202,7 +7504,8 @@ }, "node_modules/is-number": { "version": "7.0.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "engines": { "node": ">=0.12.0" } @@ -7867,6 +8170,19 @@ "source-map": "^0.5.6" } }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "optional": true, + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, "node_modules/miller-rabin": { "version": "4.0.1", "license": "MIT", @@ -8259,6 +8575,12 @@ "node": ">=10" } }, + "node_modules/node-addon-api": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", + "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==", + "optional": true + }, "node_modules/node-forge": { "version": "1.3.1", "license": "(BSD-3-Clause OR GPL-2.0)", @@ -9219,8 +9541,9 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "2.2.3", - "license": "MIT", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "engines": { "node": ">=8.6" }, @@ -9919,6 +10242,25 @@ "postcss": "^7.0.27" } }, + "node_modules/sass": { + "version": "1.89.2", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.89.2.tgz", + "integrity": "sha512-xCmtksBKd/jdJ9Bt9p7nPKiuqrlBMBuuGkQlkhZjjQk3Ty48lv93k5Dq6OPkKt4XwxDJ7tvlfrTa1MPA9bf+QA==", + "dependencies": { + "chokidar": "^4.0.0", + "immutable": "^5.0.2", + "source-map-js": ">=0.6.2 <2.0.0" + }, + "bin": { + "sass": "sass.js" + }, + "engines": { + "node": ">=14.0.0" + }, + "optionalDependencies": { + "@parcel/watcher": "^2.4.1" + } + }, "node_modules/sass-graph": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-4.0.1.tgz", @@ -9936,6 +10278,32 @@ "node": ">=12" } }, + "node_modules/sass/node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/sass/node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/scope-css": { "version": "1.2.1", "license": "MIT", @@ -10261,6 +10629,14 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-support": { "version": "0.5.21", "license": "MIT", @@ -10782,7 +11158,8 @@ }, "node_modules/to-regex-range": { "version": "5.0.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dependencies": { "is-number": "^7.0.0" }, From a5d5586dc367f9d8be3b193b392c414c74a43297 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 8 Jul 2025 16:58:02 +0200 Subject: [PATCH 7/7] tray: code lint, retina icon for mac, keep alive launcher and tray when closing if there's a client window --- .../images/{logo_16x16.png => logo_tray.png} | Bin resources/images/logo_tray@x2.png | Bin 0 -> 1688 bytes scripts/copy-assets.js | 2 + src/server/index.js | 24 +++- src/server/tray.js | 111 ++++++++++-------- 5 files changed, 85 insertions(+), 52 deletions(-) rename resources/images/{logo_16x16.png => logo_tray.png} (100%) create mode 100644 resources/images/logo_tray@x2.png diff --git a/resources/images/logo_16x16.png b/resources/images/logo_tray.png similarity index 100% rename from resources/images/logo_16x16.png rename to resources/images/logo_tray.png diff --git a/resources/images/logo_tray@x2.png b/resources/images/logo_tray@x2.png new file mode 100644 index 0000000000000000000000000000000000000000..c3c4f0c64225c3409ebabefe20c365e491489eca GIT binary patch literal 1688 zcmV;J250$+P)b%78FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H11|>;E zK~z|Ut(RSF99I>`fA`Mr&U(Ec_S!D79mny3x z@-VwoyLRGDn*YgzkvoZbzs-q1diqs}RHiP-K8BD9#EY z2Bj(-Pp8vHCHsnv2qY5Sn;l{AQ-W`xsI7=C%%k{CQ7az2df~$KT@mQ*?e$%`Hunth z3{bW9OF>o5rvND2m_;dPy>0Rc@nUOJ{m+MnhKdyvXh|mHev`L=U1gc(53;Fy7mc6Z zMQ!^I0@ZPZlmIBl!CabW{?Zv{&YfUp_yl%w)gKtJ4f)k8S4I{#B+${(l~9^|7w9Z| zx@G5=*w+6v!PtH4Ik5)j;yjmzjxhfIZ&9{g7N@1dp0Tmi*ewZ^JU0?;=tV=D4I5;q1}cn#Yu+>!B}PrdAUe)i~orcND0IS%>E6aboE$6p=wKCxt=PdY;Nl_i_D zyLHDlmYF>H$BK=w3cGR`Ir;)qr;d5+#^QA-RZ2Y^_vBL1CvoWZD3!7{bLl_WRz`YJQxeiGY|a z3%%@wmG%1`LaZy5Kn@_kFyjdW(fWICUi$p*gHkxQm4@wx8LWsfg+lM0q0QiGp zT0j5gdqzNy)I%x9jGObGTq#b-s(=~*G62)3-@{yThnCJqzJ*T@ePZK6N1T9;qi(x7iE3Z53FY8l`A?1I<8d zbHkoBBN;$z>-JhrcRrvrlnTv9v?+nVYDEK4Zey{{yjNZ|UjQu-a*x`IifS!q$xWwG zcIir>xTuQ$of8vhZg`|WK9+ZOCOaL;yJZppdL&M$e#@$f_jYiKCd-*AmUDAn(Lr%h zL+nYX&yBB&+Ikn0QY8KW?DiCe#9tjn56AI`Vn{9Eb~VqaftAl<+?>Z+%6M|=Yh2aK?tPg)_2FYKJs)mmXzYa<*}|`DD~F59d5(R>DI2U zMrmpL5b8-Fep}^_kO6gAS>j+h+i!&p36zmcCId?a`h--wK<)t5N@)zr`H@0000settings.options[x].launcher !== false).length / 2), node:true, color:'#151a24', id: 'launcher'}) require('@electron/remote/main').enable(launcher.webContents) - launcher.on('close', ()=>{ - process.stdout.write = stdoutWrite - process.stderr.write = stderrWrite - if (process.log) process.log = processLog - }) tray = require('./tray')({ window: launcher, @@ -231,6 +226,25 @@ function startLauncher() { stopServer: stopServerProcess }) + launcher.on('will-close', ()=>{ + if (clientWindows.length) { + launcher.hide() + e.preventDefault() + } + }) + + launcher.on('close', (e)=>{ + if (clientWindows.length) { + launcher.hide() + e.preventDefault() + return + } + process.stdout.write = stdoutWrite + process.stderr.write = stderrWrite + if (process.log) process.log = processLog + tray.destroy() + }) + }) let processLog = process.log, diff --git a/src/server/tray.js b/src/server/tray.js index 79e63542..bb49d4a6 100644 --- a/src/server/tray.js +++ b/src/server/tray.js @@ -1,72 +1,89 @@ -var { Menu, Tray, ipcMain } = require('electron') - -var tray = null, +var {Menu, Tray, ipcMain} = require('electron'), + settings = require('./settings'), + tray = null, contextMenu = null, - hideInTray = false, isServerRunning = false -module.exports = function (options = {}) { - - ipcMain.on('start', function (e, options) { - isServerRunning = true - resetMenu(isServerRunning) - }) - - ipcMain.on('stop', function (e, options) { - isServerRunning = false - resetMenu(isServerRunning) - }) +module.exports = function(options = {}) { var icon = __dirname + '/../assets/logo.png' if (process.platform === 'darwin') { - var icon = __dirname + '/../assets/logo_16x16.png' + icon = __dirname + '/../assets/logo_tray.png' } + tray = new Tray(icon) contextMenu = Menu.buildFromTemplate([ { - label: 'Open/Hide', click: () => { - if (hideInTray) { - options.window.show() - hideInTray = false - } else { - options.window.hide() - hideInTray = true - } + label: 'Show launcher', + id: 'show', + click: ()=>{ + options.window.show() } }, { - label: 'Start/Stop', - click: () => { - if (isServerRunning) { - ipcMain.emit('stop'); - } else { - ipcMain.emit('start'); - } + label: 'Hide launcher', + id: 'hide', + click: ()=>{ + options.window.hide() } }, { - label: 'New Window', click: () => { + label: 'Start server', + id: 'start', + click: ()=>{ + ipcMain.emit('start') + } + }, + { + label: 'Stop server', + id: 'stop', + click: ()=>{ + ipcMain.emit('stop') + } + }, + { + label: 'New client window', + id: 'new', + click: ()=> { if (isServerRunning) { options.openClient() } - }, - enabled: isServerRunning + } }, - { type: 'separator' }, - { label: 'Quit', click: () => { void options.app.quit(); } }, - ]); + { + type: 'separator' + }, + { + label: 'Quit', + role: 'Quit' + }, + ]) + tray.setContextMenu(contextMenu) - tray.setToolTip('Open Stage Control') + tray.setToolTip(settings.infos.productName) + + function updateMenu(){ + contextMenu.getMenuItemById('start').visible = !isServerRunning + contextMenu.getMenuItemById('stop').visible = isServerRunning + contextMenu.getMenuItemById('show').visible = !options.window.isVisible() + contextMenu.getMenuItemById('hide').visible = options.window.isVisible() + contextMenu.getMenuItemById('new').visible = isServerRunning + tray.setContextMenu(contextMenu) + } + + ipcMain.on('start', function(e, options) { + isServerRunning = true + updateMenu() + }) + + ipcMain.on('stop', function(e, options) { + isServerRunning = false + updateMenu() + }) + + options.window.on('show', updateMenu) + options.window.on('hide', updateMenu) return tray } - -function resetMenu(isServerRunning) { - contextMenu.items.forEach(item => { - if (item.label === 'New Window') { - item.enabled = isServerRunning - } - }) - tray.setContextMenu(contextMenu) -} \ No newline at end of file