mirror of
https://github.com/jhbruhn/respira.git
synced 2026-01-27 02:13:41 +00:00
Major changes: - Add Electron main process and preload scripts with Web Bluetooth support - Implement platform abstraction layer for storage and file services - Create BluetoothDevicePicker component for device selection UI - Migrate from electron-builder to Electron Forge for packaging - Configure Vite for dual browser/Electron builds - Add native file dialogs and persistent storage via electron-store - Hide menu bar for cleaner desktop app appearance The app now works in both browser (npm run dev) and Electron (npm run start). Package with 'npm run package' or create installers with 'npm run make'. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
34 lines
946 B
TypeScript
34 lines
946 B
TypeScript
import type { IFileService } from '../interfaces/IFileService';
|
|
|
|
/**
|
|
* Browser implementation of file service using HTML input elements
|
|
*/
|
|
export class BrowserFileService implements IFileService {
|
|
async openFileDialog(options: { accept: string }): Promise<File | null> {
|
|
return new Promise((resolve) => {
|
|
const input = document.createElement('input');
|
|
input.type = 'file';
|
|
input.accept = options.accept;
|
|
|
|
input.onchange = (e) => {
|
|
const file = (e.target as HTMLInputElement).files?.[0];
|
|
resolve(file || null);
|
|
};
|
|
|
|
input.oncancel = () => {
|
|
resolve(null);
|
|
};
|
|
|
|
input.click();
|
|
});
|
|
}
|
|
|
|
async saveFileDialog(_data: Uint8Array, _defaultName: string): Promise<void> {
|
|
// No-op in browser - could implement download if needed in the future
|
|
console.warn('saveFileDialog not implemented in browser');
|
|
}
|
|
|
|
hasNativeDialogs(): boolean {
|
|
return false;
|
|
}
|
|
}
|