@deskforge/runtime
Runtime utilities and helpers for DeskForge Tauri applications.
Installation
npm install @deskforge/runtime
Features
- Window Management - Control window size, fullscreen, minimize, maximize
- App Utilities - Get app version, name, exit, and relaunch
- IPC Communication - Type-safe communication with Tauri backend
- Event System - Listen and emit events between frontend and backend
Quick Start
import {
initWindow,
minimizeWindow,
closeWindow,
sendCommand,
onEvent
} from '@deskforge/runtime';
await initWindow({
title: 'My App',
width: 1200,
height: 800,
resizable: true,
});
await minimizeWindow();
await closeWindow();
const result = await sendCommand('my_command', { data: 'value' });
const unlisten = await onEvent('my_event', (payload) => {
console.log('Event received:', payload);
});
API Reference
Window Management
initWindow(config) - Initialize window with configuration
minimizeWindow() - Minimize the window
maximizeWindow() - Maximize the window
closeWindow() - Close the window
toggleFullscreen() - Toggle fullscreen mode
showWindow() - Show the window
hideWindow() - Hide the window
App Utilities
initApp(config) - Initialize app with configuration
getAppVersion() - Get app version
getAppName() - Get app name
exitApp(code) - Exit the application
relaunchApp() - Relaunch the application
IPC Communication
sendCommand<T>(command, payload) - Send command to backend
onEvent(event, callback) - Listen for events
emitEvent(event, payload) - Emit event to backend
createIPCHandler<T>(command) - Create typed IPC handler
Types
interface WindowConfig {
title?: string;
width?: number;
height?: number;
minWidth?: number;
minHeight?: number;
resizable?: boolean;
fullscreen?: boolean;
}
interface AppConfig {
name: string;
version: string;
author?: string;
}
interface IPCMessage {
command: string;
payload?: any;
}
interface IPCResponse {
success: boolean;
data?: any;
error?: string;
}
License
MIT