react-native-windows 0.81.11 → 0.81.13

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.
@@ -85,6 +85,8 @@ type MouseEventProps = $ReadOnly<{
85
85
 
86
86
  // Experimental/Work in Progress Pointer Event Callbacks (not yet ready for use)
87
87
  type PointerEventProps = $ReadOnly<{
88
+ onAuxClick?: ?(event: PointerEvent) => void, // [Windows]
89
+ onAuxClickCapture?: ?(event: PointerEvent) => void, // [Windows]
88
90
  onClick?: ?(event: PointerEvent) => void,
89
91
  onClickCapture?: ?(event: PointerEvent) => void,
90
92
  onPointerEnter?: ?(event: PointerEvent) => void,
@@ -85,6 +85,14 @@ const bubblingEventTypes = {
85
85
  },
86
86
  },
87
87
  // Experimental/Work in Progress Pointer Events (not yet ready for use)
88
+ // [Windows
89
+ topAuxClick: {
90
+ phasedRegistrationNames: {
91
+ captured: 'onAuxClickCapture',
92
+ bubbled: 'onAuxClick',
93
+ },
94
+ },
95
+ // Windows]
88
96
  topClick: {
89
97
  phasedRegistrationNames: {
90
98
  captured: 'onClickCapture',
@@ -383,7 +391,6 @@ const validAttributesForNonEventProps = {
383
391
  keyUpEvents: true, // [Windows]
384
392
  tabIndex: true, // [Windows]
385
393
  tooltip: true, // [Windows]
386
- onClick: true, // [Windows]
387
394
  enableFocusRing: true, // [Windows]
388
395
  importantForAccessibility: true, // [Windows]
389
396
 
@@ -424,6 +431,8 @@ const validAttributesForEventProps = {
424
431
  onTouchCancel: true,
425
432
 
426
433
  // Pointer events
434
+ onAuxClick: true, // [Windows]
435
+ onAuxClickCapture: true, // [Windows]
427
436
  onClick: true,
428
437
  onClickCapture: true,
429
438
  onPointerUp: true,
@@ -992,8 +992,6 @@ void CompositionEventHandler::UpdateActiveTouch(
992
992
  // activeTouch.touch.shiftKey = false;
993
993
  // activeTouch.touch.ctrlKey = false;
994
994
  // activeTouch.touch.altKey = false;
995
-
996
- // activeTouch.touch.isPrimary = true;
997
995
  }
998
996
 
999
997
  facebook::react::PointerEvent CreatePointerEventFromIncompleteHoverData(
@@ -1252,7 +1250,7 @@ void CompositionEventHandler::onPointerPressed(
1252
1250
  ->eventEmitterAtPoint(ptLocal)) {
1253
1251
  activeTouch.eventEmitter = eventEmitter;
1254
1252
  activeTouch.touch.target = targetComponentView.Tag();
1255
- // activeTouch.componentView = componentView;
1253
+ activeTouch.initialComponentView = targetComponentView;
1256
1254
  break;
1257
1255
  }
1258
1256
  targetComponentView = targetComponentView.Parent();
@@ -1260,7 +1258,7 @@ void CompositionEventHandler::onPointerPressed(
1260
1258
 
1261
1259
  UpdateActiveTouch(activeTouch, ptScaled, ptLocal);
1262
1260
 
1263
- // activeTouch.touch.isPrimary = true;
1261
+ activeTouch.isPrimary = pointerId == 1;
1264
1262
  activeTouch.touch.identifier = pointerId;
1265
1263
 
1266
1264
  // If the pointer has not been marked as hovering over views before the touch started, we register
@@ -1465,11 +1463,26 @@ facebook::react::PointerEvent CompositionEventHandler::CreatePointerEventFromAct
1465
1463
 
1466
1464
  // event.tangentialPressure = 0.0;
1467
1465
  // event.twist = 0;
1468
- // event.isPrimary = activeTouch.isPrimary;
1466
+ event.isPrimary = activeTouch.isPrimary;
1469
1467
 
1470
1468
  return event;
1471
1469
  }
1472
1470
 
1471
+ bool CompositionEventHandler::IsPointerWithinInitialTree(const ActiveTouch &activeTouch) noexcept {
1472
+ auto initialComponentView = activeTouch.initialComponentView.view();
1473
+ if (!initialComponentView)
1474
+ return false;
1475
+
1476
+ auto initialViewSet = GetTouchableViewsInPathToRoot(initialComponentView);
1477
+
1478
+ for (const auto &view : initialViewSet) {
1479
+ if (view.Tag() == activeTouch.touch.target)
1480
+ return true;
1481
+ }
1482
+
1483
+ return false;
1484
+ }
1485
+
1473
1486
  // If we have events that include multiple pointer updates, we should change arg from pointerId to vector<pointerId>
1474
1487
  void CompositionEventHandler::DispatchTouchEvent(
1475
1488
  TouchEventType eventType,
@@ -1526,6 +1539,13 @@ void CompositionEventHandler::DispatchTouchEvent(
1526
1539
  }
1527
1540
  case TouchEventType::End:
1528
1541
  activeTouch.eventEmitter->onPointerUp(pointerEvent);
1542
+ if (pointerEvent.isPrimary && pointerEvent.button == 0) {
1543
+ if (IsPointerWithinInitialTree(activeTouch)) {
1544
+ activeTouch.eventEmitter->onClick(pointerEvent);
1545
+ }
1546
+ } else if (IsPointerWithinInitialTree(activeTouch)) {
1547
+ activeTouch.eventEmitter->onAuxClick(pointerEvent);
1548
+ }
1529
1549
  break;
1530
1550
  case TouchEventType::Cancel:
1531
1551
  case TouchEventType::CaptureLost:
@@ -138,9 +138,10 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
138
138
  /*
139
139
  * A component view on which the touch was begun.
140
140
  */
141
- //__strong UIView<RCTComponentViewProtocol> *componentView = nil;
141
+ ReactTaggedView initialComponentView{nullptr};
142
142
  };
143
143
 
144
+ static bool IsPointerWithinInitialTree(const ActiveTouch &activeTouch) noexcept;
144
145
  static bool IsEndishEventType(TouchEventType eventType) noexcept;
145
146
  static const char *PointerTypeCStringFromUITouchType(UITouchType type) noexcept;
146
147
  static facebook::react::PointerEvent CreatePointerEventFromActiveTouch(
@@ -18,7 +18,7 @@ struct ReactTaggedView {
18
18
  ReactTaggedView(const winrt::Microsoft::ReactNative::ComponentView &componentView)
19
19
  : m_view(componentView), m_tag(componentView ? componentView.Tag() : -1) {}
20
20
 
21
- winrt::Microsoft::ReactNative::ComponentView view() noexcept {
21
+ winrt::Microsoft::ReactNative::ComponentView view() const noexcept {
22
22
  if (!m_view) {
23
23
  return nullptr;
24
24
  }
@@ -37,7 +37,7 @@ struct ReactTaggedView {
37
37
 
38
38
  private:
39
39
  facebook::react::Tag m_tag;
40
- winrt::weak_ref<winrt::Microsoft::ReactNative::ComponentView> m_view;
40
+ mutable winrt::weak_ref<winrt::Microsoft::ReactNative::ComponentView> m_view;
41
41
  };
42
42
 
43
43
  } // namespace Microsoft::ReactNative
@@ -17,19 +17,23 @@
17
17
  // The macros below are internal implementation details for macro defined in nativeModules.h
18
18
  //
19
19
 
20
+ // ADL-based fallback: returns false for any type not tagged by the macros below.
21
+ // Using ADL instead of explicit template specialization allows the macros to be
22
+ // used inside a namespace (explicit specializations of a global template must
23
+ // occur at global scope, which the macros cannot guarantee).
20
24
  template <typename T>
21
- struct IsReactTurboModule;
25
+ constexpr bool ReactIsReactTurboModuleImpl(T *) noexcept {
26
+ return false;
27
+ }
22
28
 
23
- // Default to false if no specific override
24
29
  template <typename T>
25
- struct IsReactTurboModule : std::false_type {};
30
+ struct IsReactTurboModule : std::bool_constant<ReactIsReactTurboModuleImpl(static_cast<T *>(nullptr))> {};
26
31
 
27
32
  #define INTERNAL_REACT_MODULE_REGISTRATION_AND_PROVIDER( \
28
33
  moduleStruct, moduleName, eventEmitterName, isReactTurboModule) \
29
34
  struct moduleStruct; \
30
35
  \
31
- template <> \
32
- struct IsReactTurboModule<moduleStruct> : std::isReactTurboModule##_type {}; \
36
+ constexpr bool ReactIsReactTurboModuleImpl(moduleStruct *) noexcept { return isReactTurboModule; } \
33
37
  \
34
38
  template <class TDummy> \
35
39
  struct moduleStruct##_ModuleRegistration final : winrt::Microsoft::ReactNative::ModuleRegistration { \
@@ -66,17 +70,16 @@ struct IsReactTurboModule : std::false_type {};
66
70
  INTERNAL_REACT_RECOMPOSER_4( \
67
71
  (__VA_ARGS__, INTERNAL_REACT_MODULE_3_ARGS, INTERNAL_REACT_MODULE_2_ARGS, INTERNAL_REACT_MODULE_1_ARG, ))
68
72
 
69
- #define INTERNAL_REACT_MODULE_NO_REGISTRATION_AND_PROVIDER( \
70
- moduleStruct, moduleName, eventEmitterName, isReactTurboModule) \
71
- struct moduleStruct; \
72
- \
73
- template <> \
74
- struct IsReactTurboModule<moduleStruct> : std::isReactTurboModule##_type {}; \
75
- \
76
- template <class TRegistry> \
77
- constexpr void GetReactModuleInfo(moduleStruct *, TRegistry &registry) noexcept { \
78
- registry.RegisterModule( \
79
- moduleName, eventEmitterName, winrt::Microsoft::ReactNative::ReactAttributeId<__COUNTER__>{}); \
73
+ #define INTERNAL_REACT_MODULE_NO_REGISTRATION_AND_PROVIDER( \
74
+ moduleStruct, moduleName, eventEmitterName, isReactTurboModule) \
75
+ struct moduleStruct; \
76
+ \
77
+ [[maybe_unused]] constexpr bool ReactIsReactTurboModuleImpl(moduleStruct *) noexcept { return isReactTurboModule; } \
78
+ \
79
+ template <class TRegistry> \
80
+ constexpr void GetReactModuleInfo(moduleStruct *, TRegistry &registry) noexcept { \
81
+ registry.RegisterModule( \
82
+ moduleName, eventEmitterName, winrt::Microsoft::ReactNative::ReactAttributeId<__COUNTER__>{}); \
80
83
  }
81
84
 
82
85
  // Another version of REACT_MODULE but does not do auto registration
@@ -918,7 +918,7 @@ struct ModuleEventFieldInfo<TFunc<void(TArgs...)> TModule::*> {
918
918
  return [module = static_cast<ModuleType *>(module), field](IReactContext const &) noexcept {
919
919
  // Default emitter will do nothing
920
920
  // This will be replaced with a method that will call the jsi EventEmitter when JS requests the emitter
921
- module->*field = [](TArgs... args) noexcept {};
921
+ module->*field = [](TArgs... /*args*/) noexcept {};
922
922
  };
923
923
  } else {
924
924
  return [module = static_cast<ModuleType *>(module), field, eventName, eventEmitterName](
@@ -10,11 +10,11 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.81.11</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.81.13</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>81</ReactNativeWindowsMinor>
16
- <ReactNativeWindowsPatch>11</ReactNativeWindowsPatch>
16
+ <ReactNativeWindowsPatch>13</ReactNativeWindowsPatch>
17
17
  <ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
18
- <ReactNativeWindowsCommitId>a964ab588ab12db0b975f848c88d7a0b750d6cba</ReactNativeWindowsCommitId>
18
+ <ReactNativeWindowsCommitId>57c33949c2f2863a51817500cec9bdd795d459dc</ReactNativeWindowsCommitId>
19
19
  </PropertyGroup>
20
20
  </Project>
@@ -0,0 +1,151 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #include "TouchEventEmitter.h"
9
+
10
+ namespace facebook::react {
11
+
12
+ #pragma mark - Touches
13
+
14
+ static jsi::Value touchesPayload(
15
+ jsi::Runtime& runtime,
16
+ const Touches& touches) {
17
+ auto array = jsi::Array(runtime, touches.size());
18
+ int i = 0;
19
+ for (const auto& touch : touches) {
20
+ auto object = jsi::Object(runtime);
21
+ setTouchPayloadOnObject(object, runtime, touch);
22
+ array.setValueAtIndex(runtime, i++, object);
23
+ }
24
+ return array;
25
+ }
26
+
27
+ static jsi::Value touchEventPayload(
28
+ jsi::Runtime& runtime,
29
+ const TouchEvent& event) {
30
+ auto object = jsi::Object(runtime);
31
+ object.setProperty(
32
+ runtime, "touches", touchesPayload(runtime, event.touches));
33
+ object.setProperty(
34
+ runtime, "changedTouches", touchesPayload(runtime, event.changedTouches));
35
+ object.setProperty(
36
+ runtime, "targetTouches", touchesPayload(runtime, event.targetTouches));
37
+
38
+ if (!event.changedTouches.empty()) {
39
+ const auto& firstChangedTouch = *event.changedTouches.begin();
40
+ setTouchPayloadOnObject(object, runtime, firstChangedTouch);
41
+ }
42
+ return object;
43
+ }
44
+
45
+ void TouchEventEmitter::dispatchTouchEvent(
46
+ std::string type,
47
+ TouchEvent event,
48
+ RawEvent::Category category) const {
49
+ dispatchEvent(
50
+ std::move(type),
51
+ [event = std::move(event)](jsi::Runtime& runtime) {
52
+ return touchEventPayload(runtime, event);
53
+ },
54
+ category);
55
+ }
56
+
57
+ void TouchEventEmitter::dispatchPointerEvent(
58
+ std::string type,
59
+ PointerEvent event,
60
+ RawEvent::Category category) const {
61
+ dispatchEvent(
62
+ std::move(type),
63
+ std::make_shared<PointerEvent>(std::move(event)),
64
+ category);
65
+ }
66
+
67
+ void TouchEventEmitter::onTouchStart(TouchEvent event) const {
68
+ dispatchTouchEvent(
69
+ "touchStart", std::move(event), RawEvent::Category::ContinuousStart);
70
+ }
71
+
72
+ void TouchEventEmitter::onTouchMove(TouchEvent event) const {
73
+ dispatchUniqueEvent(
74
+ "touchMove", [event = std::move(event)](jsi::Runtime& runtime) {
75
+ return touchEventPayload(runtime, event);
76
+ });
77
+ }
78
+
79
+ void TouchEventEmitter::onTouchEnd(TouchEvent event) const {
80
+ dispatchTouchEvent(
81
+ "touchEnd", std::move(event), RawEvent::Category::ContinuousEnd);
82
+ }
83
+
84
+ void TouchEventEmitter::onTouchCancel(TouchEvent event) const {
85
+ dispatchTouchEvent(
86
+ "touchCancel", std::move(event), RawEvent::Category::ContinuousEnd);
87
+ }
88
+
89
+ void TouchEventEmitter::onAuxClick(PointerEvent event) const {
90
+ dispatchPointerEvent("auxClick", std::move(event), RawEvent::Category::Discrete);
91
+ }
92
+
93
+ void TouchEventEmitter::onClick(PointerEvent event) const {
94
+ dispatchPointerEvent("click", std::move(event), RawEvent::Category::Discrete);
95
+ }
96
+
97
+ void TouchEventEmitter::onPointerCancel(PointerEvent event) const {
98
+ dispatchPointerEvent(
99
+ "pointerCancel", std::move(event), RawEvent::Category::ContinuousEnd);
100
+ }
101
+
102
+ void TouchEventEmitter::onPointerDown(PointerEvent event) const {
103
+ dispatchPointerEvent(
104
+ "pointerDown", std::move(event), RawEvent::Category::ContinuousStart);
105
+ }
106
+
107
+ void TouchEventEmitter::onPointerMove(PointerEvent event) const {
108
+ dispatchUniqueEvent(
109
+ "pointerMove", std::make_shared<PointerEvent>(std::move(event)));
110
+ }
111
+
112
+ void TouchEventEmitter::onPointerUp(PointerEvent event) const {
113
+ dispatchPointerEvent(
114
+ "pointerUp", std::move(event), RawEvent::Category::ContinuousEnd);
115
+ }
116
+
117
+ void TouchEventEmitter::onPointerEnter(PointerEvent event) const {
118
+ dispatchPointerEvent(
119
+ "pointerEnter", std::move(event), RawEvent::Category::ContinuousStart);
120
+ }
121
+
122
+ void TouchEventEmitter::onPointerLeave(PointerEvent event) const {
123
+ dispatchPointerEvent(
124
+ "pointerLeave", std::move(event), RawEvent::Category::ContinuousEnd);
125
+ }
126
+
127
+ void TouchEventEmitter::onPointerOver(PointerEvent event) const {
128
+ dispatchPointerEvent(
129
+ "pointerOver", std::move(event), RawEvent::Category::ContinuousStart);
130
+ }
131
+
132
+ void TouchEventEmitter::onPointerOut(PointerEvent event) const {
133
+ dispatchPointerEvent(
134
+ "pointerOut", std::move(event), RawEvent::Category::ContinuousStart);
135
+ }
136
+
137
+ void TouchEventEmitter::onGotPointerCapture(PointerEvent event) const {
138
+ dispatchPointerEvent(
139
+ "gotPointerCapture",
140
+ std::move(event),
141
+ RawEvent::Category::ContinuousStart);
142
+ }
143
+
144
+ void TouchEventEmitter::onLostPointerCapture(PointerEvent event) const {
145
+ dispatchPointerEvent(
146
+ "lostPointerCapture",
147
+ std::move(event),
148
+ RawEvent::Category::ContinuousEnd);
149
+ }
150
+
151
+ } // namespace facebook::react
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <react/renderer/components/view/PointerEvent.h>
11
+ #include <react/renderer/components/view/TouchEvent.h>
12
+ #include <react/renderer/core/EventEmitter.h>
13
+ #include <react/renderer/core/LayoutMetrics.h>
14
+ #include <react/renderer/core/ReactPrimitives.h>
15
+ #include <react/renderer/debug/DebugStringConvertible.h>
16
+
17
+ namespace facebook::react {
18
+
19
+ class TouchEventEmitter;
20
+
21
+ using SharedTouchEventEmitter = std::shared_ptr<const TouchEventEmitter>;
22
+
23
+ class TouchEventEmitter : public EventEmitter {
24
+ public:
25
+ using EventEmitter::EventEmitter;
26
+
27
+ void onTouchStart(TouchEvent event) const;
28
+ void onTouchMove(TouchEvent event) const;
29
+ void onTouchEnd(TouchEvent event) const;
30
+ void onTouchCancel(TouchEvent event) const;
31
+
32
+ void onAuxClick(PointerEvent event) const; // [Windows]
33
+ void onClick(PointerEvent event) const;
34
+ void onPointerCancel(PointerEvent event) const;
35
+ void onPointerDown(PointerEvent event) const;
36
+ void onPointerMove(PointerEvent event) const;
37
+ void onPointerUp(PointerEvent event) const;
38
+ void onPointerEnter(PointerEvent event) const;
39
+ void onPointerLeave(PointerEvent event) const;
40
+ void onPointerOver(PointerEvent event) const;
41
+ void onPointerOut(PointerEvent event) const;
42
+ void onGotPointerCapture(PointerEvent event) const;
43
+ void onLostPointerCapture(PointerEvent event) const;
44
+
45
+ private:
46
+ void dispatchTouchEvent(std::string type, TouchEvent event, RawEvent::Category category) const;
47
+ void dispatchPointerEvent(std::string type, PointerEvent event, RawEvent::Category category) const;
48
+ };
49
+
50
+ } // namespace facebook::react
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.81.11",
3
+ "version": "0.81.13",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",