@hanzogui/native 2.0.0-rc.41-hanzoai.5

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 (283) hide show
  1. package/.turbo/turbo-build.log +2 -0
  2. package/dist/cjs/PressBoundary.cjs +92 -0
  3. package/dist/cjs/PressBoundary.native.js +105 -0
  4. package/dist/cjs/PressBoundary.native.js.map +1 -0
  5. package/dist/cjs/burntState.cjs +46 -0
  6. package/dist/cjs/burntState.native.js +49 -0
  7. package/dist/cjs/burntState.native.js.map +1 -0
  8. package/dist/cjs/components.cjs +71 -0
  9. package/dist/cjs/components.native.js +77 -0
  10. package/dist/cjs/components.native.js.map +1 -0
  11. package/dist/cjs/gesture-handler.cjs +36 -0
  12. package/dist/cjs/gesture-handler.native.js +39 -0
  13. package/dist/cjs/gesture-handler.native.js.map +1 -0
  14. package/dist/cjs/gestureState.cjs +178 -0
  15. package/dist/cjs/gestureState.native.js +191 -0
  16. package/dist/cjs/gestureState.native.js.map +1 -0
  17. package/dist/cjs/globalState.cjs +45 -0
  18. package/dist/cjs/globalState.native.js +48 -0
  19. package/dist/cjs/globalState.native.js.map +1 -0
  20. package/dist/cjs/index.cjs +53 -0
  21. package/dist/cjs/index.native.js +56 -0
  22. package/dist/cjs/index.native.js.map +1 -0
  23. package/dist/cjs/keyboardControllerState.cjs +49 -0
  24. package/dist/cjs/keyboardControllerState.native.js +52 -0
  25. package/dist/cjs/keyboardControllerState.native.js.map +1 -0
  26. package/dist/cjs/linearGradientState.cjs +45 -0
  27. package/dist/cjs/linearGradientState.native.js +48 -0
  28. package/dist/cjs/linearGradientState.native.js.map +1 -0
  29. package/dist/cjs/nativeMenuContext.cjs +29 -0
  30. package/dist/cjs/nativeMenuContext.native.js +32 -0
  31. package/dist/cjs/nativeMenuContext.native.js.map +1 -0
  32. package/dist/cjs/portalState.cjs +45 -0
  33. package/dist/cjs/portalState.native.js +48 -0
  34. package/dist/cjs/portalState.native.js.map +1 -0
  35. package/dist/cjs/safeAreaState.cjs +73 -0
  36. package/dist/cjs/safeAreaState.native.js +76 -0
  37. package/dist/cjs/safeAreaState.native.js.map +1 -0
  38. package/dist/cjs/setup-burnt.cjs +17 -0
  39. package/dist/cjs/setup-burnt.native.js +20 -0
  40. package/dist/cjs/setup-burnt.native.js.map +1 -0
  41. package/dist/cjs/setup-expo-linear-gradient.cjs +16 -0
  42. package/dist/cjs/setup-expo-linear-gradient.native.js +19 -0
  43. package/dist/cjs/setup-expo-linear-gradient.native.js.map +1 -0
  44. package/dist/cjs/setup-gesture-handler.cjs +67 -0
  45. package/dist/cjs/setup-gesture-handler.native.js +70 -0
  46. package/dist/cjs/setup-gesture-handler.native.js.map +1 -0
  47. package/dist/cjs/setup-keyboard-controller.cjs +0 -0
  48. package/dist/cjs/setup-keyboard-controller.native.js +36 -0
  49. package/dist/cjs/setup-keyboard-controller.native.js.map +1 -0
  50. package/dist/cjs/setup-safe-area.cjs +3 -0
  51. package/dist/cjs/setup-safe-area.native.js +23 -0
  52. package/dist/cjs/setup-safe-area.native.js.map +1 -0
  53. package/dist/cjs/setup-teleport.cjs +18 -0
  54. package/dist/cjs/setup-teleport.native.js +21 -0
  55. package/dist/cjs/setup-teleport.native.js.map +1 -0
  56. package/dist/cjs/setup-worklets.cjs +21 -0
  57. package/dist/cjs/setup-worklets.native.js +24 -0
  58. package/dist/cjs/setup-worklets.native.js.map +1 -0
  59. package/dist/cjs/setup-zeego.cjs +22 -0
  60. package/dist/cjs/setup-zeego.native.js +25 -0
  61. package/dist/cjs/setup-zeego.native.js.map +1 -0
  62. package/dist/cjs/types.cjs +18 -0
  63. package/dist/cjs/types.native.js +21 -0
  64. package/dist/cjs/types.native.js.map +1 -0
  65. package/dist/cjs/workletsState.cjs +48 -0
  66. package/dist/cjs/workletsState.native.js +51 -0
  67. package/dist/cjs/workletsState.native.js.map +1 -0
  68. package/dist/cjs/zeegoState.cjs +46 -0
  69. package/dist/cjs/zeegoState.native.js +49 -0
  70. package/dist/cjs/zeegoState.native.js.map +1 -0
  71. package/dist/esm/PressBoundary.mjs +56 -0
  72. package/dist/esm/PressBoundary.mjs.map +1 -0
  73. package/dist/esm/PressBoundary.native.js +66 -0
  74. package/dist/esm/PressBoundary.native.js.map +1 -0
  75. package/dist/esm/burntState.mjs +21 -0
  76. package/dist/esm/burntState.mjs.map +1 -0
  77. package/dist/esm/burntState.native.js +21 -0
  78. package/dist/esm/burntState.native.js.map +1 -0
  79. package/dist/esm/components.mjs +44 -0
  80. package/dist/esm/components.mjs.map +1 -0
  81. package/dist/esm/components.native.js +47 -0
  82. package/dist/esm/components.native.js.map +1 -0
  83. package/dist/esm/gesture-handler.mjs +6 -0
  84. package/dist/esm/gesture-handler.mjs.map +1 -0
  85. package/dist/esm/gesture-handler.native.js +6 -0
  86. package/dist/esm/gesture-handler.native.js.map +1 -0
  87. package/dist/esm/gestureState.mjs +151 -0
  88. package/dist/esm/gestureState.mjs.map +1 -0
  89. package/dist/esm/gestureState.native.js +161 -0
  90. package/dist/esm/gestureState.native.js.map +1 -0
  91. package/dist/esm/globalState.mjs +20 -0
  92. package/dist/esm/globalState.mjs.map +1 -0
  93. package/dist/esm/globalState.native.js +20 -0
  94. package/dist/esm/globalState.native.js.map +1 -0
  95. package/dist/esm/index.js +13 -0
  96. package/dist/esm/index.js.map +1 -0
  97. package/dist/esm/index.mjs +13 -0
  98. package/dist/esm/index.mjs.map +1 -0
  99. package/dist/esm/index.native.js +13 -0
  100. package/dist/esm/index.native.js.map +1 -0
  101. package/dist/esm/keyboardControllerState.mjs +22 -0
  102. package/dist/esm/keyboardControllerState.mjs.map +1 -0
  103. package/dist/esm/keyboardControllerState.native.js +22 -0
  104. package/dist/esm/keyboardControllerState.native.js.map +1 -0
  105. package/dist/esm/linearGradientState.mjs +20 -0
  106. package/dist/esm/linearGradientState.mjs.map +1 -0
  107. package/dist/esm/linearGradientState.native.js +20 -0
  108. package/dist/esm/linearGradientState.native.js.map +1 -0
  109. package/dist/esm/nativeMenuContext.mjs +4 -0
  110. package/dist/esm/nativeMenuContext.mjs.map +1 -0
  111. package/dist/esm/nativeMenuContext.native.js +4 -0
  112. package/dist/esm/nativeMenuContext.native.js.map +1 -0
  113. package/dist/esm/portalState.mjs +20 -0
  114. package/dist/esm/portalState.mjs.map +1 -0
  115. package/dist/esm/portalState.native.js +20 -0
  116. package/dist/esm/portalState.native.js.map +1 -0
  117. package/dist/esm/safeAreaState.mjs +48 -0
  118. package/dist/esm/safeAreaState.mjs.map +1 -0
  119. package/dist/esm/safeAreaState.native.js +48 -0
  120. package/dist/esm/safeAreaState.native.js.map +1 -0
  121. package/dist/esm/setup-burnt.mjs +18 -0
  122. package/dist/esm/setup-burnt.mjs.map +1 -0
  123. package/dist/esm/setup-burnt.native.js +18 -0
  124. package/dist/esm/setup-burnt.native.js.map +1 -0
  125. package/dist/esm/setup-expo-linear-gradient.mjs +17 -0
  126. package/dist/esm/setup-expo-linear-gradient.mjs.map +1 -0
  127. package/dist/esm/setup-expo-linear-gradient.native.js +17 -0
  128. package/dist/esm/setup-expo-linear-gradient.native.js.map +1 -0
  129. package/dist/esm/setup-gesture-handler.mjs +41 -0
  130. package/dist/esm/setup-gesture-handler.mjs.map +1 -0
  131. package/dist/esm/setup-gesture-handler.native.js +41 -0
  132. package/dist/esm/setup-gesture-handler.native.js.map +1 -0
  133. package/dist/esm/setup-keyboard-controller.mjs +2 -0
  134. package/dist/esm/setup-keyboard-controller.mjs.map +1 -0
  135. package/dist/esm/setup-keyboard-controller.native.js +34 -0
  136. package/dist/esm/setup-keyboard-controller.native.js.map +1 -0
  137. package/dist/esm/setup-safe-area.mjs +4 -0
  138. package/dist/esm/setup-safe-area.mjs.map +1 -0
  139. package/dist/esm/setup-safe-area.native.js +21 -0
  140. package/dist/esm/setup-safe-area.native.js.map +1 -0
  141. package/dist/esm/setup-teleport.mjs +19 -0
  142. package/dist/esm/setup-teleport.mjs.map +1 -0
  143. package/dist/esm/setup-teleport.native.js +19 -0
  144. package/dist/esm/setup-teleport.native.js.map +1 -0
  145. package/dist/esm/setup-worklets.mjs +22 -0
  146. package/dist/esm/setup-worklets.mjs.map +1 -0
  147. package/dist/esm/setup-worklets.native.js +22 -0
  148. package/dist/esm/setup-worklets.native.js.map +1 -0
  149. package/dist/esm/setup-zeego.mjs +23 -0
  150. package/dist/esm/setup-zeego.mjs.map +1 -0
  151. package/dist/esm/setup-zeego.native.js +23 -0
  152. package/dist/esm/setup-zeego.native.js.map +1 -0
  153. package/dist/esm/types.mjs +2 -0
  154. package/dist/esm/types.mjs.map +1 -0
  155. package/dist/esm/types.native.js +2 -0
  156. package/dist/esm/types.native.js.map +1 -0
  157. package/dist/esm/workletsState.mjs +23 -0
  158. package/dist/esm/workletsState.mjs.map +1 -0
  159. package/dist/esm/workletsState.native.js +23 -0
  160. package/dist/esm/workletsState.native.js.map +1 -0
  161. package/dist/esm/zeegoState.mjs +21 -0
  162. package/dist/esm/zeegoState.mjs.map +1 -0
  163. package/dist/esm/zeegoState.native.js +21 -0
  164. package/dist/esm/zeegoState.native.js.map +1 -0
  165. package/gesture-handler/index.cjs +1 -0
  166. package/gesture-handler/index.js +1 -0
  167. package/gesture-handler/index.native.cjs +1 -0
  168. package/gesture-handler/index.native.js +1 -0
  169. package/gesture-handler.cjs +1 -0
  170. package/package.json +208 -0
  171. package/setup-burnt/index.cjs +2 -0
  172. package/setup-burnt/index.js +2 -0
  173. package/setup-burnt/index.native.cjs +2 -0
  174. package/setup-burnt/index.native.js +2 -0
  175. package/setup-burnt.cjs +1 -0
  176. package/setup-expo-linear-gradient/index.cjs +2 -0
  177. package/setup-expo-linear-gradient/index.js +2 -0
  178. package/setup-expo-linear-gradient/index.native.cjs +2 -0
  179. package/setup-expo-linear-gradient/index.native.js +2 -0
  180. package/setup-expo-linear-gradient.cjs +1 -0
  181. package/setup-gesture-handler/index.cjs +2 -0
  182. package/setup-gesture-handler/index.js +2 -0
  183. package/setup-gesture-handler/index.native.cjs +2 -0
  184. package/setup-gesture-handler/index.native.js +2 -0
  185. package/setup-gesture-handler.cjs +1 -0
  186. package/setup-keyboard-controller/index.cjs +2 -0
  187. package/setup-keyboard-controller/index.js +2 -0
  188. package/setup-keyboard-controller/index.native.cjs +2 -0
  189. package/setup-keyboard-controller/index.native.js +2 -0
  190. package/setup-keyboard-controller.cjs +1 -0
  191. package/setup-safe-area/index.cjs +2 -0
  192. package/setup-safe-area/index.js +2 -0
  193. package/setup-safe-area/index.native.cjs +2 -0
  194. package/setup-safe-area/index.native.js +2 -0
  195. package/setup-safe-area.cjs +1 -0
  196. package/setup-teleport/index.cjs +2 -0
  197. package/setup-teleport/index.js +2 -0
  198. package/setup-teleport/index.native.cjs +2 -0
  199. package/setup-teleport/index.native.js +2 -0
  200. package/setup-teleport.cjs +1 -0
  201. package/setup-worklets/index.cjs +2 -0
  202. package/setup-worklets/index.js +2 -0
  203. package/setup-worklets/index.native.cjs +2 -0
  204. package/setup-worklets/index.native.js +2 -0
  205. package/setup-worklets.cjs +1 -0
  206. package/setup-zeego/index.cjs +2 -0
  207. package/setup-zeego/index.js +2 -0
  208. package/setup-zeego/index.native.cjs +2 -0
  209. package/setup-zeego/index.native.js +2 -0
  210. package/setup-zeego.cjs +1 -0
  211. package/src/PressBoundary.tsx +81 -0
  212. package/src/burntState.ts +28 -0
  213. package/src/components.tsx +48 -0
  214. package/src/gesture-handler.ts +17 -0
  215. package/src/gestureState.ts +260 -0
  216. package/src/globalState.ts +32 -0
  217. package/src/index.ts +88 -0
  218. package/src/keyboardControllerState.ts +29 -0
  219. package/src/linearGradientState.ts +27 -0
  220. package/src/nativeMenuContext.ts +4 -0
  221. package/src/portalState.ts +27 -0
  222. package/src/safeAreaState.ts +50 -0
  223. package/src/setup-burnt.ts +38 -0
  224. package/src/setup-expo-linear-gradient.ts +36 -0
  225. package/src/setup-gesture-handler.ts +78 -0
  226. package/src/setup-keyboard-controller.ts +60 -0
  227. package/src/setup-keyboard-controller.web.ts +6 -0
  228. package/src/setup-safe-area.ts +56 -0
  229. package/src/setup-teleport.ts +36 -0
  230. package/src/setup-worklets.ts +49 -0
  231. package/src/setup-zeego.ts +42 -0
  232. package/src/types.ts +88 -0
  233. package/src/workletsState.ts +30 -0
  234. package/src/zeegoState.ts +28 -0
  235. package/tsconfig.json +12 -0
  236. package/types/PressBoundary.d.ts +14 -0
  237. package/types/PressBoundary.d.ts.map +11 -0
  238. package/types/burntState.d.ts +9 -0
  239. package/types/burntState.d.ts.map +11 -0
  240. package/types/components.d.ts +20 -0
  241. package/types/components.d.ts.map +11 -0
  242. package/types/gesture-handler.d.ts +8 -0
  243. package/types/gesture-handler.d.ts.map +11 -0
  244. package/types/gestureState.d.ts +29 -0
  245. package/types/gestureState.d.ts.map +11 -0
  246. package/types/globalState.d.ts +8 -0
  247. package/types/globalState.d.ts.map +11 -0
  248. package/types/index.d.ts +43 -0
  249. package/types/index.d.ts.map +11 -0
  250. package/types/keyboardControllerState.d.ts +7 -0
  251. package/types/keyboardControllerState.d.ts.map +11 -0
  252. package/types/linearGradientState.d.ts +9 -0
  253. package/types/linearGradientState.d.ts.map +11 -0
  254. package/types/nativeMenuContext.d.ts +4 -0
  255. package/types/nativeMenuContext.d.ts.map +11 -0
  256. package/types/portalState.d.ts +9 -0
  257. package/types/portalState.d.ts.map +11 -0
  258. package/types/safeAreaState.d.ts +13 -0
  259. package/types/safeAreaState.d.ts.map +11 -0
  260. package/types/setup-burnt.d.ts +3 -0
  261. package/types/setup-burnt.d.ts.map +11 -0
  262. package/types/setup-expo-linear-gradient.d.ts +3 -0
  263. package/types/setup-expo-linear-gradient.d.ts.map +11 -0
  264. package/types/setup-gesture-handler.d.ts +10 -0
  265. package/types/setup-gesture-handler.d.ts.map +11 -0
  266. package/types/setup-keyboard-controller.d.ts +3 -0
  267. package/types/setup-keyboard-controller.d.ts.map +11 -0
  268. package/types/setup-keyboard-controller.web.d.ts +2 -0
  269. package/types/setup-keyboard-controller.web.d.ts.map +11 -0
  270. package/types/setup-safe-area.d.ts +3 -0
  271. package/types/setup-safe-area.d.ts.map +11 -0
  272. package/types/setup-teleport.d.ts +3 -0
  273. package/types/setup-teleport.d.ts.map +11 -0
  274. package/types/setup-worklets.d.ts +3 -0
  275. package/types/setup-worklets.d.ts.map +11 -0
  276. package/types/setup-zeego.d.ts +3 -0
  277. package/types/setup-zeego.d.ts.map +11 -0
  278. package/types/types.d.ts +76 -0
  279. package/types/types.d.ts.map +11 -0
  280. package/types/workletsState.d.ts +9 -0
  281. package/types/workletsState.d.ts.map +11 -0
  282. package/types/zeegoState.d.ts +9 -0
  283. package/types/zeegoState.d.ts.map +11 -0
