chore: Upgrade React Native (#2893) [skip e2e]

This commit is contained in:
Aman Harwara
2025-04-21 21:27:09 +05:30
committed by GitHub
parent b6f2c06f30
commit 03bacd2169
259 changed files with 2368 additions and 1656 deletions

View File

@@ -10,6 +10,8 @@ ruby "2.7.6"
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
gem 'xcodeproj', '< 1.26.0'
gem 'concurrent-ruby', '< 1.3.4'
gem 'fastlane'
gem 'fastlane-plugin-bundletool'
gem 'xcode-install'

View File

@@ -63,14 +63,14 @@ def enableProguardInReleaseBuilds = false
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
* `def jscFlavor = io.github.react-native-community:jsc-android-intl:2026004.+`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
def appVersionCode = project.hasProperty('versionCode') ? Integer.valueOf(project.property('versionCode')) : 1
def appVersionName = project.hasProperty('versionName') ? project.property('versionName') : "1.0"

View File

@@ -62,7 +62,7 @@ public class CustomWebViewManager extends RNCWebViewManager {
@Override
public RNCWebViewWrapper createViewInstance(ThemedReactContext reactContext) {
return super.createViewInstance(reactContext, new CustomWebView(reactContext));
return super.createViewInstance(reactContext);
}
@Override

View File

@@ -1,142 +0,0 @@
package com.standardnotes;
import android.app.Application;
import android.app.Activity;
import android.webkit.WebView;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.Field;
import java.util.List;
import com.facebook.react.modules.network.OkHttpClientProvider;
import android.annotation.SuppressLint;
import android.database.CursorWindow;
import android.os.Bundle;
import android.view.WindowManager;
import com.kristiansorens.flagsecure.FlagSecure;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new Fido2ApiPackage());
packages.add(new CustomWebViewPackage());
packages.add(new ReceiveSharingIntentPackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
@Override
protected boolean isNewArchEnabled() {
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
}
@Override
protected Boolean isHermesEnabled() {
return BuildConfig.IS_HERMES_ENABLED;
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@SuppressLint("NewApi")
@Override
public void onCreate() {
super.onCreate();
// Enable Remote debugging for WebViews
String packageName = getApplicationContext().getPackageName();
if (packageName.equals("com.standardnotes.dev")) {
WebView.setWebContentsDebuggingEnabled(true);
}
rebuildOkHtttp();
SoLoader.init(this, /* native exopackage */ false);
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
DefaultNewArchitectureEntryPoint.load();
}
try {
/*
* This attempts to fix an error when loading big items fails so we try to change it to 10MB.
* This API is only available from API 28 so it might fail on older devices.
* Row too big to fit into CursorWindow requiredPos=0, totalRows=1
*/
Field field = CursorWindow.class.getDeclaredField("sCursorWindowSize");
field.setAccessible(true);
field.set(null, 10 * 1024 * 1024);
} catch (Exception e) {
e.printStackTrace();
}
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
@Override
public void onActivityStarted(Activity activity) {
if(FlagSecure.instance != null && FlagSecure.instance.enabled) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
}
@Override
public void onActivityResumed(Activity activity) {
}
@Override
public void onActivityPaused(Activity activity) {
}
@Override
public void onActivityStopped(Activity activity) {
}
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override
public void onActivityDestroyed(Activity activity) {
}
});
}
private void rebuildOkHtttp() {
OkHttpClientProvider.setOkHttpClientFactory(new CustomClientFactory());
}
}

View File

