Skip to content
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

Research jest v29 with React 18 #6277

Closed
wants to merge 87 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
e1e700b
bump react-native to 0.67.5
joaoloureirop Mar 1, 2023
6963df3
react upgrade configs
joaoloureirop Mar 1, 2023
31f44a4
bump lottie-react-native
joaoloureirop Mar 1, 2023
e009502
bump react-native-aes-crypto
joaoloureirop Mar 1, 2023
1d8a2de
bump react-native-minimizer
joaoloureirop Mar 1, 2023
98509ee
bump react-dom
joaoloureirop Mar 1, 2023
1f19436
migrate react-native patch
joaoloureirop Mar 1, 2023
83690de
remove old patch
joaoloureirop Mar 1, 2023
c2c5d27
remove react-native patch for now. deal with that later on
joaoloureirop Mar 1, 2023
00baf17
remove old lottie framework & viewpager
joaoloureirop Mar 1, 2023
97ea930
patch react-native-aes-crypto
joaoloureirop Mar 2, 2023
023bdab
fix submodule resolution
joaoloureirop Mar 2, 2023
c0cc237
update react-native-aes-crypto patch
joaoloureirop Mar 2, 2023
39aeec7
Bump node to 16.13.0
gantunesr Mar 8, 2023
26f736e
undo lottie manual link
joaoloureirop Mar 9, 2023
9342e19
rn 68.6 upgrade
joaoloureirop Mar 9, 2023
cd9e07f
update RCTBundleURLProvider
joaoloureirop Mar 9, 2023
dc4d5f5
update pods
joaoloureirop Mar 9, 2023
d42db47
rn 69.8 upgrade
joaoloureirop Mar 9, 2023
977924e
update pods
joaoloureirop Mar 9, 2023
15d509e
rn update 0.70.7
joaoloureirop Mar 9, 2023
528cc2e
Bump node version in bitrise config
gantunesr Mar 9, 2023
b7b0198
Update .nvmrc
gantunesr Mar 9, 2023
18c6352
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile in…
gantunesr Mar 13, 2023
4fcf9d2
use node 16
joaoloureirop Mar 9, 2023
4a8cabe
update podfile
joaoloureirop Mar 14, 2023
ca0bd3a
update pods
joaoloureirop Mar 21, 2023
1acdc77
71.4
joaoloureirop Mar 21, 2023
f6351a9
bump pods to 71.4
joaoloureirop Mar 22, 2023
d4edaad
use RN animated for now
joaoloureirop Mar 22, 2023
140a40b
update sentry/react-native. fix sentry-cli
joaoloureirop Mar 22, 2023
475efc2
hard code drawer dismiss
joaoloureirop Mar 22, 2023
9ee1632
disable svg metro bundler config to allow Bigint to number conversion
joaoloureirop Mar 28, 2023
e7410e0
Update static-logos svg's
leotm Apr 4, 2023
1c8e088
Update .nvmrc from Node 14 to 16
leotm Apr 4, 2023
43c7a9c
Update Gemfile for RN 0.71.6
leotm Apr 4, 2023
013d3ab
Update deps and pods
leotm Apr 4, 2023
d8f7279
Add commented Babel config from debugging SVGs
leotm Apr 4, 2023
0030f60
Add back react-native-svg Metro config
leotm Apr 4, 2023
ad58291
Test all @ethereumjs/util methods and BigInt
leotm Apr 4, 2023
ba710c5
udpate android configs
joaoloureirop Apr 5, 2023
06799c1
Revert "Test all @ethereumjs/util methods and BigInt"
leotm Apr 6, 2023
dc34b4f
Revert "Add commented Babel config from debugging SVGs"
leotm Apr 6, 2023
f943b6d
Convert reanimated v1 code -> v2 for ReusableModal and Drawer
Cal-L Apr 7, 2023
af6e783
Replace Notification animation with reanimated v2
Cal-L Apr 7, 2023
6274a9c
Use SheetBottom for DetectedTokens screen
Cal-L Apr 7, 2023
314b33f
Remove layout animations on accordion for now
Cal-L Apr 7, 2023
2a063aa
Merge branch 'upgrade/react-native/0.71.6' of https://github.com/Meta…
Cal-L Apr 7, 2023
0be7ed6
Update AppState listener removal
Cal-L Apr 10, 2023
2b8097d
Expose boolean in dismiss callback for ReusableModal and SheetBottom
Cal-L Apr 10, 2023
169ac93
Remove AppState listeners and fix lint
Cal-L Apr 10, 2023
74fc928
Merge branch 'main' into bump-node
Fatxx Apr 11, 2023
3c86402
Merge branch 'main' into fix/unit-test-memory-leaks
Fatxx Apr 11, 2023
5ee9e71
Test CI
Fatxx Apr 11, 2023
11f52c2
Test CI
Fatxx Apr 11, 2023
45d0c5d
Set .nvmrc v16
Fatxx Apr 11, 2023
e2334ec
Test CI
Fatxx Apr 11, 2023
3bd2497
patch react-native TextInput
joaoloureirop Apr 12, 2023
2809099
Move Flipper files on Android
Cal-L Apr 12, 2023
fcbadb0
Update build gradle files with manifest placeholders and remove need …
Cal-L Apr 12, 2023
e030929
Clean up MainActivity and MainApplication java files
Cal-L Apr 12, 2023
725f373
Configure gesture handler for Android in react-native.config.js
Cal-L Apr 12, 2023
2d00bfa
Patch compile method for packages
Cal-L Apr 13, 2023
9c3b452
Bump blur and video packages
Cal-L Apr 13, 2023
40c8d23
Find node with xcode.env
Cal-L Apr 13, 2023
42e83be
Update pod files with bumped libraries
Cal-L Apr 13, 2023
ce470df
patch(react-native): make sdk versioning absolute
joaoloureirop Apr 14, 2023
73caa13
update pods
joaoloureirop Apr 14, 2023
4bfcdb6
react-native-aes-crypto-fork: apply manual patch
joaoloureirop Apr 14, 2023
b18de8a
dont kill adb server when running on android
joaoloureirop Apr 19, 2023
023b5d6
skip build react-native from source
joaoloureirop Apr 19, 2023
8eb83be
Bump react-native-reanimated from 3.0.2 to 3.1.0
leotm Apr 21, 2023
a16fb02
Bump pod RNReanimated from 3.0.2 to 3.1.0
leotm Apr 21, 2023
4eb71cd
Add Hermes ProGuard rules for Android
leotm Apr 21, 2023
5a34bd4
Doc pos eth-json-rpc-errors issue RE Hermes
leotm Apr 21, 2023
e3fabe1
Add temp debug breakpoints and crash notes
leotm Apr 21, 2023
7251926
removed lint and audit blockers to test bitrise builds
sethkfman Apr 21, 2023
0c4e4dc
added lint disabled on files
sethkfman Apr 21, 2023
2c621fa
removed non-existing imports
sethkfman Apr 21, 2023
e1dddc3
Upgrade to Jest 27, fix global mocks
Fatxx Apr 25, 2023
e465e00
Move mock inside setup file
Fatxx Apr 25, 2023
c181338
Revert CI
Fatxx Apr 25, 2023
9bfbafe
Updated jest/types and babel-jest
Fatxx Apr 25, 2023
dd398b2
Rename test setup and added enzyme
Fatxx Apr 26, 2023
e8c415d
Update eslint ignore
Fatxx Apr 26, 2023
4777ddd
WIP
Fatxx Apr 26, 2023
169f040
Testing Jest 28
Fatxx Apr 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BUNDLE_PATH: "vendor/bundle"
BUNDLE_FORCE_RUBY_PLATFORM: 1
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ CHANGELOG.md
# Ignore auto generated file used for react-native-storybook-loader
/storybook/storyLoader.js
wdio
/app/util/test/testSetup.js
5 changes: 3 additions & 2 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ node_modules/react-native/Libraries/polyfills/.*
; Flow doesn't support platforms
.*/Libraries/Utilities/LoadingView.js

