@fluxlay/react 1.0.1 → 1.1.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/dist/index.d.ts DELETED
@@ -1,362 +0,0 @@
1
- import { FitAddon } from '@xterm/addon-fit';
2
- import { ITheme } from '@xterm/xterm';
3
- import { RefObject } from 'react';
4
- import { Terminal } from '@xterm/xterm';
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
-
50
- /**
51
- * Runs a pre-declared shell command from fluxlay.yaml.
52
- *
53
- * @param commandId The ID of the command declared in the manifest's `shell` section.
54
- * @param options Options for command execution.
55
- * @returns The standard output and error of the command.
56
- * @throws An error if the command fails or the ID is invalid.
57
- */
58
- export declare function runShell(commandId: string, options?: ShellOptions): Promise<ShellResult>;
59
-
60
- /** Options that control how a shell command is executed. */
61
- export declare interface ShellOptions {
62
- /** Number of columns (character width) of the pseudo-terminal. */
63
- columns?: number;
64
- /** Number of rows (line height) of the pseudo-terminal. */
65
- lines?: number;
66
- }
67
-
68
- /** The result returned after executing a shell command. */
69
- export declare interface ShellResult {
70
- /** Standard output produced by the command. */
71
- stdout: string;
72
- /** Standard error produced by the command. */
73
- stderr: string;
74
- /** Exit status code of the process, or `null` if the process was terminated by a signal. */
75
- statusCode: number | null;
76
- /** Whether the command exited successfully (status code 0). */
77
- success: boolean;
78
- /** Signal number that terminated the process, or `null` if it exited normally. */
79
- signal: number | null;
80
- }
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
-
138
- /** Holds the xterm {@link Terminal} and its associated {@link FitAddon}. */
139
- export declare interface TerminalInstance {
140
- /** The underlying xterm Terminal instance. */
141
- terminal: Terminal;
142
- /** The FitAddon used to resize the terminal to match its container element. */
143
- fitAddon: FitAddon;
144
- }
145
-
146
- /**
147
- * Collection of pre-built xterm color themes.
148
- *
149
- * Pass any of these values to the `theme` option of {@link useTerminal}.
150
- *
151
- * @example
152
- * ```tsx
153
- * const { terminalRef, instance } = useTerminal({
154
- * theme: TerminalThemes.dracula,
155
- * });
156
- * ```
157
- */
158
- export declare const TerminalThemes: {
159
- /** Dark themes with a transparent background. */
160
- readonly dark: {
161
- /** Default dark theme using Tailwind color palette. */
162
- readonly default: ITheme;
163
- /** Modern dark theme using Slate/Rose color palette. */
164
- readonly modern: ITheme;
165
- };
166
- /** Light themes. */
167
- readonly light: {
168
- /** Default light theme. */
169
- readonly default: ITheme;
170
- /** Modern light theme. */
171
- readonly modern: ITheme;
172
- };
173
- /** Nord theme — an arctic, north-bluish color palette. */
174
- readonly nord: ITheme;
175
- /** Dracula theme — a dark theme with vivid accent colors. */
176
- readonly dracula: ITheme;
177
- /** Gruvbox themes — a retro groove color scheme. */
178
- readonly gruvbox: {
179
- /** Gruvbox dark variant. */
180
- readonly dark: ITheme;
181
- /** Gruvbox light variant. */
182
- readonly light: ITheme;
183
- };
184
- /** Solarized themes — a precision color scheme with reduced brightness. */
185
- readonly solarized: {
186
- /** Solarized dark variant. */
187
- readonly dark: ITheme;
188
- /** Solarized light variant. */
189
- readonly light: ITheme;
190
- };
191
- /** One Dark theme — based on Atom's One Dark syntax theme. */
192
- readonly oneDark: ITheme;
193
- /** Catppuccin themes — a soothing pastel color scheme. */
194
- readonly catppuccin: {
195
- /** Catppuccin Latte — the light variant. */
196
- readonly latte: ITheme;
197
- /** Catppuccin Frappé — a cool medium-dark variant. */
198
- readonly frappe: ITheme;
199
- /** Catppuccin Macchiato — a warm medium-dark variant. */
200
- readonly macchiato: ITheme;
201
- /** Catppuccin Mocha — the darkest variant. */
202
- readonly mocha: ITheme;
203
- };
204
- /** Monokai Pro theme — a refined dark theme inspired by Monokai. */
205
- readonly monokaiPro: ITheme;
206
- /** Tokyo Night theme — a dark theme inspired by Tokyo city lights. */
207
- readonly tokyoNight: ITheme;
208
- /** Night Owl theme — optimized for late-night coding with low brightness. */
209
- readonly nightOwl: ITheme;
210
- /** Everforest themes — a green-tinted theme inspired by forests. */
211
- readonly everforest: {
212
- /** Everforest dark variant. */
213
- readonly dark: ITheme;
214
- /** Everforest light variant. */
215
- readonly light: ITheme;
216
- };
217
- };
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
-
243
- /**
244
- * React hook that subscribes to global mouse position events streamed from
245
- * the Fluxlay backend.
246
- *
247
- * The Y axis is inverted so that positive values point upward, matching a
248
- * standard mathematical coordinate system rather than the screen coordinate
249
- * system where Y grows downward.
250
- *
251
- * The subscription is scoped to the window identified by the `window_label`
252
- * query parameter of the current URL, defaulting to `"main"`.
253
- *
254
- * @returns The current mouse position as `{ x, y }`.
255
- */
256
- export declare function useMousePosition(): {
257
- x: number;
258
- y: number;
259
- };
260
-
261
- /**
262
- * React hook that executes a pre-declared Fluxlay shell command and
263
- * optionally renders its output into an xterm terminal.
264
- *
265
- * The command runs once on mount and is re-executed whenever `commandId`
266
- * changes or the `refreshInterval` elapses.
267
- *
268
- * @param commandId The ID of the command declared in `fluxlay.yaml`.
269
- * @param options Configuration options for execution and display behaviour.
270
- * @returns An object containing:
271
- * - `execute` – manually triggers the command.
272
- * - `isRunning` – `true` while the command is in progress.
273
- * - `error` – error message string when the last execution failed, otherwise `null`.
274
- * - `result` – the {@link ShellResult} of the last completed execution, or `null`.
275
- */
276
- export declare function useShell(commandId: string, options?: UseShellOptions): {
277
- execute: () => Promise<void>;
278
- isRunning: boolean;
279
- error: string | null;
280
- result: ShellResult | null;
281
- };
282
-
283
- /** Options for the {@link useShell} hook. */
284
- export declare interface UseShellOptions extends ShellOptions {
285
- /**
286
- * Interval in milliseconds at which the command is automatically re-executed.
287
- * Set to `0` to disable auto-refresh.
288
- * @defaultValue 30000
289
- */
290
- refreshInterval?: number;
291
- /**
292
- * Whether to write the command's stdout to the linked terminal.
293
- * @defaultValue true
294
- */
295
- showStdout?: boolean;
296
- /**
297
- * Whether to write the command's stderr to the linked terminal.
298
- * @defaultValue false
299
- */
300
- showStderr?: boolean;
301
- /**
302
- * Optional terminal instance returned by {@link useTerminal}.
303
- * When provided, command output is rendered directly into the terminal and
304
- * the terminal dimensions are used as the pseudo-terminal size.
305
- */
306
- terminal?: TerminalInstance | null;
307
- }
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
-
321
- /**
322
- * React hook that creates and manages a read-only xterm terminal rendered
323
- * inside a `<div>` element.
324
- *
325
- * The terminal is configured for display-only use: stdin is disabled, the
326
- * cursor is hidden, and the scrollback buffer is removed. Custom CSS overrides
327
- * are injected into `document.head` to make the terminal behave as an inline
328
- * block that expands to fill its container width.
329
- *
330
- * The terminal is disposed and the injected styles are removed when the
331
- * component unmounts or when `fontSize` / `fontFamily` change.
332
- *
333
- * @param options Display configuration for the terminal.
334
- * @returns An object containing:
335
- * - `terminalRef` – a React ref that must be attached to the container `<div>`.
336
- * - `instance` – the {@link TerminalInstance} once the terminal is mounted, or `null`.
337
- */
338
- export declare function useTerminal(options?: UseTerminalOptions): {
339
- terminalRef: RefObject<HTMLDivElement | null>;
340
- instance: TerminalInstance | null;
341
- };
342
-
343
- /** Options for the {@link useTerminal} hook. */
344
- export declare interface UseTerminalOptions {
345
- /**
346
- * Font size in pixels used by the terminal.
347
- * @defaultValue 12
348
- */
349
- fontSize?: number;
350
- /**
351
- * CSS font-family string applied to the terminal.
352
- * Defaults to a system monospace font stack.
353
- */
354
- fontFamily?: string;
355
- /**
356
- * Color theme applied to the terminal.
357
- * @defaultValue {@link TerminalThemes.dark.default}
358
- */
359
- theme?: ITheme;
360
- }
361
-
362
- export { }