@sirenodeck/sirenodeck 0.2.7 → 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 +299 -41557
- 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/service-manager.ts +53 -1
- package/src/device/black-frame.ts +3 -7
- package/src/vite/virtual-modules.ts +16 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { WsStatus } from "../bridge"
|
|
2
|
+
|
|
3
|
+
export interface DisconnectedOverlayProps {
|
|
4
|
+
readonly status: WsStatus
|
|
5
|
+
readonly disconnectedSince: number | null
|
|
6
|
+
readonly attempt: number
|
|
7
|
+
readonly lastError: string | null
|
|
8
|
+
readonly now: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const formatElapsed = (ms: number): string => {
|
|
12
|
+
const totalSeconds = Math.floor(ms / 1000)
|
|
13
|
+
const minutes = Math.floor(totalSeconds / 60)
|
|
14
|
+
const seconds = totalSeconds % 60
|
|
15
|
+
return `${minutes.toString().padStart(2, "0")}:${seconds
|
|
16
|
+
.toString()
|
|
17
|
+
.padStart(2, "0")}`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const statusText = (status: WsStatus, attempt: number): string => {
|
|
21
|
+
if (status === "failed")
|
|
22
|
+
return `Failed to reconnect after ${attempt} attempts`
|
|
23
|
+
if (status === "closed") return "Disconnected"
|
|
24
|
+
if (status === "connecting") return "Connecting…"
|
|
25
|
+
return status
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const DisconnectedOverlay = ({
|
|
29
|
+
status,
|
|
30
|
+
disconnectedSince,
|
|
31
|
+
attempt,
|
|
32
|
+
lastError,
|
|
33
|
+
now,
|
|
34
|
+
}: DisconnectedOverlayProps) => {
|
|
35
|
+
if (status === "open" || disconnectedSince === null) return null
|
|
36
|
+
const elapsed = now - disconnectedSince
|
|
37
|
+
if (elapsed < 30000) return null
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
data-testid="disconnected-overlay"
|
|
41
|
+
className="fixed inset-0 z-50 flex items-center justify-center bg-neutral-950/90 backdrop-blur"
|
|
42
|
+
>
|
|
43
|
+
<div className="w-full max-w-md rounded-xl border border-red-500/40 bg-neutral-900/95 p-8 text-center shadow-2xl">
|
|
44
|
+
<h2 className="mb-2 text-2xl font-semibold text-red-400">
|
|
45
|
+
Connection lost
|
|
46
|
+
</h2>
|
|
47
|
+
<p className="mb-6 text-sm text-neutral-400">
|
|
48
|
+
{statusText(status, attempt)}
|
|
49
|
+
</p>
|
|
50
|
+
<dl className="space-y-2 text-left text-sm">
|
|
51
|
+
<div className="flex justify-between">
|
|
52
|
+
<dt className="text-neutral-500">Status</dt>
|
|
53
|
+
<dd className="font-mono text-neutral-200">{status}</dd>
|
|
54
|
+
</div>
|
|
55
|
+
<div className="flex justify-between">
|
|
56
|
+
<dt className="text-neutral-500">Reconnect attempts</dt>
|
|
57
|
+
<dd className="font-mono text-neutral-200">{attempt}</dd>
|
|
58
|
+
</div>
|
|
59
|
+
{lastError !== null && (
|
|
60
|
+
<div className="flex justify-between">
|
|
61
|
+
<dt className="text-neutral-500">Last error</dt>
|
|
62
|
+
<dd className="truncate font-mono text-neutral-200">
|
|
63
|
+
{lastError}
|
|
64
|
+
</dd>
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
67
|
+
<div className="flex justify-between">
|
|
68
|
+
<dt className="text-neutral-500">Elapsed</dt>
|
|
69
|
+
<dd className="font-mono text-neutral-200">
|
|
70
|
+
{formatElapsed(elapsed)}
|
|
71
|
+
</dd>
|
|
72
|
+
</div>
|
|
73
|
+
</dl>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useMemo, useState } from "react"
|
|
2
|
+
import { Button, Input } from "@heroui/react"
|
|
3
|
+
|
|
4
|
+
import { categories } from "@/builtin-addons/emoji-selector/data/categories"
|
|
5
|
+
|
|
6
|
+
export const EmojiPicker = ({
|
|
7
|
+
value,
|
|
8
|
+
onSelect,
|
|
9
|
+
}: {
|
|
10
|
+
readonly value: string
|
|
11
|
+
readonly onSelect: (emoji: string) => void
|
|
12
|
+
}) => {
|
|
13
|
+
const [query, setQuery] = useState("")
|
|
14
|
+
const filtered = useMemo(() => {
|
|
15
|
+
const search = query.trim().toLowerCase()
|
|
16
|
+
return categories.map((category) => ({
|
|
17
|
+
...category,
|
|
18
|
+
emojis: search
|
|
19
|
+
? category.emojis.filter((emoji) =>
|
|
20
|
+
`${emoji.char} ${emoji.shortcode ?? ""}`
|
|
21
|
+
.toLowerCase()
|
|
22
|
+
.includes(search),
|
|
23
|
+
)
|
|
24
|
+
: category.emojis,
|
|
25
|
+
}))
|
|
26
|
+
}, [query])
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className="grid gap-3">
|
|
30
|
+
<Input
|
|
31
|
+
aria-label="Search emoji"
|
|
32
|
+
placeholder="Search emoji or name"
|
|
33
|
+
value={query}
|
|
34
|
+
onChange={(event) => setQuery(event.target.value)}
|
|
35
|
+
/>
|
|
36
|
+
<div className="max-h-[50vh] space-y-3 overflow-y-auto">
|
|
37
|
+
{filtered.map((category) =>
|
|
38
|
+
category.emojis.length === 0 ? null : (
|
|
39
|
+
<section key={category.id} aria-label={category.label}>
|
|
40
|
+
<h4 className="mb-1 text-sm text-muted">{category.label}</h4>
|
|
41
|
+
<div className="grid grid-cols-8 gap-1 sm:grid-cols-10">
|
|
42
|
+
{category.emojis.map((emoji) => (
|
|
43
|
+
<Button
|
|
44
|
+
key={`${category.id}:${emoji.char}`}
|
|
45
|
+
type="button"
|
|
46
|
+
size="sm"
|
|
47
|
+
variant={value === emoji.char ? "secondary" : "tertiary"}
|
|
48
|
+
isIconOnly
|
|
49
|
+
aria-label={emoji.shortcode ?? emoji.char}
|
|
50
|
+
aria-pressed={value === emoji.char}
|
|
51
|
+
title={emoji.shortcode}
|
|
52
|
+
className="size-9 min-w-9 rounded-md p-0 text-xl hover:outline hover:outline-2 hover:outline-primary"
|
|
53
|
+
onPress={() => onSelect(emoji.char)}
|
|
54
|
+
>
|
|
55
|
+
{emoji.char}
|
|
56
|
+
</Button>
|
|
57
|
+
))}
|
|
58
|
+
</div>
|
|
59
|
+
</section>
|
|
60
|
+
),
|
|
61
|
+
)}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { useState } from "react"
|
|
2
|
+
import { Button, Input, Label, Modal, Tabs, TextField } from "@heroui/react"
|
|
3
|
+
import * as lucideIcons from "lucide-react"
|
|
4
|
+
import { Icon } from "@sirenodeck/sirenodeck"
|
|
5
|
+
|
|
6
|
+
import { EmojiPicker } from "./EmojiPicker"
|
|
7
|
+
|
|
8
|
+
export interface PendingIconAsset {
|
|
9
|
+
readonly filename: string
|
|
10
|
+
readonly data: string
|
|
11
|
+
readonly preview: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let assetNumber = 0
|
|
15
|
+
|
|
16
|
+
const LUCIDE_ICONS = Object.keys(lucideIcons)
|
|
17
|
+
.filter(
|
|
18
|
+
(name) =>
|
|
19
|
+
/^[A-Z]/.test(name) &&
|
|
20
|
+
name !== "createLucideIcon" &&
|
|
21
|
+
!name.endsWith("Icon") &&
|
|
22
|
+
!name.endsWith("Provider"),
|
|
23
|
+
)
|
|
24
|
+
.map((name) => name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase())
|
|
25
|
+
.filter((name, index, names) => names.indexOf(name) === index)
|
|
26
|
+
.sort()
|
|
27
|
+
|
|
28
|
+
export const IconPicker = ({
|
|
29
|
+
label,
|
|
30
|
+
value,
|
|
31
|
+
onApply,
|
|
32
|
+
}: {
|
|
33
|
+
readonly label: string
|
|
34
|
+
readonly value: string
|
|
35
|
+
readonly onApply: (value: string, asset?: PendingIconAsset) => void
|
|
36
|
+
}) => {
|
|
37
|
+
const [open, setOpen] = useState(false)
|
|
38
|
+
const [kind, setKind] = useState("lucide")
|
|
39
|
+
const [draft, setDraft] = useState(value)
|
|
40
|
+
const [asset, setAsset] = useState<PendingIconAsset | null>(null)
|
|
41
|
+
const [appliedPreview, setAppliedPreview] = useState<{
|
|
42
|
+
source: string
|
|
43
|
+
dataUrl: string
|
|
44
|
+
} | null>(null)
|
|
45
|
+
const [fileError, setFileError] = useState<string | null>(null)
|
|
46
|
+
const [query, setQuery] = useState("")
|
|
47
|
+
const [visibleIconCount, setVisibleIconCount] = useState(120)
|
|
48
|
+
const matchingIcons = LUCIDE_ICONS.filter((name) =>
|
|
49
|
+
name.includes(query.trim().toLowerCase()),
|
|
50
|
+
)
|
|
51
|
+
const icons = matchingIcons.slice(0, visibleIconCount)
|
|
52
|
+
|
|
53
|
+
const close = (): void => {
|
|
54
|
+
setOpen(false)
|
|
55
|
+
setAsset(null)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className="grid min-w-0 grid-cols-[minmax(min(10rem,42%),0.85fr)_minmax(0,1.15fr)] items-center gap-x-3 gap-y-1 text-sm">
|
|
60
|
+
<Label className="min-w-0 break-words">{label}</Label>
|
|
61
|
+
<Modal>
|
|
62
|
+
<Button
|
|
63
|
+
type="button"
|
|
64
|
+
variant="tertiary"
|
|
65
|
+
className="min-h-10 min-w-0 justify-start"
|
|
66
|
+
onPress={() => {
|
|
67
|
+
setDraft(value)
|
|
68
|
+
setAsset(null)
|
|
69
|
+
setFileError(null)
|
|
70
|
+
setOpen(true)
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
{appliedPreview?.source === value ? (
|
|
74
|
+
<img
|
|
75
|
+
src={appliedPreview.dataUrl}
|
|
76
|
+
alt=""
|
|
77
|
+
className="size-6 object-contain"
|
|
78
|
+
/>
|
|
79
|
+
) : value === "" ? (
|
|
80
|
+
"Choose icon"
|
|
81
|
+
) : value.startsWith("icon://") || value.startsWith("asset://") ? (
|
|
82
|
+
<Icon source={value} size={20} />
|
|
83
|
+
) : (
|
|
84
|
+
<span className="text-xl">{value}</span>
|
|
85
|
+
)}
|
|
86
|
+
<span className="truncate">{value.split("/").at(-1)}</span>
|
|
87
|
+
</Button>
|
|
88
|
+
{open && (
|
|
89
|
+
<Modal.Backdrop
|
|
90
|
+
isOpen={open}
|
|
91
|
+
onOpenChange={(isOpen) => {
|
|
92
|
+
if (!isOpen) close()
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
<Modal.Container placement="center" scroll="inside" size="lg">
|
|
96
|
+
<Modal.Dialog
|
|
97
|
+
aria-label={`Choose ${label.toLowerCase()}`}
|
|
98
|
+
className="max-h-[85vh]"
|
|
99
|
+
>
|
|
100
|
+
<Modal.Header>
|
|
101
|
+
<Modal.Heading>Choose {label}</Modal.Heading>
|
|
102
|
+
</Modal.Header>
|
|
103
|
+
<Modal.Body className="min-h-0 flex-1 overflow-y-auto">
|
|
104
|
+
<Tabs
|
|
105
|
+
className="flex min-h-0 flex-1 flex-col"
|
|
106
|
+
selectedKey={kind}
|
|
107
|
+
onSelectionChange={(key) => setKind(String(key))}
|
|
108
|
+
>
|
|
109
|
+
<Tabs.ListContainer>
|
|
110
|
+
<Tabs.List>
|
|
111
|
+
<Tabs.Tab id="lucide">
|
|
112
|
+
Lucide
|
|
113
|
+
<Tabs.Indicator />
|
|
114
|
+
</Tabs.Tab>
|
|
115
|
+
<Tabs.Tab id="emoji">
|
|
116
|
+
Emoji
|
|
117
|
+
<Tabs.Indicator />
|
|
118
|
+
</Tabs.Tab>
|
|
119
|
+
<Tabs.Tab id="svg">
|
|
120
|
+
SVG upload
|
|
121
|
+
<Tabs.Indicator />
|
|
122
|
+
</Tabs.Tab>
|
|
123
|
+
</Tabs.List>
|
|
124
|
+
</Tabs.ListContainer>
|
|
125
|
+
<Tabs.Panel id="lucide">
|
|
126
|
+
<Input
|
|
127
|
+
aria-label="Search Lucide icons"
|
|
128
|
+
placeholder="Search by name"
|
|
129
|
+
value={query}
|
|
130
|
+
onChange={(event) => {
|
|
131
|
+
setQuery(event.target.value)
|
|
132
|
+
setVisibleIconCount(120)
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
<div className="mt-3 grid max-h-[52vh] grid-cols-6 gap-1 overflow-y-auto sm:grid-cols-8">
|
|
136
|
+
{icons.map((name) => (
|
|
137
|
+
<Button
|
|
138
|
+
key={name}
|
|
139
|
+
type="button"
|
|
140
|
+
size="sm"
|
|
141
|
+
variant={
|
|
142
|
+
draft === `icon://${name}`
|
|
143
|
+
? "secondary"
|
|
144
|
+
: "tertiary"
|
|
145
|
+
}
|
|
146
|
+
aria-label={name}
|
|
147
|
+
className="h-12 w-full min-w-0 overflow-hidden flex-col gap-0 p-1 text-[9px]"
|
|
148
|
+
onPress={() => {
|
|
149
|
+
setDraft(`icon://${name}`)
|
|
150
|
+
setAsset(null)
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
<Icon source={`icon://${name}`} size={18} />
|
|
154
|
+
<span className="w-full min-w-0 truncate text-center">
|
|
155
|
+
{name}
|
|
156
|
+
</span>
|
|
157
|
+
</Button>
|
|
158
|
+
))}
|
|
159
|
+
</div>
|
|
160
|
+
{icons.length < matchingIcons.length && (
|
|
161
|
+
<Button
|
|
162
|
+
type="button"
|
|
163
|
+
size="sm"
|
|
164
|
+
variant="tertiary"
|
|
165
|
+
className="mt-2 w-full"
|
|
166
|
+
onPress={() =>
|
|
167
|
+
setVisibleIconCount((count) => count + 120)
|
|
168
|
+
}
|
|
169
|
+
>
|
|
170
|
+
Show more icons ({matchingIcons.length - icons.length}{" "}
|
|
171
|
+
remaining)
|
|
172
|
+
</Button>
|
|
173
|
+
)}
|
|
174
|
+
</Tabs.Panel>
|
|
175
|
+
<Tabs.Panel id="emoji">
|
|
176
|
+
<EmojiPicker
|
|
177
|
+
value={draft}
|
|
178
|
+
onSelect={(emoji) => {
|
|
179
|
+
setDraft(emoji)
|
|
180
|
+
setAsset(null)
|
|
181
|
+
}}
|
|
182
|
+
/>
|
|
183
|
+
</Tabs.Panel>
|
|
184
|
+
<Tabs.Panel id="svg">
|
|
185
|
+
<TextField className="grid min-w-0 grid-cols-[minmax(min(10rem,42%),0.85fr)_minmax(0,1.15fr)] items-center gap-2">
|
|
186
|
+
<Label>Upload SVG</Label>
|
|
187
|
+
<Input
|
|
188
|
+
type="file"
|
|
189
|
+
accept="image/svg+xml,.svg"
|
|
190
|
+
aria-label="Upload SVG"
|
|
191
|
+
onChange={(event) => {
|
|
192
|
+
const file = event.target.files?.[0]
|
|
193
|
+
if (
|
|
194
|
+
file === undefined ||
|
|
195
|
+
!file.name.toLowerCase().endsWith(".svg")
|
|
196
|
+
)
|
|
197
|
+
return
|
|
198
|
+
if (file.size > 2_000_000) {
|
|
199
|
+
setFileError("SVG files must be 2 MB or smaller.")
|
|
200
|
+
setAsset(null)
|
|
201
|
+
return
|
|
202
|
+
}
|
|
203
|
+
setFileError(null)
|
|
204
|
+
const reader = new FileReader()
|
|
205
|
+
reader.onload = () => {
|
|
206
|
+
const dataUrl = String(reader.result)
|
|
207
|
+
const data = dataUrl.split(",", 2)[1]
|
|
208
|
+
if (data === undefined) return
|
|
209
|
+
const baseName = file.name
|
|
210
|
+
.replace(/[^a-zA-Z0-9._-]/g, "_")
|
|
211
|
+
.slice(-128)
|
|
212
|
+
const filename = `icon-${Date.now()}-${assetNumber++}-${baseName}`
|
|
213
|
+
setAsset({ filename, data, preview: dataUrl })
|
|
214
|
+
setDraft(`./assets/${filename}`)
|
|
215
|
+
}
|
|
216
|
+
reader.readAsDataURL(file)
|
|
217
|
+
}}
|
|
218
|
+
className="col-start-2 min-w-0 file:mr-2 file:rounded file:border-0 file:bg-surface-secondary file:px-3 file:py-2"
|
|
219
|
+
/>
|
|
220
|
+
</TextField>
|
|
221
|
+
{fileError !== null && (
|
|
222
|
+
<p role="alert" className="text-sm text-danger">
|
|
223
|
+
{fileError}
|
|
224
|
+
</p>
|
|
225
|
+
)}
|
|
226
|
+
{asset !== null && (
|
|
227
|
+
<img
|
|
228
|
+
src={asset.preview}
|
|
229
|
+
alt="SVG preview"
|
|
230
|
+
className="mt-4 size-16 object-contain"
|
|
231
|
+
/>
|
|
232
|
+
)}
|
|
233
|
+
</Tabs.Panel>
|
|
234
|
+
</Tabs>
|
|
235
|
+
</Modal.Body>
|
|
236
|
+
<Modal.Footer>
|
|
237
|
+
<Button type="button" variant="tertiary" onPress={close}>
|
|
238
|
+
Cancel
|
|
239
|
+
</Button>
|
|
240
|
+
<Button
|
|
241
|
+
type="button"
|
|
242
|
+
variant="primary"
|
|
243
|
+
isDisabled={draft === "" || fileError !== null}
|
|
244
|
+
onPress={() => {
|
|
245
|
+
onApply(draft, asset ?? undefined)
|
|
246
|
+
setAppliedPreview(
|
|
247
|
+
asset === null
|
|
248
|
+
? null
|
|
249
|
+
: { source: draft, dataUrl: asset.preview },
|
|
250
|
+
)
|
|
251
|
+
close()
|
|
252
|
+
}}
|
|
253
|
+
>
|
|
254
|
+
Apply
|
|
255
|
+
</Button>
|
|
256
|
+
</Modal.Footer>
|
|
257
|
+
</Modal.Dialog>
|
|
258
|
+
</Modal.Container>
|
|
259
|
+
</Modal.Backdrop>
|
|
260
|
+
)}
|
|
261
|
+
</Modal>
|
|
262
|
+
</div>
|
|
263
|
+
)
|
|
264
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Kbd } from "@heroui/react"
|
|
2
|
+
|
|
3
|
+
import { parseMacro } from "@/deck/macro-parse"
|
|
4
|
+
|
|
5
|
+
export const MacroPreview = ({ value }: { readonly value: string }) => {
|
|
6
|
+
if (!value.trim()) return null
|
|
7
|
+
return (
|
|
8
|
+
<div aria-label="Keyboard macro preview" className="flex flex-wrap gap-1">
|
|
9
|
+
{parseMacro(value).map((step, index) => (
|
|
10
|
+
<Kbd key={`${step.kind}-${index}`} variant="light">
|
|
11
|
+
<Kbd.Content>
|
|
12
|
+
{step.kind === "delay"
|
|
13
|
+
? `delay(${step.ms}ms)`
|
|
14
|
+
: step.kind === "text"
|
|
15
|
+
? JSON.stringify(step.value)
|
|
16
|
+
: step.value}
|
|
17
|
+
</Kbd.Content>
|
|
18
|
+
</Kbd>
|
|
19
|
+
))}
|
|
20
|
+
</div>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { WsStatus } from "../bridge"
|
|
2
|
+
|
|
3
|
+
export interface ReconnectingBannerProps {
|
|
4
|
+
readonly status: WsStatus
|
|
5
|
+
readonly disconnectedSince: number | null
|
|
6
|
+
readonly attempt: number
|
|
7
|
+
readonly now: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const formatSeconds = (ms: number): string =>
|
|
11
|
+
`${Math.floor(ms / 1000).toString()}s`
|
|
12
|
+
|
|
13
|
+
export const ReconnectingBanner = ({
|
|
14
|
+
status,
|
|
15
|
+
disconnectedSince,
|
|
16
|
+
attempt,
|
|
17
|
+
now,
|
|
18
|
+
}: ReconnectingBannerProps) => {
|
|
19
|
+
if (status === "open" || disconnectedSince === null) return null
|
|
20
|
+
const elapsed = now - disconnectedSince
|
|
21
|
+
if (elapsed >= 30000) return null
|
|
22
|
+
return (
|
|
23
|
+
<div
|
|
24
|
+
data-testid="reconnecting-banner"
|
|
25
|
+
className="pointer-events-none fixed inset-0 z-50 flex items-center justify-center"
|
|
26
|
+
>
|
|
27
|
+
<div className="pointer-events-auto max-w-md rounded-lg border border-amber-500/40 bg-amber-500/10 px-4 py-2 text-center text-amber-200 shadow-lg backdrop-blur">
|
|
28
|
+
<span className="font-medium">Reconnecting…</span>
|
|
29
|
+
<span className="ml-2 text-amber-300/80">
|
|
30
|
+
attempt {attempt} · {formatSeconds(elapsed)} elapsed
|
|
31
|
+
</span>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createGestureDetector,
|
|
3
|
+
type GestureDetector,
|
|
4
|
+
type GestureResult,
|
|
5
|
+
} from "@sirenodeck/sirenodeck"
|
|
6
|
+
|
|
7
|
+
export type MouseEventKind = "down" | "up"
|
|
8
|
+
|
|
9
|
+
export interface GestureMouseEvent {
|
|
10
|
+
readonly kind: MouseEventKind
|
|
11
|
+
readonly keyIndex: number
|
|
12
|
+
readonly timestamp: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const dispatchMouseEvent = (
|
|
16
|
+
detector: GestureDetector,
|
|
17
|
+
event: GestureMouseEvent,
|
|
18
|
+
): void => {
|
|
19
|
+
detector.detect({
|
|
20
|
+
type: event.kind,
|
|
21
|
+
timestamp: event.timestamp,
|
|
22
|
+
keyIndex: event.keyIndex,
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const createEmulatorGestureDetector = (
|
|
27
|
+
onGesture: (result: GestureResult) => void,
|
|
28
|
+
): GestureDetector => createGestureDetector({ onGesture })
|
|
29
|
+
|
|
30
|
+
export const gestureKindToWsMessage = (
|
|
31
|
+
result: GestureResult,
|
|
32
|
+
deckId: string,
|
|
33
|
+
): {
|
|
34
|
+
type: "button-action"
|
|
35
|
+
deckId: string
|
|
36
|
+
position: number
|
|
37
|
+
gesture: "tap" | "dbl-tap" | "hold"
|
|
38
|
+
} => {
|
|
39
|
+
return {
|
|
40
|
+
type: "button-action",
|
|
41
|
+
deckId,
|
|
42
|
+
position: result.keyIndex ?? 0,
|
|
43
|
+
gesture: result.kind,
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import ReactDOM from "react-dom/client"
|
|
3
|
+
import { HashRouter } from "react-router-dom"
|
|
4
|
+
|
|
5
|
+
import { App } from "./App"
|
|
6
|
+
|
|
7
|
+
import "./index.css"
|
|
8
|
+
|
|
9
|
+
const root = document.getElementById("root")
|
|
10
|
+
if (root === null) {
|
|
11
|
+
throw new Error("Could not find #root element")
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
ReactDOM.createRoot(root).render(
|
|
15
|
+
<React.StrictMode>
|
|
16
|
+
<HashRouter>
|
|
17
|
+
<App />
|
|
18
|
+
</HashRouter>
|
|
19
|
+
</React.StrictMode>,
|
|
20
|
+
)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { VERSION } from "../../../src/version"
|
|
2
|
+
|
|
3
|
+
export const AboutPage = (): React.ReactElement => (
|
|
4
|
+
<section
|
|
5
|
+
className="mx-auto max-w-2xl space-y-6 p-6"
|
|
6
|
+
aria-labelledby="about-title"
|
|
7
|
+
>
|
|
8
|
+
<div>
|
|
9
|
+
<p className="font-mono text-xs uppercase tracking-[0.3em] text-sky-400">
|
|
10
|
+
Sireno Deck
|
|
11
|
+
</p>
|
|
12
|
+
<h1
|
|
13
|
+
id="about-title"
|
|
14
|
+
className="mt-2 text-3xl font-semibold text-neutral-100"
|
|
15
|
+
>
|
|
16
|
+
A tactile command center for your desktop.
|
|
17
|
+
</h1>
|
|
18
|
+
</div>
|
|
19
|
+
<p className="text-sm leading-7 text-neutral-300">
|
|
20
|
+
Sireno Deck is a local, config-driven controller for Elgato Stream Deck
|
|
21
|
+
devices. It turns YAML into responsive button surfaces, addon workflows,
|
|
22
|
+
themes, and navigable decks that work on hardware and in the browser.
|
|
23
|
+
</p>
|
|
24
|
+
<dl className="grid gap-3 text-sm sm:grid-cols-2">
|
|
25
|
+
<div className="rounded border border-neutral-800 bg-neutral-950 p-4">
|
|
26
|
+
<dt className="text-neutral-500">Author</dt>
|
|
27
|
+
<dd className="mt-1 text-neutral-100">Sergio Carracedo</dd>
|
|
28
|
+
</div>
|
|
29
|
+
<div className="rounded border border-neutral-800 bg-neutral-950 p-4">
|
|
30
|
+
<dt className="text-neutral-500">Version</dt>
|
|
31
|
+
<dd className="mt-1 font-mono text-neutral-100">{VERSION}</dd>
|
|
32
|
+
</div>
|
|
33
|
+
<div className="rounded border border-neutral-800 bg-neutral-950 p-4">
|
|
34
|
+
<dt className="text-neutral-500">License</dt>
|
|
35
|
+
<dd className="mt-1">
|
|
36
|
+
<a
|
|
37
|
+
className="text-sky-400 hover:underline"
|
|
38
|
+
href="https://www.gnu.org/licenses/gpl-3.0.html"
|
|
39
|
+
target="_blank"
|
|
40
|
+
rel="noreferrer"
|
|
41
|
+
>
|
|
42
|
+
GNU GPL version 3 or later
|
|
43
|
+
</a>
|
|
44
|
+
</dd>
|
|
45
|
+
</div>
|
|
46
|
+
<div className="rounded border border-neutral-800 bg-neutral-950 p-4">
|
|
47
|
+
<dt className="text-neutral-500">Repository</dt>
|
|
48
|
+
<dd className="mt-1">
|
|
49
|
+
<a
|
|
50
|
+
className="text-sky-400 hover:underline"
|
|
51
|
+
href="https://github.com/sergiocarracedo/sireno-deck"
|
|
52
|
+
target="_blank"
|
|
53
|
+
rel="noreferrer"
|
|
54
|
+
>
|
|
55
|
+
github.com/sergiocarracedo/sireno-deck
|
|
56
|
+
</a>
|
|
57
|
+
</dd>
|
|
58
|
+
</div>
|
|
59
|
+
</dl>
|
|
60
|
+
<p className="text-xs leading-5 text-neutral-500">
|
|
61
|
+
This program comes with no warranty. You may redistribute and modify it
|
|
62
|
+
under the terms of the GNU General Public License.
|
|
63
|
+
</p>
|
|
64
|
+
</section>
|
|
65
|
+
)
|