@fluxlay/react 0.1.6 → 1.1.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 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,65 @@ 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 logarithmically-scaled bands (0.0 - 1.0 each). The number of bands is configurable via `useAudio({ numBands })`. */
13
+ spectrum: number[];
14
+ }
15
+
16
+ /** Options for the audio stream. */
17
+ export declare interface AudioOptions {
18
+ /** Number of frequency spectrum bands. Default is 32. */
19
+ numBands?: number;
20
+ }
21
+
22
+ /** Storage information for a single disk/volume. */
23
+ declare interface DiskInfo {
24
+ /** Mount point path (e.g. "/", "/home"). */
25
+ mountPoint: string;
26
+ /** Disk/volume name. */
27
+ name: string;
28
+ /** Total capacity in bytes. */
29
+ totalBytes: number;
30
+ /** Available (free) space in bytes. */
31
+ availableBytes: number;
32
+ /** Usage percentage (0.0 - 100.0). */
33
+ usage: number;
34
+ }
35
+
36
+ /** Media metadata information for the currently playing track. */
37
+ declare interface MediaMetadataInfo {
38
+ /** Track title, or `null` if unavailable. */
39
+ title: string | null;
40
+ /** Artist name, or `null` if unavailable. */
41
+ artist: string | null;
42
+ /** Album name, or `null` if unavailable. */
43
+ album: string | null;
44
+ /** Artwork as a data URL (e.g. "data:image/jpeg;base64,..."), or `null` if unavailable. */
45
+ artwork: string | null;
46
+ /** Track duration in seconds, or `null` if unavailable. */
47
+ duration: number | null;
48
+ /** Elapsed playback time in seconds, or `null` if unavailable. */
49
+ elapsedTime: number | null;
50
+ /** Playback rate (0.0 = paused, 1.0 = playing), or `null` if unavailable. */
51
+ playbackRate: number | null;
52
+ /** Whether media is currently playing. */
53
+ isPlaying: boolean;
54
+ }
55
+
56
+ /** Options for the media metadata stream. */
57
+ export declare interface MediaMetadataOptions {
58
+ /** Polling interval in milliseconds. Default is 1000. */
59
+ intervalMs?: number;
60
+ }
61
+
62
+ /** Custom property values set by the end user via the Fluxlay settings UI. */
63
+ declare type PropertyValues = Record<string, number | string | boolean>;
64
+
6
65
  /**
7
66
  * Runs a pre-declared shell command from fluxlay.yaml.
8
67
  *
@@ -35,6 +94,82 @@ export declare interface ShellResult {
35
94
  signal: number | null;
36
95
  }
37
96
 
97
+ /** System hardware and performance information streamed from the Fluxlay backend. */
98
+ declare interface SystemMonitorInfo {
99
+ /** Overall CPU usage percentage (0.0 - 100.0). */
100
+ cpuUsage: number;
101
+ /** Per-core CPU usage percentages (0.0 - 100.0 each). */
102
+ cpuPerCore: number[];
103
+ /** Per-core CPU frequency in MHz. */
104
+ cpuFrequencyMhz: number[];
105
+ /** Total physical memory in bytes. */
106
+ memoryTotal: number;
107
+ /** Used physical memory in bytes. */
108
+ memoryUsed: number;
109
+ /** Memory usage percentage (0.0 - 100.0). */
110
+ memoryUsage: number;
111
+ /** Total swap space in bytes. */
112
+ swapTotal: number;
113
+ /** Used swap space in bytes. */
114
+ swapUsed: number;
115
+ /** Swap usage percentage (0.0 - 100.0). */
116
+ swapUsage: number;
117
+ /** Battery charge level (0.0 - 100.0), or `null` if no battery is present. */
118
+ batteryLevel: number | null;
119
+ /** Whether the battery is currently charging, or `null` if no battery is present. */
120
+ batteryCharging: boolean | null;
121
+ /** Network receive speed in bytes per second. */
122
+ networkRxBytesPerSec: number;
123
+ /** Network transmit speed in bytes per second. */
124
+ networkTxBytesPerSec: number;
125
+ /** Disk read speed in bytes per second. */
126
+ diskReadBytesPerSec: number;
127
+ /** Disk write speed in bytes per second. */
128
+ diskWriteBytesPerSec: number;
129
+ /** Number of running processes. */
130
+ processCount: number;
131
+ /** System uptime in seconds. */
132
+ uptimeSecs: number;
133
+ /** Load average for the past 1, 5, and 15 minutes. */
134
+ loadAverage: [number, number, number];
135
+ /** Per-disk storage information. */
136
+ disks: DiskInfo[];
137
+ /** System hostname. */
138
+ hostname: string;
139
+ /** Operating system name and version. */
140
+ osName: string;
141
+ /** CPU model name (e.g. "Apple M2 Pro"). */
142
+ cpuBrand: string;
143
+ /** Number of physical CPU cores. */
144
+ physicalCoreCount: number;
145
+ /** Number of logical CPU cores (threads). */
146
+ logicalCoreCount: number;
147
+ /** CPU architecture (e.g. "aarch64", "x86_64"). */
148
+ cpuArch: string;
149
+ /** Kernel version string. */
150
+ kernelVersion: string;
151
+ }
152
+
153
+ /** Polling interval options for each system monitor category (in milliseconds). */
154
+ export declare interface SystemMonitorOptions {
155
+ /** CPU usage polling interval in ms. */
156
+ cpuIntervalMs?: number;
157
+ /** Memory usage polling interval in ms. */
158
+ memoryIntervalMs?: number;
159
+ /** Network throughput polling interval in ms. */
160
+ networkIntervalMs?: number;
161
+ /** Disk I/O polling interval in ms. */
162
+ diskIoIntervalMs?: number;
163
+ /** Disk space polling interval in ms. */
164
+ diskSpaceIntervalMs?: number;
165
+ /** Battery status polling interval in ms. */
166
+ batteryIntervalMs?: number;
167
+ /** Process count polling interval in ms. */
168
+ processIntervalMs?: number;
169
+ /** Load average polling interval in ms. */
170
+ loadAverageIntervalMs?: number;
171
+ }
172
+
38
173
  /** Holds the xterm {@link Terminal} and its associated {@link FitAddon}. */
