@sdeck/plugin-audio 0.0.0-stage → 0.2.0
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/bin/sdeck-audio.exe +0 -0
- package/dist/helper.d.ts +95 -0
- package/dist/helper.d.ts.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +681 -0
- package/dist/index.js.map +11 -0
- package/native/Cargo.lock +230 -0
- package/native/Cargo.toml +29 -0
- package/native/src/main.rs +28 -0
- package/native/src/policy.rs +41 -0
- package/native/src/protocol.rs +132 -0
- package/native/src/windows_audio.rs +609 -0
- package/package.json +65 -4
- package/src/helper.ts +270 -0
- package/src/index.tsx +541 -0
- package/README.md +0 -3
|
Binary file
|
package/dist/helper.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export interface Level {
|
|
2
|
+
/** 0–100. */
|
|
3
|
+
volume: number;
|
|
4
|
+
muted: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface AudioDevice extends Level {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
default: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface AudioApp extends Level {
|
|
12
|
+
/** Executable name, lowercased (`system` for system sounds). */
|
|
13
|
+
name: string;
|
|
14
|
+
active: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface Snapshot {
|
|
17
|
+
outputs: AudioDevice[];
|
|
18
|
+
inputs: AudioDevice[];
|
|
19
|
+
apps: AudioApp[];
|
|
20
|
+
}
|
|
21
|
+
export interface Change {
|
|
22
|
+
before: Level;
|
|
23
|
+
after: Level;
|
|
24
|
+
}
|
|
25
|
+
export type Target = {
|
|
26
|
+
kind: "output";
|
|
27
|
+
device?: string;
|
|
28
|
+
} | {
|
|
29
|
+
kind: "input";
|
|
30
|
+
device?: string;
|
|
31
|
+
} | {
|
|
32
|
+
kind: "app";
|
|
33
|
+
app: string;
|
|
34
|
+
};
|
|
35
|
+
export interface Requests {
|
|
36
|
+
snapshot: {
|
|
37
|
+
params: undefined;
|
|
38
|
+
result: Snapshot;
|
|
39
|
+
};
|
|
40
|
+
setVolume: {
|
|
41
|
+
params: {
|
|
42
|
+
target: Target;
|
|
43
|
+
volume?: number;
|
|
44
|
+
delta?: number;
|
|
45
|
+
};
|
|
46
|
+
result: Change;
|
|
47
|
+
};
|
|
48
|
+
setMute: {
|
|
49
|
+
params: {
|
|
50
|
+
target: Target;
|
|
51
|
+
muted?: boolean;
|
|
52
|
+
};
|
|
53
|
+
result: Change;
|
|
54
|
+
};
|
|
55
|
+
setDefault: {
|
|
56
|
+
params: {
|
|
57
|
+
device: string;
|
|
58
|
+
};
|
|
59
|
+
result: {
|
|
60
|
+
previous: string | null;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** Why there is no audio: shown to the user. */
|
|
65
|
+
export declare class AudioUnavailable extends Error {
|
|
66
|
+
}
|
|
67
|
+
export declare const BUILD_HINT = "Build the audio helper with `bun run build:audio`";
|
|
68
|
+
/**
|
|
69
|
+
* Where the helper is: `SDECK_AUDIO_BIN`, the cargo build next to this package, or `bin/` next to
|
|
70
|
+
* a bundled app.
|
|
71
|
+
*/
|
|
72
|
+
export declare function findHelper(env?: Record<string, string | undefined>, base?: string, exists?: (path: string) => boolean): string | undefined;
|
|
73
|
+
export interface AudioHelperOptions {
|
|
74
|
+
/** The command line to run; throw {@link AudioUnavailable} when there is none. */
|
|
75
|
+
command: () => string[];
|
|
76
|
+
/** The helper could not run, or stopped. `undefined`: it works again. */
|
|
77
|
+
onProblem?: (problem: Error | undefined) => void;
|
|
78
|
+
/** How long it keeps running after the last user leaves. */
|
|
79
|
+
lingerMs?: number;
|
|
80
|
+
timeoutMs?: number;
|
|
81
|
+
}
|
|
82
|
+
export declare class AudioHelper {
|
|
83
|
+
#private;
|
|
84
|
+
constructor(options: AudioHelperOptions);
|
|
85
|
+
/** The devices as last reported, while the helper runs. */
|
|
86
|
+
get snapshot(): Snapshot | undefined;
|
|
87
|
+
/** Whether the helper process is running. */
|
|
88
|
+
get running(): boolean;
|
|
89
|
+
/** Hears every snapshot while subscribed (which keeps the helper running). */
|
|
90
|
+
subscribe(listener: (snapshot: Snapshot | undefined) => void): () => void;
|
|
91
|
+
request<M extends keyof Requests>(method: M, params?: Requests[M]["params"]): Promise<Requests[M]["result"]>;
|
|
92
|
+
/** Stops the helper now, whoever uses it. */
|
|
93
|
+
close(): void;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,KAAK;IACpB,aAAa;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,WAAY,SAAQ,KAAK;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,QAAS,SAAQ,KAAK;IACrC,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,IAAI,EAAE,QAAQ,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,KAAK,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,MAAM,MAAM,GACd;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAA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;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,WAAW;;IAYtB,YAAY,OAAO,EAAE,kBAAkB,EAEtC;IAED,2DAA2D;IAC3D,IAAI,QAAQ,IAAI,QAAQ,GAAG,SAAS,CAEnC;IAED,6CAA6C;IAC7C,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,8EAA8E;IAC9E,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAQxE;IAEK,OAAO,CAAC,CAAC,SAAS,MAAM,QAAQ,EACpC,MAAM,EAAE,CAAC,EACT,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAC7B,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAgBhC;IAED,6CAA6C;IAC7C,KAAK,IAAI,IAAI,CAKZ;CAqHF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type AudioDevice, type Snapshot } from "./helper.ts";
|
|
2
|
+
export * from "./helper.ts";
|
|
3
|
+
/** `Spotify.exe` → `spotify`, the key of `audio.apps`. */
|
|
4
|
+
export declare function appKey(name: string): string;
|
|
5
|
+
/** What the plugin publishes, from one snapshot of the devices. */
|
|
6
|
+
export declare function audioState(snapshot: Snapshot | undefined): {
|
|
7
|
+
master: undefined;
|
|
8
|
+
mic: undefined;
|
|
9
|
+
output: undefined;
|
|
10
|
+
input: undefined;
|
|
11
|
+
outputs: undefined;
|
|
12
|
+
inputs: undefined;
|
|
13
|
+
apps: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
master: {
|
|
16
|
+
volume: number;
|
|
17
|
+
muted: boolean;
|
|
18
|
+
name: string;
|
|
19
|
+
} | undefined;
|
|
20
|
+
mic: {
|
|
21
|
+
volume: number;
|
|
22
|
+
muted: boolean;
|
|
23
|
+
name: string;
|
|
24
|
+
} | undefined;
|
|
25
|
+
output: string | undefined;
|
|
26
|
+
input: string | undefined;
|
|
27
|
+
outputs: AudioDevice[];
|
|
28
|
+
inputs: AudioDevice[];
|
|
29
|
+
apps: {
|
|
30
|
+
[k: string]: import("./helper.ts").AudioApp;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
interface TargetSettings {
|
|
34
|
+
target: "output" | "input" | "app";
|
|
35
|
+
app: string;
|
|
36
|
+
}
|
|
37
|
+
/** The state path of a target's level, for templates and expressions. */
|
|
38
|
+
export declare function targetPath(s: TargetSettings): string;
|
|
39
|
+
/** The icons of a target: sounding and muted. */
|
|
40
|
+
export declare function targetIcons(s: TargetSettings): {
|
|
41
|
+
on: string;
|
|
42
|
+
off: string;
|
|
43
|
+
};
|
|
44
|
+
/** The device after the default one, for "Next device". */
|
|
45
|
+
export declare function nextDevice(devices: readonly AudioDevice[]): AudioDevice | undefined;
|
|
46
|
+
declare const _default: import("@sdeck/plugin").PluginDef;
|
|
47
|
+
export default _default;
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,WAAW,EAMhB,KAAK,QAAQ,EAEd,MAAM,aAAa,CAAC;AAErB,cAAc,aAAa,CAAC;AAE5B,0DAA0D;AAC1D,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK3C;AAED,mEAAmE;AACnE,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBxD;AA0CD,UAAU,cAAc;IACtB,MAAM,EAAE,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;IACnC,GAAG,EAAE,MAAM,CAAC;CACb;AAQD,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAIpD;AAsBD,iDAAiD;AACjD,wBAAgB,WAAW,CAAC,CAAC,EAAE,cAAc,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAM1E;AAiQD,2DAA2D;AAC3D,wBAAgB,UAAU,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,WAAW,GAAG,SAAS,CAGnF"}
|