react-native-windows 0.77.7 → 0.77.9

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 (55) 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 +82 -96
  34. package/Shared/Networking/WinRTWebSocketResource.h +91 -7
  35. package/Shared/Shared.vcxitems +6 -5
  36. package/Shared/Shared.vcxitems.filters +3 -4
  37. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +212 -0
  38. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +295 -0
  39. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +200 -0
  40. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +224 -0
  41. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +250 -0
  42. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +267 -0
  43. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +234 -0
  44. package/codegen/react/components/rnwcore/InputAccessory.g.h +200 -0
  45. package/codegen/react/components/rnwcore/ModalHostView.g.h +283 -0
  46. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +246 -0
  47. package/codegen/react/components/rnwcore/SafeAreaView.g.h +197 -0
  48. package/codegen/react/components/rnwcore/Switch.g.h +263 -0
  49. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +200 -0
  50. package/just-task.js +1 -1
  51. package/package.json +3 -3
  52. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +0 -191
  53. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentDescriptor.h +0 -39
  54. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.cpp +0 -18
  55. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.h +0 -39
@@ -89,7 +89,6 @@ DispatchQueue GetCurrentOrSerialQueue() noexcept {
89
89
 
90
90
  return queue;
91
91
  }
92
-
93
92
  } // namespace
94
93
 