39
174
  export declare interface TerminalInstance {
40
175
  /** The underlying xterm Terminal instance. */
@@ -116,6 +251,32 @@ export declare const TerminalThemes: {
116
251
  };
117
252
  };
118
253
 
254
+ /**
255
+ * React hook that subscribes to system audio information streamed from
256
+ * the Fluxlay backend.
257
+ *
258
+ * Returns the current audio state including RMS volume, peak level,
259
+ * and frequency spectrum data, useful for building audio visualizers.
260
+ *
261
+ * @param options - Optional audio configuration.
262
+ * @returns The current audio info as `{ rms, peak, spectrum }`.
263
+ */
264
+ export declare function useAudio(options?: AudioOptions): AudioInfo;
265
+
266
+ /**
267
+ * React hook that subscribes to media metadata streamed from the
268
+ * Fluxlay backend.
269
+ *
270
+ * Returns information about the currently playing track from system
271
+ * media players (e.g. Spotify, Apple Music), including title, artist,
272
+ * album artwork, and playback state — useful for building
273
+ * music-reactive wallpapers.
274
+ *
275
+ * @param options - Optional media metadata configuration.
276
+ * @returns The current media metadata info.
277
+ */
278
+ export declare function useMediaMetadata(options?: MediaMetadataOptions): MediaMetadataInfo;
279
+
119
280
  /**
120
281
  * React hook that subscribes to global mouse position events streamed from
121
282
  * the Fluxlay backend.
@@ -129,11 +290,23 @@ export declare const TerminalThemes: {
129
290
  *
130
291
  * @returns The current mouse position as `{ x, y }`.
131
292
  */
132
- export declare function useBackendMouse(): {
293
+ export declare function useMousePosition(): {
133
294
  x: number;
134
295
  y: number;
135
296
  };
136
297
 
298
+ /**
299
+ * React hook that provides the current custom property values defined
300
+ * in the wallpaper manifest and customized by the end user.
301
+ *
302
+ * Fetches initial values on mount and subscribes to real-time updates
303
+ * via the properties stream.
304
+ *
305
+ * @typeParam T - Shape of the property values object.
306
+ * @returns The current property values typed as `T`.
307
+ */
308
+ export declare function useProperties<T extends PropertyValues = PropertyValues>(): T;
309
+
137
310
  /**
138
311
  * React hook that executes a pre-declared Fluxlay shell command and
139
312
  * optionally renders its output into an xterm terminal.
@@ -182,6 +355,19 @@ export declare interface UseShellOptions extends ShellOptions {
182
355
  terminal?: TerminalInstance | null;
183
356
  }
184
357
 
358
+ /**
359
+ * React hook that subscribes to system hardware information streamed
360
+ * from the Fluxlay backend.
361
+ *
362
+ * Returns real-time system metrics including CPU usage, memory usage,
363
+ * battery status, and network throughput — useful for building
364
+ * system-reactive wallpapers (e.g. cyberpunk HUDs, hardware monitors).
365
+ *
366
+ * @param options - Optional polling interval configuration for each category.
367
+ * @returns The current system monitor info.
368
+ */
369
+ export declare function useSystemMonitor(options?: SystemMonitorOptions): SystemMonitorInfo;
370
+
185
371
  /**
186
372
  * React hook that creates and manages a read-only xterm terminal rendered
187
373
  * inside a `<div>` element.