diff --git a/apps/web/src/contextMenuFallback.ts b/apps/web/src/contextMenuFallback.ts index 3fe6c572e4ea0bdf64c52ac6d530eb7772b5c844..63cdef8481c4420d4a9ae471a372d3f33f79f28b 100644 --- a/apps/web/src/contextMenuFallback.ts +++ b/apps/web/src/contextMenuFallback.ts @@ -1,10 +1,12 @@ +import type { ContextMenuItem } from "@t3tools/contracts"; + /** * Imperative DOM-based context menu for non-Electron environments. * Shows a positioned dropdown and returns a promise that resolves * with the clicked item id, or null if dismissed. */ export function showContextMenuFallback( - items: readonly { id: T; label: string; destructive?: boolean }[], + items: readonly ContextMenuItem[], position?: { x: number; y: number }, ): Promise { return new Promise((resolve) => { diff --git a/apps/web/src/wsNativeApi.test.ts b/apps/web/src/wsNativeApi.test.ts index 80e283ee40fbe6630285ea7238876eb0963426fa..1dd19c4c6fa000a8bebaa43a74562f99e641248d 100644 --- a/apps/web/src/wsNativeApi.test.ts +++ b/apps/web/src/wsNativeApi.test.ts @@ -1,5 +1,6 @@ import { CommandId, + type ContextMenuItem, ORCHESTRATION_WS_CHANNELS, ORCHESTRATION_WS_METHODS, ProjectId, @@ -11,7 +12,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; const requestMock = vi.fn<(...args: Array) => Promise>(); const showContextMenuFallbackMock = vi.fn< ( - items: readonly { id: T; label: string; destructive?: boolean }[], + items: readonly ContextMenuItem[], position?: { x: number; y: number }, ) => Promise >(); diff --git a/apps/web/src/wsNativeApi.ts b/apps/web/src/wsNativeApi.ts index 871e01c911126daee8a492a33ec57fff44c42d82..f3bdfe5d0718d88f823dff0c2b1d61a5f67d900f 100644 --- a/apps/web/src/wsNativeApi.ts +++ b/apps/web/src/wsNativeApi.ts @@ -2,6 +2,7 @@ import { OrchestrationEvent, ORCHESTRATION_WS_CHANNELS, ORCHESTRATION_WS_METHODS, + type ContextMenuItem, type NativeApi, ServerConfigUpdatedPayload, TerminalEvent, @@ -171,7 +172,7 @@ export function createWsNativeApi(): NativeApi { }, contextMenu: { show: async ( - items: readonly { id: T; label: string; destructive?: boolean }[], + items: readonly ContextMenuItem[], position?: { x: number; y: number }, ): Promise => { if (window.desktopBridge) { diff --git a/packages/contracts/src/ipc.ts b/packages/contracts/src/ipc.ts index a182d2325eb0c0001c851389cd4b537f9b41fa9e..aeec16ca0c32c9bee0d9b1f3c481e0917ac7587f 100644 --- a/packages/contracts/src/ipc.ts +++ b/packages/contracts/src/ipc.ts @@ -37,7 +37,7 @@ import type { } from "./orchestration"; import { EditorId } from "./editor"; -interface ContextMenuItem { +export interface ContextMenuItem { id: T; label: string; destructive?: boolean;