react-native-windows 0.74.23 → 0.74.24
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.
- package/Microsoft.ReactNative/CompositionComponentView.idl +2 -1
- package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +4 -1
- package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +7 -0
- package/Microsoft.ReactNative/Fabric/AbiViewProps.h +2 -0
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +11 -4
- package/Microsoft.ReactNative/Fabric/ComponentView.h +3 -2
- package/Microsoft.ReactNative/Fabric/Composition/BorderPrimitive.cpp +926 -0
- package/Microsoft.ReactNative/Fabric/Composition/BorderPrimitive.h +76 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +31 -13
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +27 -3
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +3 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +193 -892
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +17 -22
- package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +129 -122
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +14 -8
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +34 -20
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +5 -3
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +40 -2
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +9 -0
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +31 -3
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +8 -8
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +31 -1
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +9 -3
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +11 -0
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +2 -0
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +1 -0
- package/Microsoft.ReactNative/IReactViewComponentBuilder.idl +1 -1
- package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +25 -129
- package/Microsoft.ReactNative/ReactNativeAppBuilder.h +5 -13
- package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +13 -34
- package/Microsoft.ReactNative/ReactNativeIsland.idl +3 -2
- package/Microsoft.ReactNative/ReactNativeWin32App.cpp +129 -18
- package/Microsoft.ReactNative/ReactNativeWin32App.h +14 -5
- package/Microsoft.ReactNative/ViewProps.idl +2 -0
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/Shared/Shared.vcxitems +3 -10
- package/Shared/Shared.vcxitems.filters +1 -0
- package/package.json +3 -3
- package/templates/cpp-app/windows/MyApp/MyApp.cpp +46 -130
- package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.cpp +0 -59
- package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.h +0 -23
|
@@ -9,60 +9,39 @@ import "IReactPackageProvider.idl";
|
|
|
9
9
|
namespace Microsoft.ReactNative {
|
|
10
10
|
|
|
11
11
|
[experimental]
|
|
12
|
-
DOC_STRING("ReactNativeWin32App
|
|
12
|
+
DOC_STRING("ReactNativeWin32App sets up the infrastructure for the default experience of a ReactNative application filling a WinAppSDK window.")
|
|
13
13
|
runtimeclass ReactNativeWin32App {
|
|
14
14
|
// Properties
|
|
15
15
|
Microsoft.UI.Windowing.AppWindow AppWindow {get;};
|
|
16
16
|
|
|
17
|
-
Microsoft.UI.Composition.Compositor Compositor {get;};
|
|
18
|
-
|
|
19
|
-
Microsoft.UI.Content.DesktopChildSiteBridge DesktopChildSiteBridge {get;};
|
|
20
|
-
|
|
21
17
|
ReactNativeHost ReactNativeHost {get;};
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
ReactViewOptions ReactViewOptions {get;};
|
|
20
|
+
|
|
21
|
+
// TODO: Hide these APIs for now until we're sure we need to expose them and can do so safely
|
|
22
|
+
// Microsoft.UI.Composition.Compositor Compositor {get;};
|
|
23
|
+
// Microsoft.UI.Content.DesktopChildSiteBridge DesktopChildSiteBridge {get;};
|
|
24
|
+
// Microsoft.UI.Dispatching DispatcherQueueController {get;};
|
|
25
|
+
// ReactNativeIsland ReactNativeIsland {get;};
|
|
24
26
|
|
|
25
27
|
// Methods
|
|
26
28
|
void Start();
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
[experimental]
|
|
30
|
-
DOC_STRING("
|
|
31
|
-
runtimeclass ReactInstanceSettingsBuilder
|
|
32
|
-
{
|
|
33
|
-
ReactInstanceSettingsBuilder();
|
|
34
|
-
|
|
35
|
-
// Properties
|
|
36
|
-
ReactInstanceSettings ReactInstanceSettings {get;};
|
|
37
|
-
|
|
38
|
-
// Methods
|
|
39
|
-
ReactInstanceSettingsBuilder UseDirectDebugger(Boolean state);
|
|
40
|
-
|
|
41
|
-
ReactInstanceSettingsBuilder UseDeveloperSupport(Boolean state);
|
|
42
|
-
|
|
43
|
-
ReactInstanceSettingsBuilder BundleRootPath(String path);
|
|
44
|
-
|
|
45
|
-
ReactInstanceSettingsBuilder DebugBundlePath(String path);
|
|
46
|
-
|
|
47
|
-
ReactInstanceSettingsBuilder JavaScriptBundleFile(String file);
|
|
48
|
-
|
|
49
|
-
ReactInstanceSettingsBuilder UseFastRefresh(Boolean state);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
[experimental]
|
|
53
|
-
DOC_STRING("ReactNativeAppBuilder initializes all the required infrastructure for a Win32 Fabric Application.")
|
|
32
|
+
DOC_STRING("ReactNativeAppBuilder builds a ReactNativeWin32App with the base WinAppSDK infrastructure.")
|
|
54
33
|
runtimeclass ReactNativeAppBuilder
|
|
55
34
|
{
|
|
56
35
|
ReactNativeAppBuilder();
|
|
57
36
|
|
|
58
37
|
// Methods
|
|
59
|
-
ReactNativeAppBuilder AddPackageProviders(Windows.Foundation.Collections.IVector<Microsoft.ReactNative.IReactPackageProvider> packageProviders);
|
|
60
|
-
|
|
61
|
-
ReactNativeAppBuilder SetReactInstanceSettings(ReactInstanceSettings settings);
|
|
62
38
|
|
|
63
39
|
ReactNativeAppBuilder SetAppWindow(Microsoft.UI.Windowing.AppWindow appWindow);
|
|
64
40
|
|
|
65
|
-
|
|
41
|
+
// TODO: Hide these APIs for now until we're sure we need to expose them and can do so safely
|
|
42
|
+
// Compositor depends on the DispatcherQueue created by DispatcherQueueController
|
|
43
|
+
// ReactNativeAppBuilder SetCompositor(Microsoft.UI.Composition.Compositor compositor);
|
|
44
|
+
// ReactNativeAppBuilder SetDispatcherQueueController(Microsoft.UI.Dispatching DispatcherQueueController);
|
|
66
45
|
|
|
67
46
|
ReactNativeWin32App Build();
|
|
68
47
|
}
|
|
@@ -78,11 +78,12 @@ namespace Microsoft.ReactNative
|
|
|
78
78
|
DOC_STRING("A windows composition component that hosts React Native UI elements.")
|
|
79
79
|
runtimeclass ReactNativeIsland
|
|
80
80
|
{
|
|
81
|
-
DOC_STRING("Creates a new instance of @ReactNativeIsland.")
|
|
81
|
+
DOC_STRING("Creates a new instance of @ReactNativeIsland. Can be implemented with a ReactViewHost or a ComponentView with reactContext")
|
|
82
82
|
ReactNativeIsland();
|
|
83
83
|
|
|
84
84
|
#ifdef USE_WINUI3
|
|
85
85
|
ReactNativeIsland(Microsoft.UI.Composition.Compositor compositor);
|
|
86
|
+
ReactNativeIsland(Microsoft.UI.Composition.Compositor compositor, Microsoft.ReactNative.IReactContext context, Microsoft.ReactNative.ComponentView componentView);
|
|
86
87
|
#endif
|
|
87
88
|
|
|
88
89
|
DOC_STRING(
|
|
@@ -97,7 +98,7 @@ namespace Microsoft.ReactNative
|
|
|
97
98
|
|
|
98
99
|
DOC_STRING("ScaleFactor for this windows (DPI/96)")
|
|
99
100
|
Single ScaleFactor {get; set;};
|
|
100
|
-
|
|
101
|
+
|
|
101
102
|
Single FontSizeMultiplier { get; };
|
|
102
103
|
|
|
103
104
|
DOC_STRING("Move focus to this @ReactNativeIsland")
|
|
@@ -1,12 +1,42 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
1
4
|
#include "pch.h"
|
|
2
5
|
#include "ReactNativeWin32App.h"
|
|
3
6
|
#include "ReactNativeWin32App.g.cpp"
|
|
7
|
+
|
|
8
|
+
#include "IReactDispatcher.h"
|
|
9
|
+
#include "ReactCoreInjection.h"
|
|
4
10
|
#include "ReactNativeHost.h"
|
|
11
|
+
|
|
5
12
|
#include "winrt/Microsoft.UI.Composition.h"
|
|
6
13
|
#include "winrt/Microsoft.UI.Content.h"
|
|
14
|
+
#include "winrt/Microsoft.UI.Dispatching.h"
|
|
7
15
|
#include "winrt/Microsoft.UI.Interop.h"
|
|
8
16
|
#include "winrt/Microsoft.UI.Windowing.h"
|
|
9
17
|
|
|
18
|
+
// Scaling factor for the window's content based on the DPI of the display where the window is located.
|
|
19
|
+
float ScaleFactor(HWND hwnd) noexcept {
|
|
20
|
+
return GetDpiForWindow(hwnd) / static_cast<float>(USER_DEFAULT_SCREEN_DPI);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void UpdateRootViewSizeToAppWindow(
|
|
24
|
+
winrt::Microsoft::ReactNative::ReactNativeIsland const &rootView,
|
|
25
|
+
winrt::Microsoft::UI::Windowing::AppWindow const &window) {
|
|
26
|
+
auto hwnd = winrt::Microsoft::UI::GetWindowFromWindowId(window.Id());
|
|
27
|
+
auto scaleFactor = ScaleFactor(hwnd);
|
|
28
|
+
winrt::Windows::Foundation::Size size{
|
|
29
|
+
window.ClientSize().Width / scaleFactor, window.ClientSize().Height / scaleFactor};
|
|
30
|
+
// Do not relayout when minimized
|
|
31
|
+
if (window.Presenter().as<winrt::Microsoft::UI::Windowing::OverlappedPresenter>().State() !=
|
|
32
|
+
winrt::Microsoft::UI::Windowing::OverlappedPresenterState::Minimized) {
|
|
33
|
+
winrt::Microsoft::ReactNative::LayoutConstraints constraints;
|
|
34
|
+
constraints.LayoutDirection = winrt::Microsoft::ReactNative::LayoutDirection::Undefined;
|
|
35
|
+
constraints.MaximumSize = constraints.MinimumSize = size;
|
|
36
|
+
rootView.Arrange(constraints, {0, 0});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
10
40
|
namespace winrt::Microsoft::ReactNative::implementation {
|
|
11
41
|
ReactNativeWin32App::ReactNativeWin32App() {}
|
|
12
42
|
|
|
@@ -14,41 +44,44 @@ ReactNativeWin32App::~ReactNativeWin32App() {
|
|
|
14
44
|
m_desktopChildSiteBridge = nullptr;
|
|
15
45
|
|
|
16
46
|
// Destroy all Composition objects
|
|
17
|
-
m_compositor
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
void ReactNativeWin32App::AppWindow(winrt::Microsoft::UI::Windowing::AppWindow const &appWindow) {
|
|
22
|
-
m_appWindow = appWindow;
|
|
47
|
+
if (m_compositor != nullptr) {
|
|
48
|
+
m_compositor.Close();
|
|
49
|
+
m_compositor = nullptr;
|
|
50
|
+
}
|
|
23
51
|
}
|
|
24
52
|
|
|
25
53
|
winrt::Microsoft::UI::Windowing::AppWindow ReactNativeWin32App::AppWindow() {
|
|
26
54
|
return m_appWindow;
|
|
27
55
|
}
|
|
28
56
|
|
|
29
|
-
void ReactNativeWin32App::
|
|
30
|
-
|
|
57
|
+
void ReactNativeWin32App::AppWindow(winrt::Microsoft::UI::Windowing::AppWindow const &appWindow) {
|
|
58
|
+
m_appWindow = appWindow;
|
|
31
59
|
}
|
|
32
60
|
|
|
33
61
|
winrt::Microsoft::UI::Composition::Compositor ReactNativeWin32App::Compositor() {
|
|
34
62
|
return m_compositor;
|
|
35
63
|
}
|
|
36
64
|
|
|
37
|
-
winrt::Microsoft::
|
|
38
|
-
|
|
65
|
+
void ReactNativeWin32App::Compositor(winrt::Microsoft::UI::Composition::Compositor const &compositor) {
|
|
66
|
+
m_compositor = compositor;
|
|
39
67
|
}
|
|
40
68
|
|
|
41
|
-
void ReactNativeWin32App::
|
|
42
|
-
|
|
69
|
+
void ReactNativeWin32App::DesktopChildSiteBridge(
|
|
70
|
+
winrt::Microsoft::UI::Content::DesktopChildSiteBridge const &desktopChildSiteBridge) {
|
|
71
|
+
m_desktopChildSiteBridge = desktopChildSiteBridge;
|
|
43
72
|
}
|
|
44
73
|
|
|
45
74
|
winrt::Microsoft::UI::Content::DesktopChildSiteBridge ReactNativeWin32App::DesktopChildSiteBridge() {
|
|
46
75
|
return m_desktopChildSiteBridge;
|
|
47
76
|
}
|
|
48
77
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
78
|
+
winrt::Microsoft::UI::Dispatching::DispatcherQueueController ReactNativeWin32App::DispatcherQueueController() {
|
|
79
|
+
return m_dispatcherQueueController;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
void ReactNativeWin32App::DispatcherQueueController(
|
|
83
|
+
winrt::Microsoft::UI::Dispatching::DispatcherQueueController const &dispatcherQueueController) {
|
|
84
|
+
m_dispatcherQueueController = dispatcherQueueController;
|
|
52
85
|
}
|
|
53
86
|
|
|
54
87
|
winrt::Microsoft::ReactNative::ReactNativeHost ReactNativeWin32App::ReactNativeHost() {
|
|
@@ -62,12 +95,90 @@ void ReactNativeWin32App::ReactNativeHost(winrt::Microsoft::ReactNative::ReactNa
|
|
|
62
95
|
m_host = host;
|
|
63
96
|
}
|
|
64
97
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
98
|
+
winrt::Microsoft::ReactNative::ReactNativeIsland ReactNativeWin32App::ReactNativeIsland() {
|
|
99
|
+
return m_reactNativeIsland;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
void ReactNativeWin32App::ReactNativeIsland(winrt::Microsoft::ReactNative::ReactNativeIsland const &reactNativeIsland) {
|
|
103
|
+
m_reactNativeIsland = reactNativeIsland;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
winrt::Microsoft::ReactNative::ReactViewOptions ReactNativeWin32App::ReactViewOptions() {
|
|
107
|
+
if (m_reactViewOptions == nullptr) {
|
|
108
|
+
m_reactViewOptions = winrt::make<winrt::Microsoft::ReactNative::implementation::ReactViewOptions>();
|
|
109
|
+
}
|
|
110
|
+
return m_reactViewOptions;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
void ReactNativeWin32App::ReactViewOptions(winrt::Microsoft::ReactNative::ReactViewOptions const &viewOptions) {
|
|
114
|
+
m_reactViewOptions = viewOptions;
|
|
68
115
|
}
|
|
69
116
|
|
|
70
117
|
void ReactNativeWin32App::Start() {
|
|
118
|
+
// Show the hosting AppWindow
|
|
119
|
+
m_appWindow.Show();
|
|
120
|
+
|
|
121
|
+
// Currently set the property to use current thread dispatcher as a default UI dispatcher.
|
|
122
|
+
// TODO: Use the correct dispatcher from a developer-provided DispatcherQueueController
|
|
123
|
+
ReactNativeHost().InstanceSettings().Properties().Set(
|
|
124
|
+
ReactDispatcherHelper::UIDispatcherProperty(), ReactDispatcherHelper::UIThreadDispatcher());
|
|
125
|
+
|
|
126
|
+
auto hwnd{winrt::Microsoft::UI::GetWindowFromWindowId(m_appWindow.Id())};
|
|
127
|
+
|
|
128
|
+
winrt::Microsoft::ReactNative::ReactCoreInjection::SetTopLevelWindowId(
|
|
129
|
+
ReactNativeHost().InstanceSettings().Properties(), reinterpret_cast<uint64_t>(hwnd));
|
|
130
|
+
|
|
131
|
+
winrt::Microsoft::ReactNative::Composition::CompositionUIService::SetCompositor(
|
|
132
|
+
ReactNativeHost().InstanceSettings(), m_compositor);
|
|
133
|
+
|
|
134
|
+
// Start the react-native instance, which will create a JavaScript runtime and load the applications bundle.
|
|
135
|
+
ReactNativeHost().ReloadInstance();
|
|
136
|
+
|
|
137
|
+
// Create a RootView which will present a react-native component
|
|
138
|
+
if (m_reactNativeIsland == nullptr) {
|
|
139
|
+
m_reactNativeIsland = winrt::Microsoft::ReactNative::ReactNativeIsland(m_compositor);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
m_reactNativeIsland.ReactViewHost(
|
|
143
|
+
winrt::Microsoft::ReactNative::ReactCoreInjection::MakeViewHost(ReactNativeHost(), ReactViewOptions()));
|
|
144
|
+
|
|
145
|
+
// Update the size of the RootView when the AppWindow changes size
|
|
146
|
+
m_appWindow.Changed([wkRootView = winrt::make_weak(m_reactNativeIsland)](
|
|
147
|
+
winrt::Microsoft::UI::Windowing::AppWindow const &window,
|
|
148
|
+
winrt::Microsoft::UI::Windowing::AppWindowChangedEventArgs const &args) {
|
|
149
|
+
if (args.DidSizeChange() || args.DidVisibilityChange()) {
|
|
150
|
+
if (auto rootView = wkRootView.get()) {
|
|
151
|
+
UpdateRootViewSizeToAppWindow(rootView, window);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Quit application when main window is closed
|
|
157
|
+
m_appWindow.Destroying([this](
|
|
158
|
+
winrt::Microsoft::UI::Windowing::AppWindow const &window,
|
|
159
|
+
winrt::Windows::Foundation::IInspectable const & /*args*/) {
|
|
160
|
+
// Before we shutdown the application - unload the ReactNativeHost to give the javascript a chance to save any
|
|
161
|
+
// state
|
|
162
|
+
auto async = ReactNativeHost().UnloadInstance();
|
|
163
|
+
async.Completed([this](auto asyncInfo, winrt::Windows::Foundation::AsyncStatus asyncStatus) {
|
|
164
|
+
assert(asyncStatus == winrt::Windows::Foundation::AsyncStatus::Completed);
|
|
165
|
+
ReactNativeHost().InstanceSettings().UIDispatcher().Post([]() { PostQuitMessage(0); });
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// DesktopChildSiteBridge create a ContentSite that can host the RootView ContentIsland
|
|
170
|
+
m_desktopChildSiteBridge =
|
|
171
|
+
winrt::Microsoft::UI::Content::DesktopChildSiteBridge::Create(m_compositor, m_appWindow.Id());
|
|
172
|
+
|
|
173
|
+
m_desktopChildSiteBridge.Connect(m_reactNativeIsland.Island());
|
|
174
|
+
|
|
175
|
+
m_desktopChildSiteBridge.ResizePolicy(winrt::Microsoft::UI::Content::ContentSizePolicy::ResizeContentToParentWindow);
|
|
176
|
+
|
|
177
|
+
auto scaleFactor = ScaleFactor(hwnd);
|
|
178
|
+
m_reactNativeIsland.ScaleFactor(scaleFactor);
|
|
179
|
+
|
|
180
|
+
UpdateRootViewSizeToAppWindow(m_reactNativeIsland, m_appWindow);
|
|
181
|
+
|
|
71
182
|
m_desktopChildSiteBridge.Show();
|
|
72
183
|
|
|
73
184
|
// Run the main application event loop
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
1
3
|
#pragma once
|
|
4
|
+
|
|
2
5
|
#include "ReactNativeWin32App.g.h"
|
|
6
|
+
|
|
3
7
|
#include "winrt/Microsoft.UI.Dispatching.h"
|
|
4
8
|
|
|
5
9
|
namespace winrt::Microsoft::ReactNative::implementation {
|
|
@@ -13,26 +17,31 @@ struct ReactNativeWin32App : ReactNativeWin32AppT<ReactNativeWin32App> {
|
|
|
13
17
|
winrt::Microsoft::UI::Composition::Compositor Compositor();
|
|
14
18
|
void Compositor(winrt::Microsoft::UI::Composition::Compositor const &compositor);
|
|
15
19
|
|
|
16
|
-
winrt::Microsoft::ReactNative::ReactNativeIsland ReactNativeIsland();
|
|
17
|
-
void ReactNativeIsland(winrt::Microsoft::ReactNative::ReactNativeIsland const &reactNativeIsland);
|
|
18
|
-
|
|
19
20
|
winrt::Microsoft::UI::Content::DesktopChildSiteBridge DesktopChildSiteBridge();
|
|
20
21
|
void DesktopChildSiteBridge(winrt::Microsoft::UI::Content::DesktopChildSiteBridge const &desktopChildSiteBridge);
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
winrt::Microsoft::UI::Dispatching::DispatcherQueueController DispatcherQueueController();
|
|
24
|
+
void DispatcherQueueController(
|
|
23
25
|
winrt::Microsoft::UI::Dispatching::DispatcherQueueController const &dispatcherQueueController);
|
|
24
26
|
|
|
25
27
|
winrt::Microsoft::ReactNative::ReactNativeHost ReactNativeHost();
|
|
26
28
|
void ReactNativeHost(winrt::Microsoft::ReactNative::ReactNativeHost const &host);
|
|
27
29
|
|
|
30
|
+
winrt::Microsoft::ReactNative::ReactNativeIsland ReactNativeIsland();
|
|
31
|
+
void ReactNativeIsland(winrt::Microsoft::ReactNative::ReactNativeIsland const &reactNativeIsland);
|
|
32
|
+
|
|
33
|
+
winrt::Microsoft::ReactNative::ReactViewOptions ReactViewOptions();
|
|
34
|
+
void ReactViewOptions(winrt::Microsoft::ReactNative::ReactViewOptions const &reactViewOptions);
|
|
35
|
+
|
|
28
36
|
void Start();
|
|
29
37
|
|
|
30
38
|
private:
|
|
31
39
|
winrt::Microsoft::UI::Windowing::AppWindow m_appWindow{nullptr};
|
|
32
40
|
winrt::Microsoft::UI::Composition::Compositor m_compositor{nullptr};
|
|
41
|
+
winrt::Microsoft::UI::Content::DesktopChildSiteBridge m_desktopChildSiteBridge{nullptr};
|
|
33
42
|
winrt::Microsoft::UI::Dispatching::DispatcherQueueController m_dispatcherQueueController{nullptr};
|
|
34
43
|
winrt::Microsoft::ReactNative::ReactNativeHost m_host{nullptr};
|
|
35
44
|
winrt::Microsoft::ReactNative::ReactNativeIsland m_reactNativeIsland{nullptr};
|
|
36
|
-
winrt::Microsoft::
|
|
45
|
+
winrt::Microsoft::ReactNative::ReactViewOptions m_reactViewOptions{nullptr};
|
|
37
46
|
};
|
|
38
47
|
} // namespace winrt::Microsoft::ReactNative::implementation
|
|
@@ -24,6 +24,8 @@ namespace Microsoft.ReactNative {
|
|
|
24
24
|
Microsoft.UI.Composition.CompositionBrush AsBrush(Microsoft.ReactNative.Composition.Theme theme);
|
|
25
25
|
#endif
|
|
26
26
|
|
|
27
|
+
Boolean Equals(Color color);
|
|
28
|
+
|
|
27
29
|
static Color Black();
|
|
28
30
|
static Color Transparent();
|
|
29
31
|
static Color ReadValue(IJSValueReader reader);
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
-->
|
|
11
11
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
12
12
|
<PropertyGroup>
|
|
13
|
-
<ReactNativeWindowsVersion>0.74.
|
|
13
|
+
<ReactNativeWindowsVersion>0.74.24</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>74</ReactNativeWindowsMinor>
|
|
16
|
-
<ReactNativeWindowsPatch>
|
|
16
|
+
<ReactNativeWindowsPatch>24</ReactNativeWindowsPatch>
|
|
17
17
|
<ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
|
|
18
|
-
<ReactNativeWindowsCommitId>
|
|
18
|
+
<ReactNativeWindowsCommitId>303dd6ff07d59bea2fcaea3c375a2dbfc48beddb</ReactNativeWindowsCommitId>
|
|
19
19
|
</PropertyGroup>
|
|
20
20
|
</Project>
|
package/Shared/Shared.vcxitems
CHANGED
|
@@ -89,6 +89,9 @@
|
|
|
89
89
|
<DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\UriImageManager.idl</DependentUpon>
|
|
90
90
|
<SubType>Code</SubType>
|
|
91
91
|
</ClCompile>
|
|
92
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\BorderPrimitive.cpp">
|
|
93
|
+
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
94
|
+
</ClCompile>
|
|
92
95
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\ContentIslandComponentView.cpp">
|
|
93
96
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
94
97
|
<DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\CompositionComponentView.idl</DependentUpon>
|
|
@@ -232,11 +235,6 @@
|
|
|
232
235
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
233
236
|
<DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\ReactNativeAppBuilder.idl</DependentUpon>
|
|
234
237
|
<SubType>Code</SubType>
|
|
235
|
-
</ClCompile>
|
|
236
|
-
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\ReactInstanceSettingsBuilder.cpp">
|
|
237
|
-
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
238
|
-
<DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\ReactNativeAppBuilder.idl</DependentUpon>
|
|
239
|
-
<SubType>Code</SubType>
|
|
240
238
|
</ClCompile>
|
|
241
239
|
<ClCompile Include="$(MSBuildThisFileDirectory)BaseFileReaderResource.cpp" />
|
|
242
240
|
<ClCompile Include="$(MSBuildThisFileDirectory)BaseScriptStoreImpl.cpp" />
|
|
@@ -349,11 +347,6 @@
|
|
|
349
347
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
350
348
|
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\ReactNativeAppBuilder.idl</DependentUpon>
|
|
351
349
|
<SubType>Code</SubType>
|
|
352
|
-
</ClInclude>
|
|
353
|
-
<ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\ReactInstanceSettingsBuilder.h">
|
|
354
|
-
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
355
|
-
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\ReactNativeAppBuilder.idl</DependentUpon>
|
|
356
|
-
<SubType>Code</SubType>
|
|
357
350
|
</ClInclude>
|
|
358
351
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\DynamicReader.cpp">
|
|
359
352
|
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\IJSValueReader.idl</DependentUpon>
|
|
@@ -326,6 +326,7 @@
|
|
|
326
326
|
<ClCompile Include="$(MSBuildThisFileDirectory)Networking\NetworkPropertyIds.cpp" />
|
|
327
327
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiEventEmitter.cpp" />
|
|
328
328
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\TooltipService.cpp" />
|
|
329
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\BorderPrimitive.cpp" />
|
|
329
330
|
</ItemGroup>
|
|
330
331
|
<ItemGroup>
|
|
331
332
|
<Filter Include="Source Files">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-windows",
|
|
3
|
-
"version": "0.74.
|
|
3
|
+
"version": "0.74.24",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@react-native-community/cli": "13.6.9",
|
|
27
27
|
"@react-native-community/cli-platform-android": "13.6.9",
|
|
28
28
|
"@react-native-community/cli-platform-ios": "13.6.9",
|
|
29
|
-
"@react-native-windows/cli": "0.74.
|
|
29
|
+
"@react-native-windows/cli": "0.74.8",
|
|
30
30
|
"@react-native/assets": "1.0.0",
|
|
31
31
|
"@react-native/assets-registry": "0.74.87",
|
|
32
32
|
"@react-native/codegen": "0.74.87",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"yargs": "^17.6.2"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@react-native-windows/codegen": "0.74.
|
|
67
|
+
"@react-native-windows/codegen": "0.74.5",
|
|
68
68
|
"@react-native/metro-config": "0.74.87",
|
|
69
69
|
"@rnw-scripts/babel-react-native-config": "0.0.0",
|
|
70
70
|
"@rnw-scripts/eslint-config": "1.2.9",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
#include "NativeModules.h"
|
|
10
10
|
|
|
11
|
+
// A PackageProvider containing any turbo modules you define within this app project
|
|
11
12
|
struct CompReactPackageProvider
|
|
12
13
|
: winrt::implements<CompReactPackageProvider, winrt::Microsoft::ReactNative::IReactPackageProvider> {
|
|
13
14
|
public: // IReactPackageProvider
|
|
@@ -16,151 +17,66 @@ struct CompReactPackageProvider
|
|
|
16
17
|
}
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
float ScaleFactor(HWND hwnd) noexcept {
|
|
24
|
-
return GetDpiForWindow(hwnd) / static_cast<float>(USER_DEFAULT_SCREEN_DPI);
|
|
25
|
-
}
|
|
20
|
+
// The entry point of the Win32 application
|
|
21
|
+
_Use_decl_annotations_ int CALLBACK WinMain(HINSTANCE instance, HINSTANCE, PSTR /* commandLine */, int showCmd) {
|
|
22
|
+
// Initialize WinRT
|
|
23
|
+
winrt::init_apartment(winrt::apartment_type::single_threaded);
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
winrt::Microsoft::UI::Windowing::AppWindow const &window) {
|
|
30
|
-
auto hwnd = winrt::Microsoft::UI::GetWindowFromWindowId(window.Id());
|
|
31
|
-
auto scaleFactor = ScaleFactor(hwnd);
|
|
32
|
-
winrt::Windows::Foundation::Size size{
|
|
33
|
-
window.ClientSize().Width / scaleFactor, window.ClientSize().Height / scaleFactor};
|
|
34
|
-
// Do not relayout when minimized
|
|
35
|
-
if (window.Presenter().as<winrt::Microsoft::UI::Windowing::OverlappedPresenter>().State() !=
|
|
36
|
-
winrt::Microsoft::UI::Windowing::OverlappedPresenterState::Minimized) {
|
|
37
|
-
winrt::Microsoft::ReactNative::LayoutConstraints constraints;
|
|
38
|
-
constraints.LayoutDirection = winrt::Microsoft::ReactNative::LayoutDirection::Undefined;
|
|
39
|
-
constraints.MaximumSize = constraints.MinimumSize = size;
|
|
40
|
-
rootView.Arrange(constraints, {0,0});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
25
|
+
// Enable per monitor DPI scaling
|
|
26
|
+
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
|
43
27
|
|
|
44
|
-
//
|
|
45
|
-
winrt::Microsoft::ReactNative::ReactNativeHost CreateReactNativeHost(
|
|
46
|
-
HWND hwnd,
|
|
47
|
-
const winrt::Microsoft::UI::Composition::Compositor &compositor) {
|
|
28
|
+
// Find the path hosting the app exe file
|
|
48
29
|
WCHAR appDirectory[MAX_PATH];
|
|
49
30
|
GetModuleFileNameW(NULL, appDirectory, MAX_PATH);
|
|
50
31
|
PathCchRemoveFileSpec(appDirectory, MAX_PATH);
|
|
51
32
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// Include any autolinked modules
|
|
55
|
-
RegisterAutolinkedNativeModulePackages(host.PackageProviders());
|
|
33
|
+
// Create a ReactNativeWin32App with the ReactNativeAppBuilder
|
|
34
|
+
auto reactNativeWin32App{winrt::Microsoft::ReactNative::ReactNativeAppBuilder().Build()};
|
|
56
35
|
|
|
57
|
-
|
|
36
|
+
// Configure the initial InstanceSettings for the app's ReactNativeHost
|
|
37
|
+
auto settings{reactNativeWin32App.ReactNativeHost().InstanceSettings()};
|
|
38
|
+
// Register any autolinked native modules
|
|
39
|
+
RegisterAutolinkedNativeModulePackages(settings.PackageProviders());
|
|
40
|
+
// Register any native modules defined within this app project
|
|
41
|
+
settings.PackageProviders().Append(winrt::make<CompReactPackageProvider>());
|
|
58
42
|
|
|
59
43
|
#if BUNDLE
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
// Load the JS bundle from a file (not Metro):
|
|
45
|
+
// Set the path (on disk) where the .bundle file is located
|
|
46
|
+
settings.BundleRootPath(std::wstring(L"file://").append(appDirectory).append(L"\\Bundle\\").c_str());
|
|
47
|
+
// Set the name of the bundle file (without the .bundle extension)
|
|
48
|
+
settings.JavaScriptBundleFile(L"index.windows");
|
|
49
|
+
// Disable hot reload
|
|
50
|
+
settings.UseFastRefresh(false);
|
|
63
51
|
#else
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
// Load the JS bundle from Metro
|
|
53
|
+
settings.JavaScriptBundleFile(L"index");
|
|
54
|
+
// Enable hot reload
|
|
55
|
+
settings.UseFastRefresh(true);
|
|
66
56
|
#endif
|
|
67
|
-
|
|
68
57
|
#if _DEBUG
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
// For Debug builds
|
|
59
|
+
// Enable Direct Debugging of JS
|
|
60
|
+
settings.UseDirectDebugger(true);
|
|
61
|
+
// Enable the Developer Menu
|
|
62
|
+
settings.UseDeveloperSupport(true);
|
|
71
63
|
#else
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
// For Release builds:
|
|
65
|
+
// Disable Direct Debugging of JS
|
|
66
|
+
settings.UseDirectDebugger(false);
|
|
67
|
+
// Disable the Developer Menu
|
|
68
|
+
settings.UseDeveloperSupport(false);
|
|
74
69
|
#endif
|
|
75
70
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
host.InstanceSettings(), compositor);
|
|
81
|
-
|
|
82
|
-
return host;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
_Use_decl_annotations_ int CALLBACK WinMain(HINSTANCE instance, HINSTANCE, PSTR /* commandLine */, int showCmd) {
|
|
86
|
-
// Initialize WinRT.
|
|
87
|
-
winrt::init_apartment(winrt::apartment_type::single_threaded);
|
|
88
|
-
|
|
89
|
-
// Enable per monitor DPI scaling
|
|
90
|
-
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
|
91
|
-
|
|
92
|
-
// Create a DispatcherQueue for this thread. This is needed for Composition, Content, and
|
|
93
|
-
// Input APIs.
|
|
94
|
-
auto dispatcherQueueController{winrt::Microsoft::UI::Dispatching::DispatcherQueueController::CreateOnCurrentThread()};
|
|
95
|
-
|
|
96
|
-
// Create a Compositor for all Content on this thread.
|
|
97
|
-
auto compositor{winrt::Microsoft::UI::Composition::Compositor()};
|
|
98
|
-
|
|
99
|
-
// Create a top-level window.
|
|
100
|
-
auto window = winrt::Microsoft::UI::Windowing::AppWindow::Create();
|
|
101
|
-
window.Title(windowTitle);
|
|
102
|
-
window.Resize({1000, 1000});
|
|
103
|
-
window.Show();
|
|
104
|
-
auto hwnd = winrt::Microsoft::UI::GetWindowFromWindowId(window.Id());
|
|
105
|
-
auto scaleFactor = ScaleFactor(hwnd);
|
|
106
|
-
|
|
107
|
-
auto host = CreateReactNativeHost(hwnd, compositor);
|
|
108
|
-
|
|
109
|
-
// Start the react-native instance, which will create a JavaScript runtime and load the applications bundle
|
|
110
|
-
host.ReloadInstance();
|
|
111
|
-
|
|
112
|
-
// Create a RootView which will present a react-native component
|
|
113
|
-
winrt::Microsoft::ReactNative::ReactViewOptions viewOptions;
|
|
114
|
-
viewOptions.ComponentName(mainComponentName);
|
|
115
|
-
auto rootView = winrt::Microsoft::ReactNative::ReactNativeIsland(compositor);
|
|
116
|
-
rootView.ReactViewHost(winrt::Microsoft::ReactNative::ReactCoreInjection::MakeViewHost(host, viewOptions));
|
|
117
|
-
|
|
118
|
-
// Update the size of the RootView when the AppWindow changes size
|
|
119
|
-
window.Changed([wkRootView = winrt::make_weak(rootView)](
|
|
120
|
-
winrt::Microsoft::UI::Windowing::AppWindow const &window,
|
|
121
|
-
winrt::Microsoft::UI::Windowing::AppWindowChangedEventArgs const &args) {
|
|
122
|
-
if (args.DidSizeChange() || args.DidVisibilityChange()) {
|
|
123
|
-
if (auto rootView = wkRootView.get()) {
|
|
124
|
-
UpdateRootViewSizeToAppWindow(rootView, window);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
// Quit application when main window is closed
|
|
130
|
-
window.Destroying(
|
|
131
|
-
[host](winrt::Microsoft::UI::Windowing::AppWindow const &window, winrt::IInspectable const & /*args*/) {
|
|
132
|
-
// Before we shutdown the application - unload the ReactNativeHost to give the javascript a chance to save any
|
|
133
|
-
// state
|
|
134
|
-
auto async = host.UnloadInstance();
|
|
135
|
-
async.Completed([host](auto asyncInfo, winrt::Windows::Foundation::AsyncStatus asyncStatus) {
|
|
136
|
-
assert(asyncStatus == winrt::Windows::Foundation::AsyncStatus::Completed);
|
|
137
|
-
host.InstanceSettings().UIDispatcher().Post([]() { PostQuitMessage(0); });
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
// DesktopChildSiteBridge create a ContentSite that can host the RootView ContentIsland
|
|
142
|
-
auto bridge = winrt::Microsoft::UI::Content::DesktopChildSiteBridge::Create(compositor, window.Id());
|
|
143
|
-
bridge.Connect(rootView.Island());
|
|
144
|
-
bridge.ResizePolicy(winrt::Microsoft::UI::Content::ContentSizePolicy::ResizeContentToParentWindow);
|
|
145
|
-
|
|
146
|
-
rootView.ScaleFactor(scaleFactor);
|
|
147
|
-
|
|
148
|
-
// Set the intialSize of the root view
|
|
149
|
-
UpdateRootViewSizeToAppWindow(rootView, window);
|
|
150
|
-
|
|
151
|
-
bridge.Show();
|
|
152
|
-
|
|
153
|
-
// Run the main application event loop
|
|
154
|
-
dispatcherQueueController.DispatcherQueue().RunEventLoop();
|
|
155
|
-
|
|
156
|
-
// Rundown the DispatcherQueue. This drains the queue and raises events to let components
|
|
157
|
-
// know the message loop has finished.
|
|
158
|
-
dispatcherQueueController.ShutdownQueue();
|
|
71
|
+
// Get the AppWindow so we can configure its initial title and size
|
|
72
|
+
auto appWindow{reactNativeWin32App.AppWindow()};
|
|
73
|
+
appWindow.Title(L"{{ mainComponentName }}");
|
|
74
|
+
appWindow.Resize({1000, 1000});
|
|
159
75
|
|
|
160
|
-
|
|
161
|
-
|
|
76
|
+
// Get the ReactViewOptions so we can set the initial RN component to load
|
|
77
|
+
auto viewOptions{reactNativeWin32App.ReactViewOptions()};
|
|
78
|
+
viewOptions.ComponentName(L"{{ mainComponentName }}");
|
|
162
79
|
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
compositor = nullptr;
|
|
80
|
+
// Start the app
|
|
81
|
+
reactNativeWin32App.Start();
|
|
166
82
|
}
|