| author | |
| committer | |
| log | 674720c6cd233ca8c9a7b357eb954e26cae3466d |
| tree | 3370feadf8746aac1751108f45f62e92a1127231 |
| parent | 58c9e4b96d811c120c7434549656c19058751713 |
Re-export ContextMenuItem and replace the inlined
{ id: T; label: string; destructive?: boolean } definitions in
wsNativeApi, contextMenuFallback, and the test file.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>4 files changed, 8 insertions(+), 4 deletions(-)
apps/web/src/contextMenuFallback.ts+3-1| ... | ... | @@ -1,10 +1,12 @@ |
| 1 | import type { ContextMenuItem } from "@t3tools/contracts"; | |
| 2 | ||
| 1 | 3 | /** |
| 2 | 4 | * Imperative DOM-based context menu for non-Electron environments. |
| 3 | 5 | * Shows a positioned dropdown and returns a promise that resolves |
| 4 | 6 | * with the clicked item id, or null if dismissed. |
| 5 | 7 | */ |
| 6 | 8 | export function showContextMenuFallback<T extends string>( |
| 7 | items: readonly { id: T; label: string; destructive?: boolean }[], | |
| 9 | items: readonly ContextMenuItem<T>[], | |
| 8 | 10 | position?: { x: number; y: number }, |
| 9 | 11 | ): Promise<T | null> { |
| 10 | 12 | return new Promise<T | null>((resolve) => { |
apps/web/src/wsNativeApi.test.ts+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | import { |
| 2 | 2 | CommandId, |
| 3 | type ContextMenuItem, | |
| 3 | 4 | ORCHESTRATION_WS_CHANNELS, |
| 4 | 5 | ORCHESTRATION_WS_METHODS, |
| 5 | 6 | ProjectId, |
| ... | ... | @@ -11,7 +12,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
| 11 | 12 | const requestMock = vi.fn<(...args: Array<unknown>) => Promise<unknown>>(); |
| 12 | 13 | const showContextMenuFallbackMock = vi.fn< |
| 13 | 14 | <T extends string>( |
| 14 | items: readonly { id: T; label: string; destructive?: boolean }[], | |
| 15 | items: readonly ContextMenuItem<T>[], | |
| 15 | 16 | position?: { x: number; y: number }, |
| 16 | 17 | ) => Promise<T | null> |
| 17 | 18 | >(); |
apps/web/src/wsNativeApi.ts+2-1| ... | ... | @@ -2,6 +2,7 @@ import { |
| 2 | 2 | OrchestrationEvent, |
| 3 | 3 | ORCHESTRATION_WS_CHANNELS, |
| 4 | 4 | ORCHESTRATION_WS_METHODS, |
| 5 | type ContextMenuItem, | |
| 5 | 6 | type NativeApi, |
| 6 | 7 | ServerConfigUpdatedPayload, |
| 7 | 8 | TerminalEvent, |
| ... | ... | @@ -171,7 +172,7 @@ export function createWsNativeApi(): NativeApi { |
| 171 | 172 | }, |
| 172 | 173 | contextMenu: { |
| 173 | 174 | show: async <T extends string>( |
| 174 | items: readonly { id: T; label: string; destructive?: boolean }[], | |
| 175 | items: readonly ContextMenuItem<T>[], | |
| 175 | 176 | position?: { x: number; y: number }, |
| 176 | 177 | ): Promise<T | null> => { |
| 177 | 178 | if (window.desktopBridge) { |
packages/contracts/src/ipc.ts+1-1| ... | ... | @@ -37,7 +37,7 @@ import type { |
| 37 | 37 | } from "./orchestration"; |
| 38 | 38 | import { EditorId } from "./editor"; |
| 39 | 39 | |
| 40 | interface ContextMenuItem<T extends string = string> { | |
| 40 | export interface ContextMenuItem<T extends string = string> { | |
| 41 | 41 | id: T; |
| 42 | 42 | label: string; |
| 43 | 43 | destructive?: boolean; |