-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hello everyone, the support for new architecture (fabric) is finally landing 🚀 . I've taken a lot of time but I've had to re-understand the whole codebase, the old arch, the new arch, and I did not want to take too many shortcuts. This release should be mostly non breaking (except for a few well deserved props removals). HOWEVER, this is a lot of code over a lot of time. Mistakes can happen, if you feel unsafe stick to v11 for a lil' while. Finally this will unblock many PR (sorry for the conflicts in advance), so let's get releasing again 🔥 If you appreciate my work please to [sponsor me](https://github.com/sponsors/Titozzz) BREAKING CHANGE: - If you are using custom native implementation are still possible on the old arch but many classes were moved / renamed so they will need some changes - removed the following props: androidHardwareAccelerationDisabled (deprecated), urlPrefixesForDefaultIntent (unused)
- Loading branch information
1 parent
75908b3
commit 4e349b9
Showing
59 changed files
with
7,324 additions
and
5,660 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,137 +1,91 @@ | ||
buildscript { | ||
ext.getExtOrDefault = {name -> | ||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeWebView_' + name] | ||
} | ||
import java.nio.file.Paths | ||
|
||
// The Android Gradle plugin is only required when opening the android folder stand-alone. | ||
// This avoids unnecessary downloads and potential conflicts when the library is included as a | ||
// module dependency in an application project. | ||
if (project == rootProject) { | ||
repositories { | ||
mavenCentral() | ||
google() | ||
} | ||
|
||
dependencies { | ||
classpath("com.android.tools.build:gradle:3.6.0") | ||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}") | ||
buildscript { | ||
ext.safeExtGet = {prop -> | ||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : project.properties['ReactNativeWebView_' + prop] | ||
} | ||
} else { | ||
repositories { | ||
mavenCentral() | ||
google() | ||
gradlePluginPortal() | ||
} | ||
|
||
dependencies { | ||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}") | ||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion')}") | ||
classpath("com.android.tools.build:gradle:7.0.4") | ||
} | ||
} | ||
} | ||
|
||
def getExtOrIntegerDefault(name) { | ||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativeWebView_' + name]).toInteger() | ||
def getExtOrIntegerDefault(prop) { | ||
return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : (project.properties['ReactNativeWebView_' + prop]).toInteger() | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') | ||
defaultConfig { | ||
minSdkVersion getExtOrIntegerDefault('minSdkVersion') | ||
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
static def findNodeModulePath(baseDir, packageName) { | ||
def basePath = baseDir.toPath().normalize() | ||
// Node's module resolution algorithm searches up to the root directory, | ||
// after which the base path will be null | ||
while (basePath) { | ||
def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName) | ||
if (candidatePath.toFile().exists()) { | ||
return candidatePath.toString() | ||
} | ||
basePath = basePath.getParent() | ||
} | ||
} | ||
lintOptions { | ||
disable 'GradleCompatible' | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
return null | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
google() | ||
|
||
def found = false | ||
def defaultDir = null | ||
def androidSourcesName = 'React Native sources' | ||
|
||
if (rootProject.ext.has('reactNativeAndroidRoot')) { | ||
defaultDir = rootProject.ext.get('reactNativeAndroidRoot') | ||
} else { | ||
defaultDir = new File( | ||
projectDir, | ||
'/../../../node_modules/react-native/android' | ||
) | ||
} | ||
|
||
if (defaultDir.exists()) { | ||
maven { | ||
url defaultDir.toString() | ||
name androidSourcesName | ||
} | ||
|
||
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}") | ||
found = true | ||
} else { | ||
def parentDir = rootProject.projectDir | ||
def isNewArchitectureEnabled() { | ||
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" | ||
} | ||
|
||
1.upto(5, { | ||
if (found) return true | ||
parentDir = parentDir.parentFile | ||
|
||
def androidSourcesDir = new File( | ||
parentDir, | ||
'node_modules/react-native' | ||
) | ||
apply plugin: 'com.android.library' | ||
if (isNewArchitectureEnabled()) { | ||
apply plugin: 'com.facebook.react' | ||
} | ||
apply plugin: 'kotlin-android' | ||
|
||
def androidPrebuiltBinaryDir = new File( | ||
parentDir, | ||
'node_modules/react-native/android' | ||
) | ||
android { | ||
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') | ||
|
||
if (androidPrebuiltBinaryDir.exists()) { | ||
maven { | ||
url androidPrebuiltBinaryDir.toString() | ||
name androidSourcesName | ||
} | ||
defaultConfig { | ||
minSdkVersion getExtOrIntegerDefault('minSdkVersion') | ||
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') | ||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() | ||
} | ||
|
||
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}") | ||
found = true | ||
} else if (androidSourcesDir.exists()) { | ||
maven { | ||
url androidSourcesDir.toString() | ||
name androidSourcesName | ||
sourceSets { | ||
main { | ||
if (isNewArchitectureEnabled()) { | ||
java.srcDirs += ['src/newarch'] | ||
} else { | ||
java.srcDirs += ['src/oldarch'] | ||
} | ||
} | ||
} | ||
} | ||
|
||
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}") | ||
found = true | ||
} | ||
}) | ||
} | ||
def reactNativePath = findNodeModulePath(projectDir, "react-native") | ||
def codegenPath = findNodeModulePath(projectDir, "react-native-codegen") | ||
|
||
if (!found) { | ||
throw new GradleException( | ||
"${project.name}: unable to locate React Native android sources. " + | ||
"Ensure you have you installed React Native as a dependency in your project and try again." | ||
) | ||
} | ||
repositories { | ||
maven { | ||
url "${reactNativePath}/android" | ||
} | ||
mavenCentral() | ||
google() | ||
} | ||
|
||
def kotlin_version = getExtOrDefault('kotlinVersion') | ||
def webkit_version = getExtOrDefault('webkitVersion') | ||
|
||
dependencies { | ||
//noinspection GradleDynamicVersion | ||
implementation 'com.facebook.react:react-native:+' | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
implementation "androidx.webkit:webkit:$webkit_version" | ||
implementation 'com.facebook.react:react-native:+' | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib:${safeExtGet('kotlinVersion')}" | ||
implementation "androidx.webkit:webkit:${safeExtGet('webkitVersion')}" | ||
} | ||
|
||
if (isNewArchitectureEnabled()) { | ||
react { | ||
jsRootDir = file("../src/") | ||
libraryName = "rncwebview" | ||
codegenJavaPackageName = "com.reactnativecommunity.webview" | ||
codegenDir = new File(codegenPath) | ||
reactNativeDir = new File(reactNativePath) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
ReactNativeWebView_kotlinVersion=1.6.0 | ||
ReactNativeWebView_webkitVersion=1.4.0 | ||
ReactNativeWebView_compileSdkVersion=29 | ||
ReactNativeWebView_buildToolsVersion=29.0.3 | ||
ReactNativeWebView_targetSdkVersion=28 | ||
ReactNativeWebView_compileSdkVersion=31 | ||
ReactNativeWebView_targetSdkVersion=31 | ||
ReactNativeWebView_minSdkVersion=21 |
11 changes: 11 additions & 0 deletions
11
android/src/main/java/com/reactnativecommunity/webview/RNCBasicAuthCredential.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.reactnativecommunity.webview; | ||
|
||
class RNCBasicAuthCredential { | ||
String username; | ||
String password; | ||
|
||
RNCBasicAuthCredential(String username, String password) { | ||
this.username = username; | ||
this.password = password; | ||
} | ||
} |
Oops, something went wrong.