@tamagui/native 2.0.0-1769256574467 → 2.0.0-1769288527117
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/components.cjs +3 -3
- package/dist/cjs/components.js +3 -3
- package/dist/cjs/components.js.map +1 -1
- package/dist/cjs/components.native.js +3 -3
- package/dist/cjs/components.native.js.map +1 -1
- package/dist/cjs/gestureState.cjs +28 -12
- package/dist/cjs/gestureState.js +26 -12
- package/dist/cjs/gestureState.js.map +1 -1
- package/dist/cjs/gestureState.native.js +44 -12
- package/dist/cjs/gestureState.native.js.map +1 -1
- package/dist/cjs/index.cjs +5 -9
- package/dist/cjs/index.js +4 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +5 -9
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/portalState.cjs +13 -7
- package/dist/cjs/portalState.js +13 -7
- package/dist/cjs/portalState.js.map +1 -1
- package/dist/cjs/portalState.native.js +13 -7
- package/dist/cjs/portalState.native.js.map +1 -1
- package/dist/cjs/setup-gesture-handler.cjs +1 -1
- package/dist/cjs/setup-gesture-handler.js +1 -1
- package/dist/cjs/setup-gesture-handler.js.map +1 -1
- package/dist/cjs/setup-gesture-handler.native.js +1 -1
- package/dist/cjs/setup-gesture-handler.native.js.map +1 -1
- package/dist/cjs/setup-teleport.cjs +15 -0
- package/dist/cjs/setup-teleport.js +13 -0
- package/dist/cjs/setup-teleport.js.map +6 -0
- package/dist/cjs/setup-teleport.native.js +19 -0
- package/dist/cjs/setup-teleport.native.js.map +1 -0
- package/dist/cjs/setup-worklets.cjs +1 -1
- package/dist/cjs/setup-worklets.js +1 -1
- package/dist/cjs/setup-worklets.js.map +1 -1
- package/dist/cjs/setup-worklets.native.js +1 -1
- package/dist/cjs/setup-worklets.native.js.map +1 -1
- package/dist/cjs/types.cjs +16 -0
- package/dist/cjs/{state.js → types.js} +4 -18
- package/dist/cjs/types.js.map +6 -0
- package/dist/cjs/types.native.js +19 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/cjs/workletsState.cjs +14 -12
- package/dist/cjs/workletsState.js +14 -12
- package/dist/cjs/workletsState.js.map +1 -1
- package/dist/cjs/workletsState.native.js +14 -12
- package/dist/cjs/workletsState.native.js.map +1 -1
- package/dist/esm/components.js +4 -4
- package/dist/esm/components.js.map +1 -1
- package/dist/esm/components.mjs +4 -4
- package/dist/esm/components.mjs.map +1 -1
- package/dist/esm/components.native.js +4 -4
- package/dist/esm/components.native.js.map +1 -1
- package/dist/esm/gestureState.js +26 -12
- package/dist/esm/gestureState.js.map +1 -1
- package/dist/esm/gestureState.mjs +28 -10
- package/dist/esm/gestureState.mjs.map +1 -1
- package/dist/esm/gestureState.native.js +44 -10
- package/dist/esm/gestureState.native.js.map +1 -1
- package/dist/esm/index.js +6 -14
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +4 -4
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +4 -4
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/portalState.js +13 -7
- package/dist/esm/portalState.js.map +1 -1
- package/dist/esm/portalState.mjs +13 -6
- package/dist/esm/portalState.mjs.map +1 -1
- package/dist/esm/portalState.native.js +13 -6
- package/dist/esm/portalState.native.js.map +1 -1
- package/dist/esm/setup-gesture-handler.js +2 -2
- package/dist/esm/setup-gesture-handler.js.map +1 -1
- package/dist/esm/setup-gesture-handler.mjs +2 -2
- package/dist/esm/setup-gesture-handler.mjs.map +1 -1
- package/dist/esm/setup-gesture-handler.native.js +2 -2
- package/dist/esm/setup-gesture-handler.native.js.map +1 -1
- package/dist/esm/setup-teleport.js +13 -0
- package/dist/esm/setup-teleport.js.map +6 -0
- package/dist/esm/setup-teleport.mjs +16 -0
- package/dist/esm/setup-teleport.mjs.map +1 -0
- package/dist/esm/setup-teleport.native.js +17 -0
- package/dist/esm/setup-teleport.native.js.map +1 -0
- package/dist/esm/setup-worklets.js +2 -2
- package/dist/esm/setup-worklets.js.map +1 -1
- package/dist/esm/setup-worklets.mjs +2 -2
- package/dist/esm/setup-worklets.mjs.map +1 -1
- package/dist/esm/setup-worklets.native.js +2 -2
- package/dist/esm/setup-worklets.native.js.map +1 -1
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +6 -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.js +14 -12
- package/dist/esm/workletsState.js.map +1 -1
- package/dist/esm/workletsState.mjs +14 -10
- package/dist/esm/workletsState.mjs.map +1 -1
- package/dist/esm/workletsState.native.js +14 -10
- package/dist/esm/workletsState.native.js.map +1 -1
- package/package.json +13 -13
- package/src/components.tsx +10 -17
- package/src/gestureState.ts +58 -14
- package/src/index.ts +19 -17
- package/src/portalState.ts +17 -9
- package/src/setup-gesture-handler.ts +2 -2
- package/src/setup-teleport.ts +32 -0
- package/src/setup-worklets.ts +2 -2
- package/src/types.ts +34 -0
- package/src/workletsState.ts +19 -17
- package/types/components.d.ts +2 -10
- package/types/components.d.ts.map +2 -2
- package/types/gestureState.d.ts +16 -8
- package/types/gestureState.d.ts.map +2 -2
- package/types/index.d.ts +8 -8
- package/types/index.d.ts.map +2 -2
- package/types/portalState.d.ts +7 -6
- package/types/portalState.d.ts.map +2 -2
- package/types/setup-gesture-handler.d.ts.map +1 -1
- package/types/setup-teleport.d.ts +3 -0
- package/types/setup-teleport.d.ts.map +11 -0
- package/types/setup-worklets.d.ts.map +1 -1
- package/types/types.d.ts +30 -0
- package/types/types.d.ts.map +11 -0
- package/types/workletsState.d.ts +6 -9
- package/types/workletsState.d.ts.map +2 -2
- package/dist/cjs/setup.cjs +0 -64
- package/dist/cjs/setup.js +0 -50
- package/dist/cjs/setup.js.map +0 -6
- package/dist/cjs/setup.native.js +0 -72
- package/dist/cjs/setup.native.js.map +0 -1
- package/dist/cjs/state.cjs +0 -36
- package/dist/cjs/state.js.map +0 -6
- package/dist/cjs/state.native.js +0 -39
- package/dist/cjs/state.native.js.map +0 -1
- package/dist/esm/setup.js +0 -34
- package/dist/esm/setup.js.map +0 -6
- package/dist/esm/setup.mjs +0 -41
- package/dist/esm/setup.mjs.map +0 -1
- package/dist/esm/setup.native.js +0 -46
- package/dist/esm/setup.native.js.map +0 -1
- package/dist/esm/state.js +0 -12
- package/dist/esm/state.js.map +0 -6
- package/dist/esm/state.mjs +0 -12
- package/dist/esm/state.mjs.map +0 -1
- package/dist/esm/state.native.js +0 -12
- package/dist/esm/state.native.js.map +0 -1
- package/src/setup-portal.ts +0 -63
- package/types/setup-portal.d.ts +0 -3
- package/types/setup-portal.d.ts.map +0 -11
package/src/gestureState.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { GestureState } from './types'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
enabled: boolean
|
|
5
|
-
Gesture: any
|
|
6
|
-
GestureDetector: any
|
|
7
|
-
ScrollView: any
|
|
8
|
-
}
|
|
3
|
+
const GLOBAL_KEY = '__tamagui_native_gesture_state__'
|
|
9
4
|
|
|
10
5
|
function getGlobalState(): GestureState {
|
|
11
6
|
const g = globalThis as any
|
|
@@ -20,15 +15,64 @@ function getGlobalState(): GestureState {
|
|
|
20
15
|
return g[GLOBAL_KEY]
|
|
21
16
|
}
|
|
22
17
|
|
|
23
|
-
export
|
|
24
|
-
|
|
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?: any
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export
|
|
28
|
-
|
|
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
|
|
29
33
|
}
|
|
30
34
|
|
|
31
|
-
export function
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
export function getGestureHandler(): GestureHandlerAccessor {
|
|
36
|
+
return {
|
|
37
|
+
get isEnabled(): boolean {
|
|
38
|
+
return getGlobalState().enabled
|
|
39
|
+
},
|
|
40
|
+
get state(): GestureState {
|
|
41
|
+
return getGlobalState()
|
|
42
|
+
},
|
|
43
|
+
set(updates: Partial<GestureState>): void {
|
|
44
|
+
const state = getGlobalState()
|
|
45
|
+
Object.assign(state, updates)
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
disable(): void {
|
|
49
|
+
const state = getGlobalState()
|
|
50
|
+
state.enabled = false
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
createPressGesture(config: PressGestureConfig): any {
|
|
54
|
+
const { Gesture } = getGlobalState()
|
|
55
|
+
if (!Gesture) return null
|
|
56
|
+
|
|
57
|
+
const tap = Gesture.Tap()
|
|
58
|
+
.runOnJS(true) // run callbacks on JS thread
|
|
59
|
+
.onBegin((e: any) => config.onPressIn?.(e))
|
|
60
|
+
.onEnd((e: any) => config.onPress?.(e))
|
|
61
|
+
.onFinalize((e: any) => config.onPressOut?.(e))
|
|
62
|
+
|
|
63
|
+
if (config.hitSlop) tap.hitSlop(config.hitSlop)
|
|
64
|
+
|
|
65
|
+
if (!config.onLongPress) return tap
|
|
66
|
+
|
|
67
|
+
const longPress = Gesture.LongPress()
|
|
68
|
+
.runOnJS(true) // run callbacks on JS thread
|
|
69
|
+
.minDuration(config.delayLongPress ?? 500)
|
|
70
|
+
.onStart((e: any) => config.onLongPress?.(e))
|
|
71
|
+
.onFinalize((e: any) => config.onPressOut?.(e))
|
|
72
|
+
|
|
73
|
+
if (config.hitSlop) longPress.hitSlop(config.hitSlop)
|
|
74
|
+
|
|
75
|
+
return Gesture.Exclusive(longPress, tap)
|
|
76
|
+
},
|
|
77
|
+
}
|
|
34
78
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @example
|
|
7
7
|
* ```tsx
|
|
8
8
|
* // In your app entry (index.js or App.tsx)
|
|
9
|
-
* import '@tamagui/native/setup-
|
|
9
|
+
* import '@tamagui/native/setup-teleport'
|
|
10
10
|
* import '@tamagui/native/setup-gesture-handler'
|
|
11
11
|
* import '@tamagui/native/setup-worklets'
|
|
12
12
|
*
|
|
@@ -15,25 +15,27 @@
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
//
|
|
19
|
-
export { getNativePortalState, setNativePortalState } from './portalState'
|
|
20
|
-
export type { NativePortalState } from './portalState'
|
|
21
|
-
|
|
22
|
-
export { NativePortal, NativePortalHost, NativePortalProvider } from './components'
|
|
18
|
+
// types
|
|
23
19
|
export type {
|
|
20
|
+
NativePortalState,
|
|
21
|
+
GestureState,
|
|
22
|
+
WorkletsState,
|
|
24
23
|
NativePortalProps,
|
|
25
24
|
NativePortalHostProps,
|
|
26
25
|
NativePortalProviderProps,
|
|
27
|
-
} from './
|
|
26
|
+
} from './types'
|
|
27
|
+
|
|
28
|
+
// portal
|
|
29
|
+
export { getPortal } from './portalState'
|
|
30
|
+
export type { PortalAccessor } from './portalState'
|
|
28
31
|
|
|
29
|
-
// gesture handler
|
|
30
|
-
export {
|
|
31
|
-
|
|
32
|
-
getGestureHandlerState,
|
|
33
|
-
setGestureHandlerState,
|
|
34
|
-
} from './gestureState'
|
|
35
|
-
export type { GestureState } from './gestureState'
|
|
32
|
+
// gesture handler
|
|
33
|
+
export { getGestureHandler } from './gestureState'
|
|
34
|
+
export type { GestureHandlerAccessor, PressGestureConfig } from './gestureState'
|
|
36
35
|
|
|
37
|
-
// worklets
|
|
38
|
-
export {
|
|
39
|
-
export type {
|
|
36
|
+
// worklets
|
|
37
|
+
export { getWorklets } from './workletsState'
|
|
38
|
+
export type { WorkletsAccessor } from './workletsState'
|
|
39
|
+
|
|
40
|
+
// components
|
|
41
|
+
export { NativePortal, NativePortalHost, NativePortalProvider } from './components'
|
package/src/portalState.ts
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
enabled: boolean
|
|
3
|
-
type: 'teleport' | 'legacy' | null
|
|
4
|
-
}
|
|
1
|
+
import type { NativePortalState } from './types'
|
|
5
2
|
|
|
6
3
|
let state: NativePortalState = { enabled: false, type: null }
|
|
7
4
|
|
|
8
|
-
export
|
|
9
|
-
|
|
5
|
+
export interface PortalAccessor {
|
|
6
|
+
readonly isEnabled: boolean
|
|
7
|
+
readonly state: NativePortalState
|
|
8
|
+
set(newState: NativePortalState): void
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
export function
|
|
13
|
-
return
|
|
11
|
+
export function getPortal(): PortalAccessor {
|
|
12
|
+
return {
|
|
13
|
+
get isEnabled(): boolean {
|
|
14
|
+
return state.enabled
|
|
15
|
+
},
|
|
16
|
+
get state(): NativePortalState {
|
|
17
|
+
return state
|
|
18
|
+
},
|
|
19
|
+
set(newState: NativePortalState): void {
|
|
20
|
+
state = newState
|
|
21
|
+
},
|
|
22
|
+
}
|
|
14
23
|
}
|
|
15
|
-
// retrigger ci
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* for use with Sheet and other gesture-aware components.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { getGestureHandler } from './gestureState'
|
|
16
16
|
|
|
17
17
|
function setup() {
|
|
18
18
|
const g = globalThis as any
|
|
@@ -27,7 +27,7 @@ function setup() {
|
|
|
27
27
|
const { Gesture, GestureDetector, ScrollView } = rngh
|
|
28
28
|
|
|
29
29
|
if (Gesture && GestureDetector) {
|
|
30
|
-
|
|
30
|
+
getGestureHandler().set({
|
|
31
31
|
enabled: true,
|
|
32
32
|
Gesture,
|
|
33
33
|
GestureDetector,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setup native portal support for Tamagui.
|
|
3
|
+
*
|
|
4
|
+
* Simply import this module at the top of your app entry point:
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* import '@tamagui/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.__tamagui_native_portal_setup) return
|
|
20
|
+
g.__tamagui_native_portal_setup = true
|
|
21
|
+
|
|
22
|
+
// try teleport first (preferred)
|
|
23
|
+
const teleport = require('react-native-teleport')
|
|
24
|
+
if (teleport?.Portal && teleport?.PortalHost && teleport?.PortalProvider) {
|
|
25
|
+
g.__tamagui_teleport = teleport
|
|
26
|
+
getPortal().set({ enabled: true, type: 'teleport' })
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// run setup immediately on import
|
|
32
|
+
setup()
|
package/src/setup-worklets.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* @see https://docs.swmansion.com/react-native-worklets/docs/
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import {
|
|
21
|
+
import { getWorklets } from './workletsState'
|
|
22
22
|
|
|
23
23
|
function setup() {
|
|
24
24
|
const g = globalThis as any
|
|
@@ -32,7 +32,7 @@ function setup() {
|
|
|
32
32
|
const worklets = require('react-native-worklets-core')
|
|
33
33
|
|
|
34
34
|
if (worklets) {
|
|
35
|
-
|
|
35
|
+
getWorklets().set({
|
|
36
36
|
enabled: true,
|
|
37
37
|
Worklets: worklets.Worklets,
|
|
38
38
|
useRunOnJS: worklets.useRunOnJS,
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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 type NativePortalProps = {
|
|
24
|
+
hostName?: string
|
|
25
|
+
children: ReactNode
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type NativePortalHostProps = {
|
|
29
|
+
name: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type NativePortalProviderProps = {
|
|
33
|
+
children: ReactNode
|
|
34
|
+
}
|
package/src/workletsState.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { WorkletsState } from './types'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
enabled: boolean
|
|
5
|
-
Worklets: any
|
|
6
|
-
useRunOnJS: any
|
|
7
|
-
useWorklet: any
|
|
8
|
-
createWorkletContextValue: any
|
|
9
|
-
}
|
|
3
|
+
const GLOBAL_KEY = '__tamagui_native_worklets_state__'
|
|
10
4
|
|
|
11
5
|
function getGlobalState(): WorkletsState {
|
|
12
6
|
const g = globalThis as any
|
|
@@ -22,15 +16,23 @@ function getGlobalState(): WorkletsState {
|
|
|
22
16
|
return g[GLOBAL_KEY]
|
|
23
17
|
}
|
|
24
18
|
|
|
25
|
-
export
|
|
26
|
-
|
|
19
|
+
export interface WorkletsAccessor {
|
|
20
|
+
readonly isEnabled: boolean
|
|
21
|
+
readonly state: WorkletsState
|
|
22
|
+
set(updates: Partial<WorkletsState>): void
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
export function
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
export function getWorklets(): WorkletsAccessor {
|
|
26
|
+
return {
|
|
27
|
+
get isEnabled(): boolean {
|
|
28
|
+
return getGlobalState().enabled
|
|
29
|
+
},
|
|
30
|
+
get state(): WorkletsState {
|
|
31
|
+
return getGlobalState()
|
|
32
|
+
},
|
|
33
|
+
set(updates: Partial<WorkletsState>): void {
|
|
34
|
+
const state = getGlobalState()
|
|
35
|
+
Object.assign(state, updates)
|
|
36
|
+
},
|
|
37
|
+
}
|
|
36
38
|
}
|
package/types/components.d.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
};
|
|
6
|
-
export type NativePortalHostProps = {
|
|
7
|
-
name: string;
|
|
8
|
-
};
|
|
9
|
-
export type NativePortalProviderProps = {
|
|
10
|
-
children: ReactNode;
|
|
11
|
-
};
|
|
2
|
+
import type { NativePortalProps, NativePortalHostProps, NativePortalProviderProps } from "./types";
|
|
3
|
+
export type { NativePortalProps, NativePortalHostProps, NativePortalProviderProps };
|
|
12
4
|
/**
|
|
13
5
|
* Renders children into a teleport Portal when available.
|
|
14
6
|
* Returns null when teleport is not set up (allows fallback handling by caller).
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAAA,cAAc,iBAAiB;
|
|
2
|
+
"mappings": "AAAA,cAAc,iBAAiB;AAE/B,cACE,mBACA,uBACA,iCACK;AAEP,cAAc,mBAAmB,uBAAuB;;;;;AAMxD,OAAO,iBAAS,aAAa,EAC3B,UACA,YACC,oBAAoB;;;;;AAYvB,OAAO,iBAAS,iBAAiB,EAAE,QAAQ,wBAAwB;;;;;AAYnE,OAAO,iBAAS,qBAAqB,EAAE,YAAY,4BAA4B",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/components.tsx"
|
|
6
6
|
],
|
|
7
7
|
"sourcesContent": [
|
|
8
|
-
"import type { ReactNode } from 'react'\nimport {
|
|
8
|
+
"import type { ReactNode } from 'react'\nimport { getPortal } from './portalState'\nimport type {\n NativePortalProps,\n NativePortalHostProps,\n NativePortalProviderProps,\n} from './types'\n\nexport type { NativePortalProps, NativePortalHostProps, NativePortalProviderProps }\n\n/**\n * Renders children into a teleport Portal when available.\n * Returns null when teleport is not set up (allows fallback handling by caller).\n */\nexport function NativePortal({\n hostName = 'root',\n children,\n}: NativePortalProps): ReactNode {\n const state = getPortal().state\n if (state.type !== 'teleport') return null\n\n const { Portal } = (globalThis as any).__tamagui_teleport\n return <Portal hostName={hostName}>{children}</Portal>\n}\n\n/**\n * Renders a teleport PortalHost when available.\n * Returns null when teleport is not set up.\n */\nexport function NativePortalHost({ name }: NativePortalHostProps): ReactNode {\n const state = getPortal().state\n if (state.type !== 'teleport') return null\n\n const { PortalHost } = (globalThis as any).__tamagui_teleport\n return <PortalHost name={name} />\n}\n\n/**\n * Wraps children with teleport PortalProvider when available.\n * Returns children as-is when teleport is not set up.\n */\nexport function NativePortalProvider({ children }: NativePortalProviderProps): ReactNode {\n const state = getPortal().state\n if (state.type !== 'teleport') return <>{children}</>\n\n const { PortalProvider } = (globalThis as any).__tamagui_teleport\n return <PortalProvider>{children}</PortalProvider>\n}\n"
|
|
9
9
|
],
|
|
10
10
|
"version": 3
|
|
11
11
|
}
|
package/types/gestureState.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { GestureState } from "./types";
|
|
2
|
+
export type PressGestureConfig = {
|
|
3
|
+
onPressIn?: (e: any) => void;
|
|
4
|
+
onPressOut?: (e: any) => void;
|
|
5
|
+
onPress?: (e: any) => void;
|
|
6
|
+
onLongPress?: (e: any) => void;
|
|
7
|
+
delayLongPress?: number;
|
|
8
|
+
hitSlop?: any;
|
|
9
|
+
};
|
|
10
|
+
export interface GestureHandlerAccessor {
|
|
11
|
+
readonly isEnabled: boolean;
|
|
12
|
+
readonly state: GestureState;
|
|
13
|
+
set(updates: Partial<GestureState>): void;
|
|
14
|
+
disable(): void;
|
|
15
|
+
createPressGesture(config: PressGestureConfig): any;
|
|
6
16
|
}
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function getGestureHandlerState(): GestureState;
|
|
9
|
-
export declare function setGestureHandlerState(updates: Partial<GestureState>): void;
|
|
17
|
+
export declare function getGestureHandler(): GestureHandlerAccessor;
|
|
10
18
|
|
|
11
19
|
//# sourceMappingURL=gestureState.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "
|
|
2
|
+
"mappings": "AAAA,cAAc,oBAAoB;AAiBlC,YAAY,qBAAqB;CAC/B,aAAa;CACb,cAAc;CACd,WAAW;CACX,eAAe;CACf;CACA;;AAGF,iBAAiB,uBAAuB;UAC7B;UACA,OAAO;CAChB,IAAI,SAAS,QAAQ;CACrB;CACA,mBAAmB,QAAQ;;AAG7B,OAAO,iBAAS,qBAAqB",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/gestureState.ts"
|
|
6
6
|
],
|
|
7
7
|
"sourcesContent": [
|
|
8
|
-
"
|
|
8
|
+
"import type { GestureState } from './types'\n\nconst GLOBAL_KEY = '__tamagui_native_gesture_state__'\n\nfunction getGlobalState(): GestureState {\n const g = globalThis as any\n if (!g[GLOBAL_KEY]) {\n g[GLOBAL_KEY] = {\n enabled: false,\n Gesture: null,\n GestureDetector: null,\n ScrollView: null,\n }\n }\n return g[GLOBAL_KEY]\n}\n\nexport type PressGestureConfig = {\n onPressIn?: (e: any) => void\n onPressOut?: (e: any) => void\n onPress?: (e: any) => void\n onLongPress?: (e: any) => void\n delayLongPress?: number\n hitSlop?: any\n}\n\nexport interface GestureHandlerAccessor {\n readonly isEnabled: boolean\n readonly state: GestureState\n set(updates: Partial<GestureState>): void\n disable(): void\n createPressGesture(config: PressGestureConfig): any\n}\n\nexport function getGestureHandler(): GestureHandlerAccessor {\n return {\n get isEnabled(): boolean {\n return getGlobalState().enabled\n },\n get state(): GestureState {\n return getGlobalState()\n },\n set(updates: Partial<GestureState>): void {\n const state = getGlobalState()\n Object.assign(state, updates)\n },\n\n disable(): void {\n const state = getGlobalState()\n state.enabled = false\n },\n\n createPressGesture(config: PressGestureConfig): any {\n const { Gesture } = getGlobalState()\n if (!Gesture) return null\n\n const tap = Gesture.Tap()\n .runOnJS(true) // run callbacks on JS thread\n .onBegin((e: any) => config.onPressIn?.(e))\n .onEnd((e: any) => config.onPress?.(e))\n .onFinalize((e: any) => config.onPressOut?.(e))\n\n if (config.hitSlop) tap.hitSlop(config.hitSlop)\n\n if (!config.onLongPress) return tap\n\n const longPress = Gesture.LongPress()\n .runOnJS(true) // run callbacks on JS thread\n .minDuration(config.delayLongPress ?? 500)\n .onStart((e: any) => config.onLongPress?.(e))\n .onFinalize((e: any) => config.onPressOut?.(e))\n\n if (config.hitSlop) longPress.hitSlop(config.hitSlop)\n\n return Gesture.Exclusive(longPress, tap)\n },\n }\n}\n"
|
|
9
9
|
],
|
|
10
10
|
"version": 3
|
|
11
11
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @example
|
|
7
7
|
* ```tsx
|
|
8
8
|
* // In your app entry (index.js or App.tsx)
|
|
9
|
-
* import '@tamagui/native/setup-
|
|
9
|
+
* import '@tamagui/native/setup-teleport'
|
|
10
10
|
* import '@tamagui/native/setup-gesture-handler'
|
|
11
11
|
* import '@tamagui/native/setup-worklets'
|
|
12
12
|
*
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
* // Sheet will automatically use native gestures when available
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
export {
|
|
18
|
-
export
|
|
17
|
+
export type { NativePortalState, GestureState, WorkletsState, NativePortalProps, NativePortalHostProps, NativePortalProviderProps } from "./types";
|
|
18
|
+
export { getPortal } from "./portalState";
|
|
19
|
+
export type { PortalAccessor } from "./portalState";
|
|
20
|
+
export { getGestureHandler } from "./gestureState";
|
|
21
|
+
export type { GestureHandlerAccessor, PressGestureConfig } from "./gestureState";
|
|
22
|
+
export { getWorklets } from "./workletsState";
|
|
23
|
+
export type { WorkletsAccessor } from "./workletsState";
|
|
19
24
|
export { NativePortal, NativePortalHost, NativePortalProvider } from "./components";
|
|
20
|
-
export type { NativePortalProps, NativePortalHostProps, NativePortalProviderProps } from "./components";
|
|
21
|
-
export { isGestureHandlerEnabled, getGestureHandlerState, setGestureHandlerState } from "./gestureState";
|
|
22
|
-
export type { GestureState } from "./gestureState";
|
|
23
|
-
export { isWorkletsEnabled, getWorkletsState } from "./workletsState";
|
|
24
|
-
export type { WorkletsState } from "./workletsState";
|
|
25
25
|
|
|
26
26
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": ";;;;;;;;;;;;;;;;AAkBA,
|
|
2
|
+
"mappings": ";;;;;;;;;;;;;;;;AAkBA,cACE,mBACA,cACA,eACA,mBACA,uBACA,iCACK;AAGP,SAAS,iBAAiB;AAC1B,cAAc,sBAAsB;AAGpC,SAAS,yBAAyB;AAClC,cAAc,wBAAwB,0BAA0B;AAGhE,SAAS,mBAAmB;AAC5B,cAAc,wBAAwB;AAGtC,SAAS,cAAc,kBAAkB,4BAA4B",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/index.ts"
|
|
6
6
|
],
|
|
7
7
|
"sourcesContent": [
|
|
8
|
-
"/**\n * @tamagui/native\n *\n * Native setup modules for Tamagui. Import these at the top of your app entry point.\n *\n * @example\n * ```tsx\n * // In your app entry (index.js or App.tsx)\n * import '@tamagui/native/setup-
|
|
8
|
+
"/**\n * @tamagui/native\n *\n * Native setup modules for Tamagui. Import these at the top of your app entry point.\n *\n * @example\n * ```tsx\n * // In your app entry (index.js or App.tsx)\n * import '@tamagui/native/setup-teleport'\n * import '@tamagui/native/setup-gesture-handler'\n * import '@tamagui/native/setup-worklets'\n *\n * // Then use Tamagui components normally\n * // Sheet will automatically use native gestures when available\n * ```\n */\n\n// types\nexport type {\n NativePortalState,\n GestureState,\n WorkletsState,\n NativePortalProps,\n NativePortalHostProps,\n NativePortalProviderProps,\n} from './types'\n\n// portal\nexport { getPortal } from './portalState'\nexport type { PortalAccessor } from './portalState'\n\n// gesture handler\nexport { getGestureHandler } from './gestureState'\nexport type { GestureHandlerAccessor, PressGestureConfig } from './gestureState'\n\n// worklets\nexport { getWorklets } from './workletsState'\nexport type { WorkletsAccessor } from './workletsState'\n\n// components\nexport { NativePortal, NativePortalHost, NativePortalProvider } from './components'\n"
|
|
9
9
|
],
|
|
10
10
|
"version": 3
|
|
11
11
|
}
|
package/types/portalState.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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;
|
|
7
8
|
|
|
8
9
|
//# sourceMappingURL=portalState.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAAA,
|
|
2
|
+
"mappings": "AAAA,cAAc,yBAAyB;AAIvC,iBAAiB,eAAe;UACrB;UACA,OAAO;CAChB,IAAI,UAAU;;AAGhB,OAAO,iBAAS,aAAa",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/portalState.ts"
|
|
6
6
|
],
|
|
7
7
|
"sourcesContent": [
|
|
8
|
-
"
|
|
8
|
+
"import type { NativePortalState } from './types'\n\nlet state: NativePortalState = { enabled: false, type: null }\n\nexport interface PortalAccessor {\n readonly isEnabled: boolean\n readonly state: NativePortalState\n set(newState: NativePortalState): void\n}\n\nexport function getPortal(): PortalAccessor {\n return {\n get isEnabled(): boolean {\n return state.enabled\n },\n get state(): NativePortalState {\n return state\n },\n set(newState: NativePortalState): void {\n state = newState\n },\n }\n}\n"
|
|
9
9
|
],
|
|
10
10
|
"version": 3
|
|
11
11
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"src/setup-gesture-handler.ts"
|
|
6
6
|
],
|
|
7
7
|
"sourcesContent": [
|
|
8
|
-
"/**\n * Setup gesture handler for Tamagui native components.\n *\n * Simply import this module at the top of your app entry point:\n *\n * @example\n * ```tsx\n * import '@tamagui/native/setup-gesture-handler'\n * ```\n *\n * This automatically detects and configures react-native-gesture-handler\n * for use with Sheet and other gesture-aware components.\n */\n\nimport {
|
|
8
|
+
"/**\n * Setup gesture handler for Tamagui native components.\n *\n * Simply import this module at the top of your app entry point:\n *\n * @example\n * ```tsx\n * import '@tamagui/native/setup-gesture-handler'\n * ```\n *\n * This automatically detects and configures react-native-gesture-handler\n * for use with Sheet and other gesture-aware components.\n */\n\nimport { getGestureHandler } from './gestureState'\n\nfunction setup() {\n const g = globalThis as any\n if (g.__tamagui_native_gesture_setup_complete) {\n return\n }\n g.__tamagui_native_gesture_setup_complete = true\n\n try {\n // dynamically require RNGH - it should already be imported by the app\n const rngh = require('react-native-gesture-handler')\n const { Gesture, GestureDetector, ScrollView } = rngh\n\n if (Gesture && GestureDetector) {\n getGestureHandler().set({\n enabled: true,\n Gesture,\n GestureDetector,\n ScrollView: ScrollView || null,\n })\n\n // also set on the legacy key for backward compat with @tamagui/sheet\n g.__tamagui_sheet_gesture_state__ = {\n enabled: true,\n Gesture,\n GestureDetector,\n ScrollView: ScrollView || null,\n }\n }\n } catch {\n // RNGH not available, that's fine\n }\n}\n\n// run setup immediately on import\nsetup()\n"
|
|
9
9
|
],
|
|
10
10
|
"version": 3
|
|
11
11
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mappings": "",
|
|
3
|
+
"names": [],
|
|
4
|
+
"sources": [
|
|
5
|
+
"src/setup-teleport.ts"
|
|
6
|
+
],
|
|
7
|
+
"sourcesContent": [
|
|
8
|
+
"/**\n * Setup native portal support for Tamagui.\n *\n * Simply import this module at the top of your app entry point:\n *\n * @example\n * ```tsx\n * import '@tamagui/native/setup-teleport'\n * ```\n *\n * This automatically detects and configures react-native-teleport for portals.\n * Falls back to legacy RN shims if teleport is not installed.\n */\n\nimport { getPortal } from './portalState'\n\nfunction setup(): void {\n const g = globalThis as any\n if (g.__tamagui_native_portal_setup) return\n g.__tamagui_native_portal_setup = true\n\n // try teleport first (preferred)\n const teleport = require('react-native-teleport')\n if (teleport?.Portal && teleport?.PortalHost && teleport?.PortalProvider) {\n g.__tamagui_teleport = teleport\n getPortal().set({ enabled: true, type: 'teleport' })\n return\n }\n}\n\n// run setup immediately on import\nsetup()\n"
|
|
9
|
+
],
|
|
10
|
+
"version": 3
|
|
11
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"src/setup-worklets.ts"
|
|
6
6
|
],
|
|
7
7
|
"sourcesContent": [
|
|
8
|
-
"/**\n * Setup worklets for Tamagui native components.\n *\n * Simply import this module at the top of your app entry point:\n *\n * @example\n * ```tsx\n * import '@tamagui/native/setup-worklets'\n * ```\n *\n * This automatically detects and configures react-native-worklets-core\n * for use with Sheet and other components that benefit from synchronous\n * native-thread execution.\n *\n * When combined with setup-gesture-handler, Sheet gets native-quality\n * gesture coordination between sheet dragging and scroll views.\n *\n * @see https://docs.swmansion.com/react-native-worklets/docs/\n */\n\nimport {
|
|
8
|
+
"/**\n * Setup worklets for Tamagui native components.\n *\n * Simply import this module at the top of your app entry point:\n *\n * @example\n * ```tsx\n * import '@tamagui/native/setup-worklets'\n * ```\n *\n * This automatically detects and configures react-native-worklets-core\n * for use with Sheet and other components that benefit from synchronous\n * native-thread execution.\n *\n * When combined with setup-gesture-handler, Sheet gets native-quality\n * gesture coordination between sheet dragging and scroll views.\n *\n * @see https://docs.swmansion.com/react-native-worklets/docs/\n */\n\nimport { getWorklets } from './workletsState'\n\nfunction setup() {\n const g = globalThis as any\n if (g.__tamagui_native_worklets_setup_complete) {\n return\n }\n g.__tamagui_native_worklets_setup_complete = true\n\n try {\n // dynamically require worklets-core\n const worklets = require('react-native-worklets-core')\n\n if (worklets) {\n getWorklets().set({\n enabled: true,\n Worklets: worklets.Worklets,\n useRunOnJS: worklets.useRunOnJS,\n useWorklet: worklets.useWorklet,\n createWorkletContextValue: worklets.createWorkletContextValue,\n })\n }\n } catch {\n // worklets not available, that's fine - will fall back to JS thread\n }\n}\n\n// run setup immediately on import\nsetup()\n"
|
|
9
9
|
],
|
|
10
10
|
"version": 3
|
|
11
11
|
}
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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 type NativePortalProps = {
|
|
20
|
+
hostName?: string;
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
};
|
|
23
|
+
export type NativePortalHostProps = {
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
26
|
+
export type NativePortalProviderProps = {
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mappings": "AAAA,cAAc,iBAAiB;AAE/B,YAAY,oBAAoB;CAC9B;CACA,MAAM,aAAa;;AAGrB,iBAAiB,aAAa;CAC5B;CACA;CACA;CACA;;AAGF,iBAAiB,cAAc;CAC7B;CACA;CACA;CACA;CACA;;AAGF,YAAY,oBAAoB;CAC9B;CACA,UAAU;;AAGZ,YAAY,wBAAwB;CAClC;;AAGF,YAAY,4BAA4B;CACtC,UAAU",
|
|
3
|
+
"names": [],
|
|
4
|
+
"sources": [
|
|
5
|
+
"src/types.ts"
|
|
6
|
+
],
|
|
7
|
+
"sourcesContent": [
|
|
8
|
+
"import type { ReactNode } from 'react'\n\nexport type NativePortalState = {\n enabled: boolean\n type: 'teleport' | 'legacy' | null\n}\n\nexport interface GestureState {\n enabled: boolean\n Gesture: any\n GestureDetector: any\n ScrollView: any\n}\n\nexport interface WorkletsState {\n enabled: boolean\n Worklets: any\n useRunOnJS: any\n useWorklet: any\n createWorkletContextValue: any\n}\n\nexport type NativePortalProps = {\n hostName?: string\n children: ReactNode\n}\n\nexport type NativePortalHostProps = {\n name: string\n}\n\nexport type NativePortalProviderProps = {\n children: ReactNode\n}\n"
|
|
9
|
+
],
|
|
10
|
+
"version": 3
|
|
11
|
+
}
|
package/types/workletsState.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
createWorkletContextValue: any;
|
|
1
|
+
import type { WorkletsState } from "./types";
|
|
2
|
+
export interface WorkletsAccessor {
|
|
3
|
+
readonly isEnabled: boolean;
|
|
4
|
+
readonly state: WorkletsState;
|
|
5
|
+
set(updates: Partial<WorkletsState>): void;
|
|
7
6
|
}
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function getWorkletsState(): WorkletsState;
|
|
10
|
-
export declare function setWorkletsState(updates: Partial<WorkletsState>): void;
|
|
7
|
+
export declare function getWorklets(): WorkletsAccessor;
|
|
11
8
|
|
|
12
9
|
//# sourceMappingURL=workletsState.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "
|
|
2
|
+
"mappings": "AAAA,cAAc,qBAAqB;AAkBnC,iBAAiB,iBAAiB;UACvB;UACA,OAAO;CAChB,IAAI,SAAS,QAAQ;;AAGvB,OAAO,iBAAS,eAAe",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/workletsState.ts"
|
|
6
6
|
],
|
|
7
7
|
"sourcesContent": [
|
|
8
|
-
"
|
|
8
|
+
"import type { WorkletsState } from './types'\n\nconst GLOBAL_KEY = '__tamagui_native_worklets_state__'\n\nfunction getGlobalState(): WorkletsState {\n const g = globalThis as any\n if (!g[GLOBAL_KEY]) {\n g[GLOBAL_KEY] = {\n enabled: false,\n Worklets: null,\n useRunOnJS: null,\n useWorklet: null,\n createWorkletContextValue: null,\n }\n }\n return g[GLOBAL_KEY]\n}\n\nexport interface WorkletsAccessor {\n readonly isEnabled: boolean\n readonly state: WorkletsState\n set(updates: Partial<WorkletsState>): void\n}\n\nexport function getWorklets(): WorkletsAccessor {\n return {\n get isEnabled(): boolean {\n return getGlobalState().enabled\n },\n get state(): WorkletsState {\n return getGlobalState()\n },\n set(updates: Partial<WorkletsState>): void {\n const state = getGlobalState()\n Object.assign(state, updates)\n },\n }\n}\n"
|
|
9
9
|
],
|
|
10
10
|
"version": 3
|
|
11
11
|
}
|