react-native-windows 0.0.0-canary.721 → 0.0.0-canary.723

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/.flowconfig +0 -1
  2. package/Libraries/Components/Pressable/Pressable.windows.js +0 -1
  3. package/Libraries/Components/TextInput/TextInput.windows.js +5 -5
  4. package/Libraries/Components/View/View.windows.js +17 -5
  5. package/Libraries/Pressability/Pressability.windows.js +2 -2
  6. package/Microsoft.ReactNative/Composition.Input.idl +7 -0
  7. package/Microsoft.ReactNative/Fabric/ComponentView.h +3 -1
  8. package/Microsoft.ReactNative/Fabric/Composition/AbiCompositionViewComponentView.cpp +11 -4
  9. package/Microsoft.ReactNative/Fabric/Composition/AbiCompositionViewComponentView.h +4 -1
  10. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +46 -0
  11. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +25 -0
  12. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +56 -15
  13. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +4 -0
  14. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +17 -0
  15. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +8 -4
  16. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +5 -1
  17. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +13 -15
  18. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +6 -5
  19. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +44 -26
  20. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +6 -3
  21. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +4 -7
  22. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +2 -1
  23. package/Microsoft.ReactNative/Utils/ImageUtils.cpp +52 -3
  24. package/PropertySheets/Generated/PackageVersion.g.props +2 -2
  25. package/Shared/Modules/BlobCollector.cpp +21 -0
  26. package/Shared/Modules/BlobCollector.h +23 -0
  27. package/Shared/Modules/BlobModule.cpp +19 -0
  28. package/Shared/Shared.vcxitems +3 -1
  29. package/Shared/Shared.vcxitems.filters +6 -0
  30. package/package.json +7 -7
  31. package/template/metro.config.js +12 -7
  32. package/template/metro.devMode.config.js +14 -7
  33. package/templates/cpp-app/metro.config.js +12 -7
  34. package/Libraries/Components/ScrollView/ScrollView.windows.js +0 -1941
package/.flowconfig CHANGED
@@ -14,7 +14,6 @@
14
14
  <PROJECT_ROOT>/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js
15
15
  <PROJECT_ROOT>/Libraries/Components/RefreshControl/RefreshControl.js
16
16
  <PROJECT_ROOT>/Libraries/Components/SafeAreaView/SafeAreaView.js
17
- <PROJECT_ROOT>/Libraries/Components/ScrollView/ScrollView.js
18
17
  <PROJECT_ROOT>/Libraries/Components/TextInput/TextInput.js
19
18
  <PROJECT_ROOT>/Libraries/Components/TextInput/TextInputState.js
20
19
  <PROJECT_ROOT>/Libraries/Components/Touchable/Touchable.js
