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

Migration/turbo modules #2

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ example/ios/build
example/ios/Pods
example/ios/Podfile.lock
example/ios/E2eeExample.xcodeproj
example/ios/E2eeExample.xcworkspace
example/ios/E2eeExample.xcworkspace
11 changes: 0 additions & 11 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,3 @@ cmake_minimum_required(VERSION 3.4.1)

set (CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_CXX_STANDARD 11)

add_library(cpp
SHARED
../cpp/react-native-e2ee.cpp
cpp-adapter.cpp
)

# Specifies a path to native header files.
include_directories(
../cpp
)
22 changes: 9 additions & 13 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
import com.android.Version

apply plugin: "com.android.library"
apply plugin: "org.jetbrains.kotlin.android"

buildscript {
ext.kotlin_version = '1.8.22'
ext.kotlin_version = "1.9.0"

repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.2"
classpath "com.android.tools.build:gradle:8.3.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

apply plugin: 'kotlin-android'

def _minSdkVersion = ((rootProject?.ext?.properties?.minSdkVersion) ?: 24)

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}

apply plugin: "com.android.library"

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}
Expand Down Expand Up @@ -136,13 +135,10 @@ dependencies {
androidTestImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.0'
androidTestRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.0'

androidTestImplementation "androidx.test:runner:1.5.0"
// androidTestImplementation "androidx.test:rules:1.5.0"
androidTestImplementation "androidx.test:runner:1.5.0"

implementation("androidx.core:core-ktx:1.12.0")
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
// noinspection GradleDynamicVersion
implementation "com.facebook.react:react-android:0.72.7"
implementation("androidx.core:core-ktx:1.12.0")
}
4 changes: 2 additions & 2 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
E2ee_kotlinVersion=1.8.22
E2ee_minSdkVersion=23
E2ee_kotlinVersion=1.9.0
E2ee_minSdkVersion=21
E2ee_targetSdkVersion=34
E2ee_compileSdkVersion=34
E2ee_ndkVersion=26.1.10909125
Expand Down
16 changes: 7 additions & 9 deletions android/src/main/java/com/e2ee/E2eePackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@
import java.util.Collections;
import java.util.List;

public class E2eePackage implements ReactPackage {
@NonNull
public class E2eePackage extends TurboReactPackage {

@Nullable
@Override
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new E2eeModule(reactContext));
return modules;
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
return null;
}

@NonNull
@Override
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
return Collections.emptyList();
public ReactModuleInfoProvider getReactModuleInfoProvider() {
return null;
}
}
7 changes: 0 additions & 7 deletions cpp/react-native-e2ee.cpp

This file was deleted.

8 changes: 0 additions & 8 deletions cpp/react-native-e2ee.h

This file was deleted.

4 changes: 2 additions & 2 deletions example/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ 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.13'
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
gem 'cocoapods', '>= 1.13', '< 1.15'
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
10 changes: 4 additions & 6 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"

/**
Expand Down Expand Up @@ -71,7 +72,8 @@ def jscFlavor = 'org.webkit:android-jsc:+'
android {
ndkVersion rootProject.ext.ndkVersion

compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion

namespace "com.e2eeexample"
defaultConfig {
Expand Down Expand Up @@ -107,12 +109,8 @@ dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
implementation("com.facebook.react:flipper-integration")

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
Expand Down
4 changes: 1 addition & 3 deletions example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@
<application
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
</application>
tools:ignore="GoogleAppIndexingWarning"/>
</manifest>

This file was deleted.

22 changes: 22 additions & 0 deletions example/android/app/src/main/java/com/e2eeexample/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.com.e2eeexample

import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate

class MainActivity : ReactActivity() {

/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override fun getMainComponentName(): String = "E2eeExample"

/**
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
*/
override fun createReactActivityDelegate(): ReactActivityDelegate =
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

package com.e2eeexample

import android.app.Application
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.flipper.ReactNativeFlipper
import com.facebook.soloader.SoLoader

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())
}

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(this.applicationContext, reactNativeHost)

override fun onCreate() {
super.onCreate()
SoLoader.init(this, false)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager)
}
}

This file was deleted.

8 changes: 6 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 23
buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34
kotlinVersion = "1.9.0"

// We use NDK >=23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "26.1.10909125"
Expand All @@ -17,5 +18,8 @@ buildscript {
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}

apply plugin: "com.facebook.react.rootproject"
3 changes: 0 additions & 3 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.182.0

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
Expand Down
Loading