react-native-windows 0.76.0-preview.3 → 0.76.0-preview.4
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/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +15 -15
- package/Libraries/Components/Button.windows.js +18 -18
- package/Libraries/Components/Flyout/FlyoutNativeComponent.js +5 -1
- package/Libraries/Components/Keyboard/KeyboardExt.js +1 -1
- package/Libraries/Components/Keyboard/KeyboardExt.js.map +1 -1
- package/Libraries/Components/TextInput/TextInput.windows.js +16 -11
- package/Libraries/Components/Touchable/Touchable.windows.js +2 -2
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +5 -3
- package/Libraries/Components/View/View.windows.js +1 -3
- package/Libraries/Text/Text.windows.js +13 -9
- package/Libraries/Utilities/Platform.windows.js +4 -4
- package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +25 -129
- package/Microsoft.ReactNative/ReactNativeAppBuilder.h +5 -13
- package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +13 -34
- package/Microsoft.ReactNative/ReactNativeWin32App.cpp +129 -18
- package/Microsoft.ReactNative/ReactNativeWin32App.h +14 -5
- package/PropertySheets/External/Microsoft.ReactNative.CppLib.props +17 -0
- package/PropertySheets/External/Microsoft.ReactNative.CppLib.targets +17 -0
- package/PropertySheets/Generated/PackageVersion.g.props +2 -2
- package/PropertySheets/WebView2.props +7 -0
- package/PropertySheets/WinUI.props +1 -1
- package/Shared/Shared.vcxitems +0 -10
- package/just-task.js +1 -1
- package/package.json +4 -5
- package/templates/cpp-app/template.config.js +8 -3
- package/templates/cpp-app/windows/MyApp/MyApp.cpp +46 -131
- package/templates/cpp-lib/template.config.js +8 -3
- package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +4 -4
- package/templates/templateUtils.js +2 -3
- package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.cpp +0 -59
- package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.h +0 -23
|
@@ -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
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
Licensed under the MIT License.
|
|
5
|
+
|
|
6
|
+
This file will be consumed by ALL C++ module projects (both inside
|
|
7
|
+
and outside of this repo) that build on top of Microsoft.ReactNative.
|
|
8
|
+
Do not make any changes here unless it applies to ALL such projects.
|
|
9
|
+
-->
|
|
10
|
+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
11
|
+
<ImportGroup Condition="'$(UseFabric)' == 'true'">
|
|
12
|
+
<Import Project="$(MSBuildThisFileDirectory)Microsoft.ReactNative.Composition.CppLib.props" />
|
|
13
|
+
</ImportGroup>
|
|
14
|
+
<ImportGroup Condition="'$(UseFabric)' != 'true'">
|
|
15
|
+
<Import Project="$(MSBuildThisFileDirectory)Microsoft.ReactNative.Uwp.CppLib.props" />
|
|
16
|
+
</ImportGroup>
|
|
17
|
+
</Project>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
Licensed under the MIT License.
|
|
5
|
+
|
|
6
|
+
This file will be consumed by ALL C++ module projects (both inside
|
|
7
|
+
and outside of this repo) that build on top of Microsoft.ReactNative.
|
|
8
|
+
Do not make any changes here unless it applies to ALL such projects.
|
|
9
|
+
-->
|
|
10
|
+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
11
|
+
<ImportGroup Condition="'$(UseFabric)' == 'true'">
|
|
12
|
+
<Import Project="$(MSBuildThisFileDirectory)Microsoft.ReactNative.Composition.CppLib.targets" />
|
|
13
|
+
</ImportGroup>
|
|
14
|
+
<ImportGroup Condition="'$(UseFabric)' != 'true'">
|
|
15
|
+
<Import Project="$(MSBuildThisFileDirectory)Microsoft.ReactNative.Uwp.CppLib.targets" />
|
|
16
|
+
</ImportGroup>
|
|
17
|
+
</Project>
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
-->
|
|
11
11
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
12
12
|
<PropertyGroup>
|
|
13
|
-
<ReactNativeWindowsVersion>0.76.0-preview.
|
|
13
|
+
<ReactNativeWindowsVersion>0.76.0-preview.4</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>76</ReactNativeWindowsMinor>
|
|
16
16
|
<ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
|
|
17
17
|
<ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
|
|
18
|
-
<ReactNativeWindowsCommitId>
|
|
18
|
+
<ReactNativeWindowsCommitId>5b950cfec87e5ce5e60f7762619f9acdd33c63d2</ReactNativeWindowsCommitId>
|
|
19
19
|
</PropertyGroup>
|
|
20
20
|
</Project>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<PropertyGroup Label="WebView2 versioning">
|
|
4
|
+
<!-- WinAppSDK 1.6+ has a dependency on Microsoft.Web.WebView2, there are a few places we need to pull in this package explicitly. -->
|
|
5
|
+
<WebView2PackageVersion>1.0.2651.64</WebView2PackageVersion>
|
|
6
|
+
</PropertyGroup>
|
|
7
|
+
</Project>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
-->
|
|
9
9
|
<!-- This value is also used by the CLI, see /packages/@react-native-windows/generate-windows -->
|
|
10
10
|
<WinUI3Version Condition="'$(WinUI3Version)'=='' AND '$(UseExperimentalWinUI3)'=='true'">1.6.240701003-experimental2</WinUI3Version>
|
|
11
|
-
<WinUI3Version Condition="'$(WinUI3Version)'==''">1.
|
|
11
|
+
<WinUI3Version Condition="'$(WinUI3Version)'==''">1.6.240923002</WinUI3Version>
|
|
12
12
|
</PropertyGroup>
|
|
13
13
|
|
|
14
14
|
<PropertyGroup Label="WinUI2x versioning">
|
package/Shared/Shared.vcxitems
CHANGED
|
@@ -232,11 +232,6 @@
|
|
|
232
232
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
233
233
|
<DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\ReactNativeAppBuilder.idl</DependentUpon>
|
|
234
234
|
<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
235
|
</ClCompile>
|
|
241
236
|
<ClCompile Include="$(MSBuildThisFileDirectory)BaseFileReaderResource.cpp" />
|
|
242
237
|
<ClCompile Include="$(MSBuildThisFileDirectory)BaseScriptStoreImpl.cpp" />
|
|
@@ -349,11 +344,6 @@
|
|
|
349
344
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
350
345
|
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\ReactNativeAppBuilder.idl</DependentUpon>
|
|
351
346
|
<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
347
|
</ClInclude>
|
|
358
348
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\DynamicReader.cpp">
|
|
359
349
|
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\IJSValueReader.idl</DependentUpon>
|
package/just-task.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-windows",
|
|
3
|
-
"version": "0.76.0-preview.
|
|
3
|
+
"version": "0.76.0-preview.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@react-native-community/cli": "15.0.0-alpha.2",
|
|
27
27
|
"@react-native-community/cli-platform-android": "15.0.0-alpha.2",
|
|
28
28
|
"@react-native-community/cli-platform-ios": "15.0.0-alpha.2",
|
|
29
|
-
"@react-native-windows/cli": "0.76.0-preview.
|
|
29
|
+
"@react-native-windows/cli": "0.76.0-preview.4",
|
|
30
30
|
"@react-native/assets": "1.0.0",
|
|
31
31
|
"@react-native/assets-registry": "0.76.0-rc.6",
|
|
32
32
|
"@react-native/codegen": "0.76.0-rc.6",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"yargs": "^17.6.2"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@react-native-windows/codegen": "0.76.0-preview.
|
|
73
|
-
"@react-native/metro-config": "0.76.0-
|
|
72
|
+
"@react-native-windows/codegen": "0.76.0-preview.2",
|
|
73
|
+
"@react-native/metro-config": "0.76.0-rc.6",
|
|
74
74
|
"@rnw-scripts/babel-react-native-config": "0.0.0",
|
|
75
75
|
"@rnw-scripts/eslint-config": "1.2.27",
|
|
76
76
|
"@rnw-scripts/jest-out-of-tree-snapshot-resolver": "^1.1.31",
|
|
@@ -80,7 +80,6 @@
|
|
|
80
80
|
"@types/node": "^18.0.0",
|
|
81
81
|
"@types/react": "^18.2.6",
|
|
82
82
|
"eslint": "^8.19.0",
|
|
83
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
84
83
|
"flow-bin": "^0.245.2",
|
|
85
84
|
"jscodeshift": "^0.14.0",
|
|
86
85
|
"just-scripts": "^1.3.3",
|
|
@@ -21,7 +21,10 @@ async function preInstall(config = {}, options = {}) {}
|
|
|
21
21
|
|
|
22
22
|
async function getFileMappings(config = {}, options = {}) {
|
|
23
23
|
const projectRoot = config?.root ?? process.cwd();
|
|
24
|
-
const {rnwPath, rnwVersion, devMode, isCanary} = templateUtils.getRnwInfo(
|
|
24
|
+
const {rnwPath, rnwVersion, devMode, isCanary} = templateUtils.getRnwInfo(
|
|
25
|
+
config,
|
|
26
|
+
options,
|
|
27
|
+
);
|
|
25
28
|
|
|
26
29
|
const projectName =
|
|
27
30
|
config?.project?.windows?.project?.projectName ?? options?.name ?? 'MyApp';
|
|
@@ -49,7 +52,9 @@ async function getFileMappings(config = {}, options = {}) {
|
|
|
49
52
|
namespaceCpp: namespaceCpp,
|
|
50
53
|
|
|
51
54
|
rnwVersion: rnwVersion,
|
|
52
|
-
rnwPathFromProjectRoot: path
|
|
55
|
+
rnwPathFromProjectRoot: path
|
|
56
|
+
.relative(projectRoot, rnwPath)
|
|
57
|
+
.replace(/\//g, '\\'),
|
|
53
58
|
|
|
54
59
|
mainComponentName,
|
|
55
60
|
|
|
@@ -67,7 +72,7 @@ async function getFileMappings(config = {}, options = {}) {
|
|
|
67
72
|
devMode,
|
|
68
73
|
|
|
69
74
|
useNuGets: !devMode, // default is to use published NuGets except in devMode, change to true here if you want to test devMode and nugets simultaneously
|
|
70
|
-
addReactNativePublicAdoFeed: isCanary,
|
|
75
|
+
addReactNativePublicAdoFeed: true || isCanary, // Temporary true for all new projects until code-signing is restored, see issue #14030
|
|
71
76
|
|
|
72
77
|
cppNugetPackages,
|
|
73
78
|
};
|
|
@@ -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,152 +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
|
-
asyncStatus;
|
|
137
|
-
assert(asyncStatus == winrt::Windows::Foundation::AsyncStatus::Completed);
|
|
138
|
-
host.InstanceSettings().UIDispatcher().Post([]() { PostQuitMessage(0); });
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// DesktopChildSiteBridge create a ContentSite that can host the RootView ContentIsland
|
|
143
|
-
auto bridge = winrt::Microsoft::UI::Content::DesktopChildSiteBridge::Create(compositor, window.Id());
|
|
144
|
-
bridge.Connect(rootView.Island());
|
|
145
|
-
bridge.ResizePolicy(winrt::Microsoft::UI::Content::ContentSizePolicy::ResizeContentToParentWindow);
|
|
146
|
-
|
|
147
|
-
rootView.ScaleFactor(scaleFactor);
|
|
148
|
-
|
|
149
|
-
// Set the intialSize of the root view
|
|
150
|
-
UpdateRootViewSizeToAppWindow(rootView, window);
|
|
151
|
-
|
|
152
|
-
bridge.Show();
|
|
153
|
-
|
|
154
|
-
// Run the main application event loop
|
|
155
|
-
dispatcherQueueController.DispatcherQueue().RunEventLoop();
|
|
156
|
-
|
|
157
|
-
// Rundown the DispatcherQueue. This drains the queue and raises events to let components
|
|
158
|
-
// know the message loop has finished.
|
|
159
|
-
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});
|
|
160
75
|
|
|
161
|
-
|
|
162
|
-
|
|
76
|
+
// Get the ReactViewOptions so we can set the initial RN component to load
|
|
77
|
+
auto viewOptions{reactNativeWin32App.ReactViewOptions()};
|
|
78
|
+
viewOptions.ComponentName(L"{{ mainComponentName }}");
|
|
163
79
|
|
|
164
|
-
//
|
|
165
|
-
|
|
166
|
-
compositor = nullptr;
|
|
80
|
+
// Start the app
|
|
81
|
+
reactNativeWin32App.Start();
|
|
167
82
|
}
|
|
@@ -76,7 +76,10 @@ async function getFileMappings(config = {}, options = {}) {
|
|
|
76
76
|
);
|
|
77
77
|
|
|
78
78
|
const projectRoot = libConfig.root ?? process.cwd();
|
|
79
|
-
const {rnwPath, rnwVersion, devMode, isCanary} = templateUtils.getRnwInfo(
|
|
79
|
+
const {rnwPath, rnwVersion, devMode, isCanary} = templateUtils.getRnwInfo(
|
|
80
|
+
libConfig,
|
|
81
|
+
libOptions,
|
|
82
|
+
);
|
|
80
83
|
|
|
81
84
|
const projectName =
|
|
82
85
|
libConfig?.project?.windows?.projects[0]?.projectName ??
|
|
@@ -102,7 +105,9 @@ async function getFileMappings(config = {}, options = {}) {
|
|
|
102
105
|
namespaceCpp: namespaceCpp,
|
|
103
106
|
|
|
104
107
|
rnwVersion: rnwVersion,
|
|
105
|
-
rnwPathFromProjectRoot: path
|
|
108
|
+
rnwPathFromProjectRoot: path
|
|
109
|
+
.relative(projectRoot, rnwPath)
|
|
110
|
+
.replace(/\//g, '\\'),
|
|
106
111
|
|
|
107
112
|
// Visual Studio is very picky about the casing of the guids for projects, project references and the solution
|
|
108
113
|
// https://www.bing.com/search?q=visual+studio+project+guid+casing&cvid=311a5ad7f9fc41089507b24600d23ee7&FORM=ANAB01&PC=U531
|
|
@@ -115,7 +120,7 @@ async function getFileMappings(config = {}, options = {}) {
|
|
|
115
120
|
devMode,
|
|
116
121
|
|
|
117
122
|
useNuGets: !devMode, // default is to use published NuGets except in devMode, change to true here if you want to test devMode and nugets simultaneously
|
|
118
|
-
addReactNativePublicAdoFeed: isCanary,
|
|
123
|
+
addReactNativePublicAdoFeed: true || isCanary, // Temporary true for all new projects until code-signing is restored, see issue #14030
|
|
119
124
|
|
|
120
125
|
cppNugetPackages,
|
|
121
126
|
};
|