Files
deepseek-harness/apps/desktop/src/preload-app.ts
T
Yif e9def243e2 Merge origin/master into feat/macos-sidebar-ui-and-drag-refine
Keeps both window-chrome features: this branch's macOS shell.leading seat,
single drag owner, and fullscreen sync alongside upstream's Windows desktop
titlebar (#4407). ipc.ts and preload-app.ts merge both platforms' channels
and preload wiring; Tooltip merges upstream's suppression context with this
branch's pointer-focus suppression; slot-catalog regenerated.
2026-09-18 11:27:06 +08:00

38 lines
1.8 KiB
TypeScript

/** Origin-scoped boot, native directory selection, and update presentation with native confirmation actions. */
import { contextBridge, ipcRenderer } from 'electron'
import { DESKTOP_IPC, SCHEME, type DshDesktopProductApi, type DesktopUpdatePresentation } from './ipc.ts'
import { markDocumentPlatform, syncWindowFullscreen } from './preload-platform.ts'
import { syncNativeTheme } from './preload-theme.ts'
import { syncWindowsAppearance } from './preload-windows.ts'
const product: DshDesktopProductApi = {
protocolVersion: 1,
updates: {
status: () => ipcRenderer.invoke(DESKTOP_IPC.updatesStatus) as Promise<DesktopUpdatePresentation>,
open: () => ipcRenderer.invoke(DESKTOP_IPC.updatesOpen) as Promise<void>,
subscribe(listener) {
const handle = (_event: Electron.IpcRendererEvent, state: DesktopUpdatePresentation): void => { listener(state) }
ipcRenderer.on(DESKTOP_IPC.updatesPresentation, handle)
return () => { ipcRenderer.off(DESKTOP_IPC.updatesPresentation, handle) }
},
},
}
if (location.protocol === `${SCHEME}:` && location.hostname === 'app') {
syncWindowsAppearance()
contextBridge.exposeInMainWorld('__DSH_DIRECTORY_PICKER__', {
pick: () => ipcRenderer.invoke(DESKTOP_IPC.directoryPick) as Promise<string | null>,
})
contextBridge.exposeInMainWorld('dshDesktopBoot', {
ready: () => ipcRenderer.invoke(DESKTOP_IPC.boot) as Promise<unknown>,
failed: (message: string) => ipcRenderer.invoke(DESKTOP_IPC.bootFailed, message) as Promise<void>,
})
}
markDocumentPlatform()
syncWindowFullscreen()
syncNativeTheme()
// Main-process IPC also verifies the owning window and top frame.
contextBridge.exposeInMainWorld('dshDesktop', location.protocol === `${SCHEME}:` && location.hostname === 'app' ? product : { protocolVersion: 1 })