95
94
  namespace Microsoft::React::Networking {
@@ -104,7 +103,6 @@ WinRTWebSocketResource2::WinRTWebSocketResource2(
104
103
  : m_socket{std::move(socket)},
105
104
  m_writer(std::move(writer)),
106
105
  m_readyState{ReadyState::Connecting},
107
- m_connectPerformed{CreateEvent(/*attributes*/ nullptr, /*manual reset*/ true, /*state*/ false, /*name*/ nullptr)},
108
106
  m_callingQueue{callingQueue} {
109
107
  for (const auto &certException : certExceptions) {
110
108
  m_socket.Control().IgnorableServerCertificateErrors().Append(certException);
@@ -221,120 +219,112 @@ void WinRTWebSocketResource2::OnClosed(IWebSocket const &sender, IWebSocketClose
221
219
 
222
220
  fire_and_forget WinRTWebSocketResource2::PerformConnect(Uri &&uri) noexcept {
223
221
  auto self = shared_from_this();
224
- auto coUri = std::move(uri);
222
+ auto movedUri = std::move(uri);
225
223
 
226
224
  co_await resume_in_queue(self->m_backgroundQueue);
227
225
 
228
- auto async = self->m_socket.ConnectAsync(coUri);
229
- co_await lessthrow_await_adapter<IAsyncAction>{async};
230
-
231
- co_await resume_in_queue(self->m_callingQueue);
232
-
233
- auto result = async.ErrorCode();
234
-
235
- try {
236
- if (result >= 0) { // Non-failing HRESULT
237
- co_await resume_in_queue(self->m_backgroundQueue);
238
- self->m_readyState = ReadyState::Open;
239
-
240
- co_await resume_in_queue(self->m_callingQueue);
241
- if (self->m_connectHandler) {
242
- self->m_connectHandler();
243
- }
244
- } else {
245
- self->Fail(std::move(result), ErrorType::Connection);
246
- }
247
- } catch (hresult_error const &e) {
248
- self->Fail(e, ErrorType::Connection);
249
- } catch (std::exception const &e) {
250
- self->Fail(e.what(), ErrorType::Connection);
251
- }
252
-
253
- SetEvent(self->m_connectPerformed.get());
226
+ co_await self->m_sequencer.QueueTaskAsync(
227
+ [self = self->shared_from_this(), coUri = std::move(movedUri)]() -> IAsyncAction {
228
+ auto coSelf = self->shared_from_this();
229
+
230
+ auto async = coSelf->m_socket.ConnectAsync(coUri);
231
+ co_await lessthrow_await_adapter<IAsyncAction>{async};
232
+
233
+ auto result = async.ErrorCode();
234
+ try {
235
+ if (result >= 0) { // Non-failing HRESULT
236
+ coSelf->m_readyState = ReadyState::Open;
237
+
238
+ co_await resume_in_queue(coSelf->m_callingQueue);
239
+ if (coSelf->m_connectHandler) {
240
+ coSelf->m_connectHandler();
241
+ }
242
+ } else {
243
+ coSelf->Fail(std::move(result), ErrorType::Connection);
244
+ }
245
+ } catch (hresult_error const &e) {
246
+ coSelf->Fail(e, ErrorType::Connection);
247
+ } catch (std::exception const &e) {
248
+ coSelf->Fail(e.what(), ErrorType::Connection);
249
+ }
250
+ });
254
251
  }
255
252
 
256
253
  fire_and_forget WinRTWebSocketResource2::PerformClose() noexcept {
257
254
  auto self = shared_from_this();
258
255
 
259
- co_await resume_on_signal(self->m_connectPerformed.get());
260
-
261
256
  co_await resume_in_queue(self->m_backgroundQueue);
262
257
 
263
- // See https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close
264
- co_await self->SendPendingMessages();
258
+ co_await self->m_sequencer.QueueTaskAsync([self = self->shared_from_this()]() -> IAsyncAction {
259
+ auto coSelf = self->shared_from_this();
265
260
 
266
- try {
267
- self->m_socket.Close(static_cast<uint16_t>(m_closeCode), winrt::to_hstring(m_closeReason));
268
- self->m_readyState = ReadyState::Closing;
269
- } catch (winrt::hresult_invalid_argument const &e) {
270
- Fail(e, ErrorType::Close);
271
- } catch (hresult_error const &e) {
272
- Fail(e, ErrorType::Close);
273
- } catch (const std::exception &e) {
274
- Fail(e.what(), ErrorType::Close);
275
- }
261
+ try {
262
+ coSelf->m_socket.Close(static_cast<uint16_t>(coSelf->m_closeCode), winrt::to_hstring(coSelf->m_closeReason));
263
+ coSelf->m_readyState = ReadyState::Closing;
264
+ } catch (winrt::hresult_invalid_argument const &e) {
265
+ coSelf->Fail(e, ErrorType::Close);
266
+ } catch (hresult_error const &e) {
267
+ coSelf->Fail(e, ErrorType::Close);
268
+ } catch (const std::exception &e) {
269
+ coSelf->Fail(e.what(), ErrorType::Close);
270
+ }
271
+
272
+ co_return;
273
+ });
276
274
  }
277
275
 
278
- fire_and_forget WinRTWebSocketResource2::PerformWrite(string &&message, bool isBinary) noexcept {
276
+ fire_and_forget WinRTWebSocketResource2::EnqueueWrite(string &&message, bool isBinary) noexcept {
279
277
  auto self = shared_from_this();
280
278
  string coMessage = std::move(message);
281
279
 
282
- co_await resume_in_queue(self->m_backgroundQueue); // Ensure writes happen sequentially
283
- self->m_outgoingMessages.emplace(std::move(coMessage), isBinary);
284
-
285
- co_await resume_on_signal(self->m_connectPerformed.get());
286
-
287
280
  co_await resume_in_queue(self->m_backgroundQueue);
288
281
 
289
- co_await self->SendPendingMessages();
282
+ co_await self->m_sequencer.QueueTaskAsync(
283
+ [self = self->shared_from_this(), message = std::move(coMessage), isBinary]() -> IAsyncAction {
284
+ auto coSelf = self->shared_from_this();
285
+ auto coMessage = std::move(message);
286
+
287
+ co_await coSelf->PerformWrite(std::move(coMessage), isBinary);
288
+ });
290
289
  }
291
290
 
292
- IAsyncAction WinRTWebSocketResource2::SendPendingMessages() noexcept {
291
+ IAsyncAction WinRTWebSocketResource2::PerformWrite(string &&message, bool isBinary) noexcept {
293
292
  auto self = shared_from_this();
294
293
 
295
- while (!self->m_outgoingMessages.empty()) {
296
- if (self->m_readyState != ReadyState::Open) {
297
- co_return;
298
- }
299
-
300
- size_t length = 0;
301
- string messageLocal;
302
- bool isBinaryLocal;
303
- try {
304
- std::tie(messageLocal, isBinaryLocal) = self->m_outgoingMessages.front();
305
- self->m_outgoingMessages.pop();
306
- if (isBinaryLocal) {
307
- self->m_socket.Control().MessageType(SocketMessageType::Binary);
308
-
309
- auto buffer = CryptographicBuffer::DecodeFromBase64String(winrt::to_hstring(messageLocal));
310
- if (buffer) {
311
- length = buffer.Length();
312
- self->m_writer.WriteBuffer(buffer);
313
- }
314
- } else {
315
- self->m_socket.Control().MessageType(SocketMessageType::Utf8);
294
+ try {
295
+ if (isBinary) {
296
+ self->m_socket.Control().MessageType(SocketMessageType::Binary);
316
297
 
317
- length = messageLocal.size();
318
- winrt::array_view<const uint8_t> view(
319
- CheckedReinterpretCast<const uint8_t *>(messageLocal.c_str()),
320
- CheckedReinterpretCast<const uint8_t *>(messageLocal.c_str()) + messageLocal.length());
321
- self->m_writer.WriteBytes(view);
298
+ auto buffer = CryptographicBuffer::DecodeFromBase64String(winrt::to_hstring(message));
299
+ if (buffer) {
300
+ self->m_writer.WriteBuffer(buffer);
322
301
  }
323
- } catch (hresult_error const &e) { // TODO: Remove after fixing unit tests exceptions.
324
- self->Fail(e, ErrorType::Send);
325
- co_return;
326
- } catch (const std::exception &e) {
327
- self->Fail(e.what(), ErrorType::Send);
328
- co_return;
302
+ } else {
303
+ self->m_socket.Control().MessageType(SocketMessageType::Utf8);
304
+
305
+ winrt::array_view<const uint8_t> view(
306
+ CheckedReinterpretCast<const uint8_t *>(message.c_str()),
307
+ CheckedReinterpretCast<const uint8_t *>(message.c_str()) + message.length());
308
+ self->m_writer.WriteBytes(view);
329
309
  }
310
+ } catch (hresult_error const &e) { // TODO: Remove after fixing unit tests exceptions.
311
+ self->Fail(e, ErrorType::Send);
312
+ } catch (const std::exception &e) {
313
+ self->Fail(e.what(), ErrorType::Send);
314
+ }
330
315
 
331
- auto async = self->m_writer.StoreAsync();
332
- co_await lessthrow_await_adapter<DataWriterStoreOperation>{async};
316
+ co_await resume_in_queue(self->m_backgroundQueue);
317
+ // If an exception occurred, abort write process.
318
+ if (self->m_readyState != ReadyState::Open) {
319
+ co_return;
320
+ }
333
321
 
334
- auto result = async.ErrorCode();
335
- if (result < 0) {
336
- Fail(std::move(result), ErrorType::Send);
337
- }
322
+ auto async = self->m_writer.StoreAsync();
323
+ co_await lessthrow_await_adapter<DataWriterStoreOperation>{async};
324
+
325
+ auto result = async.ErrorCode();
326
+ if (result < 0) {
327
+ self->Fail(std::move(result), ErrorType::Send);
338
328
  }
339
329
  }
340
330
 
@@ -388,11 +378,7 @@ void WinRTWebSocketResource2::Connect(string &&url, const Protocols &protocols,
388
378
  m_socket.SetRequestHeader(L"Origin", std::move(origin));
389
379
  }
390
380
  } catch (hresult_error const &e) {
391
- Fail(e, ErrorType::Connection);
392
-
393
- SetEvent(m_connectPerformed.get());
394
-
395
- return;
381
+ return Fail(e, ErrorType::Connection);
396
382
  }
397
383
 
398
384
  PerformConnect(std::move(uri));
@@ -401,11 +387,11 @@ void WinRTWebSocketResource2::Connect(string &&url, const Protocols &protocols,
401
387
  void WinRTWebSocketResource2::Ping() noexcept {}
402
388
 
403
389
  void WinRTWebSocketResource2::Send(string &&message) noexcept {
404
- PerformWrite(std::move(message), false);
390
+ EnqueueWrite(std::move(message), false);
405
391
  }
406
392
 
407
393
  void WinRTWebSocketResource2::SendBinary(string &&base64String) noexcept {
408
- PerformWrite(std::move(base64String), true);
394
+ EnqueueWrite(std::move(base64String), true);
409
395
  }
410
396
 
411
397
  void WinRTWebSocketResource2::Close(CloseCode code, const string &reason) noexcept {
@@ -18,17 +18,101 @@ namespace Microsoft::React::Networking {
18
18
 
19
19
  class WinRTWebSocketResource2 : public IWebSocketResource,
20
20
  public std::enable_shared_from_this<WinRTWebSocketResource2> {
21
- winrt::Windows::Networking::Sockets::IMessageWebSocket m_socket;
22
-
23
21
  ///
24
- // Connection attempt performed, either succeeding or failing
22
+ // See https://devblogs.microsoft.com/oldnewthing/20250328-00/?p=111016
25
23
  ///
26
- winrt::handle m_connectPerformed;
24
+ struct TaskSequencer {
25
+ TaskSequencer() = default;
26
+ TaskSequencer(const TaskSequencer &) = delete;
27
+ void operator=(const TaskSequencer &) = delete;
28
+
29
+ private:
30
+ using CoroHandle = std::experimental::coroutine_handle<>;
31
+
32
+ struct Suspender {
33
+ CoroHandle m_handle;
34
+
35
+ bool await_ready() const noexcept {
36
+ return false;
37
+ }
38
+
39
+ void await_suspend(CoroHandle h) noexcept {
40
+ m_handle = h;
41
+ }
42
+
43
+ void await_resume() const noexcept {}
44
+ };
45
+
46
+ static void *Completed() {
47
+ return reinterpret_cast<void *>(1);
48
+ }
49
+
50
+ struct ChainedTask {
51
+ private:
52
+ std::atomic<void *> m_next;
53
+
54
+ public:
55
+ ChainedTask(void *state = nullptr) : m_next(state) {}
56
+
57
+ void ContinueWith(CoroHandle h) {
58
+ if (m_next.exchange(h.address(), std::memory_order_acquire) != nullptr) {
59
+ h();
60
+ }
61
+ }
62
+
63
+ void Complete() {
64
+ auto resumeAddress = m_next.exchange(Completed());
65
+ if (resumeAddress) {
66
+ CoroHandle::from_address(resumeAddress).resume();
67
+ }
68
+ }
69
+ };
27
70
 
71
+ struct Completer {
72
+ std::shared_ptr<ChainedTask> m_chain;
73
+
74
+ ~Completer() {
75
+ m_chain->Complete();
76
+ }
77
+ };
78
+
79
+ winrt::slim_mutex m_mutex;
80
+ std::shared_ptr<ChainedTask> m_latest = std::make_shared<ChainedTask>(Completed());
81
+
82
+ public:
83
+ template <typename Maker>
84
+ auto QueueTaskAsync(Maker &&maker) -> decltype(maker()) {
85
+ auto node = std::make_shared<ChainedTask>();
86
+ Suspender suspend;
87
+
88
+ using Async = decltype(maker());
89
+ auto task = [&node, &suspend, &maker]() -> Async {
90
+ Completer completer{node};
91
+ auto localMaker = std::forward<Maker>(maker);
92
+ auto context = winrt::apartment_context();
93
+
94
+ co_await suspend;
95
+ co_await context;
96
+
97
+ co_return co_await localMaker();
98
+ }();
99
+
100
+ {
101
+ winrt::slim_lock_guard guard(m_mutex);
102
+ m_latest.swap(node);
103
+ }
104
+
105
+ node->ContinueWith(suspend.m_handle);
106
+
107
+ return task;
108
+ }
109
+ };
110
+
111
+ winrt::Windows::Networking::Sockets::IMessageWebSocket m_socket;
28
112
  ReadyState m_readyState;
113
+ TaskSequencer m_sequencer;
29
114
  Mso::DispatchQueue m_callingQueue;
30
115
  Mso::DispatchQueue m_backgroundQueue;
31
- std::queue<std::pair<std::string, bool>> m_outgoingMessages;
32
116
  CloseCode m_closeCode{CloseCode::Normal};
33
117
  std::string m_closeReason;
34
118
 
@@ -52,9 +136,9 @@ class WinRTWebSocketResource2 : public IWebSocketResource,
52
136
  winrt::Windows::Networking::Sockets::IWebSocketClosedEventArgs const &args);
53
137
 
54
138
  winrt::fire_and_forget PerformConnect(winrt::Windows::Foundation::Uri &&uri) noexcept;
55
- winrt::fire_and_forget PerformWrite(std::string &&message, bool isBinary) noexcept;
139
+ winrt::fire_and_forget EnqueueWrite(std::string &&message, bool isBinary) noexcept;
140
+ winrt::Windows::Foundation::IAsyncAction PerformWrite(std::string &&message, bool isBinary) noexcept;
56
141
  winrt::fire_and_forget PerformClose() noexcept;
57
- winrt::Windows::Foundation::IAsyncAction SendPendingMessages() noexcept;
58
142
 
59
143
  WinRTWebSocketResource2(
60
144
  winrt::Windows::Networking::Sockets::IMessageWebSocket &&socket,
@@ -117,10 +117,10 @@
117
117
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\Modal\WindowsModalHostViewComponentView.cpp">
118
118
  <ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
119
119
  </ClCompile>
120
- <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\Modal\WindowsModalHostViewShadowNode.cpp">
120
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\ParagraphComponentView.cpp">
121
121
  <ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
122
122
  </ClCompile>
123
- <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\ParagraphComponentView.cpp">
123
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\PortalComponentView.cpp">
124
124
  <ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
125
125
  </ClCompile>
126
126
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\RootComponentView.cpp">
@@ -171,9 +171,6 @@
171
171
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiComponentDescriptor.cpp">
172
172
  <ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
173
173
  </ClCompile>
174
- <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiViewComponentDescriptor.cpp">
175
- <ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
176
- </ClCompile>
177
174
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiEventEmitter.cpp">
178
175
  <ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
179
176
  </ClCompile>
@@ -183,6 +180,9 @@
183
180
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiShadowNode.cpp">
184
181
  <ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
185
182
  </ClCompile>
183
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiPortalShadowNode.cpp">
184
+ <ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
185
+ </ClCompile>
186
186
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiViewShadowNode.cpp">
187
187
  <ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
188
188
  </ClCompile>
@@ -323,6 +323,7 @@
323
323
  <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\Modal\WindowsModalHostViewComponentView.h" />
324
324
  <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\Modal\WindowsModalHostViewSate.h" />
325
325
  <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\ParagraphComponentView.h" />
326
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\PortalComponentView.h" />
326
327
  <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\RootComponentView.h" />
327
328
  <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\ScrollViewComponentView.h" />
328
329
  <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\SwitchComponentView.h" />
@@ -179,9 +179,6 @@
179
179
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\Modal\WindowsModalHostViewComponentView.cpp">
180
180
  <Filter>Source Files\Fabric\Composition</Filter>
181
181
  </ClCompile>
182
- <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\Modal\WindowsModalHostViewShadowNode.cpp">
183
- <Filter>Source Files\Fabric\Composition</Filter>
184
- </ClCompile>
185
182
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\ParagraphComponentView.cpp">
186
183
  <Filter>Source Files\Fabric\Composition</Filter>
187
184
  </ClCompile>
@@ -245,9 +242,9 @@
245
242
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\platform\react\renderer\textlayoutmanager\TextLayoutManager.cpp">
246
243
  <Filter>Source Files\Fabric\platform\react\renderer\textlayoutmanager</Filter>
247
244
  </ClCompile>
245
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\PortalComponentView.cpp" />
248
246
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\RootComponentView.cpp" />
249
247
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\UnimplementedNativeViewComponentView.cpp" />
250
- <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiViewComponentDescriptor.cpp" />
251
248
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiViewProps.cpp" />
252
249
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\WindowsComponentDescriptorRegistry.cpp" />
253
250
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\UiaHelpers.cpp" />
@@ -301,6 +298,7 @@
301
298
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\runtimescheduler\Task.cpp" />
302
299
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\components\scrollview\ScrollEvent.cpp" />
303
300
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\platform\react\renderer\graphics\PlatformColorUtils.cpp" />
301
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiPortalShadowNode.cpp" />
304
302
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiViewShadowNode.cpp" />
305
303
  <ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiState.cpp" />
306
304
  <ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Utils\ThemeUtils.cpp" />
@@ -794,6 +792,7 @@
794
792
  <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\platform\react\renderer\textlayoutmanager\TextLayoutManager.h">
795
793
  <Filter>Header Files\Fabric\platform\react\renderer\textlayoutmanager</Filter>
796
794
  </ClInclude>
795
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\PortalComponentView.h" />
797
796
  <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\RootComponentView.h" />
798
797
  <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiViewProps.h" />
799
798
  <ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiViewComponentDescriptor.h" />
@@ -0,0 +1,212 @@
1
+
2
+ /*
3
+ * This file is auto-generated from ActivityIndicatorViewNativeComponent 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(ActivityIndicatorViewProps)
22
+ struct ActivityIndicatorViewProps : winrt::implements<ActivityIndicatorViewProps, winrt::Microsoft::ReactNative::IComponentProps> {
23
+ ActivityIndicatorViewProps(winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom)
24
+ : ViewProps(props)
25
+ {
26
+ if (cloneFrom) {
27
+ auto cloneFromProps = cloneFrom.as<ActivityIndicatorViewProps>();
28
+ hidesWhenStopped = cloneFromProps->hidesWhenStopped;
29
+ animating = cloneFromProps->animating;
30
+ color = cloneFromProps->color;
31
+ size = cloneFromProps->size;
32
+ }
33
+ }
34
+
35
+ void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept {
36
+ winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this);
37
+ }
38
+
39
+ REACT_FIELD(hidesWhenStopped)
40
+ bool hidesWhenStopped{true};
41
+
42
+ REACT_FIELD(animating)
43
+ bool animating{true};
44
+
45
+ REACT_FIELD(color)
46
+ winrt::Microsoft::ReactNative::Color color{nullptr};
47
+
48
+ REACT_FIELD(size)
49
+ std::optional<std::string> size;
50
+
51
+ const winrt::Microsoft::ReactNative::ViewProps ViewProps;
52
+ };
53
+
54
+ struct ActivityIndicatorViewEventEmitter {
55
+ ActivityIndicatorViewEventEmitter(const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter)
56
+ : m_eventEmitter(eventEmitter) {}
57
+
58
+ private:
59
+ winrt::Microsoft::ReactNative::EventEmitter m_eventEmitter{nullptr};
60
+ };
61
+
62
+ template<typename TUserData>
63
+ struct BaseActivityIndicatorView {
64
+
65
+ virtual void UpdateProps(
66
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
67
+ const winrt::com_ptr<ActivityIndicatorViewProps> &newProps,
68
+ const winrt::com_ptr<ActivityIndicatorViewProps> &/*oldProps*/) noexcept {
69
+ m_props = newProps;
70
+ }
71
+
72
+ // UpdateLayoutMetrics will only be called if this method is overridden
73
+ virtual void UpdateLayoutMetrics(
74
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
75
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*newLayoutMetrics*/,
76
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*oldLayoutMetrics*/) noexcept {
77
+ }
78
+
79
+ // UpdateState will only be called if this method is overridden
80
+ virtual void UpdateState(
81
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
82
+ const winrt::Microsoft::ReactNative::IComponentState &/*newState*/) noexcept {
83
+ }
84
+
85
+ virtual void UpdateEventEmitter(const std::shared_ptr<ActivityIndicatorViewEventEmitter> &eventEmitter) noexcept {
86
+ m_eventEmitter = eventEmitter;
87
+ }
88
+
89
+ // MountChildComponentView will only be called if this method is overridden
90
+ virtual void MountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
91
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &/*args*/) noexcept {
92
+ }
93
+
94
+ // UnmountChildComponentView will only be called if this method is overridden
95
+ virtual void UnmountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
96
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &/*args*/) noexcept {
97
+ }
98
+
99
+ // Initialize will only be called if this method is overridden
100
+ virtual void Initialize(const winrt::Microsoft::ReactNative::ComponentView &/*view*/) noexcept {
101
+ }
102
+
103
+ // CreateVisual will only be called if this method is overridden
104
+ virtual winrt::Microsoft::UI::Composition::Visual CreateVisual(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
105
+ return view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Compositor().CreateSpriteVisual();
106
+ }
107
+
108
+ // FinalizeUpdate will only be called if this method is overridden
109
+ virtual void FinalizeUpdate(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
110
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) noexcept {
111
+ }
112
+
113
+
114
+
115
+ const std::shared_ptr<ActivityIndicatorViewEventEmitter>& EventEmitter() const { return m_eventEmitter; }
116
+ const winrt::com_ptr<ActivityIndicatorViewProps>& Props() const { return m_props; }
117
+
118
+ private:
119
+ winrt::com_ptr<ActivityIndicatorViewProps> m_props;
120
+ std::shared_ptr<ActivityIndicatorViewEventEmitter> m_eventEmitter;
121
+ };
122
+
123
+ template <typename TUserData>
124
+ void RegisterActivityIndicatorViewNativeComponent(
125
+ winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder,
126
+ std::function<void(const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder&)> builderCallback) noexcept {
127
+ packageBuilder.as<winrt::Microsoft::ReactNative::IReactPackageBuilderFabric>().AddViewComponent(
128
+ L"ActivityIndicatorView", [builderCallback](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept {
129
+ auto compBuilder = builder.as<winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder>();
130
+
131
+ builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props,
132
+ const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) noexcept {
133
+ return winrt::make<ActivityIndicatorViewProps>(props, cloneFrom);
134
+ });
135
+
136
+ builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
137
+ const winrt::Microsoft::ReactNative::IComponentProps &newProps,
138
+ const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept {
139
+ auto userData = view.UserData().as<TUserData>();
140
+ userData->UpdateProps(view, newProps ? newProps.as<ActivityIndicatorViewProps>() : nullptr, oldProps ? oldProps.as<ActivityIndicatorViewProps>() : nullptr);
141
+ });
142
+
143
+ compBuilder.SetUpdateLayoutMetricsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
144
+ const winrt::Microsoft::ReactNative::LayoutMetrics &newLayoutMetrics,
145
+ const winrt::Microsoft::ReactNative::LayoutMetrics &oldLayoutMetrics) noexcept {
146
+ auto userData = view.UserData().as<TUserData>();
147
+ userData->UpdateLayoutMetrics(view, newLayoutMetrics, oldLayoutMetrics);
148
+ });
149
+
150
+ builder.SetUpdateEventEmitterHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
151
+ const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) noexcept {
152
+ auto userData = view.UserData().as<TUserData>();
153
+ userData->UpdateEventEmitter(std::make_shared<ActivityIndicatorViewEventEmitter>(eventEmitter));
154
+ });
155
+
156
+ if constexpr (&TUserData::FinalizeUpdate != &BaseActivityIndicatorView<TUserData>::FinalizeUpdate) {
157
+ builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
158
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
159
+ auto userData = view.UserData().as<TUserData>();
160
+ userData->FinalizeUpdate(view, mask);
161
+ });
162
+ }
163
+
164
+ if constexpr (&TUserData::UpdateState != &BaseActivityIndicatorView<TUserData>::UpdateState) {
165
+ builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
166
+ const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
167
+ auto userData = view.UserData().as<TUserData>();
168
+ userData->UpdateState(view, newState);
169
+ });
170
+ }
171
+
172
+ if constexpr (&TUserData::MountChildComponentView != &BaseActivityIndicatorView<TUserData>::MountChildComponentView) {
173
+ builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
174
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
175
+ auto userData = view.UserData().as<TUserData>();
176
+ return userData->MountChildComponentView(view, args);
177
+ });
178
+ }
179
+
180
+ if constexpr (&TUserData::UnmountChildComponentView != &BaseActivityIndicatorView<TUserData>::UnmountChildComponentView) {
181
+ builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
182
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
183
+ auto userData = view.UserData().as<TUserData>();
184
+ return userData->UnmountChildComponentView(view, args);
185
+ });
186
+ }
187
+
188
+ compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
189
+ auto userData = winrt::make_self<TUserData>();
190
+ if constexpr (&TUserData::Initialize != &BaseActivityIndicatorView<TUserData>::Initialize) {
191
+ userData->Initialize(view);
192
+ }
193
+ view.UserData(*userData);
194
+ });
195
+
196
+ if constexpr (&TUserData::CreateVisual != &BaseActivityIndicatorView<TUserData>::CreateVisual) {
197
+ compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
198
+ auto userData = view.UserData().as<TUserData>();
199
+ return userData->CreateVisual(view);
200
+ });
201
+ }
202
+
203
+ // Allow app to further customize the builder
204
+ if (builderCallback) {
205
+ builderCallback(compBuilder);
206
+ }
207
+ });
208
+ }
209
+
210
+ } // namespace Microsoft::ReactNativeSpecs
211
+
212
+ #endif // #ifdef RNW_NEW_ARCH