@tamagui/native 2.0.0-1769256574467 → 2.0.0-1769294704640

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 (149) hide show
  1. package/dist/cjs/components.cjs +3 -3
  2. package/dist/cjs/components.js +3 -3
  3. package/dist/cjs/components.js.map +1 -1
  4. package/dist/cjs/components.native.js +3 -3
  5. package/dist/cjs/components.native.js.map +1 -1
  6. package/dist/cjs/gestureState.cjs +29 -12
  7. package/dist/cjs/gestureState.js +26 -12
  8. package/dist/cjs/gestureState.js.map +1 -1
  9. package/dist/cjs/gestureState.native.js +48 -12
  10. package/dist/cjs/gestureState.native.js.map +1 -1
  11. package/dist/cjs/index.cjs +5 -9
  12. package/dist/cjs/index.js +4 -8
  13. package/dist/cjs/index.js.map +1 -1
  14. package/dist/cjs/index.native.js +5 -9
  15. package/dist/cjs/index.native.js.map +1 -1
  16. package/dist/cjs/portalState.cjs +13 -7
  17. package/dist/cjs/portalState.js +13 -7
  18. package/dist/cjs/portalState.js.map +1 -1
  19. package/dist/cjs/portalState.native.js +13 -7
  20. package/dist/cjs/portalState.native.js.map +1 -1
  21. package/dist/cjs/setup-gesture-handler.cjs +1 -1
  22. package/dist/cjs/setup-gesture-handler.js +1 -1
  23. package/dist/cjs/setup-gesture-handler.js.map +1 -1
  24. package/dist/cjs/setup-gesture-handler.native.js +1 -1
  25. package/dist/cjs/setup-gesture-handler.native.js.map +1 -1
  26. package/dist/cjs/setup-teleport.cjs +15 -0
  27. package/dist/cjs/setup-teleport.js +13 -0
  28. package/dist/cjs/setup-teleport.js.map +6 -0
  29. package/dist/cjs/setup-teleport.native.js +19 -0
  30. package/dist/cjs/setup-teleport.native.js.map +1 -0
  31. package/dist/cjs/setup-worklets.cjs +1 -1
  32. package/dist/cjs/setup-worklets.js +1 -1
  33. package/dist/cjs/setup-worklets.js.map +1 -1
  34. package/dist/cjs/setup-worklets.native.js +1 -1
  35. package/dist/cjs/setup-worklets.native.js.map +1 -1
  36. package/dist/cjs/types.cjs +16 -0
  37. package/dist/cjs/{state.js → types.js} +4 -18
  38. package/dist/cjs/types.js.map +6 -0
  39. package/dist/cjs/types.native.js +19 -0
  40. package/dist/cjs/types.native.js.map +1 -0
  41. package/dist/cjs/workletsState.cjs +14 -12
  42. package/dist/cjs/workletsState.js +14 -12
  43. package/dist/cjs/workletsState.js.map +1 -1
  44. package/dist/cjs/workletsState.native.js +14 -12
  45. package/dist/cjs/workletsState.native.js.map +1 -1
  46. package/dist/esm/components.js +4 -4
  47. package/dist/esm/components.js.map +1 -1
  48. package/dist/esm/components.mjs +4 -4
  49. package/dist/esm/components.mjs.map +1 -1
  50. package/dist/esm/components.native.js +4 -4
  51. package/dist/esm/components.native.js.map +1 -1
  52. package/dist/esm/gestureState.js +26 -12
  53. package/dist/esm/gestureState.js.map +1 -1
  54. package/dist/esm/gestureState.mjs +29 -10
  55. package/dist/esm/gestureState.mjs.map +1 -1
  56. package/dist/esm/gestureState.native.js +48 -10
  57. package/dist/esm/gestureState.native.js.map +1 -1
  58. package/dist/esm/index.js +6 -14
  59. package/dist/esm/index.js.map +1 -1
  60. package/dist/esm/index.mjs +4 -4
  61. package/dist/esm/index.mjs.map +1 -1
  62. package/dist/esm/index.native.js +4 -4
  63. package/dist/esm/index.native.js.map +1 -1
  64. package/dist/esm/portalState.js +13 -7
  65. package/dist/esm/portalState.js.map +1 -1
  66. package/dist/esm/portalState.mjs +13 -6
  67. package/dist/esm/portalState.mjs.map +1 -1
  68. package/dist/esm/portalState.native.js +13 -6
  69. package/dist/esm/portalState.native.js.map +1 -1
  70. package/dist/esm/setup-gesture-handler.js +2 -2
  71. package/dist/esm/setup-gesture-handler.js.map +1 -1
  72. package/dist/esm/setup-gesture-handler.mjs +2 -2
  73. package/dist/esm/setup-gesture-handler.mjs.map +1 -1
  74. package/dist/esm/setup-gesture-handler.native.js +2 -2
  75. package/dist/esm/setup-gesture-handler.native.js.map +1 -1
  76. package/dist/esm/setup-teleport.js +13 -0
  77. package/dist/esm/setup-teleport.js.map +6 -0
  78. package/dist/esm/setup-teleport.mjs +16 -0
  79. package/dist/esm/setup-teleport.mjs.map +1 -0
  80. package/dist/esm/setup-teleport.native.js +17 -0
  81. package/dist/esm/setup-teleport.native.js.map +1 -0
  82. package/dist/esm/setup-worklets.js +2 -2
  83. package/dist/esm/setup-worklets.js.map +1 -1
  84. package/dist/esm/setup-worklets.mjs +2 -2
  85. package/dist/esm/setup-worklets.mjs.map +1 -1
  86. package/dist/esm/setup-worklets.native.js +2 -2
  87. package/dist/esm/setup-worklets.native.js.map +1 -1
  88. package/dist/esm/types.js +1 -0
  89. package/dist/esm/types.js.map +6 -0
  90. package/dist/esm/types.mjs +2 -0
  91. package/dist/esm/types.mjs.map +1 -0
  92. package/dist/esm/types.native.js +2 -0
  93. package/dist/esm/types.native.js.map +1 -0
  94. package/dist/esm/workletsState.js +14 -12
  95. package/dist/esm/workletsState.js.map +1 -1
  96. package/dist/esm/workletsState.mjs +14 -10
  97. package/dist/esm/workletsState.mjs.map +1 -1
  98. package/dist/esm/workletsState.native.js +14 -10
  99. package/dist/esm/workletsState.native.js.map +1 -1
  100. package/package.json +13 -13
  101. package/src/components.tsx +10 -17
  102. package/src/gestureState.ts +67 -14
  103. package/src/index.ts +19 -17
  104. package/src/portalState.ts +17 -9
  105. package/src/setup-gesture-handler.ts +2 -2
  106. package/src/setup-teleport.ts +32 -0
  107. package/src/setup-worklets.ts +2 -2
  108. package/src/types.ts +34 -0
  109. package/src/workletsState.ts +19 -17
  110. package/types/components.d.ts +2 -10
  111. package/types/components.d.ts.map +2 -2
  112. package/types/gestureState.d.ts +16 -8
  113. package/types/gestureState.d.ts.map +2 -2
  114. package/types/index.d.ts +8 -8
  115. package/types/index.d.ts.map +2 -2
  116. package/types/portalState.d.ts +7 -6
  117. package/types/portalState.d.ts.map +2 -2
  118. package/types/setup-gesture-handler.d.ts.map +1 -1
  119. package/types/setup-teleport.d.ts +3 -0
  120. package/types/setup-teleport.d.ts.map +11 -0
  121. package/types/setup-worklets.d.ts.map +1 -1
  122. package/types/types.d.ts +30 -0
  123. package/types/types.d.ts.map +11 -0
  124. package/types/workletsState.d.ts +6 -9
  125. package/types/workletsState.d.ts.map +2 -2
  126. package/dist/cjs/setup.cjs +0 -64
  127. package/dist/cjs/setup.js +0 -50
  128. package/dist/cjs/setup.js.map +0 -6
  129. package/dist/cjs/setup.native.js +0 -72
  130. package/dist/cjs/setup.native.js.map +0 -1
  131. package/dist/cjs/state.cjs +0 -36
  132. package/dist/cjs/state.js.map +0 -6
  133. package/dist/cjs/state.native.js +0 -39
  134. package/dist/cjs/state.native.js.map +0 -1
  135. package/dist/esm/setup.js +0 -34
  136. package/dist/esm/setup.js.map +0 -6
  137. package/dist/esm/setup.mjs +0 -41
  138. package/dist/esm/setup.mjs.map +0 -1
  139. package/dist/esm/setup.native.js +0 -46
  140. package/dist/esm/setup.native.js.map +0 -1
  141. package/dist/esm/state.js +0 -12
  142. package/dist/esm/state.js.map +0 -6
  143. package/dist/esm/state.mjs +0 -12
  144. package/dist/esm/state.mjs.map +0 -1
  145. package/dist/esm/state.native.js +0 -12
  146. package/dist/esm/state.native.js.map +0 -1
  147. package/src/setup-portal.ts +0 -63
  148. package/types/setup-portal.d.ts +0 -3
  149. package/types/setup-portal.d.ts.map +0 -11
