react-native-windows 0.80.0 → 0.80.5

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 (86) hide show
  1. package/Directory.Build.props +1 -1
  2. package/Microsoft.ReactNative/Fabric/Composition/DebuggerUIIsland.cpp +169 -0
  3. package/Microsoft.ReactNative/Fabric/Composition/DebuggerUIIsland.h +42 -0
  4. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +1 -1
  5. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +60 -33
  6. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +68 -1
  7. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +9 -0
  8. package/Microsoft.ReactNative/Fabric/Composition/TextDrawing.cpp +5 -37
  9. package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.cpp +5 -3
  10. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +6 -1
  11. package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +14 -1
  12. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp +0 -17
  13. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.h +0 -3
  14. package/Microsoft.ReactNative/Fabric/platform/react/threading/TaskDispatchThread.cpp +75 -24
  15. package/Microsoft.ReactNative/Fabric/platform/react/threading/TaskDispatchThread.h +4 -25
  16. package/Microsoft.ReactNative/JsiApi.cpp +1 -1
  17. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -0
  18. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +3 -0
  19. package/Microsoft.ReactNative/ReactHost/DebuggerNotifications.h +54 -0
  20. package/Microsoft.ReactNative/ReactHost/React.h +11 -4
  21. package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +195 -29
  22. package/Microsoft.ReactNative/ReactHost/ReactHost.h +22 -4
  23. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +24 -5
  24. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -1
  25. package/Microsoft.ReactNative/ReactRootView.cpp +108 -0
  26. package/Microsoft.ReactNative/ReactRootView.h +6 -0
  27. package/Microsoft.ReactNative/Views/DevMenu.cpp +1 -1
  28. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +1 -1
  29. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  30. package/PropertySheets/JSEngine.props +1 -1
  31. package/PropertySheets/React.Cpp.props +2 -2
  32. package/ReactCommon/ReactCommon.vcxproj +18 -1
  33. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +1 -1
  34. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +4 -4
  35. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +23 -9
  36. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +16 -0
  37. package/ReactCommon/cgmanifest.json +1 -1
  38. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +2 -0
  39. package/Shared/DevServerHelper.h +13 -3
  40. package/Shared/DevSettings.h +7 -0
  41. package/Shared/DevSupportManager.cpp +79 -20
  42. package/Shared/DevSupportManager.h +7 -19
  43. package/Shared/Hermes/HermesRuntimeAgentDelegate.cpp +99 -0
  44. package/Shared/Hermes/HermesRuntimeAgentDelegate.h +81 -0
  45. package/Shared/Hermes/HermesRuntimeTargetDelegate.cpp +263 -0
  46. package/Shared/Hermes/HermesRuntimeTargetDelegate.h +77 -0
  47. package/Shared/HermesRuntimeHolder.cpp +29 -111
  48. package/Shared/HermesRuntimeHolder.h +214 -32
  49. package/Shared/IDevSupportManager.h +5 -2
  50. package/Shared/Inspector/ReactInspectorPackagerConnectionDelegate.cpp +108 -0
  51. package/Shared/Inspector/ReactInspectorPackagerConnectionDelegate.h +19 -0
  52. package/Shared/Inspector/ReactInspectorThread.h +18 -0
  53. package/Shared/JSI/RuntimeHolder.h +5 -2
  54. package/Shared/OInstance.cpp +44 -27
  55. package/Shared/Shared.vcxitems +27 -17
  56. package/Shared/Shared.vcxitems.filters +33 -15
  57. package/package.json +4 -4
  58. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.cpp +0 -79
  59. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.h +0 -51
  60. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.inc +0 -50
  61. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi.cpp +0 -41
  62. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi.h +0 -127
  63. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi.inc +0 -125
  64. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi_posix.cpp +0 -16
  65. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi_win.cpp +0 -23
  66. package/Microsoft.ReactNative.Cxx/JSI/decorator.h +0 -1054
  67. package/Microsoft.ReactNative.Cxx/JSI/instrumentation.h +0 -145
  68. package/Microsoft.ReactNative.Cxx/JSI/jsi-inl.h +0 -372
  69. package/Microsoft.ReactNative.Cxx/JSI/jsi.cpp +0 -797
  70. package/Microsoft.ReactNative.Cxx/JSI/jsi.h +0 -1799
  71. package/Microsoft.ReactNative.Cxx/JSI/threadsafe.h +0 -79
  72. package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.cpp +0 -3531
  73. package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.h +0 -38
  74. package/Microsoft.ReactNative.Cxx/node-api/js_native_api.h +0 -614
  75. package/Microsoft.ReactNative.Cxx/node-api/js_native_api_types.h +0 -212
  76. package/Microsoft.ReactNative.Cxx/node-api/js_runtime_api.h +0 -199
  77. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +0 -78
  78. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.h +0 -196
  79. package/ReactCommon/TEMP_UntilReactCommonUpdate/jserrorhandler/JsErrorHandler.cpp +0 -429
  80. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsitooling/react/runtime/JSRuntimeFactory.cpp +0 -45
  81. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsitooling/react/runtime/JSRuntimeFactory.h +0 -91
  82. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +0 -670
  83. package/Shared/InspectorPackagerConnection.cpp +0 -232
  84. package/Shared/InspectorPackagerConnection.h +0 -61
  85. /package/Shared/{HermesSamplingProfiler.cpp → Hermes/HermesSamplingProfiler.cpp} +0 -0
  86. /package/Shared/{HermesSamplingProfiler.h → Hermes/HermesSamplingProfiler.h} +0 -0
