@sirenodeck/sirenodeck 0.2.10 → 0.4.1

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.
Files changed (71) hide show
  1. package/config-ui/vite.config.ts +2 -0
  2. package/dist/main.mjs +1585 -807
  3. package/dist/{windows-CRWdUgCn.mjs → windows-BCvfQ3PA.mjs} +4 -4
  4. package/frontend/src/App.tsx +3 -0
  5. package/frontend/src/components/Deck.tsx +13 -2
  6. package/frontend/vite.config.ts +2 -0
  7. package/package.json +10 -1
  8. package/src/addon/api.ts +24 -1
  9. package/src/addon/data-directory.ts +52 -0
  10. package/src/api/protocol-internal.ts +5 -0
  11. package/src/builtin-addons/index.ts +0 -1
  12. package/src/builtin-addons/internal-settings/backend.ts +1 -1
  13. package/src/builtin-addons/internal-settings/buttons/brightness/common/frontend.tsx +14 -3
  14. package/src/builtin-addons/internal-settings/buttons/brightness-compact/frontend.tsx +6 -0
  15. package/src/builtin-addons/internal-settings/index.ts +15 -0
  16. package/src/builtin-addons/register-builtins.ts +0 -3
  17. package/src/cli/commands/addon-decks.ts +1 -0
  18. package/src/cli/commands/addon-setup-config.ts +85 -0
  19. package/src/cli/commands/addon-setup.ts +134 -0
  20. package/src/cli/commands/run.ts +57 -11
  21. package/src/cli/commands/service-manager.ts +3 -5
  22. package/src/cli/commands/start.ts +14 -81
  23. package/src/cli/commands/status-probes.ts +126 -0
  24. package/src/cli/commands/status.ts +166 -16
  25. package/src/cli/commands/stop.ts +4 -0
  26. package/src/cli/index.ts +2 -0
  27. package/src/config/environment.ts +44 -0
  28. package/src/config/loader.ts +17 -1
  29. package/src/config/schemas.ts +2 -1
  30. package/src/config/validation.ts +5 -1
  31. package/src/deck/addon-handler-bridge.ts +105 -6
  32. package/src/deck/addon-settings.ts +94 -0
  33. package/src/deck/deck-config.ts +1 -0
  34. package/src/deck/inject-config-ui-button.ts +25 -14
  35. package/src/deck/runtime/runtime.ts +175 -3
  36. package/src/deck/system-back-injection.ts +2 -0
  37. package/src/deck/system-buttons/registry.tsx +1 -0
  38. package/src/deck/system-buttons/types.ts +1 -0
  39. package/src/outputClient/real.ts +18 -1
  40. package/src/render/browser-renderer.ts +68 -12
  41. package/src/render/ws-bridge.ts +2 -0
  42. package/src/system/credentials/native.ts +74 -0
  43. package/src/system/credentials/store.ts +77 -0
  44. package/src/system/providers/notification/windows.ts +4 -4
  45. package/src/themes/default/sirenodeck.json +1 -0
  46. package/src/themes/light/sirenodeck.json +1 -0
  47. package/src/themes/manifest.ts +1 -0
  48. package/src/ui/primitives/Chip.tsx +1 -0
  49. package/src/ui/primitives/StatusIndicator.tsx +36 -0
  50. package/src/ui/primitives/index.ts +1 -0
  51. package/src/ui/surfaces/BinaryToggleSurface.tsx +52 -0
  52. package/src/ui/surfaces/LoadingSurface.tsx +34 -0
  53. package/src/ui/surfaces/index.ts +2 -0
  54. package/src/util/build-fingerprint.ts +32 -0
  55. package/src/util/daemon-control.ts +41 -0
  56. package/src/util/runtime-health.ts +57 -0
  57. package/src/util/runtime-identity.ts +25 -0
  58. package/src/vite/component-identity.ts +48 -0
  59. package/src/builtin-addons/brightness/README.md +0 -51
  60. package/src/builtin-addons/brightness/buttons/brightness/backend.ts +0 -13
  61. package/src/builtin-addons/brightness/buttons/brightness/config.ts +0 -20
  62. package/src/builtin-addons/brightness/buttons/brightness/frontend.tsx +0 -50
  63. package/src/builtin-addons/brightness/domain/macos.ts +0 -46
  64. package/src/builtin-addons/brightness/index.d.ts +0 -5
  65. package/src/builtin-addons/brightness/index.ts +0 -20
  66. package/src/builtin-addons/brightness/poller.ts +0 -27
  67. package/src/builtin-addons/brightness/sirenodeck.json +0 -6
  68. /package/src/builtin-addons/{brightness/providers → internal-settings/brightness-providers}/darwin.ts +0 -0
  69. /package/src/builtin-addons/{brightness/providers → internal-settings/brightness-providers}/index.ts +0 -0
  70. /package/src/builtin-addons/{brightness/providers → internal-settings/brightness-providers}/linux.ts +0 -0
  71. /package/src/builtin-addons/{brightness/providers → internal-settings/brightness-providers}/windows.ts +0 -0
