react-native-windows 0.74.29 → 0.74.31

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 (70) hide show
  1. package/Libraries/Components/Button.windows.js +9 -0
  2. package/Libraries/Components/Pressable/Pressable.windows.js +9 -0
  3. package/Libraries/Components/TextInput/TextInput.windows.js +11 -1
  4. package/Libraries/Components/Touchable/TouchableBounce.windows.js +225 -0
  5. package/Libraries/Components/Touchable/TouchableNativeFeedback.windows.js +373 -0
  6. package/Libraries/Components/Touchable/TouchableOpacity.windows.js +7 -0
  7. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +10 -0
  8. package/Libraries/Components/View/View.windows.js +11 -1
  9. package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  10. package/Libraries/Components/View/ViewAccessibility.windows.js +5 -2
  11. package/Libraries/Components/View/ViewPropTypes.windows.js +3 -0
  12. package/Libraries/Image/Image.windows.js +7 -0
  13. package/Libraries/Text/Text.windows.js +11 -1
  14. package/Libraries/Text/TextProps.windows.js +3 -0
  15. package/Microsoft.ReactNative/CompositionComponentView.idl +13 -1
  16. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +1 -2
  17. package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -1
  18. package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +0 -5
  19. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +293 -9
  20. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +28 -1
  21. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +13 -32
  22. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +1 -3
  23. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +1 -1
  24. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h +2 -1
  25. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +18 -5
  26. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +1 -1
  27. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +191 -329
  28. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +3 -61
  29. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.cpp +66 -0
  30. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.h +52 -0
  31. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +21 -0
  32. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +7 -4
  33. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +79 -19
  34. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +12 -6
  35. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +71 -17
  36. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +16 -0
  37. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +1 -1
  38. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +1 -1
  39. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +62 -33
  40. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +5 -2
  41. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +1 -6
  42. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +0 -3
  43. package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +0 -2
  44. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +5 -0
  45. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +19 -1
  46. package/Microsoft.ReactNative/ReactNativeHost.cpp +5 -0
  47. package/Microsoft.ReactNative/ReactNativeIsland.idl +5 -1
  48. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  49. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +253 -0
  50. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +799 -0
  51. package/Shared/Shared.vcxitems +3 -2
  52. package/Shared/Shared.vcxitems.filters +2 -3
  53. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +204 -0
  54. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +287 -0
  55. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +192 -0
  56. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +216 -0
  57. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +242 -0
  58. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +259 -0
  59. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +226 -0
  60. package/codegen/react/components/rnwcore/InputAccessory.g.h +192 -0
  61. package/codegen/react/components/rnwcore/ModalHostView.g.h +271 -0
  62. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +238 -0
  63. package/codegen/react/components/rnwcore/SafeAreaView.g.h +189 -0
  64. package/codegen/react/components/rnwcore/Switch.g.h +255 -0
  65. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +192 -0
  66. package/just-task.js +1 -1
  67. package/package.json +1 -1
  68. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentDescriptor.h +0 -39
  69. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.cpp +0 -18
  70. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.h +0 -39
