@tamagui/native 2.0.0-rc.38 → 2.0.0-rc.38-1775845464754

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.
@@ -1,2 +1,2 @@
1
1
  $ tamagui-build
2
- built @tamagui/native in 767 ms
2
+ built @tamagui/native in 192 ms
@@ -32,6 +32,10 @@ const state = (0, import_globalState.createGlobalState)(`gesture`, {
32
32
  GestureDetector: null,
33
33
  ScrollView: null
34
34
  });
35
+ const pressState = {
36
+ owner: null,
37
+ timestamp: 0
38
+ };
35
39
  function getGestureHandler() {
36
40
  return {
37
41
  get isEnabled() {
@@ -52,16 +56,54 @@ function getGestureHandler() {
52
56
  } = state.get();
53
57
  if (!Gesture) return null;
54
58
  const longPressDuration = config.delayLongPress ?? 500;
59
+ const myToken = {};
60
+ const tryClaimOwnership = () => {
61
+ const now = Date.now();
62
+ if (now - pressState.timestamp > 2e3) {
63
+ pressState.owner = null;
64
+ }
65
+ if (pressState.owner === null) {
66
+ pressState.owner = myToken;
67
+ pressState.timestamp = now;
68
+ }
69
+ return pressState.owner === myToken;
70
+ };
71
+ const isOwner = () => pressState.owner === myToken;
72
+ const releaseOwnership = () => {
73
+ if (pressState.owner === myToken) {
74
+ pressState.owner = null;
75
+ }
76
+ };
55
77
  const tap = Gesture.Tap().runOnJS(true).maxDuration(1e4).onBegin(e => {
56
- config.onPressIn?.(e);
78
+ if (tryClaimOwnership()) {
79
+ config.onPressIn?.(e);
80
+ }
57
81
  }).onEnd(e => {
58
- config.onPress?.(e);
82
+ if (isOwner()) {
83
+ config.onPress?.(e);
84
+ }
59
85
  }).onFinalize(e => {
60
- config.onPressOut?.(e);
86
+ if (isOwner()) {
87
+ config.onPressOut?.(e);
88
+ releaseOwnership();
89
+ }
61
90
  });
62
91
  if (config.hitSlop) tap.hitSlop(config.hitSlop);
63
92
  if (!config.onLongPress) return tap;
64
- const longPress = Gesture.LongPress().runOnJS(true).minDuration(longPressDuration).onBegin(e => config.onPressIn?.(e)).onStart(e => config.onLongPress?.(e)).onFinalize(e => config.onPressOut?.(e));
93
+ const longPress = Gesture.LongPress().runOnJS(true).minDuration(longPressDuration).onBegin(e => {
94
+ if (tryClaimOwnership()) {
95
+ config.onPressIn?.(e);
96
+ }
97
+ }).onStart(e => {
98
+ if (isOwner()) {
99
+ config.onLongPress?.(e);
100
+ }
101
+ }).onFinalize(e => {
102
+ if (isOwner()) {
103
+ config.onPressOut?.(e);
104
+ releaseOwnership();
105
+ }
106
+ });
65
107
  if (config.hitSlop) longPress.hitSlop(config.hitSlop);
66
108
  return Gesture.Exclusive(longPress, tap);
67
109
  }
@@ -34,6 +34,10 @@ var state = (0, import_globalState.createGlobalState)(`gesture`, {
34
34
  GestureDetector: null,
35
35
  ScrollView: null
36
36
  });
37
+ var pressState = {
38
+ owner: null,
39
+ timestamp: 0
40
+ };
37
41
  function getGestureHandler() {
38
42
  return {
39
43
  get isEnabled() {
@@ -55,27 +59,61 @@ function getGestureHandler() {
55
59
  if (!Gesture) return null;
56
60
  var _config_delayLongPress;
57
61
  var longPressDuration = (_config_delayLongPress = config.delayLongPress) !== null && _config_delayLongPress !== void 0 ? _config_delayLongPress : 500;
62
+ var myToken = {};
63
+ var tryClaimOwnership = function () {
64
+ var now = Date.now();
65
+ if (now - pressState.timestamp > 2e3) {
66
+ pressState.owner = null;
67
+ }
68
+ if (pressState.owner === null) {
69
+ pressState.owner = myToken;
70
+ pressState.timestamp = now;
71
+ }
72
+ return pressState.owner === myToken;
73
+ };
74
+ var isOwner = function () {
75
+ return pressState.owner === myToken;
76
+ };
77
+ var releaseOwnership = function () {
78
+ if (pressState.owner === myToken) {
79
+ pressState.owner = null;
80
+ }
81
+ };
58
82
  var tap = Gesture.Tap().runOnJS(true).maxDuration(1e4).onBegin(function (e) {
59
- var _config_onPressIn;
60
- (_config_onPressIn = config.onPressIn) === null || _config_onPressIn === void 0 ? void 0 : _config_onPressIn.call(config, e);
83
+ if (tryClaimOwnership()) {
84
+ var _config_onPressIn;
85
+ (_config_onPressIn = config.onPressIn) === null || _config_onPressIn === void 0 ? void 0 : _config_onPressIn.call(config, e);
86
+ }
61
87
  }).onEnd(function (e) {
62
- var _config_onPress;
63
- (_config_onPress = config.onPress) === null || _config_onPress === void 0 ? void 0 : _config_onPress.call(config, e);
88
+ if (isOwner()) {
89
+ var _config_onPress;
90
+ (_config_onPress = config.onPress) === null || _config_onPress === void 0 ? void 0 : _config_onPress.call(config, e);
91
+ }
64
92
  }).onFinalize(function (e) {
65
- var _config_onPressOut;
66
- (_config_onPressOut = config.onPressOut) === null || _config_onPressOut === void 0 ? void 0 : _config_onPressOut.call(config, e);
93
+ if (isOwner()) {
94
+ var _config_onPressOut;
95
+ (_config_onPressOut = config.onPressOut) === null || _config_onPressOut === void 0 ? void 0 : _config_onPressOut.call(config, e);
96
+ releaseOwnership();
97
+ }
67
98
  });
68
99
  if (config.hitSlop) tap.hitSlop(config.hitSlop);
69
100
  if (!config.onLongPress) return tap;
70
101
  var longPress = Gesture.LongPress().runOnJS(true).minDuration(longPressDuration).onBegin(function (e) {
71
- var _config_onPressIn;
72
- return (_config_onPressIn = config.onPressIn) === null || _config_onPressIn === void 0 ? void 0 : _config_onPressIn.call(config, e);
102
+ if (tryClaimOwnership()) {
103
+ var _config_onPressIn;
104
+ (_config_onPressIn = config.onPressIn) === null || _config_onPressIn === void 0 ? void 0 : _config_onPressIn.call(config, e);
105
+ }
73
106
  }).onStart(function (e) {
74
- var _config_onLongPress;
75
- return (_config_onLongPress = config.onLongPress) === null || _config_onLongPress === void 0 ? void 0 : _config_onLongPress.call(config, e);
107
+ if (isOwner()) {
108
+ var _config_onLongPress;
109
+ (_config_onLongPress = config.onLongPress) === null || _config_onLongPress === void 0 ? void 0 : _config_onLongPress.call(config, e);
110
+ }
76
111
  }).onFinalize(function (e) {
77
- var _config_onPressOut;
78
- return (_config_onPressOut = config.onPressOut) === null || _config_onPressOut === void 0 ? void 0 : _config_onPressOut.call(config, e);
112
+ if (isOwner()) {
113
+ var _config_onPressOut;
114
+ (_config_onPressOut = config.onPressOut) === null || _config_onPressOut === void 0 ? void 0 : _config_onPressOut.call(config, e);
115
+ releaseOwnership();
116
+ }
79
117
  });
80
118
  if (config.hitSlop) longPress.hitSlop(config.hitSlop);
81
119
  return Gesture.Exclusive(longPress, tap);
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","gestureState_exports","__export","getGestureHandler","module","exports","import_globalState","require","state","createGlobalState","enabled","Gesture","GestureDetector","ScrollView","isEnabled","get","set","updates","Object","assign","disable","createPressGesture","config","_config_delayLongPress","longPressDuration","delayLongPress","tap","Tap","runOnJS","maxDuration","onBegin","e","_config_onPressIn","onPressIn","call","onEnd","_config_onPress","onPress","onFinalize","_config_onPressOut","onPressOut","hitSlop","onLongPress","longPress","LongPress","minDuration"],"sources":["../../src/gestureState.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,oBAAA;AAAAC,QAAA,CAAAD,oBAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAkC,CAAAK,oBAAA;AAGlC,IAAAK,kBAAc,GAAAC,OAAA;AAA2C,IACvDC,KAAA,GAAS,IAAAF,kBAAA,CAAAG,iBAAA;EACTC,OAAA,EAAS;EACTC,OAAA;EACAC,eAAY;EACbC,UAAA;AA0BM;AACL,SAAOV,kBAAA;EAAA,OACD;IACF,IAAAW,SAAOA,CAAA,EAAM;MACf,OAAAN,KAAA,CAAAO,GAAA,GAAAL,OAAA;IACA;IACE,IAAAF,KAAOA,CAAA;MACT,OAAAA,KAAA,CAAAO,GAAA;IACA;IACEC,IAAAC,OAAO;MACTC,MAAA,CAAAC,MAAA,CAAAX,KAAA,CAAAO,GAAA,I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getGestureHandler","module","exports","import_globalState","require","state","createGlobalState","enabled","Gesture","GestureDetector","ScrollView","pressState","owner","timestamp","isEnabled","get","set","updates","Object","assign","disable","createPressGesture","config","_config_delayLongPress","longPressDuration","delayLongPress","myToken","tryClaimOwnership","now","Date","isOwner","releaseOwnership","tap","Tap","runOnJS","maxDuration","onBegin","e","_config_onPressIn","onPressIn","call","onEnd","_config_onPress","onPress","onFinalize","_config_onPressOut","onPressOut","hitSlop","onLongPress","longPress","LongPress","minDuration","onStart","_config_onLongPress"],"sources":["../../src/gestureState.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,oBAAA;AAAAC,QAAA,CAAAD,oBAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAkC,CAAAK,oBAAA;AAGlC,IAAAK,kBAAc,GAAAC,OAAA;AAA2C,IACvDC,KAAA,GAAS,IAAAF,kBAAA,CAAAG,iBAAA;EACTC,OAAA,EAAS;EACTC,OAAA;EACAC,eAAY;EACbC,UAAA;AAOD;AAAmB,IACjBC,UAAO;EACPC,KAAA,MAAW;EACbC,SAAA;AA0BO;AACL,SAAOb,kBAAA;EAAA,OACD;IACF,IAAAc,SAAOA,CAAA,EAAM;MACf,OAAAT,KAAA,CAAAU,GAAA,GAAAR,OAAA;IACA;IACE,IAAAF,KAAOA,CAAA;MACT,OAAAA,KAAA,CAAAU,GAAA;IACA;IACEC,IAAAC,OAAO;MACTC,MAAA,CAAAC,MAAA,CAAAd,KAAA,CAAAU,GAAA,IAAAE,OAAA;IAEA;IACEG,QAAA,EAAM;MACRf,KAAA,CAAAU,GAAA,GAAAR,OAAA;IAEA;IACEc,kBAAgBA,CAAAC,MAAI;MACpB,IAAI;QAACd;MAAS,IAAAH,KAAO,CAAA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;QAGxB,IAAKP,OAAO;UAGZ,IAAMe,kBAAoB;UAItB,CAAAA,kBAAI,GAAkBvB,MAAG,CAAAwB,UAAA,cAAAD,kBAAA,uBAAAA,kBAAA,CAAAL,IAAA,CAAAlB,MAAA,EAAAe,CAAA;UACvBN,gBAAO;QACT;MACF,CAAC;MAEC,IAAAT,MAAI,CAAAyB,OAAW,EAAAf,GAAA,CAAAe,OAAA,CAAAzB,MAAA,CAAAyB,OAAA;MACb,KAAAzB,MAAO,CAAA0B,WAAA,EAAc,OAAChB,GAAA;MAAA,IACxBiB,SAAA,GAAAzC,OAAA,CAAA0C,SAAA,GAAAhB,OAAA,OAAAiB,WAAA,CAAA3B,iBAAA,EAAAY,OAAA,WAAAC,CAAA;QACD,IACAV,iBAAuB;UACtB,IAAIW,iBAAW;UACb,CAAAA,iBAAO,GAAchB,MAAA,CAAAiB,SAAA,cAAAD,iBAAA,uBAAAA,iBAAA,CAAAE,IAAA,CAAAlB,MAAA,EAAAe,CAAA;QACrB;MAAiB,EACnB,CAAAe,OAAA,WAAAf,CAAA;QACD,IAAAP,OAAA;UAEC,IAAAuB,mBAAgB;UAGpB,CAAAA,mBAAe,GAAU/B,MAAA,CAAA0B,WAAc,cAAAK,mBAAA,uBAAAA,mBAAA,CAAAb,IAAA,CAAAlB,MAAA,EAAAe,CAAA;QACzC;MACF,GAAAO,UAAA,WAAAP,CAAA;QACF,IAAAP,OAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","NativeMenuContext","import_nativeMenuContext","NativePortal","import_components","NativePortalHost","NativePortalProvider","getBurnt","import_burntState","getGestureHandler","import_gestureState","getKeyboardControllerState","import_keyboardControllerState","getLinearGradient","import_linearGradientState","getPortal","import_portalState","getSafeArea","import_safeAreaState","getWorklets","import_workletsState","getZeego","import_zeegoState","isKeyboardControllerEnabled","setKeyboardControllerState","module","exports","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"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,iBAAA,GAAAK,OAAkC;AAGlC,IAAAzB,wBAAyB,GAAAyB,OAAA;AAIzB,IAAAnB,iBAAA,GAAqEmB,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","NativeMenuContext","import_nativeMenuContext","NativePortal","import_components","NativePortalHost","NativePortalProvider","getBurnt","import_burntState","getGestureHandler","import_gestureState","getKeyboardControllerState","import_keyboardControllerState","getLinearGradient","import_linearGradientState","getPortal","import_portalState","getSafeArea","import_safeAreaState","getWorklets","import_workletsState","getZeego","import_zeegoState","isKeyboardControllerEnabled","setKeyboardControllerState","module","exports","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAC,wBAAA,CAAAD,iBAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAC,iBAAA,CAAAD,YAAA;EAAAE,gBAAA,EAAAA,CAAA,KAAAD,iBAAA,CAAAC,gBAAA;EAAAC,oBAAA,EAAAA,CAAA,KAAAF,iBAAA,CAAAE,oBAAA;EAAAC,QAAA,EAAAA,CAAA,KAAAC,iBAAA,CAAAD,QAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAC,mBAAA,CAAAD,iBAAA;EAAAE,0BAAA,EAAAA,CAAA,KAAAC,8BAAA,CAAAD,0BAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAC,0BAAA,CAAAD,iBAAA;EAAAE,SAAA,EAAAA,CAAA,KAAAC,kBAAA,CAAAD,SAAA;EAAAE,WAAA,EAAAA,CAAA,KAAAC,oBAAA,CAAAD,WAAA;EAAAE,WAAA,EAAAA,CAAA,KAAAC,oBAAA,CAAAD,WAAA;EAAAE,QAAA,EAAAA,CAAA,KAAAC,iBAAA,CAAAD,QAAA;EAAAE,2BAAA,EAAAA,CAAA,KAAAX,8BAAA,CAAAW,2BAAA;EAAAC,0BAAA,EAAAA,CAAA,KAAAZ,8BAAA,CAAAY;AAAA;AAuCAC,MAAA,CAAAC,OAAA,GAAAhC,YAA0B,CAAAK,aAAA;AAI1B,IAAAiB,kBAAA,GAAAW,OAAkC;AAOlC,IAAAjB,mBAAA,GAAAiB,OAA4B;AAI5B,IAAAP,oBAAA,GAA4BO,OAAA;AAI5B,IAAAT,oBAAA,GAAAS,OAAkC;AAIlC,IAAAb,0BAAA,GAAAa,OAIO;AAIP,IAAAf,8BAAyB,GAAAe,OAAA;AAEzB,IAAAL,iBAAA,GAAAK,OAAkC;AAGlC,IAAAzB,wBAAyB,GAAAyB,OAAA;AAIzB,IAAAnB,iBAAA,GAAqEmB,OAAA","ignoreList":[]}
@@ -1,9 +1,45 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: true
22
+ }), mod);
23
+ var setup_gesture_handler_exports = {};
24
+ __export(setup_gesture_handler_exports, {
25
+ getGestureHandlerConfig: () => getGestureHandlerConfig,
26
+ setupGestureHandler: () => setupGestureHandler
27
+ });
28
+ module.exports = __toCommonJS(setup_gesture_handler_exports);
1
29
  var import_gestureState = require("./gestureState.cjs");
2
- function setup() {
30
+ let currentConfig = {
31
+ pressEvents: true,
32
+ sheet: true
33
+ };
34
+ function getGestureHandlerConfig() {
35
+ return currentConfig;
36
+ }
37
+ function setupGestureHandler(config) {
3
38
  const g = globalThis;
4
- if (g.__tamagui_native_gesture_setup_complete) {
5
- return;
39
+ if (config) {
40
+ currentConfig = config;
6
41
  }
42
+ const isFirstRun = !g.__tamagui_native_gesture_setup_complete;
7
43
  g.__tamagui_native_gesture_setup_complete = true;
8
44
  try {
9
45
  const rngh = require("react-native-gesture-handler");
@@ -14,13 +50,13 @@ function setup() {
14
50
  } = rngh;
15
51
  if (Gesture && GestureDetector) {
16
52
  (0, import_gestureState.getGestureHandler)().set({
17
- enabled: true,
53
+ enabled: currentConfig.pressEvents !== false,
18
54
  Gesture,
19
55
  GestureDetector,
20
56
  ScrollView: ScrollView || null
21
57
  });
22
58
  g.__tamagui_sheet_gesture_state__ = {
23
- enabled: true,
59
+ enabled: currentConfig.sheet !== false,
24
60
  Gesture,
25
61
  GestureDetector,
26
62
  ScrollView: ScrollView || null
@@ -28,4 +64,4 @@ function setup() {
28
64
  }
29
65
  } catch {}
30
66
  }
31
- setup();
67
+ setupGestureHandler();
@@ -1,11 +1,47 @@
1
1
  "use strict";
2
2
 
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
+ value: true
24
+ }), mod);
25
+ var setup_gesture_handler_exports = {};
26
+ __export(setup_gesture_handler_exports, {
27
+ getGestureHandlerConfig: () => getGestureHandlerConfig,
28
+ setupGestureHandler: () => setupGestureHandler
29
+ });
30
+ module.exports = __toCommonJS(setup_gesture_handler_exports);
3
31
  var import_gestureState = require("./gestureState.native.js");
4
- function setup() {
32
+ var currentConfig = {
33
+ pressEvents: true,
34
+ sheet: true
35
+ };
36
+ function getGestureHandlerConfig() {
37
+ return currentConfig;
38
+ }
39
+ function setupGestureHandler(config) {
5
40
  var g = globalThis;
6
- if (g.__tamagui_native_gesture_setup_complete) {
7
- return;
41
+ if (config) {
42
+ currentConfig = config;
8
43
  }
44
+ var isFirstRun = !g.__tamagui_native_gesture_setup_complete;
9
45
  g.__tamagui_native_gesture_setup_complete = true;
10
46
  try {
11
47
  var rngh = require("react-native-gesture-handler");
@@ -16,13 +52,13 @@ function setup() {
16
52
  } = rngh;
17
53
  if (Gesture && GestureDetector) {
18
54
  (0, import_gestureState.getGestureHandler)().set({
19
- enabled: true,
55
+ enabled: currentConfig.pressEvents !== false,
20
56
  Gesture,
21
57
  GestureDetector,
22
58
  ScrollView: ScrollView || null
23
59
  });
24
60
  g.__tamagui_sheet_gesture_state__ = {
25
- enabled: true,
61
+ enabled: currentConfig.sheet !== false,
26
62
  Gesture,
27
63
  GestureDetector,
28
64
  ScrollView: ScrollView || null
@@ -30,5 +66,5 @@ function setup() {
30
66
  }
31
67
  } catch (e) {}
32
68
  }
33
- setup();
69
+ setupGestureHandler();
34
70
  //# sourceMappingURL=setup-gesture-handler.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["import_gestureState","require","setup","g","globalThis","__tamagui_native_gesture_setup_complete","rngh","Gesture","GestureDetector","ScrollView","getGestureHandler","set","enabled","__tamagui_sheet_gesture_state__","e"],"sources":["../../src/setup-gesture-handler.ts"],"sourcesContent":[null],"mappings":"AAcA;;AAEA,IAAAA,mBAAiB,GAAAC,OAAA;AACf,SAAMC,KAAIA,CAAA;EACV,IAAIC,CAAA,GAAEC,UAAA;EACJ,IAAAD,CAAA,CAAAE,uCAAA;IACF;EACA;EAEAF,CAAA,CAAAE,uCAAI;EAEF;IACA,IAAAC,IAAQ,GAAAL,OAAS,+BAAgC;IAEjD,IAAI;MAAAM,OAAA;MAAWC,eAAA;MAAiBC;IAAA,IAAAH,IAAA;IAC9B,IAAAC,OAAA,IAAAC,eAAA;MAAwB,EACtB,EAAAR,mBAAS,CAAAU,iBAAA,IAAAC,GAAA;QACTC,OAAA;QACAL,OAAA;QACAC,eAAY;QACbC,UAAA,EAAAA,UAAA;MAGD,EAAE;MAAkCN,CAAA,CAClCU,+BAAS;QACTD,OAAA;QACAL,OAAA;QACAC,eAAY;QACdC,UAAA,EAAAA,UAAA;MACF;IACF;EAEA,SAAAK,CAAA,GACF;AAGA","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","setup_gesture_handler_exports","__export","getGestureHandlerConfig","setupGestureHandler","module","exports","import_gestureState","require","currentConfig","pressEvents","sheet","config","g","globalThis","isFirstRun","__tamagui_native_gesture_setup_complete","rngh","Gesture","GestureDetector","ScrollView","getGestureHandler","set","enabled","__tamagui_sheet_gesture_state__","e"],"sources":["../../src/setup-gesture-handler.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,6BAAA;AAAAC,QAAA,CAAAD,6BAAA;EAAAE,uBAAA,EAAAA,CAAA,KAAAA,uBAAA;EAAAC,mBAAA,EAAAA,CAAA,KAAAA;AAAA;AAmBAC,MAAA,CAAAC,OAAA,GAAAV,YAAkC,CAAAK,6BAAA;AASlC,IAAIM,mBAAsC,GAAAC,OAAA;AAAA,IACxCC,aAAa;EACbC,WAAO;EACTC,KAAA;AAEO;AACL,SAAOR,wBAAA;EACT,OAAAM,aAAA;AAEO;AACL,SAAML,mBAAIA,CAAAQ,MAAA;EAGV,IAAIC,CAAA,GAAAC,UAAQ;EACV,IAAAF,MAAA;IACFH,aAAA,GAAAG,MAAA;EAGA;EACA,IAAEG,UAAA,IAAAF,CAAA,CAAAG,uCAA0C;EAE5CH,CAAA,CAAAG,uCAAI;EAEF;IACA,IAAAC,IAAQ,GAAAT,OAAS,+BAAgC;IAEjD,IAAI;MAAAU,OAAA;MAAWC,eAAA;MAAiBC;IAAA,IAAAH,IAAA;IAE9B,IAAAC,OAAA,IAAAC,eAAA;MAAwB,EACtB,EAAAZ,mBAAS,CAAAc,iBAA8B,IAAAC,GAAA;QACvCC,OAAA,EAAAd,aAAA,CAAAC,WAAA;QACAQ,OAAA;QACAC,eAAY;QACbC,UAAA,EAAAA,UAAA;MAGD,EAAE;MAAkCP,CAAA,CAClCW,+BAAuB,GAAU;QACjCD,OAAA,EAAAd,aAAA,CAAAE,KAAA;QACAO,OAAA;QACAC,eAAY;QACdC,UAAA,EAAAA,UAAA;MACF;IACF;EAEA,SAAAK,CAAA,GACF;AAGA","ignoreList":[]}
@@ -5,6 +5,10 @@ const state = createGlobalState(`gesture`, {
5
5
  GestureDetector: null,
6
6
  ScrollView: null
7
7
  });
8
+ const pressState = {
9
+ owner: null,
10
+ timestamp: 0
11
+ };
8
12
  function getGestureHandler() {
9
13
  return {
10
14
  get isEnabled() {
@@ -25,16 +29,54 @@ function getGestureHandler() {
25
29
  } = state.get();
26
30
  if (!Gesture) return null;
27
31
  const longPressDuration = config.delayLongPress ?? 500;
32
+ const myToken = {};
33
+ const tryClaimOwnership = () => {
34
+ const now = Date.now();
35
+ if (now - pressState.timestamp > 2e3) {
36
+ pressState.owner = null;
37
+ }
38
+ if (pressState.owner === null) {
39
+ pressState.owner = myToken;
40
+ pressState.timestamp = now;
41
+ }
42
+ return pressState.owner === myToken;
43
+ };
44
+ const isOwner = () => pressState.owner === myToken;
45
+ const releaseOwnership = () => {
46
+ if (pressState.owner === myToken) {
47
+ pressState.owner = null;
48
+ }
49
+ };
28
50
  const tap = Gesture.Tap().runOnJS(true).maxDuration(1e4).onBegin(e => {
29
- config.onPressIn?.(e);
51
+ if (tryClaimOwnership()) {
52
+ config.onPressIn?.(e);
53
+ }
30
54
  }).onEnd(e => {
31
- config.onPress?.(e);
55
+ if (isOwner()) {
56
+ config.onPress?.(e);
57
+ }
32
58
  }).onFinalize(e => {
33
- config.onPressOut?.(e);
59
+ if (isOwner()) {
60
+ config.onPressOut?.(e);
61
+ releaseOwnership();
62
+ }
34
63
  });
35
64
  if (config.hitSlop) tap.hitSlop(config.hitSlop);
36
65
  if (!config.onLongPress) return tap;
37
- const longPress = Gesture.LongPress().runOnJS(true).minDuration(longPressDuration).onBegin(e => config.onPressIn?.(e)).onStart(e => config.onLongPress?.(e)).onFinalize(e => config.onPressOut?.(e));
66
+ const longPress = Gesture.LongPress().runOnJS(true).minDuration(longPressDuration).onBegin(e => {
67
+ if (tryClaimOwnership()) {
68
+ config.onPressIn?.(e);
69
+ }
70
+ }).onStart(e => {
71
+ if (isOwner()) {
72
+ config.onLongPress?.(e);
73
+ }
74
+ }).onFinalize(e => {
75
+ if (isOwner()) {
76
+ config.onPressOut?.(e);
77
+ releaseOwnership();
78
+ }
79
+ });
38
80
  if (config.hitSlop) longPress.hitSlop(config.hitSlop);
39
81
  return Gesture.Exclusive(longPress, tap);
40
82
  }
@@ -1 +1 @@
1
- {"version":3,"names":["createGlobalState","state","enabled","Gesture","GestureDetector","ScrollView","getGestureHandler","isEnabled","get","set","updates","Object","assign","disable","createPressGesture","config","longPressDuration","delayLongPress","tap","Tap","runOnJS","maxDuration","onBegin","e","onPressIn","onEnd","onPress","onFinalize","onPressOut","hitSlop","onLongPress","longPress","LongPress","minDuration","onStart","Exclusive"],"sources":["../../src/gestureState.ts"],"sourcesContent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C,MAAMa,SAAA,GAAY5B,OAAA,CAAQ6B,SAAA,CAAU,EACjCZ,OAAA,CAAQ,IAAI,EACZa,WAAA,CAAYjB,iBAAiB,EAC7BM,OAAA,CAASC,CAAA,IAAWR,MAAA,CAAOS,SAAA,GAAYD,CAAC,CAAC,EACzCW,OAAA,CAASX,CAAA,IAAWR,MAAA,CAAOe,WAAA,GAAcP,CAAC,CAAC,EAC3CI,UAAA,CAAYJ,CAAA,IAAWR,MAAA,CAAOa,UAAA,GAAaL,CAAC,CAAC;MAEhD,IAAIR,MAAA,CAAOc,OAAA,EAASE,SAAA,CAAUF,OAAA,CAAQd,MAAA,CAAOc,OAAO;MAGpD,OAAO1B,OAAA,CAAQgC,SAAA,CAAUJ,SAAA,EAAWb,GAAG;IACzC;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"names":["createGlobalState","state","enabled","Gesture","GestureDetector","ScrollView","pressState","owner","timestamp","getGestureHandler","isEnabled","get","set","updates","Object","assign","disable","createPressGesture","config","longPressDuration","delayLongPress","myToken","tryClaimOwnership","now","Date","isOwner","releaseOwnership","tap","Tap","runOnJS","maxDuration","onBegin","e","onPressIn","onEnd","onPress","onFinalize","onPressOut","hitSlop","onLongPress","longPress","LongPress","minDuration","onStart","Exclusive"],"sources":["../../src/gestureState.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,iBAAA,QAAyB;AAGlC,MAAMC,KAAA,GAAQD,iBAAA,CAAgC,WAAW;EACvDE,OAAA,EAAS;EACTC,OAAA,EAAS;EACTC,eAAA,EAAiB;EACjBC,UAAA,EAAY;AACd,CAAC;AAOD,MAAMC,UAAA,GAAa;EACjBC,KAAA,EAAO;EACPC,SAAA,EAAW;AACb;AA0BO,SAASC,kBAAA,EAA4C;EAC1D,OAAO;IACL,IAAIC,UAAA,EAAqB;MACvB,OAAOT,KAAA,CAAMU,GAAA,CAAI,EAAET,OAAA;IACrB;IACA,IAAID,MAAA,EAAsB;MACxB,OAAOA,KAAA,CAAMU,GAAA,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,KAAA,CAAOF,CAAA,IAAW;QACjB,IAAIP,OAAA,CAAQ,GAAG;UACbP,MAAA,CAAOiB,OAAA,GAAUH,CAAC;QACpB;MACF,CAAC,EACAI,UAAA,CAAYJ,CAAA,IAAW;QACtB,IAAIP,OAAA,CAAQ,GAAG;UACbP,MAAA,CAAOmB,UAAA,GAAaL,CAAC;UACrBN,gBAAA,CAAiB;QACnB;MACF,CAAC;MAEH,IAAIR,MAAA,CAAOoB,OAAA,EAASX,GAAA,CAAIW,OAAA,CAAQpB,MAAA,CAAOoB,OAAO;MAG9C,IAAI,CAACpB,MAAA,CAAOqB,WAAA,EAAa,OAAOZ,GAAA;MAGhC,MAAMa,SAAA,GAAYrC,OAAA,CAAQsC,SAAA,CAAU,EACjCZ,OAAA,CAAQ,IAAI,EACZa,WAAA,CAAYvB,iBAAiB,EAC7BY,OAAA,CAASC,CAAA,IAAW;QACnB,IAAIV,iBAAA,CAAkB,GAAG;UACvBJ,MAAA,CAAOe,SAAA,GAAYD,CAAC;QACtB;MACF,CAAC,EACAW,OAAA,CAASX,CAAA,IAAW;QACnB,IAAIP,OAAA,CAAQ,GAAG;UACbP,MAAA,CAAOqB,WAAA,GAAcP,CAAC;QACxB;MACF,CAAC,EACAI,UAAA,CAAYJ,CAAA,IAAW;QACtB,IAAIP,OAAA,CAAQ,GAAG;UACbP,MAAA,CAAOmB,UAAA,GAAaL,CAAC;UACrBN,gBAAA,CAAiB;QACnB;MACF,CAAC;MAEH,IAAIR,MAAA,CAAOoB,OAAA,EAASE,SAAA,CAAUF,OAAA,CAAQpB,MAAA,CAAOoB,OAAO;MAGpD,OAAOnC,OAAA,CAAQyC,SAAA,CAAUJ,SAAA,EAAWb,GAAG;IACzC;EACF;AACF","ignoreList":[]}
@@ -5,6 +5,10 @@ var state = createGlobalState(`gesture`, {
5
5
  GestureDetector: null,
6
6
  ScrollView: null
7
7
  });
8
+ var pressState = {
9
+ owner: null,
10
+ timestamp: 0
11
+ };
8
12
  function getGestureHandler() {
9
13
  return {
10
14
  get isEnabled() {
@@ -26,27 +30,61 @@ function getGestureHandler() {
26
30
  if (!Gesture) return null;
27
31
  var _config_delayLongPress;
28
32
  var longPressDuration = (_config_delayLongPress = config.delayLongPress) !== null && _config_delayLongPress !== void 0 ? _config_delayLongPress : 500;
33
+ var myToken = {};
34
+ var tryClaimOwnership = function () {
35
+ var now = Date.now();
36
+ if (now - pressState.timestamp > 2e3) {
37
+ pressState.owner = null;
38
+ }
39
+ if (pressState.owner === null) {
40
+ pressState.owner = myToken;
41
+ pressState.timestamp = now;
42
+ }
43
+ return pressState.owner === myToken;
44
+ };
45
+ var isOwner = function () {
46
+ return pressState.owner === myToken;
47
+ };
48
+ var releaseOwnership = function () {
49
+ if (pressState.owner === myToken) {
50
+ pressState.owner = null;
51
+ }
52
+ };
29
53
  var tap = Gesture.Tap().runOnJS(true).maxDuration(1e4).onBegin(function (e) {
30
- var _config_onPressIn;
31
- (_config_onPressIn = config.onPressIn) === null || _config_onPressIn === void 0 ? void 0 : _config_onPressIn.call(config, e);
54
+ if (tryClaimOwnership()) {
55
+ var _config_onPressIn;
56
+ (_config_onPressIn = config.onPressIn) === null || _config_onPressIn === void 0 ? void 0 : _config_onPressIn.call(config, e);
57
+ }
32
58
  }).onEnd(function (e) {
33
- var _config_onPress;
34
- (_config_onPress = config.onPress) === null || _config_onPress === void 0 ? void 0 : _config_onPress.call(config, e);
59
+ if (isOwner()) {
60
+ var _config_onPress;
61
+ (_config_onPress = config.onPress) === null || _config_onPress === void 0 ? void 0 : _config_onPress.call(config, e);
62
+ }
35
63
  }).onFinalize(function (e) {
36
- var _config_onPressOut;
37
- (_config_onPressOut = config.onPressOut) === null || _config_onPressOut === void 0 ? void 0 : _config_onPressOut.call(config, e);
64
+ if (isOwner()) {
65
+ var _config_onPressOut;
66
+ (_config_onPressOut = config.onPressOut) === null || _config_onPressOut === void 0 ? void 0 : _config_onPressOut.call(config, e);
67
+ releaseOwnership();
68
+ }
38
69
  });
39
70
  if (config.hitSlop) tap.hitSlop(config.hitSlop);
40
71
  if (!config.onLongPress) return tap;
41
72
  var longPress = Gesture.LongPress().runOnJS(true).minDuration(longPressDuration).onBegin(function (e) {
42
- var _config_onPressIn;
43
- return (_config_onPressIn = config.onPressIn) === null || _config_onPressIn === void 0 ? void 0 : _config_onPressIn.call(config, e);
73
+ if (tryClaimOwnership()) {
74
+ var _config_onPressIn;
75
+ (_config_onPressIn = config.onPressIn) === null || _config_onPressIn === void 0 ? void 0 : _config_onPressIn.call(config, e);
76
+ }
44
77
  }).onStart(function (e) {
45
- var _config_onLongPress;
46
- return (_config_onLongPress = config.onLongPress) === null || _config_onLongPress === void 0 ? void 0 : _config_onLongPress.call(config, e);
78
+ if (isOwner()) {
79
+ var _config_onLongPress;
80
+ (_config_onLongPress = config.onLongPress) === null || _config_onLongPress === void 0 ? void 0 : _config_onLongPress.call(config, e);
81
+ }
47
82
  }).onFinalize(function (e) {
48
- var _config_onPressOut;
49
- return (_config_onPressOut = config.onPressOut) === null || _config_onPressOut === void 0 ? void 0 : _config_onPressOut.call(config, e);
83
+ if (isOwner()) {
84
+ var _config_onPressOut;
85
+ (_config_onPressOut = config.onPressOut) === null || _config_onPressOut === void 0 ? void 0 : _config_onPressOut.call(config, e);
86
+ releaseOwnership();
87
+ }
50
88
  });
51
89
  if (config.hitSlop) longPress.hitSlop(config.hitSlop);
52
90
  return Gesture.Exclusive(longPress, tap);
@@ -1 +1 @@
1
- {"version":3,"names":["createGlobalState","state","enabled","Gesture","GestureDetector","ScrollView","getGestureHandler","isEnabled","get","set","updates","Object","assign","disable","createPressGesture","config","_config_delayLongPress","longPressDuration","delayLongPress","tap","Tap","runOnJS","maxDuration","onBegin","e","_config_onPressIn","onPressIn","call","onEnd","_config_onPress","onPress","onFinalize","_config_onPressOut","onPressOut","hitSlop","onLongPress","longPress","LongPress","minDuration"],"sources":["../../src/gestureState.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,iBAAA,QAAyB;AAGlC,IAAA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AkB,GAAAjB,MAAQ,CAAAkB,UACvB,MAAQ,IAAI,IACZD,kBAAY,UACZ,SAAS,IAAAA,kBAAkB,CAAAL,IAAc,CAAAZ,MACzC,EAAAS,CAAQ,CAAC;MAGZ;MAGA,IAAAT,MAAO,CAAAmB,OAAQ,EAAAf,GAAA,CAAAe,OAAU,CAAAnB,MAAW,CAAGmB,OAAA;MACzC,KAAAnB,MAAA,CAAAoB,WAAA,SAAAhB,GAAA;MACF,IAAAiB,SAAA,GAAAjC,OAAA,CAAAkC,SAAA,GAAAhB,OAAA,OAAAiB,WAAA,CAAArB,iBAAA,EAAAM,OAAA,WAAAC,CAAA;QACF,IAAAC,iBAAA","ignoreList":[]}
1
+ {"version":3,"names":["createGlobalState","state","enabled","Gesture","GestureDetector","ScrollView","pressState","owner","timestamp","getGestureHandler","isEnabled","get","set","updates","Object","assign","disable","createPressGesture","config","_config_delayLongPress","longPressDuration","delayLongPress","myToken","tryClaimOwnership","now","Date","isOwner","releaseOwnership","tap","Tap","runOnJS","maxDuration","onBegin","e","_config_onPressIn","onPressIn","call","onEnd","_config_onPress","onPress","onFinalize","_config_onPressOut","onPressOut","hitSlop","onLongPress","longPress","LongPress","minDuration","onStart","_config_onLongPress"],"sources":["../../src/gestureState.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,iBAAA,QAAyB;AAGlC,IAAAC,KAAM,GAAAD,iBAAQ,UAAgC;EAC5CE,OAAA,EAAS;EACTC,OAAA,EAAS;EACTC,eAAA,EAAiB;EACjBC,UAAA,EAAY;AACd,CAAC;AAOD,IAAAC,UAAM;EACJC,KAAA,EAAO;EACPC,SAAA,EAAW;AACb;AA0BO,SAASC,kBAAA,EAA4C;EAC1D,OAAO;IACL,IAAIC,UAAA,EAAqB;MACvB,OAAOT,KAAA,CAAMU,GAAA,CAAI,EAAET,OAAA;IACrB;IACA,IAAID,MAAA,EAAsB;MACxB,OAAOA,KAAA,CAAMU,GAAA,CAAI;IACnB;IACAC,IAAIC,OAAA,E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Worklets","getSafeArea","getLinearGradient","isKeyboardControllerEnabled","getKeyboardControllerState","setKeyboardControllerState","getZeego","NativeMenuContext","getBurnt","NativePortal","NativePortalHost","NativePortalProvider"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAuCA,SAASA,SAAA,QAAiB;AAI1B,SAASC,iBAAA,QAAyB;AAIlC,SAASC,WAAA,QAAmB;AAI5B,SAASC,WAAA,QAAmB;AAI5B,SAASC,iBAAA,QAAyB;AAIlC,SACEC,2BAAA,EACAC,0BAAA,EACAC,0BAAA,QACK;AAIP,SAASC,QAAA,QAAgB;AAEzB,SAASC,iBAAA,QAAyB;AAGlC,SAASC,QAAA,QAAgB;AAIzB,SAASC,YAAA,EAAcC,gBAAA,EAAkBC,oBAAA,QAA4B","ignoreList":[]}
1
+ {"version":3,"names":["getPortal","getGestureHandler","getWorklets","getSafeArea","getLinearGradient","isKeyboardControllerEnabled","getKeyboardControllerState","setKeyboardControllerState","getZeego","NativeMenuContext","getBurnt","NativePortal","NativePortalHost","NativePortalProvider"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAuCA,SAASA,SAAA,QAAiB;AAI1B,SAASC,iBAAA,QAAyB;AAOlC,SAASC,WAAA,QAAmB;AAI5B,SAASC,WAAA,QAAmB;AAI5B,SAASC,iBAAA,QAAyB;AAIlC,SACEC,2BAAA,EACAC,0BAAA,EACAC,0BAAA,QACK;AAIP,SAASC,QAAA,QAAgB;AAEzB,SAASC,iBAAA,QAAyB;AAGlC,SAASC,QAAA,QAAgB;AAIzB,SAASC,YAAA,EAAcC,gBAAA,EAAkBC,oBAAA,QAA4B","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["getPortal","getGestureHandler","getWorklets","getSafeArea","getLinearGradient","isKeyboardControllerEnabled","getKeyboardControllerState","setKeyboardControllerState","getZeego","NativeMenuContext","getBurnt","NativePortal","NativePortalHost","NativePortalProvider"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAuCA,SAASA,SAAA,QAAiB;AAI1B,SAASC,iBAAA,QAAyB;AAIlC,SAASC,WAAA,QAAmB;AAI5B,SAASC,WAAA,QAAmB;AAI5B,SAASC,iBAAA,QAAyB;AAIlC,SACEC,2BAAA,EACAC,0BAAA,EACAC,0BAAA,QACK;AAIP,SAASC,QAAA,QAAgB;AAEzB,SAASC,iBAAA,QAAyB;AAGlC,SAASC,QAAA,QAAgB;AAIzB,SAASC,YAAA,EAAcC,gBAAA,EAAkBC,oBAAA,QAA4B","ignoreList":[]}
1
+ {"version":3,"names":["getPortal","getGestureHandler","getWorklets","getSafeArea","getLinearGradient","isKeyboardControllerEnabled","getKeyboardControllerState","setKeyboardControllerState","getZeego","NativeMenuContext","getBurnt","NativePortal","NativePortalHost","NativePortalProvider"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAuCA,SAASA,SAAA,QAAiB;AAI1B,SAASC,iBAAA,QAAyB;AAOlC,SAASC,WAAA,QAAmB;AAI5B,SAASC,WAAA,QAAmB;AAI5B,SAASC,iBAAA,QAAyB;AAIlC,SACEC,2BAAA,EACAC,0BAAA,EACAC,0BAAA,QACK;AAIP,SAASC,QAAA,QAAgB;AAEzB,SAASC,iBAAA,QAAyB;AAGlC,SAASC,QAAA,QAAgB;AAIzB,SAASC,YAAA,EAAcC,gBAAA,EAAkBC,oBAAA,QAA4B","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["getPortal","getGestureHandler","getWorklets","getSafeArea","getLinearGradient","isKeyboardControllerEnabled","getKeyboardControllerState","setKeyboardControllerState","getZeego","NativeMenuContext","getBurnt","NativePortal","NativePortalHost","NativePortalProvider"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAuCA,SAASA,SAAA,QAAiB;AAI1B,SAASC,iBAAA,QAAyB;AAIlC,SAASC,WAAA,QAAmB;AAI5B,SAASC,WAAA,QAAmB;AAI5B,SAASC,iBAAA,QAAyB;AAIlC,SAAAC,2BAAA,EAAAC,0BAAA,EAAAC,0BAAA;AAAA,SACEC,QAAA;AAAA,SACAC,iBAAA;AAAA,SACAC,QAAA;AAAA,SACKC,YAAA,EAAAC,gBAAA,EAAAC,oBAAA;AAIP,SAEAJ,iBAAS,EAGTE,YAAS,EAITC,gBAAS,E","ignoreList":[]}
1
+ {"version":3,"names":["getPortal","getGestureHandler","getWorklets","getSafeArea","getLinearGradient","isKeyboardControllerEnabled","getKeyboardControllerState","setKeyboardControllerState","getZeego","NativeMenuContext","getBurnt","NativePortal","NativePortalHost","NativePortalProvider"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAuCA,SAASA,SAAA,QAAiB;AAI1B,SAASC,iBAAA,QAAyB;AAOlC,SAASC,WAAA,QAAmB;AAI5B,SAASC,WAAA,QAAmB;AAI5B,SAASC,iBAAA,QAAyB;AAIlC,SAAAC,2BAAA,EAAAC,0BAAA,EAAAC,0BAAA;AAAA,SACEC,QAAA;AAAA,SACAC,iBAAA;AAAA,SACAC,QAAA;AAAA,SACKC,YAAA,EAAAC,gBAAA,EAAAC,oBAAA;AAIP,SAEAJ,iBAAS,EAGTE,YAAS,EAITC,gBAAS,E","ignoreList":[]}
@@ -1,9 +1,17 @@
1
1
  import { getGestureHandler } from "./gestureState.mjs";
2
- function setup() {
2
+ let currentConfig = {
3
+ pressEvents: true,
4
+ sheet: true
5
+ };
6
+ function getGestureHandlerConfig() {
7
+ return currentConfig;
8
+ }
9
+ function setupGestureHandler(config) {
3
10
  const g = globalThis;
4
- if (g.__tamagui_native_gesture_setup_complete) {
5
- return;
11
+ if (config) {
12
+ currentConfig = config;
6
13
  }
14
+ const isFirstRun = !g.__tamagui_native_gesture_setup_complete;
7
15
  g.__tamagui_native_gesture_setup_complete = true;
8
16
  try {
9
17
  const rngh = require("react-native-gesture-handler");
@@ -14,13 +22,13 @@ function setup() {
14
22
  } = rngh;
15
23
  if (Gesture && GestureDetector) {
16
24
  getGestureHandler().set({
17
- enabled: true,
25
+ enabled: currentConfig.pressEvents !== false,
18
26
  Gesture,
19
27
  GestureDetector,
20
28
  ScrollView: ScrollView || null
21
29
  });
22
30
  g.__tamagui_sheet_gesture_state__ = {
23
- enabled: true,
31
+ enabled: currentConfig.sheet !== false,
24
32
  Gesture,
25
33
  GestureDetector,
26
34
  ScrollView: ScrollView || null
@@ -28,5 +36,6 @@ function setup() {
28
36
  }
29
37
  } catch {}
30
38
  }
31
- setup();
39
+ setupGestureHandler();
40
+ export { getGestureHandlerConfig, setupGestureHandler };
32
41
  //# sourceMappingURL=setup-gesture-handler.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["getGestureHandler","setup","g","globalThis","__tamagui_native_gesture_setup_complete","rngh","require","Gesture","GestureDetector","ScrollView","set","enabled","__tamagui_sheet_gesture_state__"],"sources":["../../src/setup-gesture-handler.ts"],"sourcesContent":[null],"mappings":"AAcA,SAASA,iBAAA,QAAyB;AAElC,SAASC,MAAA,EAAQ;EACf,MAAMC,CAAA,GAAIC,UAAA;EACV,IAAID,CAAA,CAAEE,uCAAA,EAAyC;IAC7C;EACF;EACAF,CAAA,CAAEE,uCAAA,GAA0C;EAE5C,IAAI;IAEF,MAAMC,IAAA,GAAOC,OAAA,CAAQ,8BAA8B;IACnD,MAAM;MAAEC,OAAA;MAASC,eAAA;MAAiBC;IAAW,IAAIJ,IAAA;IAEjD,IAAIE,OAAA,IAAWC,eAAA,EAAiB;MAC9BR,iBAAA,CAAkB,EAAEU,GAAA,CAAI;QACtBC,OAAA,EAAS;QACTJ,OAAA;QACAC,eAAA;QACAC,UAAA,EAAYA,UAAA,IAAc;MAC5B,CAAC;MAGDP,CAAA,CAAEU,+BAAA,GAAkC;QAClCD,OAAA,EAAS;QACTJ,OAAA;QACAC,eAAA;QACAC,UAAA,EAAYA,UAAA,IAAc;MAC5B;IACF;EACF,QAAQ,CAER;AACF;AAGAR,KAAA,CAAM","ignoreList":[]}
1
+ {"version":3,"names":["getGestureHandler","currentConfig","pressEvents","sheet","getGestureHandlerConfig","setupGestureHandler","config","g","globalThis","isFirstRun","__tamagui_native_gesture_setup_complete","rngh","require","Gesture","GestureDetector","ScrollView","set","enabled","__tamagui_sheet_gesture_state__"],"sources":["../../src/setup-gesture-handler.ts"],"sourcesContent":[null],"mappings":"AAmBA,SAASA,iBAAA,QAAyB;AASlC,IAAIC,aAAA,GAAsC;EACxCC,WAAA,EAAa;EACbC,KAAA,EAAO;AACT;AAEO,SAASC,wBAAA,EAAgD;EAC9D,OAAOH,aAAA;AACT;AAEO,SAASI,oBAAoBC,MAAA,EAAqC;EACvE,MAAMC,CAAA,GAAIC,UAAA;EAGV,IAAIF,MAAA,EAAQ;IACVL,aAAA,GAAgBK,MAAA;EAClB;EAGA,MAAMG,UAAA,GAAa,CAACF,CAAA,CAAEG,uCAAA;EACtBH,CAAA,CAAEG,uCAAA,GAA0C;EAE5C,IAAI;IAEF,MAAMC,IAAA,GAAOC,OAAA,CAAQ,8BAA8B;IACnD,MAAM;MAAEC,OAAA;MAASC,eAAA;MAAiBC;IAAW,IAAIJ,IAAA;IAEjD,IAAIE,OAAA,IAAWC,eAAA,EAAiB;MAE9Bd,iBAAA,CAAkB,EAAEgB,GAAA,CAAI;QACtBC,OAAA,EAAShB,aAAA,CAAcC,WAAA,KAAgB;QACvCW,OAAA;QACAC,eAAA;QACAC,UAAA,EAAYA,UAAA,IAAc;MAC5B,CAAC;MAGDR,CAAA,CAAEW,+BAAA,GAAkC;QAClCD,OAAA,EAAShB,aAAA,CAAcE,KAAA,KAAU;QACjCU,OAAA;QACAC,eAAA;QACAC,UAAA,EAAYA,UAAA,IAAc;MAC5B;IACF;EACF,QAAQ,CAER;AACF;AAGAV,mBAAA,CAAoB","ignoreList":[]}
@@ -1,9 +1,17 @@
1
1
  import { getGestureHandler } from "./gestureState.native.js";
2
- function setup() {
2
+ var currentConfig = {
3
+ pressEvents: true,
4
+ sheet: true
5
+ };
6
+ function getGestureHandlerConfig() {
7
+ return currentConfig;
8
+ }
9
+ function setupGestureHandler(config) {
3
10
  var g = globalThis;
4
- if (g.__tamagui_native_gesture_setup_complete) {
5
- return;
11
+ if (config) {
12
+ currentConfig = config;
6
13
  }
14
+ var isFirstRun = !g.__tamagui_native_gesture_setup_complete;
7
15
  g.__tamagui_native_gesture_setup_complete = true;
8
16
  try {
9
17
  var rngh = require("react-native-gesture-handler");
@@ -14,13 +22,13 @@ function setup() {
14
22
  } = rngh;
15
23
  if (Gesture && GestureDetector) {
16
24
  getGestureHandler().set({
17
- enabled: true,
25
+ enabled: currentConfig.pressEvents !== false,
18
26
  Gesture,
19
27
  GestureDetector,
20
28
  ScrollView: ScrollView || null
21
29
  });
22
30
  g.__tamagui_sheet_gesture_state__ = {
23
- enabled: true,
31
+ enabled: currentConfig.sheet !== false,
24
32
  Gesture,
25
33
  GestureDetector,
26
34
  ScrollView: ScrollView || null
@@ -28,5 +36,6 @@ function setup() {
28
36
  }
29
37
  } catch (e) {}
30
38
  }
31
- setup();
39
+ setupGestureHandler();
40
+ export { getGestureHandlerConfig, setupGestureHandler };
32
41
  //# sourceMappingURL=setup-gesture-handler.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getGestureHandler","setup","g","globalThis","__tamagui_native_gesture_setup_complete","rngh","require","Gesture","GestureDetector","ScrollView","set","enabled","__tamagui_sheet_gesture_state__","e"],"sources":["../../src/setup-gesture-handler.ts"],"sourcesContent":[null],"mappings":"AAcA,SAASA,iBAAA,QAAyB;AAElC,SAASC,MAAA,EAAQ;EACf,IAAAC,CAAA,GAAMC,UAAI;EACV,IAAID,CAAA,CAAEE,uCAAA,EAAyC;IAC7C;EACF;EACAF,CAAA,CAAEE,uCAAA,GAA0C;EAE5C,IAAI;IAEF,IAAAC,IAAM,GAAAC,OAAO,+BAAQ;IACrB;MAAMC,OAAE;MAAAC,eAAS;MAAAC;IAAiB,IAAWJ,IAAI;IAEjD,IAAIE,OAAA,IAAWC,eAAA,EAAiB;MAC9BR,iBAAA,CAAkB,EAAEU,GAAA,CAAI;QACtBC,OAAA,EAAS;QACTJ,OAAA;QACAC,eAAA;QACAC,UAAA,EAAYA,UAAA,IAAc;MAC5B,CAAC;MAGDP,CAAA,CAAEU,+BAAA,GAAkC;QAClCD,OAAA,EAAS;QACTJ,OAAA;QACAC,eAAA;QACAC,UAAA,EAAYA,UAAA,IAAc;MAC5B;IACF;EACF,SAAQI,CAAA,GAER;AACF;AAGAZ,KAAA,CAAM","ignoreList":[]}
1
+ {"version":3,"names":["getGestureHandler","currentConfig","pressEvents","sheet","getGestureHandlerConfig","setupGestureHandler","config","g","globalThis","isFirstRun","__tamagui_native_gesture_setup_complete","rngh","require","Gesture","GestureDetector","ScrollView","set","enabled","__tamagui_sheet_gesture_state__","e"],"sources":["../../src/setup-gesture-handler.ts"],"sourcesContent":[null],"mappings":"AAmBA,SAASA,iBAAA,QAAyB;AASlC,IAAIC,aAAA,GAAsC;EACxCC,WAAA,EAAa;EACbC,KAAA,EAAO;AACT;AAEO,SAASC,wBAAA,EAAgD;EAC9D,OAAOH,aAAA;AACT;AAEO,SAASI,oBAAoBC,MAAA,EAAqC;EACvE,IAAAC,CAAA,GAAMC,UAAI;EAGV,IAAIF,MAAA,EAAQ;IACVL,aAAA,GAAgBK,MAAA;EAClB;EAGA,IAAAG,UAAM,IAAAF,CAAa,CAACG,uCAAE;EACtBH,CAAA,CAAEG,uCAAA,GAA0C;EAE5C,IAAI;IAEF,IAAAC,IAAM,GAAAC,OAAO,+BAAQ;IACrB;MAAMC,OAAE;MAAAC,eAAS;MAAAC;IAAiB,IAAWJ,IAAI;IAEjD,IAAIE,OAAA,IAAWC,eAAA,EAAiB;MAE9Bd,iBAAA,CAAkB,EAAEgB,GAAA,CAAI;QACtBC,OAAA,EAAShB,aAAA,CAAcC,WAAA,KAAgB;QACvCW,OAAA;QACAC,eAAA;QACAC,UAAA,EAAYA,UAAA,IAAc;MAC5B,CAAC;MAGDR,CAAA,CAAEW,+BAAA,GAAkC;QAClCD,OAAA,EAAShB,aAAA,CAAcE,KAAA,KAAU;QACjCU,OAAA;QACAC,eAAA;QACAC,UAAA,EAAYA,UAAA,IAAc;MAC5B;IACF;EACF,SAAQI,CAAA,GAER;AACF;AAGAd,mBAAA,CAAoB","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/native",
3
- "version": "2.0.0-rc.38",
3
+ "version": "2.0.0-rc.38-1775845464754",
4
4
  "description": "Native setup modules for Tamagui - portals, gesture handler, worklets, and more",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -131,7 +131,7 @@
131
131
  "clean:build": "tamagui-build clean:build"
132
132
  },
133
133
  "devDependencies": {
134
- "@tamagui/build": "2.0.0-rc.38",
134
+ "@tamagui/build": "2.0.0-rc.38-1775845464754",
135
135
  "burnt": "^0.12.2",
136
136
  "react": ">=19",
137
137
  "react-native": "0.83.2",
@@ -8,6 +8,16 @@ const state = createGlobalState<GestureState>(`gesture`, {
8
8
  ScrollView: null,
9
9
  })
10
10
 
11
+ /**
12
+ * Global press coordination - ensures only innermost pressable fires press events,
13
+ * matching RN Pressable/responder system semantics where deepest component wins.
14
+ * First gesture to fire onBegin claims ownership of the entire press sequence.
15
+ */
16
+ const pressState = {
17
+ owner: null as object | null,
18
+ timestamp: 0,
19
+ }
20
+
11
21
  export interface Insets {
12
22
  top?: number
13
23
  left?: number
@@ -54,19 +64,53 @@ export function getGestureHandler(): GestureHandlerAccessor {
54
64
 
55
65
  const longPressDuration = config.delayLongPress ?? 500
56
66
 
67
+ // unique token for this gesture instance - used to track ownership
68
+ const myToken = {}
69
+
70
+ // helper to check/claim ownership
71
+ const tryClaimOwnership = () => {
72
+ const now = Date.now()
73
+ // reset if stale (component may have unmounted mid-press)
74
+ if (now - pressState.timestamp > 2000) {
75
+ pressState.owner = null
76
+ }
77
+ if (pressState.owner === null) {
78
+ pressState.owner = myToken
79
+ pressState.timestamp = now
80
+ }
81
+ return pressState.owner === myToken
82
+ }
83
+
84
+ const isOwner = () => pressState.owner === myToken
85
+
86
+ const releaseOwnership = () => {
87
+ if (pressState.owner === myToken) {
88
+ pressState.owner = null
89
+ }
90
+ }
91
+
57
92
  // Tap gesture for regular presses
58
93
  // Use long maxDuration to not cancel during long presses
59
94
  const tap = Gesture.Tap()
60
95
  .runOnJS(true)
61
96
  .maxDuration(10000) // allow very long presses
62
97
  .onBegin((e: any) => {
63
- config.onPressIn?.(e)
98
+ // first gesture to fire onBegin claims ownership of the press sequence
99
+ // this matches RN Pressable/responder semantics (deepest wins)
100
+ if (tryClaimOwnership()) {
101
+ config.onPressIn?.(e)
102
+ }
64
103
  })
65
104
  .onEnd((e: any) => {
66
- config.onPress?.(e)
105
+ if (isOwner()) {
106
+ config.onPress?.(e)
107
+ }
67
108
  })
68
109
  .onFinalize((e: any) => {
69
- config.onPressOut?.(e)
110
+ if (isOwner()) {
111
+ config.onPressOut?.(e)
112
+ releaseOwnership()
113
+ }
70
114
  })
71
115
 
72
116
  if (config.hitSlop) tap.hitSlop(config.hitSlop)
@@ -78,9 +122,22 @@ export function getGestureHandler(): GestureHandlerAccessor {
78
122
  const longPress = Gesture.LongPress()
79
123
  .runOnJS(true)
80
124
  .minDuration(longPressDuration)
81
- .onBegin((e: any) => config.onPressIn?.(e))
82
- .onStart((e: any) => config.onLongPress?.(e))
83
- .onFinalize((e: any) => config.onPressOut?.(e))
125
+ .onBegin((e: any) => {
126
+ if (tryClaimOwnership()) {
127
+ config.onPressIn?.(e)
128
+ }
129
+ })
130
+ .onStart((e: any) => {
131
+ if (isOwner()) {
132
+ config.onLongPress?.(e)
133
+ }
134
+ })
135
+ .onFinalize((e: any) => {
136
+ if (isOwner()) {
137
+ config.onPressOut?.(e)
138
+ releaseOwnership()
139
+ }
140
+ })
84
141
 
85
142
  if (config.hitSlop) longPress.hitSlop(config.hitSlop)
86
143
 
package/src/index.ts CHANGED
@@ -43,6 +43,9 @@ export type { PortalAccessor } from './portalState'
43
43
  // gesture handler
44
44
  export { getGestureHandler } from './gestureState'
45
45
  export type { GestureHandlerAccessor, PressGestureConfig } from './gestureState'
46
+ // NOTE: setupGestureHandler is exported from setup-gesture-handler.ts entry point,
47
+ // not here, to avoid bundler pulling in RNGH require during tree-shaking
48
+ export type { GestureHandlerConfig } from './setup-gesture-handler'
46
49
 
47
50
  // worklets
48
51
  export { getWorklets } from './workletsState'
@@ -5,7 +5,12 @@
5
5
  *
6
6
  * @example
7
7
  * ```tsx
8
+ * // auto-setup with all features enabled
8
9
  * import '@tamagui/native/setup-gesture-handler'
10
+ *
11
+ * // or configure selectively
12
+ * import { setupGestureHandler } from '@tamagui/native/setup-gesture-handler'
13
+ * setupGestureHandler({ pressEvents: true, sheet: false })
9
14
  * ```
10
15
  *
11
16
  * This automatically detects and configures react-native-gesture-handler
@@ -14,11 +19,32 @@
14
19
 
15
20
  import { getGestureHandler } from './gestureState'
16
21
 
17
- function setup() {
22
+ export interface GestureHandlerConfig {
23
+ /** use RNGH for press events on Tamagui components (default: true) */
24
+ pressEvents?: boolean
25
+ /** use RNGH for Sheet drag gestures (default: true) */
26
+ sheet?: boolean
27
+ }
28
+
29
+ let currentConfig: GestureHandlerConfig = {
30
+ pressEvents: true,
31
+ sheet: true,
32
+ }
33
+
34
+ export function getGestureHandlerConfig(): GestureHandlerConfig {
35
+ return currentConfig
36
+ }
37
+
38
+ export function setupGestureHandler(config?: GestureHandlerConfig): void {
18
39
  const g = globalThis as any
19
- if (g.__tamagui_native_gesture_setup_complete) {
20
- return
40
+
41
+ // override config if provided
42
+ if (config) {
43
+ currentConfig = config
21
44
  }
45
+
46
+ // allow re-running setup to change config
47
+ const isFirstRun = !g.__tamagui_native_gesture_setup_complete
22
48
  g.__tamagui_native_gesture_setup_complete = true
23
49
 
24
50
  try {
@@ -27,16 +53,17 @@ function setup() {
27
53
  const { Gesture, GestureDetector, ScrollView } = rngh
28
54
 
29
55
  if (Gesture && GestureDetector) {
56
+ // only enable if pressEvents is true
30
57
  getGestureHandler().set({
31
- enabled: true,
58
+ enabled: currentConfig.pressEvents !== false,
32
59
  Gesture,
33
60
  GestureDetector,
34
61
  ScrollView: ScrollView || null,
35
62
  })
36
63
 
37
- // also set on the legacy key for backward compat with @tamagui/sheet
64
+ // sheet state - only enable if sheet is true
38
65
  g.__tamagui_sheet_gesture_state__ = {
39
- enabled: true,
66
+ enabled: currentConfig.sheet !== false,
40
67
  Gesture,
41
68
  GestureDetector,
42
69
  ScrollView: ScrollView || null,
@@ -47,5 +74,5 @@ function setup() {
47
74
  }
48
75
  }
49
76
 
50
- // run setup immediately on import
51
- setup()
77
+ // run setup immediately on import (can be overridden by calling setupGestureHandler)
78
+ setupGestureHandler()
@@ -1,11 +1,11 @@
1
1
  {
2
- "mappings": "AACA,cAAc,oBAAoB;AASlC,iBAAiB,OAAO;CACtB;CACA;CACA;CACA;;AAGF,YAAY,qBAAqB;CAC/B,aAAa;CACb,cAAc;CACd,WAAW;CACX,eAAe;CACf;CACA,mBAAmB;;AAGrB,iBAAiB,uBAAuB;UAC7B;UACA,OAAO;CAChB,IAAI,SAAS,QAAQ;CACrB;CACA,mBAAmB,QAAQ;;AAG7B,OAAO,iBAAS,qBAAqB",
2
+ "mappings": "AACA,cAAc,oBAAoB;AAmBlC,iBAAiB,OAAO;CACtB;CACA;CACA;CACA;;AAGF,YAAY,qBAAqB;CAC/B,aAAa;CACb,cAAc;CACd,WAAW;CACX,eAAe;CACf;CACA,mBAAmB;;AAGrB,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
  "version": 3,
8
8
  "sourcesContent": [
9
- "import { createGlobalState } from './globalState'\nimport type { GestureState } from './types'\n\nconst state = createGlobalState<GestureState>(`gesture`, {\n enabled: false,\n Gesture: null,\n GestureDetector: null,\n ScrollView: null,\n})\n\nexport interface Insets {\n top?: number\n left?: number\n bottom?: number\n right?: number\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?: number | Insets | null\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 state.get().enabled\n },\n get state(): GestureState {\n return state.get()\n },\n set(updates: Partial<GestureState>): void {\n Object.assign(state.get(), updates)\n },\n\n disable(): void {\n state.get().enabled = false\n },\n\n createPressGesture(config: PressGestureConfig): any {\n const { Gesture } = state.get()\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) => {\n config.onPressIn?.(e)\n })\n .onEnd((e: any) => {\n config.onPress?.(e)\n })\n .onFinalize((e: any) => {\n config.onPressOut?.(e)\n })\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
+ "import { createGlobalState } from './globalState'\nimport type { GestureState } from './types'\n\nconst state = createGlobalState<GestureState>(`gesture`, {\n enabled: false,\n Gesture: null,\n GestureDetector: null,\n ScrollView: null,\n})\n\n/**\n * Global press coordination - ensures only innermost pressable fires press events,\n * matching RN Pressable/responder system semantics where deepest component wins.\n * First gesture to fire onBegin claims ownership of the entire press sequence.\n */\nconst pressState = {\n owner: null as object | null,\n timestamp: 0,\n}\n\nexport interface Insets {\n top?: number\n left?: number\n bottom?: number\n right?: number\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?: number | Insets | null\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 state.get().enabled\n },\n get state(): GestureState {\n return state.get()\n },\n set(updates: Partial<GestureState>): void {\n Object.assign(state.get(), updates)\n },\n\n disable(): void {\n state.get().enabled = false\n },\n\n createPressGesture(config: PressGestureConfig): any {\n const { Gesture } = state.get()\n if (!Gesture) return null\n\n const longPressDuration = config.delayLongPress ?? 500\n\n // unique token for this gesture instance - used to track ownership\n const myToken = {}\n\n // helper to check/claim ownership\n const tryClaimOwnership = () => {\n const now = Date.now()\n // reset if stale (component may have unmounted mid-press)\n if (now - pressState.timestamp > 2000) {\n pressState.owner = null\n }\n if (pressState.owner === null) {\n pressState.owner = myToken\n pressState.timestamp = now\n }\n return pressState.owner === myToken\n }\n\n const isOwner = () => pressState.owner === myToken\n\n const releaseOwnership = () => {\n if (pressState.owner === myToken) {\n pressState.owner = null\n }\n }\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) => {\n // first gesture to fire onBegin claims ownership of the press sequence\n // this matches RN Pressable/responder semantics (deepest wins)\n if (tryClaimOwnership()) {\n config.onPressIn?.(e)\n }\n })\n .onEnd((e: any) => {\n if (isOwner()) {\n config.onPress?.(e)\n }\n })\n .onFinalize((e: any) => {\n if (isOwner()) {\n config.onPressOut?.(e)\n releaseOwnership()\n }\n })\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) => {\n if (tryClaimOwnership()) {\n config.onPressIn?.(e)\n }\n })\n .onStart((e: any) => {\n if (isOwner()) {\n config.onLongPress?.(e)\n }\n })\n .onFinalize((e: any) => {\n if (isOwner()) {\n config.onPressOut?.(e)\n releaseOwnership()\n }\n })\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"
10
10
  ]
11
11
  }
package/types/index.d.ts CHANGED
@@ -23,6 +23,7 @@ export { getPortal } from "./portalState";
23
23
  export type { PortalAccessor } from "./portalState";
24
24
  export { getGestureHandler } from "./gestureState";
25
25
  export type { GestureHandlerAccessor, PressGestureConfig } from "./gestureState";
26
+ export type { GestureHandlerConfig } from "./setup-gesture-handler";
26
27
  export { getWorklets } from "./workletsState";
27
28
  export type { WorkletsAccessor } from "./workletsState";
28
29
  export { getSafeArea } from "./safeAreaState";
@@ -1,11 +1,11 @@
1
1
  {
2
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAsBA,cACE,mBACA,cACA,eACA,eACA,gBACA,eACA,iBACA,qBACA,YACA,YACA,mBACA,uBACA,iCACK;AAGP,SAAS,iBAAiB;AAC1B,cAAc,sBAAsB;AAGpC,SAAS,yBAAyB;AAClC,cAAc,wBAAwB,0BAA0B;AAGhE,SAAS,mBAAmB;AAC5B,cAAc,wBAAwB;AAGtC,SAAS,mBAAmB;AAC5B,cAAc,wBAAwB;AAGtC,SAAS,yBAAyB;AAClC,cAAc,8BAA8B;AAG5C,SACE,6BACA,4BACA,kCACK;AACP,cAAc,+BAA+B;AAG7C,SAAS,gBAAgB;AACzB,cAAc,qBAAqB;AACnC,SAAS,yBAAyB;AAGlC,SAAS,gBAAgB;AACzB,cAAc,qBAAqB;AAGnC,SAAS,cAAc,kBAAkB,4BAA4B",
2
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAsBA,cACE,mBACA,cACA,eACA,eACA,gBACA,eACA,iBACA,qBACA,YACA,YACA,mBACA,uBACA,iCACK;AAGP,SAAS,iBAAiB;AAC1B,cAAc,sBAAsB;AAGpC,SAAS,yBAAyB;AAClC,cAAc,wBAAwB,0BAA0B;AAGhE,cAAc,4BAA4B;AAG1C,SAAS,mBAAmB;AAC5B,cAAc,wBAAwB;AAGtC,SAAS,mBAAmB;AAC5B,cAAc,wBAAwB;AAGtC,SAAS,yBAAyB;AAClC,cAAc,8BAA8B;AAG5C,SACE,6BACA,4BACA,kCACK;AACP,cAAc,+BAA+B;AAG7C,SAAS,gBAAgB;AACzB,cAAc,qBAAqB;AACnC,SAAS,yBAAyB;AAGlC,SAAS,gBAAgB;AACzB,cAAc,qBAAqB;AAGnC,SAAS,cAAc,kBAAkB,4BAA4B",
3
3
  "names": [],
4
4
  "sources": [
5
5
  "src/index.ts"
6
6
  ],
7
7
  "version": 3,
8
8
  "sourcesContent": [
9
- "/**\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 * import '@tamagui/native/setup-safe-area'\n * import '@tamagui/native/expo-linear-gradient'\n * import '@tamagui/native/setup-keyboard-controller'\n *\n * // Then use Tamagui components normally\n * // Sheet will automatically use native gestures when available\n * // LinearGradient will use expo-linear-gradient when installed\n * ```\n */\n\n// types\nexport type {\n NativePortalState,\n GestureState,\n WorkletsState,\n SafeAreaState,\n SafeAreaInsets,\n SafeAreaFrame,\n SafeAreaMetrics,\n LinearGradientState,\n ZeegoState,\n BurntState,\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// safe area\nexport { getSafeArea } from './safeAreaState'\nexport type { SafeAreaAccessor } from './safeAreaState'\n\n// linear gradient\nexport { getLinearGradient } from './linearGradientState'\nexport type { LinearGradientAccessor } from './linearGradientState'\n\n// keyboard controller state exports (safe - no side effects)\nexport {\n isKeyboardControllerEnabled,\n getKeyboardControllerState,\n setKeyboardControllerState,\n} from './keyboardControllerState'\nexport type { KeyboardControllerState } from './keyboardControllerState'\n\n// zeego (native menus)\nexport { getZeego } from './zeegoState'\nexport type { ZeegoAccessor } from './zeegoState'\nexport { NativeMenuContext } from './nativeMenuContext'\n\n// burnt (native toasts)\nexport { getBurnt } from './burntState'\nexport type { BurntAccessor } from './burntState'\n\n// components\nexport { NativePortal, NativePortalHost, NativePortalProvider } from './components'\n"
9
+ "/**\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 * import '@tamagui/native/setup-safe-area'\n * import '@tamagui/native/expo-linear-gradient'\n * import '@tamagui/native/setup-keyboard-controller'\n *\n * // Then use Tamagui components normally\n * // Sheet will automatically use native gestures when available\n * // LinearGradient will use expo-linear-gradient when installed\n * ```\n */\n\n// types\nexport type {\n NativePortalState,\n GestureState,\n WorkletsState,\n SafeAreaState,\n SafeAreaInsets,\n SafeAreaFrame,\n SafeAreaMetrics,\n LinearGradientState,\n ZeegoState,\n BurntState,\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// NOTE: setupGestureHandler is exported from setup-gesture-handler.ts entry point,\n// not here, to avoid bundler pulling in RNGH require during tree-shaking\nexport type { GestureHandlerConfig } from './setup-gesture-handler'\n\n// worklets\nexport { getWorklets } from './workletsState'\nexport type { WorkletsAccessor } from './workletsState'\n\n// safe area\nexport { getSafeArea } from './safeAreaState'\nexport type { SafeAreaAccessor } from './safeAreaState'\n\n// linear gradient\nexport { getLinearGradient } from './linearGradientState'\nexport type { LinearGradientAccessor } from './linearGradientState'\n\n// keyboard controller state exports (safe - no side effects)\nexport {\n isKeyboardControllerEnabled,\n getKeyboardControllerState,\n setKeyboardControllerState,\n} from './keyboardControllerState'\nexport type { KeyboardControllerState } from './keyboardControllerState'\n\n// zeego (native menus)\nexport { getZeego } from './zeegoState'\nexport type { ZeegoAccessor } from './zeegoState'\nexport { NativeMenuContext } from './nativeMenuContext'\n\n// burnt (native toasts)\nexport { getBurnt } from './burntState'\nexport type { BurntAccessor } from './burntState'\n\n// components\nexport { NativePortal, NativePortalHost, NativePortalProvider } from './components'\n"
10
10
  ]
11
11
  }
@@ -1,3 +1,10 @@
1
- export {};
1
+ export interface GestureHandlerConfig {
2
+ /** use RNGH for press events on Tamagui components (default: true) */
3
+ pressEvents?: boolean;
4
+ /** use RNGH for Sheet drag gestures (default: true) */
5
+ sheet?: boolean;
6
+ }
7
+ export declare function getGestureHandlerConfig(): GestureHandlerConfig;
8
+ export declare function setupGestureHandler(config?: GestureHandlerConfig): void;
2
9
 
3
10
  //# sourceMappingURL=setup-gesture-handler.d.ts.map
@@ -1,11 +1,11 @@
1
1
  {
2
- "mappings": "",
2
+ "mappings": "AAqBA,iBAAiB,qBAAqB;;CAEpC;;CAEA;;AAQF,OAAO,iBAAS,2BAA2B;AAI3C,OAAO,iBAAS,oBAAoB,SAAS",
3
3
  "names": [],
4
4
  "sources": [
5
5
  "src/setup-gesture-handler.ts"
6
6
  ],
7
7
  "version": 3,
8
8
  "sourcesContent": [
9
- "/**\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
+ "/**\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 * // auto-setup with all features enabled\n * import '@tamagui/native/setup-gesture-handler'\n *\n * // or configure selectively\n * import { setupGestureHandler } from '@tamagui/native/setup-gesture-handler'\n * setupGestureHandler({ pressEvents: true, sheet: false })\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\nexport interface GestureHandlerConfig {\n /** use RNGH for press events on Tamagui components (default: true) */\n pressEvents?: boolean\n /** use RNGH for Sheet drag gestures (default: true) */\n sheet?: boolean\n}\n\nlet currentConfig: GestureHandlerConfig = {\n pressEvents: true,\n sheet: true,\n}\n\nexport function getGestureHandlerConfig(): GestureHandlerConfig {\n return currentConfig\n}\n\nexport function setupGestureHandler(config?: GestureHandlerConfig): void {\n const g = globalThis as any\n\n // override config if provided\n if (config) {\n currentConfig = config\n }\n\n // allow re-running setup to change config\n const isFirstRun = !g.__tamagui_native_gesture_setup_complete\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 // only enable if pressEvents is true\n getGestureHandler().set({\n enabled: currentConfig.pressEvents !== false,\n Gesture,\n GestureDetector,\n ScrollView: ScrollView || null,\n })\n\n // sheet state - only enable if sheet is true\n g.__tamagui_sheet_gesture_state__ = {\n enabled: currentConfig.sheet !== false,\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 (can be overridden by calling setupGestureHandler)\nsetupGestureHandler()\n"
10
10
  ]
11
11
  }