@@ -34,7 +34,7 @@
34
34
  <FmtVersion>10.1.0</FmtVersion>
35
35
  <FmtCommitHash>ca2e3685b160617d3d95fcd9e789c4e06ca88</FmtCommitHash>
36
36
  <!-- Commit hash for https://github.com/microsoft/node-api-jsi code. -->
37
- <NodeApiJsiCommitHash>980cb60d7911237d0f647fc566543ef627adac70</NodeApiJsiCommitHash>
37
+ <NodeApiJsiCommitHash>21b47f08b762b21b1d4d970940ab23f59f43249c</NodeApiJsiCommitHash>
38
38
  </PropertyGroup>
39
39
 
40
40
  <!--
@@ -0,0 +1,169 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ #include "pch.h"
4
+ #include "DebuggerUIIsland.h"
5
+
6
+ #include <AutoDraw.h>
7
+ #include <react/renderer/attributedstring/AttributedStringBox.h>
8
+ #include <react/renderer/textlayoutmanager/WindowsTextLayoutManager.h>
9
+ #include <winrt/Microsoft.UI.Composition.h>
10
+ #include <winrt/Microsoft.UI.Content.h>
11
+ #include <winrt/Microsoft.UI.Input.h>
12
+ #include "CompositionContextHelper.h"
13
+ #include "TextDrawing.h"
14
+
15
+ namespace winrt::Microsoft::ReactNative::implementation {
16
+
17
+ constexpr float debuggerUIFontSize = 10.0f;
18
+ constexpr float debuggerTextMargin = 4.0f;
19
+
20
+ DebuggerUIIsland::DebuggerUIIsland(
21
+ const winrt::Microsoft::UI::Composition::Compositor &compositor,
22
+ winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
23
+ winrt::Microsoft::ReactNative::Composition::Theme theme) noexcept
24
+ : m_compositor(compositor), m_compContext(compContext), m_theme(theme) {
25
+ m_backgroundVisual = m_compositor.CreateSpriteVisual();
26
+ m_backgroundVisual.RelativeSizeAdjustment({1.0f, 1.0f});
27
+
28
+ auto backgroundBrush = m_compositor.CreateColorBrush({100, 0, 0, 0});
29
+ m_backgroundVisual.Brush(backgroundBrush);
30
+
31
+ m_TextVisual = m_compositor.CreateSpriteVisual();
32
+ m_TextVisual.IsPixelSnappingEnabled(true);
33
+
34
+ m_backgroundVisual.Children().InsertAtTop(m_TextVisual);
35
+ }
36
+
37
+ DebuggerUIIsland::~DebuggerUIIsland() noexcept {
38
+ m_island.StateChanged(m_islandStateChangedToken);
39
+ }
40
+
41
+ void DebuggerUIIsland::Redraw() noexcept {
42
+ if (!m_island)
43
+ return;
44
+
45
+ if (m_island.ActualSize().x == 0 || m_island.ActualSize().y == 0)
46
+ return;
47
+
48
+ auto scaleFactor = m_island.Environment().DisplayScale();
49
+
50
+ auto attributedString = facebook::react::AttributedString{};
51
+ auto fragment = facebook::react::AttributedString::Fragment{};
52
+ fragment.string = m_message;
53
+ fragment.textAttributes.fontSize = debuggerUIFontSize;
54
+ attributedString.appendFragment(std::move(fragment));
55
+
56
+ // Resume Icon
57
+ auto iconFragment = facebook::react::AttributedString::Fragment{};
58
+ iconFragment.string = " \uF08F";
59
+ iconFragment.textAttributes.fontFamily = "Segoe Fluent Icons";
60
+ iconFragment.textAttributes.fontSize = debuggerUIFontSize;
61
+ attributedString.appendFragment(std::move(iconFragment));
62
+
63
+ auto attributedStringBox = facebook::react::AttributedStringBox{attributedString};
64
+
65
+ facebook::react::LayoutConstraints constraints;
66
+ constraints.maximumSize.width = std::max(0.0f, m_island.ActualSize().x - debuggerTextMargin * 2 * scaleFactor);
67
+ constraints.maximumSize.height = std::max(0.0f, m_island.ActualSize().y - debuggerTextMargin * 2 * scaleFactor);
68
+
69
+ auto textAttributes = facebook::react::TextAttributes{};
70
+ textAttributes.foregroundColor = facebook::react::blackColor();
71
+
72
+ winrt::com_ptr<::IDWriteTextLayout> textLayout;
73
+ facebook::react::WindowsTextLayoutManager::GetTextLayout(attributedStringBox, {}, constraints, textLayout);
74
+
75
+ DWRITE_TEXT_METRICS tm;
76
+ textLayout->GetMetrics(&tm);
77
+
78
+ winrt::Windows::Foundation::Size surfaceSize = {
79
+ std::ceilf(std::min(constraints.maximumSize.width, tm.width + debuggerTextMargin * 2 * scaleFactor)),
80
+ std::ceilf(std::min(constraints.maximumSize.height, tm.height + debuggerTextMargin * 2 * scaleFactor))};
81
+ auto drawingSurface = m_compContext.CreateDrawingSurfaceBrush(
82
+ surfaceSize,
83
+ winrt::Windows::Graphics::DirectX::DirectXPixelFormat::B8G8R8A8UIntNormalized,
84
+ winrt::Windows::Graphics::DirectX::DirectXAlphaMode::Premultiplied);
85
+
86
+ POINT offset;
87
+ {
88
+ ::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(drawingSurface, scaleFactor, &offset);
89
+ if (auto d2dDeviceContext = autoDraw.GetRenderTarget()) {
90
+ d2dDeviceContext->Clear(D2D1::ColorF{1.0f, 1.0f, 0.76f, 1.0f});
91
+
92
+ auto theme = winrt::get_self<winrt::Microsoft::ReactNative::Composition::implementation::Theme>(m_theme);
93
+
94
+ Composition::RenderText(
95
+ *d2dDeviceContext,
96
+ *textLayout,
97
+ attributedStringBox.getValue(),
98
+ textAttributes,
99
+ {static_cast<float>(offset.x + std::floorf(debuggerTextMargin * scaleFactor)),
100
+ static_cast<float>(offset.y + std::floorf(debuggerTextMargin * scaleFactor))},
101
+ scaleFactor,
102
+ *theme);
103
+ }
104
+
105
+ drawingSurface.HorizontalAlignmentRatio(0.0f);
106
+ drawingSurface.Stretch(winrt::Microsoft::ReactNative::Composition::Experimental::CompositionStretch::None);
107
+
108
+ m_TextVisual.Brush(winrt::Microsoft::ReactNative::Composition::Experimental::implementation::
109
+ MicrosoftCompositionContextHelper::InnerBrush(drawingSurface));
110
+ m_TextVisual.Size({surfaceSize.Width, surfaceSize.Height});
111
+
112
+ m_debuggerHitRect = {
113
+ m_island.ActualSize().x / 2 - tm.width / 2 + debuggerTextMargin * scaleFactor,
114
+ debuggerTextMargin * scaleFactor,
115
+ surfaceSize.Width,
116
+ surfaceSize.Height};
117
+
118
+ m_TextVisual.Offset({m_debuggerHitRect.X, m_debuggerHitRect.Y, 0.0f});
119
+ }
120
+ }
121
+
122
+ void DebuggerUIIsland::Message(std::string &&value) noexcept {
123
+ m_message = value;
124
+ Redraw();
125
+ }
126
+
127
+ winrt::Microsoft::UI::Content::ContentIsland DebuggerUIIsland::Island() noexcept {
128
+ if (!m_island) {
129
+ m_island = winrt::Microsoft::UI::Content::ContentIsland::Create(m_backgroundVisual);
130
+
131
+ m_islandStateChangedToken =
132
+ m_island.StateChanged([weakThis = weak_from_this()](
133
+ winrt::Microsoft::UI::Content::ContentIsland const &island,
134
+ winrt::Microsoft::UI::Content::ContentIslandStateChangedEventArgs const &args) {
135
+ if (auto pThis = weakThis.lock()) {
136
+ if (args.DidRasterizationScaleChange() || args.DidActualSizeChange()) {
137
+ pThis->Redraw();
138
+ }
139
+ }
140
+ });
141
+
142
+ auto pointerSource = winrt::Microsoft::UI::Input::InputPointerSource::GetForIsland(m_island);
143
+
144
+ m_islandPointerUpToken =
145
+ pointerSource.PointerReleased([weakThis = weak_from_this()](
146
+ winrt::Microsoft::UI::Input::InputPointerSource const &,
147
+ winrt::Microsoft::UI::Input::PointerEventArgs const &args) {
148
+ if (auto pThis = weakThis.lock()) {
149
+ auto position = args.CurrentPoint().Position();
150
+ if (position.X >= pThis->m_debuggerHitRect.X && position.Y >= pThis->m_debuggerHitRect.Y &&
151
+ position.X <= pThis->m_debuggerHitRect.X + pThis->m_debuggerHitRect.Width &&
152
+ position.Y <= pThis->m_debuggerHitRect.Y + pThis->m_debuggerHitRect.Height) {
153
+ pThis->m_resumedEvent(nullptr, nullptr);
154
+ }
155
+ }
156
+ });
157
+ }
158
+ return m_island;
159
+ }
160
+
161
+ winrt::event_token DebuggerUIIsland::Resumed(
162
+ winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable> const &handler) noexcept {
163
+ return m_resumedEvent.add(handler);
164
+ }
165
+ void DebuggerUIIsland::Resumed(winrt::event_token const &token) noexcept {
166
+ m_resumedEvent.remove(token);
167
+ }
168
+
169
+ } // namespace winrt::Microsoft::ReactNative::implementation
@@ -0,0 +1,42 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ #pragma once
4
+
5
+ #include <winrt/Microsoft.ReactNative.Composition.Experimental.h>
6
+ #include <winrt/Microsoft.ReactNative.Composition.h>
7
+
8
+ namespace winrt::Microsoft::ReactNative::implementation {
9
+
10
+ struct DebuggerUIIsland : std::enable_shared_from_this<DebuggerUIIsland> {
11
+ DebuggerUIIsland(
12
+ const winrt::Microsoft::UI::Composition::Compositor &compositor,
13
+ winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
14
+ winrt::Microsoft::ReactNative::Composition::Theme theme) noexcept;
15
+ ~DebuggerUIIsland() noexcept;
16
+ winrt::Microsoft::UI::Content::ContentIsland Island() noexcept;
17
+
18
+ void Message(std::string &&value) noexcept;
19
+
20
+ winrt::event_token Resumed(
21
+ winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable> const &handler) noexcept;
22
+ void Resumed(winrt::event_token const &token) noexcept;
23
+
24
+ private:
25
+ void Redraw() noexcept;
26
+
27
+ winrt::event_token m_islandStateChangedToken;
28
+ winrt::event_token m_islandPointerUpToken;
29
+
30
+ winrt::Microsoft::UI::Composition::SpriteVisual m_backgroundVisual{nullptr};
31
+ winrt::Microsoft::UI::Composition::SpriteVisual m_TextVisual{nullptr};
32
+ winrt::Windows::Foundation::Rect m_debuggerHitRect{0, 0, 0, 0};
33
+ winrt::Microsoft::ReactNative::Composition::Theme m_theme{nullptr};
34
+ std::string m_message;
35
+
36
+ winrt::event<winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>> m_resumedEvent;
37
+ winrt::Microsoft::UI::Composition::Compositor m_compositor{nullptr};
38
+ winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext m_compContext{nullptr};
39
+ winrt::Microsoft::UI::Content::ContentIsland m_island{nullptr};
40
+ };
41
+
42
+ } // namespace winrt::Microsoft::ReactNative::implementation
@@ -103,9 +103,9 @@ void DebuggingOverlayComponentView::HandleCommand(
103
103
  auto rootVisual = root->OuterVisual();
104
104
 
105
105
  while (m_activeOverlays != 0) {
106
+ --m_activeOverlays;
106
107
  auto visual = rootVisual.GetAt(root->overlayIndex() + m_activeOverlays);
107
108
  rootVisual.Remove(visual);
108
- --m_activeOverlays;
109
109
  }
110
110
  }
