-
Notifications
You must be signed in to change notification settings - Fork 150
Support Windows New Arch using TurboModule #227
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
anupriya13
wants to merge
12
commits into
christopherdro:master
Choose a base branch
from
anupriya13:user/anuverma/windowsNewArch
base: master
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
12 commits
Select commit
Hold shift + click to select a range
d2c6ba5
Add support for Windows new arch
anupriya13 557436e
autolink example
anupriya13 efec423
update metro
anupriya13 b58b517
Update yarn.lock
anupriya13 af65d20
update react version
anupriya13 b833d75
Update yarn.lock
anupriya13 529c437
Update App.js
anupriya13 f5ade7a
try adding some code for print :/
anupriya13 03bae4d
use fire and forget
anupriya13 a705883
add error handling
anupriya13 b798d23
fix multiple promise resolution/rejections
anupriya13 8ec008c
Update package.json
anupriya13 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// @flow | ||
import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport'; | ||
import { TurboModuleRegistry } from 'react-native'; | ||
|
||
export type RNPrintOptions = { | ||
html?: string, | ||
filePath?: string, | ||
isLandscape?: boolean, | ||
jobName: string, | ||
}; | ||
|
||
export interface Spec extends TurboModule { | ||
+print: (options: RNPrintOptions) => Promise<Object>; | ||
} | ||
|
||
export default (TurboModuleRegistry.get<Spec>('RNPrint'): ?Spec); |
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,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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
presets: ['module:metro-react-native-babel-preset'], | ||
presets: ['module:@react-native/babel-preset'], | ||
}; |
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,3 @@ | ||
const config = {}; | ||
|
||
module.exports = require('@rnx-kit/jest-preset')('windows', config); |
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 |
---|---|---|
@@ -1,29 +1,56 @@ | ||
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config'); | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const exclusionList = require('metro-config/src/defaults/exclusionList'); | ||
|
||
const rnwPath = fs.realpathSync( | ||
path.resolve(require.resolve('react-native-windows/package.json'), '..'), | ||
); | ||
|
||
// | ||
|
||
/** | ||
* Metro configuration for React Native | ||
* https://github.com/facebook/react-native | ||
* Metro configuration | ||
* https://facebook.github.io/metro/docs/configuration | ||
* | ||
* @format | ||
* @type {import('metro-config').MetroConfig} | ||
*/ | ||
const path = require('path'); | ||
const blacklist = require('metro-config/src/defaults/blacklist'); | ||
|
||
module.exports = { | ||
const config = { | ||
// | ||
resolver: { | ||
blacklistRE: blacklist([ | ||
// This stops "react-native run-windows" from causing the metro server to crash if its already running | ||
blockList: exclusionList([ | ||
// This stops "npx @react-native-community/cli run-windows" from causing the metro server to crash if its already running | ||
new RegExp( | ||
`${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`, | ||
), | ||
// This prevents "react-native run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip | ||
// This prevents "npx @react-native-community/cli run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip or other files produced by msbuild | ||
new RegExp(`${rnwPath}/build/.*`), | ||
new RegExp(`${rnwPath}/target/.*`), | ||
/.*\.ProjectImports\.zip/, | ||
]), | ||
// | ||
extraNodeModules: { | ||
'react-native-print': path.resolve( | ||
__dirname, | ||
'../' | ||
), } | ||
}, | ||
watchFolders:[ | ||
// This allows us to use the local version of react-native-windows | ||
rnwPath, | ||
// This allows us to use the local version of react-native-print | ||
path.resolve(__dirname, '../'), | ||
], | ||
transformer: { | ||
getTransformOptions: async () => ({ | ||
transform: { | ||
experimentalImportSupport: false, | ||
inlineRequires: false, | ||
inlineRequires: true, | ||
}, | ||
}), | ||
}, | ||
}; | ||
|
||
module.exports = mergeConfig(getDefaultConfig(__dirname), config); |
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,27 @@ | ||
<?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. | ||
|
||
App projects should not change this value. | ||
|
||
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 app project creation and should not be changed. | ||
|
||
See https://microsoft.github.io/react-native-windows/docs/nuget | ||
--> | ||
<UseExperimentalNuget>true</UseExperimentalNuget> | ||
|
||
<ReactExperimentalFeaturesSet>true</ReactExperimentalFeaturesSet> | ||
</PropertyGroup> | ||
|
||
</Project> |
Binary file added
BIN
+1.4 KB
example/windows/RNPrintExample.Package/Images/LockScreenLogo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.52 KB
example/windows/RNPrintExample.Package/Images/SplashScreen.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.87 KB
example/windows/RNPrintExample.Package/Images/Square150x150Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.61 KB
example/windows/RNPrintExample.Package/Images/Square44x44Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.23 KB
...NPrintExample.Package/Images/Square44x44Logo.targetsize-24_altform-unplated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.13 KB
example/windows/RNPrintExample.Package/Images/Wide310x150Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions
49
example/windows/RNPrintExample.Package/Package.appxmanifest
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,49 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<Package | ||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" | ||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" | ||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" | ||
IgnorableNamespaces="uap rescap"> | ||
|
||
<Identity | ||
Name="RNPrintExample" | ||
Publisher="CN=anuverma" | ||
Version="1.0.0.0" /> | ||
|
||
<Properties> | ||
<DisplayName>RNPrintExample</DisplayName> | ||
<PublisherDisplayName>anuverma</PublisherDisplayName> | ||
<Logo>Images\StoreLogo.png</Logo> | ||
</Properties> | ||
|
||
<Dependencies> | ||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" /> | ||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.17763.0" /> | ||
</Dependencies> | ||
|
||
<Resources> | ||
<Resource Language="x-generate"/> | ||
</Resources> | ||
|
||
<Applications> | ||
<Application Id="App" | ||
Executable="$targetnametoken$.exe" | ||
EntryPoint="$targetentrypoint$"> | ||
<uap:VisualElements | ||
DisplayName="RNPrintExample" | ||
Description="RNPrintExample" | ||
BackgroundColor="transparent" | ||
Square150x150Logo="Images\Square150x150Logo.png" | ||
Square44x44Logo="Images\Square44x44Logo.png"> | ||
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" /> | ||
<uap:SplashScreen Image="Images\SplashScreen.png" /> | ||
</uap:VisualElements> | ||
</Application> | ||
</Applications> | ||
|
||
<Capabilities> | ||
<Capability Name="internetClient" /> | ||
<rescap:Capability Name="runFullTrust" /> | ||
</Capabilities> | ||
</Package> |
78 changes: 78 additions & 0 deletions
78
example/windows/RNPrintExample.Package/RNPrintExample.Package.wapproj
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,78 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(SolutionDir)\ExperimentalFeatures.props" Condition="Exists('$(SolutionDir)\ExperimentalFeatures.props')" /> | ||
<PropertyGroup> | ||
<ProjectGuid>{fb783acc-1363-4523-9535-954521af5b55}</ProjectGuid> | ||
<DefaultLanguage>en-US</DefaultLanguage> | ||
<EntryPointProjectUniqueName>..\RNPrintExample\RNPrintExample.vcxproj</EntryPointProjectUniqueName> | ||
<DebuggerType>NativeOnly</DebuggerType> | ||
<BackgroundTaskDebugEngines>NativeOnly</BackgroundTaskDebugEngines> | ||
</PropertyGroup> | ||
<PropertyGroup Label="ReactNativeWindowsProps"> | ||
<ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir> | ||
</PropertyGroup> | ||
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.WindowsSdk.Default.props" /> | ||
<PropertyGroup> | ||
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath> | ||
</PropertyGroup> | ||
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" /> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|x86"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x86</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x86"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x86</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|ARM64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>ARM64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|ARM64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>ARM64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<ImportGroup Label="ReactNativeWindowsPropertySheets"> | ||
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.props" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.props')" /> | ||
</ImportGroup> | ||
<ItemGroup> | ||
<AppxManifest Include="Package.appxmanifest"> | ||
<SubType>Designer</SubType> | ||
</AppxManifest> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="Images\SplashScreen.scale-200.png" /> | ||
<Content Include="Images\LockScreenLogo.scale-200.png" /> | ||
<Content Include="Images\Square150x150Logo.scale-200.png" /> | ||
<Content Include="Images\Square44x44Logo.scale-200.png" /> | ||
<Content Include="Images\Square44x44Logo.targetsize-24_altform-unplated.png" /> | ||
<Content Include="Images\StoreLogo.png" /> | ||
<Content Include="Images\Wide310x150Logo.scale-200.png" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\RNPrintExample\RNPrintExample.vcxproj"> | ||
<SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" /> | ||
<ImportGroup Label="ReactNativeWindowsTargets"> | ||
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.targets" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.targets')" /> | ||
</ImportGroup> | ||
<Target Name="EnsureReactNativeWindowsTargets" BeforeTargets="PrepareForBuild"> | ||
<PropertyGroup> | ||
<ErrorText>This project references targets in your node_modules\react-native-windows folder that are missing. The missing file is {0}.</ErrorText> | ||
</PropertyGroup> | ||
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.props'))" /> | ||
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Composition.Package.targets'))" /> | ||
</Target> | ||
</Project> |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The index file should be modified to be:
export default RNPrint from './codegenSpecs/NativeRNPrint';
Or something like that.