@@ -36,7 +36,6 @@ import useAndroidRippleForView, {
36
36
  import * as React from 'react';
37
37
  import {useImperativeHandle, useMemo, useRef, useState} from 'react';
38
38
  import type {HandledKeyboardEvent} from '../../Components/View/ViewPropTypes';
39
- import TextInputState from '../TextInput/TextInputState';
40
39
 
41
40
  type ViewStyleProp = $ElementType<React.ElementConfig<typeof View>, 'style'>;
42
41
 
@@ -1522,8 +1522,8 @@ function InternalTextInput(props: Props): React.Node {
1522
1522
  // $FlowFixMe - keyDownEvents was already checked to not be undefined
1523
1523
  for (const el of props.keyDownEvents) {
1524
1524
  if (
1525
- event.nativeEvent.code == el.code &&
1526
- el.handledEventPhase == eventPhase.Bubbling
1525
+ event.nativeEvent.code === el.code &&
1526
+ el.handledEventPhase === eventPhase.Bubbling
1527
1527
  ) {
1528
1528
  event.stopPropagation();
1529
1529
  }
@@ -1536,7 +1536,7 @@ function InternalTextInput(props: Props): React.Node {
1536
1536
  if (props.keyUpEvents && event.isPropagationStopped() !== true) {
1537
1537
  // $FlowFixMe - keyDownEvents was already checked to not be undefined
1538
1538
  for (const el of props.keyUpEvents) {
1539
- if (event.nativeEvent.code == el.code && el.handledEventPhase == 3) {
1539
+ if (event.nativeEvent.code === el.code && el.handledEventPhase === 3) {
1540
1540
  event.stopPropagation();
1541
1541
  }
1542
1542
  }
@@ -1548,7 +1548,7 @@ function InternalTextInput(props: Props): React.Node {
1548
1548
  if (props.keyDownEvents && event.isPropagationStopped() !== true) {
1549
1549
  // $FlowFixMe - keyDownEvents was already checked to not be undefined
1550
1550
  for (const el of props.keyDownEvents) {
1551
- if (event.nativeEvent.code == el.code && el.handledEventPhase == 1) {
1551
+ if (event.nativeEvent.code === el.code && el.handledEventPhase === 1) {
1552
1552
  event.stopPropagation();
1553
1553
  }
1554
1554
  }
@@ -1560,7 +1560,7 @@ function InternalTextInput(props: Props): React.Node {
1560
1560
  if (props.keyUpEvents && event.isPropagationStopped() !== true) {
1561
1561
  // $FlowFixMe - keyDownEvents was already checked to not be undefined
1562
1562
  for (const el of props.keyUpEvents) {
1563
- if (event.nativeEvent.code == el.code && el.handledEventPhase == 1) {
1563
+ if (event.nativeEvent.code === el.code && el.handledEventPhase === 1) {
1564
1564
  event.stopPropagation();
1565
1565
  }
1566
1566
  }
@@ -126,7 +126,10 @@ const View: React.AbstractComponent<
126
126
  if (otherProps.keyDownEvents && event.isPropagationStopped() !== true) {
127
127
  // $FlowFixMe - keyDownEvents was already checked to not be undefined
128
128
  for (const el of otherProps.keyDownEvents) {
129
- if (event.nativeEvent.code == el.code && el.handledEventPhase == 3) {
129
+ if (
130
+ event.nativeEvent.code === el.code &&
131
+ el.handledEventPhase === 3
132
+ ) {
130
133
  event.stopPropagation();
131
134
  }
132
135
  }
@@ -138,7 +141,10 @@ const View: React.AbstractComponent<
138
141
  if (otherProps.keyUpEvents && event.isPropagationStopped() !== true) {
139
142
  // $FlowFixMe - keyDownEvents was already checked to not be undefined
140
143
  for (const el of otherProps.keyUpEvents) {
141
- if (event.nativeEvent.code == el.code && el.handledEventPhase == 3) {
144
+ if (
145
+ event.nativeEvent.code === el.code &&
146
+ el.handledEventPhase === 3
147
+ ) {
142
148
  event.stopPropagation();
143
149
  }
144
150
  }
@@ -150,7 +156,10 @@ const View: React.AbstractComponent<
150
156
  if (otherProps.keyDownEvents && event.isPropagationStopped() !== true) {
151
157
  // $FlowFixMe - keyDownEvents was already checked to not be undefined
152
158
  for (const el of otherProps.keyDownEvents) {
153
- if (event.nativeEvent.code == el.code && el.handledEventPhase == 1) {
159
+ if (
160
+ event.nativeEvent.code === el.code &&
161
+ el.handledEventPhase === 1
162
+ ) {
154
163
  event.stopPropagation();
155
164
  }
156
165
  }
@@ -162,7 +171,10 @@ const View: React.AbstractComponent<
162
171
  if (otherProps.keyUpEvents && event.isPropagationStopped() !== true) {
163
172
  // $FlowFixMe - keyDownEvents was already checked to not be undefined
164
173
  for (const el of otherProps.keyUpEvents) {
165
- if (event.nativeEvent.code == el.code && el.handledEventPhase == 1) {
174
+ if (
175
+ event.nativeEvent.code === el.code &&
176
+ el.handledEventPhase === 1
177
+ ) {
166
178
  event.stopPropagation();
167
179
  }
168
180
  }
@@ -191,7 +203,7 @@ const View: React.AbstractComponent<
191
203
  }
192
204
  return child;
193
205
  });
194
- if (updatedChildren.length == 1) {
206
+ if (updatedChildren.length === 1) {
195
207
  return updatedChildren[0];
196
208
  } else {
197
209
  return updatedChildren;
@@ -629,7 +629,7 @@ export default class Pressability {
629
629
  (event.nativeEvent.code === 'Space' ||
630
630
  event.nativeEvent.code === 'Enter' ||
631
631
  event.nativeEvent.code === 'GamepadA') &&
632
- event.defaultPrevented != true &&
632
+ event.defaultPrevented !== true &&
633
633
  this._isKeyDown
634
634
  ) {
635
635
  const {onPressOut, onPress} = this._config;
@@ -649,7 +649,7 @@ export default class Pressability {
649
649
  (event.nativeEvent.code === 'Space' ||
650
650
  event.nativeEvent.code === 'Enter' ||
651
651
  event.nativeEvent.code === 'GamepadA') &&
652
- event.defaultPrevented != true
652
+ event.defaultPrevented !== true
653
653
  ) {
654
654
  const {onPressIn} = this._config;
655
655
  this._isKeyDown = true;
@@ -25,6 +25,13 @@ namespace Microsoft.ReactNative.Composition.Input
25
25
  Windows.System.VirtualKey OriginalKey { get; };
26
26
  }
27
27
 
28
+ interface CharacterReceivedRoutedEventArgs requires RoutedEventArgs
29
+ {
30
+ Boolean Handled { get; set; };
31
+ Windows.UI.Core.CorePhysicalKeyStatus KeyStatus { get; };
32
+ Int32 KeyCode { get; };
33
+ };
34
+
28
35
  interface IPointerPointTransform
29
36
  {
30
37
  IPointerPointTransform Inverse { get; };
@@ -87,6 +87,9 @@ struct IComponentView {
87
87
  virtual void onKeyUp(
88
88
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
89
89
  const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept = 0;
90
+ virtual void onCharacterReceived(
91
+ const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
92
+ const winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs &args) noexcept = 0;
90
93
  virtual bool focusable() const noexcept = 0;
91
94
  virtual facebook::react::SharedViewEventEmitter eventEmitterAtPoint(facebook::react::Point pt) noexcept = 0;
92
95
  virtual facebook::react::SharedViewEventEmitter eventEmitter() noexcept = 0;
@@ -97,7 +100,6 @@ struct IComponentView {
97
100
  facebook::react::Point pt,
98
101
  facebook::react::Point &localPt,
99
102
  bool ignorePointerEvents = false) const noexcept = 0;
100
- virtual int64_t sendMessage(uint32_t msg, uint64_t wParam, int64_t lParam) noexcept = 0;
101
103
  virtual winrt::IInspectable EnsureUiaProvider() noexcept = 0;
102
104
  // Notify up the tree to bring the rect into view by scrolling as needed
103
105
  virtual void StartBringIntoView(BringIntoViewOptions &&args) noexcept = 0;
@@ -57,7 +57,11 @@ void AbiCompositionViewComponentView::updateProps(
57
57
  const auto &oldViewProps = *std::static_pointer_cast<const AbiViewProps>(m_props);
58
58
  const auto &newViewProps = *std::static_pointer_cast<const AbiViewProps>(props);
59
59
 
60
+ updateAccessibilityProps(oldViewProps, newViewProps);
61
+ // updateShadowProps(oldViewProps, newViewProps, m_visual);
62
+ // updateTransformProps(oldViewProps, newViewProps, m_visual);
60
63
  updateBorderProps(oldViewProps, newViewProps);
64
+
61
65
  Builder().UpdateProps(m_handle, newViewProps.UserProps());
62
66
 
63
67
  m_props = std::static_pointer_cast<AbiViewProps const>(props);
@@ -101,10 +105,6 @@ bool AbiCompositionViewComponentView::focusable() const noexcept {
101
105
  return m_props->focusable;
102
106
  }
103
107
 
104
- int64_t AbiCompositionViewComponentView::sendMessage(uint32_t msg, uint64_t wParam, int64_t lParam) noexcept {
105
- return Builder().SendMessage(m_handle, msg, wParam, lParam);
106
- }
107
-
108
108
  void AbiCompositionViewComponentView::onKeyDown(
109
109
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
110
110
  const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept {
@@ -119,6 +119,13 @@ void AbiCompositionViewComponentView::onKeyUp(
119
119
  Super::onKeyUp(source, args);
120
120
  }
121
121
 
122
+ void AbiCompositionViewComponentView::onCharacterReceived(
123
+ const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
124
+ const winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs &args) noexcept {
125
+ Builder().OnCharacterReceived(m_handle, source, args);
126
+ Super::onCharacterReceived(source, args);
127
+ }
128
+
122
129
  void AbiCompositionViewComponentView::onPointerEntered(
123
130
  const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
124
131
  Builder().OnPointerEntered(m_handle, args);
@@ -40,13 +40,16 @@ struct AbiCompositionViewComponentView : CompositionBaseComponentView {
40
40
  void finalizeUpdates(RNComponentViewUpdateMask updateMask) noexcept override;
41
41
  void prepareForRecycle() noexcept override;
42
42
  bool focusable() const noexcept override;
43
- int64_t sendMessage(uint32_t msg, uint64_t wParam, int64_t lParam) noexcept override;
44
43
  void onKeyDown(
45
44
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
46
45
  const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept override;
47
46
  void onKeyUp(
48
47
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
49
48
  const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept override;
49
+ void onCharacterReceived(
50
+ const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
51
+ const winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs &args) noexcept
52
+ override;
50
53
  void onPointerEntered(
51
54
  const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
52
55
  void onPointerExited(
@@ -75,6 +75,52 @@ winrt::Windows::System::VirtualKey KeyRoutedEventArgs::OriginalKey() noexcept {
75
75
  return m_key;
76
76
  }
77
77
 
78
+ CharacterReceivedRoutedEventArgs::CharacterReceivedRoutedEventArgs(
79
+ facebook::react::Tag tag,
80
+ uint32_t msg,
81
+ uint64_t wParam,
82
+ int64_t lParam) {
83
+ m_keycode = static_cast<int32_t>(wParam);
84
+ m_keyStatus.RepeatCount = (lParam & 0x0000FFFF); // bits 0-15
85
+ m_keyStatus.ScanCode = (lParam & 0x00FF0000) >> 16; // bits 16-23
86
+ m_keyStatus.IsExtendedKey = (lParam & 0x01000000) >> 24; // bit 24
87
+ m_keyStatus.IsMenuKeyDown = (lParam & 0x20000000) >> 29; // bit 29
88
+ m_keyStatus.WasKeyDown = (lParam & 0x40000000) >> 30; // bit 30
89
+ m_keyStatus.IsKeyReleased = (lParam & 0x80000000) >> 31; // bit 31
90
+ }
91
+
92
+ #ifdef USE_WINUI3
93
+ CharacterReceivedRoutedEventArgs::CharacterReceivedRoutedEventArgs(
94
+ facebook::react::Tag tag,
95
+ winrt::Microsoft::UI::Input::CharacterReceivedEventArgs const &args)
96
+ : m_tag(tag) {
97
+ auto keyStatus = args.KeyStatus();
98
+ m_keyStatus.RepeatCount = keyStatus.RepeatCount;
99
+ m_keyStatus.ScanCode = keyStatus.ScanCode;
100
+ m_keyStatus.IsExtendedKey = keyStatus.IsExtendedKey;
101
+ m_keyStatus.IsMenuKeyDown = keyStatus.IsMenuKeyDown;
102
+ m_keyStatus.WasKeyDown = keyStatus.WasKeyDown;
103
+ m_keyStatus.IsKeyReleased = keyStatus.IsKeyReleased;
104
+ m_keycode = args.KeyCode();
105
+ }
106
+ #endif
107
+
108
+ int32_t CharacterReceivedRoutedEventArgs::OriginalSource() noexcept {
109
+ return m_tag;
110
+ }
111
+ bool CharacterReceivedRoutedEventArgs::Handled() noexcept {
112
+ return m_handled;
113
+ }
114
+ void CharacterReceivedRoutedEventArgs::Handled(bool value) noexcept {
115
+ m_handled = value;
116
+ }
117
+ int32_t CharacterReceivedRoutedEventArgs::KeyCode() noexcept {
118
+ return m_keycode;
119
+ }
120
+ winrt::Windows::UI::Core::CorePhysicalKeyStatus CharacterReceivedRoutedEventArgs::KeyStatus() noexcept {
121
+ return m_keyStatus;
122
+ }
123
+
78
124
  #ifdef USE_WINUI3
79
125
  PointerPointProperties::PointerPointProperties(const winrt::Microsoft::UI::Input::PointerPointProperties &ppp)
80
126
  : m_sysPointerPointProps(ppp) {}
@@ -39,6 +39,31 @@ struct KeyRoutedEventArgs : winrt::implements<
39
39
  winrt::Windows::UI::Core::CorePhysicalKeyStatus m_keyStatus;
40
40
  };
41
41
 
42
+ struct CharacterReceivedRoutedEventArgs
43
+ : winrt::implements<
44
+ CharacterReceivedRoutedEventArgs,
45
+ winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs,
46
+ winrt::Microsoft::ReactNative::Composition::Input::RoutedEventArgs> {
47
+ CharacterReceivedRoutedEventArgs(facebook::react::Tag tag, uint32_t msg, uint64_t wParam, int64_t lParam);
48
+ #ifdef USE_WINUI3
49
+ CharacterReceivedRoutedEventArgs(
50
+ facebook::react::Tag tag,
51
+ winrt::Microsoft::UI::Input::CharacterReceivedEventArgs const &args);
52
+ #endif
53
+
54
+ int32_t OriginalSource() noexcept;
55
+ bool Handled() noexcept;
56
+ void Handled(bool value) noexcept;
57
+ int32_t KeyCode() noexcept;
58
+ winrt::Windows::UI::Core::CorePhysicalKeyStatus KeyStatus() noexcept;
59
+
60
+ private:
61
+ facebook::react::Tag m_tag{-1};
62
+ bool m_handled{false};
63
+ int32_t m_keycode;
64
+ winrt::Windows::UI::Core::CorePhysicalKeyStatus m_keyStatus;
65
+ };
66
+
42
67
  struct PointerPointProperties : PointerPointPropertiesT<PointerPointProperties> {
43
68
  #ifdef USE_WINUI3
44
69
  PointerPointProperties(const winrt::Microsoft::UI::Input::PointerPointProperties &ppp);
@@ -232,9 +232,31 @@ CompositionEventHandler::CompositionEventHandler(
232
232
  onKeyUp(keyboardSource, keyArgs);
233
233
  winrt::get_self<CompositionInputKeyboardSource>(keyboardSource)->Disconnect();
234
234
  });
235
+
236
+ m_characterReceivedToken =
237
+ keyboardSource.CharacterReceived([this](
238
+ winrt::Microsoft::UI::Input::InputKeyboardSource const &source,
239
+ winrt::Microsoft::UI::Input::CharacterReceivedEventArgs const &args) {
240
+ if (SurfaceId() == -1)
241
+ return;
242
+
243
+ auto focusedComponent = RootComponentView().GetFocusedComponent();
244
+ auto charArgs = winrt::make<
245
+ winrt::Microsoft::ReactNative::Composition::Input::implementation::CharacterReceivedRoutedEventArgs>(
246
+ focusedComponent
247
+ ? focusedComponent->tag()
248
+ : static_cast<facebook::react::Tag>(
249
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::CompositionRootView>(
250
+ m_compRootView)
251
+ ->GetTag()),
252
+ args);
253
+ auto keyboardSource = winrt::make<CompositionInputKeyboardSource>(source);
254
+ onCharacterReceived(keyboardSource, charArgs);
255
+ winrt::get_self<CompositionInputKeyboardSource>(keyboardSource)->Disconnect();
256
+ });
235
257
  }
236
258
  #endif
237
- };
259
+ }
238
260
 
239
261
  CompositionEventHandler::~CompositionEventHandler() {
240
262
  #ifdef USE_WINUI3
@@ -247,6 +269,7 @@ CompositionEventHandler::~CompositionEventHandler() {
247
269
  auto keyboardSource = winrt::Microsoft::UI::Input::InputKeyboardSource::GetForIsland(island);
248
270
  keyboardSource.KeyDown(m_keyDownToken);
249
271
  keyboardSource.KeyUp(m_keyUpToken);
272
+ keyboardSource.CharacterReceived(m_characterReceivedToken);
250
273
  }
251
274
  #endif
252
275
  }
@@ -357,13 +380,20 @@ int64_t CompositionEventHandler::SendMessage(uint32_t msg, uint64_t wParam, int6
357
380
  }
358
381
  case WM_CHAR:
359
382
  case WM_SYSCHAR: {
360
- // TODO full bubbling of events
361
- if (auto focusedComponent = RootComponentView().GetFocusedComponent()) {
362
- auto result = focusedComponent->sendMessage(msg, wParam, lParam);
363
- if (result)
364
- return result;
365
- }
366
- break;
383
+ auto focusedComponent = RootComponentView().GetFocusedComponent();
384
+ auto args = winrt::make<
385
+ winrt::Microsoft::ReactNative::Composition::Input::implementation::CharacterReceivedRoutedEventArgs>(
386
+ focusedComponent
387
+ ? focusedComponent->tag()
388
+ : static_cast<facebook::react::Tag>(
389
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::CompositionRootView>(m_compRootView)
390
+ ->GetTag()),
391
+ msg,
392
+ wParam,
393
+ lParam);
394
+ auto keyboardSource = winrt::make<CompositionKeyboardSource>(this);
395
+ onCharacterReceived(keyboardSource, args);
396
+ winrt::get_self<CompositionKeyboardSource>(keyboardSource)->Disconnect();
367
397
  }
368
398
  case WM_KEYDOWN:
369
399
  case WM_KEYUP:
@@ -404,8 +434,8 @@ void CompositionEventHandler::onKeyDown(
404
434
 
405
435
  bool fShift = source.GetKeyState(winrt::Windows::System::VirtualKey::Shift) ==
406
436
  winrt::Windows::UI::Core::CoreVirtualKeyStates::Down;
407
- bool fCtrl =
408
- GetKeyState(winrt::Windows::System::VirtualKey::Control) == winrt::Windows::UI::Core::CoreVirtualKeyStates::Down;
437
+ bool fCtrl = source.GetKeyState(winrt::Windows::System::VirtualKey::Control) ==
438
+ winrt::Windows::UI::Core::CoreVirtualKeyStates::Down;
409
439
 
410
440
  if (fShift && fCtrl && args.Key() == static_cast<winrt::Windows::System::VirtualKey>(VkKeyScanA('d')) &&
411
441
  Mso::React::ReactOptions::UseDeveloperSupport(m_context.Properties().Handle())) {
@@ -435,6 +465,17 @@ void CompositionEventHandler::onKeyUp(
435
465
  }
436
466
  }
437
467
 
468
+ void CompositionEventHandler::onCharacterReceived(
469
+ const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
470
+ const winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs &args) noexcept {
471
+ if (auto focusedComponent = RootComponentView().GetFocusedComponent()) {
472
+ focusedComponent->onCharacterReceived(source, args);
473
+
474
+ if (args.Handled())
475
+ return;
476
+ }
477
+ }
478
+
438
479
  std::vector<IComponentView *> GetTouchableViewsInPathToRoot(IComponentView *view) {
439
480
  std::vector<IComponentView *> results;
440
481
  while (view) {
@@ -448,11 +489,11 @@ std::vector<IComponentView *> GetTouchableViewsInPathToRoot(IComponentView *view
448
489
 
449
490
  /**
450
491
  * Private method which is used for tracking the location of pointer events to manage the entering/leaving events.
451
- * The primary idea is that a pointer's presence & movement is dictated by a variety of underlying events such as down,
452
- * move, and up — and they should all be treated the same when it comes to tracking the entering & leaving of pointers
453
- * to views. This method accomplishes that by receiving the pointer event, the target view (can be null in cases when
454
- * the event indicates that the pointer has left the screen entirely), and a block/callback where the underlying event
455
- * should be fired.
492
+ * The primary idea is that a pointer's presence & movement is dictated by a variety of underlying events such as
493
+ * down, move, and up — and they should all be treated the same when it comes to tracking the entering & leaving of
494
+ * pointers to views. This method accomplishes that by receiving the pointer event, the target view (can be null in
495
+ * cases when the event indicates that the pointer has left the screen entirely), and a block/callback where the
496
+ * underlying event should be fired.
456
497
  */
457
498
  void CompositionEventHandler::HandleIncomingPointerEvent(
458
499
  facebook::react::PointerEvent &event,
@@ -56,6 +56,9 @@ class CompositionEventHandler {
56
56
  void onKeyUp(
57
57
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
58
58
  const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept;
59
+ void onCharacterReceived(
60
+ const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
61
+ const winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs &args) noexcept;
59
62
 
60
63
  facebook::react::SurfaceId SurfaceId() noexcept;
61
64
  RootComponentView &RootComponentView() noexcept;
@@ -141,6 +144,7 @@ class CompositionEventHandler {
141
144
  winrt::event_token m_pointerWheelChangedToken;
142
145
  winrt::event_token m_keyDownToken;
143
146
  winrt::event_token m_keyUpToken;
147
+ winrt::event_token m_characterReceivedToken;
144
148
  #endif
145
149
  };
146
150
 
@@ -152,6 +152,23 @@ HRESULT __stdcall CompositionRootAutomationProvider::ElementProviderFromPoint(
152
152
 
153
153
  auto spRootView = std::static_pointer_cast<::Microsoft::ReactNative::RootComponentView>(strongView);
154
154
 
155
+ #ifdef USE_WINUI3
156
+ if (m_island) {
157
+ auto cc = m_island.CoordinateConverter();
158
+ auto local =
159
+ cc.ConvertScreenToLocal(winrt::Windows::Graphics::PointInt32{static_cast<int32_t>(x), static_cast<int32_t>(y)});
160
+ auto provider = spRootView->UiaProviderFromPoint(
161
+ {static_cast<LONG>(local.X * m_island.RasterizationScale()),
162
+ static_cast<LONG>(local.Y * m_island.RasterizationScale())});
163
+ auto spFragment = provider.try_as<IRawElementProviderFragment>();
164
+ if (spFragment) {
165
+ *pRetVal = spFragment.detach();
166
+ }
167
+
168
+ return S_OK;
169
+ }
170
+ #endif
171
+
155
172
  if (m_hwnd == nullptr || !IsWindow(m_hwnd)) {
156
173
  // TODO: Add support for non-HWND based hosting
157
174
  return E_FAIL;
@@ -138,10 +138,6 @@ void CompositionBaseComponentView::handleCommand(std::string const &commandName,
138
138
  assert(false); // Unhandled command
139
139
  }
140
140
 
141
- int64_t CompositionBaseComponentView::sendMessage(uint32_t msg, uint64_t wParam, int64_t lParam) noexcept {
142
- return 0;
143
- }
144
-
145
141
  void CompositionBaseComponentView::onKeyDown(
146
142
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
147
143
  const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept {
@@ -158,6 +154,14 @@ void CompositionBaseComponentView::onKeyUp(
158
154
  }
159
155
  }
160
156
 
157
+ void CompositionBaseComponentView::onCharacterReceived(
158
+ const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
159
+ const winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs &args) noexcept {
160
+ if (m_parent && !args.Handled()) {
161
+ m_parent->onCharacterReceived(source, args);
162
+ }
163
+ }
164
+
161
165
  void CompositionBaseComponentView::onPointerEntered(
162
166
  const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
163
167
  if (m_parent && !args.Handled()) {
@@ -54,13 +54,17 @@ struct CompositionBaseComponentView : public IComponentView,
54
54
  void onKeyUp(
55
55
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
56
56
  const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept override;
57
+ void onCharacterReceived(
58
+ const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
59
+ const winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs &args) noexcept
60
+ override;
61
+
57
62
  bool focusable() const noexcept override;
58
63
  std::vector<facebook::react::ComponentDescriptorProvider> supplementalComponentDescriptorProviders() noexcept
59
64
  override;
60
65
  facebook::react::SharedViewEventEmitter eventEmitter() noexcept override;
61
66
  facebook::react::SharedViewEventEmitter eventEmitterAtPoint(facebook::react::Point pt) noexcept override;
62
67
  facebook::react::Tag tag() const noexcept override;
63
- int64_t sendMessage(uint32_t msg, uint64_t wParam, int64_t lParam) noexcept override;
64
68
 
65
69
  RECT getClientRect() const noexcept override;
66
70
 
@@ -46,10 +46,6 @@ void ReactCompositionViewComponentBuilder::SetUpdateFinalizer(UpdateFinalizer im
46
46
  void ReactCompositionViewComponentBuilder::SetVisualCreator(Composition::VisualCreator impl) noexcept {
47
47
  m_visualCreator = impl;
48
48
  }
49
- // (Object handle, UInt32 Msg, UInt64 WParam, Int64 LParam) => Int64
50
- void ReactCompositionViewComponentBuilder::SetMessageHandler(MessageHandler impl) noexcept {
51
- m_messageHandler = impl;
52
- }
53
49
 
54
50
  void ReactCompositionViewComponentBuilder::SetKeyDownHandler(KeyHandler impl) noexcept {
55
51
  m_keyDown = impl;
@@ -59,6 +55,10 @@ void ReactCompositionViewComponentBuilder::SetKeyUpHandler(KeyHandler impl) noex
59
55
  m_keyUp = impl;
60
56
  }
61
57
 
58
+ void ReactCompositionViewComponentBuilder::SetCharacterReceivedHandler(CharacterReceivedHandler impl) noexcept {
59
+ m_characterReceived = impl;
60
+ }
61
+
62
62
  void ReactCompositionViewComponentBuilder::SetPointerEnteredHandler(PointerHandler impl) noexcept {
63
63
  m_pointerEntered = impl;
64
64
  }
@@ -125,17 +125,6 @@ IVisual ReactCompositionViewComponentBuilder::CreateVisual(winrt::Windows::Found
125
125
  return m_visualCreator(handle);
126
126
  }
127
127
 
128
- int64_t ReactCompositionViewComponentBuilder::SendMessage(
129
- winrt::Windows::Foundation::IInspectable handle,
130
- uint32_t msg,
131
- uint64_t wparam,
132
- int64_t lparam) noexcept {
133
- if (!m_messageHandler) {
134
- return 0;
135
- }
136
- return m_messageHandler(handle, msg, wparam, lparam);
137
- }
138
-
139
128
  void ReactCompositionViewComponentBuilder::OnKeyDown(
140
129
  winrt::Windows::Foundation::IInspectable handle,
141
130
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
@@ -154,6 +143,15 @@ void ReactCompositionViewComponentBuilder::OnKeyUp(
154
143
  }
155
144
  }
156
145
 
146
+ void ReactCompositionViewComponentBuilder::OnCharacterReceived(
147
+ winrt::Windows::Foundation::IInspectable handle,
148
+ const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
149
+ const winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs &args) noexcept {
150
+ if (m_characterReceived) {
151
+ m_characterReceived(handle, source, args);
152
+ }
153
+ }
154
+
157
155
  void ReactCompositionViewComponentBuilder::OnPointerEntered(
158
156
  winrt::Windows::Foundation::IInspectable handle,
159
157
  const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept {
@@ -30,11 +30,10 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
30
30
  void SetUpdateFinalizer(UpdateFinalizer impl) noexcept;
31
31
  // (Object handle) => IVisual
32
32
  void SetVisualCreator(VisualCreator impl) noexcept;
33
- // (Object handle, UInt32 Msg, UInt64 WParam, Int64 LParam) => Int64
34
- void SetMessageHandler(MessageHandler impl) noexcept;
35
33
 
36
34
  void SetKeyDownHandler(KeyHandler impl) noexcept;
37
35
  void SetKeyUpHandler(KeyHandler impl) noexcept;
36
+ void SetCharacterReceivedHandler(CharacterReceivedHandler impl) noexcept;
38
37
 
39
38
  void SetPointerEnteredHandler(PointerHandler impl) noexcept;
40
39
  void SetPointerExitedHandler(PointerHandler impl) noexcept;
@@ -55,8 +54,6 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
55
54
  void UpdateLayoutMetrics(winrt::Windows::Foundation::IInspectable handle, LayoutMetrics metrics) noexcept;
56
55
  void FinalizeUpdates(winrt::Windows::Foundation::IInspectable handle) noexcept;
57
56
  IVisual CreateVisual(winrt::Windows::Foundation::IInspectable handle) noexcept;
58
- int64_t
59
- SendMessage(winrt::Windows::Foundation::IInspectable handle, uint32_t Msg, uint64_t WParam, int64_t LParam) noexcept;
60
57
  void OnKeyDown(
61
58
  winrt::Windows::Foundation::IInspectable handle,
62
59
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
@@ -65,6 +62,10 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
65
62
  winrt::Windows::Foundation::IInspectable handle,
66
63
  const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
67
64
  const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept;
65
+ void OnCharacterReceived(
66
+ winrt::Windows::Foundation::IInspectable handle,
67
+ const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
68
+ const winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs &args) noexcept;
68
69
  void OnPointerEntered(
69
70
  winrt::Windows::Foundation::IInspectable handle,
70
71
  const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept;
@@ -93,9 +94,9 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
93
94
  LayoutMetricsUpdater m_layoutMetricsUpdater;
94
95
  UpdateFinalizer m_finalizer;
95
96
  VisualCreator m_visualCreator;
96
- MessageHandler m_messageHandler;
97
97
  KeyHandler m_keyUp;
98
98
  KeyHandler m_keyDown;
99
+ CharacterReceivedHandler m_characterReceived;
99
100
  PointerHandler m_pointerEntered;
100
101
  PointerHandler m_pointerExited;
101
102
  PointerHandler m_pointerReleased;