@@ -0,0 +1,106 @@
package com.standardnotes
import android.annotation.SuppressLint
import android.app.Activity
import android.app.Application
import android.database.CursorWindow
import android.os.Bundle
import android.view.WindowManager
import android.webkit.WebView
import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.react.ReactHost
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.modules.network.OkHttpClientProvider
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.soloader.SoLoader
import com.kristiansorens.flagsecure.FlagSecure
import java.io.IOException
import java.lang.reflect.Field
class MainApplication : Application(), ReactApplication {
override val reactNativeHost: ReactNativeHost = object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
add(Fido2ApiPackage())
add(CustomWebViewPackage())
add(ReceiveSharingIntentPackage())
}
override fun getJSMainModuleName(): String = "index"
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}
override val reactHost: ReactHost
get() = getDefaultReactHost(applicationContext, reactNativeHost)
@SuppressLint("NewApi")
override fun onCreate() {
super.onCreate()
// Enable Remote debugging for WebViews
val packageName = applicationContext.packageName
if (packageName == "com.standardnotes.dev") {
WebView.setWebContentsDebuggingEnabled(true)
}
rebuildOkHttp()
try {
SoLoader.init(this, OpenSourceMergedSoMapping)
} catch (e: IOException) {
throw RuntimeException(e)
}
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
load()
}
try {
// Increase CursorWindow size to avoid "Row too big" issue
val field: Field = CursorWindow::class.java.getDeclaredField("sCursorWindowSize")
field.isAccessible = true
field.set(null, 10 * 1024 * 1024)
} catch (e: Exception) {
e.printStackTrace()
}
registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
activity.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
}
override fun onActivityStarted(activity: Activity) {
if (FlagSecure.instance != null && FlagSecure.instance!!.enabled) {
activity.window.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
}
}
override fun onActivityResumed(activity: Activity) {}
override fun onActivityPaused(activity: Activity) {}
override fun onActivityStopped(activity: Activity) {}
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
override fun onActivityDestroyed(activity: Activity) {}
})
}
private fun rebuildOkHttp() {
OkHttpClientProvider.setOkHttpClientFactory(CustomClientFactory())
}
}

View File

