@edgestation/sdk 0.2.0 → 0.4.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/README.md +1 -1
- package/dist/types.d.ts +124 -3
- package/manifest.schema.json +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -206,4 +206,4 @@ To share the widget, ship the folder with `manifest.json`, `dist/` and any files
|
|
|
206
206
|
|
|
207
207
|
## Types
|
|
208
208
|
|
|
209
|
-
Everything is exported from `@edgestation/sdk` as types: `WidgetApi`, `WidgetModule`, `WidgetManifest`, `WidgetProps`, the settings types and the results of `api.system()`, `api.media`, `api.apps` and `api.storage`.
|
|
209
|
+
Everything is exported from `@edgestation/sdk` as types: `WidgetApi`, `WidgetModule`, `WidgetManifest`, `WidgetProps`, the settings types and the results of `api.system()`, `api.media`, `api.audio`, `api.apps` and `api.storage`.
|
package/dist/types.d.ts
CHANGED
|
@@ -47,9 +47,21 @@ export interface SelectSetting extends SettingBase {
|
|
|
47
47
|
value: string;
|
|
48
48
|
label: string;
|
|
49
49
|
}[];
|
|
50
|
+
/**
|
|
51
|
+
* Adds the choices of a list EdgeStation reads when the settings show, after `options`. A
|
|
52
|
+
* saved value that isn't in the list then (an app that isn't running) stays saved, and the
|
|
53
|
+
* widget gets it as it is.
|
|
54
|
+
*/
|
|
55
|
+
source?: SettingSource;
|
|
50
56
|
/** Used until the user picks something. Defaults to the first option. */
|
|
51
57
|
default?: string;
|
|
52
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Lists a select setting can add choices from:
|
|
61
|
+
* - `audioApps`: the apps with sound on the default output (`api.audio`), each saved as its
|
|
62
|
+
* executable's file name (`AudioApp.program`, such as `Discord.exe`).
|
|
63
|
+
*/
|
|
64
|
+
export type SettingSource = 'audioApps';
|
|
53
65
|
/** Free text, such as a URL. */
|
|
54
66
|
export interface TextSetting extends SettingBase {
|
|
55
67
|
type: 'text';
|
|
@@ -85,6 +97,11 @@ export interface WidgetApi {
|
|
|
85
97
|
readonly media: MediaApi;
|
|
86
98
|
/** The apps of the Start menu: listed when called, started, and their icons. */
|
|
87
99
|
readonly apps: AppsApi;
|
|
100
|
+
/**
|
|
101
|
+
* The machine's sound as the volume mixer shows it: the default output and microphone, the
|
|
102
|
+
* apps playing, their volumes and how loud they are. Read and changed when called.
|
|
103
|
+
*/
|
|
104
|
+
readonly audio: AudioApi;
|
|
88
105
|
/**
|
|
89
106
|
* The web's `fetch`, sent by the app rather than the Edge page, so CORS doesn't apply: any
|
|
90
107
|
* `http` or `https` URL answers as it would answer a server. Headers browsers forbid
|
|
@@ -147,9 +164,10 @@ export interface WebviewOptions {
|
|
|
147
164
|
*/
|
|
148
165
|
mobile?: boolean;
|
|
149
166
|
/**
|
|
150
|
-
* Shows a Home button
|
|
151
|
-
* takes it back there. The view leaves
|
|
152
|
-
* widget's root, like the picture). Where `url` redirects to as it loads
|
|
167
|
+
* Shows a round Home button above the keyboard button, over the view's bottom right corner,
|
|
168
|
+
* while it is away from `url`, which takes it back there. The view leaves a hole for it (an
|
|
169
|
+
* element added to the widget's root, like the picture). Where `url` redirects to as it loads
|
|
170
|
+
* counts as `url`.
|
|
153
171
|
*/
|
|
154
172
|
homeButton?: boolean;
|
|
155
173
|
}
|
|
@@ -268,6 +286,109 @@ export interface AppInfo {
|
|
|
268
286
|
/** What the Start menu calls it. */
|
|
269
287
|
name: string;
|
|
270
288
|
}
|
|
289
|
+
/** The machine's sound, as Windows' volume mixer shows it. Nothing listens in between calls. */
|
|
290
|
+
export interface AudioApi {
|
|
291
|
+
/** The default output and microphone, and the apps on that output, read when called. */
|
|
292
|
+
mixer(): Promise<AudioMixer>;
|
|
293
|
+
/** How loud the default output, the microphone and each app are right now. */
|
|
294
|
+
levels(): Promise<AudioLevels>;
|
|
295
|
+
/**
|
|
296
|
+
* Calls `fn` when the mixer changes: a volume or mute, an app's sound opening, closing,
|
|
297
|
+
* starting or stopping, the default device. Read `mixer()` then. Windows tells the app, so
|
|
298
|
+
* nothing polls. While the widget's page is off screen or the Edge is frozen it waits, then
|
|
299
|
+
* calls `fn` once when the widget shows again. Stops on unmount; returns a function that stops
|
|
300
|
+
* it sooner.
|
|
301
|
+
*/
|
|
302
|
+
onChange(fn: () => unknown): Cleanup;
|
|
303
|
+
/**
|
|
304
|
+
* Calls `fn` with the levels 25 times a second while there is sound, and for two seconds
|
|
305
|
+
* after, so meters can fall; then not at all until there is sound again (it shows within a
|
|
306
|
+
* quarter of a second). Only while the widget's page shows and the Edge isn't frozen. Stops
|
|
307
|
+
* on unmount; returns a function that stops it sooner.
|
|
308
|
+
*/
|
|
309
|
+
onLevels(fn: (levels: AudioLevels) => unknown): Cleanup;
|
|
310
|
+
/**
|
|
311
|
+
* Sets the volume of `target`, from 0 to 1 (values outside are clamped). Resolves `false`
|
|
312
|
+
* when it is gone: the app closed, or there is no such device anymore.
|
|
313
|
+
*/
|
|
314
|
+
setVolume(target: AudioTarget, volume: number): Promise<boolean>;
|
|
315
|
+
/**
|
|
316
|
+
* Mutes or unmutes `target`, like `setVolume`. Muting `'input'` mutes the default
|
|
317
|
+
* microphone and, when it is another device, the default one for calls.
|
|
318
|
+
*/
|
|
319
|
+
setMuted(target: AudioTarget, muted: boolean): Promise<boolean>;
|
|
320
|
+
/** The output devices plugged in and enabled, by name, read when called. */
|
|
321
|
+
outputs(): Promise<AudioOutput[]>;
|
|
322
|
+
/**
|
|
323
|
+
* Makes output `id` the default one, as Sound settings' "Set as default device" does: calls
|
|
324
|
+
* keep the device picked for them. Resolves `false` when it is no longer plugged in. Windows
|
|
325
|
+
* has no public API for this: it uses the one Sound settings uses.
|
|
326
|
+
*/
|
|
327
|
+
setOutput(id: string): Promise<boolean>;
|
|
328
|
+
/**
|
|
329
|
+
* URL of the icon of an app's executable (`AudioApp.path`), for an `<img>`: a PNG `size`
|
|
330
|
+
* pixels square (16 to 256, default 64).
|
|
331
|
+
*/
|
|
332
|
+
icon(path: string, size?: number): string;
|
|
333
|
+
}
|
|
334
|
+
/** What `setVolume` and `setMuted` change: the default output, the microphone, or an app's `id`. */
|
|
335
|
+
export type AudioTarget = 'output' | 'input' | (string & {});
|
|
336
|
+
export interface AudioMixer {
|
|
337
|
+
/** The default output, the one the volume flyout shows; `null` without one. */
|
|
338
|
+
output: AudioDevice | null;
|
|
339
|
+
/**
|
|
340
|
+
* The default microphone; `null` without one. `muted` is `true` only when the default one
|
|
341
|
+
* for calls is muted too.
|
|
342
|
+
*/
|
|
343
|
+
input: AudioDevice | null;
|
|
344
|
+
/** The apps with a sound session on the default output, by name, System sounds last. */
|
|
345
|
+
apps: AudioApp[];
|
|
346
|
+
}
|
|
347
|
+
/** A sound device. */
|
|
348
|
+
export interface AudioDevice {
|
|
349
|
+
/** Windows' id of the device, as `outputs()` lists it. */
|
|
350
|
+
id: string;
|
|
351
|
+
/** What Sound settings calls it (`Speakers (Realtek(R) Audio)`). */
|
|
352
|
+
name: string;
|
|
353
|
+
/** From 0 to 1, as the volume flyout shows it. */
|
|
354
|
+
volume: number;
|
|
355
|
+
muted: boolean;
|
|
356
|
+
}
|
|
357
|
+
/** An app's sound: every session Windows' volume mixer shows as one. */
|
|
358
|
+
export interface AudioApp {
|
|
359
|
+
/** Names the app's sound while it runs, for `setVolume` and `levels()`. Not kept across restarts. */
|
|
360
|
+
id: string;
|
|
361
|
+
/**
|
|
362
|
+
* The name the app gives its sound, else what Task Manager calls it (its executable's
|
|
363
|
+
* description), else its executable's file name.
|
|
364
|
+
*/
|
|
365
|
+
name: string;
|
|
366
|
+
/** Its executable, for `icon()`; `null` for System sounds. */
|
|
367
|
+
path: string | null;
|
|
368
|
+
/**
|
|
369
|
+
* Its executable's file name (`Discord.exe`): it names the app across restarts and updates
|
|
370
|
+
* (its folder may change with them), so save this one. `null` for System sounds.
|
|
371
|
+
*/
|
|
372
|
+
program: string | null;
|
|
373
|
+
/** From 0 to 1, a share of the output's volume. */
|
|
374
|
+
volume: number;
|
|
375
|
+
muted: boolean;
|
|
376
|
+
/** Playing right now, rather than open and silent. */
|
|
377
|
+
active: boolean;
|
|
378
|
+
}
|
|
379
|
+
/** Peak levels of the last few milliseconds, from 0 to 1. */
|
|
380
|
+
export interface AudioLevels {
|
|
381
|
+
output: number;
|
|
382
|
+
/** The default microphone, while an app records from it; 0 otherwise. */
|
|
383
|
+
input: number;
|
|
384
|
+
/** By app `id`. */
|
|
385
|
+
apps: Record<string, number>;
|
|
386
|
+
}
|
|
387
|
+
/** An output device `setOutput` can switch to. */
|
|
388
|
+
export interface AudioOutput {
|
|
389
|
+
id: string;
|
|
390
|
+
name: string;
|
|
391
|
+
}
|
|
271
392
|
/** The default export of a widget's entry module. */
|
|
272
393
|
export interface WidgetModule {
|
|
273
394
|
/** Render into `el`. May return (or resolve to) a cleanup function. */
|
package/manifest.schema.json
CHANGED
|
@@ -87,6 +87,10 @@
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
|
+
"source": {
|
|
91
|
+
"enum": ["audioApps"],
|
|
92
|
+
"description": "Adds the choices of a list EdgeStation reads when the settings show, after options. audioApps: the apps with sound, saved as their executable's file name. A saved value missing from the list stays saved."
|
|
93
|
+
},
|
|
90
94
|
"default": {
|
|
91
95
|
"type": "string",
|
|
92
96
|
"description": "Value until the user picks one. Defaults to the first option."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edgestation/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Types and build helpers to write widgets for EdgeStation, the secondary display dashboard made for the Corsair Xeneon Edge, in plain JavaScript, Svelte, React or Vue.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"edgestation",
|