@@ -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 Hanzogui 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.__hanzogui_native_burnt_setup) return
20
+ g.__hanzogui_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 Hanzogui.
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.__hanzogui_native_linear_gradient_setup) return
20
+ g.__hanzogui_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,78 @@
1
+ /**
2
+ * Setup gesture handler for Hanzogui native components.
3
+ *
4
+ * Simply import this module at the top of your app entry point:
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * // auto-setup with all features enabled
9
+ * import '@hanzogui/native/setup-gesture-handler'
10
+ *
11
+ * // or configure selectively
12
+ * import { setupGestureHandler } from '@hanzogui/native/setup-gesture-handler'
13
+ * setupGestureHandler({ pressEvents: true, sheet: false })
14
+ * ```
15
+ *
16
+ * This automatically detects and configures react-native-gesture-handler
17
+ * for use with Sheet and other gesture-aware components.
18
+ */
19
+
20
+ import { getGestureHandler } from './gestureState'
21
+
22
+ export interface GestureHandlerConfig {
23
+ /** use RNGH for press events on Hanzogui components (default: true) */
24
+ pressEvents?: boolean
25
+ /** use RNGH for Sheet drag gestures (default: true) */
26
+ sheet?: boolean
27
+ }
28
+
29
+ let currentConfig: GestureHandlerConfig = {
30
+ pressEvents: true,
31
+ sheet: true,
32
+ }
33
+
34
+ export function getGestureHandlerConfig(): GestureHandlerConfig {
35
+ return currentConfig
36
+ }
37
+
38
+ export function setupGestureHandler(config?: GestureHandlerConfig): void {
39
+ const g = globalThis as any
40
+
41
+ // override config if provided
42
+ if (config) {
43
+ currentConfig = config
44
+ }
45
+
46
+ // allow re-running setup to change config
47
+ const isFirstRun = !g.__hanzogui_native_gesture_setup_complete
48
+ g.__hanzogui_native_gesture_setup_complete = true
49
+
50
+ try {
51
+ // dynamically require RNGH - it should already be imported by the app
52
+ const rngh = require('react-native-gesture-handler')
53
+ const { Gesture, GestureDetector, ScrollView } = rngh
54
+
55
+ if (Gesture && GestureDetector) {
56
+ // only enable if pressEvents is true
57
+ getGestureHandler().set({
58
+ enabled: currentConfig.pressEvents !== false,
59
+ Gesture,
60
+ GestureDetector,
61
+ ScrollView: ScrollView || null,
62
+ })
63
+
64
+ // sheet state - only enable if sheet is true
65
+ g.__hanzogui_sheet_gesture_state__ = {
66
+ enabled: currentConfig.sheet !== false,
67
+ Gesture,
68
+ GestureDetector,
69
+ ScrollView: ScrollView || null,
70
+ }
71
+ }
72
+ } catch {
73
+ // RNGH not available, that's fine
74
+ }
75
+ }
76
+
77
+ // run setup immediately on import (can be overridden by calling setupGestureHandler)
78
+ setupGestureHandler()
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Setup keyboard controller for Hanzogui 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.__hanzogui_native_keyboard_controller_setup_complete) {
25
+ return
26
+ }
27
+ g.__hanzogui_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 Hanzogui 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 Hanzogui 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.TAMAGUI_TARGET !== 'native') {
30
+ return
31
+ }
32
+
33
+ const g = globalThis as any
34
+ if (g.__hanzogui_native_safe_area_setup_complete) {
35
+ return
36
+ }
37
+ g.__hanzogui_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()
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Setup native portal support for Hanzogui.
3
+ *
4
+ * Simply import this module at the top of your app entry point:
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * import '@hanzogui/native/setup-teleport'
9
+ * ```
10
+ *
11
+ * This automatically detects and configures react-native-teleport for portals.
12
+ * Falls back to legacy RN shims if teleport is not installed.
13
+ */
14
+
15
+ import { getPortal } from './portalState'
16
+
17
+ function setup(): void {
18
+ const g = globalThis as any
19
+ if (g.__hanzogui_native_portal_setup) return
20
+ g.__hanzogui_native_portal_setup = true
21
+
22
+ // try teleport first (preferred)
23
+ try {
24
+ const teleport = require('react-native-teleport')
25
+ if (teleport?.Portal && teleport?.PortalHost && teleport?.PortalProvider) {
26
+ g.__hanzogui_teleport = teleport
27
+ getPortal().set({ enabled: true, type: 'teleport' })
28
+ return
29
+ }
30
+ } catch {
31
+ // react-native-teleport not installed, that's ok
32
+ }
33
+ }
34
+
35
+ // run setup immediately on import
36
+ setup()
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Setup worklets for Hanzogui 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-worklets'
9
+ * ```
10
+ *
11
+ * This automatically detects and configures react-native-worklets-core
12
+ * for use with Sheet and other components that benefit from synchronous
13
+ * native-thread execution.
14
+ *
15
+ * When combined with setup-gesture-handler, Sheet gets native-quality
16
+ * gesture coordination between sheet dragging and scroll views.
17
+ *
18
+ * @see https://docs.swmansion.com/react-native-worklets/docs/
19
+ */
20
+
21
+ import { getWorklets } from './workletsState'
22
+
23
+ function setup() {
24
+ const g = globalThis as any
25
+ if (g.__hanzogui_native_worklets_setup_complete) {
26
+ return
27
+ }
28
+ g.__hanzogui_native_worklets_setup_complete = true
29
+
30
+ try {
31
+ // dynamically require worklets-core
32
+ const worklets = require('react-native-worklets-core')
33
+
34
+ if (worklets) {
35
+ getWorklets().set({
36
+ enabled: true,
37
+ Worklets: worklets.Worklets,
38
+ useRunOnJS: worklets.useRunOnJS,
39
+ useWorklet: worklets.useWorklet,
40
+ createWorkletContextValue: worklets.createWorkletContextValue,
41
+ })
42
+ }
43
+ } catch {
44
+ // worklets not available, that's fine - will fall back to JS thread
45
+ }
46
+ }
47
+
48
+ // run setup immediately on import
49
+ setup()
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Setup zeego for Hanzogui native menus.
3
+ *
4
+ * Simply import this module at the top of your app entry point:
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * import '@hanzogui/native/setup-zeego'
9
+ * ```
10
+ *
11
+ * This automatically detects and configures zeego for use with
12
+ * Menu and ContextMenu native mode.
13
+ */
14
+
15
+ import { getZeego } from './zeegoState'
16
+
17
+ function setup(): void {
18
+ const g = globalThis as any
19
+ if (g.__hanzogui_native_zeego_setup) return
20
+ g.__hanzogui_native_zeego_setup = true
21
+
22
+ try {
23
+ const DropdownMenu = require('zeego/dropdown-menu')
24
+ const ContextMenu = require('zeego/context-menu')
25
+
26
+ if (DropdownMenu && ContextMenu) {
27
+ getZeego().set({
28
+ enabled: true,
29
+ DropdownMenu,
30
+ ContextMenu,
31
+ })
32
+ }
33
+ } catch (err) {
34
+ if (process.env.NODE_ENV === 'development') {
35
+ console.warn(`Error setting up Zeego`, err)
36
+ }
37
+ // zeego not installed
38
+ }
39
+ }
40
+
41
+ // run setup immediately on import
42
+ setup()
package/src/types.ts ADDED
@@ -0,0 +1,88 @@
1
+ import type { ReactNode } from 'react'
2
+
3
+ export type NativePortalState = {
4
+ enabled: boolean
5
+ type: 'teleport' | 'legacy' | null
6
+ }
7
+
8
+ export interface GestureState {
9
+ enabled: boolean
10
+ Gesture: any
11
+ GestureDetector: any
12
+ ScrollView: any
13
+ }
14
+
15
+ export interface WorkletsState {
16
+ enabled: boolean
17
+ Worklets: any
18
+ useRunOnJS: any
19
+ useWorklet: any
20
+ createWorkletContextValue: any
21
+ }
22
+
23
+ export interface SafeAreaInsets {
24
+ top: number
25
+ right: number
26
+ bottom: number
27
+ left: number
28
+ }
29
+
30
+ export interface SafeAreaFrame {
31
+ x: number
32
+ y: number
33
+ width: number
34
+ height: number
35
+ }
36
+
37
+ export interface SafeAreaMetrics {
38
+ insets: SafeAreaInsets
39
+ frame: SafeAreaFrame
40
+ }
41
+
42
+ export interface SafeAreaState {
43
+ enabled: boolean
44
+ useSafeAreaInsets: (() => SafeAreaInsets) | null
45
+ useSafeAreaFrame: (() => SafeAreaFrame) | null
46
+ initialMetrics: SafeAreaMetrics | null
47
+ }
48
+
49
+ export type NativePortalProps = {
50
+ hostName?: string
51
+ children: ReactNode
52
+ }
53
+
54
+ export type NativePortalHostProps = {
55
+ name: string
56
+ }
57
+
58
+ export type NativePortalProviderProps = {
59
+ children: ReactNode
60
+ }
61
+
62
+ export interface LinearGradientState {
63
+ enabled: boolean
64
+ Component: any
65
+ }
66
+
67
+ export interface ZeegoState {
68
+ enabled: boolean
69
+ DropdownMenu: any
70
+ ContextMenu: any
71
+ }
72
+
73
+ export interface BurntState {
74
+ enabled: boolean
75
+ toast: ((options: any) => void) | null
76
+ dismissAllAlerts: (() => void) | null
77
+ }
78
+
79
+ export interface KeyboardControllerState {
80
+ enabled: boolean
81
+ KeyboardProvider: any
82
+ KeyboardAwareScrollView: any
83
+ useKeyboardHandler: any
84
+ useReanimatedKeyboardAnimation: any
85
+ KeyboardController: any
86
+ KeyboardEvents: any
87
+ KeyboardStickyView: any
88
+ }
@@ -0,0 +1,30 @@
1
+ import { createGlobalState } from './globalState'
2
+ import type { WorkletsState } from './types'
3
+
4
+ const state = createGlobalState<WorkletsState>(`worklets`, {
5
+ enabled: false,
6
+ Worklets: null,
7
+ useRunOnJS: null,
8
+ useWorklet: null,
9
+ createWorkletContextValue: null,
10
+ })
11
+
12
+ export interface WorkletsAccessor {
13
+ readonly isEnabled: boolean
14
+ readonly state: WorkletsState
15
+ set(updates: Partial<WorkletsState>): void
16
+ }
17
+
18
+ export function getWorklets(): WorkletsAccessor {
19
+ return {
20
+ get isEnabled(): boolean {
21
+ return state.get().enabled
22
+ },
23
+ get state(): WorkletsState {
24
+ return state.get()
25
+ },
26
+ set(updates: Partial<WorkletsState>): void {
27
+ Object.assign(state.get(), updates)
28
+ },
29
+ }
30
+ }
@@ -0,0 +1,28 @@
1
+ import { createGlobalState } from './globalState'
2
+ import type { ZeegoState } from './types'
3
+
4
+ const state = createGlobalState<ZeegoState>(`zeego`, {
5
+ enabled: false,
6
+ DropdownMenu: null,
7
+ ContextMenu: null,
8
+ })
9
+
10
+ export interface ZeegoAccessor {
11
+ readonly isEnabled: boolean
12
+ readonly state: ZeegoState
13
+ set(newState: ZeegoState): void
14
+ }
15
+
16
+ export function getZeego(): ZeegoAccessor {
17
+ return {
18
+ get isEnabled(): boolean {
19
+ return state.get().enabled
20
+ },
21
+ get state(): ZeegoState {
22
+ return state.get()
23
+ },
24
+ set(newState: ZeegoState): void {
25
+ state.set(newState)
26
+ },
27
+ }
28
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "composite": true,
5
+ "isolatedDeclarations": true
6
+ },
7
+ "exclude": [
8
+ "types",
9
+ "dist",
10
+ "**/__tests__"
11
+ ]
12
+ }
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { View, type ViewProps } from "react-native";
3
+ export interface PressBoundaryProps extends ViewProps {
4
+ enabled?: boolean;
5
+ /**
6
+ * Alias for enabling the boundary. The behavior is limited to Hanzogui's
7
+ * shared press ownership and does not patch arbitrary RN bubbling.
8
+ */
9
+ stopPropagation?: boolean;
10
+ debugName?: string | null;
11
+ }
12
+ export declare const PressBoundary: React.ForwardRefExoticComponent<PressBoundaryProps & React.RefAttributes<View>>;
13
+
14
+ //# sourceMappingURL=PressBoundary.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,WAAW,iBAAiB;AAOrC,iBAAiB,2BAA2B,UAAU;CACpD;;;;;CAKA;CACA;;AAiBF,OAAO,cAAM,eAAe,MAAM,0BAChC,qBAAqB,MAAM,cAAc",
3
+ "names": [],
4
+ "sources": [
5
+ "src/PressBoundary.tsx"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "import React from 'react'\nimport { View, type ViewProps } from 'react-native'\nimport {\n claimExternalPressOwnership,\n releaseExternalPressOwnership,\n type ExternalPressOwnershipToken,\n} from './gestureState'\n\nexport interface PressBoundaryProps extends ViewProps {\n enabled?: boolean\n /**\n * Alias for enabling the boundary. The behavior is limited to Hanzogui's\n * shared press ownership and does not patch arbitrary RN bubbling.\n */\n stopPropagation?: boolean\n debugName?: string | null\n}\n\nfunction composeFirst<T extends (...args: any[]) => void>(ours: T, theirs?: T) {\n return (...args: Parameters<T>) => {\n ours(...args)\n theirs?.(...args)\n }\n}\n\nfunction composeLast<T extends (...args: any[]) => void>(theirs: T | undefined, ours: T) {\n return (...args: Parameters<T>) => {\n theirs?.(...args)\n ours(...args)\n }\n}\n\nexport const PressBoundary: React.ForwardRefExoticComponent<\n PressBoundaryProps & React.RefAttributes<View>\n> = React.forwardRef<View, PressBoundaryProps>(function PressBoundary(\n {\n enabled,\n stopPropagation,\n debugName,\n onTouchStart,\n onTouchEnd,\n onTouchCancel,\n onResponderGrant,\n onResponderRelease,\n onResponderTerminate,\n ...props\n },\n forwardedRef\n) {\n const tokenRef = React.useRef<ExternalPressOwnershipToken | null>(null)\n const isEnabled = enabled ?? stopPropagation ?? true\n\n const claim = React.useCallback((): void => {\n if (!isEnabled) return\n if (tokenRef.current) {\n releaseExternalPressOwnership(tokenRef.current, debugName)\n }\n tokenRef.current = claimExternalPressOwnership(debugName)\n }, [debugName, isEnabled])\n\n const release = React.useCallback((): void => {\n if (!tokenRef.current) return\n releaseExternalPressOwnership(tokenRef.current, debugName)\n tokenRef.current = null\n }, [debugName])\n\n React.useEffect(() => release, [release])\n\n return (\n <View\n ref={forwardedRef}\n {...props}\n onTouchStart={composeFirst(claim, onTouchStart)}\n onTouchEnd={composeLast(onTouchEnd, release)}\n onTouchCancel={composeLast(onTouchCancel, release)}\n onResponderGrant={composeFirst(claim, onResponderGrant)}\n onResponderRelease={composeLast(onResponderRelease, release)}\n onResponderTerminate={composeLast(onResponderTerminate, release)}\n />\n )\n})\n"
10
+ ]
11
+ }
@@ -0,0 +1,9 @@
1
+ import type { BurntState } from "./types";
2
+ export interface BurntAccessor {
3
+ readonly isEnabled: boolean;
4
+ readonly state: BurntState;
5
+ set(newState: BurntState): void;
6
+ }
7
+ export declare function getBurnt(): BurntAccessor;
8
+
9
+ //# sourceMappingURL=burntState.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AACA,cAAc,kBAAkB;AAQhC,iBAAiB,cAAc;UACpB;UACA,OAAO;CAChB,IAAI,UAAU;;AAGhB,OAAO,iBAAS,YAAY",
3
+ "names": [],
4
+ "sources": [
5
+ "src/burntState.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "import { createGlobalState } from './globalState'\nimport type { BurntState } from './types'\n\nconst state = createGlobalState<BurntState>(`burnt`, {\n enabled: false,\n toast: null,\n dismissAllAlerts: null,\n})\n\nexport interface BurntAccessor {\n readonly isEnabled: boolean\n readonly state: BurntState\n set(newState: BurntState): void\n}\n\nexport function getBurnt(): BurntAccessor {\n return {\n get isEnabled(): boolean {\n return state.get().enabled\n },\n get state(): BurntState {\n return state.get()\n },\n set(newState: BurntState): void {\n state.set(newState)\n },\n }\n}\n"
10
+ ]
11
+ }