@@ -1,11 +1,11 @@
buildscript {
ext {
buildToolsVersion = "34.0.0"
buildToolsVersion = "35.0.0"
minSdkVersion = 28
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.24"
compileSdkVersion = 35
targetSdkVersion = 35
ndkVersion = "27.1.12297006"
kotlinVersion = "2.0.21"
androidXCore = "1.6.0"
}
repositories {

View File

@@ -32,7 +32,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false
newArchEnabled=true
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

View File

@@ -84,7 +84,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

File diff suppressed because it is too large Load Diff

View File

@@ -188,14 +188,15 @@ class ShareViewController: SLComposeServiceViewController {
userDefaults?.synchronize()
let url = URL(string: "\(shareProtocol)://dataUrl=\(sharedKey)")
var responder = self as UIResponder?
let selectorOpenURL = sel_registerName("openURL:")
while (responder != nil) {
if (responder?.responds(to: selectorOpenURL))! {
let _ = responder?.perform(selectorOpenURL, with: url)
var responder: UIResponder? = self
while let currentResponder = responder {
if let application = currentResponder as? UIApplication {
if let url = url {
application.open(url, options: [:], completionHandler: nil)
}
break
}
responder = responder!.next
responder = currentResponder.next
}
extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
@@ -288,7 +289,7 @@ class ShareViewController: SLComposeServiceViewController {
// Debug method to print out SharedMediaFile details in the console
func toString() {
print("[SharedMediaFile] \n\tpath: \(self.path)\n\tthumbnail: \(self.thumbnail)\n\tduration: \(self.duration)\n\ttype: \(self.type)")
print("[SharedMediaFile] \n\tpath: \(self.path)\n\tthumbnail: \(String(describing: self.thumbnail))\n\tduration: \(String(describing: self.duration))\n\ttype: \(self.type)")
}
}

View File

@@ -1,6 +1,7 @@
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <ReactAppDependencyProvider/RCTAppDependencyProvider.h>
#import <React/RCTLinkingManager.h>
#import <WebKit/WKWebsiteDataStore.h>
#import <TrustKit/TrustKit.h>
@@ -25,6 +26,7 @@
[self clearWebEditorCache];
self.moduleName = @"StandardNotes";
self.dependencyProvider = [RCTAppDependencyProvider new];
self.initialProps = @{};
BOOL success = [super application:application didFinishLaunchingWithOptions:launchOptions];

View File

@@ -86,25 +86,6 @@
<string>Photo library is optionally used to select files to upload or QR code images from your photo library.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone is optionally used to capture videos.</string>
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
<string>Entypo.ttf</string>
<string>EvilIcons.ttf</string>
<string>Feather.ttf</string>
<string>FontAwesome.ttf</string>
<string>FontAwesome5_Brands.ttf</string>
<string>FontAwesome5_Regular.ttf</string>
<string>FontAwesome5_Solid.ttf</string>
<string>Foundation.ttf</string>
<string>Ionicons.ttf</string>
<string>MaterialIcons.ttf</string>
<string>MaterialCommunityIcons.ttf</string>
<string>SimpleLineIcons.ttf</string>
<string>Octicons.ttf</string>
<string>Zocial.ttf</string>
<string>Fontisto.ttf</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>

View File

@@ -67,25 +67,6 @@
<string>Not used by application; required in configuration because API exists in build dependencies.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Photo library is required to select QR code images from your photo library.</string>
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
<string>Entypo.ttf</string>
<string>EvilIcons.ttf</string>
<string>Feather.ttf</string>
<string>FontAwesome.ttf</string>
<string>FontAwesome5_Brands.ttf</string>
<string>FontAwesome5_Regular.ttf</string>
<string>FontAwesome5_Solid.ttf</string>
<string>Foundation.ttf</string>
<string>Ionicons.ttf</string>
<string>MaterialIcons.ttf</string>
<string>MaterialCommunityIcons.ttf</string>
<string>SimpleLineIcons.ttf</string>
<string>Octicons.ttf</string>
<string>Zocial.ttf</string>
<string>Fontisto.ttf</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>

View File

@@ -19,7 +19,7 @@ const defaultConfig = getDefaultConfig(__dirname)
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('metro-config').MetroConfig}
* @type {import('@react-native/metro-config').MetroConfig}
*/
const config = {
watchFolders: [path.resolve(__dirname, '../snjs')],

View File

@@ -30,17 +30,20 @@
"devDependencies": {
"@babel/core": "*",
"@babel/preset-typescript": "^7.18.6",
"@babel/runtime": "^7.20.1",
"@react-native-async-storage/async-storage": "1.19.3",
"@react-native/babel-preset": "0.75.3",
"@react-native/eslint-config": "0.75.3",
"@react-native/metro-config": "0.75.3",
"@babel/runtime": "^7.25.0",
"@react-native-async-storage/async-storage": "2.1.2",
"@react-native-community/cli": "15.0.1",
"@react-native-community/cli-platform-android": "15.0.1",
"@react-native-community/cli-platform-ios": "15.0.1",
"@react-native/babel-preset": "0.78.1",
"@react-native/eslint-config": "0.78.1",
"@react-native/metro-config": "0.78.1",
"@standardnotes/config": "^2.4.3",
"@standardnotes/react-native-utils": "1.0.1",
"@standardnotes/snjs": "workspace:*",
"@standardnotes/web": "workspace:*",
"@tsconfig/react-native": "^3.0.2",
"@types/react": "^18.2.39",
"@types/react": "^19.1.2",
"@types/react-native": "^0.72.3",
"@typescript-eslint/eslint-plugin": "*",
"@typescript-eslint/parser": "*",
@@ -50,29 +53,29 @@
"eslint-plugin-prettier": "*",
"get-yarn-workspaces": "^1.0.2",
"npm-check-updates": "*",
"pod-install": "^0.2.0",
"pod-install": "^0.3.5",
"prettier": "*",
"prettier-plugin-organize-imports": "^3.2.0",
"react": "18.2.0",
"react-native": "0.75.3",
"react": "19.0.0",
"react-native": "0.78.1",
"react-native-file-viewer": "^2.1.5",
"react-native-fingerprint-scanner": "standardnotes/react-native-fingerprint-scanner#b55d1c0ca627a87a130f758603f12911fbac200f",
"react-native-flag-secure-android": "standardnotes/react-native-flag-secure-android#cb08e74583c22a5d912842459b35ebbbb4bcd852",
"react-native-fs": "^2.20.0",
"react-native-iap": "^12.15.4",
"react-native-iap": "^12.16.2",
"react-native-keychain": "standardnotes/react-native-keychain#4fd687461cecfa26d482d820ee43c0de61b964d4",
"react-native-mmkv": "^2.6.2",
"react-native-mmkv": "^3.2.0",
"react-native-privacy-snapshot": "standardnotes/react-native-privacy-snapshot#653e904c90fc6f2b578da59138f2bfe5d7f942fe",
"react-native-share": "^10.0.0",
"react-native-share": "^12.0.9",
"react-native-version-info": "^1.1.1",
"react-native-webview": "13.12.2",
"react-native-webview": "13.13.5",
"typescript": "*"
},
"engines": {
"node": ">=16"
},
"dependencies": {
"@notifee/react-native": "^7.8.0",
"react-native-store-review": "^0.4.1"
"@notifee/react-native": "^9.1.8",
"react-native-store-review": "^0.4.3"
}
}

View File

@@ -58,7 +58,7 @@ export class ReceivedSharedItemsHandler {
private receivedItemsQueue: ReceivedItem[] = []
private isApplicationLaunched = false
constructor(private webViewRef: RefObject<WebView>) {
constructor(private webViewRef: RefObject<WebView | null>) {
this.registerNativeEventSub()
}