react-native-windows 0.77.7 → 0.77.8

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