111
111
  return;
@@ -35,26 +35,44 @@ struct ModalHostState
35
35
  struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::Foundation::IInspectable>,
36
36
  ::Microsoft::ReactNativeSpecs::BaseModalHostView<ModalHostView> {
37
37
  ~ModalHostView() {
38
- if (m_reactNativeIsland) {
39
- m_reactNativeIsland.Island().Close();
40
- }
38
+ if (m_popUp) {
39
+ // Unregister closing event handler
40
+ if (m_appWindow && m_appWindowClosingToken) {
41
+ m_appWindow.Closing(m_appWindowClosingToken);
42
+ m_appWindowClosingToken.value = 0;
43
+ }
41
44
 
42
- // Add AppWindow closing token cleanup
43
- if (m_appWindow && m_appWindowClosingToken) {
44
- m_appWindow.Closing(m_appWindowClosingToken);
45
- m_appWindowClosingToken.value = 0;
46
- }
45
+ // Reset topWindowID before destroying
46
+ if (m_prevWindowID) {
47
+ winrt::Microsoft::ReactNative::ReactCoreInjection::SetTopLevelWindowId(
48
+ m_reactContext.Properties().Handle(), m_prevWindowID);
49
+ m_prevWindowID = 0;
50
+ }
47
51
 
48
- if (m_popUp) {
49
- if (m_departFocusToken && !m_popUp.IsClosed()) {
50
- // WASDK BUG: InputFocusNavigationHost::GetForSiteBridge fails on a DesktopPopupSiteBridge
51
- // https://github.com/microsoft/react-native-windows/issues/14604
52
- /*
53
- auto navHost =
54
- winrt::Microsoft::UI::Input::InputFocusNavigationHost::GetForSiteBridge(m_popUp.as<winrt::Microsoft::UI::Content::IContentSiteBridge>());
55
- navHost.DepartFocusRequested(m_departFocusToken);
56
- */
52
+ // Close island
53
+ if (m_reactNativeIsland) {
54
+ m_reactNativeIsland.Island().Close();
55
+ m_reactNativeIsland = nullptr;
56
+ }
57
+
58
+ // Hide popup
59
+ if (m_popUp.IsVisible()) {
60
+ m_popUp.Hide();
61
+ }
62
+
63
+ // Destroy AppWindow this automatically resumes parent window to receive inputs
64
+ if (m_appWindow) {
65
+ m_appWindow.Destroy();
66
+ m_appWindow = nullptr;
67
+ }
68
+
69
+ // Bring parent window to foreground
70
+ if (m_parentHwnd) {
71
+ SetForegroundWindow(m_parentHwnd);
72
+ SetFocus(m_parentHwnd);
57
73
  }
74
+
75
+ // Close bridge
58
76
  m_popUp.Close();
59
77
  m_popUp = nullptr;
60
78
  }
@@ -88,7 +106,7 @@ struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::F
88
106
  QueueShow(view);
89
107
  } else {
90
108
  m_visible = false;
91
- CloseWindow();
109
+ HideWindow();
92
110
  }
93
111
  }
94
112
 
@@ -219,31 +237,33 @@ struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::F
219
237
  }
220
238
  }
