// Injected by the bun process via BrowserWindow preload (src/bun/windows.ts // buildPreload) before any page script. Brand-neutral names so rebrands never // touch this file. import type { EditorOpenContext } from '@shared/rpc'; declare global { interface Window { __APP_PLATFORM?: string; /** Which root component this window boots. */ __APP_MODE?: 'main' | 'editor' | 'manager'; /** Window-kind specific context (EditorOpenContext for editor windows). */ __APP_CTX?: unknown; } } export const PLATFORM = typeof window !== 'undefined' ? (window.__APP_PLATFORM ?? '') : ''; /** True when the window uses macOS hiddenInset chrome (header fused with titlebar). */ export const IS_MAC_CHROME = PLATFORM === 'darwin'; export const IS_WINDOWS = PLATFORM === 'win32'; /** Shortcut-hint labels: "⌘W" on macOS, "Ctrl+W" elsewhere. */ export const MOD_LABEL = IS_MAC_CHROME ? '⌘' : 'Ctrl+'; export const ALT_LABEL = IS_MAC_CHROME ? '⌥' : 'Alt+'; export const APP_MODE: 'main' | 'editor' | 'manager' = typeof window !== 'undefined' ? (window.__APP_MODE ?? 'main') : 'main'; export const EDITOR_CONTEXT = typeof window !== 'undefined' ? (window.__APP_CTX as EditorOpenContext | undefined) : undefined; /** * Kill the webview's default right-click menu (Reload, Inspect Element…) * everywhere the app doesn't show its own native menu. Text fields keep the * system text menu (cut/copy/paste, spelling). */ export function blockNativeContextMenu(event: Event): void { const target = event.target as HTMLElement | null; if (target?.closest('input, textarea, [contenteditable="true"]')) return; event.preventDefault(); }