From c2b2e2fc7b888bcf003c21b895d7bf66fcf36e8a Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Mon, 22 Mar 2021 14:59:37 -0500 Subject: [PATCH 1/5] add pull yml --- .github/pull.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/pull.yml diff --git a/.github/pull.yml b/.github/pull.yml new file mode 100644 index 00000000000000..0232035eb0f013 --- /dev/null +++ b/.github/pull.yml @@ -0,0 +1,17 @@ +version: "1" +rules: # Array of rules + - base: master # Required. Target branch + upstream: microsoft:master # Required. Must be in the same fork network. + mergeMethod: squash # Optional, one of [none, merge, squash, rebase, hardreset], Default: none. + mergeUnstable: false # Optional, merge pull request even when the mergeable_state is not clean. Default: false + assignees: # Optional + - HeyImChris + - saadnajmi + reviewers: # Optional + - HeyImChris + - saadnajmi + conflictReviewers: # Optional, on merge conflict assign a reviewer + - HeyImChris + - saadnajmi +label: ":arrow_heading_down: pull" # Optional +conflictLabel: "merge-conflict" # Optional, on merge conflict assign a custom label, Default: merge-conflict \ No newline at end of file From 7a9006bdb9b72629f61fab0b17089d6876757175 Mon Sep 17 00:00:00 2001 From: "pull[bot]" <39814207+pull[bot]@users.noreply.github.com> Date: Wed, 21 Apr 2021 17:44:03 +0000 Subject: [PATCH 2/5] match handleOpenURLNotification event payload with iOS (#755) (#2) Co-authored-by: Ryan Linton --- Libraries/LinkingIOS/macos/RCTLinkingManager.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LinkingIOS/macos/RCTLinkingManager.mm b/Libraries/LinkingIOS/macos/RCTLinkingManager.mm index 678c2a67639129..979c36b5fe38f3 100644 --- a/Libraries/LinkingIOS/macos/RCTLinkingManager.mm +++ b/Libraries/LinkingIOS/macos/RCTLinkingManager.mm @@ -82,7 +82,7 @@ - (void)handleOpenURLNotification:(NSNotification *)notification NSWindow *lastWindow = [[NSApp windows] lastObject]; [lastWindow makeKeyAndOrderFront:nil]; - [self sendEventWithName:@"url" body:notification.userInfo[@"url"]]; + [self sendEventWithName:@"url" body:notification.userInfo]; } RCT_EXPORT_METHOD(openURL:(NSURL *)URL From d9faa3a52a69e4678a32a4f9a8ad6ca88a9f7b66 Mon Sep 17 00:00:00 2001 From: "pull[bot]" <39814207+pull[bot]@users.noreply.github.com> Date: Thu, 14 Oct 2021 19:00:50 +0000 Subject: [PATCH 3/5] [pull] master from microsoft:master (#11) * Deprecated api (#853) * Remove deprecated/unused context param * Update a few Mac deprecated APIs * Packing RN dependencies, hermes and ignoring javadoc failure, (#852) * Ignore javadoc failure * Bringing few more changes from 0.63-stable * Fixing a patch in engine selection * Fixing a patch in nuget spec * Fixing the output directory of nuget pack * Packaging dependencies in the nuget * Fix onMouseEnter/onMouseLeave callbacks not firing on Pressable (#855) * add pull yml * match handleOpenURLNotification event payload with iOS (#755) (#2) Co-authored-by: Ryan Linton * fix mouse evetns on pressable * delete extra yml from this branch * Add macOS tags * reorder props to have onMouseEnter/onMouseLeave always be before onPress Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton * Grammar fixes. (#856) Updates simple grammar issues. Co-authored-by: Nick Trescases <42704557+ntre@users.noreply.github.com> Co-authored-by: Anandraj Co-authored-by: Saad Najmi Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton Co-authored-by: Muhammad Hamza Zaman --- .ado/android-pr.yml | 17 +- .ado/publish.yml | 7 + Libraries/Components/Pressable/Pressable.js | 6 + README.md | 6 +- React/Base/macOS/RCTPlatformDisplayLink.m | 12 +- React/Views/RCTActivityIndicatorView.m | 4 +- React/Views/RCTProgressViewManager.m | 6 +- React/Views/RCTSlider.m | 2 +- React/Views/RCTSwitch.m | 8 +- .../Build/ReactAndroid/ReactAndroid.nuspec | 76 ++- .../patches/Build/ReactAndroid/release.gradle | 10 + .../facebook/react/bridge/ReactBridge.java | 18 +- .../react/ReactInstanceManagerBuilder.java | 70 ++- android-patches/scripts/download-deps.py | 296 ---------- .../scripts/downloadDependencies.py | 540 ++++++++++++++++++ packages/rn-tester/Podfile.lock | 58 +- .../js/examples/Pressable/PressableExample.js | 2 + 17 files changed, 774 insertions(+), 364 deletions(-) create mode 100644 android-patches/patches/Build/ReactAndroid/release.gradle delete mode 100644 android-patches/scripts/download-deps.py create mode 100644 android-patches/scripts/downloadDependencies.py diff --git a/.ado/android-pr.yml b/.ado/android-pr.yml index c4275eb91ada58..fd4ac235668491 100644 --- a/.ado/android-pr.yml +++ b/.ado/android-pr.yml @@ -46,11 +46,18 @@ jobs: - template: templates\prep-android-nuget.yml + # Verify depenendencies can be enumerated and downloaded .. + - task: CmdLine@2 + displayName: 'Verify Dependencies can be enumerated' + inputs: + script: sudo apt-get install python3-pip && sudo apt-get install python3-setuptools && pip3 install BeautifulSoup4 && pip3 install wheel && pip3 install wget && python3 android-patches/scripts/downloadDependencies.py $(Build.SourcesDirectory) && tree $(Build.SourcesDirectory)/android + + # Very similar to the default pack task .. but appends 'ndk21' to the nuget pack version - task: CmdLine@2 displayName: 'Verify NuGet can be packed' inputs: - script: NDK=ndk`cat ${ANDROID_SDK_ROOT}/ndk-bundle/source.properties 2>&1 | grep Pkg.Revision | awk '{ print $3}' | awk -F. '{ print $1 }'`; mono $(System.DefaultWorkingDirectory)/nuget-bin/nuget.exe pack $(System.DefaultWorkingDirectory)/ReactAndroid/ReactAndroid.nuspec -OutputDirectory $(System.DefaultWorkingDirectory) -Properties buildNumber=$(buildNumber)-$NDK;commitId=$(Build.SourceVersion) + script: NDK=ndk`cat ${ANDROID_SDK_ROOT}/ndk-bundle/source.properties 2>&1 | grep Pkg.Revision | awk '{ print $3}' | awk -F. '{ print $1 }'`; mono $(System.DefaultWorkingDirectory)/nuget-bin/nuget.exe pack $(System.DefaultWorkingDirectory)/ReactAndroid/ReactAndroid.nuspec -OutputDirectory $(Build.StagingDirectory)/final -Properties buildNumber=$(buildNumber)-$NDK;commitId=$(Build.SourceVersion) # Android CI doesn't create a nuget now, but this check is failing builds. Quickest fix to unblock builds is to disable the check... but we need to find the root cause and fix it and enable this again. # - script: '[ -f $(System.DefaultWorkingDirectory)/*.nupkg ]' @@ -70,4 +77,10 @@ jobs: - task: CmdLine@2 displayName: gradlew clean inputs: - script: ./gradlew clean \ No newline at end of file + script: ./gradlew clean + + - task: PublishBuildArtifacts@1 + displayName: 'Publish final artifacts' + inputs: + PathtoPublish: '$(Build.StagingDirectory)/final' + ArtifactName: 'ReactNative-Final' diff --git a/.ado/publish.yml b/.ado/publish.yml index e130fd1562b2ec..410840614be5ce 100644 --- a/.ado/publish.yml +++ b/.ado/publish.yml @@ -144,6 +144,13 @@ jobs: - template: templates\prep-android-nuget.yml + # Enumerate and download all dependencies .. + - task: CmdLine@2 + displayName: 'Verify Dependencies can be enumerated' + inputs: + script: sudo apt-get install python3-pip && sudo apt-get install python3-setuptools && pip3 install BeautifulSoup4 && pip3 install wheel && pip3 install wget && python3 android-patches/scripts/downloadDependencies.py $(Build.SourcesDirectory) && tree $(Build.SourcesDirectory)/android + + # Very similar to the default pack task .. but appends 'ndk21b' to the nuget pack version - task: CmdLine@2 displayName: 'NuGet pack' diff --git a/Libraries/Components/Pressable/Pressable.js b/Libraries/Components/Pressable/Pressable.js index b71ff90090cc7e..34d3c8ccf716a3 100644 --- a/Libraries/Components/Pressable/Pressable.js +++ b/Libraries/Components/Pressable/Pressable.js @@ -170,6 +170,8 @@ function Pressable(props: Props, forwardedRef): React.Node { delayLongPress, disabled, focusable, + onMouseEnter, // [TODO(macOS GH#774) + onMouseLeave, // ]TODO(macOS GH#774) onLongPress, onPress, onPressIn, @@ -208,6 +210,8 @@ function Pressable(props: Props, forwardedRef): React.Node { android_disableSound, delayLongPress, delayPressIn: unstable_pressDelay, + onHoverIn: onMouseEnter, // [TODO(macOS GH#774) + onHoverOut: onMouseLeave, // ]TODO(macOS GH#774) onLongPress, onPress, onPressIn(event: PressEvent): void { @@ -236,6 +240,8 @@ function Pressable(props: Props, forwardedRef): React.Node { delayLongPress, disabled, hitSlop, + onMouseEnter, // [TODO(macOS GH#774) + onMouseLeave, // ]TODO(macOS GH#774) onLongPress, onPress, onPressIn, diff --git a/README.md b/README.md index e460fe18614386..26aed19de38740 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ This repository is a working fork of **facebook/react-native** that adds support for the official React Native for macOS implementation from Microsoft. -You can read more about the macOS implementation in our website - [React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/) +You can read more about the macOS implementation on our website - [React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/) ## Contents @@ -50,14 +50,14 @@ Search the [existing issues](https://github.com/microsoft/react-native-macos/iss - Ensure the [appropriate template](https://github.com/microsoft/react-native-macos/issues/new/choose) is used when filing your issue(s). ## Contributing -See [Contributing guidelines](https://github.com/microsoft/react-native-macos/blob/master/CONTRIBUTING.md) for how to setup your fork of the repo and start a PR to contribute to React Native for macOS. +See [Contributing guidelines](https://github.com/microsoft/react-native-macos/blob/master/CONTRIBUTING.md) for how to set up your fork of the repo and start a PR to contribute to React Native for macOS. [Good First Issue](https://github.com/microsoft/react-native-macos/labels/good%20first%20issue) and [help wanted](https://github.com/microsoft/react-native-macos/labels/help%20wanted) are great starting points for PRs. ## Documentation [React Native already has great documentation](https://reactnative.dev/docs/getting-started) and we're working to ensure the React Native for Windows + macOS are part of that documentation story. -[React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/) has it's own separate documentation site where Windows and macOS +[React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/) has its own separate documentation site where Windows and macOS specific information, like API docs and blog updates live. We are bootstrapping documentation for macOS at this time, tune in for updates. ### Examples diff --git a/React/Base/macOS/RCTPlatformDisplayLink.m b/React/Base/macOS/RCTPlatformDisplayLink.m index ff51cdceb16744..8e8ebfc45e917b 100644 --- a/React/Base/macOS/RCTPlatformDisplayLink.m +++ b/React/Base/macOS/RCTPlatformDisplayLink.m @@ -15,7 +15,7 @@ #import #import -#import +#import @interface RCTPlatformDisplayLink () @@ -30,7 +30,7 @@ @implementation RCTPlatformDisplayLink __weak id _target; NSRunLoop *_runLoop; NSMutableArray *_modes; - OSSpinLock _lock; // OS_SPINLOCK_INIT == 0 + os_unfair_lock _lock; // OS_UNFAIR_LOCK_INIT == 0 } + (RCTPlatformDisplayLink *)displayLinkWithTarget:(id)target selector:(SEL)sel @@ -47,7 +47,7 @@ static CVReturn RCTPlatformDisplayLinkCallBack(__unused CVDisplayLinkRef display RCTPlatformDisplayLink *rctDisplayLink = (__bridge RCTPlatformDisplayLink*)displayLinkContext; // Lock and check for invalidation prior to calling out to the runloop - OSSpinLockLock(&rctDisplayLink->_lock); + os_unfair_lock_lock(&rctDisplayLink->_lock); if (rctDisplayLink->_runLoop != nil) { CFRunLoopRef cfRunLoop = [rctDisplayLink->_runLoop getCFRunLoop]; CFRunLoopPerformBlock(cfRunLoop, kCFRunLoopDefaultMode, ^{ @@ -55,7 +55,7 @@ static CVReturn RCTPlatformDisplayLinkCallBack(__unused CVDisplayLinkRef display }); CFRunLoopWakeUp(cfRunLoop); } - OSSpinLockUnlock(&rctDisplayLink->_lock); + os_unfair_lock_unlock(&rctDisplayLink->_lock); } return kCVReturnSuccess; } @@ -98,10 +98,10 @@ - (void)removeFromRunLoop:(__unused NSRunLoop *)runloop forMode:(NSRunLoopMode)m - (void)invalidate { if (_runLoop != nil) { - OSSpinLockLock(&_lock); + os_unfair_lock_lock(&_lock); _runLoop = nil; _modes = nil; - OSSpinLockUnlock(&_lock); + os_unfair_lock_unlock(&_lock); // CVDisplayLinkStop attempts to acquire a mutex possibly held during the callback's invocation. // Stop the display link outside of the lock to avoid deadlocking here. diff --git a/React/Views/RCTActivityIndicatorView.m b/React/Views/RCTActivityIndicatorView.m index 0305458737e8f6..4b4a8bbf7bf710 100644 --- a/React/Views/RCTActivityIndicatorView.m +++ b/React/Views/RCTActivityIndicatorView.m @@ -23,7 +23,7 @@ - (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { self.displayedWhenStopped = NO; - self.style = NSProgressIndicatorSpinningStyle; + self.style = NSProgressIndicatorStyleSpinning; } return self; } @@ -82,7 +82,7 @@ - (void)updateLayer [super updateLayer]; if (_color != nil) { CGFloat r, g, b, a; - [[_color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&r green:&g blue:&b alpha:&a]; + [[_color colorUsingColorSpace:[NSColorSpace genericRGBColorSpace]] getRed:&r green:&g blue:&b alpha:&a]; CIFilter *colorPoly = [CIFilter filterWithName:@"CIColorPolynomial"]; [colorPoly setDefaults]; diff --git a/React/Views/RCTProgressViewManager.m b/React/Views/RCTProgressViewManager.m index dd802c059a5b6e..d732342940aaa4 100644 --- a/React/Views/RCTProgressViewManager.m +++ b/React/Views/RCTProgressViewManager.m @@ -14,9 +14,9 @@ @implementation RCTConvert (RCTProgressViewManager) #if TARGET_OS_OSX // [TODO(macOS GH#774) RCT_ENUM_CONVERTER(NSProgressIndicatorStyle, (@{ - @"default": @(NSProgressIndicatorBarStyle), - @"bar": @(NSProgressIndicatorBarStyle), -}), NSProgressIndicatorBarStyle, integerValue) + @"default": @(NSProgressIndicatorStyleBar), + @"bar": @(NSProgressIndicatorStyleBar), +}), NSProgressIndicatorStyleBar, integerValue) #else // ]TODO(macOS GH#774) RCT_ENUM_CONVERTER( UIProgressViewStyle, diff --git a/React/Views/RCTSlider.m b/React/Views/RCTSlider.m index cb11a7a28673c4..7c5b1f655386b5 100644 --- a/React/Views/RCTSlider.m +++ b/React/Views/RCTSlider.m @@ -126,7 +126,7 @@ @implementation RCTSlider { - (instancetype)initWithFrame:(NSRect)frameRect { if (self = [super initWithFrame:frameRect]) { - self.cell.controlSize = NSRegularControlSize; + self.cell.controlSize = NSControlSizeRegular; ((RCTSliderCell*)self.cell).delegate = self; } return self; diff --git a/React/Views/RCTSwitch.m b/React/Views/RCTSwitch.m index 2bbb711b0b9827..056f8066090bcc 100644 --- a/React/Views/RCTSwitch.m +++ b/React/Views/RCTSwitch.m @@ -19,7 +19,7 @@ @implementation RCTSwitch - (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { - self.buttonType = NSSwitchButton; + self.buttonType = NSButtonTypeSwitch; self.title = @""; // default is "Button" } return self; @@ -34,7 +34,7 @@ - (void)setOn:(BOOL)on animated:(BOOL)animated } #else // [TODO(macOS GH#774) - (void)setOn:(BOOL)on animated:(BOOL)animated { - self.state = on ? NSOnState : NSOffState; + self.state = on ? NSControlStateValueOn : NSControlStateValueOff; } #endif // ]TODO(macOS GH#774) @@ -42,12 +42,12 @@ - (void)setOn:(BOOL)on animated:(BOOL)animated { - (BOOL)on { - return self.state == NSOnState; + return self.state == NSControlStateValueOn; } - (void)setOn:(BOOL)on { - self.state = on ? NSOnState : NSOffState; + self.state = on ? NSControlStateValueOn : NSControlStateValueOff; } #endif // ]TODO(macOS GH#774) diff --git a/android-patches/patches/Build/ReactAndroid/ReactAndroid.nuspec b/android-patches/patches/Build/ReactAndroid/ReactAndroid.nuspec index b03fdffd8a7c4e..200effcbc06ba7 100644 --- a/android-patches/patches/Build/ReactAndroid/ReactAndroid.nuspec +++ b/android-patches/patches/Build/ReactAndroid/ReactAndroid.nuspec @@ -1,6 +1,6 @@ ---- "E:\\github\\rnm-63-fresh\\ReactAndroid\\ReactAndroid.nuspec" 1969-12-31 16:00:00.000000000 -0800 -+++ "E:\\github\\rnm-63\\ReactAndroid\\ReactAndroid.nuspec" 2020-10-27 20:20:54.071789900 -0700 -@@ -0,0 +1,130 @@ +--- "E:\\gh\\react-native-macos2\\ReactAndroid\\ReactAndroid.nuspec" 1969-12-31 16:00:00.000000000 -0800 ++++ "E:\\gh\\react-native-macos\\ReactAndroid\\ReactAndroid.nuspec" 2021-10-12 19:48:38.934480100 -0700 +@@ -0,0 +1,200 @@ + + + @@ -64,6 +64,41 @@ + + + ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + @@ -116,6 +151,40 @@ + + + ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + @@ -128,6 +197,7 @@ + + + ++ + + + diff --git a/android-patches/patches/Build/ReactAndroid/release.gradle b/android-patches/patches/Build/ReactAndroid/release.gradle new file mode 100644 index 00000000000000..ed6ab89d7ce85e --- /dev/null +++ b/android-patches/patches/Build/ReactAndroid/release.gradle @@ -0,0 +1,10 @@ +--- /home/mganandraj/github/rnm-64-vanilla/ReactAndroid/release.gradle 2021-10-11 17:51:44.286455263 -0700 ++++ /home/mganandraj/github/rnm-64/ReactAndroid/release.gradle 2021-10-07 16:35:28.636536900 -0700 +@@ -74,6 +74,7 @@ + afterEvaluate { project -> + + task androidJavadoc(type: Javadoc) { ++ failOnError false + source = android.sourceSets.main.java.srcDirs + classpath += files(android.bootClasspath) + classpath += files(project.getConfigurations().getByName("compile").asList()) diff --git a/android-patches/patches/OfficeRNHost/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java b/android-patches/patches/OfficeRNHost/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java index 6e760b741d1f9a..453802aa68d84f 100644 --- a/android-patches/patches/OfficeRNHost/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java +++ b/android-patches/patches/OfficeRNHost/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java @@ -1,11 +1,21 @@ ---- "E:\\github\\rnm-63-fresh\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\bridge\\ReactBridge.java" 2020-10-27 20:26:16.762190600 -0700 -+++ "E:\\github\\rnm-63\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\bridge\\ReactBridge.java" 2020-10-13 21:38:04.995797000 -0700 -@@ -31,6 +31,14 @@ +--- "E:\\gh\\react-native-macos2\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\bridge\\ReactBridge.java" 2021-10-12 13:35:49.124099000 -0700 ++++ "E:\\gh\\react-native-macos\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\bridge\\ReactBridge.java" 2021-10-12 13:22:46.508704400 -0700 +@@ -31,6 +31,24 @@ Systrace.beginSection( TRACE_TAG_REACT_JAVA_BRIDGE, "ReactBridge.staticInit::load:reactnativejni"); ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_SO_FILE_START); + -+ SoLoader.loadLibrary("v8jsi"); ++ // JS Engine is configurable .. And we expect only one packaged. ++ // Hence ignore failure. ++ ++ try { ++ SoLoader.loadLibrary("hermes"); ++ } catch (UnsatisfiedLinkError jscE) {} ++ ++ try { ++ SoLoader.loadLibrary("v8jsi"); ++ } catch (UnsatisfiedLinkError jscE) {} ++ + SoLoader.loadLibrary("glog_init"); + SoLoader.loadLibrary("fb"); + SoLoader.loadLibrary("fbjni"); diff --git a/android-patches/patches/V8/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java b/android-patches/patches/V8/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java index 8b8f4bfb7a43a8..0a7078a01da333 100644 --- a/android-patches/patches/V8/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java +++ b/android-patches/patches/V8/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java @@ -1,5 +1,5 @@ ---- "E:\\github\\rnm-63-fresh\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\ReactInstanceManagerBuilder.java" 2020-10-27 20:26:16.728167300 -0700 -+++ "E:\\github\\rnm-63\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\ReactInstanceManagerBuilder.java" 2020-10-13 21:27:45.535631600 -0700 +--- "E:\\gh\\react-native-macos2\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\ReactInstanceManagerBuilder.java" 2021-10-12 13:33:12.881732000 -0700 ++++ "E:\\gh\\react-native-macos\\ReactAndroid\\src\\main\\java\\com\\facebook\\react\\ReactInstanceManagerBuilder.java" 2021-10-12 13:26:43.722189600 -0700 @@ -26,6 +26,7 @@ import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener; import com.facebook.react.devsupport.interfaces.DevSupportManager; @@ -8,21 +8,69 @@ import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; import com.facebook.react.packagerconnection.RequestHandler; import com.facebook.react.uimanager.UIImplementationProvider; -@@ -291,7 +292,8 @@ +@@ -59,8 +60,21 @@ + private @Nullable JSIModulePackage mJSIModulesPackage; + private @Nullable Map mCustomPackagerCommandHandlers; + ++ public enum JSEngine { ++ Hermes, ++ V8 ++ } ++ ++ private JSEngine mJSEngine = JSEngine.V8; ++ + /* package protected */ ReactInstanceManagerBuilder() {} + ++ public ReactInstanceManagerBuilder setJSEngine( ++ JSEngine jsEngine) { ++ mJSEngine = jsEngine; ++ return this; ++ } ++ + /** Sets a provider of {@link UIImplementation}. Uses default provider if null is passed. */ + public ReactInstanceManagerBuilder setUIImplementationProvider( + @Nullable UIImplementationProvider uiImplementationProvider) { +@@ -291,40 +305,10 @@ private JavaScriptExecutorFactory getDefaultJSExecutorFactory( String appName, String deviceName, Context applicationContext) { - try { +- // If JSC is included, use it as normal +- initializeSoLoaderIfNecessary(applicationContext); +- SoLoader.loadLibrary("jscexecutor"); +- return new JSCExecutorFactory(appName, deviceName); +- } catch (UnsatisfiedLinkError jscE) { +- // https://github.com/facebook/hermes/issues/78 shows that +- // people who aren't trying to use Hermes are having issues. +- // https://github.com/facebook/react-native/issues/25923#issuecomment-554295179 +- // includes the actual JSC error in at least one case. +- // +- // So, if "__cxa_bad_typeid" shows up in the jscE exception +- // message, then we will assume that's the failure and just +- // throw now. +- +- if (jscE.getMessage().contains("__cxa_bad_typeid")) { +- throw jscE; +- } +- +- // Otherwise use Hermes +- try { ++ if(mJSEngine == JSEngine.V8) { + return new V8ExecutorFactory(appName, deviceName); -+/* try { - // If JSC is included, use it as normal - initializeSoLoaderIfNecessary(applicationContext); - SoLoader.loadLibrary("jscexecutor"); -@@ -325,6 +327,6 @@ - hermesE.printStackTrace(); - throw jscE; ++ } else { + return new HermesExecutorFactory(); +- } catch (UnsatisfiedLinkError hermesE) { +- // If we get here, either this is a JSC build, and of course +- // Hermes failed (since it's not in the APK), or it's a Hermes +- // build, and Hermes had a problem. +- +- // We suspect this is a JSC issue (it's the default), so we +- // will throw that exception, but we will print hermesE first, +- // since it could be a Hermes issue and we don't want to +- // swallow that. +- hermesE.printStackTrace(); +- throw jscE; } - } -+ } */ } } diff --git a/android-patches/scripts/download-deps.py b/android-patches/scripts/download-deps.py deleted file mode 100644 index 681e0ede5bf1b1..00000000000000 --- a/android-patches/scripts/download-deps.py +++ /dev/null @@ -1,296 +0,0 @@ -from bs4 import BeautifulSoup -import os -import re -import shlex -import shutil -from subprocess import Popen, PIPE -import sys -import wget -import urllib2 -import glob - - -if len(sys.argv) != 2: - print "Please provide RN repo path as argument" - sys.exit() - -root_dir = sys.argv[1] -dependency_dir = os.path.join(root_dir, "android_dependencies_downloaded2") -dependency_list_file_path = os.path.join( - root_dir, "gradle_dependency_list.txt" - ) -# maven_repo_url = "http://central.maven.org/maven2/" -maven_repo_url = "https://repo1.maven.org/maven2/" -# desired_ndk = "androidndk.12.2.0" -desired_sdk = "androidsdk.29.0.1" -# desired_jdk = "jdk.1.8.2" - - -def create_folder(folder_path): - """Create folder if it does not exist - - Parameters - ---------- - folder_path : str - folder path to be checked - """ - if not os.path.exists(folder_path): - print('Trying to create ' + folder_path) - os.makedirs(folder_path) - - -def set_env_variables(): - """ - Sets the NDK, SDK, JAVA_HOME, ANDROID_HOME vars - if they are not set - """ - if 'NugetMachineInstallRoot' not in os.environ: - print "Nuget cache not defined, do you have an office enlistment in this machine?" - sys.exit() - - nugetcache_path = os.environ['NugetMachineInstallRoot'] - # desired_ndk_path = os.path.join(nugetcache_path, desired_ndk) - # desired_sdk_path = os.path.join(nugetcache_path, desired_sdk) - # desired_jdk_path = os.path.join(nugetcache_path, desired_jdk, "x64")# - - #set_env_variable("ANDROID_NDK", desired_ndk_path) - #set_env_variable("ANDOIRD_SDK", desired_sdk_path) - #set_env_variable("ANDROID_HOME", desired_sdk_path) - #set_env_variable("JAVA_HOME", desired_jdk_path) - - set_env_variable("ANDROID_NDK", "E:\\devtools\\android-ndk-r17c") - set_env_variable("ANDOIRD_SDK", "D:\\nugetcache\\androidsdk.29.0.1") - set_env_variable("ANDROID_HOME", "D:\\nugetcache\\androidsdk.29.0.1") - set_env_variable("JAVA_HOME", "D:\\nugetcache\\jdk.1.8.3\\x64") - - -def set_env_variable(key, value): - """Set env variable given key and value - Parameters - ------------- - key : str - enivronment key name - value : str - desired value for key - """ - os.environ[key] = value - - -def list_dependencies(): - """ Write all gradle dependencies to file - """ - os.chdir(root_dir) - -# Note: Likely we need a union of releaseCompileClasspath & releaseRuntimeClasspath & debugCompileClasspath & debugRuntimeClasspath - gradle_command = "gradlew.bat ReactAndroid:dependencies --configuration releaseCompileClasspath" - gradle_command = gradle_command + " > " + \ - "\"" + dependency_list_file_path + "\"" - command_args = shlex.split(gradle_command) - process = Popen(command_args, stdout=PIPE) - (output, err) = process.communicate() - exit_code = process.wait() - - -def parse_dependencies(filepath): - """ Parse gradle dependencies and return list - - Parameters - ----------- - filepath : str - file containing gradle dependency list - - Returns - ----------- - dependency_list : list - list of dependecies in maven format - """ - infile = open(filepath, "r") - dependency_list = [] - - dependency_regex = "\S+:\S+:\S+" - omit_dependency_delim = "(*)" - for line in infile: - if line.endswith(omit_dependency_delim): - continue - - regex_matches = re.search(dependency_regex, line) - if regex_matches != None: - dependency = regex_matches.group(0) - if dependency not in dependency_list: - dependency_list.append(dependency) - - return dependency_list - - -def create_dependency_folder_structure(dependency): - """ Takes dependency in maven format and creates - folder structure required for download. - Returns the path where it should be downloaded - Parameters - ---------- - dependency : str - name in maven format - Returns - ---------- - path : str - folder depth path where dependencies - will be downloaded - """ - group_id, artifact, version = dependency.split(":") - - folder_chain = [] - for group in group_id.split("."): - folder_chain.append(group) - - folder_chain.append(artifact) - folder_chain.append(version) - - parent_dir = dependency_dir - for folder in folder_chain: - child_dir = os.path.join(parent_dir, folder) - create_folder(child_dir) - parent_dir = child_dir - - return parent_dir - - -def download_dependencies(dependency_list): - """Creates the directory structure - and downloads the maven dependecies - and saves it in the same format - - Parameters - ----------- - dependency_list : list - list of dependencies in maven format - """ - for dependency in dependency_list: - download_dir = create_dependency_folder_structure(dependency) - relative_dir = os.path.relpath(download_dir, dependency_dir) - relative_url = relative_dir.replace("\\", "/") - download_url = maven_repo_url + relative_url - - group_id, artifact, version = dependency.split(":") - file_type = artifact + "-" + version + "." - dependency_pom_path = os.path.join(download_dir, file_type + "pom") - - try: - html_source = urllib2.urlopen(download_url).read() - except: - print "[ERROR downloading ] " + download_url - print "Attempting to pull from local sdk" - copy_deps_from_local_sdk(download_dir, relative_dir) - dependency_list.extend( - get_parent_node_dep_list_from_pom(dependency_pom_path) - ) - continue - - soup = BeautifulSoup(html_source, "html.parser") - for link in soup.find_all('a'): - if file_type in link['href']: - file_name = link['href'] - if not os.path.exists(os.path.join(download_dir, file_name)): - wget.download(download_url + "/" + file_name, download_dir) - print "Downloaded " + file_name - - dependency_list.extend( - get_parent_node_dep_list_from_pom(dependency_pom_path) - ) - - -def get_parent_node_dep_list_from_pom(pom_file_path): - """Reads a pom file and gets parent node deps. - Parent node deps are not resolved by gradle deps, - hence resolving them as well. - Parameters - --------------- - pom_file_path : str - pom file to be parsed - Returns - -------------- - parent_dependency_list : list - List of parent node dependencies - """ - namespace = "http://maven.apache.org/POM/4.0.0" - - if not os.path.exists(pom_file_path): - print "POM file " + pom_file_path + " does not exist" - print "Continuing..." - return [] - pom_file_content = open(pom_file_path, "r").read() - soup = BeautifulSoup(pom_file_content, "html.parser") - parents = soup.find_all("parent") - - parent_dependency_list = [] - for parent in parents: - groupId = artifactId = version = "" - if (parent.find("groupid") is None or - parent.find("artifactid") is None or - parent.find("version") is None): - continue - groupId = parent.find("groupid").text - artifactId = parent.find("artifactid").text - version = parent.find("version").text - parent_dependency_list.append(":".join([groupId, artifactId, version])) - - return parent_dependency_list - - -def copy_deps_from_local_sdk(target_dir, relative_dir): - """ Copies dependency files from nuget cache sdk - to target directory in this case download dependency directory - Parameters - -------------- - target_dir : str - directory created for download of dependency - relative_dir : str - maven directory structure of dependency - """ - - nugetcache_path = os.environ['NugetMachineInstallRoot'] - if not os.path.exists(nugetcache_path): - print "Nuget cache does not exist. Continuing." - return - desired_sdk_path = os.path.join(nugetcache_path, desired_sdk) - if not os.path.exists(desired_sdk_path): - print "Desired android sdk " + desired_sdk + " not found in nuget cache. Continuing." - return - - source_dir = os.path.join( - desired_sdk_path, "extras", "android", "m2repository") - source_dir = os.path.join(source_dir, relative_dir) - if not os.path.exists(source_dir): - print "Dependecy not present in nuget cache android sdk. Continuing." - return - - src_files = os.listdir(source_dir) - for file_name in src_files: - src_file = os.path.join(source_dir, file_name) - if os.path.isfile(src_file): - if not os.path.exists(os.path.join(target_dir, file_name)): - shutil.copy(src_file, target_dir) - print "Copied file : " + file_name - else: - print file_name + " already present" - - -def parse_and_download_dependencies(filepath): - """ Parse and download gradle dependencies - - Parameters - ----------- - filepath : str - file containing gradle dependency list - """ - dependency_list = parse_dependencies(filepath) - download_dependencies(dependency_list) - - -def main(): - create_folder(dependency_dir) - set_env_variables() - list_dependencies() - parse_and_download_dependencies(dependency_list_file_path) - -if __name__ == '__main__': - main() diff --git a/android-patches/scripts/downloadDependencies.py b/android-patches/scripts/downloadDependencies.py new file mode 100644 index 00000000000000..dd036900583644 --- /dev/null +++ b/android-patches/scripts/downloadDependencies.py @@ -0,0 +1,540 @@ +from bs4 import BeautifulSoup +import os +import re +import shlex +import shutil +from subprocess import Popen, PIPE, STDOUT +import sys +import wget +from urllib.request import urlopen +import glob +import zipfile +import time +import sys +import logging +import xml.etree.ElementTree as ET +import json + +# Note: This list of repo needs to be kept current manually. +maven_repos = ["https://repo1.maven.org/maven2/", "https://jcenter.bintray.com/"] + +desired_sdk = os.getenv("ANDROID_SDK_ROOT") +if not desired_sdk: + logging.error("Envrionment variable ANDROID_SDK_ROOT must be set.") + exit(-1) + +if os.getenv("ANDROID_NDK"): + desired_ndk = os.getenv("ANDROID_NDK") +elif os.path.exists(os.path.join(desired_sdk, "ndk-bundle")): + desired_ndk = os.path.join(desired_sdk, "ndk-bundle") +elif os.path.exists(os.path.join(desired_sdk, "ndk")): + desired_ndk = os.path.join(desired_sdk, "ndk") +else: + logging.error("Envrionment variable ANDROID_NDK must be set.") + exit(-1) + +desired_jdk = os.getenv("JAVA_HOME") +if not desired_jdk: + logging.error("Envrionment variable JAVA_HOME must be set.") + exit(-1) + + +def create_folder(folder_path): + """Create folder if it does not exist + + Parameters + ---------- + folder_path : str + folder path to be checked + """ + if not os.path.exists(folder_path): + try: + os.makedirs(folder_path) + except Exception as inst: + logging.error("Error while creating directory: " + inst) + +def list_dependencies(react_native_dir, output_file_path): + """ Write all gradle dependencies to file + """ + os.chdir(react_native_dir) + env = dict(os.environ) + env['ANDROID_SDK_ROOT']=desired_sdk + env['ANDROID_NDK']=desired_ndk + env['JAVA_HOME']=desired_jdk + + logging.debug("desired_jdk:" + desired_jdk) + + gradle_command = "./gradlew :ReactAndroid:dependencies --configuration api" + with open(output_file_path, "w+") as output_file: + try: + process = Popen(shlex.split(gradle_command), stdout=output_file, stderr=PIPE, env=env) + output, err = process.communicate() + if err: + logging.error("Dependency enumeration failed !") + logging.error(err) + exit(1) + exit_code = process.wait() + if exit_code < 0: + logging.error("Dependency enumeration failed with error code: " + exit_code + " !") + exit(1) + except Exception as e: + logging.error("Dependency enumeration failed with exception: " + str(e)) + exit(1) + + +def parse_dependencies(filepath): + """ Parse gradle dependencies and return list + + Parameters + ----------- + filepath : str + file containing gradle dependency list + + Returns + ----------- + dependency_list : list + list of dependecies in maven format + """ + infile = open(filepath, "r") + dependency_list = [] + + dependency_regex = "[a-zA-Z0-9._-]+:[a-zA-Z0-9._-]+:[a-zA-Z0-9._-]+" + omit_dependency_delim = "(*)" + for line in infile: + if line.endswith(omit_dependency_delim): + continue + + regex_matches = re.search(dependency_regex, line) + if regex_matches != None: + dependency = regex_matches.group(0) + if dependency not in dependency_list: + dependency_list.append(dependency) + logging.info("Identified library: " + line) + else: + logging.info("Ignored entry: " + line) + + return dependency_list + + +def create_dependency_folder_structure(dependency_dir_maven, dependency): + """ Takes dependency in maven format and creates + folder structure required for download. + Returns the path where it should be downloaded + Parameters + ---------- + dependency : str + name in maven format + Returns + ---------- + path : str + folder depth path where dependencies + will be downloaded + """ + group_id, artifact, version = dependency.split(":") + + folder_chain = [] + for group in group_id.split("."): + folder_chain.append(group) + + folder_chain.append(artifact) + folder_chain.append(version) + + parent_dir = dependency_dir_maven + for folder in folder_chain: + child_dir = os.path.join(parent_dir, folder) + create_folder(child_dir) + parent_dir = child_dir + + return parent_dir + + +def try_download_dependency(download_dir, relative_url, file_type, dependency, repo_url): + logging.debug("Attempting to download " + dependency) + download_url = repo_url + relative_url + + try: + html_source = urlopen(download_url).read() + soup = BeautifulSoup(html_source, "html.parser") + for link in soup.find_all('a'): + if file_type in link['href']: + file_name = link['href'] + if not os.path.exists(os.path.join(download_dir, file_name)): + wget.download(download_url + "/" + file_name, download_dir) + logging.info("Downloaded " + file_name) + + return True # either the file exists (previously downloaded) or the download succeeded (i.e. without exception). + + except Exception as inst: + logging.info("Exception while downloading: " + str(inst)) + return False + + return False + +def get_office_platform(platform): + switcher = {'arm64-v8a':'droidarm64', 'armeabi-v7a':'droidarm', 'x86':'droidx86','x86_64':'droidx64'} + return switcher.get(platform,"") + +def extract_so(original_file_root, native_dir, original_file_name): + logging.info("Attempting to extract native libraries from " + original_file_name) + archive_filename_without_ext, archive_file_extension = os.path.splitext(original_file_name) + original_file_path = os.path.join(original_file_root, original_file_name) + zip_filepath = os.path.join(original_file_root, original_file_name + ".zip") + shutil.move(original_file_path, zip_filepath) + + # Extract the archive + with zipfile.ZipFile(zip_filepath) as zip_file: + zip_target_folder = os.path.join(original_file_root, archive_filename_without_ext) + zip_file.extractall(zip_target_folder) + + # Extract native libraries. + for candidate_so_root, dirsi, candidate_so_files in os.walk(zip_target_folder): + for candidate_so_file in candidate_so_files: + if candidate_so_file.endswith(".so"): + logging.info("Found native library " + candidate_so_file) + so_path = os.path.join(candidate_so_root, candidate_so_file) + + lib_platform = os.path.basename(candidate_so_root) + lib_office_platform = get_office_platform(lib_platform) + if not lib_office_platform: + logging.error("Invalid platform for native library: " + candidate_so_file) + exit(1) + + so_target_dir = os.path.join(native_dir, lib_office_platform) + create_folder(so_target_dir) + shutil.move(so_path, so_target_dir) + + # Re-zip back to original file name. + new_zip_filepath = os.path.join(original_file_root, archive_filename_without_ext + "_rezipped.zip") + with zipfile.ZipFile(new_zip_filepath, 'w', zipfile.ZIP_DEFLATED) as zip_file: + for rootz, dirsz, filesz in os.walk(zip_target_folder): + for filez in filesz: + dest_path = os.path.join(rootz, filez) + # rel_path = os.path.relpath(dest_path, os.path.join(zip_target_folder, '..')) + rel_path = os.path.relpath(dest_path, zip_target_folder) + zip_file.write(dest_path, rel_path) + + # Rename the rezipped file to original file name. + shutil.move(new_zip_filepath, os.path.join(original_file_root, original_file_name)) + + # Remove the originally renamed archive and extracted folder. + shutil.rmtree(zip_target_folder) + os.remove(zip_filepath) + +def extract_sos(maven_dir, native_dir): + logging.debug("Attempting to extract native libraries") + + for original_file_root, dirs, original_files in os.walk(maven_dir): + for original_file_name in original_files: + archive_filename_without_ext, archive_file_extension = os.path.splitext(original_file_name) + if(archive_file_extension in ['.jar', '.aar']): + extract_so(original_file_root, native_dir, original_file_name) + + + +def download_dependencies(dependency_dir_maven, dependency_list): + """Creates the directory structure + and downloads the maven dependecies + and saves it in the same format + + Parameters + ----------- + dependency_list : list + list of dependencies in maven format + """ + parent_list = [] + for dependency in dependency_list: + download_dir = create_dependency_folder_structure(dependency_dir_maven, dependency) + relative_dir = os.path.relpath(download_dir, dependency_dir_maven) + relative_url = relative_dir.replace("\\", "/") + + group_id, artifact, version = dependency.split(":") + file_type = artifact + "-" + version + "." + dependency_pom_path = os.path.join(download_dir, file_type + "pom") + + succeeded = False + for repo_url in maven_repos: + succeeded = try_download_dependency(download_dir, relative_url, file_type, dependency, repo_url) + if (succeeded): + break + + if not succeeded: + logging.error("[ERROR downloading ] " + relative_url + " from the listed maven repos.") + logging.error("Attempting to pull from local sdk") + succeeded = copy_deps_from_local_sdk(download_dir, relative_dir) + + if not succeeded: + logging.error("[Failed to download ] " + dependency) + else: + additional_dependency_list = get_dependency_node_dep_list_from_pom(dependency_pom_path) + for additional_dependency in additional_dependency_list: + if (additional_dependency not in dependency_list): + dependency_list.append(additional_dependency) + + parent_dependency_list = get_parent_node_dep_list_from_pom(dependency_pom_path) + for parent_dependency in parent_dependency_list: + if ((parent_dependency not in parent_list) and (parent_dependency not in dependency_list)): + parent_list.append(parent_dependency) + + for dependency in parent_list: + download_dir = create_dependency_folder_structure(dependency_dir_maven, dependency) + relative_dir = os.path.relpath(download_dir, dependency_dir_maven) + relative_url = relative_dir.replace("\\", "/") + + group_id, artifact, version = dependency.split(":") + file_type = artifact + "-" + version + "." + dependency_pom_path = os.path.join(download_dir, file_type + "pom") + + succeeded = False + for repo_url in maven_repos: + succeeded = try_download_dependency(download_dir, relative_url, file_type, dependency, repo_url) + if (succeeded): + break + + if not succeeded: + logging.error("[ERROR downloading ] " + relative_url + " from the listed maven repos.") + logging.error("Attempting to pull from local sdk") + succeeded = copy_deps_from_local_sdk(download_dir, relative_dir) + + if not succeeded: + logging.error("[Failed to download ] " + dependency) + + # Don't recurse down for parent dependencies + +def get_dependency_node_dep_list_from_pom(pom_file_path): + """Reads a pom file and gets parent node deps. + Parent node deps are not resolved by gradle deps, + hence resolving them as well. + Parameters + --------------- + pom_file_path : str + pom file to be parsed + Returns + -------------- + parent_dependency_list : list + List of parent node dependencies + """ + namespace = "http://maven.apache.org/POM/4.0.0" + + if not os.path.exists(pom_file_path): + logging.info("POM file " + pom_file_path + " does not exist") + logging.info("Continuing...") + return [] + + dependency_dependency_list = [] + tree = ET.parse(pom_file_path) + for dependency in tree.getroot().findall('.//{http://maven.apache.org/POM/4.0.0}dependency'): + groupId = dependency.find('.//{http://maven.apache.org/POM/4.0.0}groupId') + artifactId = dependency.find('.//{http://maven.apache.org/POM/4.0.0}artifactId') + version = dependency.find('.//{http://maven.apache.org/POM/4.0.0}version') + scope = dependency.find('.//{http://maven.apache.org/POM/4.0.0}scope') + + if groupId is None or artifactId is None or version is None: + break + + if(scope is None or scope.text in ['compile', 'runtime']): + if scope is not None: + logging.info("[" + scope.text + "]") + logging.info(groupId.text + ":" + artifactId.text + ":" + version.text) + dependency_dependency_list.append(":".join([groupId.text, artifactId.text, version.text])) + + return dependency_dependency_list + + + +def get_parent_node_dep_list_from_pom(pom_file_path): + """Reads a pom file and gets parent node deps. + Parent node deps are not resolved by gradle deps, + hence resolving them as well. + Parameters + --------------- + pom_file_path : str + pom file to be parsed + Returns + -------------- + parent_dependency_list : list + List of parent node dependencies + """ + namespace = "http://maven.apache.org/POM/4.0.0" + + if not os.path.exists(pom_file_path): + logging.info("POM file " + pom_file_path + " does not exist") + logging.info("Continuing...") + return [] + + parent_dependency_list = [] + tree = ET.parse(pom_file_path) + # TODO: Share code with last block + for dependency in tree.getroot().findall('.//{http://maven.apache.org/POM/4.0.0}parent'): + groupId = dependency.find('.//{http://maven.apache.org/POM/4.0.0}groupId') + artifactId = dependency.find('.//{http://maven.apache.org/POM/4.0.0}artifactId') + version = dependency.find('.//{http://maven.apache.org/POM/4.0.0}version') + scope = dependency.find('.//{http://maven.apache.org/POM/4.0.0}scope') + + if groupId is None or artifactId is None or version is None: + break + + if(scope is None or scope.text in ['compile', 'runtime']): + if scope is not None: + logging.info("[" + scope.text + "]") + logging.info(groupId.text + ":" + artifactId.text + ":" + version.text) + parent_dependency_list.append(":".join([groupId.text, artifactId.text, version.text])) + + # pom_file_content = open(pom_file_path, "r").read() + # soup = BeautifulSoup(pom_file_content, "html.parser") + # parents = soup.find_all("parent") + + # parent_dependency_list = [] + # for parent in parents: + # groupId = artifactId = version = "" + # if (parent.find("groupid") is None or + # parent.find("artifactid") is None or + # parent.find("version") is None): + # continue + # groupId = parent.find("groupid").text + # artifactId = parent.find("artifactid").text + # version = parent.find("version").text + # parent_dependency_list.append(":".join([groupId, artifactId, version])) + + return parent_dependency_list + + +def copy_deps_from_local_sdk(target_dir, relative_dir): + """ Copies dependency files from nuget cache sdk + to target directory in this case download dependency directory + Parameters + -------------- + target_dir : str + directory created for download of dependency + relative_dir : str + maven directory structure of dependency + """ + +# nugetcache_path = os.environ['NugetMachineInstallRoot'] +# if not os.path.exists(nugetcache_path): +# logging.info("Nuget cache does not exist. Continuing.") +# return False + +# desired_sdk_path = os.path.join(nugetcache_path, desired_sdk) +# if not os.path.exists(desired_sdk_path): +# logging.info("Desired android sdk " + desired_sdk + " not found in nuget cache. Continuing.") +# return False + + source_dir = os.path.join( + desired_sdk, "extras", "android", "m2repository") + source_dir = os.path.join(source_dir, relative_dir) + if not os.path.exists(source_dir): + logging.info("Dependecy not present in nuget cache android sdk. Continuing.") + return False + + src_files = os.listdir(source_dir) + for file_name in src_files: + src_file = os.path.join(source_dir, file_name) + if os.path.isfile(src_file): + if not os.path.exists(os.path.join(target_dir, file_name)): + shutil.copy(src_file, target_dir) + logging.info("Copied file : " + file_name) + else: + logging.info(file_name + " already present") + return True + + return False + + +def parse_and_download_dependencies(dependency_dir_maven, dependency_list_filepath): + """ Parse and download gradle dependencies + + Parameters + ----------- + filepath : str + file containing gradle dependency list + """ + dependency_list = parse_dependencies(dependency_list_filepath) + download_dependencies(dependency_dir_maven, dependency_list) + +def ensure_output_dir(output_dir_path): + # Move out if already exists. + if os.path.exists(output_dir_path): + logging.debug(output_dir_path + " exists ! Trying to move it.") + output_dir_path_copy = output_dir_path + '-' + time.strftime("%Y%m%d-%H%M%S") + shutil.move(output_dir_path, output_dir_path_copy ) + + # If it still exists, fail the execution. + if os.path.exists(output_dir_path): + logging.error("Unable to cleanup existing dependency directory: " + output_dir_path) + logging.error("Move it away manually and rerun the script.") + exit(1) + + # Create a fresh directory for output. + create_folder(output_dir_path) + +def main(): + if len(sys.argv) == 2: + react_native_dir = sys.argv[1] + else: + react_native_dir = os.getcwd() + + # Some smoke checks to ensure that we have a valid react-native checkout. + packageJsonFile = os.path.join(react_native_dir, "package.json") + with open(packageJsonFile) as packageJsonText: + packageJson = json.load(packageJsonText) + if(packageJson[u'name'] != u'react-native' and packageJson[u'name'] != u'react-native-macos'): + logging.info("Not a valid RN repo path!") + exit(-1) + + if (not os.path.join(react_native_dir, "ReactAndroid", "build.gradle")): + logging.info("Not a valid RN repo path!") + exit(-1) + + dependency_dir_root = os.path.join(react_native_dir, "android", "dependencies") + dependency_dir_maven = os.path.join(dependency_dir_root, "cross", "cross", "x-none", "maven") + dependency_dir_native = dependency_dir_root + dependency_dir_hermes = os.path.join(dependency_dir_root, "hermes") + dependency_list_file_path = os.path.join(dependency_dir_root, "gradle_dependencies.txt") + log_file_path = os.path.join(react_native_dir, "android", "log_" + time.strftime("%Y%m%d-%H%M%S") + ".txt" ) + + if(not os.path.exists(os.path.join(react_native_dir, "android"))): + os.mkdir(os.path.join(react_native_dir, "android")) + + logging.basicConfig(level = logging.DEBUG, filename = log_file_path) + logging.info("react_native_dir: " + react_native_dir) + logging.info("Maven dependency path: " + dependency_dir_maven) + logging.info("Native dependency path: " + dependency_dir_native) + logging.info("Dependency list file path: " + dependency_list_file_path) + + # Ensure we have an output directory + ensure_output_dir(dependency_dir_root) + + # List gradle dependencies to file. + list_dependencies(react_native_dir, dependency_list_file_path) + + # download dependencies to maven root + parse_and_download_dependencies(dependency_dir_maven, dependency_list_file_path) + + # Extract the native libraries from maven packages + extract_sos(dependency_dir_maven, dependency_dir_native) + + # Copy and extract hermes. + dependency_dir_hermes_android_aar_path = os.path.join(dependency_dir_hermes, "android") + hermes_engine_node_modules_path = os.path.join(react_native_dir, "node_modules", "hermes-engine") + shutil.copytree(os.path.join(hermes_engine_node_modules_path, "android"), dependency_dir_hermes_android_aar_path) + shutil.copytree(os.path.join(hermes_engine_node_modules_path, "linux64-bin"), os.path.join(dependency_dir_hermes, "linux64-bin")) + shutil.copytree(os.path.join(hermes_engine_node_modules_path, "win64-bin"), os.path.join(dependency_dir_hermes, "win64-bin")) + shutil.copytree(os.path.join(hermes_engine_node_modules_path, "osx-bin"), os.path.join(dependency_dir_hermes, "osx-bin")) + shutil.copy(os.path.join(hermes_engine_node_modules_path, "package.json"), dependency_dir_hermes) + + dependency_dir_hermes_android_native_debug = os.path.join(dependency_dir_hermes_android_aar_path, "debug") + dependency_dir_hermes_android_native_release = os.path.join(dependency_dir_hermes_android_aar_path, "release") + extract_so(dependency_dir_hermes_android_aar_path, dependency_dir_hermes_android_native_debug, "hermes-debug.aar") + extract_so(dependency_dir_hermes_android_aar_path, dependency_dir_hermes_android_native_debug, "hermes-cppruntime-debug.aar") + + extract_so(dependency_dir_hermes_android_aar_path, dependency_dir_hermes_android_native_release, "hermes-release.aar") + extract_so(dependency_dir_hermes_android_aar_path, dependency_dir_hermes_android_native_release, "hermes-cppruntime-release.aar") + + # Copy log file into the dependency root folder. + shutil.copy(log_file_path, os.path.join(dependency_dir_root)) + + with open(log_file_path, "r") as fin: + print(fin.read()) + +if __name__ == '__main__': + main() diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index bfd74ba17252fe..aa646a70b9313b 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -510,8 +510,8 @@ SPEC CHECKSUMS: CocoaAsyncSocket: 694058e7c0ed05a9e217d1b3c7ded962f4180845 CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f DoubleConversion: 0ea4559a49682230337df966e735d6cc7760108e - FBLazyVector: f3a2bccaa26e739c3ef011f4ca86c3ca5427eee6 - FBReactNativeSpec: 284873b891962e396668ece89aa3290221b560f6 + FBLazyVector: 3e1c4c346ec478750c07d0f1d89b424d96cac528 + FBReactNativeSpec: 49208bf2f791afd2253440847299776bdcdbc96f Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365 Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 Flipper-Folly: c12092ea368353b58e992843a990a3225d4533c3 @@ -522,35 +522,35 @@ SPEC CHECKSUMS: glog: 0dc7efada961c0793012970b60faebbd58b0decb OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355 RCT-Folly: 2f2111690f1e23490285c059ca53be22fe6d6bee - RCTRequired: 892b1fc61efc4f66a92b9c6ca85e2522e051f0e2 - RCTTypeSafety: 94bdbb3ebfd2fcc54174c5eb66486cbfac50fe60 - React: c6d1cfc7cb81cde55e07be8c1411fcdb14161562 - React-callinvoker: 577cf455f9e762be4e2b03e03fc0b267a2cff771 - React-Core: d8c133ae796db1854204a1f260ef6e3837f1285c - React-CoreModules: 23672f86dd25805b0a9096692b139e26116c1980 - React-cxxreact: 1f21c1a08237692657816d8092f3d1dc6f13fb41 - React-jsi: e42a0922ac3286bbfc1840aebba8e41fdfcc98d7 - React-jsiexecutor: 161f172db05ec4ae77be65940206ba29930355a4 - React-jsinspector: 680bd24100071d26698fef4e9c75cf69db027954 - React-perflogger: 3a28a552bc5c0be0e8cdcf9f2977aea59eba7380 - React-RCTActionSheet: 06144b4bb931c8f217afba1cd620a682cce980fa - React-RCTAnimation: 8b89532952beb474e0d2b3fbe1bdb3e107026551 - React-RCTBlob: c83099e47b7a9c1aeeb584b8696abc9f78adf3f1 - React-RCTImage: 69061c1547f728421a0aa09a2f1147f59c0d873c - React-RCTLinking: 341ac25287553e51b319266245ef03c36169c671 - React-RCTNetwork: 1ab7893ac9d21d03da65ac958271405def8fe43a - React-RCTPushNotification: e5353eb3f501048e032cda7f9491105cc70039a0 - React-RCTSettings: fa2839bad861f0d44c223938658e9e7782074c55 - React-RCTTest: ca048e75c0b296329201ea81b9f14d27ddd41823 - React-RCTText: d2c121533280c59313f002e6575118b877dd40fc - React-RCTVibration: c53993ba40851fc666c350da5269556b1c1470a4 - React-runtimeexecutor: 87ba843187b8bebb4111c8c54f199cd4785d2ee3 + RCTRequired: 6ef1ca4d8dc14cfdd1c37f14eb4137badd10e982 + RCTTypeSafety: 903e3df81eaa3809cd3593f10de14c4bdd29f500 + React: c49df3a16180bd95f195f359dd2e08555147b95d + React-callinvoker: aec8865b89dbb1cd8d6cbe782badf4d7495682c9 + React-Core: 27db1d573718bb6d53fef2f1dc93c1fdb0d5699d + React-CoreModules: 554ae8216e1963fcfc0ba8aa539a69ad0e0e64ab + React-cxxreact: 841ef739ed5009a9a2e034af90fd7c5157a44790 + React-jsi: 4b7f4a5733a77130579aa2b2af3c7963ea5f58c0 + React-jsiexecutor: 56d0bf876000abf04e757f3cbd6795d257466b6d + React-jsinspector: 6ddd209772e5b066824a030da0e81a949c8bc45b + React-perflogger: 112849bd1692d40371bcb528e6cd37f6e97da42e + React-RCTActionSheet: b2bedbbb047c24e34304e5e6332182c81fbde3c4 + React-RCTAnimation: 88a7a4272ba2142484d5310fa7450d2e65e58cea + React-RCTBlob: 19acefd489b5c3493a92c1f5c0e3d9eac8d05e46 + React-RCTImage: 723ec9d61d7f68e6be2e28fb7064d29902c534ac + React-RCTLinking: 2d7559d3c705da2474cd9c47351d029600a1f037 + React-RCTNetwork: 36c561fb46ebe56891a401fa6559fd6eae1fcf33 + React-RCTPushNotification: 993a3510ea377519306a04d69970ebc9867e25e2 + React-RCTSettings: f3e5ffe73ea7831d98b2d0a119102d9ba232774c + React-RCTTest: d56fa23c7ae8c29236cfb2cd7389337c81f6455b + React-RCTText: 627606cbb59d72a924eed4257ebae197b0570757 + React-RCTVibration: b212ea311c7b325cabd4d780cc337cff23d40f63 + React-runtimeexecutor: 04275caf6c4b2128dcbafcfa015def1782d84760 React-TurboModuleCxx-RNW: 12172bdbaaf052406ec571465243fad4b2eb2702 - React-TurboModuleCxx-WinRTPort: 32917c4b48bbe4bb20ce172c40c3cd6315354c3e - ReactCommon: f4a3480837fc8e5c73ffc38c057594b3a1ec7a43 - Yoga: 9defa6fd4bf71cdbba9b1389adb9deed6255f4b1 + React-TurboModuleCxx-WinRTPort: 9fbcbcbfed07bdacde7fde7f85773e705f2a9c1e + ReactCommon: 91962a733289a96984bc8c761b08ed23c0fbe5f8 + Yoga: 9cd54ce33d6f399a07a78172b0c8d7b89a9fc2c5 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a PODFILE CHECKSUM: cb260f8f7765c910b68f8267cbd74709f6ae6e54 -COCOAPODS: 1.10.1 +COCOAPODS: 1.11.0 diff --git a/packages/rn-tester/js/examples/Pressable/PressableExample.js b/packages/rn-tester/js/examples/Pressable/PressableExample.js index f7a1e4dc33dd2c..6c8764654ea56e 100644 --- a/packages/rn-tester/js/examples/Pressable/PressableExample.js +++ b/packages/rn-tester/js/examples/Pressable/PressableExample.js @@ -99,6 +99,8 @@ function PressableFeedbackEvents() { testID="pressable_feedback_events_button" accessibilityLabel="pressable feedback events" accessibilityRole="button" + onMouseEnter={() => appendEvent('mouseEnter')} // [TODO(macOS GH#774) + onMouseLeave={() => appendEvent('mouseLeave')} // ]TODO(macOS GH#774) onPress={() => appendEvent('press')} onPressIn={() => appendEvent('pressIn')} onPressOut={() => appendEvent('pressOut')} From 4c72f3355657901f755442fdf3bf54e88f889f2d Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Wed, 8 Dec 2021 23:24:05 -0600 Subject: [PATCH 4/5] Use NSSwitch --- React/Views/RCTSwitch.h | 2 +- React/Views/RCTSwitch.m | 15 --------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/React/Views/RCTSwitch.h b/React/Views/RCTSwitch.h index b2fea24c9ea6f7..9dbb28709ca228 100644 --- a/React/Views/RCTSwitch.h +++ b/React/Views/RCTSwitch.h @@ -12,7 +12,7 @@ #if !TARGET_OS_OSX // TODO(macOS GH#774) @interface RCTSwitch : UISwitch #else // [TODO(macOS GH#774) -@interface RCTSwitch : NSButton +@interface RCTSwitch : NSSwitch #endif // ]TODO(macOS GH#774) #if !TARGET_OS_OSX // TODO(macOS GH#774) diff --git a/React/Views/RCTSwitch.m b/React/Views/RCTSwitch.m index 056f8066090bcc..78b846bbdf97bf 100644 --- a/React/Views/RCTSwitch.m +++ b/React/Views/RCTSwitch.m @@ -7,25 +7,10 @@ #import "RCTSwitch.h" -#if TARGET_OS_OSX // [TODO(macOS GH#774) -#import -#endif // ]TODO(macOS GH#774) - #import "UIView+React.h" @implementation RCTSwitch -#if TARGET_OS_OSX // [TODO(macOS GH#774) -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) { - self.buttonType = NSButtonTypeSwitch; - self.title = @""; // default is "Button" - } - return self; -} -#endif - #if !TARGET_OS_OSX // TODO(macOS GH#774) - (void)setOn:(BOOL)on animated:(BOOL)animated { From fb507f12cf22505f4afc7699861034b280c94ddd Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Wed, 8 Dec 2021 23:29:47 -0600 Subject: [PATCH 5/5] remove change from my fork --- .github/pull.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .github/pull.yml diff --git a/.github/pull.yml b/.github/pull.yml deleted file mode 100644 index 0232035eb0f013..00000000000000 --- a/.github/pull.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: "1" -rules: # Array of rules - - base: master # Required. Target branch - upstream: microsoft:master # Required. Must be in the same fork network. - mergeMethod: squash # Optional, one of [none, merge, squash, rebase, hardreset], Default: none. - mergeUnstable: false # Optional, merge pull request even when the mergeable_state is not clean. Default: false - assignees: # Optional - - HeyImChris - - saadnajmi - reviewers: # Optional - - HeyImChris - - saadnajmi - conflictReviewers: # Optional, on merge conflict assign a reviewer - - HeyImChris - - saadnajmi -label: ":arrow_heading_down: pull" # Optional -conflictLabel: "merge-conflict" # Optional, on merge conflict assign a custom label, Default: merge-conflict \ No newline at end of file