@sirenodeck/sirenodeck 0.2.6 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config-ui/index.html +13 -0
- package/config-ui/src/App.tsx +675 -0
- package/config-ui/src/DeckFrame.tsx +445 -0
- package/config-ui/src/Shell.tsx +108 -0
- package/config-ui/src/SidePanel.tsx +96 -0
- package/config-ui/src/bridge-log-store.ts +115 -0
- package/config-ui/src/bridge.ts +303 -0
- package/config-ui/src/components/ActionValueEditor.tsx +209 -0
- package/config-ui/src/components/ButtonActionsEditor.tsx +84 -0
- package/config-ui/src/components/DisconnectedOverlay.tsx +77 -0
- package/config-ui/src/components/EmojiPicker.tsx +65 -0
- package/config-ui/src/components/IconPicker.tsx +264 -0
- package/config-ui/src/components/MacroPreview.tsx +22 -0
- package/config-ui/src/components/ReconnectingBanner.tsx +35 -0
- package/config-ui/src/gesture.ts +45 -0
- package/config-ui/src/index.css +8 -0
- package/config-ui/src/main.tsx +20 -0
- package/config-ui/src/pages/AboutPage.tsx +65 -0
- package/config-ui/src/pages/AddonsPage.tsx +232 -0
- package/config-ui/src/pages/BridgeLogsPage.tsx +94 -0
- package/config-ui/src/pages/ButtonConfigEditor/ButtonAppearanceFields.tsx +77 -0
- package/config-ui/src/pages/ButtonConfigEditor/ButtonTypePicker.tsx +80 -0
- package/config-ui/src/pages/ButtonConfigEditor/ConfigForm.tsx +50 -0
- package/config-ui/src/pages/ButtonConfigEditor/FormFieldParts.tsx +23 -0
- package/config-ui/src/pages/ButtonConfigEditor/PositionPicker.tsx +68 -0
- package/config-ui/src/pages/ButtonConfigEditor/controls/ActionControl.tsx +27 -0
- package/config-ui/src/pages/ButtonConfigEditor/controls/ArrayControl.tsx +77 -0
- package/config-ui/src/pages/ButtonConfigEditor/controls/BooleanControl.tsx +34 -0
- package/config-ui/src/pages/ButtonConfigEditor/controls/DeckSelectControl.tsx +47 -0
- package/config-ui/src/pages/ButtonConfigEditor/controls/EmojiControl.tsx +70 -0
- package/config-ui/src/pages/ButtonConfigEditor/controls/IconControl.tsx +31 -0
- package/config-ui/src/pages/ButtonConfigEditor/controls/ObjectControl.tsx +52 -0
- package/config-ui/src/pages/ButtonConfigEditor/controls/RecordControl.tsx +104 -0
- package/config-ui/src/pages/ButtonConfigEditor/controls/SelectControl.tsx +46 -0
- package/config-ui/src/pages/ButtonConfigEditor/controls/ShellControl.tsx +29 -0
- package/config-ui/src/pages/ButtonConfigEditor/controls/TextControl.tsx +36 -0
- package/config-ui/src/pages/ButtonConfigEditor/controls/UnionControl.tsx +96 -0
- package/config-ui/src/pages/ButtonConfigEditor/controls/registry.ts +17 -0
- package/config-ui/src/pages/ButtonConfigEditor/types.ts +67 -0
- package/config-ui/src/pages/ButtonConfigEditor/utils.ts +56 -0
- package/config-ui/src/pages/ButtonConfigEditor.tsx +226 -0
- package/config-ui/src/pages/ConfigPage.tsx +326 -0
- package/config-ui/src/pages/DecksPage.tsx +104 -0
- package/config-ui/src/pages/EditorPage.tsx +1697 -0
- package/config-ui/src/pages/ServiceLogsPage.tsx +130 -0
- package/config-ui/vite.config.ts +105 -0
- package/dist/main.mjs +403 -41501
- package/frontend/index.html +12 -0
- package/frontend/src/App.tsx +536 -0
- package/frontend/src/__mocks__/addons-registry.ts +2 -0
- package/frontend/src/__mocks__/theme.ts +1 -0
- package/frontend/src/__mocks__/themes-manifest.tsx +78 -0
- package/frontend/src/__mocks__/token.ts +2 -0
- package/frontend/src/bridge/client.ts +186 -0
- package/frontend/src/bridge/use-button-action.ts +31 -0
- package/frontend/src/bridge/ws-context.tsx +24 -0
- package/frontend/src/components/Deck.tsx +486 -0
- package/frontend/src/components/DisconnectedOverlay.tsx +82 -0
- package/frontend/src/components/ErrorBoundary.tsx +92 -0
- package/frontend/src/components/ReconnectingBanner.tsx +40 -0
- package/frontend/src/index.css +40 -0
- package/frontend/src/main.tsx +23 -0
- package/frontend/vite.config.ts +132 -0
- package/package.json +20 -6
- package/src/builtin-addons/internal-settings/index.ts +0 -1
- package/src/builtin-addons/internal-settings/logo72x72.png +0 -0
- package/src/cli/commands/emulator-mode.ts +26 -4
- package/src/cli/commands/run.ts +28 -1
- package/src/cli/commands/service-manager.ts +53 -1
- package/src/cli/commands/start.ts +17 -0
- package/src/cli/startup-display.ts +1 -1
- package/src/core/settings.ts +5 -3
- package/src/device/black-frame.ts +5 -14
- package/src/outputClient/real.ts +2 -0
- package/src/vite/virtual-modules.ts +16 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
@import "sirenodeck-theme";
|
|
3
|
+
|
|
4
|
+
:root {
|
|
5
|
+
color-scheme: dark light;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
html,
|
|
9
|
+
body,
|
|
10
|
+
#root {
|
|
11
|
+
height: 100%;
|
|
12
|
+
margin: 0;
|
|
13
|
+
background-color: var(--color-bg);
|
|
14
|
+
color: var(--color-fg);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Rich-text primitives — emitted by Text.tsx. Theme-agnostic so any
|
|
18
|
+
* theme gets them automatically. */
|
|
19
|
+
.sireno-rich-text-break {
|
|
20
|
+
display: block;
|
|
21
|
+
height: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.sireno-rich-text-strong {
|
|
25
|
+
font-weight: 700;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.sireno-rich-text-blink {
|
|
29
|
+
animation: sireno-blink 1s step-end infinite;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@keyframes sireno-blink {
|
|
33
|
+
0%,
|
|
34
|
+
100% {
|
|
35
|
+
opacity: 1;
|
|
36
|
+
}
|
|
37
|
+
50% {
|
|
38
|
+
opacity: 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StrictMode, type ReactNode } from "react"
|
|
2
|
+
import { createRoot } from "react-dom/client"
|
|
3
|
+
import { BrowserRouter } from "react-router-dom"
|
|
4
|
+
import { App } from "./App"
|
|
5
|
+
import { ErrorBoundary, useHmrResetKey } from "./components/ErrorBoundary"
|
|
6
|
+
import "./index.css"
|
|
7
|
+
|
|
8
|
+
const Root = (): ReactNode => {
|
|
9
|
+
const resetKey = useHmrResetKey()
|
|
10
|
+
return (
|
|
11
|
+
<StrictMode>
|
|
12
|
+
<ErrorBoundary resetKey={resetKey}>
|
|
13
|
+
<BrowserRouter>
|
|
14
|
+
<App />
|
|
15
|
+
</BrowserRouter>
|
|
16
|
+
</ErrorBoundary>
|
|
17
|
+
</StrictMode>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const container = document.getElementById("root")
|
|
22
|
+
if (container === null) throw new Error("#root not found")
|
|
23
|
+
createRoot(container).render(<Root />)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { defineConfig } from "vite"
|
|
2
|
+
import react from "@vitejs/plugin-react"
|
|
3
|
+
import tailwindcss from "@tailwindcss/vite"
|
|
4
|
+
import { dirname, resolve } from "node:path"
|
|
5
|
+
import { fileURLToPath } from "node:url"
|
|
6
|
+
import { readFileSync } from "node:fs"
|
|
7
|
+
import { sirenoDeck2 } from "../src/vite/index"
|
|
8
|
+
import { frontendBridgeUrl } from "../src/render/frontend-bridge-url"
|
|
9
|
+
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
11
|
+
|
|
12
|
+
const wsUrl = frontendBridgeUrl()
|
|
13
|
+
const proxyUrl = process.env["SIRENO_WS_PROXY_URL"] ?? ""
|
|
14
|
+
|
|
15
|
+
const addonsFromEnv = () => {
|
|
16
|
+
const blob = process.env["SIRENO_ADDONS"]
|
|
17
|
+
if (blob === undefined || blob.length === 0) return undefined
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(blob) as Array<{
|
|
20
|
+
name: string
|
|
21
|
+
frontend?: { main: string; styles?: string[] }
|
|
22
|
+
buttons?: Array<{ type: string }>
|
|
23
|
+
buttonTypes?: Record<string, string>
|
|
24
|
+
}>
|
|
25
|
+
} catch {
|
|
26
|
+
return undefined
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const themeFromEnv = ():
|
|
31
|
+
| { name: string; manifestPath: string; uiOverridesPath: string | null }
|
|
32
|
+
| undefined => {
|
|
33
|
+
const blob = process.env["SIRENO_THEME"]
|
|
34
|
+
if (blob === undefined || blob.length === 0) return undefined
|
|
35
|
+
try {
|
|
36
|
+
const parsed = JSON.parse(blob) as {
|
|
37
|
+
name?: unknown
|
|
38
|
+
manifestPath?: unknown
|
|
39
|
+
uiOverridesPath?: unknown
|
|
40
|
+
}
|
|
41
|
+
if (
|
|
42
|
+
typeof parsed.name === "string" &&
|
|
43
|
+
typeof parsed.manifestPath === "string"
|
|
44
|
+
) {
|
|
45
|
+
return {
|
|
46
|
+
name: parsed.name,
|
|
47
|
+
manifestPath: parsed.manifestPath,
|
|
48
|
+
uiOverridesPath:
|
|
49
|
+
parsed.uiOverridesPath === null ||
|
|
50
|
+
typeof parsed.uiOverridesPath === "string"
|
|
51
|
+
? (parsed.uiOverridesPath as string | null)
|
|
52
|
+
: null,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
/* ignore */
|
|
57
|
+
}
|
|
58
|
+
return undefined
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default defineConfig({
|
|
62
|
+
plugins: [
|
|
63
|
+
react(),
|
|
64
|
+
tailwindcss(),
|
|
65
|
+
sirenoDeck2({
|
|
66
|
+
token: process.env["SIRENO_TOKEN"] ?? "",
|
|
67
|
+
...(themeFromEnv() ? { theme: themeFromEnv()! } : {}),
|
|
68
|
+
...(addonsFromEnv() !== undefined ? { addons: addonsFromEnv()! } : {}),
|
|
69
|
+
}),
|
|
70
|
+
{
|
|
71
|
+
name: "sireno-asset-proxy",
|
|
72
|
+
configureServer(server) {
|
|
73
|
+
const configDir =
|
|
74
|
+
process.env["SIRENO_CONFIG_DIR"] ?? resolve(__dirname, "../../..")
|
|
75
|
+
server.middlewares.use("/@sireno-asset", (req, res, next) => {
|
|
76
|
+
const url = req.url ?? ""
|
|
77
|
+
const safe = url.split("?")[0]!.replace(/^\/+/, "")
|
|
78
|
+
if (safe.includes("..")) {
|
|
79
|
+
next()
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
const filePath = resolve(configDir, safe)
|
|
83
|
+
try {
|
|
84
|
+
const body = readFileSync(filePath)
|
|
85
|
+
const ext = filePath.split(".").pop()?.toLowerCase() ?? ""
|
|
86
|
+
const mime =
|
|
87
|
+
ext === "svg"
|
|
88
|
+
? "image/svg+xml"
|
|
89
|
+
: ext === "png"
|
|
90
|
+
? "image/png"
|
|
91
|
+
: ext === "jpg" || ext === "jpeg"
|
|
92
|
+
? "image/jpeg"
|
|
93
|
+
: ext === "webp"
|
|
94
|
+
? "image/webp"
|
|
95
|
+
: "application/octet-stream"
|
|
96
|
+
res.setHeader("Content-Type", mime)
|
|
97
|
+
res.setHeader("Cache-Control", "no-cache")
|
|
98
|
+
res.end(body)
|
|
99
|
+
} catch {
|
|
100
|
+
next()
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
server: {
|
|
107
|
+
host: process.env["SIRENO_VITE_HOST"] ?? "127.0.0.1",
|
|
108
|
+
port: 5180,
|
|
109
|
+
strictPort: true,
|
|
110
|
+
},
|
|
111
|
+
resolve: {
|
|
112
|
+
alias: [
|
|
113
|
+
{ find: /^@\//, replacement: resolve(__dirname, "../src") + "/" },
|
|
114
|
+
{
|
|
115
|
+
find: /^@sirenodeck\/sirenodeck(\/.*)?$/,
|
|
116
|
+
replacement: resolve(__dirname, "../src") + "$1",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
find: /^sirenodeck\/react$/,
|
|
120
|
+
replacement: resolve(__dirname, "../src/api/react/index"),
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
define: {
|
|
125
|
+
"import.meta.env.VITE_WS_URL": JSON.stringify(wsUrl),
|
|
126
|
+
"import.meta.env.VITE_WS_PROXY_URL": JSON.stringify(proxyUrl),
|
|
127
|
+
"import.meta.env.SIRENO_CONFIG_DIR": JSON.stringify(
|
|
128
|
+
process.env["SIRENO_CONFIG_DIR"] ?? resolve(__dirname, "../../.."),
|
|
129
|
+
),
|
|
130
|
+
},
|
|
131
|
+
assetsInclude: ["**/*.html"],
|
|
132
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sirenodeck/sirenodeck",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "CLI for managing Elgato Stream Deck devices via a config-driven deck system.",
|
|
5
5
|
"homepage": "https://deck.sireno.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -19,12 +19,20 @@
|
|
|
19
19
|
"bin",
|
|
20
20
|
"config",
|
|
21
21
|
"dist",
|
|
22
|
+
"frontend",
|
|
23
|
+
"config-ui",
|
|
22
24
|
"src",
|
|
23
25
|
"LICENSE",
|
|
24
26
|
"README.md",
|
|
25
27
|
"!src/**/*.test.ts",
|
|
26
28
|
"!src/**/*.test.tsx",
|
|
27
29
|
"!src/**/__tests__/**",
|
|
30
|
+
"!frontend/**/__tests__/**",
|
|
31
|
+
"!config-ui/**/__tests__/**",
|
|
32
|
+
"!frontend/.sireno-deck/**",
|
|
33
|
+
"!config-ui/.sireno-deck/**",
|
|
34
|
+
"!frontend/.sirenodeck/**",
|
|
35
|
+
"!config-ui/.sirenodeck/**",
|
|
28
36
|
"!**/*.snap"
|
|
29
37
|
],
|
|
30
38
|
"type": "module",
|
|
@@ -98,24 +106,34 @@
|
|
|
98
106
|
"@elgato-stream-deck/node": "^7.6.3",
|
|
99
107
|
"@heroui/react": "3.2.6",
|
|
100
108
|
"@heroui/styles": "3.2.6",
|
|
109
|
+
"@internationalized/date": "^3.12.4",
|
|
101
110
|
"@meteocons/svg-static": "^0.1.0",
|
|
111
|
+
"@react-aria/ssr": "^3.10.1",
|
|
112
|
+
"@react-aria/utils": "^3.34.1",
|
|
113
|
+
"@tailwindcss/vite": "^4.0.0",
|
|
114
|
+
"@vitejs/plugin-react": "^6.0.0",
|
|
102
115
|
"chokidar": "^5.0.0",
|
|
103
116
|
"dbus-next": "^0.10.2",
|
|
104
117
|
"execa": "^9.6.0",
|
|
105
118
|
"jsonc-parser": "^3.3.1",
|
|
119
|
+
"lucide-react": "^1.22.0",
|
|
106
120
|
"pino": "^10.3.1",
|
|
107
121
|
"playwright": "^1.50.0",
|
|
108
122
|
"qrcode": "^1.5.4",
|
|
109
123
|
"react": "^19.0.0",
|
|
124
|
+
"react-aria": "^3.52.1",
|
|
125
|
+
"react-aria-components": "^1.21.1",
|
|
110
126
|
"react-dom": "^19.0.0",
|
|
127
|
+
"react-router-dom": "^7.18.1",
|
|
111
128
|
"sharp": "^0.34.0",
|
|
129
|
+
"tailwindcss": "^4.0.0",
|
|
130
|
+
"vite": "^8.0.0",
|
|
112
131
|
"ws": "^8.18.0",
|
|
113
132
|
"yaml": "^2.9.0",
|
|
114
133
|
"yargs": "^18.0.0",
|
|
115
134
|
"zod": "^4.4.3"
|
|
116
135
|
},
|
|
117
136
|
"devDependencies": {
|
|
118
|
-
"@tailwindcss/vite": "^4.0.0",
|
|
119
137
|
"@testing-library/dom": "^10.4.0",
|
|
120
138
|
"@testing-library/jest-dom": "^6.6.3",
|
|
121
139
|
"@testing-library/react": "^16.1.0",
|
|
@@ -125,17 +143,13 @@
|
|
|
125
143
|
"@types/react-dom": "^19.0.0",
|
|
126
144
|
"@types/ws": "^8.5.13",
|
|
127
145
|
"@types/yargs": "^17.0.35",
|
|
128
|
-
"@vitejs/plugin-react": "^6.0.0",
|
|
129
146
|
"jsdom": "^25.0.1",
|
|
130
|
-
"lucide-react": "^1.22.0",
|
|
131
147
|
"oxfmt": "latest",
|
|
132
148
|
"oxlint": "latest",
|
|
133
149
|
"pino-pretty": "^13.0.0",
|
|
134
|
-
"tailwindcss": "^4.0.0",
|
|
135
150
|
"tsdown": "^0.22.14",
|
|
136
151
|
"tsx": "^4.22.4",
|
|
137
152
|
"typescript": "7.0.1-rc",
|
|
138
|
-
"vite": "^8.0.0",
|
|
139
153
|
"vitest": "^4.1.9"
|
|
140
154
|
}
|
|
141
155
|
}
|
|
Binary file
|
|
@@ -51,13 +51,35 @@ export const findWorkspaceRoot = (): string => {
|
|
|
51
51
|
return here
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
const packageRoot = (): string | null => {
|
|
55
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
56
|
+
const root = dirname(here)
|
|
57
|
+
return existsSync(join(root, "frontend", "vite.config.ts")) ? root : null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const resolveViteBin = (): string => {
|
|
61
|
+
let dir = packageRoot() ?? findWorkspaceRoot()
|
|
62
|
+
for (;;) {
|
|
63
|
+
const bin = join(dir, "node_modules", ".bin", "vite")
|
|
64
|
+
if (existsSync(bin)) return bin
|
|
65
|
+
const parent = dirname(dir)
|
|
66
|
+
if (parent === dir) return bin
|
|
67
|
+
dir = parent
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
54
71
|
export const resolveConfigUiCwd = (override?: string): string => {
|
|
55
72
|
if (override !== undefined) return override
|
|
56
|
-
|
|
73
|
+
const root = packageRoot()
|
|
74
|
+
return root !== null
|
|
75
|
+
? join(root, "config-ui")
|
|
76
|
+
: resolvePath(findWorkspaceRoot(), "packages", "cli", "config-ui")
|
|
57
77
|
}
|
|
58
78
|
|
|
59
79
|
export const resolveFrontendCwd = (): string =>
|
|
60
|
-
|
|
80
|
+
packageRoot() !== null
|
|
81
|
+
? join(packageRoot()!, "frontend")
|
|
82
|
+
: resolvePath(findWorkspaceRoot(), "packages", "cli", "frontend")
|
|
61
83
|
|
|
62
84
|
interface ViteSpawnOptions {
|
|
63
85
|
port: number
|
|
@@ -124,7 +146,7 @@ const spawnViteAndWaitForReady = (
|
|
|
124
146
|
if (emulatorMode !== undefined) {
|
|
125
147
|
env["SIRENO_EMULATOR_MODE"] = String(emulatorMode)
|
|
126
148
|
}
|
|
127
|
-
const viteBin =
|
|
149
|
+
const viteBin = resolveViteBin()
|
|
128
150
|
const viteArgs = [
|
|
129
151
|
"--config",
|
|
130
152
|
resolvePath(cwd, "vite.config.ts"),
|
|
@@ -134,7 +156,7 @@ const spawnViteAndWaitForReady = (
|
|
|
134
156
|
if (host !== undefined) {
|
|
135
157
|
viteArgs.push("--host", host)
|
|
136
158
|
}
|
|
137
|
-
const child = spawn(viteBin, viteArgs, {
|
|
159
|
+
const child = spawn(process.execPath, [viteBin, ...viteArgs], {
|
|
138
160
|
cwd,
|
|
139
161
|
env,
|
|
140
162
|
stdio: ["ignore", "pipe", "pipe"],
|
package/src/cli/commands/run.ts
CHANGED
|
@@ -110,6 +110,11 @@ import {
|
|
|
110
110
|
} from "@/outputClient"
|
|
111
111
|
import type { AddonInventoryEntry } from "@/api/protocol-internal"
|
|
112
112
|
import { loadDeviceConfig } from "@/util/device-config"
|
|
113
|
+
import {
|
|
114
|
+
createSettingsStore,
|
|
115
|
+
resolveSettingsPath,
|
|
116
|
+
type SettingsStore,
|
|
117
|
+
} from "@/core/settings"
|
|
113
118
|
import {
|
|
114
119
|
collectAddonDefaultButtonConfig,
|
|
115
120
|
materializeAddonDecks,
|
|
@@ -163,6 +168,7 @@ export interface RunOptions {
|
|
|
163
168
|
readonly remote?: boolean
|
|
164
169
|
readonly deviceModel?: string
|
|
165
170
|
readonly frontendUrl?: string
|
|
171
|
+
readonly configUiUrl?: string
|
|
166
172
|
readonly intervalMs?: number
|
|
167
173
|
readonly xdgConfigHome?: string
|
|
168
174
|
readonly homeDir?: string
|
|
@@ -902,7 +908,9 @@ const buildRuntime = (
|
|
|
902
908
|
logger,
|
|
903
909
|
)
|
|
904
910
|
const token = process.env["SIRENO_TOKEN"] ?? ""
|
|
905
|
-
const configUiUrl = new URL(
|
|
911
|
+
const configUiUrl = new URL(
|
|
912
|
+
options.configUiUrl ?? `http://127.0.0.1:${DEFAULT_CONFIG_UI_PORT}/`,
|
|
913
|
+
)
|
|
906
914
|
if (token.length > 0) configUiUrl.searchParams.set("token", token)
|
|
907
915
|
configUiUrl.hash = "/config"
|
|
908
916
|
const runtimeDecks = injectConfigUiButton(allDecks, configUiUrl.toString())
|
|
@@ -1505,6 +1513,8 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1505
1513
|
let configWatcher: ConfigWatcher | null = null
|
|
1506
1514
|
let outputHandle: OutputHandle | null = null
|
|
1507
1515
|
let currentOutputHandle: OutputHandle | null = null
|
|
1516
|
+
let settingsStore: SettingsStore | null = null
|
|
1517
|
+
let unsubscribeBrightnessSettings: (() => void) | null = null
|
|
1508
1518
|
let unregisterSignal: (() => void) | null = null
|
|
1509
1519
|
let unregisterReload: (() => void) | null = null
|
|
1510
1520
|
let unsubscribeLockMode: (() => void) | null = null
|
|
@@ -1521,6 +1531,10 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1521
1531
|
})
|
|
1522
1532
|
|
|
1523
1533
|
try {
|
|
1534
|
+
settingsStore = createSettingsStore({
|
|
1535
|
+
path: resolveSettingsPath(xdgConfigHome),
|
|
1536
|
+
logger,
|
|
1537
|
+
})
|
|
1524
1538
|
// Validate config first so a broken YAML exits before we ever touch
|
|
1525
1539
|
// hardware or spawn an emulator.
|
|
1526
1540
|
loadedConfig = await validateAndLoadConfig(options)
|
|
@@ -1544,8 +1558,13 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1544
1558
|
decks = loaded.decks
|
|
1545
1559
|
pubSub = loaded.pubSub
|
|
1546
1560
|
runtime = loaded.runtime
|
|
1561
|
+
runtime.setBrightness(settingsStore.get().brightness)
|
|
1547
1562
|
methods = loaded.methods
|
|
1548
1563
|
store = loaded.store
|
|
1564
|
+
unsubscribeBrightnessSettings = pubSub.subscribe<{ value: number }>(
|
|
1565
|
+
"methods:adjustBrightness",
|
|
1566
|
+
({ value }) => settingsStore?.update({ brightness: value }),
|
|
1567
|
+
)
|
|
1549
1568
|
|
|
1550
1569
|
providers = await startSystemProviders(options, methods)
|
|
1551
1570
|
hostPolicy = createHostPolicyCoordinator({
|
|
@@ -1775,6 +1794,9 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1775
1794
|
logger,
|
|
1776
1795
|
})
|
|
1777
1796
|
addonServicesDispose = () => addonServices?.dispose()
|
|
1797
|
+
pubSub.publish("sireno:settings:brightness", {
|
|
1798
|
+
value: runtime.getBrightness(),
|
|
1799
|
+
})
|
|
1778
1800
|
|
|
1779
1801
|
for (const deck of decks) {
|
|
1780
1802
|
registerDeckIcon(deck, resolverOptions, logger)
|
|
@@ -1856,6 +1878,9 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
1856
1878
|
...(options.frontendUrl !== undefined
|
|
1857
1879
|
? { frontendUrl: options.frontendUrl }
|
|
1858
1880
|
: {}),
|
|
1881
|
+
...(options.configUiUrl !== undefined
|
|
1882
|
+
? { configUiUrl: options.configUiUrl }
|
|
1883
|
+
: {}),
|
|
1859
1884
|
...(options.port !== undefined ? { port: options.port } : {}),
|
|
1860
1885
|
...(options.intervalMs !== undefined
|
|
1861
1886
|
? { intervalMs: options.intervalMs }
|
|
@@ -2082,6 +2107,8 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
|
|
|
2082
2107
|
|
|
2083
2108
|
await done
|
|
2084
2109
|
} finally {
|
|
2110
|
+
unsubscribeBrightnessSettings?.()
|
|
2111
|
+
settingsStore?.close()
|
|
2085
2112
|
if (unregisterSignal !== null) unregisterSignal()
|
|
2086
2113
|
if (unregisterReload !== null) unregisterReload()
|
|
2087
2114
|
if (bridgeSignal !== null) bridgeSignal.abort()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process"
|
|
2
|
-
import { existsSync } from "node:fs"
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs"
|
|
3
3
|
import { homedir } from "node:os"
|
|
4
4
|
import { join } from "node:path"
|
|
5
5
|
import { platform } from "node:process"
|
|
@@ -20,6 +20,33 @@ export interface InvokeManagerOptions {
|
|
|
20
20
|
|
|
21
21
|
const DAEMON_NAME = "sirenodeck"
|
|
22
22
|
|
|
23
|
+
export const refreshStaleUnit = (
|
|
24
|
+
content: string,
|
|
25
|
+
currentScript: string,
|
|
26
|
+
nodePath: string,
|
|
27
|
+
exists: (path: string) => boolean = existsSync,
|
|
28
|
+
): string => {
|
|
29
|
+
const match = content.match(
|
|
30
|
+
/^ExecStart="([^"]+)" "([^"]+\/dist\/main\.mjs)" start$/m,
|
|
31
|
+
)
|
|
32
|
+
const oldScript = match?.[2]
|
|
33
|
+
if (
|
|
34
|
+
match === null ||
|
|
35
|
+
oldScript === undefined ||
|
|
36
|
+
oldScript === currentScript ||
|
|
37
|
+
!exists(currentScript)
|
|
38
|
+
)
|
|
39
|
+
return content
|
|
40
|
+
const brewUpgrade =
|
|
41
|
+
oldScript.includes("/Cellar/sirenodeck/") &&
|
|
42
|
+
currentScript.includes("/Cellar/sirenodeck/")
|
|
43
|
+
if (exists(oldScript) && !brewUpgrade) return content
|
|
44
|
+
return content.replace(
|
|
45
|
+
match[0],
|
|
46
|
+
`ExecStart="${nodePath}" "${currentScript}" start`,
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
23
50
|
const systemctl = (userLevel: boolean, args: ReadonlyArray<string>): void => {
|
|
24
51
|
const cmd = userLevel ? "systemctl" : "systemctl"
|
|
25
52
|
const fullArgs = userLevel ? ["--user", ...args] : [...args]
|
|
@@ -123,6 +150,31 @@ export const ensureInstalled = async (
|
|
|
123
150
|
const { logger, system = false } = options
|
|
124
151
|
const userLevel = !system
|
|
125
152
|
if (isUnitInstalled(userLevel)) {
|
|
153
|
+
if (currentOS() === "linux") {
|
|
154
|
+
const unitPath = userLevel
|
|
155
|
+
? join(
|
|
156
|
+
homedir(),
|
|
157
|
+
".config",
|
|
158
|
+
"systemd",
|
|
159
|
+
"user",
|
|
160
|
+
`${DAEMON_NAME}.service`,
|
|
161
|
+
)
|
|
162
|
+
: `/etc/systemd/system/${DAEMON_NAME}.service`
|
|
163
|
+
const content = readFileSync(unitPath, "utf8")
|
|
164
|
+
const currentScript = process.argv[1]
|
|
165
|
+
const updated =
|
|
166
|
+
currentScript === undefined
|
|
167
|
+
? content
|
|
168
|
+
: refreshStaleUnit(content, currentScript, process.execPath)
|
|
169
|
+
if (updated !== content) {
|
|
170
|
+
writeFileSync(unitPath, updated)
|
|
171
|
+
systemctl(userLevel, ["daemon-reload"])
|
|
172
|
+
logger.info(
|
|
173
|
+
{ unitPath },
|
|
174
|
+
"ensureInstalled: refreshed stale executable path",
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
126
178
|
logger.debug({ userLevel }, "ensureInstalled: unit already present")
|
|
127
179
|
return
|
|
128
180
|
}
|
|
@@ -75,6 +75,7 @@ import { buildStandardProbeDeps } from "@/cli/probe-deps"
|
|
|
75
75
|
import { onboardCodingAgents } from "@/cli/coding-agents-onboarding"
|
|
76
76
|
import { resolveUserPath } from "@/cli/cwd"
|
|
77
77
|
import { offerConfigSkillOnFirstRun } from "@/cli/skills-first-run"
|
|
78
|
+
import { resolveInstallRoot } from "../install-root"
|
|
78
79
|
|
|
79
80
|
export interface StartOptions {
|
|
80
81
|
readonly config?: string
|
|
@@ -83,6 +84,7 @@ export interface StartOptions {
|
|
|
83
84
|
readonly remote?: boolean
|
|
84
85
|
readonly deviceModel?: string
|
|
85
86
|
readonly frontendUrl?: string
|
|
87
|
+
readonly configUiUrl?: string
|
|
86
88
|
readonly intervalMs?: number
|
|
87
89
|
readonly xdgConfigHome?: string
|
|
88
90
|
readonly homeDir?: string
|
|
@@ -106,6 +108,7 @@ const toRunOptions = (
|
|
|
106
108
|
remote: options.remote,
|
|
107
109
|
deviceModel: options.deviceModel,
|
|
108
110
|
frontendUrl: options.frontendUrl,
|
|
111
|
+
configUiUrl: options.configUiUrl,
|
|
109
112
|
intervalMs: options.intervalMs,
|
|
110
113
|
xdgConfigHome: options.xdgConfigHome,
|
|
111
114
|
homeDir: options.homeDir,
|
|
@@ -116,6 +119,8 @@ const toRunOptions = (
|
|
|
116
119
|
})
|
|
117
120
|
|
|
118
121
|
const resolveFrontendDist = (): string => {
|
|
122
|
+
const installRoot = resolveInstallRoot()
|
|
123
|
+
if (installRoot !== null) return join(installRoot, "frontend", "dist")
|
|
119
124
|
const here = dirname(fileURLToPath(import.meta.url))
|
|
120
125
|
return resolvePath(here, "../../../frontend/dist")
|
|
121
126
|
}
|
|
@@ -590,6 +595,11 @@ const runInProcessSetup = async (
|
|
|
590
595
|
// letting it also override a fresh invocation made one past `--emulator`
|
|
591
596
|
// run force every later plain `p dev start` into emulator mode.
|
|
592
597
|
const runtimeFlags = buildRuntimeFlags(options)
|
|
598
|
+
const installRoot = resolveInstallRoot()
|
|
599
|
+
const installedFrontendUrl =
|
|
600
|
+
installRoot !== null && runtimeFlags.emulator !== true
|
|
601
|
+
? `http://127.0.0.1:${runtimeFlags.httpPort}`
|
|
602
|
+
: undefined
|
|
593
603
|
writeConfigPath(configPath)
|
|
594
604
|
writeFlags(runtimeFlags)
|
|
595
605
|
|
|
@@ -605,6 +615,13 @@ const runInProcessSetup = async (
|
|
|
605
615
|
remote: runtimeFlags.remote,
|
|
606
616
|
deviceModel: runtimeFlags.deviceModel,
|
|
607
617
|
httpPort: runtimeFlags.httpPort,
|
|
618
|
+
...(options.frontendUrl === undefined &&
|
|
619
|
+
installedFrontendUrl !== undefined
|
|
620
|
+
? {
|
|
621
|
+
frontendUrl: installedFrontendUrl,
|
|
622
|
+
configUiUrl: installedFrontendUrl,
|
|
623
|
+
}
|
|
624
|
+
: {}),
|
|
608
625
|
},
|
|
609
626
|
(pids) => {
|
|
610
627
|
writeChildren({ pids: [...pids] })
|
|
@@ -188,7 +188,7 @@ export const formatFeaturesList = (
|
|
|
188
188
|
"Features",
|
|
189
189
|
...items.map(
|
|
190
190
|
(it) =>
|
|
191
|
-
`│
|
|
191
|
+
`│ ${it.available ? color.green("✓") : color.red("✗")} ${it.name}${!it.available && it.reason ? ` — ${it.reason}` : ""}`,
|
|
192
192
|
),
|
|
193
193
|
]
|
|
194
194
|
|
package/src/core/settings.ts
CHANGED
|
@@ -34,9 +34,10 @@ const SETTINGS_FILE = "settings.json"
|
|
|
34
34
|
const resolveXdgConfigHome = (): string =>
|
|
35
35
|
process.env["XDG_CONFIG_HOME"] ?? join(homedir(), ".config")
|
|
36
36
|
|
|
37
|
-
export const resolveSettingsPath = (
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
export const resolveSettingsPath = (
|
|
38
|
+
xdgConfigHome: string = resolveXdgConfigHome(),
|
|
39
|
+
): string => {
|
|
40
|
+
const dir = join(xdgConfigHome, SETTINGS_DIR)
|
|
40
41
|
return join(dir, SETTINGS_FILE)
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -71,6 +72,7 @@ export const loadSettings = (
|
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
export const atomicWriteJson = (path: string, data: unknown): void => {
|
|
75
|
+
mkdirSync(dirname(path), { recursive: true })
|
|
74
76
|
const tmpPath = `${path}.${randomBytes(6).toString("hex")}.tmp`
|
|
75
77
|
const fd = openSync(tmpPath, "w", 0o600)
|
|
76
78
|
try {
|
|
@@ -8,28 +8,19 @@ import type pino from "pino"
|
|
|
8
8
|
// runPipeline's finally block; the helper is preserved for that single use
|
|
9
9
|
// site and stays best-effort because the device may be unplugged at the
|
|
10
10
|
// moment of exit.
|
|
11
|
-
const buildBlackBuffer = (
|
|
12
|
-
const stride = 3 * 8
|
|
13
|
-
const total = keyCount * stride * 8
|
|
14
|
-
return Buffer.alloc(total)
|
|
15
|
-
}
|
|
11
|
+
const buildBlackBuffer = (): Buffer => Buffer.alloc(72 * 72 * 3)
|
|
16
12
|
|
|
17
13
|
export const pushBlackFrame = async (
|
|
18
14
|
device: StreamDeckDevice,
|
|
19
15
|
logger: pino.Logger,
|
|
20
16
|
): Promise<void> => {
|
|
21
17
|
try {
|
|
22
|
-
const buf = buildBlackBuffer(
|
|
18
|
+
const buf = buildBlackBuffer()
|
|
23
19
|
for (let i = 0; i < device.getKeyCount(); i++) {
|
|
24
|
-
await device.fillKeyBuffer(i, buf
|
|
20
|
+
await device.fillKeyBuffer(i, buf)
|
|
25
21
|
}
|
|
26
|
-
// ponytail:
|
|
27
|
-
// device
|
|
28
|
-
// queued image writes above are dropped at USB disconnect.
|
|
29
|
-
await device.setBrightness(0)
|
|
30
|
-
// ponytail: give the queued USB writes a moment to drain before the caller
|
|
31
|
-
// closes the device; otherwise node-hid may flush to a closed handle and
|
|
32
|
-
// the panel keeps the last fully-rendered frame.
|
|
22
|
+
// ponytail: allow queued image writes to drain before the caller closes
|
|
23
|
+
// the device; brightness is intentionally left unchanged.
|
|
33
24
|
await new Promise<void>((r) => setTimeout(r, 200))
|
|
34
25
|
logger.info("black-frame: pushed")
|
|
35
26
|
} catch (err) {
|
package/src/outputClient/real.ts
CHANGED
|
@@ -147,6 +147,8 @@ export class RealOutputClient implements OutputClient {
|
|
|
147
147
|
let configUiSupervisor: SuperviseHandle | null = null
|
|
148
148
|
|
|
149
149
|
try {
|
|
150
|
+
this.deviceBrightness = opts.runtime.getBrightness()
|
|
151
|
+
await device.setBrightness(this.deviceBrightness)
|
|
150
152
|
// ponytail: paint the waiting state directly to hardware before Vite or
|
|
151
153
|
// Playwright starts; the deck must remain useful when its frontend is down.
|
|
152
154
|
const logoCandidates = [
|
|
@@ -270,7 +270,22 @@ const BROWSER_NODE_STUBS: ReadonlyArray<{
|
|
|
270
270
|
hasDefault: false,
|
|
271
271
|
names: ["readFile", "readdir", "stat"],
|
|
272
272
|
},
|
|
273
|
-
{
|
|
273
|
+
{
|
|
274
|
+
specifier: "node:path",
|
|
275
|
+
hasDefault: false,
|
|
276
|
+
names: [
|
|
277
|
+
"join",
|
|
278
|
+
"dirname",
|
|
279
|
+
"basename",
|
|
280
|
+
"isAbsolute",
|
|
281
|
+
"resolve",
|
|
282
|
+
"extname",
|
|
283
|
+
"relative",
|
|
284
|
+
"normalize",
|
|
285
|
+
"parse",
|
|
286
|
+
"sep",
|
|
287
|
+
],
|
|
288
|
+
},
|
|
274
289
|
]
|
|
275
290
|
|
|
276
291
|
const nodeStubSource = ({
|