@@ -1,11 +1,6 @@
1
- const GLOBAL_KEY = '__tamagui_native_gesture_state__'
1
+ import type { GestureState } from './types'
2
2
 
3
- export interface GestureState {
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,73 @@ function getGlobalState(): GestureState {
20
15
  return g[GLOBAL_KEY]
21
16
  }
22
17
 
23
- export function isGestureHandlerEnabled(): boolean {
24
- return getGlobalState().enabled
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 function getGestureHandlerState(): GestureState {
28
- return getGlobalState()
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 setGestureHandlerState(updates: Partial<GestureState>): void {
32
- const state = getGlobalState()
33
- Object.assign(state, updates)
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 longPressDuration = config.delayLongPress ?? 500
58
+
59
+ // Tap gesture for regular presses
60
+ // Use long maxDuration to not cancel during long presses
61
+ const tap = Gesture.Tap()
62
+ .runOnJS(true)
63
+ .maxDuration(10000) // allow very long presses
64
+ .onBegin((e: any) => config.onPressIn?.(e))
65
+ .onEnd((e: any) => config.onPress?.(e))
66
+ .onFinalize((e: any) => config.onPressOut?.(e))
67
+
68
+ if (config.hitSlop) tap.hitSlop(config.hitSlop)
69
+
70
+ // if no long press handler, just use tap
71
+ if (!config.onLongPress) return tap
72
+
73
+ // LongPress gesture for long press handling
74
+ const longPress = Gesture.LongPress()
75
+ .runOnJS(true)
76
+ .minDuration(longPressDuration)
77
+ .onBegin((e: any) => config.onPressIn?.(e))
78
+ .onStart((e: any) => config.onLongPress?.(e))
79
+ .onFinalize((e: any) => config.onPressOut?.(e))
80
+
81
+ if (config.hitSlop) longPress.hitSlop(config.hitSlop)
82
+
83
+ // exclusive: longPress has priority, tap is fallback for quick presses
84
+ return Gesture.Exclusive(longPress, tap)
85
+ },
86
+ }
34
87
  }
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-portal'
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
- // portal state exports (safe - no side effects)
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 './components'
26
+ } from './types'
27
+
28
+ // portal
29
+ export { getPortal } from './portalState'
30
+ export type { PortalAccessor } from './portalState'
28
31
 
