react-native-windows 0.76.0-preview.2 → 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/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Text/Text.windows.js +13 -9
- package/Libraries/Utilities/Platform.windows.js +4 -4
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +12 -0
- package/Microsoft.ReactNative/Fabric/ComponentView.h +3 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +66 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +8 -2
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +24 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +8 -3
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +11 -0
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextDrawing.cpp +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/TextDrawing.h +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +12 -4
- package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +338 -0
- package/Microsoft.ReactNative/Fabric/Composition/TooltipService.h +66 -0
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +8 -0
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +1 -0
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +3 -0
- package/Microsoft.ReactNative/Fabric/ReactTaggedView.h +4 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.cpp +5 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.h +1 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +1 -1
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -1
- package/Microsoft.ReactNative/ReactCoreInjection.h +0 -1
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +15 -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 +3 -10
- package/Shared/Shared.vcxitems.filters +1 -0
- package/just-task.js +1 -1
- package/package.json +15 -16
- 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
package/Shared/Shared.vcxitems
CHANGED
|
@@ -150,6 +150,9 @@
|
|
|
150
150
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\TextDrawing.cpp">
|
|
151
151
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
152
152
|
</ClCompile>
|
|
153
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\TooltipService.cpp">
|
|
154
|
+
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
155
|
+
</ClCompile>
|
|
153
156
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\UiaHelpers.cpp">
|
|
154
157
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
155
158
|
</ClCompile>
|
|
@@ -229,11 +232,6 @@
|
|
|
229
232
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
230
233
|
<DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\ReactNativeAppBuilder.idl</DependentUpon>
|
|
231
234
|
<SubType>Code</SubType>
|
|
232
|
-
</ClCompile>
|
|
233
|
-
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\ReactInstanceSettingsBuilder.cpp">
|
|
234
|
-
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
235
|
-
<DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\ReactNativeAppBuilder.idl</DependentUpon>
|
|
236
|
-
<SubType>Code</SubType>
|
|
237
235
|
</ClCompile>
|
|
238
236
|
<ClCompile Include="$(MSBuildThisFileDirectory)BaseFileReaderResource.cpp" />
|
|
239
237
|
<ClCompile Include="$(MSBuildThisFileDirectory)BaseScriptStoreImpl.cpp" />
|
|
@@ -346,11 +344,6 @@
|
|
|
346
344
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
347
345
|
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\ReactNativeAppBuilder.idl</DependentUpon>
|
|
348
346
|
<SubType>Code</SubType>
|
|
349
|
-
</ClInclude>
|
|
350
|
-
<ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\ReactInstanceSettingsBuilder.h">
|
|
351
|
-
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
352
|
-
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\ReactNativeAppBuilder.idl</DependentUpon>
|
|
353
|
-
<SubType>Code</SubType>
|
|
354
347
|
</ClInclude>
|
|
355
348
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\DynamicReader.cpp">
|
|
356
349
|
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\IJSValueReader.idl</DependentUpon>
|
|
@@ -333,6 +333,7 @@
|
|
|
333
333
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\RuntimeTargetConsole.cpp" />
|
|
334
334
|
<ClCompile Include="$(MSBuildThisFileDirectory)Networking\NetworkPropertyIds.cpp" />
|
|
335
335
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiEventEmitter.cpp" />
|
|
336
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\TooltipService.cpp" />
|
|
336
337
|
</ItemGroup>
|
|
337
338
|
<ItemGroup>
|
|
338
339
|
<Filter Include="Source Files">
|
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,15 +26,15 @@
|
|
|
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
|
-
"@react-native/assets-registry": "0.76.0-rc.
|
|
32
|
-
"@react-native/codegen": "0.76.0-rc.
|
|
33
|
-
"@react-native/community-cli-plugin": "0.76.0-rc.
|
|
34
|
-
"@react-native/gradle-plugin": "0.76.0-rc.
|
|
35
|
-
"@react-native/js-polyfills": "0.76.0-rc.
|
|
36
|
-
"@react-native/normalize-colors": "0.76.0-rc.
|
|
37
|
-
"@react-native/virtualized-lists": "0.76.0-rc.
|
|
31
|
+
"@react-native/assets-registry": "0.76.0-rc.6",
|
|
32
|
+
"@react-native/codegen": "0.76.0-rc.6",
|
|
33
|
+
"@react-native/community-cli-plugin": "0.76.0-rc.6",
|
|
34
|
+
"@react-native/gradle-plugin": "0.76.0-rc.6",
|
|
35
|
+
"@react-native/js-polyfills": "0.76.0-rc.6",
|
|
36
|
+
"@react-native/normalize-colors": "0.76.0-rc.6",
|
|
37
|
+
"@react-native/virtualized-lists": "0.76.0-rc.6",
|
|
38
38
|
"abort-controller": "^3.0.0",
|
|
39
39
|
"anser": "^1.4.9",
|
|
40
40
|
"ansi-regex": "^5.0.0",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"jest-environment-node": "^29.6.3",
|
|
51
51
|
"jsc-android": "^250231.0.0",
|
|
52
52
|
"memoize-one": "^5.0.0",
|
|
53
|
-
"metro-runtime": "^0.81.0
|
|
54
|
-
"metro-source-map": "^0.81.0
|
|
53
|
+
"metro-runtime": "^0.81.0",
|
|
54
|
+
"metro-source-map": "^0.81.0",
|
|
55
55
|
"mkdirp": "^0.5.1",
|
|
56
56
|
"nullthrows": "^1.1.1",
|
|
57
57
|
"pretty-format": "^29.7.0",
|
|
@@ -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,13 +80,12 @@
|
|
|
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",
|
|
87
86
|
"prettier": "2.8.8",
|
|
88
87
|
"react": "18.3.1",
|
|
89
|
-
"react-native": "0.76.0-rc.
|
|
88
|
+
"react-native": "0.76.0-rc.6",
|
|
90
89
|
"react-native-platform-override": "^1.9.46",
|
|
91
90
|
"react-refresh": "^0.14.0",
|
|
92
91
|
"typescript": "5.0.4"
|
|
@@ -94,7 +93,7 @@
|
|
|
94
93
|
"peerDependencies": {
|
|
95
94
|
"@types/react": "^18.2.6",
|
|
96
95
|
"react": "^18.2.0",
|
|
97
|
-
"react-native": "0.76.0-rc.
|
|
96
|
+
"react-native": "0.76.0-rc.6"
|
|
98
97
|
},
|
|
99
98
|
"beachball": {
|
|
100
99
|
"defaultNpmTag": "preview",
|
|
@@ -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
|
};
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
67
67
|
</ImportGroup>
|
|
68
68
|
<ImportGroup Label="ReactNativeWindowsPropertySheets">
|
|
69
|
-
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.
|
|
69
|
+
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.props" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.props')" />
|
|
70
70
|
</ImportGroup>
|
|
71
71
|
<ItemDefinitionGroup>
|
|
72
72
|
<ClCompile>
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
</ItemGroup>
|
|
132
132
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
133
133
|
<ImportGroup Label="ReactNativeWindowsTargets">
|
|
134
|
-
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.
|
|
134
|
+
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.targets" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.targets')" />
|
|
135
135
|
</ImportGroup>
|
|
136
136
|
<ItemGroup>
|
|
137
137
|
{{#cppNugetPackages}}
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
<PropertyGroup>
|
|
143
143
|
<ErrorText>This project references targets in your node_modules\react-native-windows folder. The missing file is {0}.</ErrorText>
|
|
144
144
|
</PropertyGroup>
|
|
145
|
-
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.
|
|
146
|
-
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.
|
|
145
|
+
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.props'))" />
|
|
146
|
+
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.CppLib.targets'))" />
|
|
147
147
|
</Target>
|
|
148
148
|
</Project>
|
|
@@ -112,9 +112,8 @@ async function runNpmInstall(config = {}, options = {}) {
|
|
|
112
112
|
|
|
113
113
|
async function updateProjectPackageJson(config = {}, options = {}, props = {}) {
|
|
114
114
|
const projectRoot = config?.root ?? process.cwd();
|
|
115
|
-
const projectPackage =
|
|
116
|
-
projectRoot
|
|
117
|
-
);
|
|
115
|
+
const projectPackage =
|
|
116
|
+
await pkgUtils.WritableNpmPackage.fromPath(projectRoot);
|
|
118
117
|
|
|
119
118
|
if (!projectPackage) {
|
|
120
119
|
throw new Error(
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
#include "pch.h"
|
|
2
|
-
#include "ReactInstanceSettingsBuilder.h"
|
|
3
|
-
#include "ReactInstanceSettingsBuilder.g.cpp"
|
|
4
|
-
#include "ReactInstanceSettings.h"
|
|
5
|
-
|
|
6
|
-
namespace winrt::ReactNative {
|
|
7
|
-
using namespace winrt::Microsoft::ReactNative;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
namespace winrt::UI {
|
|
11
|
-
using namespace winrt::Microsoft::UI;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
namespace winrt::Microsoft::ReactNative::implementation {
|
|
15
|
-
ReactInstanceSettingsBuilder::ReactInstanceSettingsBuilder() {
|
|
16
|
-
m_reactInstanceSettings = winrt::make<winrt::ReactNative::implementation::ReactInstanceSettings>();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
winrt::ReactNative::ReactInstanceSettings ReactInstanceSettingsBuilder::ReactInstanceSettings() {
|
|
20
|
-
return m_reactInstanceSettings;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
winrt::ReactNative::ReactInstanceSettingsBuilder ReactInstanceSettingsBuilder::UseDirectDebugger(bool const &state) {
|
|
24
|
-
m_reactInstanceSettings.UseDirectDebugger(state);
|
|
25
|
-
|
|
26
|
-
return *this;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
winrt::ReactNative::ReactInstanceSettingsBuilder ReactInstanceSettingsBuilder::UseDeveloperSupport(bool const &state) {
|
|
30
|
-
m_reactInstanceSettings.UseDeveloperSupport(state);
|
|
31
|
-
|
|
32
|
-
return *this;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
winrt::ReactNative::ReactInstanceSettingsBuilder ReactInstanceSettingsBuilder::BundleRootPath(hstring const &path) {
|
|
36
|
-
m_reactInstanceSettings.BundleRootPath(std::wstring(L"file://").append(path.c_str()).append(L"\\Bundle\\").c_str());
|
|
37
|
-
|
|
38
|
-
return *this;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
winrt::ReactNative::ReactInstanceSettingsBuilder ReactInstanceSettingsBuilder::DebugBundlePath(hstring const &path) {
|
|
42
|
-
m_reactInstanceSettings.DebugBundlePath(path.c_str());
|
|
43
|
-
|
|
44
|
-
return *this;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
winrt::ReactNative::ReactInstanceSettingsBuilder ReactInstanceSettingsBuilder::JavaScriptBundleFile(
|
|
48
|
-
hstring const &file) {
|
|
49
|
-
m_reactInstanceSettings.JavaScriptBundleFile(file.c_str());
|
|
50
|
-
|
|
51
|
-
return *this;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
winrt::ReactNative::ReactInstanceSettingsBuilder ReactInstanceSettingsBuilder::UseFastRefresh(bool const &state) {
|
|
55
|
-
m_reactInstanceSettings.UseFastRefresh(state);
|
|
56
|
-
|
|
57
|
-
return *this;
|
|
58
|
-
}
|
|
59
|
-
} // namespace winrt::Microsoft::ReactNative::implementation
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
#include "ReactInstanceSettingsBuilder.g.h"
|
|
3
|
-
|
|
4
|
-
namespace winrt::Microsoft::ReactNative::implementation {
|
|
5
|
-
struct ReactInstanceSettingsBuilder : ReactInstanceSettingsBuilderT<ReactInstanceSettingsBuilder> {
|
|
6
|
-
ReactInstanceSettingsBuilder();
|
|
7
|
-
|
|
8
|
-
winrt::Microsoft::ReactNative::ReactInstanceSettings ReactInstanceSettings();
|
|
9
|
-
winrt::Microsoft::ReactNative::ReactInstanceSettingsBuilder UseDirectDebugger(bool const &state);
|
|
10
|
-
winrt::Microsoft::ReactNative::ReactInstanceSettingsBuilder UseDeveloperSupport(bool const &state);
|
|
11
|
-
winrt::Microsoft::ReactNative::ReactInstanceSettingsBuilder BundleRootPath(hstring const &path);
|
|
12
|
-
winrt::Microsoft::ReactNative::ReactInstanceSettingsBuilder DebugBundlePath(hstring const &path);
|
|
13
|
-
winrt::Microsoft::ReactNative::ReactInstanceSettingsBuilder JavaScriptBundleFile(hstring const &file);
|
|
14
|
-
winrt::Microsoft::ReactNative::ReactInstanceSettingsBuilder UseFastRefresh(bool const &state);
|
|
15
|
-
|
|
16
|
-
private:
|
|
17
|
-
winrt::Microsoft::ReactNative::ReactInstanceSettings m_reactInstanceSettings{nullptr};
|
|
18
|
-
};
|
|
19
|
-
} // namespace winrt::Microsoft::ReactNative::implementation
|
|
20
|
-
namespace winrt::Microsoft::ReactNative::factory_implementation {
|
|
21
|
-
struct ReactInstanceSettingsBuilder
|
|
22
|
-
: ReactInstanceSettingsBuilderT<ReactInstanceSettingsBuilder, implementation::ReactInstanceSettingsBuilder> {};
|
|
23
|
-
} // namespace winrt::Microsoft::ReactNative::factory_implementation
|