@@ -0,0 +1,259 @@
1
+
2
+ /*
3
+ * This file is auto-generated from AndroidSwitchNativeComponent spec file in flow / TypeScript.
4
+ */
5
+ // clang-format off
6
+ #pragma once
7
+
8
+ #include <JSValueComposition.h>
9
+ #include <NativeModules.h>
10
+ #include <winrt/Microsoft.ReactNative.Composition.h>
11
+ #include <winrt/Microsoft.UI.Composition.h>
12
+
13
+ namespace Microsoft::ReactNativeSpecs {
14
+
15
+ REACT_STRUCT(AndroidSwitchProps)
16
+ struct AndroidSwitchProps : winrt::implements<AndroidSwitchProps, winrt::Microsoft::ReactNative::IComponentProps> {
17
+ AndroidSwitchProps(winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom)
18
+ : ViewProps(props)
19
+ {
20
+ if (cloneFrom) {
21
+ auto cloneFromProps = cloneFrom.as<AndroidSwitchProps>();
22
+ disabled = cloneFromProps->disabled;
23
+ enabled = cloneFromProps->enabled;
24
+ thumbColor = cloneFromProps->thumbColor;
25
+ trackColorForFalse = cloneFromProps->trackColorForFalse;
26
+ trackColorForTrue = cloneFromProps->trackColorForTrue;
27
+ value = cloneFromProps->value;
28
+ on = cloneFromProps->on;
29
+ thumbTintColor = cloneFromProps->thumbTintColor;
30
+ trackTintColor = cloneFromProps->trackTintColor;
31
+ }
32
+ }
33
+
34
+ void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept {
35
+ winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this);
36
+ }
37
+
38
+ REACT_FIELD(disabled)
39
+ std::optional<bool> disabled{};
40
+
41
+ REACT_FIELD(enabled)
42
+ bool enabled{true};
43
+
44
+ REACT_FIELD(thumbColor)
45
+ winrt::Microsoft::ReactNative::Color thumbColor{nullptr};
46
+
47
+ REACT_FIELD(trackColorForFalse)
48
+ winrt::Microsoft::ReactNative::Color trackColorForFalse{nullptr};
49
+
50
+ REACT_FIELD(trackColorForTrue)
51
+ winrt::Microsoft::ReactNative::Color trackColorForTrue{nullptr};
52
+
53
+ REACT_FIELD(value)
54
+ std::optional<bool> value{};
55
+
56
+ REACT_FIELD(on)
57
+ std::optional<bool> on{};
58
+
59
+ REACT_FIELD(thumbTintColor)
60
+ winrt::Microsoft::ReactNative::Color thumbTintColor{nullptr};
61
+
62
+ REACT_FIELD(trackTintColor)
63
+ winrt::Microsoft::ReactNative::Color trackTintColor{nullptr};
64
+
65
+ const winrt::Microsoft::ReactNative::ViewProps ViewProps;
66
+ };
67
+
68
+ REACT_STRUCT(AndroidSwitch_OnChange)
69
+ struct AndroidSwitch_OnChange {
70
+ REACT_FIELD(value)
71
+ bool value{};
72
+
73
+ REACT_FIELD(target)
74
+ int32_t target{};
75
+ };
76
+
77
+ struct AndroidSwitchEventEmitter {
78
+ AndroidSwitchEventEmitter(const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter)
79
+ : m_eventEmitter(eventEmitter) {}
80
+
81
+ using OnChange = AndroidSwitch_OnChange;
82
+
83
+ void onChange(OnChange &value) const {
84
+ m_eventEmitter.DispatchEvent(L"change", [value](const winrt::Microsoft::ReactNative::IJSValueWriter writer) {
85
+ winrt::Microsoft::ReactNative::WriteValue(writer, value);
86
+ });
87
+ }
88
+
89
+ private:
90
+ winrt::Microsoft::ReactNative::EventEmitter m_eventEmitter{nullptr};
91
+ };
92
+
93
+ template<typename TUserData>
94
+ struct BaseAndroidSwitch {
95
+
96
+ virtual void UpdateProps(
97
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
98
+ const winrt::com_ptr<AndroidSwitchProps> &newProps,
99
+ const winrt::com_ptr<AndroidSwitchProps> &/*oldProps*/) noexcept {
100
+ m_props = newProps;
101
+ }
102
+
103
+ // UpdateLayoutMetrics will only be called if this method is overridden
104
+ virtual void UpdateLayoutMetrics(
105
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
106
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*newLayoutMetrics*/,
107
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*oldLayoutMetrics*/) noexcept {
108
+ }
109
+
110
+ // UpdateState will only be called if this method is overridden
111
+ virtual void UpdateState(
112
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
113
+ const winrt::Microsoft::ReactNative::IComponentState &/*newState*/) noexcept {
114
+ }
115
+
116
+ virtual void UpdateEventEmitter(const std::shared_ptr<AndroidSwitchEventEmitter> &eventEmitter) noexcept {
117
+ m_eventEmitter = eventEmitter;
118
+ }
119
+
120
+ // MountChildComponentView will only be called if this method is overridden
121
+ virtual void MountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
122
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &/*args*/) noexcept {
123
+ }
124
+
125
+ // UnmountChildComponentView will only be called if this method is overridden
126
+ virtual void UnmountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
127
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &/*args*/) noexcept {
128
+ }
129
+
130
+ // Initialize will only be called if this method is overridden
131
+ virtual void Initialize(const winrt::Microsoft::ReactNative::ComponentView &/*view*/) noexcept {
132
+ }
133
+
134
+ // CreateVisual will only be called if this method is overridden
135
+ virtual winrt::Microsoft::UI::Composition::Visual CreateVisual(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
136
+ return view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Compositor().CreateSpriteVisual();
137
+ }
138
+
139
+ // FinalizeUpdate will only be called if this method is overridden
140
+ virtual void FinalizeUpdate(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
141
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) noexcept {
142
+ }
143
+
144
+ // You must provide an implementation of this method to handle the "setNativeValue" command
145
+ virtual void HandleSetNativeValueCommand(bool value) noexcept = 0;
146
+
147
+ void HandleCommand(const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::HandleCommandArgs& args) noexcept {
148
+ auto userData = view.UserData().as<TUserData>();
149
+ auto commandName = args.CommandName();
150
+ if (commandName == L"setNativeValue") {
151
+ bool value;
152
+ winrt::Microsoft::ReactNative::ReadArgs(args.CommandArgs(), value);
153
+ userData->HandleSetNativeValueCommand(value);
154
+ return;
155
+ }
156
+ }
157
+
158
+ const std::shared_ptr<AndroidSwitchEventEmitter>& EventEmitter() const { return m_eventEmitter; }
159
+ const winrt::com_ptr<AndroidSwitchProps>& Props() const { return m_props; }
160
+
161
+ private:
162
+ winrt::com_ptr<AndroidSwitchProps> m_props;
163
+ std::shared_ptr<AndroidSwitchEventEmitter> m_eventEmitter;
164
+ };
165
+
166
+ template <typename TUserData>
167
+ void RegisterAndroidSwitchNativeComponent(
168
+ winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder,
169
+ std::function<void(const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder&)> builderCallback) noexcept {
170
+ packageBuilder.as<winrt::Microsoft::ReactNative::IReactPackageBuilderFabric>().AddViewComponent(
171
+ L"AndroidSwitch", [builderCallback](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept {
172
+ auto compBuilder = builder.as<winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder>();
173
+
174
+ builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props,
175
+ const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) noexcept {
176
+ return winrt::make<AndroidSwitchProps>(props, cloneFrom);
177
+ });
178
+
179
+ builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
180
+ const winrt::Microsoft::ReactNative::IComponentProps &newProps,
181
+ const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept {
182
+ auto userData = view.UserData().as<TUserData>();
183
+ userData->UpdateProps(view, newProps ? newProps.as<AndroidSwitchProps>() : nullptr, oldProps ? oldProps.as<AndroidSwitchProps>() : nullptr);
184
+ });
185
+
186
+ compBuilder.SetUpdateLayoutMetricsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
187
+ const winrt::Microsoft::ReactNative::LayoutMetrics &newLayoutMetrics,
188
+ const winrt::Microsoft::ReactNative::LayoutMetrics &oldLayoutMetrics) noexcept {
189
+ auto userData = view.UserData().as<TUserData>();
190
+ userData->UpdateLayoutMetrics(view, newLayoutMetrics, oldLayoutMetrics);
191
+ });
192
+
193
+ builder.SetUpdateEventEmitterHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
194
+ const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) noexcept {
195
+ auto userData = view.UserData().as<TUserData>();
196
+ userData->UpdateEventEmitter(std::make_shared<AndroidSwitchEventEmitter>(eventEmitter));
197
+ });
198
+
199
+ if constexpr (&TUserData::FinalizeUpdate != &BaseAndroidSwitch<TUserData>::FinalizeUpdate) {
200
+ builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
201
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
202
+ auto userData = view.UserData().as<TUserData>();
203
+ userData->FinalizeUpdate(view, mask);
204
+ });
205
+ }
206
+
207
+ if constexpr (&TUserData::UpdateState != &BaseAndroidSwitch<TUserData>::UpdateState) {
208
+ builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
209
+ const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
210
+ auto userData = view.UserData().as<TUserData>();
211
+ userData->member(view, newState);
212
+ });
213
+ }
214
+
215
+ builder.SetCustomCommandHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
216
+ const winrt::Microsoft::ReactNative::HandleCommandArgs& args) noexcept {
217
+ auto userData = view.UserData().as<TUserData>();
218
+ userData->HandleCommand(view, args);
219
+ });
220
+
221
+ if constexpr (&TUserData::MountChildComponentView != &BaseAndroidSwitch<TUserData>::MountChildComponentView) {
222
+ builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
223
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
224
+ auto userData = view.UserData().as<TUserData>();
225
+ return userData->MountChildComponentView(view, args);
226
+ });
227
+ }
228
+
229
+ if constexpr (&TUserData::UnmountChildComponentView != &BaseAndroidSwitch<TUserData>::UnmountChildComponentView) {
230
+ builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
231
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
232
+ auto userData = view.UserData().as<TUserData>();
233
+ return userData->UnmountChildComponentView(view, args);
234
+ });
235
+ }
236
+
237
+ compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
238
+ auto userData = winrt::make_self<TUserData>();
239
+ if constexpr (&TUserData::Initialize != &BaseAndroidSwitch<TUserData>::Initialize) {
240
+ userData->Initialize(view);
241
+ }
242
+ view.UserData(*userData);
243
+ });
244
+
245
+ if constexpr (&TUserData::CreateVisual != &BaseAndroidSwitch<TUserData>::CreateVisual) {
246
+ compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
247
+ auto userData = view.UserData().as<TUserData>();
248
+ return userData->CreateVisual(view);
249
+ });
250
+ }
251
+
252
+ // Allow app to further customize the builder
253
+ if (builderCallback) {
254
+ builderCallback(compBuilder);
255
+ }
256
+ });
257
+ }
258
+
259
+ } // namespace Microsoft::ReactNativeSpecs
@@ -0,0 +1,226 @@
1
+
2
+ /*
3
+ * This file is auto-generated from DebuggingOverlayNativeComponent spec file in flow / TypeScript.
4
+ */
5
+ // clang-format off
6
+ #pragma once
7
+
8
+ #include <JSValueComposition.h>
9
+ #include <NativeModules.h>
10
+ #include <winrt/Microsoft.ReactNative.Composition.h>
11
+ #include <winrt/Microsoft.UI.Composition.h>
12
+
13
+ namespace Microsoft::ReactNativeSpecs {
14
+
15
+ REACT_STRUCT(DebuggingOverlayProps)
16
+ struct DebuggingOverlayProps : winrt::implements<DebuggingOverlayProps, winrt::Microsoft::ReactNative::IComponentProps> {
17
+ DebuggingOverlayProps(winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom)
18
+ : ViewProps(props)
19
+ {
20
+ if (cloneFrom) {
21
+ auto cloneFromProps = cloneFrom.as<DebuggingOverlayProps>();
22
+
23
+ }
24
+ }
25
+
26
+ void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept {
27
+ winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this);
28
+ }
29
+
30
+ const winrt::Microsoft::ReactNative::ViewProps ViewProps;
31
+ };
32
+
33
+ struct DebuggingOverlayEventEmitter {
34
+ DebuggingOverlayEventEmitter(const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter)
35
+ : m_eventEmitter(eventEmitter) {}
36
+
37
+ private:
38
+ winrt::Microsoft::ReactNative::EventEmitter m_eventEmitter{nullptr};
39
+ };
40
+
41
+ template<typename TUserData>
42
+ struct BaseDebuggingOverlay {
43
+
44
+ virtual void UpdateProps(
45
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
46
+ const winrt::com_ptr<DebuggingOverlayProps> &newProps,
47
+ const winrt::com_ptr<DebuggingOverlayProps> &/*oldProps*/) noexcept {
48
+ m_props = newProps;
49
+ }
50
+
51
+ // UpdateLayoutMetrics will only be called if this method is overridden
52
+ virtual void UpdateLayoutMetrics(
53
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
54
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*newLayoutMetrics*/,
55
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*oldLayoutMetrics*/) noexcept {
56
+ }
57
+
58
+ // UpdateState will only be called if this method is overridden
59
+ virtual void UpdateState(
60
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
61
+ const winrt::Microsoft::ReactNative::IComponentState &/*newState*/) noexcept {
62
+ }
63
+
64
+ virtual void UpdateEventEmitter(const std::shared_ptr<DebuggingOverlayEventEmitter> &eventEmitter) noexcept {
65
+ m_eventEmitter = eventEmitter;
66
+ }
67
+
68
+ // MountChildComponentView will only be called if this method is overridden
69
+ virtual void MountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
70
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &/*args*/) noexcept {
71
+ }
72
+
73
+ // UnmountChildComponentView will only be called if this method is overridden
74
+ virtual void UnmountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
75
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &/*args*/) noexcept {
76
+ }
77
+
78
+ // Initialize will only be called if this method is overridden
79
+ virtual void Initialize(const winrt::Microsoft::ReactNative::ComponentView &/*view*/) noexcept {
80
+ }
81
+
82
+ // CreateVisual will only be called if this method is overridden
83
+ virtual winrt::Microsoft::UI::Composition::Visual CreateVisual(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
84
+ return view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Compositor().CreateSpriteVisual();
85
+ }
86
+
87
+ // FinalizeUpdate will only be called if this method is overridden
88
+ virtual void FinalizeUpdate(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
89
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) noexcept {
90
+ }
91
+
92
+ // You must provide an implementation of this method to handle the "highlightTraceUpdates" command
93
+ virtual void HandleHighlightTraceUpdatesCommand(std::vector<winrt::Microsoft::ReactNative::JSValue> updates) noexcept = 0;
94
+
95
+ // You must provide an implementation of this method to handle the "highlightElements" command
96
+ virtual void HandleHighlightElementsCommand(std::vector<winrt::Microsoft::ReactNative::JSValue> elements) noexcept = 0;
97
+
98
+ // You must provide an implementation of this method to handle the "clearElementsHighlights" command
99
+ virtual void HandleClearElementsHighlightsCommand() noexcept = 0;
100
+
101
+ void HandleCommand(const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::HandleCommandArgs& args) noexcept {
102
+ auto userData = view.UserData().as<TUserData>();
103
+ auto commandName = args.CommandName();
104
+ if (commandName == L"highlightTraceUpdates") {
105
+ std::vector<winrt::Microsoft::ReactNative::JSValue> updates;
106
+ winrt::Microsoft::ReactNative::ReadArgs(args.CommandArgs(), updates);
107
+ userData->HandleHighlightTraceUpdatesCommand(updates);
108
+ return;
109
+ }
110
+
111
+ if (commandName == L"highlightElements") {
112
+ std::vector<winrt::Microsoft::ReactNative::JSValue> elements;
113
+ winrt::Microsoft::ReactNative::ReadArgs(args.CommandArgs(), elements);
114
+ userData->HandleHighlightElementsCommand(elements);
115
+ return;
116
+ }
117
+
118
+ if (commandName == L"clearElementsHighlights") {
119
+
120
+ userData->HandleClearElementsHighlightsCommand();
121
+ return;
122
+ }
123
+ }
124
+
125
+ const std::shared_ptr<DebuggingOverlayEventEmitter>& EventEmitter() const { return m_eventEmitter; }
126
+ const winrt::com_ptr<DebuggingOverlayProps>& Props() const { return m_props; }
127
+
128
+ private:
129
+ winrt::com_ptr<DebuggingOverlayProps> m_props;
130
+ std::shared_ptr<DebuggingOverlayEventEmitter> m_eventEmitter;
131
+ };
132
+
133
+ template <typename TUserData>
134
+ void RegisterDebuggingOverlayNativeComponent(
135
+ winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder,
136
+ std::function<void(const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder&)> builderCallback) noexcept {
137
+ packageBuilder.as<winrt::Microsoft::ReactNative::IReactPackageBuilderFabric>().AddViewComponent(
138
+ L"DebuggingOverlay", [builderCallback](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept {
139
+ auto compBuilder = builder.as<winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder>();
140
+
141
+ builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props,
142
+ const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) noexcept {
143
+ return winrt::make<DebuggingOverlayProps>(props, cloneFrom);
144
+ });
145
+
146
+ builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
147
+ const winrt::Microsoft::ReactNative::IComponentProps &newProps,
148
+ const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept {
149
+ auto userData = view.UserData().as<TUserData>();
150
+ userData->UpdateProps(view, newProps ? newProps.as<DebuggingOverlayProps>() : nullptr, oldProps ? oldProps.as<DebuggingOverlayProps>() : nullptr);
151
+ });
152
+
153
+ compBuilder.SetUpdateLayoutMetricsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
154
+ const winrt::Microsoft::ReactNative::LayoutMetrics &newLayoutMetrics,
155
+ const winrt::Microsoft::ReactNative::LayoutMetrics &oldLayoutMetrics) noexcept {
156
+ auto userData = view.UserData().as<TUserData>();
157
+ userData->UpdateLayoutMetrics(view, newLayoutMetrics, oldLayoutMetrics);
158
+ });
159
+
160
+ builder.SetUpdateEventEmitterHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
161
+ const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) noexcept {
162
+ auto userData = view.UserData().as<TUserData>();
163
+ userData->UpdateEventEmitter(std::make_shared<DebuggingOverlayEventEmitter>(eventEmitter));
164
+ });
165
+
166
+ if constexpr (&TUserData::FinalizeUpdate != &BaseDebuggingOverlay<TUserData>::FinalizeUpdate) {
167
+ builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
168
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
169
+ auto userData = view.UserData().as<TUserData>();
170
+ userData->FinalizeUpdate(view, mask);
171
+ });
172
+ }
173
+
174
+ if constexpr (&TUserData::UpdateState != &BaseDebuggingOverlay<TUserData>::UpdateState) {
175
+ builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
176
+ const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
177
+ auto userData = view.UserData().as<TUserData>();
178
+ userData->member(view, newState);
179
+ });
180
+ }
181
+
182
+ builder.SetCustomCommandHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
183
+ const winrt::Microsoft::ReactNative::HandleCommandArgs& args) noexcept {
184
+ auto userData = view.UserData().as<TUserData>();
185
+ userData->HandleCommand(view, args);
186
+ });
187
+
188
+ if constexpr (&TUserData::MountChildComponentView != &BaseDebuggingOverlay<TUserData>::MountChildComponentView) {
189
+ builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
190
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
191
+ auto userData = view.UserData().as<TUserData>();
192
+ return userData->MountChildComponentView(view, args);
193
+ });
194
+ }
195
+
196
+ if constexpr (&TUserData::UnmountChildComponentView != &BaseDebuggingOverlay<TUserData>::UnmountChildComponentView) {
197
+ builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
198
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
199
+ auto userData = view.UserData().as<TUserData>();
200
+ return userData->UnmountChildComponentView(view, args);
201
+ });
202
+ }
203
+
204
+ compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
205
+ auto userData = winrt::make_self<TUserData>();
206
+ if constexpr (&TUserData::Initialize != &BaseDebuggingOverlay<TUserData>::Initialize) {
207
+ userData->Initialize(view);
208
+ }
209
+ view.UserData(*userData);
210
+ });
211
+
212
+ if constexpr (&TUserData::CreateVisual != &BaseDebuggingOverlay<TUserData>::CreateVisual) {
213
+ compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
214
+ auto userData = view.UserData().as<TUserData>();
215
+ return userData->CreateVisual(view);
216
+ });
217
+ }
218
+
219
+ // Allow app to further customize the builder
220
+ if (builderCallback) {
221
+ builderCallback(compBuilder);
222
+ }
223
+ });
224
+ }
225
+
226
+ } // namespace Microsoft::ReactNativeSpecs
@@ -0,0 +1,192 @@
1
+
2
+ /*
3
+ * This file is auto-generated from InputAccessoryNativeComponent spec file in flow / TypeScript.
4
+ */
5
+ // clang-format off
6
+ #pragma once
7
+
8
+ #include <JSValueComposition.h>
9
+ #include <NativeModules.h>
10
+ #include <winrt/Microsoft.ReactNative.Composition.h>
11
+ #include <winrt/Microsoft.UI.Composition.h>
12
+
13
+ namespace Microsoft::ReactNativeSpecs {
14
+
15
+ REACT_STRUCT(InputAccessoryProps)
16
+ struct InputAccessoryProps : winrt::implements<InputAccessoryProps, winrt::Microsoft::ReactNative::IComponentProps> {
17
+ InputAccessoryProps(winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom)
18
+ : ViewProps(props)
19
+ {
20
+ if (cloneFrom) {
21
+ auto cloneFromProps = cloneFrom.as<InputAccessoryProps>();
22
+ backgroundColor = cloneFromProps->backgroundColor;
23
+ }
24
+ }
25
+
26
+ void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept {
27
+ winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this);
28
+ }
29
+
30
+ REACT_FIELD(backgroundColor)
31
+ winrt::Microsoft::ReactNative::Color backgroundColor{nullptr};
32
+
33
+ const winrt::Microsoft::ReactNative::ViewProps ViewProps;
34
+ };
35
+
36
+ struct InputAccessoryEventEmitter {
37
+ InputAccessoryEventEmitter(const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter)
38
+ : m_eventEmitter(eventEmitter) {}
39
+
40
+ private:
41
+ winrt::Microsoft::ReactNative::EventEmitter m_eventEmitter{nullptr};
42
+ };
43
+
44
+ template<typename TUserData>
45
+ struct BaseInputAccessory {
46
+
47
+ virtual void UpdateProps(
48
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
49
+ const winrt::com_ptr<InputAccessoryProps> &newProps,
50
+ const winrt::com_ptr<InputAccessoryProps> &/*oldProps*/) noexcept {
51
+ m_props = newProps;
52
+ }
53
+
54
+ // UpdateLayoutMetrics will only be called if this method is overridden
55
+ virtual void UpdateLayoutMetrics(
56
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
57
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*newLayoutMetrics*/,
58
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*oldLayoutMetrics*/) noexcept {
59
+ }
60
+
61
+ // UpdateState will only be called if this method is overridden
62
+ virtual void UpdateState(
63
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
64
+ const winrt::Microsoft::ReactNative::IComponentState &/*newState*/) noexcept {
65
+ }
66
+
67
+ virtual void UpdateEventEmitter(const std::shared_ptr<InputAccessoryEventEmitter> &eventEmitter) noexcept {
68
+ m_eventEmitter = eventEmitter;
69
+ }
70
+
71
+ // MountChildComponentView will only be called if this method is overridden
72
+ virtual void MountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
73
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &/*args*/) noexcept {
74
+ }
75
+
76
+ // UnmountChildComponentView will only be called if this method is overridden
77
+ virtual void UnmountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
78
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &/*args*/) noexcept {
79
+ }
80
+
81
+ // Initialize will only be called if this method is overridden
82
+ virtual void Initialize(const winrt::Microsoft::ReactNative::ComponentView &/*view*/) noexcept {
83
+ }
84
+
85
+ // CreateVisual will only be called if this method is overridden
86
+ virtual winrt::Microsoft::UI::Composition::Visual CreateVisual(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
87
+ return view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Compositor().CreateSpriteVisual();
88
+ }
89
+
90
+ // FinalizeUpdate will only be called if this method is overridden
91
+ virtual void FinalizeUpdate(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
92
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) noexcept {
93
+ }
94
+
95
+
96
+
97
+ const std::shared_ptr<InputAccessoryEventEmitter>& EventEmitter() const { return m_eventEmitter; }
98
+ const winrt::com_ptr<InputAccessoryProps>& Props() const { return m_props; }
99
+
100
+ private:
101
+ winrt::com_ptr<InputAccessoryProps> m_props;
102
+ std::shared_ptr<InputAccessoryEventEmitter> m_eventEmitter;
103
+ };
104
+
105
+ template <typename TUserData>
106
+ void RegisterInputAccessoryNativeComponent(
107
+ winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder,
108
+ std::function<void(const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder&)> builderCallback) noexcept {
109
+ packageBuilder.as<winrt::Microsoft::ReactNative::IReactPackageBuilderFabric>().AddViewComponent(
110
+ L"InputAccessory", [builderCallback](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept {
111
+ auto compBuilder = builder.as<winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder>();
112
+
113
+ builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props,
114
+ const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) noexcept {
115
+ return winrt::make<InputAccessoryProps>(props, cloneFrom);
116
+ });
117
+
118
+ builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
119
+ const winrt::Microsoft::ReactNative::IComponentProps &newProps,
120
+ const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept {
121
+ auto userData = view.UserData().as<TUserData>();
122
+ userData->UpdateProps(view, newProps ? newProps.as<InputAccessoryProps>() : nullptr, oldProps ? oldProps.as<InputAccessoryProps>() : nullptr);
123
+ });
124
+
125
+ compBuilder.SetUpdateLayoutMetricsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
126
+ const winrt::Microsoft::ReactNative::LayoutMetrics &newLayoutMetrics,
127
+ const winrt::Microsoft::ReactNative::LayoutMetrics &oldLayoutMetrics) noexcept {
128
+ auto userData = view.UserData().as<TUserData>();
129
+ userData->UpdateLayoutMetrics(view, newLayoutMetrics, oldLayoutMetrics);
130
+ });
131
+
132
+ builder.SetUpdateEventEmitterHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
133
+ const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) noexcept {
134
+ auto userData = view.UserData().as<TUserData>();
135
+ userData->UpdateEventEmitter(std::make_shared<InputAccessoryEventEmitter>(eventEmitter));
136
+ });
137
+
138
+ if constexpr (&TUserData::FinalizeUpdate != &BaseInputAccessory<TUserData>::FinalizeUpdate) {
139
+ builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
140
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
141
+ auto userData = view.UserData().as<TUserData>();
142
+ userData->FinalizeUpdate(view, mask);
143
+ });
144
+ }
145
+
146
+ if constexpr (&TUserData::UpdateState != &BaseInputAccessory<TUserData>::UpdateState) {
147
+ builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
148
+ const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
149
+ auto userData = view.UserData().as<TUserData>();
150
+ userData->member(view, newState);
151
+ });
152
+ }
153
+
154
+ if constexpr (&TUserData::MountChildComponentView != &BaseInputAccessory<TUserData>::MountChildComponentView) {
155
+ builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
156
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
157
+ auto userData = view.UserData().as<TUserData>();
158
+ return userData->MountChildComponentView(view, args);
159
+ });
160
+ }
161
+
162
+ if constexpr (&TUserData::UnmountChildComponentView != &BaseInputAccessory<TUserData>::UnmountChildComponentView) {
163
+ builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
164
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
165
+ auto userData = view.UserData().as<TUserData>();
166
+ return userData->UnmountChildComponentView(view, args);
167
+ });
168
+ }
169
+
170
+ compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
171
+ auto userData = winrt::make_self<TUserData>();
172
+ if constexpr (&TUserData::Initialize != &BaseInputAccessory<TUserData>::Initialize) {
173
+ userData->Initialize(view);
174
+ }
175
+ view.UserData(*userData);
176
+ });
177
+
178
+ if constexpr (&TUserData::CreateVisual != &BaseInputAccessory<TUserData>::CreateVisual) {
179
+ compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
180
+ auto userData = view.UserData().as<TUserData>();
181
+ return userData->CreateVisual(view);
182
+ });
183
+ }
184
+
185
+ // Allow app to further customize the builder
186
+ if (builderCallback) {
187
+ builderCallback(compBuilder);
188
+ }
189
+ });
190
+ }
191
+
192
+ } // namespace Microsoft::ReactNativeSpecs