Skip to content

Commit

Permalink
[RNMobile] Update gesture handler and reanimated libraries (#39098)
Browse files Browse the repository at this point in the history
* Bump react-native-gesture-handler to 2.2.0

* Bump react-native-reanimated to 2.4.1

* Update babel config to support reanimated lib

* Update Android demo app to support new lib versions

* Add patch for react-native-gesture-handler

* Add patch for react-native-reanimated

Hermes engine has to be manually set because the library is not able to detect it automatically.

* Update iOS demo app to support new lib versions - It includes changing the Gutenberg class from NSObject to UIResponder

* Add Reanimated library to WPAndroid glue code

* Downgrade react-native-reanimated to 2.2.4

The downgrade is necessary in order to prevent a known issue in Reanimated (software-mansion/react-native-reanimated#2719).

* Use absolute path for reanimated babel plugin

Using the absolute path is required for Reanimated plugin when generating the JS bundle outside Gutenberg, like we do in Gutenberg Mobile.

* Update Jest setup to support Reanimated2

* Add google repository to react-native-bridge build

This is required to support the react-native-gesture-handler package.

* Point dependencies to their forked repository

* Update package-lock.json

* Remove react-native-reanimated patch

* Update react-native-editor Podfile.lock

* Update package-lock.json

* Silence react-native-gesture-handler warning

* Update package-lock.json

* Update gesture handler and reanimated package versions

* Bump react-native-gesture-handler to 2.2.0-wp-2

* Revert adding google repository to react-native-bridge build

* Update react-native-editor changelog

* Update Podfile.lock

* Bump react-native-gesture-handler to 2.2.0-wp-3

Co-authored-by: Gerardo <gerardo.pacheco@automattic.com>
  • Loading branch information
fluiddot and geriux committed Mar 3, 2022
1 parent 90a5f28 commit a1b11c5
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 74 deletions.
122 changes: 61 additions & 61 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.facebook.react.ReactPackage;
import com.facebook.react.ReactRootView;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.JSIModulePackage;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
Expand All @@ -45,6 +46,7 @@
import com.reactnativecommunity.webview.RNCWebViewPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
import com.swmansion.reanimated.ReanimatedPackage;
import com.swmansion.rnscreens.RNScreensPackage;
import com.th3rdwave.safeareacontext.SafeAreaContextPackage;
Expand Down Expand Up @@ -577,6 +579,12 @@ public void sendEventToHost(String eventName, ReadableMap properties) {
mRnReactNativeGutenbergBridgePackage);
}

protected JSIModulePackage getJSIModulePackage() {
// In the future, once we support more JSI modules, we would need to provide our own JSIModulePackage and
// include Reanimated.
return new ReanimatedJSIModulePackage();
}

private MainPackageConfig getMainPackageConfig(ImagePipelineConfig imagePipelineConfig) {
return new MainPackageConfig.Builder().setFrescoConfig(imagePipelineConfig).build();
}
Expand Down Expand Up @@ -606,6 +614,7 @@ public void onCreateView(Context initContext,
.addPackages(getPackages())
.setUseDeveloperSupport(isDebug)
.setJavaScriptExecutorFactory(new HermesExecutorFactory())
.setJSIModulesPackage(getJSIModulePackage())
.setInitialLifecycleState(LifecycleState.BEFORE_CREATE);
if (BuildConfig.SHOULD_ATTACH_JS_BUNDLE) {
builder.setBundleAssetName("index.android.bundle");
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-bridge/ios/Gutenberg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Aztec
import RNTAztecView

@objc
public class Gutenberg: NSObject {
public class Gutenberg: UIResponder {
public static func supportedBlocks(isDev: Bool = false) -> [String] {
guard let json = try? SourceFile.supportedBlocks.getContent() else { return [] }
let data = Data(json.utf8)
Expand Down
3 changes: 3 additions & 0 deletions packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ For each user feature we should also add a importance categorization label to i
-->

## Unreleased

- [*] Fix autocorrected Headings applying bold formatting on iOS [#38633]

- [***] Support for multiple color palettes [#38417]

- [*] Update gesture handler and reanimated libraries [#39098]

## 1.71.1

- [*] Highlight text: Check if style attribute value is defined during filtering [#38670]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

import org.wordpress.mobile.WPAndroidGlue.GutenbergProps;

Expand All @@ -25,6 +27,11 @@ protected String getMainComponentName() {
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}

@Nullable
@Override
protected Bundle getLaunchOptions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.facebook.react.ReactApplication;
import com.BV.LinearGradient.LinearGradientPackage;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.JSIModulePackage;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.reactnativecommunity.clipboard.ClipboardPackage;
Expand All @@ -37,6 +38,7 @@
import com.facebook.soloader.SoLoader;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
import com.swmansion.reanimated.ReanimatedPackage;
import com.swmansion.rnscreens.RNScreensPackage;
import com.th3rdwave.safeareacontext.SafeAreaContextPackage;
Expand Down Expand Up @@ -308,6 +310,11 @@ protected List<ReactPackage> getPackages() {
protected String getJSMainModuleName() {
return "index";
}

@Override
protected JSIModulePackage getJSIModulePackage() {
return new ReanimatedJSIModulePackage();
}
};
}

Expand Down
8 changes: 6 additions & 2 deletions packages/react-native-editor/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ module.exports = function ( api ) {
extensions: [ 'css', 'scss', 'sass' ],
},
],
path.resolve(
__dirname,
'../../node_modules/react-native-reanimated/plugin'
),
],
overrides: [
{
Expand All @@ -32,7 +36,7 @@ module.exports = function ( api ) {
},
],
],
exclude: /node_modules\/(react-native|@react-native-community|@react-navigation)/,
exclude: /node_modules\/(react-native|@react-native-community|@react-navigation|react-native-reanimated)/,
},
{
// Auto-add `import { createElement } from '@wordpress/element';` when JSX is found.
Expand All @@ -47,7 +51,7 @@ module.exports = function ( api ) {
},
],
],
exclude: /node_modules\/(react-native|@react-native-community|@react-navigation)/,
exclude: /node_modules\/(react-native|@react-native-community|@react-navigation|react-native-reanimated)/,
},
],
env: {
Expand Down

0 comments on commit a1b11c5

Please sign in to comment.