Line data Source code
1 : import type { ElectronAPI } from '@comfyorg/comfyui-electron-types'
2 :
3 : import { isDesktop } from '@/platform/distribution/types'
4 :
5 : /**
6 : * Extend Window interface to include electronAPI
7 : * @public
8 : */
9 : export type ElectronWindow = typeof window & {
10 : electronAPI?: ElectronAPI
11 : }
12 :
13 0 : export function electronAPI() {
14 0 : return (window as ElectronWindow).electronAPI as ElectronAPI
15 : }
16 :
17 0 : export function showNativeSystemMenu() {
18 0 : electronAPI().showContextMenu()
19 : }
20 :
21 0 : export function isNativeWindow() {
22 0 : return isDesktop && !!window.navigator.windowControlsOverlay?.visible
23 : }
24 :
25 2381 : export function isLocalDesktopHost() {
26 2381 : const bridge = window.__comfyDesktop2
27 : const isRemote = bridge?.isRemote?.() ?? window.__comfyDesktop2Remote ?? false
28 2381 : return !isRemote && (isDesktop || bridge !== undefined)
29 : }
|