Skip to content

Commit

Permalink
feat: add patch package
Browse files Browse the repository at this point in the history
  • Loading branch information
okwasniewski committed Nov 27, 2023
1 parent 54ec59a commit a3575ec
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Header = (): Node => {
]}>
Welcome to
{'\n'}
React Native
React Native visionOS
</Text>
</ImageBackground>
);
Expand All @@ -65,7 +65,6 @@ const styles = StyleSheet.create({
* source image's size.
*/
marginLeft: -128,
marginBottom: -192,
},
text: {
fontSize: 40,
Expand Down
24 changes: 24 additions & 0 deletions packages/react-native/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<h1 align="center">
<a href="https://reactnative.dev/">
React Native Vision OS
</a>
</h1>

<p align="center">
<strong>Learn once, write anywhere:</strong><br>
Build spatial apps with React.
</p>

React Native Vision OS allows you to write visionOS with full support for platform SDK. This is a full fork of the main repository with changes needed to support visionOS.

This project is still at an early stage of development and is not ready for production use.

## Contributing

1. Download latest Xcode beta [here](https://developer.apple.com/xcode/).
2. Install visionOS Simulator runtime.
3. (Optional) Using Hermes - Install latest version of CMake (3.28) from `main` branch:
```sh
brew install cmake --HEAD
```
4. Follow the same steps as for running iOS defined in [packages/rn-tester/README.md](./packages/rn-tester/README.md)
1 change: 1 addition & 0 deletions packages/react-native/React/Base/RCTBundleURLProvider.mm
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot
[[NSURLQueryItem alloc] initWithName:@"platform" value:RCTPlatformName],
[[NSURLQueryItem alloc] initWithName:@"dev" value:enableDev ? @"true" : @"false"],
[[NSURLQueryItem alloc] initWithName:@"lazy" value:lazy ? @"true" : @"false"],
[[NSURLQueryItem alloc] initWithName:@"resolver.variant" value:@"visionos"],
[[NSURLQueryItem alloc] initWithName:@"minify" value:enableMinification ? @"true" : @"false"],
[[NSURLQueryItem alloc] initWithName:@"inlineSourceMap" value:inlineSourceMap ? @"true" : @"false"],
[[NSURLQueryItem alloc] initWithName:@"modulesOnly" value:modulesOnly ? @"true" : @"false"],
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@callstack/react-native-visionos",
"version": "1000.0.0",
"version": "0.74.0-nightly-20231127",
"description": "React Native for visionOS",
"license": "MIT",
"repository": {
Expand Down
8 changes: 6 additions & 2 deletions packages/react-native/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest"
"test": "jest",
"postinstall": "patch-package"
},
"dependencies": {
"react": "18.2.0",
"@callstack/react-native-visionos": "1000.0.0"
"react-native": "0.74.0-nightly-20231126-b50a7093b",
"@callstack/react-native-visionos": "0.74.0-nightly-20231127"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand All @@ -26,6 +28,8 @@
"babel-jest": "^29.6.3",
"eslint": "^8.19.0",
"jest": "^29.6.3",
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0",
"prettier": "2.8.8",
"react-test-renderer": "18.2.0",
"typescript": "5.0.4"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/node_modules/@react-native/community-cli-plugin/dist/utils/metroPlatformResolver.js b/node_modules/@react-native/community-cli-plugin/dist/utils/metroPlatformResolver.js
index 5cd205a..fa8a320 100644
--- a/node_modules/@react-native/community-cli-plugin/dist/utils/metroPlatformResolver.js
+++ b/node_modules/@react-native/community-cli-plugin/dist/utils/metroPlatformResolver.js
@@ -31,13 +31,14 @@ exports.reactNativePlatformResolver = reactNativePlatformResolver;
*/
function reactNativePlatformResolver(platformImplementations) {
return (context, moduleName, platform) => {
+ let platformOrVariant = context.customResolverOptions.variant || platform;
let modifiedModuleName = moduleName;
- if (platform != null && platformImplementations[platform]) {
+ if (platformOrVariant != null && platformImplementations[platformOrVariant]) {
if (moduleName === "react-native") {
- modifiedModuleName = platformImplementations[platform];
+ modifiedModuleName = platformImplementations[platformOrVariant];
} else if (moduleName.startsWith("react-native/")) {
modifiedModuleName = `${
- platformImplementations[platform]
+ platformImplementations[platformOrVariant]
}/${modifiedModuleName.slice("react-native/".length)}`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,13 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = HelloWorld;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,7";
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
Expand All @@ -506,7 +511,12 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = HelloWorld;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,7";
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
Expand Down

0 comments on commit a3575ec

Please sign in to comment.