* feat(editor): add github releases auto update flow Enable desktop auto-update checks and install prompt so packaged apps can update from published GitHub Releases. * fix(canvas): keep frame labels aligned during zoom Draw labels in viewport space with zoom-aware positioning so frame titles stay anchored while panning and zooming. * fix(ai): disable chat interactions when no models connected Prevent sending and shortcut actions when provider models are unavailable, and show a concise model picker hint to avoid false-available UI states. * docs: refresh readme community and demo section Embed the product demo video inline, add a styled Discord community entry, and update media assets for clearer README presentation. * chore: update nitro external dependency settings Align SSR bundling with current runtime usage by removing the unnecessary @opencode-ai external entries. * feat(electron): enhance macOS build process and update auto-updater - Added a new build script for macOS that allows building for both arm64 and x64 architectures. - Updated GitHub Actions workflow to support separate build arguments for macOS arm64 and x64. - Implemented a custom GitHub update provider for macOS to handle versioning based on architecture. - Introduced a new icon for the electron app and removed the old logo image. --------- Co-authored-by: Fini <fini.yang@gmail.com>
66 lines
1.8 KiB
TypeScript
66 lines
1.8 KiB
TypeScript
import { contextBridge, ipcRenderer, type IpcRendererEvent } from 'electron'
|
|
|
|
export type UpdaterStatus =
|
|
| 'disabled'
|
|
| 'idle'
|
|
| 'checking'
|
|
| 'available'
|
|
| 'downloading'
|
|
| 'downloaded'
|
|
| 'not-available'
|
|
| 'error'
|
|
|
|
export interface UpdaterState {
|
|
status: UpdaterStatus
|
|
currentVersion: string
|
|
latestVersion?: string
|
|
downloadProgress?: number
|
|
releaseDate?: string
|
|
error?: string
|
|
}
|
|
|
|
export interface ElectronAPI {
|
|
isElectron: true
|
|
openFile: () => Promise<{ filePath: string; content: string } | null>
|
|
saveFile: (
|
|
content: string,
|
|
defaultPath?: string,
|
|
) => Promise<string | null>
|
|
saveToPath: (filePath: string, content: string) => Promise<string>
|
|
updater: {
|
|
getState: () => Promise<UpdaterState>
|
|
checkForUpdates: () => Promise<UpdaterState>
|
|
quitAndInstall: () => Promise<boolean>
|
|
onStateChange: (callback: (state: UpdaterState) => void) => () => void
|
|
}
|
|
}
|
|
|
|
const api: ElectronAPI = {
|
|
isElectron: true,
|
|
|
|
openFile: () => ipcRenderer.invoke('dialog:openFile'),
|
|
|
|
saveFile: (content: string, defaultPath?: string) =>
|
|
ipcRenderer.invoke('dialog:saveFile', { content, defaultPath }),
|
|
|
|
saveToPath: (filePath: string, content: string) =>
|
|
ipcRenderer.invoke('dialog:saveToPath', { filePath, content }),
|
|
|
|
updater: {
|
|
getState: () => ipcRenderer.invoke('updater:getState'),
|
|
checkForUpdates: () => ipcRenderer.invoke('updater:checkForUpdates'),
|
|
quitAndInstall: () => ipcRenderer.invoke('updater:quitAndInstall'),
|
|
onStateChange: (callback: (state: UpdaterState) => void) => {
|
|
const listener = (_event: IpcRendererEvent, state: UpdaterState) => {
|
|
callback(state)
|
|
}
|
|
ipcRenderer.on('updater:state', listener)
|
|
return () => {
|
|
ipcRenderer.removeListener('updater:state', listener)
|
|
}
|
|
},
|
|
},
|
|
}
|
|
|
|
contextBridge.exposeInMainWorld('electronAPI', api)
|