@fluxlay/react 0.1.6 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,19 +18,114 @@ import "@fluxlay/react/dist/sdk.css";
18
18
 
19
19
  ## API
20
20
 
21
- ### `useBackendMouse()`
21
+ ### `useMousePosition()`
22
22
 
23
23
  Subscribes to the global mouse position streamed from the Fluxlay backend. The Y axis is inverted so that positive values point upward (standard mathematical coordinates).
24
24
 
25
25
  ```tsx
26
- import { useBackendMouse } from "@fluxlay/react";
26
+ import { useMousePosition } from "@fluxlay/react";
27
27
 
28
28
  function Wallpaper() {
29
- const { x, y } = useBackendMouse();
29
+ const { x, y } = useMousePosition();
30
30
  return <div style={{ transform: `translate(${x}px, ${y}px)` }} />;
31
31
  }
32
32
  ```
33
33
 
34
+ ### `useSystemMonitor()`
35
+
36
+ Subscribes to real-time system and hardware metrics streamed from the Fluxlay backend. Returns CPU, memory, battery, network, disk, and other system information.
37
+
38
+ ```tsx
39
+ import { useSystemMonitor } from "@fluxlay/react";
40
+
41
+ function Wallpaper() {
42
+ const { cpuUsage, memoryUsage, batteryLevel } = useSystemMonitor();
43
+ return (
44
+ <div style={{ fontFamily: "monospace" }}>
45
+ <p>CPU: {cpuUsage.toFixed(1)}%</p>
46
+ <p>Memory: {memoryUsage.toFixed(1)}%</p>
47
+ <p>Battery: {batteryLevel ?? "N/A"}</p>
48
+ </div>
49
+ );
50
+ }
51
+ ```
52
+
53
+ Refresh intervals can be configured per-category in `fluxlay.yaml`:
54
+
55
+ ```yaml
56
+ sdk:
57
+ system_monitor:
58
+ cpu_interval_ms: 500
59
+ memory_interval_ms: 1000
60
+ battery_interval_ms: 10000
61
+ ```
62
+
63
+ ### `useAudio()`
64
+
65
+ Subscribes to real-time system audio information streamed from the Fluxlay backend. Returns RMS volume, peak level, and a 32-band frequency spectrum, useful for building audio visualizers.
66
+
67
+ ```tsx
68
+ import { useAudio } from "@fluxlay/react";
69
+
70
+ function Wallpaper() {
71
+ const { rms, peak, spectrum } = useAudio();
72
+ return (
73
+ <div>
74
+ <p>Volume: {(rms * 100).toFixed(0)}%</p>
75
+ <div style={{ display: "flex", gap: 2, alignItems: "flex-end", height: 100 }}>
76
+ {spectrum.map((v, i) => (
77
+ <div key={i} style={{ width: 4, height: `${v * 100}%`, background: "white" }} />
78
+ ))}
79
+ </div>
80
+ </div>
81
+ );
82
+ }
83
+ ```
84
+
85
+ | Field | Type | Description |
86
+ |-------|------|-------------|
87
+ | `rms` | `number` | RMS (Root Mean Square) volume level (0.0 – 1.0). |
88
+ | `peak` | `number` | Peak volume level (0.0 – 1.0). |
89
+ | `spectrum` | `number[]` | Frequency spectrum split into 32 logarithmically-scaled bands (0.0 – 1.0 each). |
90
+
91
+ ### `useMediaMetadata()`
92
+
93
+ Subscribes to media metadata for the currently playing track from system media players (e.g. Spotify, Apple Music). Returns title, artist, album artwork, playback progress, and playback state.
94
+
95
+ ```tsx
96
+ import { useMediaMetadata } from "@fluxlay/react";
97
+
98
+ function Wallpaper() {
99
+ const { title, artist, artwork, isPlaying, elapsedTime, duration } = useMediaMetadata();
100
+ return (
101
+ <div>
102
+ {artwork && <img src={artwork} alt="Album art" width={200} />}
103
+ <p>{title ?? "Not playing"}</p>
104
+ <p>{artist}</p>
105
+ </div>
106
+ );
107
+ }
108
+ ```
109
+
110
+ Polling interval can be configured in `fluxlay.yaml`:
111
+
112
+ ```yaml
113
+ sdk:
114
+ media_metadata:
115
+ interval_ms: 1000
116
+ ```
117
+
118
+ | Field | Type | Description |
119
+ |-------|------|-------------|
120
+ | `title` | `string \| null` | Track title. |
121
+ | `artist` | `string \| null` | Artist name. |
122
+ | `album` | `string \| null` | Album name. |
123
+ | `artwork` | `string \| null` | Artwork as a data URL (`data:image/...;base64,...`). |
124
+ | `duration` | `number \| null` | Track duration in seconds. |
125
+ | `elapsedTime` | `number \| null` | Elapsed playback time in seconds. |
126
+ | `playbackRate` | `number \| null` | Playback rate (0.0 = paused, 1.0 = playing). |
127
+ | `isPlaying` | `boolean` | Whether media is currently playing. |
128
+
34
129
  ### `useShell(commandId, options?)`