@@ -0,0 +1,74 @@
1
+ import { createHash } from "node:crypto"
2
+ import { CredentialStoreError, type CredentialBackend } from "./store"
3
+
4
+ type NativeEntry = {
5
+ getSecret(): Promise<number[] | null>
6
+ setSecret(value: Uint8Array): Promise<void>
7
+ deleteCredential(): Promise<boolean>
8
+ }
9
+ type EntryFactory = (account: string) => Promise<NativeEntry>
10
+
11
+ const accountFor = (addon: string, name: string): string =>
12
+ createHash("sha256")
13
+ .update(JSON.stringify([addon, name]))
14
+ .digest("hex")
15
+
16
+ /** Entries contain no user-provided names in native-store metadata. */
17
+ export const createNativeCredentialBackend = (
18
+ createEntry: EntryFactory = async (account) => {
19
+ const { AsyncEntry } = await import("@napi-rs/keyring")
20
+ return new AsyncEntry("sirenodeck.credentials.v1", account, {
21
+ linux: { store: "secret-service" },
22
+ })
23
+ },
24
+ ): CredentialBackend => {
25
+ const entry = async (addon: string, name: string): Promise<NativeEntry> => {
26
+ try {
27
+ return await createEntry(accountFor(addon, name))
28
+ } catch {
29
+ throw new CredentialStoreError("unavailable")
30
+ }
31
+ }
32
+ return {
33
+ availability: async () => {
34
+ try {
35
+ const probe = await createEntry(
36
+ accountFor("sirenodeck", "availability-probe"),
37
+ )
38
+ await probe.getSecret()
39
+ return "available"
40
+ } catch {
41
+ return "unavailable"
42
+ }
43
+ },
44
+ get: async (addon, name) => {
45
+ const item = await entry(addon, name)
46
+ try {
47
+ const bytes = await item.getSecret()
48
+ return bytes === null
49
+ ? undefined
50
+ : new TextDecoder("utf-8", { fatal: true }).decode(
51
+ Uint8Array.from(bytes),
52
+ )
53
+ } catch {
54
+ throw new CredentialStoreError("operation-failed")
55
+ }
56
+ },
57
+ set: async (addon, name, value) => {
58
+ const item = await entry(addon, name)
59
+ try {
60
+ await item.setSecret(new TextEncoder().encode(value))
61
+ } catch {
62
+ throw new CredentialStoreError("operation-failed")
63
+ }
64
+ },
65
+ delete: async (addon, name) => {
66
+ const item = await entry(addon, name)
67
+ try {
68
+ await item.deleteCredential()
69
+ } catch {
70
+ throw new CredentialStoreError("operation-failed")
71
+ }
72
+ },
73
+ }
74
+ }
@@ -0,0 +1,77 @@
1
+ /** Windows Credential Manager's generic credential blob limit, in bytes. */
2
+ export const MAX_CREDENTIAL_BYTES = 2560
3
+
4
+ export type CredentialErrorCode =
5
+ | "unavailable"
6
+ | "locked"
7
+ | "too-large"
8
+ | "invalid-name"
9
+ | "operation-failed"
10
+
11
+ /** Error messages must not include credential values or native error details. */
12
+ export class CredentialStoreError extends Error {
13
+ constructor(readonly code: CredentialErrorCode) {
14
+ super(`Credential store: ${code}`)
15
+ this.name = "CredentialStoreError"
16
+ }
17
+ }
18
+
19
+ /** A backend receives the addon scope from the host, not from addon code. */
20
+ export interface CredentialBackend {
21
+ availability(): Promise<"available" | "locked" | "unavailable">
22
+ get(addon: string, name: string): Promise<string | undefined>
23
+ set(addon: string, name: string, value: string): Promise<void>
24
+ delete(addon: string, name: string): Promise<void>
25
+ }
26
+
27
+ export interface AddonCredentials {
28
+ availability(): Promise<"available" | "locked" | "unavailable">
29
+ get(name: string): Promise<string | undefined>
30
+ set(name: string, value: string): Promise<void>
31
+ delete(name: string): Promise<void>
32
+ }
33
+
34
+ const validateName = (name: string): void => {
35
+ if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(name)) {
36
+ throw new CredentialStoreError("invalid-name")
37
+ }
38
+ }
39
+
40
+ /** Bind an addon identity so callers cannot choose another namespace. */
41
+ export const scopeCredentials = (
42
+ backend: CredentialBackend,
43
+ addon: string,
44
+ ): AddonCredentials => {
45
+ return {
46
+ availability: () => backend.availability(),
47
+ get: async (name) => {
48
+ validateName(name)
49
+ return backend.get(addon, name)
50
+ },
51
+ set: async (name, value) => {
52
+ validateName(name)
53
+ if (Buffer.byteLength(value, "utf8") > MAX_CREDENTIAL_BYTES) {
54
+ throw new CredentialStoreError("too-large")
55
+ }
56
+ await backend.set(addon, name, value)
57
+ },
58
+ delete: async (name) => {
59
+ validateName(name)
60
+ await backend.delete(addon, name)
61
+ },
62
+ }
63
+ }
64
+
65
+ /** Fail closed until a native credential backend is installed and available. */
66
+ export const unavailableCredentialBackend: CredentialBackend = {
67
+ availability: async () => "unavailable",
68
+ get: async () => {
69
+ throw new CredentialStoreError("unavailable")
70
+ },
71
+ set: async () => {
72
+ throw new CredentialStoreError("unavailable")
73
+ },
74
+ delete: async () => {
75
+ throw new CredentialStoreError("unavailable")
76
+ },
77
+ }
@@ -18,14 +18,14 @@ const shellQuote = (value: string): string =>
18
18
  // ponytail: raw toast template via PowerShell BurntToast-free path. Sufficient
