mirror of
https://github.com/stablyai/orca.git
synced 2026-11-04 11:07:42 +00:00
refactor(browser): move the grab hook type to its owner (#36087)
Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
This commit is contained in:
+3
-31
@@ -1,13 +1,4 @@
|
||||
import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useState,
|
||||
type Dispatch,
|
||||
type MutableRefObject,
|
||||
type SetStateAction
|
||||
} from 'react'
|
||||
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { useMountedRef } from '@/hooks/useMountedRef'
|
||||
import { useAppStore } from '@/store'
|
||||
@@ -26,6 +17,7 @@ import {
|
||||
import { useBrowserPageAnnotationViewportTracking } from './use-browser-page-annotation-viewport-tracking'
|
||||
import { runBrowserGrabActionShortcut } from './browser-page-grab-action'
|
||||
import type {
|
||||
BrowserPageGrabAnnotations,
|
||||
BrowserPageGrabAnnotationsOptions,
|
||||
BrowserPageGrabToastState,
|
||||
GrabIntent
|
||||
@@ -58,27 +50,7 @@ export function useBrowserPageGrabAnnotations({
|
||||
webviewRef,
|
||||
setBrowserOverlayViewport,
|
||||
browserAnnotationsLength
|
||||
}: BrowserPageGrabAnnotationsOptions): {
|
||||
grabIntent: GrabIntent
|
||||
startGrabIntent: (nextIntent: GrabIntent) => void
|
||||
pendingAnnotationPayload: BrowserGrabPayload | null
|
||||
setPendingAnnotationPayload: Dispatch<SetStateAction<BrowserGrabPayload | null>>
|
||||
grabToast: BrowserPageGrabToastState | null
|
||||
setGrabToast: Dispatch<SetStateAction<BrowserPageGrabToastState | null>>
|
||||
grabToastTimerRef: MutableRefObject<ReturnType<typeof setTimeout> | undefined>
|
||||
dismissGrabToast: () => void
|
||||
handleGrabCopy: () => void
|
||||
handleGrabCopyScreenshot: () => void
|
||||
grabMenuActionTakenRef: MutableRefObject<boolean>
|
||||
handleAddBrowserAnnotation: (
|
||||
comment: string,
|
||||
intent: BrowserAnnotationIntent,
|
||||
imagePaths?: string[]
|
||||
) => void
|
||||
handleCancelPendingBrowserAnnotation: () => void
|
||||
cancelPendingBrowserCapture: () => void
|
||||
handleGrabActionShortcut: (key: 'c' | 's') => void
|
||||
} {
|
||||
}: BrowserPageGrabAnnotationsOptions): BrowserPageGrabAnnotations {
|
||||
const mountedRef = useMountedRef()
|
||||
const toolTargetIdRef = useRef(toolTargetId)
|
||||
const grabToastTimerRef = useRef<ReturnType<typeof setTimeout>>(undefined)
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import type { RuntimeBrowserClientPlacement } from '../../../../../shared/runtime-browser-placement'
|
||||
import type { Dispatch, MutableRefObject, SetStateAction } from 'react'
|
||||
import type { BrowserGrabPayload } from '../../../../../shared/browser-grab-types'
|
||||
import type {
|
||||
BrowserAnnotationIntent,
|
||||
BrowserGrabPayload,
|
||||
GrabIntent
|
||||
} from '../../../../../shared/browser-grab-types'
|
||||
import type { BrowserContextMenuRequestedEvent } from '../../../../../shared/browser-guest-events'
|
||||
import type { BrowserPage as BrowserPageState } from '../../../../../shared/browser-workspace-types'
|
||||
import type { GrabModeHook } from '../annotate/useGrabMode'
|
||||
@@ -57,6 +61,28 @@ export type BrowserPageGrabAnnotationsOptions = {
|
||||
browserAnnotationsLength: number
|
||||
}
|
||||
|
||||
export type BrowserPageGrabAnnotations = {
|
||||
grabIntent: GrabIntent
|
||||
startGrabIntent: (nextIntent: GrabIntent) => void
|
||||
pendingAnnotationPayload: BrowserGrabPayload | null
|
||||
setPendingAnnotationPayload: Dispatch<SetStateAction<BrowserGrabPayload | null>>
|
||||
grabToast: BrowserPageGrabToastState | null
|
||||
setGrabToast: Dispatch<SetStateAction<BrowserPageGrabToastState | null>>
|
||||
grabToastTimerRef: MutableRefObject<ReturnType<typeof setTimeout> | undefined>
|
||||
dismissGrabToast: () => void
|
||||
handleGrabCopy: () => void
|
||||
handleGrabCopyScreenshot: () => void
|
||||
grabMenuActionTakenRef: MutableRefObject<boolean>
|
||||
handleAddBrowserAnnotation: (
|
||||
comment: string,
|
||||
intent: BrowserAnnotationIntent,
|
||||
imagePaths?: string[]
|
||||
) => void
|
||||
handleCancelPendingBrowserAnnotation: () => void
|
||||
cancelPendingBrowserCapture: () => void
|
||||
handleGrabActionShortcut: (key: 'c' | 's') => void
|
||||
}
|
||||
|
||||
export type BrowserPageRecoveryNavigationValidation = {
|
||||
committed: boolean
|
||||
started: boolean
|
||||
|
||||
Reference in New Issue
Block a user