Files
zeekayandHanzo Dev 751ef5c778 rename the framework to @hanzo/gui and the loader to @hanzogui/loader
Both old names are owned by a different npm account (artemis-prime), so
publishing them returns 403 — which is how this surfaced: the 8.0.0 run
shipped @hanzogui/logo and @hanzogui/demos depending on [email protected], a
version that cannot be published and therefore does not exist. Those two
were uninstallable.

@hanzo/gui and @hanzogui/* are ours, so the framework now carries the name
it is imported by everywhere downstream, and the loader moves under the
scope we control.

The rewrite is limited to package references. `DEBUG?.startsWith('hanzogui')`
is a log-namespace filter and join(dir, 'hanzogui') is a path — rewriting
either would change behaviour, so both are untouched.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-30 20:23:18 -07:00

56 lines
1.3 KiB
TypeScript

import { useRef } from 'react'
import type { GestureResponderEvent } from 'react-native'
import { useEvent } from '@hanzo/gui'
export const useDoublePress = ({
onSinglePress,
onDoublePress,
eagerSingle,
delay = 350,
}: {
onSinglePress?: (e: GestureResponderEvent) => void
onDoublePress?: (e: GestureResponderEvent) => void
delay?: number
eagerSingle?: boolean
}) => {
const state = useRef({
last: 0,
tm: 0 as any,
pendingSinglePress: null as any,
})
return {
onPress: useEvent((e: GestureResponderEvent) => {
clearTimeout(state.current.tm)
const time = Date.now()
const delta = time - state.current.last
if (delta < delay) {
onDoublePress?.(e)
} else {
if (eagerSingle) {
onSinglePress?.(e)
} else {
state.current.pendingSinglePress = () => {
onSinglePress?.(e)
state.current.pendingSinglePress = null
}
state.current.tm = setTimeout(state.current.pendingSinglePress, delay)
}
}
state.current.last = time
}),
onMouseLeave: useEvent(() => {
if (state.current.pendingSinglePress) {
// flush single press on mouse leave
clearTimeout(state.current.tm)
state.current.pendingSinglePress?.()
state.current.pendingSinglePress = null
}
}),
}
}