19
19
  // for our "Pomodoro done" use case; richer XML templates are out of scope.
20
20
  const buildToastScript = (title: string, body: string): string => {
21
- const safeTitle = title.replace(/[`$"\\]/g, "\\$&")
22
- const safeBody = body.replace(/[`$"\\]/g, "\\$&")
21
+ const safeTitle = Buffer.from(title, "utf8").toString("base64")
22
+ const safeBody = Buffer.from(body, "utf8").toString("base64")
23
23
  return [
24
24
  "Add-Type -AssemblyName System.Windows.Forms | Out-Null",
25
25
  `$balloon = New-Object System.Windows.Forms.NotifyIcon`,
26
26
  `$balloon.Icon = [System.Drawing.SystemIcons]::Information`,
27
- `$balloon.BalloonTipTitle = "${safeTitle}"`,
28
- `$balloon.BalloonTipText = "${safeBody}"`,
27
+ `$balloon.BalloonTipTitle = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${safeTitle}'))`,
28
+ `$balloon.BalloonTipText = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${safeBody}'))`,
29
29
  `$balloon.Visible = $true`,
30
30
  `$balloon.ShowBalloonTip(5000)`,
31
31
  "Start-Sleep -Milliseconds 5500",
@@ -6,6 +6,7 @@
6
6
  "description": "The default dark theme for Sireno Deck.",
7
7
  "colorTokens": {
8
8
  "background": "#2e3540",
9
+ "modalDeckBgr": "#252b34",
9
10
  "frame": "#53738B",
10
11
  "foreground": "#eef2f7",
11
12
  "foreground-contrast": "#333",
@@ -6,6 +6,7 @@
6
6
  "description": "Light theme for Sireno Deck.",
7
7
  "colorTokens": {
8
8
  "background": "#f5f7fa",
9
+ "modalDeckBgr": "#dde3ea",
9
10
  "frame": "#9eb4c5",
10
11
  "foreground": "#1a202c",
11
12
  "foreground-contrast": "#fafafa",
@@ -3,6 +3,7 @@ import { z } from "zod"
3
3
  export const ThemeColorTokenSchema = z
4
4
  .object({
5
5
  background: z.string().min(1),
6
+ modalDeckBgr: z.string().min(1).optional(),
6
7
  frame: z.string().min(1),
7
8
  foreground: z.string().min(1),
8
9
  "foreground-contrast": z.string().min(1),
@@ -46,6 +46,7 @@ export function chipBase(props: ChipProps): ReactElement {
46
46
  TONE_CLASS[tone],
47
47
  ])}
48
48
  size={props.size ?? "sm"}
49
+ tone={tone}
49
50
  data-sireno-ui-chip="true"
50
51
  text={props.text}
51
52
  />
@@ -0,0 +1,36 @@
1
+ import type { ReactElement } from "react"
2
+ import type { ChipTone } from "./Chip"
3
+
4
+ const TONE_CLASS: Record<ChipTone, string> = {
5
+ accent: "bg-accent text-accent",
6
+ danger: "bg-danger text-danger",
7
+ foreground: "bg-foreground text-foreground",
8
+ primary: "bg-primary text-primary",
9
+ success: "bg-success text-success",
10
+ muted: "bg-grey text-grey",
11
+ }
12
+
13
+ export interface StatusIndicatorProps {
14
+ label: string
15
+ tone: ChipTone
16
+ glow?: boolean
17
+ }
18
+
19
+ export function StatusIndicator({
20
+ label,
21
+ tone,
22
+ glow = false,
23
+ }: StatusIndicatorProps): ReactElement {
24
+ return (
25
+ <span
26
+ role="img"
27
+ aria-label={label}
28
+ className={`inline-block shrink-0 rounded-full ${TONE_CLASS[tone]}`}
29
+ style={{
30
+ width: 40,
31
+ height: 7,
32
+ boxShadow: glow ? "0 0 6px currentColor" : undefined,
33
+ }}
34
+ />
35
+ )
36
+ }
@@ -2,5 +2,6 @@ export * from "./Chip"
2
2
  export * from "./Icon"
3
3
  export * from "./Label"
4
4
  export * from "./ProgressBar"
5
+ export * from "./StatusIndicator"
5
6
  export * from "./TapIndicator"
6
7
  export * from "./Text"
@@ -0,0 +1,52 @@
1
+ import type { ReactElement } from "react"
2
+ import type { ChipTone } from "../primitives/Chip"
3
+ import { Icon } from "../primitives/Icon"
4
+ import { Label } from "../primitives/Label"
5
+ import { Text } from "../primitives/Text"
6
+ import { StatusIndicator } from "../primitives/StatusIndicator"
7
+
8
+ export interface BinaryToggleSurfaceProps {
9
+ label: string
10
+ labelColor?: string
11
+ source?: string
12
+ variant?: ChipTone
13
+ status: boolean
14
+ details?: string
15
+ }
16
+
17
+ export function BinaryToggleSurface({
18
+ label,
19
+ labelColor,
20
+ source,
21
+ variant = "accent",
22
+ status,
23
+ details,
24
+ }: BinaryToggleSurfaceProps): ReactElement {
25
+ return (
26
+ <div
27
+ className={`relative isolate grid h-full w-full min-w-0 grid-rows-[minmax(0,1fr)_auto] pb-1 ${
28
+ status
29
+ ? ""
30
+ : "before:absolute before:-inset-2 before:-z-10 before:bg-black/40 before:content-['']"
31
+ }`}
32
+ >
33
+ <div className="flex min-h-0 min-w-0 flex-col items-center justify-center gap-1 overflow-hidden">
34
+ {source ? <Icon source={source} size={24} /> : null}
35
+ <Text
36
+ text={label}
37
+ weight="bold"
38
+ fit={{ type: "fit", lines: 2, ellipsis: true }}
39
+ style={labelColor ? { color: labelColor } : undefined}
40
+ />
41
+ {details ? <Label text={details} variant="small" /> : null}
42
+ </div>
43
+ <div className="flex justify-center self-end">
44
+ <StatusIndicator
45
+ label={status ? "On" : "Off"}
46
+ tone={status ? variant : "danger"}
47
+ glow={status}
48
+ />
49
+ </div>
50
+ </div>
51
+ )
52
+ }
@@ -0,0 +1,34 @@
1
+ import type { ReactElement } from "react"
2
+ import { Icon } from "../primitives/Icon"
3
+ import { Label } from "../primitives/Label"
4
+
5
+ export function LoadingSurface(): ReactElement {
6
+ return (
7
+ <div
8
+ className="flex h-full w-full min-w-0 flex-col items-center justify-center gap-1 overflow-hidden"
9
+ role="status"
10
+ aria-label="Loading"
11
+ >
12
+ <style>{`
13
+ @keyframes sireno-loading-dot {
14
+ 0%, 24.999%, 50%, 100% { opacity: 1; }
15
+ 25%, 49.999% { opacity: 0; }
16
+ }
17
+ @media (prefers-reduced-motion: no-preference) {
18
+ .sireno-loading-dot { animation: sireno-loading-dot 4s steps(1, end) infinite; }
19
+ .sireno-loading-dot:nth-child(2) { animation-delay: 1s; }
20
+ .sireno-loading-dot:nth-child(3) { animation-delay: 2s; }
21
+ }
22
+ `}</style>
23
+ <Icon source="icon://hourglass" size={20} />
24
+ <div className="flex items-baseline" aria-hidden="true">
25
+ <Label text="Loading" />
26
+ <span className="font-bold" style={{ whiteSpace: "pre" }}>
27
+ <span className="sireno-loading-dot">.</span>
28
+ <span className="sireno-loading-dot">.</span>
29
+ <span className="sireno-loading-dot">.</span>
30
+ </span>
31
+ </div>
32
+ </div>
33
+ )
34
+ }
@@ -1,7 +1,9 @@
1
1
  export * from "./BarsSurface"
2
+ export * from "./BinaryToggleSurface"
2
3
  export * from "./IconLabelProgressSurface"
3
4
  export * from "./IconLabelSurface"
4
5
  export * from "./LabelValueListSurface"
6
+ export * from "./LoadingSurface"
5
7
  export * from "./TemporaryErrorSurface"
6
8
  export * from "./ValueChart"
7
9
 
@@ -0,0 +1,32 @@
1
+ import { createHash } from "node:crypto"
2
+ import { readdirSync, readFileSync } from "node:fs"
3
+ import { join } from "node:path"
4
+
5
+ /** Fingerprint the source inputs shared by the CLI and its web surfaces. */
6
+ export const fingerprintBuildInputs = (root: string): string => {
7
+ const hash = createHash("sha256")
8
+ const visit = (relative: string): void => {
9
+ const entries = readdirSync(join(root, relative), {
10
+ withFileTypes: true,
11
+ }).sort((a, b) => a.name.localeCompare(b.name, "en"))
12
+ for (const entry of entries) {
13
+ if (
14
+ entry.name.startsWith(".") ||
15
+ ["node_modules", "dist", "__tests__", "coverage"].includes(entry.name)
16
+ )
17
+ continue
18
+ const path = relative ? `${relative}/${entry.name}` : entry.name
19
+ if (entry.isDirectory()) visit(path)
20
+ else if (entry.isFile() && !/\.(test|spec)\.[^.]+$/.test(entry.name)) {
21
+ const contents = readFileSync(join(root, path))
22
+ hash.update(`${path.length}:${path}:${contents.length}:`)
23
+ hash.update(contents)
24
+ }
25
+ }
26
+ }
27
+ for (const directory of ["src", "frontend", "config-ui"]) visit(directory)
28
+ const manifest = readFileSync(join(root, "package.json"))
29
+ hash.update(`package.json:${manifest.length}:`)
30
+ hash.update(manifest)
31
+ return hash.digest("hex")
32
+ }
@@ -6,6 +6,11 @@ import type pino from "pino"
6
6
 
7
7
  import type { DaemonPaths } from "./daemon"
8
8
  import { isSocketLive } from "./single-instance"
9
+ import {
10
+ runtimeHealth,
11
+ runtimeHealthSchema,
12
+ type RuntimeHealth,
13
+ } from "./runtime-health"
9
14
 
10
15
  const GET_TOKEN = "get-token\n"
11
16
 
@@ -33,6 +38,8 @@ export const startDaemonControl = async (
33
38
  socket.setEncoding("utf8")
34
39
  socket.on("data", (data) => {
35
40
  if (String(data).trim() === "get-token") socket.end(`${token}\n`)
41
+ else if (String(data).trim() === "get-health")
42
+ socket.end(`${JSON.stringify(runtimeHealth.snapshot())}\n`)
36
43
  else socket.destroy()
37
44
  })
38
45
  })
@@ -83,3 +90,37 @@ export const requestDaemonToken = (
83
90
  export const removeDaemonControl = (paths: DaemonPaths): void => {
84
91
  if (existsSync(paths.controlSocket)) unlinkSync(paths.controlSocket)
85
92
  }
93
+
94
+ export const requestDaemonHealth = (
95
+ paths: DaemonPaths,
96
+ timeoutMs = 1_000,
97
+ ): Promise<RuntimeHealth | null> =>
98
+ new Promise((resolve) => {
99
+ if (!existsSync(paths.controlSocket)) return resolve(null)
100
+ const socket = connect(paths.controlSocket)
101
+ let data = ""
102
+ let settled = false
103
+ const finish = (value: RuntimeHealth | null): void => {
104
+ if (settled) return
105
+ settled = true
106
+ clearTimeout(timer)
107
+ socket.destroy()
108
+ resolve(value)
109
+ }
110
+ const timer = setTimeout(() => finish(null), timeoutMs)
111
+ socket.setEncoding("utf8")
112
+ socket.on("connect", () => socket.write("get-health\n"))
113
+ socket.on("data", (chunk) => {
114
+ data += chunk
115
+ if (!data.includes("\n")) return
116
+ try {
117
+ const parsed: unknown = JSON.parse(data.split("\n", 1)[0]!)
118
+ const result = runtimeHealthSchema.safeParse(parsed)
119
+ finish(result.success ? result.data : null)
120
+ } catch {
121
+ finish(null)
122
+ }
123
+ })
124
+ socket.on("error", () => finish(null))
125
+ socket.on("close", () => finish(null))
126
+ })
@@ -0,0 +1,57 @@
1
+ import { runtimeIdentity } from "./runtime-identity"
2
+ import { z } from "zod"
3
+
4
+ export type RendererState =
5
+ | "starting"
6
+ | "healthy"
7
+ | "recovering"
8
+ | "failed"
9
+ | "not-applicable"
10
+ export interface RuntimeHealth {
11
+ identity: { version: string; buildId: string | null }
12
+ core: "starting" | "ready" | "stopping"
13
+ renderer: { state: RendererState; lastFrameAt: number | null }
14
+ }
15
+
16
+ export const runtimeHealthSchema = z
17
+ .object({
18
+ identity: z
19
+ .object({ version: z.string(), buildId: z.string().nullable() })
20
+ .strict(),
21
+ core: z.enum(["starting", "ready", "stopping"]),
22
+ renderer: z
23
+ .object({
24
+ state: z.enum([
25
+ "starting",
26
+ "healthy",
27
+ "recovering",
28
+ "failed",
29
+ "not-applicable",
30
+ ]),
31
+ lastFrameAt: z.number().finite().nullable(),
32
+ })
33
+ .strict(),
34
+ })
35
+ .strict()
36
+
37
+ const health: RuntimeHealth = {
38
+ identity: runtimeIdentity,
39
+ core: "starting",
40
+ renderer: { state: "starting", lastFrameAt: null },
41
+ }
42
+
43
+ export const runtimeHealth = {
44
+ snapshot: (): RuntimeHealth => ({
45
+ ...health,
46
+ renderer: { ...health.renderer },
47
+ }),
48
+ setCore: (state: RuntimeHealth["core"]): void => {
49
+ health.core = state
50
+ },
51
+ setRenderer: (
52
+ state: RendererState,
53
+ lastFrameAt = health.renderer.lastFrameAt,
54
+ ): void => {
55
+ health.renderer = { state, lastFrameAt }
56
+ },
57
+ }
@@ -0,0 +1,25 @@
1
+ import { dirname, resolve } from "node:path"
2
+ import { fileURLToPath } from "node:url"
3
+ import { VERSION } from "../version"
4
+ import { fingerprintBuildInputs } from "./build-fingerprint"
5
+
6
+ declare const __SIRENO_BUILD_ID__: string | undefined
7
+
8
+ const development = process.env.SIRENO_DEV_MODE === "true"
9
+ let buildId: string | null = null
10
+ if (typeof __SIRENO_BUILD_ID__ !== "undefined") {
11
+ buildId = __SIRENO_BUILD_ID__
12
+ } else if (development) {
13
+ try {
14
+ buildId = fingerprintBuildInputs(
15
+ resolve(dirname(fileURLToPath(import.meta.url)), "../.."),
16
+ )
17
+ } catch {
18
+ // A missing source tree cannot establish a build identity.
19
+ }
20
+ }
21
+
22
+ export const runtimeIdentity = {
23
+ version: `${VERSION}${development ? "-dev" : ""}`,
24
+ buildId,
25
+ } as const
@@ -0,0 +1,48 @@
1
+ import type { Plugin } from "vite"
2
+ import { fingerprintBuildInputs } from "../util/build-fingerprint"
3
+ import packageJson from "../../package.json" with { type: "json" }
4
+
5
+ export const componentIdentity = (
6
+ root: string,
7
+ component: "frontend" | "config-ui",
8
+ ): Plugin => {
9
+ let buildId: string | null = null
10
+ try {
11
+ buildId = fingerprintBuildInputs(root)
12
+ } catch {
13
+ /* unavailable source */
14
+ }
15
+ const version = `${packageJson.version}${process.env.SIRENO_DEV_MODE === "true" ? "-dev" : ""}`
16
+ const identity = JSON.stringify({ component, version, buildId })
17
+ return {
18
+ name: "sireno-component-identity",
19
+ configureServer(server) {
20
+ server.middlewares.use("/assets/sirenodeck-build.json", (_req, res) => {
21
+ res.setHeader("Content-Type", "application/json")
22
+ res.setHeader("Cache-Control", "no-store")
23
+ // HMR can change browser code without restarting the server. Do not
24
+ // claim the startup fingerprint still identifies the running bundle.
25
+ let current: string | null = null
26
+ try {
27
+ current = fingerprintBuildInputs(root)
28
+ } catch {
29
+ /* unavailable source */
30
+ }
31
+ res.end(
32
+ JSON.stringify({
33
+ component,
34
+ version,
35
+ buildId: current === buildId ? buildId : null,
36
+ }),
37
+ )
38
+ })
39
+ },
40
+ generateBundle() {
41
+ this.emitFile({
42
+ type: "asset",
43
+ fileName: "assets/sirenodeck-build.json",
44
+ source: identity,
45
+ })
46
+ },
47
+ }
48
+ }
@@ -1,51 +0,0 @@
1
- # brightness
2
-
3
- Single button that adjusts screen brightness. Tap = action (up/down/set). The button shows the current brightness as a bar.
4
-
5
- Uses the OS provider from `packages/cli/src/system/providers/`:
6
-
7
- - Linux: `xrandr` / `brightnessctl` (whichever is available)
8
- - macOS: `osascript`
9
- - Windows: PowerShell + WMI
10
-
11
- ## Buttons
12
-
13
- | Type | Description |
14
- | ----------------------- | ------------------------------------------------ |
15
- | `brightness:brightness` | Single button: shows + adjusts screen brightness |
16
-
17
- ## Config
18
-
19
- ```yaml
20
- - position: 5
21
- type: brightness:brightness
22
- config:
23
- action: up # "up" (default), "down", or "set"
24
- value: 75 # required for "set" (0-100); ignored for up/down
25
- ```
26
-
27
- ### Gesture semantics
28
-
29
- - **Tap** on a `brightness:brightness` button → executes the configured `action`.
30
- - **Hold** on a `brightness:brightness` button → toggles between `up` and `down` for fine-grained adjustment.
31
-
32
- ## Example
33
-
34
- In your `settings` deck (auto-generated by `internal-settings`):
35
-
36
- ```yaml
37
- decks:
38
- settings:
39
- name: Settings
40
- buttons:
41
- - position: 0
42
- type: brightness:brightness
43
- config: { action: up }
44
- ```
45
-
46
- Run `xrandr --output eDP-1 --brightness 0.75` (Linux) to verify the action works on your system.
47
-
48
- ## See also
49
-
50
- - [system-status](../system-status/README.md) — same polling pattern; brightness is just a one-button metric
51
- - [OS providers](../../../../system/providers/README.md) — brightness provider per OS
@@ -1,13 +0,0 @@
1
- import type { AddonButtonTypeService } from "@/addon/api"
2
-
3
- import { buildMacOSCommand, formatCommand, isMacOS } from "../../domain/macos"
4
- import { configSchema, type ConfigSchema } from "./config"
5
-
6
- export default {
7
- configSchema,
8
- defaultRenderIntervalMs: 2000,
9
- onTap: ({ config, executor }) => {
10
- if (!isMacOS(process.platform)) return
11
- void executor.run(formatCommand(buildMacOSCommand(config))).catch(() => {})
12
- },
13
- } satisfies AddonButtonTypeService<ConfigSchema>
@@ -1,20 +0,0 @@
1
- import { z } from "zod"
2
-
3
- export const configSchema = z
4
- .object({
5
- action: z
6
- .enum(["up", "down", "set"])
7
- .optional()
8
- .default("up")
9
- .meta({ title: "Brightness action" }),
10
- value: z
11
- .number()
12
- .int()
13
- .min(0)
14
- .max(100)
15
- .optional()
16
- .meta({ title: "Brightness (%)" }),
17
- })
18
- .strict()
19
-
20
- export type ConfigSchema = z.infer<typeof configSchema>