// Copyright 2024, Command Line Inc. // SPDX-License-Identifier: Apache-2.0 import { type Placement } from "@floating-ui/react"; import type * as jotai from "jotai"; import type * as rxjs from "rxjs"; declare global { type GlobalAtomsType = { clientId: jotai.Atom; // readonly client: jotai.Atom; // driven from WOS uiContext: jotai.Atom; // driven from windowId, tabId waveWindow: jotai.Atom; // driven from WOS workspace: jotai.Atom; // driven from WOS fullConfigAtom: jotai.PrimitiveAtom; // driven from WOS, settings -- updated via WebSocket settingsAtom: jotai.Atom; // derrived from fullConfig tabAtom: jotai.Atom; // driven from WOS staticTabId: jotai.Atom; isFullScreen: jotai.PrimitiveAtom; controlShiftDelayAtom: jotai.PrimitiveAtom; prefersReducedMotionAtom: jotai.Atom; updaterStatusAtom: jotai.PrimitiveAtom; typeAheadModalAtom: jotai.PrimitiveAtom; modalOpen: jotai.PrimitiveAtom; allConnStatus: jotai.Atom; flashErrors: jotai.PrimitiveAtom; notifications: jotai.PrimitiveAtom; notificationPopoverMode: jotia.atom; reinitVersion: jotai.PrimitiveAtom; }; type WritableWaveObjectAtom = jotai.WritableAtom; type ThrottledValueAtom = jotai.WritableAtom], void>; type AtomWithThrottle = { currentValueAtom: jotai.Atom; throttledValueAtom: ThrottledValueAtom; }; type DebouncedValueAtom = jotai.WritableAtom], void>; type AtomWithDebounce = { currentValueAtom: jotai.Atom; debouncedValueAtom: DebouncedValueAtom; }; type SplitAtom = Atom[]>; type WritableSplitAtom = WritableAtom[], [SplitAtomAction], void>; type TabLayoutData = { blockId: string; }; type WaveInitOpts = { tabId: string; clientId: string; windowId: string; activate: boolean; }; type ElectronApi = { getAuthKey(): string; getIsDev(): boolean; getCursorPoint: () => Electron.Point; getPlatform: () => NodeJS.Platform; getEnv: (varName: string) => string; getUserName: () => string; getHostName: () => string; getDataDir: () => string; getConfigDir: () => string; getWebviewPreload: () => string; getAboutModalDetails: () => AboutModalDetails; getDocsiteUrl: () => string; showContextMenu: (workspaceId: string, menu?: ElectronContextMenuItem[]) => void; onContextMenuClick: (callback: (id: string) => void) => void; onNavigate: (callback: (url: string) => void) => void; onIframeNavigate: (callback: (url: string) => void) => void; downloadFile: (path: string) => void; openExternal: (url: string) => void; onFullScreenChange: (callback: (isFullScreen: boolean) => void) => void; onUpdaterStatusChange: (callback: (status: UpdaterStatus) => void) => void; getUpdaterStatus: () => UpdaterStatus; getUpdaterChannel: () => string; installAppUpdate: () => void; onMenuItemAbout: (callback: () => void) => void; updateWindowControlsOverlay: (rect: Dimensions) => void; onReinjectKey: (callback: (waveEvent: WaveKeyboardEvent) => void) => void; setWebviewFocus: (focusedId: number) => void; // focusedId si the getWebContentsId of the webview registerGlobalWebviewKeys: (keys: string[]) => void; onControlShiftStateUpdate: (callback: (state: boolean) => void) => void; createWorkspace: () => void; switchWorkspace: (workspaceId: string) => void; deleteWorkspace: (workspaceId: string) => void; setActiveTab: (tabId: string) => void; createTab: () => void; closeTab: (workspaceId: string, tabId: string) => void; setWindowInitStatus: (status: "ready" | "wave-ready") => void; onWaveInit: (callback: (initOpts: WaveInitOpts) => void) => void; sendLog: (log: string) => void; onQuicklook: (filePath: string) => void; openNativePath(filePath: string): void; }; type ElectronContextMenuItem = { id: string; // unique id, used for communication label: string; role?: string; // electron role (optional) type?: "separator" | "normal" | "submenu" | "checkbox" | "radio"; submenu?: ElectronContextMenuItem[]; checked?: boolean; visible?: boolean; enabled?: boolean; sublabel?: string; }; type ContextMenuItem = { label?: string; type?: "separator" | "normal" | "submenu" | "checkbox" | "radio"; role?: string; // electron role (optional) click?: () => void; // not required if role is set submenu?: ContextMenuItem[]; checked?: boolean; visible?: boolean; enabled?: boolean; sublabel?: string; }; type KeyPressDecl = { mods: { Cmd?: boolean; Option?: boolean; Shift?: boolean; Ctrl?: boolean; Alt?: boolean; Meta?: boolean; }; key: string; keyType: string; }; type SubjectWithRef = rxjs.Subject & { refCount: number; release: () => void }; type HeaderElem = | IconButtonDecl | HeaderText | HeaderInput | HeaderDiv | HeaderTextButton | ConnectionButton | MenuButton; type IconButtonDecl = { elemtype: "iconbutton"; icon: string | React.ReactNode; iconColor?: string; iconSpin?: boolean; className?: string; title?: string; click?: (e: React.MouseEvent) => void; longClick?: (e: React.MouseEvent) => void; disabled?: boolean; noAction?: boolean; }; type HeaderTextButton = { elemtype: "textbutton"; text: string; className?: string; onClick?: (e: React.MouseEvent) => void; }; type HeaderText = { elemtype: "text"; text: string; ref?: React.MutableRefObject; className?: string; noGrow?: boolean; onClick?: (e: React.MouseEvent) => void; }; type HeaderInput = { elemtype: "input"; value: string; className?: string; isDisabled?: boolean; ref?: React.MutableRefObject; onChange?: (e: React.ChangeEvent) => void; onKeyDown?: (e: React.KeyboardEvent) => void; onFocus?: (e: React.FocusEvent) => void; onBlur?: (e: React.FocusEvent) => void; }; type HeaderDiv = { elemtype: "div"; className?: string; children: HeaderElem[]; onMouseOver?: (e: React.MouseEvent) => void; onMouseOut?: (e: React.MouseEvent) => void; onClick?: (e: React.MouseEvent) => void; }; type ConnectionButton = { elemtype: "connectionbutton"; icon: string; text: string; iconColor: string; onClick?: (e: React.MouseEvent) => void; connected: boolean; }; type MenuItem = { label: string; icon?: string | React.ReactNode; subItems?: MenuItem[]; onClick?: (e: React.MouseEvent) => void; }; type MenuButtonProps = { items: MenuItem[]; className?: string; text: string; title?: string; menuPlacement?: Placement; }; type MenuButton = { elemtype: "menubutton"; } & MenuButtonProps; interface ViewModel { viewType: string; viewIcon?: jotai.Atom; viewName?: jotai.Atom; viewText?: jotai.Atom; preIconButton?: jotai.Atom; endIconButtons?: jotai.Atom; blockBg?: jotai.Atom; manageConnection?: jotai.Atom; noPadding?: jotai.Atom; filterOutNowsh?: jotai.Atom; onBack?: () => void; onForward?: () => void; onSearchChange?: (text: string) => void; onSearch?: (text: string) => void; getSettingsMenuItems?: () => ContextMenuItem[]; giveFocus?: () => boolean; keyDownHandler?: (e: WaveKeyboardEvent) => boolean; dispose?: () => void; } type UpdaterStatus = "up-to-date" | "checking" | "downloading" | "ready" | "error" | "installing"; // jotai doesn't export this type :/ type Loadable = { state: "loading" } | { state: "hasData"; data: T } | { state: "hasError"; error: unknown }; interface Dimensions { width: number; height: number; left: number; top: number; } type TypeAheadModalType = { [key: string]: boolean }; interface AboutModalDetails { version: string; buildTime: number; } type BlockComponentModel = { openSwitchConnection?: () => void; viewModel: ViewModel; }; type ConnStatusType = "connected" | "connecting" | "disconnected" | "error" | "init"; interface SuggestionBaseItem { label: string; value: string; icon?: string | React.ReactNode; } interface SuggestionConnectionItem extends SuggestionBaseItem { status: ConnStatusType; iconColor: string; onSelect?: (_: string) => void; current?: boolean; } interface SuggestionConnectionScope { headerText?: string; items: SuggestionConnectionItem[]; } type SuggestionsType = SuggestionConnectionItem | SuggestionConnectionScope; type MarkdownResolveOpts = { connName: string; baseDir: string; }; type FlashErrorType = { id: string; icon: string; title: string; message: string; expiration: number; }; export type NotificationActionType = { label: string; actionKey: string; rightIcon?: string; color?: "green" | "grey"; disabled?: boolean; }; export type NotificationType = { id?: string; icon: string; title: string; message: string; timestamp: string; expiration?: number; hidden?: boolean; actions?: NotificationActionType[]; persistent?: boolean; type?: "error" | "update" | "info" | "warning"; }; interface AbstractWshClient { recvRpcMessage(msg: RpcMessage): void; } type ClientRpcEntry = { reqId: string; startTs: number; command: string; msgFn: (msg: RpcMessage) => void; }; type TimeSeriesMeta = { name?: string; color?: string; label?: string; maxy?: string | number; miny?: string | number; decimalPlaces?: number; }; } export {};