@hanzogui/native 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/dist/cjs/burntState.cjs +44 -0
  2. package/dist/cjs/burntState.native.js +47 -0
  3. package/dist/cjs/burntState.native.js.map +1 -0
  4. package/dist/cjs/components.cjs +66 -0
  5. package/dist/cjs/components.native.js +75 -0
  6. package/dist/cjs/components.native.js.map +1 -0
  7. package/dist/cjs/gestureState.cjs +65 -0
  8. package/dist/cjs/gestureState.native.js +81 -0
  9. package/dist/cjs/gestureState.native.js.map +1 -0
  10. package/dist/cjs/globalState.cjs +39 -0
  11. package/dist/cjs/globalState.native.js +42 -0
  12. package/dist/cjs/globalState.native.js.map +1 -0
  13. package/dist/cjs/index.cjs +48 -0
  14. package/dist/cjs/index.native.js +51 -0
  15. package/dist/cjs/index.native.js.map +1 -0
  16. package/dist/cjs/keyboardControllerState.cjs +47 -0
  17. package/dist/cjs/keyboardControllerState.native.js +50 -0
  18. package/dist/cjs/keyboardControllerState.native.js.map +1 -0
  19. package/dist/cjs/linearGradientState.cjs +43 -0
  20. package/dist/cjs/linearGradientState.native.js +46 -0
  21. package/dist/cjs/linearGradientState.native.js.map +1 -0
  22. package/dist/cjs/nativeMenuContext.cjs +27 -0
  23. package/dist/cjs/nativeMenuContext.native.js +30 -0
  24. package/dist/cjs/nativeMenuContext.native.js.map +1 -0
  25. package/dist/cjs/portalState.cjs +43 -0
  26. package/dist/cjs/portalState.native.js +46 -0
  27. package/dist/cjs/portalState.native.js.map +1 -0
  28. package/dist/cjs/safeAreaState.cjs +65 -0
  29. package/dist/cjs/safeAreaState.native.js +68 -0
  30. package/dist/cjs/safeAreaState.native.js.map +1 -0
  31. package/dist/cjs/setup-burnt.cjs +16 -0
  32. package/dist/cjs/setup-burnt.native.js +19 -0
  33. package/dist/cjs/setup-burnt.native.js.map +1 -0
  34. package/dist/cjs/setup-expo-linear-gradient.cjs +15 -0
  35. package/dist/cjs/setup-expo-linear-gradient.native.js +18 -0
  36. package/dist/cjs/setup-expo-linear-gradient.native.js.map +1 -0
  37. package/dist/cjs/setup-gesture-handler.cjs +27 -0
  38. package/dist/cjs/setup-gesture-handler.native.js +30 -0
  39. package/dist/cjs/setup-gesture-handler.native.js.map +1 -0
  40. package/dist/cjs/setup-keyboard-controller.cjs +0 -0
  41. package/dist/cjs/setup-keyboard-controller.native.js +33 -0
  42. package/dist/cjs/setup-keyboard-controller.native.js.map +1 -0
  43. package/dist/cjs/setup-safe-area.cjs +1 -0
  44. package/dist/cjs/setup-safe-area.native.js +25 -0
  45. package/dist/cjs/setup-safe-area.native.js.map +1 -0
  46. package/dist/cjs/setup-teleport.cjs +18 -0
  47. package/dist/cjs/setup-teleport.native.js +21 -0
  48. package/dist/cjs/setup-teleport.native.js.map +1 -0
  49. package/dist/cjs/setup-worklets.cjs +18 -0
  50. package/dist/cjs/setup-worklets.native.js +21 -0
  51. package/dist/cjs/setup-worklets.native.js.map +1 -0
  52. package/dist/cjs/setup-zeego.cjs +19 -0
  53. package/dist/cjs/setup-zeego.native.js +22 -0
  54. package/dist/cjs/setup-zeego.native.js.map +1 -0
  55. package/dist/cjs/types.cjs +16 -0
  56. package/dist/cjs/types.native.js +19 -0
  57. package/dist/cjs/types.native.js.map +1 -0
  58. package/dist/cjs/workletsState.cjs +46 -0
  59. package/dist/cjs/workletsState.native.js +49 -0
  60. package/dist/cjs/workletsState.native.js.map +1 -0
  61. package/dist/cjs/zeegoState.cjs +44 -0
  62. package/dist/cjs/zeegoState.native.js +47 -0
  63. package/dist/cjs/zeegoState.native.js.map +1 -0
  64. package/dist/esm/burntState.mjs +21 -0
  65. package/dist/esm/burntState.mjs.map +1 -0
  66. package/dist/esm/burntState.native.js +21 -0
  67. package/dist/esm/burntState.native.js.map +1 -0
  68. package/dist/esm/components.mjs +41 -0
  69. package/dist/esm/components.mjs.map +1 -0
  70. package/dist/esm/components.native.js +47 -0
  71. package/dist/esm/components.native.js.map +1 -0
  72. package/dist/esm/gestureState.mjs +42 -0
  73. package/dist/esm/gestureState.mjs.map +1 -0
  74. package/dist/esm/gestureState.native.js +55 -0
  75. package/dist/esm/gestureState.native.js.map +1 -0
  76. package/dist/esm/globalState.mjs +16 -0
  77. package/dist/esm/globalState.mjs.map +1 -0
  78. package/dist/esm/globalState.native.js +16 -0
  79. package/dist/esm/globalState.native.js.map +1 -0
  80. package/dist/esm/index.js +12 -0
  81. package/dist/esm/index.js.map +1 -0
  82. package/dist/esm/index.mjs +12 -0
  83. package/dist/esm/index.mjs.map +1 -0
  84. package/dist/esm/index.native.js +12 -0
  85. package/dist/esm/index.native.js.map +1 -0
  86. package/dist/esm/keyboardControllerState.mjs +22 -0
  87. package/dist/esm/keyboardControllerState.mjs.map +1 -0
  88. package/dist/esm/keyboardControllerState.native.js +22 -0
  89. package/dist/esm/keyboardControllerState.native.js.map +1 -0
  90. package/dist/esm/linearGradientState.mjs +20 -0
  91. package/dist/esm/linearGradientState.mjs.map +1 -0
  92. package/dist/esm/linearGradientState.native.js +20 -0
  93. package/dist/esm/linearGradientState.native.js.map +1 -0
  94. package/dist/esm/nativeMenuContext.mjs +4 -0
  95. package/dist/esm/nativeMenuContext.mjs.map +1 -0
  96. package/dist/esm/nativeMenuContext.native.js +4 -0
  97. package/dist/esm/nativeMenuContext.native.js.map +1 -0
  98. package/dist/esm/portalState.mjs +20 -0
  99. package/dist/esm/portalState.mjs.map +1 -0
  100. package/dist/esm/portalState.native.js +20 -0
  101. package/dist/esm/portalState.native.js.map +1 -0
  102. package/dist/esm/safeAreaState.mjs +42 -0
  103. package/dist/esm/safeAreaState.mjs.map +1 -0
  104. package/dist/esm/safeAreaState.native.js +42 -0
  105. package/dist/esm/safeAreaState.native.js.map +1 -0
  106. package/dist/esm/setup-burnt.mjs +17 -0
  107. package/dist/esm/setup-burnt.mjs.map +1 -0
  108. package/dist/esm/setup-burnt.native.js +17 -0
  109. package/dist/esm/setup-burnt.native.js.map +1 -0
  110. package/dist/esm/setup-expo-linear-gradient.mjs +16 -0
  111. package/dist/esm/setup-expo-linear-gradient.mjs.map +1 -0
  112. package/dist/esm/setup-expo-linear-gradient.native.js +16 -0
  113. package/dist/esm/setup-expo-linear-gradient.native.js.map +1 -0
  114. package/dist/esm/setup-gesture-handler.mjs +28 -0
  115. package/dist/esm/setup-gesture-handler.mjs.map +1 -0
  116. package/dist/esm/setup-gesture-handler.native.js +28 -0
  117. package/dist/esm/setup-gesture-handler.native.js.map +1 -0
  118. package/dist/esm/setup-keyboard-controller.mjs +2 -0
  119. package/dist/esm/setup-keyboard-controller.mjs.map +1 -0
  120. package/dist/esm/setup-keyboard-controller.native.js +31 -0
  121. package/dist/esm/setup-keyboard-controller.native.js.map +1 -0
  122. package/dist/esm/setup-safe-area.mjs +2 -0
  123. package/dist/esm/setup-safe-area.mjs.map +1 -0
  124. package/dist/esm/setup-safe-area.native.js +23 -0
  125. package/dist/esm/setup-safe-area.native.js.map +1 -0
  126. package/dist/esm/setup-teleport.mjs +19 -0
  127. package/dist/esm/setup-teleport.mjs.map +1 -0
  128. package/dist/esm/setup-teleport.native.js +19 -0
  129. package/dist/esm/setup-teleport.native.js.map +1 -0
  130. package/dist/esm/setup-worklets.mjs +19 -0
  131. package/dist/esm/setup-worklets.mjs.map +1 -0
  132. package/dist/esm/setup-worklets.native.js +19 -0
  133. package/dist/esm/setup-worklets.native.js.map +1 -0
  134. package/dist/esm/setup-zeego.mjs +20 -0
  135. package/dist/esm/setup-zeego.mjs.map +1 -0
  136. package/dist/esm/setup-zeego.native.js +20 -0
  137. package/dist/esm/setup-zeego.native.js.map +1 -0
  138. package/dist/esm/types.mjs +2 -0
  139. package/dist/esm/types.mjs.map +1 -0
  140. package/dist/esm/types.native.js +2 -0
  141. package/dist/esm/types.native.js.map +1 -0
  142. package/dist/esm/workletsState.mjs +23 -0
  143. package/dist/esm/workletsState.mjs.map +1 -0
  144. package/dist/esm/workletsState.native.js +23 -0
  145. package/dist/esm/workletsState.native.js.map +1 -0
  146. package/dist/esm/zeegoState.mjs +21 -0
  147. package/dist/esm/zeegoState.mjs.map +1 -0
  148. package/dist/esm/zeegoState.native.js +21 -0
  149. package/dist/esm/zeegoState.native.js.map +1 -0
  150. package/package.json +195 -0
  151. package/setup-burnt/index.cjs +2 -0
  152. package/setup-burnt/index.js +2 -0
  153. package/setup-burnt/index.native.cjs +2 -0
  154. package/setup-burnt/index.native.js +2 -0
  155. package/setup-burnt.cjs +1 -0
  156. package/setup-expo-linear-gradient/index.cjs +2 -0
  157. package/setup-expo-linear-gradient/index.js +2 -0
  158. package/setup-expo-linear-gradient/index.native.cjs +2 -0
  159. package/setup-expo-linear-gradient/index.native.js +2 -0
  160. package/setup-expo-linear-gradient.cjs +1 -0
  161. package/setup-gesture-handler/index.cjs +2 -0
  162. package/setup-gesture-handler/index.js +2 -0
  163. package/setup-gesture-handler/index.native.cjs +2 -0
  164. package/setup-gesture-handler/index.native.js +2 -0
  165. package/setup-gesture-handler.cjs +1 -0
  166. package/setup-keyboard-controller/index.cjs +2 -0
  167. package/setup-keyboard-controller/index.js +2 -0
  168. package/setup-keyboard-controller/index.native.cjs +2 -0
  169. package/setup-keyboard-controller/index.native.js +2 -0
  170. package/setup-keyboard-controller.cjs +1 -0
  171. package/setup-safe-area/index.cjs +2 -0
  172. package/setup-safe-area/index.js +2 -0
  173. package/setup-safe-area/index.native.cjs +2 -0
  174. package/setup-safe-area/index.native.js +2 -0
  175. package/setup-safe-area.cjs +1 -0
  176. package/setup-teleport/index.cjs +2 -0
  177. package/setup-teleport/index.js +2 -0
  178. package/setup-teleport/index.native.cjs +2 -0
  179. package/setup-teleport/index.native.js +2 -0
  180. package/setup-teleport.cjs +1 -0
  181. package/setup-worklets/index.cjs +2 -0
  182. package/setup-worklets/index.js +2 -0
  183. package/setup-worklets/index.native.cjs +2 -0
  184. package/setup-worklets/index.native.js +2 -0
  185. package/setup-worklets.cjs +1 -0
  186. package/setup-zeego/index.cjs +2 -0
  187. package/setup-zeego/index.js +2 -0
  188. package/setup-zeego/index.native.cjs +2 -0
  189. package/setup-zeego/index.native.js +2 -0
  190. package/setup-zeego.cjs +1 -0
  191. package/src/burntState.ts +28 -0
  192. package/src/components.tsx +48 -0
  193. package/src/gestureState.ts +91 -0
  194. package/src/globalState.ts +32 -0
  195. package/src/index.ts +77 -0
  196. package/src/keyboardControllerState.ts +29 -0
  197. package/src/linearGradientState.ts +27 -0
  198. package/src/nativeMenuContext.ts +4 -0
  199. package/src/portalState.ts +27 -0
  200. package/src/safeAreaState.ts +50 -0
  201. package/src/setup-burnt.ts +38 -0
  202. package/src/setup-expo-linear-gradient.ts +36 -0
  203. package/src/setup-gesture-handler.ts +51 -0
  204. package/src/setup-keyboard-controller.ts +60 -0
  205. package/src/setup-keyboard-controller.web.ts +6 -0
  206. package/src/setup-safe-area.ts +56 -0
  207. package/src/setup-teleport.ts +36 -0
  208. package/src/setup-worklets.ts +49 -0
  209. package/src/setup-zeego.ts +42 -0
  210. package/src/types.ts +88 -0
  211. package/src/workletsState.ts +30 -0
  212. package/src/zeegoState.ts +28 -0
  213. package/tsconfig.json +12 -0
  214. package/types/burntState.d.ts +9 -0
  215. package/types/components.d.ts +20 -0
  216. package/types/gestureState.d.ts +25 -0
  217. package/types/globalState.d.ts +8 -0
  218. package/types/index.d.ts +41 -0
  219. package/types/keyboardControllerState.d.ts +7 -0
  220. package/types/linearGradientState.d.ts +9 -0
  221. package/types/nativeMenuContext.d.ts +4 -0
  222. package/types/portalState.d.ts +9 -0
  223. package/types/safeAreaState.d.ts +13 -0
  224. package/types/setup-burnt.d.ts +3 -0
  225. package/types/setup-expo-linear-gradient.d.ts +3 -0
  226. package/types/setup-gesture-handler.d.ts +3 -0
  227. package/types/setup-keyboard-controller.d.ts +3 -0
  228. package/types/setup-keyboard-controller.web.d.ts +2 -0
  229. package/types/setup-safe-area.d.ts +3 -0
  230. package/types/setup-teleport.d.ts +3 -0
  231. package/types/setup-worklets.d.ts +3 -0
  232. package/types/setup-zeego.d.ts +3 -0
  233. package/types/types.d.ts +76 -0
  234. package/types/workletsState.d.ts +9 -0
  235. package/types/zeegoState.d.ts +9 -0
