@sdeck/plugin-audio 0.4.0 → 0.4.2
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/README.md +36 -0
- package/bin/sdeck-audio.exe +0 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +2 -2
- package/package.json +12 -7
- package/src/index.tsx +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Audio
|
|
2
|
+
|
|
3
|
+
Volume and mute for your speakers, microphone and each app, and switching between audio devices.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Open **Plugins** in [sdeck Studio](https://sdeck.one) and install **Audio**.
|
|
8
|
+
|
|
9
|
+
## Actions
|
|
10
|
+
|
|
11
|
+
| Action | What it does |
|
|
12
|
+
| ----------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| **Volume** | Raises, lowers, sets or mutes the speakers, the microphone or one app, and shows its level. |
|
|
14
|
+
| **Volume slider** | A level bar on a touch sensor. Touch to step the volume (left lowers, right raises), hold to keep going. |
|
|
15
|
+
| **Switch audio device** | Makes another speaker or microphone the default, or steps through them. |
|
|
16
|
+
|
|
17
|
+
## Setting up
|
|
18
|
+
|
|
19
|
+
On Windows there is nothing to set up: the helper that reaches your audio devices comes with the
|
|
20
|
+
plugin. In the settings, **Audio helper** takes the full path of `sdeck-audio` if it is somewhere
|
|
21
|
+
else. From a checkout of the repository, build it with `bun run build:audio`.
|
|
22
|
+
|
|
23
|
+
For **One app**, enter the executable name as it appears while the app plays sound.
|
|
24
|
+
|
|
25
|
+
## Live values
|
|
26
|
+
|
|
27
|
+
`audio.master` and `audio.mic` (each with `.volume`, `.muted`, `.name`), `audio.output`,
|
|
28
|
+
`audio.input` (the default devices' names), `audio.outputs`, `audio.inputs`, and
|
|
29
|
+
`audio.apps.<name>` (with `.volume`, `.muted`, `.active`).
|
|
30
|
+
|
|
31
|
+
## Permissions
|
|
32
|
+
|
|
33
|
+
| Permission | Why |
|
|
34
|
+
| ---------- | --------------------------------------------------------- |
|
|
35
|
+
| Audio | Reading and changing volume, mute and the default device. |
|
|
36
|
+
| Process | Running the audio helper. |
|
package/bin/sdeck-audio.exe
CHANGED
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -224,7 +224,7 @@ var BLUE = "#60a5fa";
|
|
|
224
224
|
var plugin = createPlugin({
|
|
225
225
|
id: "@sdeck/plugin-audio",
|
|
226
226
|
name: "Audio",
|
|
227
|
-
version: "0.4.
|
|
227
|
+
version: "0.4.2",
|
|
228
228
|
namespace: "audio",
|
|
229
229
|
description: "Volume and mute for speakers, microphone and each app, and device switching.",
|
|
230
230
|
author: "sdeck",
|
|
@@ -680,4 +680,4 @@ export {
|
|
|
680
680
|
targetPath
|
|
681
681
|
};
|
|
682
682
|
|
|
683
|
-
//# debugId=
|
|
683
|
+
//# debugId=CAF967AAC83306FD64756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.tsx", "../src/helper.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { existsSync } from \"node:fs\";\nimport {\n createPlugin,\n Permissions,\n setting,\n useHostState,\n useImage,\n useKeyRepeat,\n useSensorPressed,\n useSensorRepeat,\n} from \"@sdeck/plugin\";\nimport {\n captionLayer,\n iconLayer,\n iconSize,\n KEY,\n type Look,\n meterLayer,\n readable,\n surface,\n surfaceStyle,\n textLayer,\n volumeStepLayers,\n} from \"@sdeck/schema\";\nimport {\n type AudioDevice,\n AudioHelper,\n AudioUnavailable,\n BUILD_HINT,\n type Change,\n findHelper,\n type Snapshot,\n type Target,\n} from \"./helper.ts\";\n\nexport * from \"./helper.ts\";\n\nconst BLUE = \"#60a5fa\";\n\nconst plugin = createPlugin({\n id: \"@sdeck/plugin-audio\",\n name: \"Audio\",\n version: \"0.4.0\",\n namespace: \"audio\",\n description: \"Volume and mute for speakers, microphone and each app, and device switching.\",\n author: \"sdeck\",\n permissions: [Permissions.audio, Permissions.process],\n settings: {\n helper: setting.text(\"Audio helper\", {\n placeholder: \"Found automatically\",\n description: \"Full path of sdeck-audio, if it is somewhere unusual.\",\n }),\n },\n});\n\nconst sources = {\n outputs: plugin.source(\"outputs\", () => deviceOptions(\"outputs\")),\n inputs: plugin.source(\"inputs\", () => deviceOptions(\"inputs\")),\n apps: plugin.source(\"apps\", async () =>\n (await helper.request(\"snapshot\")).apps.map((a) => ({ value: a.name, label: a.name })),\n ),\n};\n\n/** `Spotify.exe` → `spotify`, the key of `audio.apps`. */\nexport function appKey(name: string): string {\n return name\n .trim()\n .toLowerCase()\n .replace(/\\.exe$/, \"\");\n}\n\n/** What the plugin publishes, from one snapshot of the devices. */\nexport function audioState(snapshot: Snapshot | undefined) {\n if (!snapshot) {\n return {\n master: undefined,\n mic: undefined,\n output: undefined,\n input: undefined,\n outputs: undefined,\n inputs: undefined,\n apps: undefined,\n };\n }\n const level = (d: AudioDevice | undefined) =>\n d && { volume: d.volume, muted: d.muted, name: d.name };\n const output = snapshot.outputs.find((d) => d.default);\n const input = snapshot.inputs.find((d) => d.default);\n return {\n master: level(output),\n mic: level(input),\n output: output?.name,\n input: input?.name,\n outputs: snapshot.outputs,\n inputs: snapshot.inputs,\n apps: Object.fromEntries(snapshot.apps.map((app) => [appKey(app.name), app])),\n };\n}\n\n// -- The helper ---------------------------------------------------------------------------------\n\nconst helper = new AudioHelper({\n command: () => {\n if (process.platform !== \"win32\") {\n throw new AudioUnavailable(\"Audio control is available on Windows only\");\n }\n const path = String(plugin.context?.settings().helper || \"\") || findHelper();\n if (!path) throw new AudioUnavailable(`${BUILD_HINT}.`);\n return [path];\n },\n onProblem: (problem) => plugin.context?.status(problem?.message, \"error\"),\n});\n\n/** One part of what the helper reports. */\nconst from = <K extends keyof ReturnType<typeof audioState>>(id: K, description: string) => ({\n description,\n start: (set: (value: ReturnType<typeof audioState>[K]) => void) =>\n helper.subscribe((snapshot) => set(audioState(snapshot)[id])),\n});\n\nconst values = {\n master: plugin.state.json(\n \"master\",\n \"Speakers\",\n from(\"master\", \"audio.master.volume, .muted, .name\"),\n ),\n mic: plugin.state.json(\"mic\", \"Microphone\", from(\"mic\", \"audio.mic.volume, .muted, .name\")),\n output: plugin.state.string(\n \"output\",\n \"Output device\",\n from(\"output\", \"The default output's name.\"),\n ),\n input: plugin.state.string(\"input\", \"Input device\", from(\"input\", \"The default input's name.\")),\n outputs: plugin.state.json(\n \"outputs\",\n \"Output devices\",\n from(\"outputs\", \"Every output with its level.\"),\n ),\n inputs: plugin.state.json(\n \"inputs\",\n \"Input devices\",\n from(\"inputs\", \"Every input with its level.\"),\n ),\n apps: plugin.state.json(\n \"apps\",\n \"App volumes\",\n from(\"apps\", \"audio.apps.spotify.volume, .muted, .active\"),\n ),\n};\n\n/** An icon (`lucide/mic`) as an image, once loaded. */\nconst useIcon = (icon: string, color: string) => useImage(`icon:${icon}`, color);\n\n// -- Volume -------------------------------------------------------------------------------------\n\nconst TARGETS = [\n { value: \"output\", label: \"Speakers (default output)\" },\n { value: \"input\", label: \"Microphone (default input)\" },\n { value: \"app\", label: \"One app\" },\n] as const;\n\ninterface TargetSettings {\n target: \"output\" | \"input\" | \"app\";\n app: string;\n}\n\nfunction targetOf(s: TargetSettings): Target {\n if (s.target !== \"app\") return { kind: s.target };\n if (!s.app.trim()) throw new Error(\"choose an app\");\n return { kind: \"app\", app: s.app.trim() };\n}\n\n/** The state path of a target's level, for templates and expressions. */\nexport function targetPath(s: TargetSettings): string {\n if (s.target === \"output\") return \"audio.master\";\n if (s.target === \"input\") return \"audio.mic\";\n return `audio.apps[${JSON.stringify(appKey(s.app))}]`;\n}\n\nconst targetName = (s: TargetSettings) =>\n s.target === \"output\" ? \"Volume\" : s.target === \"input\" ? \"Mic\" : appKey(s.app) || \"App\";\n\n/** Brand icons of common apps, by executable name. */\nconst APP_ICONS: Record<string, string> = {\n spotify: \"si/SiSpotify\",\n discord: \"si/SiDiscord\",\n chrome: \"si/SiGooglechrome\",\n firefox: \"si/SiFirefoxbrowser\",\n msedge: \"fa6/FaEdge\",\n brave: \"si/SiBrave\",\n opera: \"si/SiOpera\",\n steam: \"si/SiSteam\",\n vlc: \"si/SiVlcmediaplayer\",\n obs64: \"si/SiObsstudio\",\n slack: \"fa6/FaSlack\",\n zoom: \"si/SiZoom\",\n system: \"lucide/bell\",\n};\n\n/** The icons of a target: sounding and muted. */\nexport function targetIcons(s: TargetSettings): { on: string; off: string } {\n if (s.target === \"output\") return { on: \"lucide/volume-2\", off: \"lucide/volume-x\" };\n if (s.target === \"input\") return { on: \"lucide/mic\", off: \"lucide/mic-off\" };\n const brand = APP_ICONS[appKey(s.app)];\n // A brand keeps its own mark when muted; it turns red.\n return brand ? { on: brand, off: brand } : { on: \"lucide/app-window\", off: \"lucide/volume-x\" };\n}\n\nconst targetFields = {\n target: setting.select(\"Control\", TARGETS, { default: \"output\" }),\n app: setting.text(\"App\", {\n required: true,\n source: \"apps\",\n placeholder: \"spotify.exe\",\n description: \"The executable name, as it appears while the app plays sound.\",\n visibleIf: { target: \"app\" },\n }),\n};\n\ntype Operation = \"up\" | \"down\" | \"set\" | \"mute\" | \"unmute\" | \"toggle\";\n\nasync function adjust(\n target: Target,\n operation: Operation,\n step: number,\n level: number,\n): Promise<Change> {\n switch (operation) {\n case \"up\":\n return helper.request(\"setVolume\", { target, delta: step });\n case \"down\":\n return helper.request(\"setVolume\", { target, delta: -step });\n case \"set\":\n return helper.request(\"setVolume\", { target, volume: level });\n case \"toggle\":\n return helper.request(\"setMute\", { target });\n default:\n return helper.request(\"setMute\", { target, muted: operation === \"mute\" });\n }\n}\n\nconst OPERATION_NAMES: Record<Operation, string> = {\n up: \"Volume up\",\n down: \"Volume down\",\n set: \"Set volume\",\n mute: \"Mute\",\n unmute: \"Unmute\",\n toggle: \"Toggle mute\",\n};\n\nconst volume = plugin.action({\n id: \"volume\",\n name: \"Volume\",\n description: \"Changes or mutes the speakers, the microphone or one app, and shows its level.\",\n category: \"Audio\",\n icon: \"volume-2\",\n slots: [\"key\", \"sensor\"],\n settings: {\n ...targetFields,\n operation: setting.select(\"When pressed\", OPERATION_NAMES, { default: \"toggle\" }),\n step: setting.number(\"Step (%)\", {\n default: 5,\n min: 1,\n max: 50,\n visibleIf: { operation: [\"up\", \"down\"] },\n }),\n level: setting.number(\"Level (%)\", {\n default: 50,\n min: 0,\n max: 100,\n visibleIf: { operation: \"set\" },\n }),\n background: setting.color(\"Background\", { default: KEY, appearance: true }),\n },\n run: async ({ settings }) => {\n const target = targetOf(settings);\n const { before, after } = await adjust(\n target,\n settings.operation,\n settings.step,\n settings.level,\n );\n return {\n result: after,\n label: `${OPERATION_NAMES[settings.operation]} (${targetName(settings)})`,\n undo: async () => {\n await helper.request(\"setVolume\", { target, volume: before.volume });\n await helper.request(\"setMute\", { target, muted: before.muted });\n },\n };\n },\n look: (s, slot): Look => {\n const path = targetPath(s);\n const muted = `${path}.muted`;\n const icons = targetIcons(s);\n const step = s.operation === \"up\" ? \"plus\" : s.operation === \"down\" ? \"minus\" : \"\";\n const white = readable(\"#ffffff\", s.background);\n const red = readable(\"#f87171\", s.background);\n const blue = readable(BLUE, s.background);\n const level = `{{${path}.volume == null ? \"N/A\" : ${path}.volume + \"%\"}}`;\n const bar = meterLayer(\"bar\", `${path}.volume ?? 0`, { color: BLUE });\n if (step && s.target === \"output\") {\n const layers = (color: string) =>\n volumeStepLayers(step, slot, { color, stepColor: blue, center: 37, size: 52 });\n const [icon, sign] = layers(white);\n return {\n background: surface(s.background),\n layers: [\n { ...icon, visible: `!${muted}` },\n { ...layers(red)[0], id: \"muted\", visible: muted },\n sign,\n textLayer(\"level\", level, {\n color: white,\n size: 18,\n frame: { x: 0, y: 58, width: 100, height: 24 },\n }),\n bar,\n ],\n };\n }\n return {\n background: surface(s.background),\n layers: [\n iconLayer(\"icon\", icons.on, {\n color: white,\n size: 40,\n visible: `!${muted}`,\n row: \"icon\",\n }),\n iconLayer(\"muted\", icons.off, {\n color: red,\n size: 40,\n visible: muted,\n row: \"icon\",\n }),\n ...(step\n ? [\n iconLayer(\"step\", `lucide/${step}`, {\n color: blue,\n size: 20,\n row: \"icon\",\n }),\n ]\n : []),\n textLayer(\"level\", level, { color: white, size: 18 }),\n bar,\n ],\n };\n },\n});\n\n// -- Slider -------------------------------------------------------------------------------------\n\nconst slider = plugin.action({\n id: \"slider\",\n name: \"Volume slider\",\n description:\n \"A level bar on a sensor strip: touch it to step the volume (the left one lowers, the right one raises), hold to keep going.\",\n category: \"Audio\",\n icon: \"sliders-horizontal\",\n slots: [\"sensor\", \"window\", \"key\"],\n settings: {\n ...targetFields,\n direction: setting.select(\"Touching it\", {\n auto: \"Left lowers, right raises\",\n down: \"Lowers\",\n up: \"Raises\",\n }),\n step: setting.number(\"Step (%)\", { default: 4, min: 1, max: 50 }),\n color: setting.color(\"Bar colour\", { default: BLUE, appearance: true }),\n },\n run: async ({ settings }) => {\n const target = targetOf(settings);\n const delta = settings.direction === \"down\" ? -settings.step : settings.step;\n const { before, after } = await helper.request(\"setVolume\", { target, delta });\n return {\n result: after,\n label: `${targetName(settings)} ${after.volume}%`,\n undo: () => helper.request(\"setVolume\", { target, volume: before.volume }),\n };\n },\n component: ({ settings, slot, plugin }) => {\n const name = settings.target === \"output\" ? \"master\" : settings.target === \"input\" ? \"mic\" : \"\";\n const whole = useHostState(name ? `audio.${name}` : \"audio.apps\");\n const level = (\n name ? whole : (whole as Record<string, unknown> | undefined)?.[appKey(settings.app)]\n ) as { volume: number; muted: boolean } | undefined;\n const down =\n settings.direction === \"down\" ||\n (settings.direction === \"auto\" && slot.kind !== \"window\" && slot.index % 2 === 0);\n const step = () => {\n helper\n .request(\"setVolume\", {\n target: targetOf(settings),\n delta: down ? -settings.step : settings.step,\n })\n .catch((error: Error) => plugin.log(\"slider:\", error.message));\n };\n const sensorPressed = useSensorPressed(slot.kind === \"sensor\" ? slot.index : 0);\n const index = slot.kind === \"window\" ? -1 : slot.index;\n useSensorRepeat((i) => slot.kind === \"sensor\" && i === index && step(), {\n sensor: slot.kind === \"sensor\" ? index : -1,\n intervalMs: 150,\n });\n useKeyRepeat((i) => slot.kind === \"key\" && i === index && step(), {\n key: slot.kind === \"key\" ? index : -1,\n intervalMs: 150,\n });\n const strip = slot.kind === \"sensor\";\n const text = !level ? \"N/A\" : `${level.volume}%`;\n const icons = targetIcons(settings);\n const size = strip ? 12 : 24;\n const icon = useIcon(level?.muted ? icons.off : icons.on, \"#ffffff\");\n const arrow = useIcon(down ? \"lucide/minus\" : \"lucide/plus\", \"#ffffff\");\n return (\n <div\n style={{\n display: \"flex\",\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n ...surfaceStyle(strip && sensorPressed ? \"#334155\" : KEY),\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n position: \"absolute\",\n left: 0,\n top: 0,\n bottom: 0,\n width: `${level?.volume ?? 0}%`,\n background: level?.muted ? \"#7f1d1d\" : settings.color,\n opacity: 0.6,\n }}\n />\n <div\n style={{\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n gap: strip ? 3 : 6,\n color: \"#ffffff\",\n fontWeight: 700,\n fontSize: 20,\n }}\n >\n {strip && arrow ? <img src={arrow} width={10} height={10} alt=\"\" /> : null}\n {icon ? <img src={icon} width={size} height={size} alt=\"\" /> : null}\n {/* On a sensor the bar alone shows the level. */}\n {strip ? null : <div style={{ display: \"flex\" }}>{text}</div>}\n </div>\n </div>\n );\n },\n});\n\n// -- Default device -----------------------------------------------------------------------------\n\nconst NEXT = \"__next\";\n\n/** The device after the default one, for \"Next device\". */\nexport function nextDevice(devices: readonly AudioDevice[]): AudioDevice | undefined {\n const at = devices.findIndex((d) => d.default);\n return devices[(at + 1) % devices.length];\n}\n\nconst defaultDevice = plugin.action({\n id: \"default-device\",\n name: \"Switch audio device\",\n description: \"Makes another speaker or microphone the default, or steps through them.\",\n category: \"Audio\",\n icon: \"speaker\",\n slots: [\"key\", \"sensor\"],\n settings: {\n flow: setting.select(\"Switch the\", {\n output: \"Output (speakers)\",\n input: \"Input (microphone)\",\n }),\n output: setting.pick(\"To\", \"outputs\", {\n first: [{ value: NEXT, label: \"The next device\" }],\n default: NEXT,\n visibleIf: { flow: \"output\" },\n }),\n input: setting.pick(\"To\", \"inputs\", {\n first: [{ value: NEXT, label: \"The next device\" }],\n default: NEXT,\n visibleIf: { flow: \"input\" },\n }),\n background: setting.color(\"Background\", { default: KEY, appearance: true }),\n },\n run: async ({ settings }) => {\n const wanted = settings.flow === \"output\" ? settings.output : settings.input;\n const snapshot = await helper.request(\"snapshot\");\n const devices = settings.flow === \"output\" ? snapshot.outputs : snapshot.inputs;\n const device = wanted === NEXT ? nextDevice(devices) : devices.find((d) => d.id === wanted);\n if (!device) throw new Error(\"that audio device is not connected\");\n const { previous } = await helper.request(\"setDefault\", { device: device.id });\n return {\n result: device.name,\n label: `Audio ${settings.flow}: ${device.name}`,\n ...(previous && {\n undo: () => helper.request(\"setDefault\", { device: previous }),\n }),\n };\n },\n look: (s): Look => ({\n background: surface(s.background),\n layers: [\n iconLayer(\"icon\", s.flow === \"output\" ? \"lucide/headphones\" : \"lucide/mic\", {\n color: readable(\"#ffffff\", s.background),\n size: iconSize(true) - 4,\n row: \"icon\",\n }),\n iconLayer(\"switch\", \"lucide/arrow-left-right\", {\n color: readable(\"#c4b5fd\", s.background),\n size: 20,\n row: \"icon\",\n }),\n captionLayer(\"device\", `{{${values[s.flow].key} ?? \"N/A\"}}`, {\n color: readable(\"#f4f4f5\", s.background),\n size: 11,\n }),\n ],\n }),\n});\n\nconst deviceOptions = async (flow: \"outputs\" | \"inputs\") =>\n (await helper.request(\"snapshot\"))[flow].map((d) => ({ value: d.id, label: d.name }));\n\nexport default plugin.define({\n onboarding: {\n steps: [\n {\n id: \"helper\",\n title: \"The audio helper\",\n body: \"sdeck reaches your speakers, microphone and apps through a small helper that comes with this plugin on Windows. Leave this empty unless it is somewhere else.\",\n settings: [\"helper\"],\n done: (activated) => {\n const custom = String(activated.settings().helper ?? \"\").trim();\n return custom ? existsSync(custom) : findHelper() !== undefined;\n },\n },\n ],\n },\n actions: [volume, slider, defaultDevice],\n sources: Object.values(sources),\n state: Object.values(values),\n activate(activated) {\n if (process.platform !== \"win32\") {\n activated.status(\"Audio control is available on Windows only\", \"info\");\n } else if (!findHelper() && !activated.settings().helper) {\n activated.status(`${BUILD_HINT}.`, \"info\");\n }\n return () => {\n helper.close();\n };\n },\n});\n",
|
|
5
|
+
"import { existsSync } from \"node:fs\";\nimport {\n createPlugin,\n Permissions,\n setting,\n useHostState,\n useImage,\n useKeyRepeat,\n useSensorPressed,\n useSensorRepeat,\n} from \"@sdeck/plugin\";\nimport {\n captionLayer,\n iconLayer,\n iconSize,\n KEY,\n type Look,\n meterLayer,\n readable,\n surface,\n surfaceStyle,\n textLayer,\n volumeStepLayers,\n} from \"@sdeck/schema\";\nimport {\n type AudioDevice,\n AudioHelper,\n AudioUnavailable,\n BUILD_HINT,\n type Change,\n findHelper,\n type Snapshot,\n type Target,\n} from \"./helper.ts\";\n\nexport * from \"./helper.ts\";\n\nconst BLUE = \"#60a5fa\";\n\nconst plugin = createPlugin({\n id: \"@sdeck/plugin-audio\",\n name: \"Audio\",\n version: \"0.4.2\",\n namespace: \"audio\",\n description: \"Volume and mute for speakers, microphone and each app, and device switching.\",\n author: \"sdeck\",\n permissions: [Permissions.audio, Permissions.process],\n settings: {\n helper: setting.text(\"Audio helper\", {\n placeholder: \"Found automatically\",\n description: \"Full path of sdeck-audio, if it is somewhere unusual.\",\n }),\n },\n});\n\nconst sources = {\n outputs: plugin.source(\"outputs\", () => deviceOptions(\"outputs\")),\n inputs: plugin.source(\"inputs\", () => deviceOptions(\"inputs\")),\n apps: plugin.source(\"apps\", async () =>\n (await helper.request(\"snapshot\")).apps.map((a) => ({ value: a.name, label: a.name })),\n ),\n};\n\n/** `Spotify.exe` → `spotify`, the key of `audio.apps`. */\nexport function appKey(name: string): string {\n return name\n .trim()\n .toLowerCase()\n .replace(/\\.exe$/, \"\");\n}\n\n/** What the plugin publishes, from one snapshot of the devices. */\nexport function audioState(snapshot: Snapshot | undefined) {\n if (!snapshot) {\n return {\n master: undefined,\n mic: undefined,\n output: undefined,\n input: undefined,\n outputs: undefined,\n inputs: undefined,\n apps: undefined,\n };\n }\n const level = (d: AudioDevice | undefined) =>\n d && { volume: d.volume, muted: d.muted, name: d.name };\n const output = snapshot.outputs.find((d) => d.default);\n const input = snapshot.inputs.find((d) => d.default);\n return {\n master: level(output),\n mic: level(input),\n output: output?.name,\n input: input?.name,\n outputs: snapshot.outputs,\n inputs: snapshot.inputs,\n apps: Object.fromEntries(snapshot.apps.map((app) => [appKey(app.name), app])),\n };\n}\n\n// -- The helper ---------------------------------------------------------------------------------\n\nconst helper = new AudioHelper({\n command: () => {\n if (process.platform !== \"win32\") {\n throw new AudioUnavailable(\"Audio control is available on Windows only\");\n }\n const path = String(plugin.context?.settings().helper || \"\") || findHelper();\n if (!path) throw new AudioUnavailable(`${BUILD_HINT}.`);\n return [path];\n },\n onProblem: (problem) => plugin.context?.status(problem?.message, \"error\"),\n});\n\n/** One part of what the helper reports. */\nconst from = <K extends keyof ReturnType<typeof audioState>>(id: K, description: string) => ({\n description,\n start: (set: (value: ReturnType<typeof audioState>[K]) => void) =>\n helper.subscribe((snapshot) => set(audioState(snapshot)[id])),\n});\n\nconst values = {\n master: plugin.state.json(\n \"master\",\n \"Speakers\",\n from(\"master\", \"audio.master.volume, .muted, .name\"),\n ),\n mic: plugin.state.json(\"mic\", \"Microphone\", from(\"mic\", \"audio.mic.volume, .muted, .name\")),\n output: plugin.state.string(\n \"output\",\n \"Output device\",\n from(\"output\", \"The default output's name.\"),\n ),\n input: plugin.state.string(\"input\", \"Input device\", from(\"input\", \"The default input's name.\")),\n outputs: plugin.state.json(\n \"outputs\",\n \"Output devices\",\n from(\"outputs\", \"Every output with its level.\"),\n ),\n inputs: plugin.state.json(\n \"inputs\",\n \"Input devices\",\n from(\"inputs\", \"Every input with its level.\"),\n ),\n apps: plugin.state.json(\n \"apps\",\n \"App volumes\",\n from(\"apps\", \"audio.apps.spotify.volume, .muted, .active\"),\n ),\n};\n\n/** An icon (`lucide/mic`) as an image, once loaded. */\nconst useIcon = (icon: string, color: string) => useImage(`icon:${icon}`, color);\n\n// -- Volume -------------------------------------------------------------------------------------\n\nconst TARGETS = [\n { value: \"output\", label: \"Speakers (default output)\" },\n { value: \"input\", label: \"Microphone (default input)\" },\n { value: \"app\", label: \"One app\" },\n] as const;\n\ninterface TargetSettings {\n target: \"output\" | \"input\" | \"app\";\n app: string;\n}\n\nfunction targetOf(s: TargetSettings): Target {\n if (s.target !== \"app\") return { kind: s.target };\n if (!s.app.trim()) throw new Error(\"choose an app\");\n return { kind: \"app\", app: s.app.trim() };\n}\n\n/** The state path of a target's level, for templates and expressions. */\nexport function targetPath(s: TargetSettings): string {\n if (s.target === \"output\") return \"audio.master\";\n if (s.target === \"input\") return \"audio.mic\";\n return `audio.apps[${JSON.stringify(appKey(s.app))}]`;\n}\n\nconst targetName = (s: TargetSettings) =>\n s.target === \"output\" ? \"Volume\" : s.target === \"input\" ? \"Mic\" : appKey(s.app) || \"App\";\n\n/** Brand icons of common apps, by executable name. */\nconst APP_ICONS: Record<string, string> = {\n spotify: \"si/SiSpotify\",\n discord: \"si/SiDiscord\",\n chrome: \"si/SiGooglechrome\",\n firefox: \"si/SiFirefoxbrowser\",\n msedge: \"fa6/FaEdge\",\n brave: \"si/SiBrave\",\n opera: \"si/SiOpera\",\n steam: \"si/SiSteam\",\n vlc: \"si/SiVlcmediaplayer\",\n obs64: \"si/SiObsstudio\",\n slack: \"fa6/FaSlack\",\n zoom: \"si/SiZoom\",\n system: \"lucide/bell\",\n};\n\n/** The icons of a target: sounding and muted. */\nexport function targetIcons(s: TargetSettings): { on: string; off: string } {\n if (s.target === \"output\") return { on: \"lucide/volume-2\", off: \"lucide/volume-x\" };\n if (s.target === \"input\") return { on: \"lucide/mic\", off: \"lucide/mic-off\" };\n const brand = APP_ICONS[appKey(s.app)];\n // A brand keeps its own mark when muted; it turns red.\n return brand ? { on: brand, off: brand } : { on: \"lucide/app-window\", off: \"lucide/volume-x\" };\n}\n\nconst targetFields = {\n target: setting.select(\"Control\", TARGETS, { default: \"output\" }),\n app: setting.text(\"App\", {\n required: true,\n source: \"apps\",\n placeholder: \"spotify.exe\",\n description: \"The executable name, as it appears while the app plays sound.\",\n visibleIf: { target: \"app\" },\n }),\n};\n\ntype Operation = \"up\" | \"down\" | \"set\" | \"mute\" | \"unmute\" | \"toggle\";\n\nasync function adjust(\n target: Target,\n operation: Operation,\n step: number,\n level: number,\n): Promise<Change> {\n switch (operation) {\n case \"up\":\n return helper.request(\"setVolume\", { target, delta: step });\n case \"down\":\n return helper.request(\"setVolume\", { target, delta: -step });\n case \"set\":\n return helper.request(\"setVolume\", { target, volume: level });\n case \"toggle\":\n return helper.request(\"setMute\", { target });\n default:\n return helper.request(\"setMute\", { target, muted: operation === \"mute\" });\n }\n}\n\nconst OPERATION_NAMES: Record<Operation, string> = {\n up: \"Volume up\",\n down: \"Volume down\",\n set: \"Set volume\",\n mute: \"Mute\",\n unmute: \"Unmute\",\n toggle: \"Toggle mute\",\n};\n\nconst volume = plugin.action({\n id: \"volume\",\n name: \"Volume\",\n description: \"Changes or mutes the speakers, the microphone or one app, and shows its level.\",\n category: \"Audio\",\n icon: \"volume-2\",\n slots: [\"key\", \"sensor\"],\n settings: {\n ...targetFields,\n operation: setting.select(\"When pressed\", OPERATION_NAMES, { default: \"toggle\" }),\n step: setting.number(\"Step (%)\", {\n default: 5,\n min: 1,\n max: 50,\n visibleIf: { operation: [\"up\", \"down\"] },\n }),\n level: setting.number(\"Level (%)\", {\n default: 50,\n min: 0,\n max: 100,\n visibleIf: { operation: \"set\" },\n }),\n background: setting.color(\"Background\", { default: KEY, appearance: true }),\n },\n run: async ({ settings }) => {\n const target = targetOf(settings);\n const { before, after } = await adjust(\n target,\n settings.operation,\n settings.step,\n settings.level,\n );\n return {\n result: after,\n label: `${OPERATION_NAMES[settings.operation]} (${targetName(settings)})`,\n undo: async () => {\n await helper.request(\"setVolume\", { target, volume: before.volume });\n await helper.request(\"setMute\", { target, muted: before.muted });\n },\n };\n },\n look: (s, slot): Look => {\n const path = targetPath(s);\n const muted = `${path}.muted`;\n const icons = targetIcons(s);\n const step = s.operation === \"up\" ? \"plus\" : s.operation === \"down\" ? \"minus\" : \"\";\n const white = readable(\"#ffffff\", s.background);\n const red = readable(\"#f87171\", s.background);\n const blue = readable(BLUE, s.background);\n const level = `{{${path}.volume == null ? \"N/A\" : ${path}.volume + \"%\"}}`;\n const bar = meterLayer(\"bar\", `${path}.volume ?? 0`, { color: BLUE });\n if (step && s.target === \"output\") {\n const layers = (color: string) =>\n volumeStepLayers(step, slot, { color, stepColor: blue, center: 37, size: 52 });\n const [icon, sign] = layers(white);\n return {\n background: surface(s.background),\n layers: [\n { ...icon, visible: `!${muted}` },\n { ...layers(red)[0], id: \"muted\", visible: muted },\n sign,\n textLayer(\"level\", level, {\n color: white,\n size: 18,\n frame: { x: 0, y: 58, width: 100, height: 24 },\n }),\n bar,\n ],\n };\n }\n return {\n background: surface(s.background),\n layers: [\n iconLayer(\"icon\", icons.on, {\n color: white,\n size: 40,\n visible: `!${muted}`,\n row: \"icon\",\n }),\n iconLayer(\"muted\", icons.off, {\n color: red,\n size: 40,\n visible: muted,\n row: \"icon\",\n }),\n ...(step\n ? [\n iconLayer(\"step\", `lucide/${step}`, {\n color: blue,\n size: 20,\n row: \"icon\",\n }),\n ]\n : []),\n textLayer(\"level\", level, { color: white, size: 18 }),\n bar,\n ],\n };\n },\n});\n\n// -- Slider -------------------------------------------------------------------------------------\n\nconst slider = plugin.action({\n id: \"slider\",\n name: \"Volume slider\",\n description:\n \"A level bar on a sensor strip: touch it to step the volume (the left one lowers, the right one raises), hold to keep going.\",\n category: \"Audio\",\n icon: \"sliders-horizontal\",\n slots: [\"sensor\", \"window\", \"key\"],\n settings: {\n ...targetFields,\n direction: setting.select(\"Touching it\", {\n auto: \"Left lowers, right raises\",\n down: \"Lowers\",\n up: \"Raises\",\n }),\n step: setting.number(\"Step (%)\", { default: 4, min: 1, max: 50 }),\n color: setting.color(\"Bar colour\", { default: BLUE, appearance: true }),\n },\n run: async ({ settings }) => {\n const target = targetOf(settings);\n const delta = settings.direction === \"down\" ? -settings.step : settings.step;\n const { before, after } = await helper.request(\"setVolume\", { target, delta });\n return {\n result: after,\n label: `${targetName(settings)} ${after.volume}%`,\n undo: () => helper.request(\"setVolume\", { target, volume: before.volume }),\n };\n },\n component: ({ settings, slot, plugin }) => {\n const name = settings.target === \"output\" ? \"master\" : settings.target === \"input\" ? \"mic\" : \"\";\n const whole = useHostState(name ? `audio.${name}` : \"audio.apps\");\n const level = (\n name ? whole : (whole as Record<string, unknown> | undefined)?.[appKey(settings.app)]\n ) as { volume: number; muted: boolean } | undefined;\n const down =\n settings.direction === \"down\" ||\n (settings.direction === \"auto\" && slot.kind !== \"window\" && slot.index % 2 === 0);\n const step = () => {\n helper\n .request(\"setVolume\", {\n target: targetOf(settings),\n delta: down ? -settings.step : settings.step,\n })\n .catch((error: Error) => plugin.log(\"slider:\", error.message));\n };\n const sensorPressed = useSensorPressed(slot.kind === \"sensor\" ? slot.index : 0);\n const index = slot.kind === \"window\" ? -1 : slot.index;\n useSensorRepeat((i) => slot.kind === \"sensor\" && i === index && step(), {\n sensor: slot.kind === \"sensor\" ? index : -1,\n intervalMs: 150,\n });\n useKeyRepeat((i) => slot.kind === \"key\" && i === index && step(), {\n key: slot.kind === \"key\" ? index : -1,\n intervalMs: 150,\n });\n const strip = slot.kind === \"sensor\";\n const text = !level ? \"N/A\" : `${level.volume}%`;\n const icons = targetIcons(settings);\n const size = strip ? 12 : 24;\n const icon = useIcon(level?.muted ? icons.off : icons.on, \"#ffffff\");\n const arrow = useIcon(down ? \"lucide/minus\" : \"lucide/plus\", \"#ffffff\");\n return (\n <div\n style={{\n display: \"flex\",\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n ...surfaceStyle(strip && sensorPressed ? \"#334155\" : KEY),\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n position: \"absolute\",\n left: 0,\n top: 0,\n bottom: 0,\n width: `${level?.volume ?? 0}%`,\n background: level?.muted ? \"#7f1d1d\" : settings.color,\n opacity: 0.6,\n }}\n />\n <div\n style={{\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n gap: strip ? 3 : 6,\n color: \"#ffffff\",\n fontWeight: 700,\n fontSize: 20,\n }}\n >\n {strip && arrow ? <img src={arrow} width={10} height={10} alt=\"\" /> : null}\n {icon ? <img src={icon} width={size} height={size} alt=\"\" /> : null}\n {/* On a sensor the bar alone shows the level. */}\n {strip ? null : <div style={{ display: \"flex\" }}>{text}</div>}\n </div>\n </div>\n );\n },\n});\n\n// -- Default device -----------------------------------------------------------------------------\n\nconst NEXT = \"__next\";\n\n/** The device after the default one, for \"Next device\". */\nexport function nextDevice(devices: readonly AudioDevice[]): AudioDevice | undefined {\n const at = devices.findIndex((d) => d.default);\n return devices[(at + 1) % devices.length];\n}\n\nconst defaultDevice = plugin.action({\n id: \"default-device\",\n name: \"Switch audio device\",\n description: \"Makes another speaker or microphone the default, or steps through them.\",\n category: \"Audio\",\n icon: \"speaker\",\n slots: [\"key\", \"sensor\"],\n settings: {\n flow: setting.select(\"Switch the\", {\n output: \"Output (speakers)\",\n input: \"Input (microphone)\",\n }),\n output: setting.pick(\"To\", \"outputs\", {\n first: [{ value: NEXT, label: \"The next device\" }],\n default: NEXT,\n visibleIf: { flow: \"output\" },\n }),\n input: setting.pick(\"To\", \"inputs\", {\n first: [{ value: NEXT, label: \"The next device\" }],\n default: NEXT,\n visibleIf: { flow: \"input\" },\n }),\n background: setting.color(\"Background\", { default: KEY, appearance: true }),\n },\n run: async ({ settings }) => {\n const wanted = settings.flow === \"output\" ? settings.output : settings.input;\n const snapshot = await helper.request(\"snapshot\");\n const devices = settings.flow === \"output\" ? snapshot.outputs : snapshot.inputs;\n const device = wanted === NEXT ? nextDevice(devices) : devices.find((d) => d.id === wanted);\n if (!device) throw new Error(\"that audio device is not connected\");\n const { previous } = await helper.request(\"setDefault\", { device: device.id });\n return {\n result: device.name,\n label: `Audio ${settings.flow}: ${device.name}`,\n ...(previous && {\n undo: () => helper.request(\"setDefault\", { device: previous }),\n }),\n };\n },\n look: (s): Look => ({\n background: surface(s.background),\n layers: [\n iconLayer(\"icon\", s.flow === \"output\" ? \"lucide/headphones\" : \"lucide/mic\", {\n color: readable(\"#ffffff\", s.background),\n size: iconSize(true) - 4,\n row: \"icon\",\n }),\n iconLayer(\"switch\", \"lucide/arrow-left-right\", {\n color: readable(\"#c4b5fd\", s.background),\n size: 20,\n row: \"icon\",\n }),\n captionLayer(\"device\", `{{${values[s.flow].key} ?? \"N/A\"}}`, {\n color: readable(\"#f4f4f5\", s.background),\n size: 11,\n }),\n ],\n }),\n});\n\nconst deviceOptions = async (flow: \"outputs\" | \"inputs\") =>\n (await helper.request(\"snapshot\"))[flow].map((d) => ({ value: d.id, label: d.name }));\n\nexport default plugin.define({\n onboarding: {\n steps: [\n {\n id: \"helper\",\n title: \"The audio helper\",\n body: \"sdeck reaches your speakers, microphone and apps through a small helper that comes with this plugin on Windows. Leave this empty unless it is somewhere else.\",\n settings: [\"helper\"],\n done: (activated) => {\n const custom = String(activated.settings().helper ?? \"\").trim();\n return custom ? existsSync(custom) : findHelper() !== undefined;\n },\n },\n ],\n },\n actions: [volume, slider, defaultDevice],\n sources: Object.values(sources),\n state: Object.values(values),\n activate(activated) {\n if (process.platform !== \"win32\") {\n activated.status(\"Audio control is available on Windows only\", \"info\");\n } else if (!findHelper() && !activated.settings().helper) {\n activated.status(`${BUILD_HINT}.`, \"info\");\n }\n return () => {\n helper.close();\n };\n },\n});\n",
|
|
6
6
|
"/**\n * Talks to `sdeck-audio`, the helper process that reaches the system's audio devices. It runs\n * only while something needs it, and is restarted if it stops on its own.\n */\nimport { type ChildProcess, spawn } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport interface Level {\n /** 0–100. */\n volume: number;\n muted: boolean;\n}\n\nexport interface AudioDevice extends Level {\n id: string;\n name: string;\n default: boolean;\n}\n\nexport interface AudioApp extends Level {\n /** Executable name, lowercased (`system` for system sounds). */\n name: string;\n active: boolean;\n}\n\nexport interface Snapshot {\n outputs: AudioDevice[];\n inputs: AudioDevice[];\n apps: AudioApp[];\n}\n\nexport interface Change {\n before: Level;\n after: Level;\n}\n\nexport type Target =\n | { kind: \"output\"; device?: string }\n | { kind: \"input\"; device?: string }\n | { kind: \"app\"; app: string };\n\nexport interface Requests {\n snapshot: { params: undefined; result: Snapshot };\n setVolume: { params: { target: Target; volume?: number; delta?: number }; result: Change };\n setMute: { params: { target: Target; muted?: boolean }; result: Change };\n setDefault: { params: { device: string }; result: { previous: string | null } };\n}\n\n/** Why there is no audio: shown to the user. */\nexport class AudioUnavailable extends Error {}\n\nexport const BUILD_HINT = \"Build the audio helper with `bun run build:audio`\";\n\n/**\n * Where the helper is: `SDECK_AUDIO_BIN`, the cargo build next to this package, or `bin/` next to\n * a bundled app.\n */\nexport function findHelper(\n env: Record<string, string | undefined> = process.env,\n base: string = import.meta.dir,\n exists: (path: string) => boolean = existsSync,\n): string | undefined {\n const name = process.platform === \"win32\" ? \"sdeck-audio.exe\" : \"sdeck-audio\";\n return [\n env.SDECK_AUDIO_BIN,\n join(base, \"..\", \"native\", \"target\", \"release\", name),\n join(base, \"..\", \"bin\", name),\n join(base, \"..\", \"native\", \"target\", \"debug\", name),\n ].find((path): path is string => Boolean(path) && exists(path as string));\n}\n\ninterface Pending {\n resolve: (value: unknown) => void;\n reject: (error: Error) => void;\n timer: ReturnType<typeof setTimeout>;\n}\n\nexport interface AudioHelperOptions {\n /** The command line to run; throw {@link AudioUnavailable} when there is none. */\n command: () => string[];\n /** The helper could not run, or stopped. `undefined`: it works again. */\n onProblem?: (problem: Error | undefined) => void;\n /** How long it keeps running after the last user leaves. */\n lingerMs?: number;\n timeoutMs?: number;\n}\n\nexport class AudioHelper {\n readonly #options: AudioHelperOptions;\n readonly #listeners = new Set<(snapshot: Snapshot | undefined) => void>();\n readonly #pending = new Map<number, Pending>();\n #child: ChildProcess | undefined;\n #snapshot: Snapshot | undefined;\n #users = 0;\n #next = 1;\n #linger: ReturnType<typeof setTimeout> | undefined;\n #restart: ReturnType<typeof setTimeout> | undefined;\n #delay = 1000;\n\n constructor(options: AudioHelperOptions) {\n this.#options = options;\n }\n\n /** The devices as last reported, while the helper runs. */\n get snapshot(): Snapshot | undefined {\n return this.#snapshot;\n }\n\n /** Whether the helper process is running. */\n get running(): boolean {\n return this.#child !== undefined;\n }\n\n /** Hears every snapshot while subscribed (which keeps the helper running). */\n subscribe(listener: (snapshot: Snapshot | undefined) => void): () => void {\n this.#listeners.add(listener);\n const release = this.#acquire();\n if (this.#snapshot) listener(this.#snapshot);\n return () => {\n this.#listeners.delete(listener);\n release();\n };\n }\n\n async request<M extends keyof Requests>(\n method: M,\n params?: Requests[M][\"params\"],\n ): Promise<Requests[M][\"result\"]> {\n const release = this.#acquire();\n try {\n const child = this.#child ?? this.#start();\n const id = this.#next++;\n return (await new Promise<unknown>((resolve, reject) => {\n const timer = setTimeout(() => {\n this.#pending.delete(id);\n reject(new Error(\"the audio helper did not answer\"));\n }, this.#options.timeoutMs ?? 5000);\n this.#pending.set(id, { resolve, reject, timer });\n child.stdin?.write(`${JSON.stringify({ id, method, params })}\\n`);\n })) as Requests[M][\"result\"];\n } finally {\n release();\n }\n }\n\n /** Stops the helper now, whoever uses it. */\n close(): void {\n this.#users = 0;\n this.#listeners.clear();\n clearTimeout(this.#linger);\n this.#stop();\n }\n\n #acquire(): () => void {\n this.#users++;\n clearTimeout(this.#linger);\n if (!this.#child && !this.#restart) {\n try {\n this.#start();\n } catch (error) {\n this.#options.onProblem?.(error as Error);\n }\n }\n let released = false;\n return () => {\n if (released) return;\n released = true;\n this.#users--;\n if (this.#users > 0) return;\n this.#linger = setTimeout(() => this.#stop(), this.#options.lingerMs ?? 3000);\n };\n }\n\n #start(): ChildProcess {\n clearTimeout(this.#restart);\n this.#restart = undefined;\n const [file, ...args] = this.#options.command();\n if (!file) throw new AudioUnavailable(BUILD_HINT);\n const child = spawn(file, args, { stdio: [\"pipe\", \"pipe\", \"pipe\"], windowsHide: true });\n this.#child = child;\n let buffer = \"\";\n let errors = \"\";\n child.stdout?.setEncoding(\"utf8\");\n child.stdout?.on(\"data\", (chunk: string) => {\n buffer += chunk;\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n for (const line of lines) this.#receive(line);\n });\n child.stderr?.setEncoding(\"utf8\");\n child.stderr?.on(\"data\", (chunk: string) => {\n errors = (errors + chunk).slice(-2000);\n });\n // Writing to a helper that just died must not crash the host.\n child.stdin?.on(\"error\", () => {});\n const ended = (reason: string) => {\n if (this.#child !== child) return;\n this.#child = undefined;\n this.#fail(new Error(reason));\n this.#publish(undefined);\n this.#options.onProblem?.(new AudioUnavailable(reason));\n if (this.#users <= 0) return;\n this.#restart = setTimeout(() => {\n this.#restart = undefined;\n if (this.#users <= 0 || this.#child) return;\n try {\n this.#start();\n } catch (error) {\n this.#options.onProblem?.(error as Error);\n }\n }, this.#delay);\n this.#delay = Math.min(this.#delay * 2, 30_000);\n };\n child.once(\"error\", (error) => ended(`the audio helper cannot run: ${error.message}`));\n child.once(\"close\", (code) =>\n ended(errors.trim() || `the audio helper stopped (exit ${code})`),\n );\n return child;\n }\n\n #stop(): void {\n clearTimeout(this.#restart);\n this.#restart = undefined;\n const child = this.#child;\n this.#child = undefined;\n this.#fail(new Error(\"the audio helper was stopped\"));\n this.#publish(undefined);\n if (!child) return;\n // Closing its input asks it to exit; insist if it does not.\n child.stdin?.end();\n const kill = setTimeout(() => child.kill(), 2000);\n child.once(\"close\", () => clearTimeout(kill));\n }\n\n #receive(line: string): void {\n let message: { id?: number; result?: unknown; error?: string; event?: string; data?: unknown };\n try {\n message = JSON.parse(line);\n } catch {\n return;\n }\n if (message.event === \"snapshot\") {\n this.#delay = 1000;\n this.#options.onProblem?.(undefined);\n this.#publish(message.data as Snapshot);\n return;\n }\n const pending = this.#pending.get(message.id ?? -1);\n if (!pending) return;\n this.#pending.delete(message.id as number);\n clearTimeout(pending.timer);\n if (message.error !== undefined) pending.reject(new Error(message.error));\n else pending.resolve(message.result);\n }\n\n #publish(snapshot: Snapshot | undefined): void {\n if (this.#snapshot === undefined && snapshot === undefined) return;\n this.#snapshot = snapshot;\n for (const listener of [...this.#listeners]) listener(snapshot);\n }\n\n #fail(error: Error): void {\n for (const pending of this.#pending.values()) {\n clearTimeout(pending.timer);\n pending.reject(error);\n }\n this.#pending.clear();\n }\n}\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";;AAAA,uBAAS;AACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACPA;AACA;AACA;AAAA;AA4CO,MAAM,yBAAyB,MAAM;AAAC;AAEtC,IAAM,aAAa;AAMnB,SAAS,UAAU,CACxB,MAA0C,QAAQ,KAClD,OAAe,YAAY,KAC3B,SAAoC,YAChB;AAAA,EACpB,MAAM,OAAO,QAAQ,aAAa,UAAU,oBAAoB;AAAA,EAChE,OAAO;AAAA,IACL,IAAI;AAAA,IACJ,KAAK,MAAM,MAAM,UAAU,UAAU,WAAW,IAAI;AAAA,IACpD,KAAK,MAAM,MAAM,OAAO,IAAI;AAAA,IAC5B,KAAK,MAAM,MAAM,UAAU,UAAU,SAAS,IAAI;AAAA,EACpD,EAAE,KAAK,CAAC,SAAyB,QAAQ,IAAI,KAAK,OAAO,IAAc,CAAC;AAAA;AAAA;AAmBnE,MAAM,YAAY;AAAA,EACd;AAAA,EACA,aA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AAU,SAAS,EAAE,QAAQ;AAAA,MACxD,UAAU,OAAO,GAAG,eAAe,MAAM;AAAA,IAC3C;AAAA,IACA,OAAO,MAAM;AAAA,MACX,QAAO,MAAM;AAAA;AAAA;AAGnB,CAAC;",
|
|
9
|
-
"debugId": "
|
|
9
|
+
"debugId": "CAF967AAC83306FD64756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdeck/plugin-audio",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"description": "Volume and mute for devices and apps, and switching between devices.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -28,7 +28,12 @@
|
|
|
28
28
|
},
|
|
29
29
|
"sdeck": {
|
|
30
30
|
"apiVersion": 3,
|
|
31
|
-
"entry": "./dist/index.js"
|
|
31
|
+
"entry": "./dist/index.js",
|
|
32
|
+
"icon": "lucide/audio-lines",
|
|
33
|
+
"permissions": [
|
|
34
|
+
"audio",
|
|
35
|
+
"process"
|
|
36
|
+
]
|
|
32
37
|
},
|
|
33
38
|
"scripts": {
|
|
34
39
|
"build": "bun ../../scripts/build-package.ts --target=bun",
|
|
@@ -37,8 +42,8 @@
|
|
|
37
42
|
"build:native": "cargo build --release --manifest-path native/Cargo.toml"
|
|
38
43
|
},
|
|
39
44
|
"peerDependencies": {
|
|
40
|
-
"@sdeck/plugin": "^0.4.
|
|
41
|
-
"@sdeck/schema": "^0.4.
|
|
45
|
+
"@sdeck/plugin": "^0.4.4",
|
|
46
|
+
"@sdeck/schema": "^0.4.2",
|
|
42
47
|
"react": ">=19.3"
|
|
43
48
|
},
|
|
44
49
|
"peerDependenciesMeta": {
|
|
@@ -53,8 +58,8 @@
|
|
|
53
58
|
}
|
|
54
59
|
},
|
|
55
60
|
"devDependencies": {
|
|
56
|
-
"@sdeck/plugin": "0.4.
|
|
57
|
-
"@sdeck/schema": "0.4.
|
|
61
|
+
"@sdeck/plugin": "0.4.4",
|
|
62
|
+
"@sdeck/schema": "0.4.2"
|
|
58
63
|
},
|
|
59
64
|
"repository": {
|
|
60
65
|
"type": "git",
|
package/src/index.tsx
CHANGED
|
@@ -40,7 +40,7 @@ const BLUE = "#60a5fa";
|
|
|
40
40
|
const plugin = createPlugin({
|
|
41
41
|
id: "@sdeck/plugin-audio",
|
|
42
42
|
name: "Audio",
|
|
43
|
-
version: "0.4.
|
|
43
|
+
version: "0.4.2",
|
|
44
44
|
namespace: "audio",
|
|
45
45
|
description: "Volume and mute for speakers, microphone and each app, and device switching.",
|
|
46
46
|
author: "sdeck",
|