29
- // gesture handler state exports (safe - no side effects)
30
- export {
31
- isGestureHandlerEnabled,
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 state exports (safe - no side effects)
38
- export { isWorkletsEnabled, getWorkletsState } from './workletsState'
39
- export type { WorkletsState } from './workletsState'
36
+ // worklets
37
+ export { getWorklets } from './workletsState'
38
+ export type { WorkletsAccessor } from './workletsState'
39
+
40
+ // components
41
+ export { NativePortal, NativePortalHost, NativePortalProvider } from './components'
@@ -1,15 +1,23 @@
1
- export type NativePortalState = {
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 function setNativePortalState(newState: NativePortalState) {
9
- state = newState
5
+ export interface PortalAccessor {
6
+ readonly isEnabled: boolean
7
+ readonly state: NativePortalState
8
+ set(newState: NativePortalState): void
10
9
  }
11
10
 
12
- export function getNativePortalState(): NativePortalState {
13
- return state
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 { setGestureHandlerState } from './gestureState'
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
- setGestureHandlerState({
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()
@@ -18,7 +18,7 @@
18
18
  * @see https://docs.swmansion.com/react-native-worklets/docs/
19
19
  */
20
20
 
21
- import { setWorkletsState } from './workletsState'
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
- setWorkletsState({
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
+ }
@@ -1,12 +1,6 @@
1
- const GLOBAL_KEY = '__tamagui_native_worklets_state__'
1
+ import type { WorkletsState } from './types'
2
2
 
3
- export interface WorkletsState {
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 function isWorkletsEnabled(): boolean {
26
- return getGlobalState().enabled
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 getWorkletsState(): WorkletsState {
30
- return getGlobalState()
31
- }
32
-
33
- export function setWorkletsState(updates: Partial<WorkletsState>): void {
34
- const state = getGlobalState()
35
- Object.assign(state, updates)
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
  }
@@ -1,14 +1,6 @@
1
1
  import type { ReactNode } from "react";
2
- export type NativePortalProps = {
3
- hostName?: string;
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;AAI/B,YAAY,oBAAoB;CAC9B;CACA,UAAU;;AAGZ,YAAY,wBAAwB;CAClC;;AAGF,YAAY,4BAA4B;CACtC,UAAU;;;;;;AAOZ,OAAO,iBAAS,aAAa,EAC3B,UACA,YACC,oBAAoB;;;;;AAYvB,OAAO,iBAAS,iBAAiB,EAAE,QAAQ,wBAAwB;;;;;AAYnE,OAAO,iBAAS,qBAAqB,EAAE,YAAY,4BAA4B",
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 { getNativePortalState } from './portalState'\n\n// types matching react-native-teleport's API\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\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 = getNativePortalState()\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 = getNativePortalState()\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 = getNativePortalState()\n if (state.type !== 'teleport') return <>{children}</>\n\n const { PortalProvider } = (globalThis as any).__tamagui_teleport\n return <PortalProvider>{children}</PortalProvider>\n}\n"
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
  }
@@ -1,11 +1,19 @@
1
- export interface GestureState {
2
- enabled: boolean;
3
- Gesture: any;
4
- GestureDetector: any;
5
- ScrollView: any;
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 isGestureHandlerEnabled(): boolean;
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": "AAEA,iBAAiB,aAAa;CAC5B;CACA;CACA;CACA;;AAgBF,OAAO,iBAAS;AAIhB,OAAO,iBAAS,0BAA0B;AAI1C,OAAO,iBAAS,uBAAuB,SAAS,QAAQ",
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
- "const GLOBAL_KEY = '__tamagui_native_gesture_state__'\n\nexport interface GestureState {\n enabled: boolean\n Gesture: any\n GestureDetector: any\n ScrollView: any\n}\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 function isGestureHandlerEnabled(): boolean {\n return getGlobalState().enabled\n}\n\nexport function getGestureHandlerState(): GestureState {\n return getGlobalState()\n}\n\nexport function setGestureHandlerState(updates: Partial<GestureState>): void {\n const state = getGlobalState()\n Object.assign(state, updates)\n}\n"
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 longPressDuration = config.delayLongPress ?? 500\n\n // Tap gesture for regular presses\n // Use long maxDuration to not cancel during long presses\n const tap = Gesture.Tap()\n .runOnJS(true)\n .maxDuration(10000) // allow very long presses\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 no long press handler, just use tap\n if (!config.onLongPress) return tap\n\n // LongPress gesture for long press handling\n const longPress = Gesture.LongPress()\n .runOnJS(true)\n .minDuration(longPressDuration)\n .onBegin((e: any) => config.onPressIn?.(e))\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 // exclusive: longPress has priority, tap is fallback for quick presses\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-portal'
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 { getNativePortalState, setNativePortalState } from "./portalState";
18
- export type { NativePortalState } from "./portalState";
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
@@ -1,11 +1,11 @@
1
1
  {
2
- "mappings": ";;;;;;;;;;;;;;;;AAkBA,SAAS,sBAAsB,4BAA4B;AAC3D,cAAc,yBAAyB;AAEvC,SAAS,cAAc,kBAAkB,4BAA4B;AACrE,cACE,mBACA,uBACA,iCACK;AAGP,SACE,yBACA,wBACA,8BACK;AACP,cAAc,oBAAoB;AAGlC,SAAS,mBAAmB,wBAAwB;AACpD,cAAc,qBAAqB",
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-portal'\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// portal state exports (safe - no side effects)\nexport { getNativePortalState, setNativePortalState } from './portalState'\nexport type { NativePortalState } from './portalState'\n\nexport { NativePortal, NativePortalHost, NativePortalProvider } from './components'\nexport type {\n NativePortalProps,\n NativePortalHostProps,\n NativePortalProviderProps,\n} from './components'\n\n// gesture handler state exports (safe - no side effects)\nexport {\n isGestureHandlerEnabled,\n getGestureHandlerState,\n setGestureHandlerState,\n} from './gestureState'\nexport type { GestureState } from './gestureState'\n\n// worklets state exports (safe - no side effects)\nexport { isWorkletsEnabled, getWorkletsState } from './workletsState'\nexport type { WorkletsState } from './workletsState'\n"
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
  }
@@ -1,8 +1,9 @@
1
- export type NativePortalState = {
2
- enabled: boolean;
3
- type: "teleport" | "legacy" | null;
4
- };
5
- export declare function setNativePortalState(newState: NativePortalState);
6
- export declare function getNativePortalState(): NativePortalState;
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,YAAY,oBAAoB;CAC9B;CACA,MAAM,aAAa;;AAKrB,OAAO,iBAAS,qBAAqB,UAAU;AAI/C,OAAO,iBAAS,wBAAwB",
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
- "export type NativePortalState = {\n enabled: boolean\n type: 'teleport' | 'legacy' | null\n}\n\nlet state: NativePortalState = { enabled: false, type: null }\n\nexport function setNativePortalState(newState: NativePortalState) {\n state = newState\n}\n\nexport function getNativePortalState(): NativePortalState {\n return state\n}\n// retrigger ci\n"
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 { setGestureHandlerState } 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 setGestureHandlerState({\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"
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,3 @@
1
+ export {};
2
+
3
+ //# sourceMappingURL=setup-teleport.d.ts.map
@@ -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 { setWorkletsState } 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 setWorkletsState({\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"
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
  }
@@ -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
+ }
@@ -1,12 +1,9 @@
1
- export interface WorkletsState {
2
- enabled: boolean;
3
- Worklets: any;
4
- useRunOnJS: any;
5
- useWorklet: any;
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 isWorkletsEnabled(): boolean;
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": "AAEA,iBAAiB,cAAc;CAC7B;CACA;CACA;CACA;CACA;;AAiBF,OAAO,iBAAS;AAIhB,OAAO,iBAAS,oBAAoB;AAIpC,OAAO,iBAAS,iBAAiB,SAAS,QAAQ",
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
- "const GLOBAL_KEY = '__tamagui_native_worklets_state__'\n\nexport interface WorkletsState {\n enabled: boolean\n Worklets: any\n useRunOnJS: any\n useWorklet: any\n createWorkletContextValue: any\n}\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 function isWorkletsEnabled(): boolean {\n return getGlobalState().enabled\n}\n\nexport function getWorkletsState(): WorkletsState {\n return getGlobalState()\n}\n\nexport function setWorkletsState(updates: Partial<WorkletsState>): void {\n const state = getGlobalState()\n Object.assign(state, updates)\n}\n"
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
  }