221
239
 
222
- void CloseWindow() noexcept {
223
- // enable input to parent before closing the modal window, so focus can return back to the parent window
224
- EnableWindow(m_parentHwnd, true);
240
+ /*
241
+ HideWindow called on visible=false
242
+ unmounts the modal window using onDismiss event
243
+ */
244
+ void HideWindow() noexcept {
245
+ // Hide popup
225
246
  if (m_popUp) {
226
247
  m_popUp.Hide();
227
248
  }
228
249
 
229
- // Unregister closing event handler
230
- if (m_appWindow && m_appWindowClosingToken) {
231
- m_appWindow.Closing(m_appWindowClosingToken);
232
- m_appWindowClosingToken.value = 0;
250
+ // Restore message routing to parent
251
+ if (m_prevWindowID) {
252
+ winrt::Microsoft::ReactNative::ReactCoreInjection::SetTopLevelWindowId(
253
+ m_reactContext.Properties().Handle(), m_prevWindowID);
233
254
  }
234
255
 
235
- // dispatch onDismiss event
256
+ // Bring parent window to foreground
257
+ if (m_parentHwnd) {
258
+ SetForegroundWindow(m_parentHwnd);
259
+ SetFocus(m_parentHwnd);
260
+ }
261
+
262
+ // Dispatch onDismiss event
236
263
  if (auto eventEmitter = EventEmitter()) {
237
264
  ::Microsoft::ReactNativeSpecs::ModalHostViewEventEmitter::OnDismiss eventArgs;
238
265
  eventEmitter->onDismiss(eventArgs);
239
266
  }
240
-
241
- // reset the topWindowID
242
- if (m_prevWindowID) {
243
- winrt::Microsoft::ReactNative::ReactCoreInjection::SetTopLevelWindowId(
244
- m_reactContext.Properties().Handle(), m_prevWindowID);
245
- m_prevWindowID = 0;
246
- }
247
267
  }
248
268
 
249
269
  // creates a new modal window
@@ -279,9 +299,16 @@ struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::F
279
299
  overlappedPresenter.IsModal(true);
280
300
  overlappedPresenter.SetBorderAndTitleBar(true, true);
281
301
 
302
+ // modal should only have close button
303
+ overlappedPresenter.IsMinimizable(false);
304
+ overlappedPresenter.IsMaximizable(false);
305
+
282
306
  // Apply the presenter to the window
283
307
  m_appWindow.SetPresenter(overlappedPresenter);
284
308
 
309
+ // Hide the title bar icon
310
+ m_appWindow.TitleBar().IconShowOptions(winrt::Microsoft::UI::Windowing::IconShowOptions::HideIconAndSystemMenu);
311
+
285
312
  // Set initial title using the stored local props
286
313
  if (m_localProps && m_localProps->title.has_value()) {
287
314
  winrt::hstring titleValue = winrt::to_hstring(m_localProps->title.value());
@@ -284,6 +284,7 @@ void ReactNativeIsland::UpdateRootVisualSize() noexcept {
284
284
  m_rootVisual.Size({m_size.Width * m_scaleFactor, m_size.Height * m_scaleFactor});
285
285
 
286
286
  UpdateLoadingVisualSize();
287
+ UpdateDebuggerVisualSize();
287
288
  }
288
289
 
289
290
  void ReactNativeIsland::UpdateLoadingVisualSize() noexcept {
@@ -300,6 +301,13 @@ void ReactNativeIsland::UpdateLoadingVisualSize() noexcept {
300
301
  }
301
302
  }
302
303
 
304
+ void ReactNativeIsland::UpdateDebuggerVisualSize() noexcept {
305
+ if (!m_debuggerChildSiteLink)
306
+ return;
307
+
308
+ m_debuggerChildSiteLink.ActualSize(m_size);
309
+ }
310
+
303
311
  float ReactNativeIsland::ScaleFactor() noexcept {
304
312
  return m_scaleFactor;
305
313
  }
@@ -484,6 +492,20 @@ void ReactNativeIsland::InitRootView(
484
492
  m_CompositionEventHandler = std::make_shared<::Microsoft::ReactNative::CompositionEventHandler>(m_context, *this);
485
493
  m_CompositionEventHandler->Initialize();
486
494
 
495
+ ::Microsoft::ReactNative::DebuggerNotifications::SubscribeShowDebuggerPausedOverlay(
496
+ m_context.Notifications().Handle(),
497
+ m_context.UIDispatcher().Handle(),
498
+ [weakThis = get_weak()](std::string message, std::function<void()> onResume) {
499
+ if (auto strongThis = weakThis.get()) {
500
+ strongThis->ShowDebuggerUI(message, onResume);
501
+ }
502
+ },
503
+ [weakThis = get_weak()]() {
504
+ if (auto strongThis = weakThis.get()) {
505
+ strongThis->HideDebuggerUI();
506
+ }
507
+ });
508
+
487
509
  UpdateRootViewInternal();
488
510
 
489
511
  m_isInitialized = true;
@@ -746,7 +768,10 @@ void ReactNativeIsland::ShowInstanceLoading() noexcept {
746
768
  NotifySizeChanged();
747
769
  UpdateLoadingVisualSize();
748
770
 
749
- InternalRootVisual().InsertAt(m_loadingVisual, m_hasRenderedVisual ? 1 : 0);
771
+ // ShowDebuggerUI(); // TEMP
772
+
773
+ InternalRootVisual().InsertAt(
774
+ m_loadingVisual, m_hasRenderedVisual ? (m_debuggerVisual ? 2 : 1) : (m_debuggerVisual ? 1 : 0));
750
775
  }
751
776
 
752
777
  void ReactNativeIsland::InitTextScaleMultiplier() noexcept {
@@ -767,6 +792,48 @@ void ReactNativeIsland::InitTextScaleMultiplier() noexcept {
767
792
  });
768
793
  }
769
794
 
795
+ void ReactNativeIsland::ShowDebuggerUI(std::string message, const std::function<void()> &onResume) noexcept {
796
+ if (!m_debuggerVisual) {
797
+ auto compContext =
798
+ winrt::Microsoft::ReactNative::Composition::implementation::CompositionUIService::GetCompositionContext(
799
+ m_context.Properties().Handle());
800
+ m_debuggerVisual = compContext.CreateSpriteVisual();
801
+
802
+ m_debuggerChildSiteLink = winrt::Microsoft::UI::Content::ChildSiteLink::Create(
803
+ Island(),
804
+ winrt::Microsoft::ReactNative::Composition::Experimental::MicrosoftCompositionContextHelper::InnerVisual(
805
+ m_debuggerVisual)
806
+ .as<winrt::Microsoft::UI::Composition::ContainerVisual>());
807
+
808
+ m_debuggerUIIsland = std::make_shared<DebuggerUIIsland>(m_compositor, compContext, Theme());
809
+ m_debuggerUIIsland->Message(std::string(message));
810
+ m_debuggerVisual.RelativeSizeWithOffset({0.0f, 0.0f}, {1.0f, 1.0f});
811
+
812
+ m_debuggerUIIsland->Resumed(
813
+ [wkThis = get_weak(), onResume](
814
+ const winrt::Windows::Foundation::IInspectable &, const winrt::Windows::Foundation::IInspectable &) {
815
+ if (auto pThis = wkThis.get()) {
816
+ // pThis->HideDebuggerUI();
817
+ onResume();
818
+ }
819
+ });
820
+
821
+ InternalRootVisual().InsertAt(m_debuggerVisual, m_hasRenderedVisual ? 1 : 0);
822
+ m_debuggerUIIsland->Island().IsHitTestVisibleWhenTransparent(false);
823
+ m_debuggerChildSiteLink.Connect(m_debuggerUIIsland->Island());
824
+ }
825
+
826
+ m_debuggerVisual.IsVisible(true);
827
+
828
+ UpdateRootVisualSize();
829
+ }
830
+
831
+ void ReactNativeIsland::HideDebuggerUI() noexcept {
832
+ if (m_debuggerVisual) {
833
+ m_debuggerVisual.IsVisible(false);
834
+ }
835
+ }
836
+
770
837
  winrt::Windows::Foundation::Size ReactNativeIsland::Measure(
771
838
  const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints,
772
839
  const winrt::Windows::Foundation::Point &viewportOffset) const {
@@ -7,11 +7,14 @@
7
7
  #include <FocusNavigationResult.g.h>
8
8
 
9
9
  #include <ReactContext.h>
10
+ #include <ReactHost/DebuggerNotifications.h>
10
11
  #include <react/renderer/core/LayoutConstraints.h>
11
12
  #include <winrt/Microsoft.ReactNative.Composition.Experimental.h>
12
13
  #include <winrt/Microsoft.ReactNative.h>
14
+ #include <winrt/Microsoft.UI.Content.h>
13
15
  #include <winrt/Windows.UI.ViewManagement.h>
14
16
  #include "CompositionEventHandler.h"
17
+ #include "DebuggerUIIsland.h"
15
18
  #include "PortalComponentView.h"
16
19
  #include "ReactHost/React.h"
17
20
 
@@ -181,6 +184,9 @@ struct ReactNativeIsland
181
184
  std::shared_ptr<::Microsoft::ReactNative::CompositionEventHandler> m_CompositionEventHandler;
182
185
  winrt::Microsoft::ReactNative::Composition::Experimental::IVisual m_rootVisual{nullptr};
183
186
  winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_loadingVisual{nullptr};
187
+ winrt::Microsoft::UI::Content::ChildSiteLink m_debuggerChildSiteLink{nullptr};
188
+ std::shared_ptr<DebuggerUIIsland> m_debuggerUIIsland;
189
+ winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_debuggerVisual{nullptr};
184
190
  winrt::Microsoft::ReactNative::Composition::Experimental::IActivityVisual m_loadingActivityVisual{nullptr};
185
191
  winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader m_resources{nullptr};
186
192
  winrt::Microsoft::ReactNative::Composition::Theme m_theme{nullptr};
@@ -196,8 +202,11 @@ struct ReactNativeIsland
196
202
  void ShowInstanceLoaded() noexcept;
197
203
  void ShowInstanceError() noexcept;
198
204
  void ShowInstanceLoading() noexcept;
205
+ void ShowDebuggerUI(std::string message, const std::function<void()> &onResume) noexcept;
206
+ void HideDebuggerUI() noexcept;
199
207
  void UpdateRootVisualSize() noexcept;
200
208
  void UpdateLoadingVisualSize() noexcept;
209
+ void UpdateDebuggerVisualSize() noexcept;
201
210
  Composition::Experimental::IDrawingSurfaceBrush CreateLoadingVisualBrush() noexcept;
202
211
  void ApplyConstraints(
203
212
  const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraintsIn,
@@ -7,7 +7,6 @@
7
7
  #include "TextDrawing.h"
8
8
 
9
9
  #include <AutoDraw.h>
10
- #include <Fabric/platform/react/renderer/graphics/PlatformColorUtils.h>
11
10
  #include <Utils/ValueUtils.h>
12
11
  #include <unicode.h>
13
12
  #include <windows.ui.composition.interop.h>
@@ -36,27 +35,11 @@ void RenderText(
36
35
  // to cache and reuse a brush across all text elements instead, taking care to recreate
37
36
  // it in the event of device removed.
38
37
  winrt::com_ptr<ID2D1SolidColorBrush> brush;
39
-
40
- // Check if we should use theme-aware default color instead of hardcoded black
41
- bool useDefaultColor = false;
42
38
  if (textAttributes.foregroundColor) {
43
- auto &color = *textAttributes.foregroundColor;
44
- // If it's black (or very dark) without explicit PlatformColor, use theme-aware color
45
- if (color.m_platformColor.empty() && color.m_color.R <= 10 && color.m_color.G <= 10 && color.m_color.B <= 10) {
46
- useDefaultColor = true;
47
- }
48
- } else {
49
- useDefaultColor = true;
50
- }
51
-
52
- if (useDefaultColor) {
53
- // Use theme-aware TextFillColorPrimary which adapts to light/dark mode
54
- auto d2dColor = theme.D2DPlatformColor("TextFillColorPrimary");
55
- winrt::check_hresult(deviceContext.CreateSolidColorBrush(d2dColor, brush.put()));
56
- } else {
57
- // User set explicit color or PlatformColor - use it
58
39
  auto color = theme.D2DColor(*textAttributes.foregroundColor);
59
40
  winrt::check_hresult(deviceContext.CreateSolidColorBrush(color, brush.put()));
41
+ } else {
42
+ winrt::check_hresult(deviceContext.CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Black, 1.0f), brush.put()));
60
43
  }
61
44
 
62
45
  if (textAttributes.textDecorationLineType) {
@@ -89,27 +72,12 @@ void RenderText(
89
72
  (fragment.textAttributes.foregroundColor != textAttributes.foregroundColor) ||
90
73
  !isnan(fragment.textAttributes.opacity)) {
91
74
  winrt::com_ptr<ID2D1SolidColorBrush> fragmentBrush;
92
-
93
- // Check if we should use theme-aware default color for this fragment
94
- bool useFragmentDefaultColor = false;
95
75
  if (fragment.textAttributes.foregroundColor) {
96
- auto &color = *fragment.textAttributes.foregroundColor;
97
- // If it's black (or very dark) without explicit PlatformColor, use theme-aware color
98
- if (color.m_platformColor.empty() && color.m_color.R <= 10 && color.m_color.G <= 10 && color.m_color.B <= 10) {
99
- useFragmentDefaultColor = true;
100
- }
101
- } else {
102
- useFragmentDefaultColor = true;
103
- }
104
-
105
- if (useFragmentDefaultColor) {
106
- // Use theme-aware TextFillColorPrimary which adapts to light/dark mode
107
- auto d2dColor = theme.D2DPlatformColor("TextFillColorPrimary");
108
- winrt::check_hresult(deviceContext.CreateSolidColorBrush(d2dColor, fragmentBrush.put()));
109
- } else {
110
- // User set explicit color or PlatformColor - use it
111
76
  auto color = theme.D2DColor(*fragment.textAttributes.foregroundColor);
112
77
  winrt::check_hresult(deviceContext.CreateSolidColorBrush(color, fragmentBrush.put()));
78
+ } else {
79
+ winrt::check_hresult(
80
+ deviceContext.CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Black, 1.0f), fragmentBrush.put()));
113
81
  }
114
82
 
115
83
  if (fragment.textAttributes.textDecorationLineType) {
@@ -291,9 +291,11 @@ ImageResponseOrImageErrorInfo ImageFailedResponse::ResolveImage() {
291
291
  if (imageOrError.errorInfo->error.empty()) {
292
292
  imageOrError.errorInfo->error = "Failed to load image.";
293
293
  }
294
- for (auto &&[header, value] : m_responseHeaders) {
295
- imageOrError.errorInfo->httpResponseHeaders.push_back(
296
- std::make_pair<std::string, std::string>(winrt::to_string(header), winrt::to_string(value)));
294
+ if (m_responseHeaders) {
295
+ for (auto &&[header, value] : m_responseHeaders) {
296
+ imageOrError.errorInfo->httpResponseHeaders.push_back(
297
+ std::make_pair<std::string, std::string>(winrt::to_string(header), winrt::to_string(value)));
298
+ }
297
299
  }
298
300
  return imageOrError;
299
301
  }
@@ -167,6 +167,9 @@ void FabricUIManager::setProps(facebook::react::SurfaceId surfaceId, const folly
167
167
  }
168
168
 
169
169
  void FabricUIManager::stopSurface(facebook::react::SurfaceId surfaceId) noexcept {
170
+ if (surfaceId == -1) {
171
+ return;
172
+ }
170
173
  visit(surfaceId, [&](const facebook::react::SurfaceHandler &surfaceHandler) {
171
174
  surfaceHandler.stop();
172
175
  m_scheduler->unregisterSurface(surfaceHandler);
@@ -176,7 +179,9 @@ void FabricUIManager::stopSurface(facebook::react::SurfaceId surfaceId) noexcept
176
179
  std::unique_lock lock(m_handlerMutex);
177
180
 
178
181
  auto iterator = m_handlerRegistry.find(surfaceId);
179
- m_handlerRegistry.erase(iterator);
182
+ if (iterator != m_handlerRegistry.end()) {
183
+ m_handlerRegistry.erase(iterator);
184
+ }
180
185
  }
181
186
 
182
187
  auto &rootDescriptor = m_registry.componentViewDescriptorWithTag(surfaceId);
@@ -10,6 +10,7 @@
10
10
  #include <Fabric/Composition/ImageResponseImage.h>
11
11
  #include <Fabric/Composition/UriImageManager.h>
12
12
  #include <Networking/NetworkPropertyIds.h>
13
+ #include <Utils/CppWinrtLessExceptions.h>
13
14
  #include <Utils/ImageUtils.h>
14
15
  #include <fmt/format.h>
15
16
  #include <functional/functor.h>
@@ -131,7 +132,19 @@ WindowsImageManager::GetImageRandomAccessStreamAsync(
131
132
  request.Content(bodyContent);
132
133
  }
133
134
 
134
- winrt::Windows::Web::Http::HttpResponseMessage response(co_await m_httpClient.SendRequestAsync(request));
135
+ auto asyncOp = m_httpClient.SendRequestAsync(request);
136
+ co_await lessthrow_await_adapter<winrt::Windows::Foundation::IAsyncOperationWithProgress<
137
+ winrt::Windows::Web::Http::HttpResponseMessage,
138
+ winrt::Windows::Web::Http::HttpProgress>>{asyncOp};
139
+
140
+ if (asyncOp.Status() == winrt::Windows::Foundation::AsyncStatus::Error ||
141
+ asyncOp.Status() == winrt::Windows::Foundation::AsyncStatus::Canceled) {
142
+ auto errorMessage = FormatHResultError(winrt::hresult_error(asyncOp.ErrorCode()));
143
+ co_return winrt::Microsoft::ReactNative::Composition::ImageFailedResponse(
144
+ winrt::to_hstring("Network request failed: " + errorMessage));
145
+ }
146
+
147
+ winrt::Windows::Web::Http::HttpResponseMessage response = asyncOp.GetResults();
135
148
 
136
149
  if (!response.IsSuccessStatusCode()) {
137
150
  co_return winrt::Microsoft::ReactNative::Composition::ImageFailedResponse(
@@ -189,21 +189,4 @@ SharedColor GetTextInputPlaceholderColor(bool isFocused, const winrt::Windows::U
189
189
  }
190
190
  }
191
191
 
192
- SharedColor GetDefaultTextColor() {
193
- // In high contrast mode, always use system WindowText for accessibility
194
- auto accessibilitySettings{winrt::Windows::UI::ViewManagement::AccessibilitySettings()};
195
- if (accessibilitySettings.HighContrast()) {
196
- auto uiSettings{winrt::Windows::UI::ViewManagement::UISettings()};
197
- auto windowText = uiSettings.UIElementColor(winrt::Windows::UI::ViewManagement::UIElementType::WindowText);
198
- return hostPlatformColorFromRGBA(windowText.R, windowText.G, windowText.B, windowText.A);
199
- }
200
-
201
- // Use Windows 11 design system semantic color TextFillColorPrimary
202
- // This automatically adapts to light/dark mode themes:
203
- // - Light mode: rgba(0, 0, 0, 0.894) - nearly black for good contrast
204
- // - Dark mode: rgba(255, 255, 255, 1.0) - white for readability
205
- auto color = ResolvePlatformColor({"TextFillColorPrimary"});
206
- return hostPlatformColorFromRGBA(color.R, color.G, color.B, color.A);
207
- }
208
-
209
192
  } // namespace facebook::react