.*/node_modules/resolve/test/resolver/malformed_package_json/package\.json$

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

Expand Down Expand Up @@ -50,7 +52,6 @@ nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
unnecessary-invariant=warn
signature-verification-failure=warn

[strict]
deprecated-type
Expand All @@ -62,4 +63,4 @@ untyped-import
untyped-type-import

[version]
^0.158.0
^0.182.0
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.14.0
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14
v16
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.5
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby '>= 2.6.10'

gem 'cocoapods', '>= 1.11.3'
4 changes: 2 additions & 2 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
-keep class com.facebook.react.turbomodule.** { *; }

# Hermes
# -keep class com.facebook.hermes.unicode.** { *; }
# -keep class com.facebook.jni.** { *; }#
-keep class com.facebook.hermes.unicode.** { *; }
-keep class com.facebook.jni.** { *; }#

# react-native-webrt https://github.com/react-native-webrtc/react-native-webrtc/issues/590
-keep class org.webrtc.** { *; }
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
<meta-data android:name="io.branch.sdk.TestMode" android:value="false" /> <!-- Set to true to use Branch_Test_Key -->
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
*/
package com.flipper;
package io.metamask;

import android.content.Context;
import com.facebook.flipper.android.AndroidFlipperClient;
Expand All @@ -17,32 +17,35 @@
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
import com.facebook.react.ReactInstanceEventListener;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.network.NetworkingModule;
import okhttp3.OkHttpClient;

