|
| 1 | +import type { Ref } from 'vue' |
| 2 | +import { configureNative as configureSharedNative, type NativePlatform as SharedNative } from '@sbox/ui/native' |
| 3 | +import type { Capture } from './screenshot-types' |
| 4 | +export type Unlisten = () => void |
| 5 | +export interface FileDialogOptions { |
| 6 | + title?: string |
| 7 | + defaultPath?: string |
| 8 | + directory?: boolean |
| 9 | + multiple?: boolean |
| 10 | + filters?: { name: string; extensions: string[] }[] |
| 11 | +} |
| 12 | +export interface NativeUpdater { |
| 13 | + updateStatus: Ref<string> |
| 14 | + updateStatusText: Readonly<Ref<string>> |
| 15 | + checkForUpdate(options?: { silent?: boolean }): Promise<unknown> |
| 16 | +} |
| 17 | +export interface DesktopNative extends SharedNative { |
| 18 | + readonly kind: 'rust' | 'web' |
| 19 | + readonly windowLabel: string |
| 20 | + readonly updater: NativeUpdater |
| 21 | + readonly screenshot: Pick<typeof import('../tools/media/screenshot/screenshot'), |
| 22 | + 'getLatestCapture' | 'getLatestCapturePixels' | 'cropSelectionPixels' | 'saveSelection' | |
| 23 | + 'clearCapture' | 'ensureOverlay' | 'startScreenshot' | 'finishScreenshot'> |
| 24 | + getAppVersion(): Promise<string> |
| 25 | + openExternalUrl(url: string): Promise<void> |
| 26 | + pickPaths(options?: FileDialogOptions): Promise<string | string[] | null> |
| 27 | + selectSavePath(options?: FileDialogOptions): Promise<string | null> |
| 28 | + readClipboardText(): Promise<string> |
| 29 | + writeClipboardImage(bytes: Uint8Array, width: number, height: number): Promise<void> |
| 30 | + listen<T>(event: string, handler: (payload: T) => void): Promise<Unlisten> |
| 31 | + onPathDrop(handler: (paths: string[]) => void): Promise<Unlisten> |
| 32 | + setOverlayBounds(capture: Capture): Promise<void> |
| 33 | + showOverlay(): Promise<void> |
| 34 | + getAutostart(): Promise<boolean> |
| 35 | + setAutostart(enabled: boolean): Promise<void> |
| 36 | + toggleWindow(): Promise<void> |
| 37 | + onCloseRequested(shouldHide: () => boolean): Promise<Unlisten> |
| 38 | + registerShortcut(key: string, onPressed: () => void): Promise<void> |
| 39 | + isShortcutRegistered(key: string): Promise<boolean> |
| 40 | + clearShortcuts(): Promise<void> |
| 41 | +} |
| 42 | + |
| 43 | +export let native: DesktopNative |
| 44 | +/** Configure before importing/mounting the shared app. */ |
| 45 | +export function configureDesktopNative(platform: DesktopNative): void { |
| 46 | + native = platform |
| 47 | + configureSharedNative(platform) |
| 48 | +} |
0 commit comments