-
-
Notifications
You must be signed in to change notification settings - Fork 641
feat(windows): support react-native-windows new architecture #3708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PHILLIPS71
wants to merge
26
commits into
software-mansion:main
Choose a base branch
from
PHILLIPS71:feat/windows-new-arch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
0e77458
feat: react-native-windows v0.81.4 initialisation
PHILLIPS71 2f0e529
chore: add Windows metro exclusions for react-native-windows
PHILLIPS71 5f3d94f
chore: remove react-native-restart as it does not support the new arch
PHILLIPS71 3112e51
refactor: conditionally render react-native-gesture-handler as it doe…
PHILLIPS71 159e905
fix: getViewManagerConfig is no longer supported
PHILLIPS71 c80eb38
chore: set publisher in windows package manifest
PHILLIPS71 a9f40cf
chore: react-native-windows requires node >=22
PHILLIPS71 e4af86e
refactor: migrate namespaces from Windows::UI::* to Microsoft::UI::*
PHILLIPS71 c15e2ab
refactor(windows): migrate ViewManager implementations to Fabric new …
PHILLIPS71 2c58c52
feat: implement activityState visibility control for fabric screens
PHILLIPS71 9a9f1d0
style: reformat + cleanup
PHILLIPS71 ea7a249
refactor: remove redundant RNS prefix in register calls
PHILLIPS71 a05ba22
chore: ignore nuget files
PHILLIPS71 52123f1
chore: remove old windows sln files
PHILLIPS71 34e76d1
fix: app crashes on app start
PHILLIPS71 134d57e
docs: improve code comments + README
PHILLIPS71 464450f
Merge branch 'main' into feat/windows-new-arch
PHILLIPS71 12c3dac
chore: remove paper example as in #3710
PHILLIPS71 645d48c
chore: remove react-native-restart not supported in new arch
PHILLIPS71 413df0d
refactor: pr comments
PHILLIPS71 80fe99d
refactor: pr comments
PHILLIPS71 d1fa320
fix: AdditionalDependenices typo
PHILLIPS71 e09773b
fix: revert react-native-restart removal + add interop file for windows
PHILLIPS71 87f8001
chore: revert tvos example podlock react-native-restart changes
PHILLIPS71 1344ea8
Merge branch 'main' into feat/windows-new-arch
PHILLIPS71 fa40db6
chore: update react-native-windows to v0.82.3
PHILLIPS71 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <configuration> | ||
| <packageSources> | ||
| <clear /> | ||
| <add key="react-native" value="https://pkgs.dev.azure.com/ms/react-native/_packaging/react-native-public/nuget/v3/index.json" /> | ||
| <add key="Nuget.org" value="https://api.nuget.org/v3/index.json" /> | ||
| </packageSources> | ||
| <disabledPackageSources> | ||
| <clear /> | ||
| </disabledPackageSources> | ||
| </configuration> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { GestureHandlerRootView } from 'react-native-gesture-handler'; | ||
| export { GestureDetectorProvider } from 'react-native-screens/gesture-handler'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import React from 'react'; | ||
| import type { StyleProp, ViewStyle } from 'react-native'; | ||
|
|
||
| // react-native-gesture-handler is not supported on Windows. | ||
| // See https://github.com/software-mansion/react-native-gesture-handler/issues/3723 | ||
| // Metro resolves this file instead of gesture-handler-interop.ts when bundling for Windows, | ||
| // so neither gesture-handler package is included in the Windows bundle. | ||
|
|
||
| const GestureHandlerRootView = ({ | ||
| children, | ||
| }: Readonly<{ | ||
| style?: StyleProp<ViewStyle>; | ||
| children: React.ReactNode; | ||
| }>): React.JSX.Element => <>{children}</>; | ||
|
|
||
| const GestureDetectorProvider = ({ | ||
| children, | ||
| }: Readonly<{ | ||
| children: React.ReactNode; | ||
| }>): React.JSX.Element => <>{children}</>; | ||
|
|
||
| export { GestureHandlerRootView, GestureDetectorProvider }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default } from 'react-native-restart'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // react-native-restart is not supported on Windows. | ||
| const RNRestart = { | ||
| restart: () => {}, | ||
| Restart: () => {}, | ||
| }; | ||
|
|
||
| export default RNRestart; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
|
||
| <PropertyGroup Label="Microsoft.ReactNative Experimental Features"> | ||
| <!-- | ||
| Required for building a New Architecture project. | ||
|
|
||
| Library projects can change this value to test against Old and New | ||
| Architectures when building the library project's local sln file. | ||
|
|
||
| Otherwise this value will be decided by the consuming RNW app. | ||
|
|
||
| See https://microsoft.github.io/react-native-windows/docs/new-architecture | ||
| --> | ||
| <RnwNewArch>true</RnwNewArch> | ||
|
|
||
| <!-- | ||
| Changes compilation to assume use of Microsoft.ReactNative NuGet packages | ||
| instead of building the framework from source. Defaults to true. | ||
|
|
||
| This is set during library project creation and is used when building | ||
| the library project's local sln file. | ||
|
|
||
| Otherwise this value will be decided by the consuming RNW app. | ||
|
|
||
| See https://microsoft.github.io/react-native-windows/docs/nuget | ||
| --> | ||
| <UseExperimentalNuget>true</UseExperimentalNuget> | ||
|
|
||
| <ReactExperimentalFeaturesSet>true</ReactExperimentalFeaturesSet> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio Version 17 | ||
| VisualStudioVersion = 17.3.32929.385 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RNScreens", "RNScreens\RNScreens.vcxproj", "{D638F49E-29D2-4699-AC52-FACD82FA7138}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|x64 = Debug|x64 | ||
| Debug|x86 = Debug|x86 | ||
| Debug|ARM64 = Debug|ARM64 | ||
| Release|x64 = Release|x64 | ||
| Release|x86 = Release|x86 | ||
| Release|ARM64 = Release|ARM64 | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Debug|x64.ActiveCfg = Debug|x64 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Debug|x64.Build.0 = Debug|x64 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Debug|x64.Deploy.0 = Debug|x64 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Debug|x86.ActiveCfg = Debug|Win32 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Debug|x86.Build.0 = Debug|Win32 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Debug|x86.Deploy.0 = Debug|Win32 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Debug|ARM64.ActiveCfg = Debug|ARM64 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Debug|ARM64.Build.0 = Debug|ARM64 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Debug|ARM64.Deploy.0 = Debug|ARM64 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Release|x64.ActiveCfg = Release|x64 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Release|x64.Build.0 = Release|x64 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Release|x64.Deploy.0 = Release|x64 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Release|x86.ActiveCfg = Release|Win32 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Release|x86.Build.0 = Release|Win32 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Release|x86.Deploy.0 = Release|Win32 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Release|ARM64.ActiveCfg = Release|ARM64 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Release|ARM64.Build.0 = Release|ARM64 | ||
| {D638F49E-29D2-4699-AC52-FACD82FA7138}.Release|ARM64.Deploy.0 = Release|ARM64 | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {D43FAD39-F619-437D-BB40-04A3982ACB6A} | ||
| EndGlobalSection | ||
| EndGlobal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| #pragma once | ||
| #include "pch.h" | ||
|
|
||
| namespace winrt::RNScreens::implementation { | ||
| // Placeholder IComponentProps for Fabric components that have no custom native | ||
| // props on Windows yet. Satisfies the SetCreateProps contract so the framework | ||
| // can deliver base ViewProps (layout, style) without crashing. | ||
| // | ||
| // REACT_STRUCT is omitted - that macro generates ReadProp dispatch metadata, | ||
| // which is only needed when SetProp delegates to ReadProp. Here SetProp is a | ||
| // deliberate no-op, so the metadata would be dead weight. | ||
| // | ||
| // TODO: replace with a component-specific props struct for each stub as native | ||
| // implementations are developed. | ||
| struct BaseProps | ||
| : implements<BaseProps, Microsoft::ReactNative::IComponentProps> { | ||
| BaseProps( | ||
| Microsoft::ReactNative::ViewProps /*props*/, | ||
| const Microsoft::ReactNative::IComponentProps & /*cloneFrom*/) noexcept { | ||
| } | ||
|
|
||
| void SetProp( | ||
| uint32_t /*hash*/, | ||
| hstring /*propName*/, | ||
| Microsoft::ReactNative::IJSValueReader /*value*/) noexcept { | ||
| } | ||
|
PHILLIPS71 marked this conversation as resolved.
|
||
| }; | ||
|
|
||
| // Registers a Fabric component that requires no per-instance state, custom | ||
| // props, events, or visual overrides. Satisfies two required registration | ||
| // contracts: | ||
| // | ||
| // SetCreateProps - required so the framework can construct a props object | ||
| // when base ViewProps (layout, style) are delivered. Without it, the | ||
| // framework crashes on the first prop update. | ||
| // | ||
| // SetViewComponentViewInitializer - required even when no per-instance | ||
| // initialization is needed; the framework asserts on mount without it. | ||
| // | ||
| // To graduate a component from stub to real implementation, replace the | ||
| // RegisterStubComponent call in its .cpp with a full AddViewComponent block | ||
| // using a concrete props struct and whatever subset of | ||
| // SetUpdatePropsHandler / SetUpdateEventEmitterHandler / SetCreateVisualHandler | ||
| // the component needs. See Screen.cpp for the established pattern. | ||
| inline void RegisterStubComponent( | ||
| const Microsoft::ReactNative::IReactPackageBuilderFabric &fabricBuilder, | ||
| const hstring &componentName) noexcept { | ||
| using namespace Microsoft::ReactNative; | ||
| fabricBuilder.AddViewComponent( | ||
| componentName, | ||
| [](const IReactViewComponentBuilder &builder) noexcept { | ||
| builder.SetCreateProps( | ||
| []( | ||
| ViewProps props, | ||
| const IComponentProps &cloneFrom) noexcept -> IComponentProps { | ||
| return winrt::make<BaseProps>(props, cloneFrom); | ||
| }); | ||
| builder | ||
| .as<Composition::IReactCompositionViewComponentBuilder>() | ||
| .SetViewComponentViewInitializer( | ||
| [](const ComponentView &) noexcept { | ||
| }); | ||
| }); | ||
| } | ||
| } // namespace winrt::RNScreens::implementation | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #include "pch.h" | ||
| #include "ModalScreen.h" | ||
| #include "Screen.h" | ||
|
|
||
| namespace winrt::RNScreens::implementation { | ||
| using namespace winrt::Microsoft::ReactNative; | ||
|
|
||
| // RNSModalScreen shares identical native behavior with RNSScreen on Windows. | ||
| // Both components are containers whose screen-level semantics (presentation | ||
| // style, animation) are managed by JS; the native side only needs to forward | ||
| // lifecycle events. | ||
| void RegisterModalScreen( | ||
| const IReactPackageBuilderFabric &fabricBuilder) noexcept { | ||
| RegisterScreenLike(fabricBuilder, L"RNSModalScreen"); | ||
| } | ||
| } // namespace winrt::RNScreens::implementation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #pragma once | ||
| #include "pch.h" | ||
|
|
||
| namespace winrt::RNScreens::implementation { | ||
| // Delegates to RegisterScreenLike; see Screen.h for the shared behavior. | ||
| void RegisterModalScreen( | ||
| const Microsoft::ReactNative::IReactPackageBuilderFabric &fabricBuilder) | ||
| noexcept; | ||
| } // namespace winrt::RNScreens::implementation |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.