/**
* Class responsible of loading Flipper inside your React Native application. This is the debug
* flavor of it. Here you can add your own plugins and customize the Flipper setup.
*/
public class ReactNativeFlipper {
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (FlipperUtils.shouldEnableFlipper(context)) {
final FlipperClient client = AndroidFlipperClient.getInstance(context);

client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
client.addPlugin(new ReactFlipperPlugin());
client.addPlugin(new DatabasesFlipperPlugin(context));
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
client.addPlugin(CrashReporterPlugin.getInstance());

NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
NetworkingModule.setCustomClientBuilder(
new NetworkingModule.CustomClientBuilder() {
@Override
public void apply(OkHttpClient.Builder builder) {
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
}
});
new NetworkingModule.CustomClientBuilder() {
@Override
public void apply(OkHttpClient.Builder builder) {
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
}
});
client.addPlugin(networkFlipperPlugin);
client.start();

Expand All @@ -51,19 +54,19 @@ public void apply(OkHttpClient.Builder builder) {
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (reactContext == null) {
reactInstanceManager.addReactInstanceEventListener(
new ReactInstanceManager.ReactInstanceEventListener() {
@Override
public void onReactContextInitialized(ReactContext reactContext) {
reactInstanceManager.removeReactInstanceEventListener(this);
reactContext.runOnNativeModulesQueueThread(
new Runnable() {
@Override
public void run() {
client.addPlugin(new FrescoFlipperPlugin());
}
});
}
});
new ReactInstanceEventListener() {
@Override
public void onReactContextInitialized(ReactContext reactContext) {
reactInstanceManager.removeReactInstanceEventListener(this);
reactContext.runOnNativeModulesQueueThread(
new Runnable() {
@Override
public void run() {
client.addPlugin(new FrescoFlipperPlugin());
}
});
}
});
} else {
client.addPlugin(new FrescoFlipperPlugin());
}
Expand Down
3 changes: 1 addition & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.metamask"
xmlns:tools="http://schemas.android.com/tools"
>

Expand Down Expand Up @@ -39,7 +38,7 @@
android:launchMode="singleTask"
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package io.metamask.newarchitecture;

import android.app.Application;
import androidx.annotation.NonNull;
import com.facebook.react.PackageList;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
import com.facebook.react.bridge.JSIModulePackage;
import com.facebook.react.bridge.JSIModuleProvider;
import com.facebook.react.bridge.JSIModuleSpec;
import com.facebook.react.bridge.JSIModuleType;
import com.facebook.react.bridge.JavaScriptContextHolder;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.UIManager;
import com.facebook.react.fabric.ComponentFactory;
import com.facebook.react.fabric.CoreComponentsRegistry;
import com.facebook.react.fabric.FabricJSIModuleProvider;
import com.facebook.react.fabric.ReactNativeConfig;
import com.facebook.react.uimanager.ViewManagerRegistry;
import io.metamask.BuildConfig;
import io.metamask.newarchitecture.components.MainComponentsRegistry;
import io.metamask.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
import java.util.ArrayList;
import java.util.List;

/**
* A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both
* TurboModule delegates and the Fabric Renderer.
*
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
* `newArchEnabled` property). Is ignored otherwise.
*/
public class MainApplicationReactNativeHost extends ReactNativeHost {
public MainApplicationReactNativeHost(Application application) {
super(application);
}

@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

@Override
protected List<ReactPackage> getPackages() {
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
// TurboModules must also be loaded here providing a valid TurboReactPackage implementation:
// packages.add(new TurboReactPackage() { ... });
// If you have custom Fabric Components, their ViewManagers should also be loaded here
// inside a ReactPackage.
return packages;
}

@Override
protected String getJSMainModuleName() {
return "index";
}

@NonNull
@Override
protected ReactPackageTurboModuleManagerDelegate.Builder
getReactPackageTurboModuleManagerDelegateBuilder() {
// Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary
// for the new architecture and to use TurboModules correctly.
return new MainApplicationTurboModuleManagerDelegate.Builder();
}

@Override
protected JSIModulePackage getJSIModulePackage() {
return new JSIModulePackage() {
@Override
public List<JSIModuleSpec> getJSIModules(
final ReactApplicationContext reactApplicationContext,
final JavaScriptContextHolder jsContext) {
final List<JSIModuleSpec> specs = new ArrayList<>();

// Here we provide a new JSIModuleSpec that will be responsible of providing the
// custom Fabric Components.
specs.add(
new JSIModuleSpec() {
@Override
public JSIModuleType getJSIModuleType() {
return JSIModuleType.UIManager;
}

@Override
public JSIModuleProvider<UIManager> getJSIModuleProvider() {
final ComponentFactory componentFactory = new ComponentFactory();
CoreComponentsRegistry.register(componentFactory);

// Here we register a Components Registry.
// The one that is generated with the template contains no components
// and just provides you the one from React Native core.
MainComponentsRegistry.register(componentFactory);

final ReactInstanceManager reactInstanceManager = getReactInstanceManager();

ViewManagerRegistry viewManagerRegistry =
new ViewManagerRegistry(
reactInstanceManager.getOrCreateViewManagers(reactApplicationContext));

return new FabricJSIModuleProvider(
reactApplicationContext,
componentFactory,
ReactNativeConfig.DEFAULT_CONFIG,
viewManagerRegistry);
}
});
return specs;
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.metamask.newarchitecture.components;

import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.fabric.ComponentFactory;
import com.facebook.soloader.SoLoader;

/**
* Class responsible to load the custom Fabric Components. This class has native methods and needs a
* corresponding C++ implementation/header file to work correctly (already placed inside the jni/
* folder for you).
*
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
* `newArchEnabled` property). Is ignored otherwise.
*/
@DoNotStrip
public class MainComponentsRegistry {
static {
SoLoader.loadLibrary("fabricjni");
}

@DoNotStrip private final HybridData mHybridData;

@DoNotStrip
private native HybridData initHybrid(ComponentFactory componentFactory);

@DoNotStrip
private MainComponentsRegistry(ComponentFactory componentFactory) {
mHybridData = initHybrid(componentFactory);
}

@DoNotStrip
public static MainComponentsRegistry register(ComponentFactory componentFactory) {
return new MainComponentsRegistry(componentFactory);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.metamask.newarchitecture.modules;

import com.facebook.jni.HybridData;
import com.facebook.react.ReactPackage;
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.soloader.SoLoader;
import java.util.List;

/**
* Class responsible to load the TurboModules. This class has native methods and needs a
* corresponding C++ implementation/header file to work correctly (already placed inside the jni/
* folder for you).
*
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
* `newArchEnabled` property). Is ignored otherwise.
*/
public class MainApplicationTurboModuleManagerDelegate
extends ReactPackageTurboModuleManagerDelegate {

private static volatile boolean sIsSoLibraryLoaded;

protected MainApplicationTurboModuleManagerDelegate(
ReactApplicationContext reactApplicationContext, List<ReactPackage> packages) {
super(reactApplicationContext, packages);
}

protected native HybridData initHybrid();

native boolean canCreateTurboModule(String moduleName);

public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder {
protected MainApplicationTurboModuleManagerDelegate build(
ReactApplicationContext context, List<ReactPackage> packages) {
return new MainApplicationTurboModuleManagerDelegate(context, packages);
}
}

@Override
protected synchronized void maybeLoadOtherSoLibraries() {
if (!sIsSoLibraryLoaded) {
// If you change the name of your application .so file in the Android.mk file,
// make sure you update the name here as well.
SoLoader.loadLibrary("rndiffapp_appmodules");
sIsSoLibraryLoaded = true;
}
}
}
7 changes: 7 additions & 0 deletions android/app/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.13)

# Define the library name here.
project(rndiffapp_appmodules)

# This file includes all the necessary to let you build your application with the New Architecture.
include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake)
Loading