Remove electron dependency from browser build by using platform-agnostic dialog types (#982)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
This commit is contained in:
Copilot
2025-12-23 19:21:14 +01:00
committed by GitHub
parent 2afddb8d63
commit e6ecb77d01
4 changed files with 66 additions and 4 deletions

59
events/DialogTypes.ts Normal file
View File

@@ -0,0 +1,59 @@
/**
* Browser-compatible dialog type definitions
* These types mirror Electron's dialog types but don't require the electron package
*/
export interface FileFilter {
name: string
extensions: string[]
}
export interface OpenDialogOptions {
title?: string
defaultPath?: string
buttonLabel?: string
filters?: FileFilter[]
properties?: Array<
| 'openFile'
| 'openDirectory'
| 'multiSelections'
| 'showHiddenFiles'
| 'createDirectory'
| 'promptToCreate'
| 'noResolveAliases'
| 'treatPackageAsDirectory'
| 'dontAddToRecent'
>
message?: string
securityScopedBookmarks?: boolean
}
export interface OpenDialogReturnValue {
canceled: boolean
filePaths: string[]
bookmarks?: string[]
}
export interface SaveDialogOptions {
title?: string
defaultPath?: string
buttonLabel?: string
filters?: FileFilter[]
message?: string
nameFieldLabel?: string
showsTagField?: boolean
properties?: Array<
| 'showHiddenFiles'
| 'createDirectory'
| 'treatPackageAsDirectory'
| 'showOverwriteConfirmation'
| 'dontAddToRecent'
>
securityScopedBookmarks?: boolean
}
export interface SaveDialogReturnValue {
canceled: boolean
filePath?: string
bookmark?: string
}

View File

@@ -62,8 +62,8 @@ export interface CertificateUploadResponse {
data: string // base64 encoded
}
// Electron dialog types (re-exported for convenience)
import { OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from 'electron'
// Dialog types (browser-compatible versions)
import type { OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from './DialogTypes'
export type OpenDialogOptionsV2 = OpenDialogOptions
export type OpenDialogReturnValueV2 = OpenDialogReturnValue

View File

@@ -1,4 +1,4 @@
import { OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from 'electron'
import type { OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from './DialogTypes'
import { RpcEvent } from './EventSystem/Rpc'
// Legacy functions - use RpcEvents from EventsV2.ts for new code