35
130
 
36
131
  Executes a shell command declared in `fluxlay.yaml` and optionally renders its output into a terminal.
package/dist/index.d.ts CHANGED
@@ -3,6 +3,50 @@ import { ITheme } from '@xterm/xterm';
3
3
  import { RefObject } from 'react';
4
4
  import { Terminal } from '@xterm/xterm';
5
5
 
6
+ /** System audio information streamed from the Fluxlay backend. */
7
+ declare interface AudioInfo {
8
+ /** RMS (Root Mean Square) volume level (0.0 - 1.0). */
9
+ rms: number;
10
+ /** Peak volume level (0.0 - 1.0). */
11
+ peak: number;
12
+ /** Frequency spectrum split into 32 logarithmically-scaled bands (0.0 - 1.0 each). */
13
+ spectrum: number[];
14
+ }
15
+
16
+ /** Storage information for a single disk/volume. */
17
+ declare interface DiskInfo {
18
+ /** Mount point path (e.g. "/", "/home"). */
19
+ mountPoint: string;
20
+ /** Disk/volume name. */
21
+ name: string;
22
+ /** Total capacity in bytes. */
23
+ totalBytes: number;
24
+ /** Available (free) space in bytes. */
25
+ availableBytes: number;
26
+ /** Usage percentage (0.0 - 100.0). */
27
+ usage: number;
28
+ }
29
+
30
+ /** Media metadata information for the currently playing track. */
31
+ declare interface MediaMetadataInfo {
32
+ /** Track title, or `null` if unavailable. */
33
+ title: string | null;
34
+ /** Artist name, or `null` if unavailable. */
35
+ artist: string | null;
36
+ /** Album name, or `null` if unavailable. */
37
+ album: string | null;
38
+ /** Artwork as a data URL (e.g. "data:image/jpeg;base64,..."), or `null` if unavailable. */
39
+ artwork: string | null;
40
+ /** Track duration in seconds, or `null` if unavailable. */
41
+ duration: number | null;
42
+ /** Elapsed playback time in seconds, or `null` if unavailable. */
43
+ elapsedTime: number | null;
44
+ /** Playback rate (0.0 = paused, 1.0 = playing), or `null` if unavailable. */
45
+ playbackRate: number | null;
46
+ /** Whether media is currently playing. */
47
+ isPlaying: boolean;
48
+ }
49
+
6
50
  /**
7
51
  * Runs a pre-declared shell command from fluxlay.yaml.
8
52
  *
@@ -35,6 +79,62 @@ export declare interface ShellResult {
35
79
  signal: number | null;
36
80
  }
37
81
 
82
+ /** System hardware and performance information streamed from the Fluxlay backend. */
83
+ declare interface SystemMonitorInfo {
84
+ /** Overall CPU usage percentage (0.0 - 100.0). */
85
+ cpuUsage: number;
86
+ /** Per-core CPU usage percentages (0.0 - 100.0 each). */
87
+ cpuPerCore: number[];
88
+ /** Per-core CPU frequency in MHz. */
89
+ cpuFrequencyMhz: number[];
90
+ /** Total physical memory in bytes. */
91
+ memoryTotal: number;
92
+ /** Used physical memory in bytes. */
93
+ memoryUsed: number;
94
+ /** Memory usage percentage (0.0 - 100.0). */
95
+ memoryUsage: number;
96
+ /** Total swap space in bytes. */
97
+ swapTotal: number;
98
+ /** Used swap space in bytes. */
99
+ swapUsed: number;
100
+ /** Swap usage percentage (0.0 - 100.0). */
101
+ swapUsage: number;
102
+ /** Battery charge level (0.0 - 100.0), or `null` if no battery is present. */
103
+ batteryLevel: number | null;
104
+ /** Whether the battery is currently charging, or `null` if no battery is present. */
105
+ batteryCharging: boolean | null;
106
+ /** Network receive speed in bytes per second. */
107
+ networkRxBytesPerSec: number;
108
+ /** Network transmit speed in bytes per second. */
109
+ networkTxBytesPerSec: number;
110
+ /** Disk read speed in bytes per second. */
111
+ diskReadBytesPerSec: number;
112
+ /** Disk write speed in bytes per second. */
113
+ diskWriteBytesPerSec: number;
114
+ /** Number of running processes. */
115
+ processCount: number;
116
+ /** System uptime in seconds. */
117
+ uptimeSecs: number;
118
+ /** Load average for the past 1, 5, and 15 minutes. */
119
+ loadAverage: [number, number, number];
120
+ /** Per-disk storage information. */
121
+ disks: DiskInfo[];
122
+ /** System hostname. */
123
+ hostname: string;
124
+ /** Operating system name and version. */
125
+ osName: string;
126
+ /** CPU model name (e.g. "Apple M2 Pro"). */
127
+ cpuBrand: string;
128
+ /** Number of physical CPU cores. */
129
+ physicalCoreCount: number;
130
+ /** Number of logical CPU cores (threads). */
131
+ logicalCoreCount: number;
132
+ /** CPU architecture (e.g. "aarch64", "x86_64"). */
133
+ cpuArch: string;
134
+ /** Kernel version string. */
135
+ kernelVersion: string;
136
+ }
137
+
38
138
  /** Holds the xterm {@link Terminal} and its associated {@link FitAddon}. */
