@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.
- package/dist/cjs/burntState.cjs +44 -0
- package/dist/cjs/burntState.native.js +47 -0
- package/dist/cjs/burntState.native.js.map +1 -0
- package/dist/cjs/components.cjs +66 -0
- package/dist/cjs/components.native.js +75 -0
- package/dist/cjs/components.native.js.map +1 -0
- package/dist/cjs/gestureState.cjs +65 -0
- package/dist/cjs/gestureState.native.js +81 -0
- package/dist/cjs/gestureState.native.js.map +1 -0
- package/dist/cjs/globalState.cjs +39 -0
- package/dist/cjs/globalState.native.js +42 -0
- package/dist/cjs/globalState.native.js.map +1 -0
- package/dist/cjs/index.cjs +48 -0
- package/dist/cjs/index.native.js +51 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/keyboardControllerState.cjs +47 -0
- package/dist/cjs/keyboardControllerState.native.js +50 -0
- package/dist/cjs/keyboardControllerState.native.js.map +1 -0
- package/dist/cjs/linearGradientState.cjs +43 -0
- package/dist/cjs/linearGradientState.native.js +46 -0
- package/dist/cjs/linearGradientState.native.js.map +1 -0
- package/dist/cjs/nativeMenuContext.cjs +27 -0
- package/dist/cjs/nativeMenuContext.native.js +30 -0
- package/dist/cjs/nativeMenuContext.native.js.map +1 -0
- package/dist/cjs/portalState.cjs +43 -0
- package/dist/cjs/portalState.native.js +46 -0
- package/dist/cjs/portalState.native.js.map +1 -0
- package/dist/cjs/safeAreaState.cjs +65 -0
- package/dist/cjs/safeAreaState.native.js +68 -0
- package/dist/cjs/safeAreaState.native.js.map +1 -0
- package/dist/cjs/setup-burnt.cjs +16 -0
- package/dist/cjs/setup-burnt.native.js +19 -0
- package/dist/cjs/setup-burnt.native.js.map +1 -0
- package/dist/cjs/setup-expo-linear-gradient.cjs +15 -0
- package/dist/cjs/setup-expo-linear-gradient.native.js +18 -0
- package/dist/cjs/setup-expo-linear-gradient.native.js.map +1 -0
- package/dist/cjs/setup-gesture-handler.cjs +27 -0
- package/dist/cjs/setup-gesture-handler.native.js +30 -0
- package/dist/cjs/setup-gesture-handler.native.js.map +1 -0
- package/dist/cjs/setup-keyboard-controller.cjs +0 -0
- package/dist/cjs/setup-keyboard-controller.native.js +33 -0
- package/dist/cjs/setup-keyboard-controller.native.js.map +1 -0
- package/dist/cjs/setup-safe-area.cjs +1 -0
- package/dist/cjs/setup-safe-area.native.js +25 -0
- package/dist/cjs/setup-safe-area.native.js.map +1 -0
- package/dist/cjs/setup-teleport.cjs +18 -0
- package/dist/cjs/setup-teleport.native.js +21 -0
- package/dist/cjs/setup-teleport.native.js.map +1 -0
- package/dist/cjs/setup-worklets.cjs +18 -0
- package/dist/cjs/setup-worklets.native.js +21 -0
- package/dist/cjs/setup-worklets.native.js.map +1 -0
- package/dist/cjs/setup-zeego.cjs +19 -0
- package/dist/cjs/setup-zeego.native.js +22 -0
- package/dist/cjs/setup-zeego.native.js.map +1 -0
- package/dist/cjs/types.cjs +16 -0
- package/dist/cjs/types.native.js +19 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/cjs/workletsState.cjs +46 -0
- package/dist/cjs/workletsState.native.js +49 -0
- package/dist/cjs/workletsState.native.js.map +1 -0
- package/dist/cjs/zeegoState.cjs +44 -0
- package/dist/cjs/zeegoState.native.js +47 -0
- package/dist/cjs/zeegoState.native.js.map +1 -0
- package/dist/esm/burntState.mjs +21 -0
- package/dist/esm/burntState.mjs.map +1 -0
- package/dist/esm/burntState.native.js +21 -0
- package/dist/esm/burntState.native.js.map +1 -0
- package/dist/esm/components.mjs +41 -0
- package/dist/esm/components.mjs.map +1 -0
- package/dist/esm/components.native.js +47 -0
- package/dist/esm/components.native.js.map +1 -0
- package/dist/esm/gestureState.mjs +42 -0
- package/dist/esm/gestureState.mjs.map +1 -0
- package/dist/esm/gestureState.native.js +55 -0
- package/dist/esm/gestureState.native.js.map +1 -0
- package/dist/esm/globalState.mjs +16 -0
- package/dist/esm/globalState.mjs.map +1 -0
- package/dist/esm/globalState.native.js +16 -0
- package/dist/esm/globalState.native.js.map +1 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +12 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +12 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/keyboardControllerState.mjs +22 -0
- package/dist/esm/keyboardControllerState.mjs.map +1 -0
- package/dist/esm/keyboardControllerState.native.js +22 -0
- package/dist/esm/keyboardControllerState.native.js.map +1 -0
- package/dist/esm/linearGradientState.mjs +20 -0
- package/dist/esm/linearGradientState.mjs.map +1 -0
- package/dist/esm/linearGradientState.native.js +20 -0
- package/dist/esm/linearGradientState.native.js.map +1 -0
- package/dist/esm/nativeMenuContext.mjs +4 -0
- package/dist/esm/nativeMenuContext.mjs.map +1 -0
- package/dist/esm/nativeMenuContext.native.js +4 -0
- package/dist/esm/nativeMenuContext.native.js.map +1 -0
- package/dist/esm/portalState.mjs +20 -0
- package/dist/esm/portalState.mjs.map +1 -0
- package/dist/esm/portalState.native.js +20 -0
- package/dist/esm/portalState.native.js.map +1 -0
- package/dist/esm/safeAreaState.mjs +42 -0
- package/dist/esm/safeAreaState.mjs.map +1 -0
- package/dist/esm/safeAreaState.native.js +42 -0
- package/dist/esm/safeAreaState.native.js.map +1 -0
- package/dist/esm/setup-burnt.mjs +17 -0
- package/dist/esm/setup-burnt.mjs.map +1 -0
- package/dist/esm/setup-burnt.native.js +17 -0
- package/dist/esm/setup-burnt.native.js.map +1 -0
- package/dist/esm/setup-expo-linear-gradient.mjs +16 -0
- package/dist/esm/setup-expo-linear-gradient.mjs.map +1 -0
- package/dist/esm/setup-expo-linear-gradient.native.js +16 -0
- package/dist/esm/setup-expo-linear-gradient.native.js.map +1 -0
- package/dist/esm/setup-gesture-handler.mjs +28 -0
- package/dist/esm/setup-gesture-handler.mjs.map +1 -0
- package/dist/esm/setup-gesture-handler.native.js +28 -0
- package/dist/esm/setup-gesture-handler.native.js.map +1 -0
- package/dist/esm/setup-keyboard-controller.mjs +2 -0
- package/dist/esm/setup-keyboard-controller.mjs.map +1 -0
- package/dist/esm/setup-keyboard-controller.native.js +31 -0
- package/dist/esm/setup-keyboard-controller.native.js.map +1 -0
- package/dist/esm/setup-safe-area.mjs +2 -0
- package/dist/esm/setup-safe-area.mjs.map +1 -0
- package/dist/esm/setup-safe-area.native.js +23 -0
- package/dist/esm/setup-safe-area.native.js.map +1 -0
- package/dist/esm/setup-teleport.mjs +19 -0
- package/dist/esm/setup-teleport.mjs.map +1 -0
- package/dist/esm/setup-teleport.native.js +19 -0
- package/dist/esm/setup-teleport.native.js.map +1 -0
- package/dist/esm/setup-worklets.mjs +19 -0
- package/dist/esm/setup-worklets.mjs.map +1 -0
- package/dist/esm/setup-worklets.native.js +19 -0
- package/dist/esm/setup-worklets.native.js.map +1 -0
- package/dist/esm/setup-zeego.mjs +20 -0
- package/dist/esm/setup-zeego.mjs.map +1 -0
- package/dist/esm/setup-zeego.native.js +20 -0
- package/dist/esm/setup-zeego.native.js.map +1 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +2 -0
- package/dist/esm/types.native.js.map +1 -0
- package/dist/esm/workletsState.mjs +23 -0
- package/dist/esm/workletsState.mjs.map +1 -0
- package/dist/esm/workletsState.native.js +23 -0
- package/dist/esm/workletsState.native.js.map +1 -0
- package/dist/esm/zeegoState.mjs +21 -0
- package/dist/esm/zeegoState.mjs.map +1 -0
- package/dist/esm/zeegoState.native.js +21 -0
- package/dist/esm/zeegoState.native.js.map +1 -0
- package/package.json +195 -0
- package/setup-burnt/index.cjs +2 -0
- package/setup-burnt/index.js +2 -0
- package/setup-burnt/index.native.cjs +2 -0
- package/setup-burnt/index.native.js +2 -0
- package/setup-burnt.cjs +1 -0
- package/setup-expo-linear-gradient/index.cjs +2 -0
- package/setup-expo-linear-gradient/index.js +2 -0
- package/setup-expo-linear-gradient/index.native.cjs +2 -0
- package/setup-expo-linear-gradient/index.native.js +2 -0
- package/setup-expo-linear-gradient.cjs +1 -0
- package/setup-gesture-handler/index.cjs +2 -0
- package/setup-gesture-handler/index.js +2 -0
- package/setup-gesture-handler/index.native.cjs +2 -0
- package/setup-gesture-handler/index.native.js +2 -0
- package/setup-gesture-handler.cjs +1 -0
- package/setup-keyboard-controller/index.cjs +2 -0
- package/setup-keyboard-controller/index.js +2 -0
- package/setup-keyboard-controller/index.native.cjs +2 -0
- package/setup-keyboard-controller/index.native.js +2 -0
- package/setup-keyboard-controller.cjs +1 -0
- package/setup-safe-area/index.cjs +2 -0
- package/setup-safe-area/index.js +2 -0
- package/setup-safe-area/index.native.cjs +2 -0
- package/setup-safe-area/index.native.js +2 -0
- package/setup-safe-area.cjs +1 -0
- package/setup-teleport/index.cjs +2 -0
- package/setup-teleport/index.js +2 -0
- package/setup-teleport/index.native.cjs +2 -0
- package/setup-teleport/index.native.js +2 -0
- package/setup-teleport.cjs +1 -0
- package/setup-worklets/index.cjs +2 -0
- package/setup-worklets/index.js +2 -0
- package/setup-worklets/index.native.cjs +2 -0
- package/setup-worklets/index.native.js +2 -0
- package/setup-worklets.cjs +1 -0
- package/setup-zeego/index.cjs +2 -0
- package/setup-zeego/index.js +2 -0
- package/setup-zeego/index.native.cjs +2 -0
- package/setup-zeego/index.native.js +2 -0
- package/setup-zeego.cjs +1 -0
- package/src/burntState.ts +28 -0
- package/src/components.tsx +48 -0
- package/src/gestureState.ts +91 -0
- package/src/globalState.ts +32 -0
- package/src/index.ts +77 -0
- package/src/keyboardControllerState.ts +29 -0
- package/src/linearGradientState.ts +27 -0
- package/src/nativeMenuContext.ts +4 -0
- package/src/portalState.ts +27 -0
- package/src/safeAreaState.ts +50 -0
- package/src/setup-burnt.ts +38 -0
- package/src/setup-expo-linear-gradient.ts +36 -0
- package/src/setup-gesture-handler.ts +51 -0
- package/src/setup-keyboard-controller.ts +60 -0
- package/src/setup-keyboard-controller.web.ts +6 -0
- package/src/setup-safe-area.ts +56 -0
- package/src/setup-teleport.ts +36 -0
- package/src/setup-worklets.ts +49 -0
- package/src/setup-zeego.ts +42 -0
- package/src/types.ts +88 -0
- package/src/workletsState.ts +30 -0
- package/src/zeegoState.ts +28 -0
- package/tsconfig.json +12 -0
- package/types/burntState.d.ts +9 -0
- package/types/components.d.ts +20 -0
- package/types/gestureState.d.ts +25 -0
- package/types/globalState.d.ts +8 -0
- package/types/index.d.ts +41 -0
- package/types/keyboardControllerState.d.ts +7 -0
- package/types/linearGradientState.d.ts +9 -0
- package/types/nativeMenuContext.d.ts +4 -0
- package/types/portalState.d.ts +9 -0
- package/types/safeAreaState.d.ts +13 -0
- package/types/setup-burnt.d.ts +3 -0
- package/types/setup-expo-linear-gradient.d.ts +3 -0
- package/types/setup-gesture-handler.d.ts +3 -0
- package/types/setup-keyboard-controller.d.ts +3 -0
- package/types/setup-keyboard-controller.web.d.ts +2 -0
- package/types/setup-safe-area.d.ts +3 -0
- package/types/setup-teleport.d.ts +3 -0
- package/types/setup-worklets.d.ts +3 -0
- package/types/setup-zeego.d.ts +3 -0
- package/types/types.d.ts +76 -0
- package/types/workletsState.d.ts +9 -0
- package/types/zeegoState.d.ts +9 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setup native portal support 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-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.__gui_native_portal_setup) return
|
|
20
|
+
g.__gui_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.__gui_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 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-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.__gui_native_worklets_setup_complete) {
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
g.__gui_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 Hanzo GUI 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.__gui_native_zeego_setup) return
|
|
20
|
+
g.__gui_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,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,20 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { NativePortalProps, NativePortalHostProps, NativePortalProviderProps } from "./types";
|
|
3
|
+
export type { NativePortalProps, NativePortalHostProps, NativePortalProviderProps };
|
|
4
|
+
/**
|
|
5
|
+
* Renders children into a teleport Portal when available.
|
|
6
|
+
* Returns null when teleport is not set up (allows fallback handling by caller).
|
|
7
|
+
*/
|
|
8
|
+
export declare function NativePortal({ hostName, children }: NativePortalProps): ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Renders a teleport PortalHost when available.
|
|
11
|
+
* Returns null when teleport is not set up.
|
|
12
|
+
*/
|
|
13
|
+
export declare function NativePortalHost({ name }: NativePortalHostProps): ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Wraps children with teleport PortalProvider when available.
|
|
16
|
+
* Returns children as-is when teleport is not set up.
|
|
17
|
+
*/
|
|
18
|
+
export declare function NativePortalProvider({ children }: NativePortalProviderProps): ReactNode;
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { GestureState } from "./types";
|
|
2
|
+
export interface Insets {
|
|
3
|
+
top?: number;
|
|
4
|
+
left?: number;
|
|
5
|
+
bottom?: number;
|
|
6
|
+
right?: number;
|
|
7
|
+
}
|
|
8
|
+
export type PressGestureConfig = {
|
|
9
|
+
onPressIn?: (e: any) => void;
|
|
10
|
+
onPressOut?: (e: any) => void;
|
|
11
|
+
onPress?: (e: any) => void;
|
|
12
|
+
onLongPress?: (e: any) => void;
|
|
13
|
+
delayLongPress?: number;
|
|
14
|
+
hitSlop?: number | Insets | null;
|
|
15
|
+
};
|
|
16
|
+
export interface GestureHandlerAccessor {
|
|
17
|
+
readonly isEnabled: boolean;
|
|
18
|
+
readonly state: GestureState;
|
|
19
|
+
set(updates: Partial<GestureState>): void;
|
|
20
|
+
disable(): void;
|
|
21
|
+
createPressGesture(config: PressGestureConfig): any;
|
|
22
|
+
}
|
|
23
|
+
export declare function getGestureHandler(): GestureHandlerAccessor;
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=gestureState.d.ts.map
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
export type { NativePortalState, GestureState, WorkletsState, SafeAreaState, SafeAreaInsets, SafeAreaFrame, SafeAreaMetrics, LinearGradientState, ZeegoState, BurntState, NativePortalProps, NativePortalHostProps, NativePortalProviderProps } from "./types";
|
|
22
|
+
export { getPortal } from "./portalState";
|
|
23
|
+
export type { PortalAccessor } from "./portalState";
|
|
24
|
+
export { getGestureHandler } from "./gestureState";
|
|
25
|
+
export type { GestureHandlerAccessor, PressGestureConfig } from "./gestureState";
|
|
26
|
+
export { getWorklets } from "./workletsState";
|
|
27
|
+
export type { WorkletsAccessor } from "./workletsState";
|
|
28
|
+
export { getSafeArea } from "./safeAreaState";
|
|
29
|
+
export type { SafeAreaAccessor } from "./safeAreaState";
|
|
30
|
+
export { getLinearGradient } from "./linearGradientState";
|
|
31
|
+
export type { LinearGradientAccessor } from "./linearGradientState";
|
|
32
|
+
export { isKeyboardControllerEnabled, getKeyboardControllerState, setKeyboardControllerState } from "./keyboardControllerState";
|
|
33
|
+
export type { KeyboardControllerState } from "./keyboardControllerState";
|
|
34
|
+
export { getZeego } from "./zeegoState";
|
|
35
|
+
export type { ZeegoAccessor } from "./zeegoState";
|
|
36
|
+
export { NativeMenuContext } from "./nativeMenuContext";
|
|
37
|
+
export { getBurnt } from "./burntState";
|
|
38
|
+
export type { BurntAccessor } from "./burntState";
|
|
39
|
+
export { NativePortal, NativePortalHost, NativePortalProvider } from "./components";
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { KeyboardControllerState } from "./types";
|
|
2
|
+
export type { KeyboardControllerState };
|
|
3
|
+
export declare function isKeyboardControllerEnabled(): boolean;
|
|
4
|
+
export declare function getKeyboardControllerState(): KeyboardControllerState;
|
|
5
|
+
export declare function setKeyboardControllerState(updates: Partial<KeyboardControllerState>): void;
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=keyboardControllerState.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LinearGradientState } from "./types";
|
|
2
|
+
export interface LinearGradientAccessor {
|
|
3
|
+
readonly isEnabled: boolean;
|
|
4
|
+
readonly state: LinearGradientState;
|
|
5
|
+
set(newState: LinearGradientState): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function getLinearGradient(): LinearGradientAccessor;
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=linearGradientState.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NativePortalState } from "./types";
|
|
2
|
+
export interface PortalAccessor {
|
|
3
|
+
readonly isEnabled: boolean;
|
|
4
|
+
readonly state: NativePortalState;
|
|
5
|
+
set(newState: NativePortalState): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function getPortal(): PortalAccessor;
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=portalState.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SafeAreaState, SafeAreaInsets, SafeAreaFrame } from "./types";
|
|
2
|
+
export interface SafeAreaAccessor {
|
|
3
|
+
readonly isEnabled: boolean;
|
|
4
|
+
readonly state: SafeAreaState;
|
|
5
|
+
set(updates: Partial<SafeAreaState>): void;
|
|
6
|
+
/** Get initial insets (non-reactive, for style resolution) */
|
|
7
|
+
getInsets(): SafeAreaInsets;
|
|
8
|
+
/** Get initial frame (non-reactive) */
|
|
9
|
+
getFrame(): SafeAreaFrame;
|
|
10
|
+
}
|
|
11
|
+
export declare function getSafeArea(): SafeAreaAccessor;
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=safeAreaState.d.ts.map
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type NativePortalState = {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
type: "teleport" | "legacy" | null;
|
|
5
|
+
};
|
|
6
|
+
export interface GestureState {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
Gesture: any;
|
|
9
|
+
GestureDetector: any;
|
|
10
|
+
ScrollView: any;
|
|
11
|
+
}
|
|
12
|
+
export interface WorkletsState {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
Worklets: any;
|
|
15
|
+
useRunOnJS: any;
|
|
16
|
+
useWorklet: any;
|
|
17
|
+
createWorkletContextValue: any;
|
|
18
|
+
}
|
|
19
|
+
export interface SafeAreaInsets {
|
|
20
|
+
top: number;
|
|
21
|
+
right: number;
|
|
22
|
+
bottom: number;
|
|
23
|
+
left: number;
|
|
24
|
+
}
|
|
25
|
+
export interface SafeAreaFrame {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}
|
|
31
|
+
export interface SafeAreaMetrics {
|
|
32
|
+
insets: SafeAreaInsets;
|
|
33
|
+
frame: SafeAreaFrame;
|
|
34
|
+
}
|
|
35
|
+
export interface SafeAreaState {
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
useSafeAreaInsets: (() => SafeAreaInsets) | null;
|
|
38
|
+
useSafeAreaFrame: (() => SafeAreaFrame) | null;
|
|
39
|
+
initialMetrics: SafeAreaMetrics | null;
|
|
40
|
+
}
|
|
41
|
+
export type NativePortalProps = {
|
|
42
|
+
hostName?: string;
|
|
43
|
+
children: ReactNode;
|
|
44
|
+
};
|
|
45
|
+
export type NativePortalHostProps = {
|
|
46
|
+
name: string;
|
|
47
|
+
};
|
|
48
|
+
export type NativePortalProviderProps = {
|
|
49
|
+
children: ReactNode;
|
|
50
|
+
};
|
|
51
|
+
export interface LinearGradientState {
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
Component: any;
|
|
54
|
+
}
|
|
55
|
+
export interface ZeegoState {
|
|
56
|
+
enabled: boolean;
|
|
57
|
+
DropdownMenu: any;
|
|
58
|
+
ContextMenu: any;
|
|
59
|
+
}
|
|
60
|
+
export interface BurntState {
|
|
61
|
+
enabled: boolean;
|
|
62
|
+
toast: ((options: any) => void) | null;
|
|
63
|
+
dismissAllAlerts: (() => void) | null;
|
|
64
|
+
}
|
|
65
|
+
export interface KeyboardControllerState {
|
|
66
|
+
enabled: boolean;
|
|
67
|
+
KeyboardProvider: any;
|
|
68
|
+
KeyboardAwareScrollView: any;
|
|
69
|
+
useKeyboardHandler: any;
|
|
70
|
+
useReanimatedKeyboardAnimation: any;
|
|
71
|
+
KeyboardController: any;
|
|
72
|
+
KeyboardEvents: any;
|
|
73
|
+
KeyboardStickyView: any;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WorkletsState } from "./types";
|
|
2
|
+
export interface WorkletsAccessor {
|
|
3
|
+
readonly isEnabled: boolean;
|
|
4
|
+
readonly state: WorkletsState;
|
|
5
|
+
set(updates: Partial<WorkletsState>): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function getWorklets(): WorkletsAccessor;
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=workletsState.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ZeegoState } from "./types";
|
|
2
|
+
export interface ZeegoAccessor {
|
|
3
|
+
readonly isEnabled: boolean;
|
|
4
|
+
readonly state: ZeegoState;
|
|
5
|
+
set(newState: ZeegoState): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function getZeego(): ZeegoAccessor;
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=zeegoState.d.ts.map
|