@@ -0,0 +1,28 @@
1
+ import { createGlobalState } from './globalState'
2
+ import type { BurntState } from './types'
3
+
4
+ const state = createGlobalState<BurntState>(`burnt`, {
5
+ enabled: false,
6
+ toast: null,
7
+ dismissAllAlerts: null,
8
+ })
9
+
10
+ export interface BurntAccessor {
11
+ readonly isEnabled: boolean
12
+ readonly state: BurntState
13
+ set(newState: BurntState): void
14
+ }
15
+
16
+ export function getBurnt(): BurntAccessor {
17
+ return {
18
+ get isEnabled(): boolean {
19
+ return state.get().enabled
20
+ },
21
+ get state(): BurntState {
22
+ return state.get()
23
+ },
24
+ set(newState: BurntState): void {
25
+ state.set(newState)
26
+ },
27
+ }
28
+ }
@@ -0,0 +1,48 @@
1
+ import type { ReactNode } from 'react'
2
+ import { getPortal } from './portalState'
3
+ import type {
4
+ NativePortalProps,
5
+ NativePortalHostProps,
6
+ NativePortalProviderProps,
7
+ } from './types'
8
+
9
+ export type { NativePortalProps, NativePortalHostProps, NativePortalProviderProps }
10
+
11
+ /**
12
+ * Renders children into a teleport Portal when available.
13
+ * Returns null when teleport is not set up (allows fallback handling by caller).
14
+ */
15
+ export function NativePortal({
16
+ hostName = 'root',
17
+ children,
18
+ }: NativePortalProps): ReactNode {
19
+ const state = getPortal().state
20
+ if (state.type !== 'teleport') return null
21
+
22
+ const { Portal } = (globalThis as any).__gui_teleport
23
+ return <Portal hostName={hostName}>{children}</Portal>
24
+ }
25
+
26
+ /**
27
+ * Renders a teleport PortalHost when available.
28
+ * Returns null when teleport is not set up.
29
+ */
30
+ export function NativePortalHost({ name }: NativePortalHostProps): ReactNode {
31
+ const state = getPortal().state
32
+ if (state.type !== 'teleport') return null
33
+
34
+ const { PortalHost } = (globalThis as any).__gui_teleport
35
+ return <PortalHost name={name} />
36
+ }
37
+
38
+ /**
39
+ * Wraps children with teleport PortalProvider when available.
40
+ * Returns children as-is when teleport is not set up.
41
+ */
42
+ export function NativePortalProvider({ children }: NativePortalProviderProps): ReactNode {
43
+ const state = getPortal().state
44
+ if (state.type !== 'teleport') return <>{children}</>
45
+
46
+ const { PortalProvider } = (globalThis as any).__gui_teleport
47
+ return <PortalProvider>{children}</PortalProvider>
48
+ }
@@ -0,0 +1,91 @@
1
+ import { createGlobalState } from './globalState'
2
+ import type { GestureState } from './types'
3
+
4
+ const state = createGlobalState<GestureState>(`gesture`, {
5
+ enabled: false,
6
+ Gesture: null,
7
+ GestureDetector: null,
8
+ ScrollView: null,
9
+ })
10
+
11
+ export interface Insets {
12
+ top?: number
13
+ left?: number
14
+ bottom?: number
15
+ right?: number
16
+ }
17
+
18
+ export type PressGestureConfig = {
19
+ onPressIn?: (e: any) => void
20
+ onPressOut?: (e: any) => void
21
+ onPress?: (e: any) => void
22
+ onLongPress?: (e: any) => void
23
+ delayLongPress?: number
24
+ hitSlop?: number | Insets | null
25
+ }
26
+
27
+ export interface GestureHandlerAccessor {
28
+ readonly isEnabled: boolean
29
+ readonly state: GestureState
30
+ set(updates: Partial<GestureState>): void
31
+ disable(): void
32
+ createPressGesture(config: PressGestureConfig): any
33
+ }
34
+
35
+ export function getGestureHandler(): GestureHandlerAccessor {
36
+ return {
37
+ get isEnabled(): boolean {
38
+ return state.get().enabled
39
+ },
40
+ get state(): GestureState {
41
+ return state.get()
42
+ },
43
+ set(updates: Partial<GestureState>): void {
44
+ Object.assign(state.get(), updates)
45
+ },
46
+
47
+ disable(): void {
48
+ state.get().enabled = false
49
+ },
50
+
51
+ createPressGesture(config: PressGestureConfig): any {
52
+ const { Gesture } = state.get()
53
+ if (!Gesture) return null
54
+
55
+ const longPressDuration = config.delayLongPress ?? 500
56
+
57
+ // Tap gesture for regular presses
58
+ // Use long maxDuration to not cancel during long presses
59
+ const tap = Gesture.Tap()
60
+ .runOnJS(true)
61
+ .maxDuration(10000) // allow very long presses
62
+ .onBegin((e: any) => {
63
+ config.onPressIn?.(e)
64
+ })
65
+ .onEnd((e: any) => {
66
+ config.onPress?.(e)
67
+ })
68
+ .onFinalize((e: any) => {
69
+ config.onPressOut?.(e)
70
+ })
71
+
72
+ if (config.hitSlop) tap.hitSlop(config.hitSlop)
73
+
74
+ // if no long press handler, just use tap
75
+ if (!config.onLongPress) return tap
76
+
77
+ // LongPress gesture for long press handling
78
+ const longPress = Gesture.LongPress()
79
+ .runOnJS(true)
80
+ .minDuration(longPressDuration)
81
+ .onBegin((e: any) => config.onPressIn?.(e))
82
+ .onStart((e: any) => config.onLongPress?.(e))
83
+ .onFinalize((e: any) => config.onPressOut?.(e))
84
+
85
+ if (config.hitSlop) longPress.hitSlop(config.hitSlop)
86
+
87
+ // exclusive: longPress has priority, tap is fallback for quick presses
88
+ return Gesture.Exclusive(longPress, tap)
89
+ },
90
+ }
91
+ }
@@ -0,0 +1,32 @@
1
+ export function createGlobalState<T extends { enabled: boolean }>(
2
+ key: string,
3
+ defaultValue: T
4
+ ): {
5
+ get: () => T
6
+ set: (next: T) => void
7
+ } {
8
+ const GLOBAL_KEY = `__gui_${key}__`
9
+
10
+ type GuiGlobal = typeof globalThis & {
11
+ [GLOBAL_KEY]?: T
12
+ }
13
+
14
+ function getGlobalState(): T {
15
+ const g = globalThis as GuiGlobal
16
+ if (!g[GLOBAL_KEY]) {
17
+ // reset on module load so reloadReactNative gets a clean state
18
+ // (globalThis persists across reloads but module scope re-evaluates)
19
+ g[GLOBAL_KEY] = defaultValue
20
+ }
21
+ return g[GLOBAL_KEY]!
22
+ }
23
+
24
+ function setGlobalState(newState: T): void {
25
+ ;(globalThis as GuiGlobal)[GLOBAL_KEY] = newState
26
+ }
27
+
28
+ return {
29
+ get: getGlobalState,
30
+ set: setGlobalState,
31
+ }
32
+ }
package/src/index.ts ADDED
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @hanzogui/native
3
+ *
4
+ * Native setup modules for Gui. Import these at the top of your app entry point.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * // In your app entry (index.js or App.tsx)
9
+ * import '@hanzogui/native/setup-teleport'
10
+ * import '@hanzogui/native/setup-gesture-handler'
11
+ * import '@hanzogui/native/setup-worklets'
12
+ * import '@hanzogui/native/setup-safe-area'
13
+ * import '@hanzogui/native/expo-linear-gradient'
14
+ * import '@hanzogui/native/setup-keyboard-controller'
15
+ *
16
+ * // Then use Hanzo GUI components normally
17
+ * // Sheet will automatically use native gestures when available
18
+ * // LinearGradient will use expo-linear-gradient when installed
19
+ * ```
20
+ */
21
+
22
+ // types
23
+ export type {
24
+ NativePortalState,
25
+ GestureState,
26
+ WorkletsState,
27
+ SafeAreaState,
28
+ SafeAreaInsets,
29
+ SafeAreaFrame,
30
+ SafeAreaMetrics,
31
+ LinearGradientState,
32
+ ZeegoState,
33
+ BurntState,
34
+ NativePortalProps,
35
+ NativePortalHostProps,
36
+ NativePortalProviderProps,
37
+ } from './types'
38
+
39
+ // portal
40
+ export { getPortal } from './portalState'
41
+ export type { PortalAccessor } from './portalState'
42
+
43
+ // gesture handler
44
+ export { getGestureHandler } from './gestureState'
45
+ export type { GestureHandlerAccessor, PressGestureConfig } from './gestureState'
46
+
47
+ // worklets
48
+ export { getWorklets } from './workletsState'
49
+ export type { WorkletsAccessor } from './workletsState'
50
+
51
+ // safe area
52
+ export { getSafeArea } from './safeAreaState'
53
+ export type { SafeAreaAccessor } from './safeAreaState'
54
+
55
+ // linear gradient
56
+ export { getLinearGradient } from './linearGradientState'
57
+ export type { LinearGradientAccessor } from './linearGradientState'
58
+
59
+ // keyboard controller state exports (safe - no side effects)
60
+ export {
61
+ isKeyboardControllerEnabled,
62
+ getKeyboardControllerState,
63
+ setKeyboardControllerState,
64
+ } from './keyboardControllerState'
65
+ export type { KeyboardControllerState } from './keyboardControllerState'
66
+
67
+ // zeego (native menus)
68
+ export { getZeego } from './zeegoState'
69
+ export type { ZeegoAccessor } from './zeegoState'
70
+ export { NativeMenuContext } from './nativeMenuContext'
71
+
72
+ // burnt (native toasts)
73
+ export { getBurnt } from './burntState'
74
+ export type { BurntAccessor } from './burntState'
75
+
76
+ // components
77
+ export { NativePortal, NativePortalHost, NativePortalProvider } from './components'
@@ -0,0 +1,29 @@
1
+ import { createGlobalState } from './globalState'
2
+ import type { KeyboardControllerState } from './types'
3
+
4
+ export type { KeyboardControllerState }
5
+
6
+ const state = createGlobalState<KeyboardControllerState>(`keyboard_controller`, {
7
+ enabled: false,
8
+ KeyboardProvider: null,
9
+ KeyboardAwareScrollView: null,
10
+ useKeyboardHandler: null,
11
+ useReanimatedKeyboardAnimation: null,
12
+ KeyboardController: null,
13
+ KeyboardEvents: null,
14
+ KeyboardStickyView: null,
15
+ })
16
+
17
+ export function isKeyboardControllerEnabled(): boolean {
18
+ return state.get().enabled
19
+ }
20
+
21
+ export function getKeyboardControllerState(): KeyboardControllerState {
22
+ return state.get()
23
+ }
24
+
25
+ export function setKeyboardControllerState(
26
+ updates: Partial<KeyboardControllerState>
27
+ ): void {
28
+ Object.assign(state.get(), updates)
29
+ }
@@ -0,0 +1,27 @@
1
+ import { createGlobalState } from './globalState'
2
+ import type { LinearGradientState } from './types'
3
+
4
+ const state = createGlobalState<LinearGradientState>(`linear_gradient`, {
5
+ enabled: false,
6
+ Component: null,
7
+ })
8
+
9
+ export interface LinearGradientAccessor {
10
+ readonly isEnabled: boolean
11
+ readonly state: LinearGradientState
12
+ set(newState: LinearGradientState): void
13
+ }
14
+
15
+ export function getLinearGradient(): LinearGradientAccessor {
16
+ return {
17
+ get isEnabled(): boolean {
18
+ return state.get().enabled
19
+ },
20
+ get state(): LinearGradientState {
21
+ return state.get()
22
+ },
23
+ set(newState: LinearGradientState): void {
24
+ state.set(newState)
25
+ },
26
+ }
27
+ }
@@ -0,0 +1,4 @@
1
+ import type React from 'react'
2
+ import { createContext } from 'react'
3
+
4
+ export const NativeMenuContext: React.Context<boolean> = createContext(false)
@@ -0,0 +1,27 @@
1
+ import { createGlobalState } from './globalState'
2
+ import type { NativePortalState } from './types'
3
+
4
+ const state = createGlobalState<NativePortalState>(`portal`, {
5
+ enabled: false,
6
+ type: null,
7
+ })
8
+
9
+ export interface PortalAccessor {
10
+ readonly isEnabled: boolean
11
+ readonly state: NativePortalState
12
+ set(newState: NativePortalState): void
13
+ }
14
+
15
+ export function getPortal(): PortalAccessor {
16
+ return {
17
+ get isEnabled(): boolean {
18
+ return state.get().enabled
19
+ },
20
+ get state(): NativePortalState {
21
+ return state.get()
22
+ },
23
+ set(newState: NativePortalState): void {
24
+ state.set(newState)
25
+ },
26
+ }
27
+ }
@@ -0,0 +1,50 @@
1
+ import { createGlobalState } from './globalState'
2
+ import type { SafeAreaState, SafeAreaInsets, SafeAreaFrame } from './types'
3
+
4
+ const state = createGlobalState<SafeAreaState>(`safe_area`, {
5
+ enabled: false,
6
+ useSafeAreaInsets: null,
7
+ useSafeAreaFrame: null,
8
+ initialMetrics: null,
9
+ })
10
+
11
+ const defaultInsets: SafeAreaInsets = { top: 0, right: 0, bottom: 0, left: 0 }
12
+ const defaultFrame: SafeAreaFrame = { x: 0, y: 0, width: 0, height: 0 }
13
+
14
+ export interface SafeAreaAccessor {
15
+ readonly isEnabled: boolean
16
+ readonly state: SafeAreaState
17
+ set(updates: Partial<SafeAreaState>): void
18
+ /** Get initial insets (non-reactive, for style resolution) */
19
+ getInsets(): SafeAreaInsets
20
+ /** Get initial frame (non-reactive) */
21
+ getFrame(): SafeAreaFrame
22
+ }
23
+
24
+ export function getSafeArea(): SafeAreaAccessor {
25
+ return {
26
+ get isEnabled() {
27
+ return state.get().enabled
28
+ },
29
+ get state() {
30
+ return state.get()
31
+ },
32
+ set(updates: Partial<SafeAreaState>) {
33
+ Object.assign(state.get(), updates)
34
+ },
35
+ getInsets() {
36
+ const s = state.get()
37
+ if (!s.enabled || !s.initialMetrics) {
38
+ return defaultInsets
39
+ }
40
+ return s.initialMetrics.insets
41
+ },
42
+ getFrame() {
43
+ const s = state.get()
44
+ if (!s.enabled || !s.initialMetrics) {
45
+ return defaultFrame
46
+ }
47
+ return s.initialMetrics.frame
48
+ },
49
+ }
50
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Setup burnt for Hanzo GUI native toasts.
3
+ *
4
+ * Simply import this module at the top of your app entry point:
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * import '@hanzogui/native/setup-burnt'
9
+ * ```
10
+ *
11
+ * This automatically detects and configures burnt for use with
12
+ * native Toast functionality.
13
+ */
14
+
15
+ import { getBurnt } from './burntState'
16
+
17
+ function setup(): void {
18
+ const g = globalThis as any
19
+ if (g.__gui_native_burnt_setup) return
20
+ g.__gui_native_burnt_setup = true
21
+
22
+ try {
23
+ const Burnt = require('burnt') as typeof import('burnt')
24
+
25
+ if (Burnt) {
26
+ getBurnt().set({
27
+ enabled: true,
28
+ toast: Burnt.toast,
29
+ dismissAllAlerts: Burnt.dismissAllAlerts,
30
+ })
31
+ }
32
+ } catch {
33
+ // burnt not installed
34
+ }
35
+ }
36
+
37
+ // run setup immediately on import
38
+ setup()
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Setup expo-linear-gradient for Gui.
3
+ *
4
+ * Simply import this module at the top of your app entry point:
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * import '@hanzogui/native/setup-expo-linear-gradient'
9
+ * ```
10
+ *
11
+ * This automatically detects and configures expo-linear-gradient.
12
+ * If not installed, LinearGradient will log a warning on native.
13
+ */
14
+
15
+ import { getLinearGradient } from './linearGradientState'
16
+
17
+ function setup(): void {
18
+ const g = globalThis as any
19
+ if (g.__gui_native_linear_gradient_setup) return
20
+ g.__gui_native_linear_gradient_setup = true
21
+
22
+ try {
23
+ const expoLinearGradient = require('expo-linear-gradient')
24
+ if (expoLinearGradient?.LinearGradient) {
25
+ getLinearGradient().set({
26
+ enabled: true,
27
+ Component: expoLinearGradient.LinearGradient,
28
+ })
29
+ }
30
+ } catch {
31
+ // expo-linear-gradient not installed, will use CSS fallback
32
+ }
33
+ }
34
+
35
+ // run setup immediately on import
36
+ setup()
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Setup gesture handler for Hanzo GUI native components.
3
+ *
4
+ * Simply import this module at the top of your app entry point:
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * import '@hanzogui/native/setup-gesture-handler'
9
+ * ```
10
+ *
11
+ * This automatically detects and configures react-native-gesture-handler
12
+ * for use with Sheet and other gesture-aware components.
13
+ */
14
+
15
+ import { getGestureHandler } from './gestureState'
16
+
17
+ function setup() {
18
+ const g = globalThis as any
19
+ if (g.__gui_native_gesture_setup_complete) {
20
+ return
21
+ }
22
+ g.__gui_native_gesture_setup_complete = true
23
+
24
+ try {
25
+ // dynamically require RNGH - it should already be imported by the app
26
+ const rngh = require('react-native-gesture-handler')
27
+ const { Gesture, GestureDetector, ScrollView } = rngh
28
+
29
+ if (Gesture && GestureDetector) {
30
+ getGestureHandler().set({
31
+ enabled: true,
32
+ Gesture,
33
+ GestureDetector,
34
+ ScrollView: ScrollView || null,
35
+ })
36
+
37
+ // also set on the legacy key for backward compat with @hanzogui/sheet
38
+ g.__gui_sheet_gesture_state__ = {
39
+ enabled: true,
40
+ Gesture,
41
+ GestureDetector,
42
+ ScrollView: ScrollView || null,
43
+ }
44
+ }
45
+ } catch {
46
+ // RNGH not available, that's fine
47
+ }
48
+ }
49
+
50
+ // run setup immediately on import
51
+ setup()
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Setup keyboard controller for Hanzo GUI native components.
3
+ *
4
+ * Simply import this module at the top of your app entry point:
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * import '@hanzogui/native/setup-keyboard-controller'
9
+ * ```
10
+ *
11
+ * This automatically detects and configures react-native-keyboard-controller
12
+ * for use with Sheet and other keyboard-aware components.
13
+ *
14
+ * When enabled, Sheet gains:
15
+ * - Frame-by-frame keyboard tracking (60/120 FPS)
16
+ * - Smooth gesture + keyboard handoff
17
+ * - Interactive keyboard dismiss on sheet drag
18
+ */
19
+
20
+ import { setKeyboardControllerState } from './keyboardControllerState'
21
+
22
+ function setup() {
23
+ const g = globalThis as any
24
+ if (g.__gui_native_keyboard_controller_setup_complete) {
25
+ return
26
+ }
27
+ g.__gui_native_keyboard_controller_setup_complete = true
28
+
29
+ try {
30
+ // dynamically require keyboard-controller - it should already be imported by the app
31
+ const rnkc = require('react-native-keyboard-controller')
32
+ const {
33
+ KeyboardProvider,
34
+ KeyboardAwareScrollView,
35
+ useKeyboardHandler,
36
+ useReanimatedKeyboardAnimation,
37
+ KeyboardController,
38
+ KeyboardEvents,
39
+ KeyboardStickyView,
40
+ } = rnkc
41
+
42
+ if (useKeyboardHandler && KeyboardProvider) {
43
+ setKeyboardControllerState({
44
+ enabled: true,
45
+ KeyboardProvider: KeyboardProvider || null,
46
+ KeyboardAwareScrollView: KeyboardAwareScrollView || null,
47
+ useKeyboardHandler: useKeyboardHandler || null,
48
+ useReanimatedKeyboardAnimation: useReanimatedKeyboardAnimation || null,
49
+ KeyboardController: KeyboardController || null,
50
+ KeyboardEvents: KeyboardEvents || null,
51
+ KeyboardStickyView: KeyboardStickyView || null,
52
+ })
53
+ }
54
+ } catch {
55
+ // keyboard-controller not available, that's fine
56
+ }
57
+ }
58
+
59
+ // run setup immediately on import
60
+ setup()
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Web stub for keyboard controller setup.
3
+ * No-op on web - keyboard-controller is native-only.
4
+ */
5
+
6
+ // intentionally empty - web doesn't need keyboard-controller
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Setup react-native-safe-area-context for Hanzo GUI native components.
3
+ *
4
+ * Simply import this module at the top of your app entry point:
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * import '@hanzogui/native/setup-safe-area'
9
+ * ```
10
+ *
11
+ * This automatically detects and configures react-native-safe-area-context
12
+ * for use with Hanzo GUI components that need safe area awareness.
13
+ *
14
+ * Note: You must still wrap your app with SafeAreaProvider yourself:
15
+ * ```tsx
16
+ * import { SafeAreaProvider } from 'react-native-safe-area-context'
17
+ * <SafeAreaProvider>
18
+ * <App />
19
+ * </SafeAreaProvider>
20
+ * ```
21
+ *
22
+ * On web, this is a no-op since CSS env(safe-area-inset-*) values work natively.
23
+ */
24
+
25
+ import { getSafeArea } from './safeAreaState'
26
+
27
+ function setup() {
28
+ // only run on native
29
+ if (process.env.HANZO_GUI_TARGET !== 'native') {
30
+ return
31
+ }
32
+
33
+ const g = globalThis as any
34
+ if (g.__gui_native_safe_area_setup_complete) {
35
+ return
36
+ }
37
+ g.__gui_native_safe_area_setup_complete = true
38
+
39
+ try {
40
+ const safeAreaContext = require('react-native-safe-area-context')
41
+ const { useSafeAreaInsets, useSafeAreaFrame, initialWindowMetrics } = safeAreaContext
42
+
43
+ if (useSafeAreaInsets) {
44
+ getSafeArea().set({
45
+ enabled: true,
46
+ useSafeAreaInsets,
47
+ useSafeAreaFrame: useSafeAreaFrame || null,
48
+ initialMetrics: initialWindowMetrics || null,
49
+ })
50
+ }
51
+ } catch {
52
+ // react-native-safe-area-context not available
53
+ }
54
+ }
55
+
56
+ setup()