39
139
  export declare interface TerminalInstance {
40
140
  /** The underlying xterm Terminal instance. */
@@ -116,6 +216,30 @@ export declare const TerminalThemes: {
116
216
  };
117
217
  };
118
218
 
219
+ /**
220
+ * React hook that subscribes to system audio information streamed from
221
+ * the Fluxlay backend.
222
+ *
223
+ * Returns the current audio state including RMS volume, peak level,
224
+ * and frequency spectrum data, useful for building audio visualizers.
225
+ *
226
+ * @returns The current audio info as `{ rms, peak, spectrum }`.
227
+ */
228
+ export declare function useAudio(): AudioInfo;
229
+
230
+ /**
231
+ * React hook that subscribes to media metadata streamed from the
232
+ * Fluxlay backend.
233
+ *
234
+ * Returns information about the currently playing track from system
235
+ * media players (e.g. Spotify, Apple Music), including title, artist,
236
+ * album artwork, and playback state — useful for building
237
+ * music-reactive wallpapers.
238
+ *
239
+ * @returns The current media metadata info.
240
+ */
241
+ export declare function useMediaMetadata(): MediaMetadataInfo;
242
+
119
243
  /**
120
244
  * React hook that subscribes to global mouse position events streamed from
121
245
  * the Fluxlay backend.
@@ -129,7 +253,7 @@ export declare const TerminalThemes: {
129
253
  *
130
254
  * @returns The current mouse position as `{ x, y }`.
131
255
  */
132
- export declare function useBackendMouse(): {
256
+ export declare function useMousePosition(): {
133
257
  x: number;
134
258
  y: number;
135
259
  };
@@ -182,6 +306,18 @@ export declare interface UseShellOptions extends ShellOptions {
182
306
  terminal?: TerminalInstance | null;
183
307
  }
184
308
 
309
+ /**
310
+ * React hook that subscribes to system hardware information streamed
311
+ * from the Fluxlay backend.
312
+ *
313
+ * Returns real-time system metrics including CPU usage, memory usage,
314
+ * battery status, and network throughput — useful for building
315
+ * system-reactive wallpapers (e.g. cyberpunk HUDs, hardware monitors).
316
+ *
317
+ * @returns The current system monitor info.
318
+ */
319
+ export declare function useSystemMonitor(): SystemMonitorInfo;
320
+
185
321
  /**
186
322
  * React hook that creates and manages a read-only xterm terminal rendered
187
323
  * inside a `<div>` element.