@react-native-gpui/gesture-handler 3.3.0-alpha.0 → 3.3.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to `@react-native-gpui/gesture-handler` are listed here. Each version's section becomes the notes of its GitHub release.
4
4
 
5
+ ## 3.3.0-alpha.1 - 2026-11-12
6
+
7
+ - A gesture whose callbacks run on the JS thread (`runOnJS(true)`, or a handler from the old API) receives its events. They were sent to its view, where only worklet callbacks listen, so a sheet dragged by such a gesture did not move.
8
+
5
9
  ## 3.3.0-alpha.0 - 2026-11-01
6
10
 
7
11
  - First release, for `react-native-gesture-handler` 3.3.x with Reanimated 4.7.x and Worklets 0.13.x.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @react-native-gpui/gesture-handler
2
2
 
3
- Desktop support for [`react-native-gesture-handler`](https://github.com/software-mansion/react-native-gesture-handler): gestures from the mouse, trackpad and touch screen.
3
+ Adapter for [`react-native-gesture-handler`](https://github.com/software-mansion/react-native-gesture-handler) (MIT): recognizes gestures from the mouse, trackpad and touch screen.
4
4
 
5
5
  Part of [react-native-gpui](https://github.com/streetwriters/react-native-gpui), React Native for macOS, Windows and Linux.
6
6
 
@@ -6,6 +6,7 @@
6
6
  #include <folly/dynamic.h>
7
7
  #include <folly/json.h>
8
8
  #include <glog/logging.h>
9
+ #include <jsi/JSIDynamic.h>
9
10
 
10
11
  #include <algorithm>
11
12
  #include <cmath>
@@ -13,6 +14,7 @@
13
14
  #include <memory>
14
15
  #include <mutex>
15
16
  #include <string>
17
+ #include <string_view>
16
18
  #include <unordered_map>
17
19
  #include <utility>
18
20
  #include <vector>
@@ -51,6 +53,21 @@ struct Handler {
51
53
  std::mutex handlersMutex;
52
54
  std::unordered_map<int32_t, Handler> handlers;
53
55
 
56
+ // What one pointer event produced. A gesture whose callbacks run on the JS
57
+ // thread is told through device events, as GestureDetector listens for them;
58
+ // any other through events on its view.
59
+ struct Recognized {
60
+ std::vector<RecognizedGesture> viewEvents;
61
+ std::vector<std::pair<std::string, folly::dynamic>> deviceEvents;
62
+ };
63
+
64
+ bool runsOnJS(const Handler& handler) {
65
+ constexpr int32_t kJSFunctionOldAPI = 3;
66
+ constexpr int32_t kJSFunctionNewAPI = 4;
67
+ return handler.actionType == kJSFunctionOldAPI ||
68
+ handler.actionType == kJSFunctionNewAPI;
69
+ }
70
+
54
71
  folly::dynamic configObject(folly::dynamic config) {
55
72
  return config.isObject() ? std::move(config) : folly::dynamic::object();
56
73
  }
@@ -111,15 +128,23 @@ folly::dynamic payloadFor(
111
128
  }
112
129
 
113
130
  void appendEvent(
114
- std::vector<RecognizedGesture>& events,
115
- int32_t viewTag,
131
+ Recognized& events,
132
+ const Handler& handler,
116
133
  const char* type,
117
134
  const folly::dynamic& payload) {
118
- events.push_back({viewTag, type, folly::toJson(payload)});
135
+ if (runsOnJS(handler)) {
136
+ const bool stateChange =
137
+ std::string_view(type) == "topGestureHandlerStateChange";
138
+ events.deviceEvents.emplace_back(
139
+ stateChange ? "onGestureHandlerStateChange" : "onGestureHandlerEvent",
140
+ payload);
141
+ return;
142
+ }
143
+ events.viewEvents.push_back({handler.viewTag, type, folly::toJson(payload)});
119
144
  }
120
145
 
121
146
  void appendState(
122
- std::vector<RecognizedGesture>& events,
147
+ Recognized& events,
123
148
  int32_t handlerTag,
124
149
  Handler& handler,
125
150
  int32_t nextState,
@@ -133,7 +158,7 @@ void appendState(
133
158
  }
134
159
  appendEvent(
135
160
  events,
136
- handler.viewTag,
161
+ handler,
137
162
  "topGestureHandlerStateChange",
138
163
  payloadFor(handlerTag, handler, nextState, oldState, pointer, true));
139
164
  }
@@ -190,8 +215,8 @@ bool blockedByActiveHandler(int32_t handlerTag) {
190
215
  return false;
191
216
  }
192
217
 
193
- std::vector<RecognizedGesture> processPointer(const RawPointerEvent& pointer) {
194
- std::vector<RecognizedGesture> events;
218
+ Recognized processPointer(const RawPointerEvent& pointer) {
219
+ Recognized events;
195
220
  std::lock_guard<std::mutex> lock(handlersMutex);
196
221
  if (gestureTracingEnabled() && pointer.phase != 4) {
197
222
  LOG(INFO) << "[gesture-handler] pointer phase=" << pointer.phase << " at ("
@@ -303,7 +328,7 @@ std::vector<RecognizedGesture> processPointer(const RawPointerEvent& pointer) {
303
328
  (isPan(handler) || isLongPress(handler))) {
304
329
  appendEvent(
305
330
  events,
306
- handler.viewTag,
331
+ handler,
307
332
  "topGestureHandlerEvent",
308
333
  payloadFor(
309
334
  handlerTag,
@@ -341,7 +366,7 @@ std::vector<RecognizedGesture> processPointer(const RawPointerEvent& pointer) {
341
366
  if (isTap(handler) || isLongPress(handler)) {
342
367
  appendEvent(
343
368
  events,
344
- handler.viewTag,
369
+ handler,
345
370
  "topGestureHandlerEvent",
346
371
  payloadFor(
347
372
  handlerTag,
@@ -365,8 +390,11 @@ std::vector<RecognizedGesture> processPointer(const RawPointerEvent& pointer) {
365
390
  pointer);
366
391
  }
367
392
  }
368
- if (gestureTracingEnabled() && (pointer.phase != 4 || !events.empty())) {
369
- LOG(INFO) << "[gesture-handler] recognized events=" << events.size();
393
+ if (gestureTracingEnabled() &&
394
+ (pointer.phase != 4 || !events.viewEvents.empty() ||
395
+ !events.deviceEvents.empty())) {
396
+ LOG(INFO) << "[gesture-handler] recognized events="
397
+ << events.viewEvents.size() + events.deviceEvents.size();
370
398
  }
371
399
  return events;
372
400
  }
@@ -479,7 +507,18 @@ class GPUIGestureHandlerModule final
479
507
  bool installUIRuntimeBindings(Runtime&) {
480
508
  return true;
481
509
  }
510
+
511
+ void emit(const std::string& name, folly::dynamic payload) {
512
+ emitDeviceEvent(
513
+ name,
514
+ [payload = std::move(payload)](
515
+ Runtime& runtime, std::vector<facebook::jsi::Value>& args) {
516
+ args.emplace_back(facebook::jsi::valueFromDynamic(runtime, payload));
517
+ });
518
+ }
482
519
  };
520
+
521
+ std::weak_ptr<GPUIGestureHandlerModule> currentModule;
483
522
  } // namespace
484
523
 
485
524
  std::shared_ptr<facebook::react::TurboModule>
@@ -491,10 +530,19 @@ create_gpui_gesture_handler_module(
491
530
  }
492
531
  rngpui::registerPointerObserver(
493
532
  [](const rngpui::extension::RawPointerEvent& pointer) {
494
- return processPointer(pointer);
533
+ auto events = processPointer(pointer);
534
+ if (auto module = currentModule.lock()) {
535
+ for (auto& [name, payload] : events.deviceEvents) {
536
+ module->emit(name, std::move(payload));
537
+ }
538
+ }
539
+ return std::move(events.viewEvents);
495
540
  });
496
541
  if (gestureTracingEnabled()) {
497
542
  LOG(INFO) << "[gesture-handler] native pointer processor installed";
498
543
  }
499
- return std::make_shared<GPUIGestureHandlerModule>(std::move(jsInvoker));
544
+ auto module =
545
+ std::make_shared<GPUIGestureHandlerModule>(std::move(jsInvoker));
546
+ currentModule = module;
547
+ return module;
500
548
  }
package/package.json CHANGED
@@ -1,21 +1,23 @@
1
1
  {
2
2
  "name": "@react-native-gpui/gesture-handler",
3
- "version": "3.3.0-alpha.0",
4
- "description": "Native GPUI gesture recognition for react-native-gesture-handler",
3
+ "version": "3.3.0-alpha.1",
4
+ "description": "Adapter for react-native-gesture-handler (MIT): recognizes gestures from the mouse, trackpad and touch screen",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git+https://github.com/streetwriters/react-native-gpui.git",
8
+ "url": "git+https://github.com/streetwriters/react-native-gpui-modules.git",
9
9
  "directory": "modules/gesture-handler"
10
10
  },
11
- "homepage": "https://streetwriters.github.io/react-native-gpui/",
11
+ "homepage": "https://github.com/streetwriters/react-native-gpui-modules/tree/main/modules/gesture-handler#readme",
12
12
  "bugs": {
13
- "url": "https://github.com/streetwriters/react-native-gpui/issues"
13
+ "url": "https://github.com/streetwriters/react-native-gpui-modules/issues"
14
14
  },
15
15
  "files": [
16
16
  "desktop",
17
17
  "react-native.config.js",
18
18
  "src",
19
+ "README.md",
20
+ "LICENSE",
19
21
  "CHANGELOG.md",
20
22
  "!**/*.test.js",
21
23
  "!**/*.test.mjs",