node-system-bridge
Version:
A cross-platform system automation library for Node.js and Electron, written in Rust
484 lines (481 loc) • 13.1 kB
TypeScript
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export declare namespace Process {
/**
* Launch an application
*
* # Parameters
* * `app_path` - Application executable file path
* * `args` - Optional launch arguments array
*
* # Returns
* Returns process ID (PID)
*
* # Examples
* ```javascript
* // Without arguments
* const pid = Process.launchApp('/Applications/Safari.app/Contents/MacOS/Safari');
*
* // With arguments
* const pid = Process.launchApp('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', [
* '--new-window',
* 'https://example.com'
* ]);
* ```
*/
export function launchApp(appPath: string, args?: Array<string> | undefined | null): number
/**
* Kill a process
*
* # Parameters
* * `pid` - Process ID
*
* # Examples
* ```javascript
* Process.killProcess(1234);
* ```
*/
export function killProcess(pid: number): void
/**
* Check if a process is running
*
* # Parameters
* * `pid` - Process ID
*
* # Returns
* Returns true if process exists, false otherwise
*
* # Examples
* ```javascript
* if (Process.isRunning(1234)) {
* console.log('Process is running');
* }
* ```
*/
export function isRunning(pid: number): boolean
/** Process information object */
export interface ProcessInfo {
/** Process ID */
pid: number
/** Process name */
name: string
/** CPU usage percentage */
cpuUsage: number
/** Memory usage in bytes */
memory: number
/** Parent process ID */
parentPid?: number
/** Launch command and arguments (array) */
cmd: Array<string>
/** Executable file path */
exe?: string
/** Current working directory */
cwd?: string
}
/**
* Get all processes list
*
* # Returns
* Returns an array of all process information
*
* # Examples
* ```javascript
* const processes = Process.getAllProcesses();
* console.log(`Total processes: ${processes.length}`);
*
* // Find specific processes
* const chromeProcesses = processes.filter(p => p.name.includes('Chrome'));
* console.log('Chrome processes:', chromeProcesses);
*
* // Sort by memory
* const topMemory = processes.sort((a, b) => b.memory - a.memory).slice(0, 10);
* console.log('Top 10 memory usage:', topMemory);
* ```
*/
export function getAllProcesses(): Array<ProcessInfo>
}
export declare namespace Mouse {
/**
* Simulate mouse click
*
* # Parameters
* * `x` - Screen X coordinate (absolute, from top-left corner)
* * `y` - Screen Y coordinate (absolute, from top-left corner)
* * `button` - Optional mouse button type, default is "left". Options:
* - "left": Left button
* - "right": Right button
* - "middle": Middle button
* * `click_type` - Optional click type, default is "single". Options:
* - "single": Single click
* - "double": Double click
*
* # Examples
* ```javascript
* import { Mouse } from 'node-system-bridge';
*
* // Simple click (left button single click)
* Mouse.click(100, 200);
*
* // Right click
* Mouse.click(100, 200, 'right');
*
* // Double click
* Mouse.click(100, 200, 'left', 'double');
* ```
*/
export function click(x: number, y: number, button?: string | undefined | null, clickType?: string | undefined | null): void
/**
* Move mouse to specified coordinates
*
* # Parameters
* * `x` - Screen X coordinate
* * `y` - Screen Y coordinate
*
* # Examples
* ```javascript
* Mouse.moveTo(500, 300);
* ```
*/
export function moveTo(x: number, y: number): void
/**
* Press mouse button down
*
* # Parameters
* * `button` - Optional mouse button type, default is "left"
*
* # Examples
* ```javascript
* Mouse.mouseDown('left');
* // ... perform other operations ...
* Mouse.mouseUp('left');
* ```
*/
export function mouseDown(button?: string | undefined | null): void
/**
* Release mouse button
*
* # Parameters
* * `button` - Optional mouse button type, default is "left"
*
* # Examples
* ```javascript
* Mouse.mouseUp('left');
* ```
*/
export function mouseUp(button?: string | undefined | null): void
/**
* Scroll mouse wheel
*
* # Parameters
* * `amount` - Scroll amount (positive for up, negative for down)
*
* # Examples
* ```javascript
* // Scroll up
* Mouse.scroll(5);
*
* // Scroll down
* Mouse.scroll(-5);
* ```
*/
export function scroll(amount: number): void
/**
* Smoothly move mouse to specified coordinates (simulates human trajectory)
*
* # Parameters
* * `x` - Target screen X coordinate
* * `y` - Target screen Y coordinate
* * `duration_ms` - Optional movement duration in milliseconds, auto-calculated if not specified
* * `use_bezier` - Optional, whether to use Bezier curve (default: true)
* * `curve_intensity` - Optional, curve intensity 0.0-1.0 (default: 0.2)
* * `add_jitter` - Optional, whether to add random jitter (default: true)
*
* # Examples
* ```javascript
* // Use default parameters (Bezier curve + auto duration)
* Mouse.moveToSmooth(500, 300);
*
* // Specify movement duration of 1 second
* Mouse.moveToSmooth(500, 300, 1000);
*
* // Customize all parameters
* Mouse.moveToSmooth(500, 300, 1000, true, 0.3, true);
*
* // Linear movement (without Bezier curve)
* Mouse.moveToSmooth(500, 300, 500, false);
* ```
*/
export function moveToSmooth(x: number, y: number, durationMs?: number | undefined | null, useBezier?: boolean | undefined | null, curveIntensity?: number | undefined | null, addJitter?: boolean | undefined | null): void
/** Mouse position object */
export interface MousePosition {
/** X coordinate */
x: number
/** Y coordinate */
y: number
}
/**
* Get current mouse position
*
* # Returns
* Returns an object containing x and y coordinates
*
* # Examples
* ```javascript
* const pos = Mouse.getPosition();
* console.log(`Mouse at (${pos.x}, ${pos.y})`);
* ```
*/
export function getPosition(): MousePosition
}
export declare namespace Keyboard {
/**
* Simulate typing text (simulates human typing)
*
* # Parameters
* * `text` - Text to type (supports emoji and all Unicode characters)
* * `speed` - Typing speed: "slow", "normal", "fast" (default: "normal")
* * `base_delay` - Optional base delay in milliseconds
* * `add_pauses` - Whether to add random pauses (default: true)
*
* # Examples
* ```javascript
* import { Keyboard } from 'node-system-bridge';
*
* // Basic usage
* Keyboard.typeText('Hello World! 👋');
*
* // Slow typing
* Keyboard.typeText('Typing slowly...', 'slow');
*
* // Custom delay
* Keyboard.typeText('Custom delay', 'normal', 100);
* ```
*/
export function typeText(text: string, speed?: string | undefined | null, baseDelay?: number | undefined | null, addPauses?: boolean | undefined | null): void
/**
* Press a special key
*
* # Parameters
* * `key` - Key name: supports "enter", "tab", "backspace", "delete", "escape", "space",
* "up", "down", "left", "right", "home", "end", "pageup", "pagedown"
*
* # Examples
* ```javascript
* Keyboard.pressKey('enter');
* Keyboard.pressKey('tab');
* ```
*/
export function pressKey(key: string): void
/**
* Read from clipboard and type
*
* # Parameters
* * `speed` - Typing speed: "slow", "normal", "fast" (default: "normal")
*
* # Examples
* ```javascript
* // Read from clipboard and type at normal speed
* Keyboard.typeFromClipboard();
*
* // Slow typing
* Keyboard.typeFromClipboard('slow');
* ```
*/
export function typeFromClipboard(speed?: string | undefined | null): void
}
export declare namespace Clipboard {
/**
* Read clipboard text
*
* # Returns
* Returns text content from clipboard
*
* # Examples
* ```javascript
* const text = Clipboard.readText();
* console.log('Clipboard content:', text);
* ```
*/
export function readText(): string
/**
* Write text to clipboard
*
* # Parameters
* * `text` - Text to write
*
* # Examples
* ```javascript
* Clipboard.writeText('Hello, World!');
* ```
*/
export function writeText(text: string): void
/**
* Clear clipboard
*
* # Examples
* ```javascript
* Clipboard.clear();
* ```
*/
export function clear(): void
}
export declare namespace Window {
/**
* Bring window to front
*
* # Parameters
* * `pid` - Process ID
*
* # Description
* Activates and brings the specified process's window to front. Not pinned on top, subsequent windows can cover it.
*
* # Examples
* ```javascript
* import { Window, Process } from 'node-system-bridge';
*
* const pid = await Process.launchApp('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome');
* await Window.bringToFront(pid);
* ```
*/
export function bringToFront(pid: number): void
}
export declare namespace System {
/** System information object */
export interface SystemInfo {
/** Hostname */
hostname: string
/** Platform (win32, darwin, linux) */
platform: string
/** Architecture (x64, arm64) */
arch: string
/** System version */
release: string
/** Manufacturer */
manufacturer: string
/** Model */
model: string
/** System version description */
sysVersion: string
/** Serial number */
serial: string
/** CPU manufacturer */
cpuManufacturer: string
/** CPU brand */
cpuBrand: string
/** CPU vendor */
cpuVendor: string
/** Distribution name */
distro: string
/** Operating system UUID */
osUuid: string
/** Hardware UUID */
hardwareUuid: string
/** MAC addresses list */
macs: Array<string>
/** Primary network interface */
primaryInterface: string
/** Whether virtual machine */
isVirtual: boolean
/** Data source (wmi, wmic, basic) */
source: string
}
/**
* Get system information
*
* # Returns
* Returns detailed system information
*
* # Description
* Automatically uses the best method to get system information with multi-layer fallback:
* - Windows: WMI API -> wmic command -> basic info
* - macOS: sysctl/IOKit -> basic info
* - Linux: procfs/sysfs -> basic info
*
* # Examples
* ```javascript
* import { System } from 'node-system-bridge';
*
* const info = await System.getSystemInfo();
* console.log({
* hostname: info.hostname,
* platform: info.platform,
* manufacturer: info.manufacturer,
* model: info.model,
* cpuBrand: info.cpuBrand,
* macs: info.macs
* });
* ```
*/
export function getSystemInfo(): Promise<SystemInfo>
}
export declare namespace FileOps {
/**
* Copy file or directory
*
* # Parameters
* * `source` - Source path (file or directory)
* * `dest` - Destination path
*
* # Description
* Automatically detects whether source path is file or directory and performs corresponding copy operation.
* If it's a directory, recursively copies all contents.
*
* # Examples
* ```javascript
* import { FileOps } from 'node-system-bridge';
*
* // Copy file
* FileOps.copyPath('/path/to/source.txt', '/path/to/dest.txt');
*
* // Copy directory
* FileOps.copyPath('/path/to/sourceDir', '/path/to/destDir');
* ```
*/
export function copyPath(source: string, dest: string): void
/**
* Move file or directory
*
* # Parameters
* * `source` - Source path (file or directory)
* * `dest` - Destination path
*
* # Description
* Automatically detects whether source path is file or directory and performs corresponding move operation.
* Move operation will copy first, then delete source file/directory.
*
* # Examples
* ```javascript
* import { FileOps } from 'node-system-bridge';
*
* // Move file
* FileOps.movePath('/path/to/source.txt', '/path/to/dest.txt');
*
* // Move directory
* FileOps.movePath('/path/to/sourceDir', '/path/to/destDir');
* ```
*/
export function movePath(source: string, dest: string): void
/**
* Delete file or directory
*
* # Parameters
* * `path` - Path to delete (file or directory)
*
* # Description
* Automatically detects whether path is file or directory and performs corresponding delete operation.
* If it's a directory, recursively deletes all contents.
*
* # Examples
* ```javascript
* import { FileOps } from 'node-system-bridge';
*
* // Delete file
* FileOps.deletePath('/path/to/file.txt');
*
* // Delete directory
* FileOps.deletePath('/path/to/dir');
* ```
*/
export function deletePath(path: string): void
}