Revert "Codemod format for trailing commas change"

This reverts commit d1a1020a4a.
This commit is contained in:
Riccardo Cipolleschi
2025-08-20 14:10:22 +01:00
parent 9915efb275
commit c658dfcc28
230 changed files with 1547 additions and 2348 deletions
+12 -24
View File
@@ -26,12 +26,10 @@ fun getListReactAndroidProperty(name: String) = reactAndroidProperties.getProper
apiValidation {
ignoredPackages.addAll(
getListReactAndroidProperty("binaryCompatibilityValidator.ignoredPackages")
)
getListReactAndroidProperty("binaryCompatibilityValidator.ignoredPackages"))
ignoredClasses.addAll(getListReactAndroidProperty("binaryCompatibilityValidator.ignoredClasses"))
nonPublicMarkers.addAll(
getListReactAndroidProperty("binaryCompatibilityValidator.nonPublicMarkers")
)
getListReactAndroidProperty("binaryCompatibilityValidator.nonPublicMarkers"))
validationDisabled =
reactAndroidProperties
.getProperty("binaryCompatibilityValidator.validationDisabled")
@@ -39,9 +37,8 @@ apiValidation {
}
version =
if (
project.hasProperty("isSnapshot") && (project.property("isSnapshot") as? String).toBoolean()
) {
if (project.hasProperty("isSnapshot") &&
(project.property("isSnapshot") as? String).toBoolean()) {
"${reactAndroidProperties.getProperty("VERSION_NAME")}-SNAPSHOT"
} else {
reactAndroidProperties.getProperty("VERSION_NAME")
@@ -69,10 +66,8 @@ tasks.register("clean", Delete::class.java) {
description = "Remove all the build files and intermediate build outputs"
dependsOn(gradle.includedBuild("gradle-plugin").task(":clean"))
subprojects.forEach {
if (
it.project.plugins.hasPlugin("com.android.library") ||
it.project.plugins.hasPlugin("com.android.application")
) {
if (it.project.plugins.hasPlugin("com.android.library") ||
it.project.plugins.hasPlugin("com.android.application")) {
dependsOn(it.tasks.named("clean"))
}
}
@@ -82,13 +77,10 @@ tasks.register("clean", Delete::class.java) {
delete(rootProject.file("./packages/react-native/sdks/download/"))
delete(rootProject.file("./packages/react-native/sdks/hermes/"))
delete(
rootProject.file("./packages/react-native/ReactAndroid/src/main/jni/prebuilt/lib/arm64-v8a/")
)
rootProject.file("./packages/react-native/ReactAndroid/src/main/jni/prebuilt/lib/arm64-v8a/"))
delete(
rootProject.file(
"./packages/react-native/ReactAndroid/src/main/jni/prebuilt/lib/armeabi-v7a/"
)
)
"./packages/react-native/ReactAndroid/src/main/jni/prebuilt/lib/armeabi-v7a/"))
delete(rootProject.file("./packages/react-native/ReactAndroid/src/main/jni/prebuilt/lib/x86/"))
delete(rootProject.file("./packages/react-native/ReactAndroid/src/main/jni/prebuilt/lib/x86_64/"))
delete(rootProject.file("./packages/react-native-codegen/lib"))
@@ -106,8 +98,7 @@ tasks.register("publishAllToMavenTempLocal") {
dependsOn(":packages:react-native:ReactAndroid:publishAllPublicationsToMavenTempLocalRepository")
// We don't publish the external-artifacts to Maven Local as ci is using it via workspace.
dependsOn(
":packages:react-native:ReactAndroid:hermes-engine:publishAllPublicationsToMavenTempLocalRepository"
)
":packages:react-native:ReactAndroid:hermes-engine:publishAllPublicationsToMavenTempLocalRepository")
}
tasks.register("publishAndroidToSonatype") {
@@ -129,8 +120,7 @@ if (project.findProperty("react.internal.useHermesNightly")?.toString()?.toBoole
That's fine for local development, but you should not commit this change.
********************************************************************************
"""
.trimIndent()
)
.trimIndent())
allprojects {
configurations.all {
resolutionStrategy.dependencySubstitution {
@@ -162,12 +152,10 @@ allprojects {
"**/build/**",
"**/hermes-engine/**",
"**/internal/featureflags/**",
"**/systeminfo/ReactNativeVersion.kt",
)
"**/systeminfo/ReactNativeVersion.kt")
listOf(
com.ncorti.ktfmt.gradle.tasks.KtfmtCheckTask::class,
com.ncorti.ktfmt.gradle.tasks.KtfmtFormatTask::class,
)
com.ncorti.ktfmt.gradle.tasks.KtfmtFormatTask::class)
.forEach { tasks.withType(it) { exclude(excludePatterns) } }
// Disable the problematic ktfmt script tasks due to symbolic link issues in subprojects
@@ -68,8 +68,7 @@ tasks.withType<KotlinCompile>().configureEach {
// See comment above on JDK 11 support
jvmTarget.set(JvmTarget.JVM_11)
allWarningsAsErrors.set(
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
)
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false)
}
}
@@ -208,8 +208,7 @@ abstract class ReactExtension @Inject constructor(val project: Project) {
} else {
buildTypes.forEach { buildType ->
result.add(
(dependencyConfiguration ?: "${buildType}Implementation") to ":$nameCleansed"
)
(dependencyConfiguration ?: "${buildType}Implementation") to ":$nameCleansed")
}
}
}
@@ -112,8 +112,7 @@ class ReactPlugin : Plugin<Project> {
********************************************************************************
"""
.trimIndent()
)
.trimIndent())
exitProcess(1)
}
}
@@ -187,8 +186,7 @@ class ReactPlugin : Plugin<Project> {
// We want to exclude the build directory, to don't pick them up for execution
// avoidance.
tree.exclude("**/build/**/*")
}
)
})
val needsCodegenFromPackageJson = project.needsCodegenFromPackageJson(rootExtension.root)
it.onlyIf { (isLibrary || needsCodegenFromPackageJson) && !includesGeneratedCode }
@@ -305,8 +303,7 @@ class ReactPlugin : Plugin<Project> {
project.extensions.getByType(ApplicationAndroidComponentsExtension::class.java).apply {
onVariants(selector().all()) { variant ->
variant.sources.java?.addStaticSourceDirectory(
generatedAutolinkingJavaDir.get().asFile.absolutePath
)
generatedAutolinkingJavaDir.get().asFile.absolutePath)
}
}
}
@@ -59,12 +59,10 @@ class ReactRootProjectPlugin : Plugin<Project> {
}
private fun checkLegacyArchProperty(project: Project) {
if (
(project.hasProperty(PropertyUtils.NEW_ARCH_ENABLED) &&
!project.property(PropertyUtils.NEW_ARCH_ENABLED).toString().toBoolean()) ||
(project.hasProperty(PropertyUtils.SCOPED_NEW_ARCH_ENABLED) &&
!project.property(PropertyUtils.SCOPED_NEW_ARCH_ENABLED).toString().toBoolean())
) {
if ((project.hasProperty(PropertyUtils.NEW_ARCH_ENABLED) &&
!project.property(PropertyUtils.NEW_ARCH_ENABLED).toString().toBoolean()) ||
(project.hasProperty(PropertyUtils.SCOPED_NEW_ARCH_ENABLED) &&
!project.property(PropertyUtils.SCOPED_NEW_ARCH_ENABLED).toString().toBoolean())) {
project.logger.error(
"""
********************************************************************************
@@ -79,8 +77,7 @@ class ReactRootProjectPlugin : Plugin<Project> {
********************************************************************************
"""
.trimIndent()
)
.trimIndent())
}
}
}
@@ -54,11 +54,9 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio
configureNewArchPackagingOptions(project, config, variant)
configureJsEnginePackagingOptions(config, variant, isHermesEnabledInThisVariant, useThirdPartyJSC)
if (
!isHermesEnabledInThisVariant &&
!useThirdPartyJSC &&
rootProject.name != "react-native-github"
) {
if (!isHermesEnabledInThisVariant &&
!useThirdPartyJSC &&
rootProject.name != "react-native-github") {
showJSCRemovalMessage(project)
}
@@ -39,15 +39,12 @@ abstract class PrivateReactExtension @Inject constructor(project: Project) {
// - We're inside a user project, so inside the ./android folder. Default should be
// ../
// User can always override this default by setting a `root =` inside the template.
if (
project.rootProject.name == "react-native-github" ||
project.rootProject.name == "react-native-build-from-source"
) {
if (project.rootProject.name == "react-native-github" ||
project.rootProject.name == "react-native-build-from-source") {
project.rootProject.layout.projectDirectory.dir("../../")
} else {
project.rootProject.layout.projectDirectory.dir("../")
}
)
})
val reactNativeDir: DirectoryProperty =
objects.directoryProperty().convention(root.dir("node_modules/react-native"))
@@ -165,88 +165,88 @@ abstract class GenerateAutolinkingNewArchitecturesFileTask : DefaultTask() {
// language=cmake
val CMAKE_TEMPLATE =
"""
# This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin)
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
# We set REACTNATIVE_MERGED_SO so libraries/apps can selectively decide to depend on either libreactnative.so
# or link against a old prefab target (this is needed for React Native 0.76 on).
set(REACTNATIVE_MERGED_SO true)
{{ libraryIncludes }}
set(AUTOLINKED_LIBRARIES
{{ libraryModules }}
)
"""
# This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin)
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
# We set REACTNATIVE_MERGED_SO so libraries/apps can selectively decide to depend on either libreactnative.so
# or link against a old prefab target (this is needed for React Native 0.76 on).
set(REACTNATIVE_MERGED_SO true)
{{ libraryIncludes }}
set(AUTOLINKED_LIBRARIES
{{ libraryModules }}
)
"""
.trimIndent()
// language=cpp
val CPP_TEMPLATE =
"""
/**
* This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
*/
#include "autolinking.h"
{{ autolinkingCppIncludes }}
namespace facebook {
namespace react {
std::shared_ptr<TurboModule> autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams &params) {
{{ autolinkingCppTurboModuleJavaProviders }}
return nullptr;
}
std::shared_ptr<TurboModule> autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr<CallInvoker>& jsInvoker) {
{{ autolinkingCppTurboModuleCxxProviders }}
return nullptr;
}
void autolinking_registerProviders(std::shared_ptr<ComponentDescriptorProviderRegistry const> providerRegistry) {
{{ autolinkingCppComponentDescriptors }}
return;
}
} // namespace react
} // namespace facebook
"""
/**
* This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
*/
#include "autolinking.h"
{{ autolinkingCppIncludes }}
namespace facebook {
namespace react {
std::shared_ptr<TurboModule> autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams &params) {
{{ autolinkingCppTurboModuleJavaProviders }}
return nullptr;
}
std::shared_ptr<TurboModule> autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr<CallInvoker>& jsInvoker) {
{{ autolinkingCppTurboModuleCxxProviders }}
return nullptr;
}
void autolinking_registerProviders(std::shared_ptr<ComponentDescriptorProviderRegistry const> providerRegistry) {
{{ autolinkingCppComponentDescriptors }}
return;
}
} // namespace react
} // namespace facebook
"""
.trimIndent()
// language=cpp
val hTemplate =
"""
/**
* This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
*/
#pragma once
#include <ReactCommon/CallInvoker.h>
#include <ReactCommon/JavaTurboModule.h>
#include <ReactCommon/TurboModule.h>
#include <jsi/jsi.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
namespace facebook {
namespace react {
std::shared_ptr<TurboModule> autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams &params);
std::shared_ptr<TurboModule> autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr<CallInvoker>& jsInvoker);
void autolinking_registerProviders(std::shared_ptr<ComponentDescriptorProviderRegistry const> providerRegistry);
} // namespace react
} // namespace facebook
"""
/**
* This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
*/
#pragma once
#include <ReactCommon/CallInvoker.h>
#include <ReactCommon/JavaTurboModule.h>
#include <ReactCommon/TurboModule.h>
#include <jsi/jsi.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
namespace facebook {
namespace react {
std::shared_ptr<TurboModule> autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams &params);
std::shared_ptr<TurboModule> autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr<CallInvoker>& jsInvoker);
void autolinking_registerProviders(std::shared_ptr<ComponentDescriptorProviderRegistry const> providerRegistry);
} // namespace react
} // namespace facebook
"""
.trimIndent()
}
}
@@ -82,7 +82,6 @@ abstract class GenerateCodegenArtifactsTask : Exec() {
libraryName,
"--javaPackageName",
codegenJavaPackageName,
)
)
))
}
}
@@ -69,7 +69,6 @@ abstract class GenerateCodegenSchemaTask : Exec() {
"NativeSampleTurboModule",
generatedSchemaFile.get().asFile.cliPath(workingDir),
jsRootDir.asFile.get().cliPath(workingDir),
)
)
))
}
}
@@ -32,19 +32,17 @@ abstract class GenerateEntryPointTask : DefaultTask() {
JsonUtils.fromAutolinkingConfigJson(autolinkInputFile.get().asFile)
?: error(
"""
RNGP - Autolinking: Could not parse autolinking config file:
${autolinkInputFile.get().asFile.absolutePath}
The file is either missing or not containing valid JSON so the build won't succeed.
"""
.trimIndent()
)
RNGP - Autolinking: Could not parse autolinking config file:
${autolinkInputFile.get().asFile.absolutePath}
The file is either missing or not containing valid JSON so the build won't succeed.
"""
.trimIndent())
val packageName =
model.project?.android?.packageName
?: error(
"RNGP - Autolinking: Could not find project.android.packageName in react-native config output! Could not autolink packages without this field."
)
"RNGP - Autolinking: Could not find project.android.packageName in react-native config output! Could not autolink packages without this field.")
val generatedFileContents = composeFileContent(packageName)
val outputDir = generatedOutputDirectory.get().asFile
@@ -64,45 +62,45 @@ abstract class GenerateEntryPointTask : DefaultTask() {
// language=java
val generatedFileContentsTemplate =
"""
package com.facebook.react;
import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
import com.facebook.react.views.view.WindowUtilKt;
import com.facebook.react.soloader.OpenSourceMergedSoMapping;
import com.facebook.soloader.SoLoader;
import java.io.IOException;
/**
* This class is the entry point for loading React Native using the configuration
* that the users specifies in their .gradle files.
*
* The `loadReactNative(this)` method invocation should be called inside the
* application onCreate otherwise the app won't load correctly.
*/
public class ReactNativeApplicationEntryPoint {
public static void loadReactNative(Context context) {
try {
SoLoader.init(context, OpenSourceMergedSoMapping.INSTANCE);
} catch (IOException error) {
throw new RuntimeException(error);
}
if ({{packageName}}.BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
DefaultNewArchitectureEntryPoint.load();
}
if ({{packageName}}.BuildConfig.IS_EDGE_TO_EDGE_ENABLED) {
WindowUtilKt.setEdgeToEdgeFeatureFlagOn();
}
package com.facebook.react;
import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
import com.facebook.react.views.view.WindowUtilKt;
import com.facebook.react.soloader.OpenSourceMergedSoMapping;
import com.facebook.soloader.SoLoader;
import java.io.IOException;
/**
* This class is the entry point for loading React Native using the configuration
* that the users specifies in their .gradle files.
*
* The `loadReactNative(this)` method invocation should be called inside the
* application onCreate otherwise the app won't load correctly.
*/
public class ReactNativeApplicationEntryPoint {
public static void loadReactNative(Context context) {
try {
SoLoader.init(context, OpenSourceMergedSoMapping.INSTANCE);
} catch (IOException error) {
throw new RuntimeException(error);
}
if ({{packageName}}.BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
DefaultNewArchitectureEntryPoint.load();
}
if ({{packageName}}.BuildConfig.IS_EDGE_TO_EDGE_ENABLED) {
WindowUtilKt.setEdgeToEdgeFeatureFlagOn();
}
}
"""
}
"""
.trimIndent()
}
}
@@ -34,19 +34,17 @@ abstract class GeneratePackageListTask : DefaultTask() {
JsonUtils.fromAutolinkingConfigJson(autolinkInputFile.get().asFile)
?: error(
"""
RNGP - Autolinking: Could not parse autolinking config file:
${autolinkInputFile.get().asFile.absolutePath}
The file is either missing or not containing valid JSON so the build won't succeed.
"""
.trimIndent()
)
RNGP - Autolinking: Could not parse autolinking config file:
${autolinkInputFile.get().asFile.absolutePath}
The file is either missing or not containing valid JSON so the build won't succeed.
"""
.trimIndent())
val packageName =
model.project?.android?.packageName
?: error(
"RNGP - Autolinking: Could not find project.android.packageName in react-native config output! Could not autolink packages without this field."
)
"RNGP - Autolinking: Could not find project.android.packageName in react-native config output! Could not autolink packages without this field.")
val androidPackages = filterAndroidPackages(model)
val packageImports = composePackageImports(packageName, androidPackages)
@@ -136,69 +134,69 @@ abstract class GeneratePackageListTask : DefaultTask() {
// language=java
val generatedFileContentsTemplate =
"""
package com.facebook.react;
import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainPackageConfig;
import com.facebook.react.shell.MainReactPackage;
import java.util.Arrays;
import java.util.ArrayList;
{{ packageImports }}
@SuppressWarnings("deprecation")
public class PackageList {
private Application application;
private ReactNativeHost reactNativeHost;
private MainPackageConfig mConfig;
public PackageList(ReactNativeHost reactNativeHost) {
this(reactNativeHost, null);
}
public PackageList(Application application) {
this(application, null);
}
public PackageList(ReactNativeHost reactNativeHost, MainPackageConfig config) {
this.reactNativeHost = reactNativeHost;
mConfig = config;
}
public PackageList(Application application, MainPackageConfig config) {
this.reactNativeHost = null;
this.application = application;
mConfig = config;
}
private ReactNativeHost getReactNativeHost() {
return this.reactNativeHost;
}
private Resources getResources() {
return this.getApplication().getResources();
}
private Application getApplication() {
if (this.reactNativeHost == null) return this.application;
return this.reactNativeHost.getApplication();
}
private Context getApplicationContext() {
return this.getApplication().getApplicationContext();
}
public ArrayList<ReactPackage> getPackages() {
return new ArrayList<>(Arrays.<ReactPackage>asList(
new MainReactPackage(mConfig){{ packageClassInstances }}
));
}
}
"""
package com.facebook.react;
import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainPackageConfig;
import com.facebook.react.shell.MainReactPackage;
import java.util.Arrays;
import java.util.ArrayList;
{{ packageImports }}
@SuppressWarnings("deprecation")
public class PackageList {
private Application application;
private ReactNativeHost reactNativeHost;
private MainPackageConfig mConfig;
public PackageList(ReactNativeHost reactNativeHost) {
this(reactNativeHost, null);
}
public PackageList(Application application) {
this(application, null);
}
public PackageList(ReactNativeHost reactNativeHost, MainPackageConfig config) {
this.reactNativeHost = reactNativeHost;
mConfig = config;
}
public PackageList(Application application, MainPackageConfig config) {
this.reactNativeHost = null;
this.application = application;
mConfig = config;
}
private ReactNativeHost getReactNativeHost() {
return this.reactNativeHost;
}
private Resources getResources() {
return this.getApplication().getResources();
}
private Application getApplication() {
if (this.reactNativeHost == null) return this.application;
return this.reactNativeHost.getApplication();
}
private Context getApplicationContext() {
return this.getApplication().getApplicationContext();
}
public ArrayList<ReactPackage> getPackages() {
return new ArrayList<>(Arrays.<ReactPackage>asList(
new MainReactPackage(mConfig){{ packageClassInstances }}
));
}
}
"""
.trimIndent()
}
}
@@ -54,8 +54,7 @@ abstract class BuildCodegenCLITask : Exec() {
windowsAwareBashCommandLine(
codegenDir.asFile.get().canonicalPath.unixifyPath().plus(BUILD_SCRIPT_PATH),
bashWindowsHome = bashWindowsHome.orNull,
)
)
))
super.exec()
}
@@ -29,10 +29,8 @@ abstract class CustomExecTask : Exec() {
@get:Input @get:Optional abstract val onlyIfProvidedPathDoesNotExists: Property<String>
override fun exec() {
if (
onlyIfProvidedPathDoesNotExists.isPresent &&
File(onlyIfProvidedPathDoesNotExists.get()).exists()
) {
if (onlyIfProvidedPathDoesNotExists.isPresent &&
File(onlyIfProvidedPathDoesNotExists.get()).exists()) {
return
}
if (standardOutputFile.isPresent) {
@@ -64,8 +64,7 @@ abstract class PrepareGflagsTask : DefaultTask() {
.replace(Regex("@GFLAGS_NAMESPACE@"), "gflags")
.replace(
Regex(
"@(HAVE_STDINT_H|HAVE_SYS_TYPES_H|HAVE_INTTYPES_H|GFLAGS_INTTYPES_FORMAT_C99)@"
),
"@(HAVE_STDINT_H|HAVE_SYS_TYPES_H|HAVE_INTTYPES_H|GFLAGS_INTTYPES_FORMAT_C99)@"),
"1",
)
.replace(Regex("@([A-Z0-9_]+)@"), "1")
@@ -61,8 +61,7 @@ abstract class PrepareGlogTask : DefaultTask() {
"ac_cv___attribute___noreturn" to "__attribute__ ((noreturn))",
"ac_cv___attribute___printf_4_5" to
"__attribute__((__format__ (__printf__, 4, 5)))",
)
),
)),
ReplaceTokens::class.java,
)
matchedFile.path = (matchedFile.name.removeSuffix(".in"))
@@ -39,8 +39,7 @@ internal object BackwardCompatUtils {
********************************************************************************
"""
.trimIndent()
)
.trimIndent())
}
}
@@ -56,14 +55,14 @@ internal object BackwardCompatUtils {
val message =
"""
=============== JavaScriptCore is being moved ===============
JavaScriptCore has been extracted from react-native core
and will be removed in a future release. It can now be
installed from `@react-native-community/javascriptcore`
See: https://github.com/react-native-community/javascriptcore
=============================================================
=============== JavaScriptCore is being moved ===============
JavaScriptCore has been extracted from react-native core
and will be removed in a future release. It can now be
installed from `@react-native-community/javascriptcore`
See: https://github.com/react-native-community/javascriptcore
=============================================================
"""
"""
.trimIndent()
project.logger.warn(message)
hasShownJSCRemovalMessage = true
@@ -33,8 +33,7 @@ internal object DependencyUtils {
val exclusiveEnterpriseRepository = project.rootProject.exclusiveEnterpriseRepository()
if (exclusiveEnterpriseRepository != null) {
project.logger.lifecycle(
"Replacing ALL Maven Repositories with: $exclusiveEnterpriseRepository"
)
"Replacing ALL Maven Repositories with: $exclusiveEnterpriseRepository")
}
project.rootProject.allprojects { eachProject ->
@@ -136,30 +135,26 @@ internal object DependencyUtils {
"com.facebook.react:react-native",
"${groupString}:react-android:${versionString}",
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.",
)
)
))
dependencySubstitution.add(
Triple(
"com.facebook.react:hermes-engine",
"${groupString}:hermes-android:${versionString}",
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.",
)
)
))
if (groupString != DEFAULT_INTERNAL_PUBLISHING_GROUP) {
dependencySubstitution.add(
Triple(
"com.facebook.react:react-android",
"${groupString}:react-android:${versionString}",
"The react-android dependency was modified to use the correct Maven group.",
)
)
))
dependencySubstitution.add(
Triple(
"com.facebook.react:hermes-android",
"${groupString}:hermes-android:${versionString}",
"The hermes-android dependency was modified to use the correct Maven group.",
)
)
))
}
return dependencySubstitution
}
@@ -45,8 +45,7 @@ internal object NdkConfiguratorUtils {
}
if (cmakeArgs.none { it.startsWith("-DREACT_ANDROID_DIR") }) {
cmakeArgs.add(
"-DREACT_ANDROID_DIR=${extension.reactNativeDir.file("ReactAndroid").get().asFile}"
)
"-DREACT_ANDROID_DIR=${extension.reactNativeDir.file("ReactAndroid").get().asFile}")
}
if (cmakeArgs.none { it.startsWith("-DANDROID_STL") }) {
cmakeArgs.add("-DANDROID_STL=c++_shared")
@@ -87,8 +86,7 @@ internal object NdkConfiguratorUtils {
"**/libjsi.so",
// AGP will give priority of libc++_shared coming from App modules.
"**/libc++_shared.so",
)
)
))
}
/**
@@ -105,14 +105,13 @@ private fun detectCliFile(reactNativeRoot: File, preconfiguredCliFile: File?): F
error(
"""
Couldn't determine CLI location!
Couldn't determine CLI location!
Please set `react { cliFile = file(...) }` inside your
build.gradle to the path of the react-native cli.js file.
This file typically resides in `node_modules/react-native/cli.js`
"""
.trimIndent()
)
Please set `react { cliFile = file(...) }` inside your
build.gradle to the path of the react-native cli.js file.
This file typically resides in `node_modules/react-native/cli.js`
"""
.trimIndent())
}
/**
@@ -161,8 +160,7 @@ internal fun detectOSAwareHermesCommand(projectRoot: File, hermesCommand: String
error(
"Couldn't determine Hermesc location. " +
"Please set `react.hermesCommand` to the path of the hermesc binary file. " +
"node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc"
)
"node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc")
}
/**
@@ -188,8 +186,7 @@ internal fun getHermesOSBin(): String {
if (Os.isLinuxAmd64()) return "linux64-bin"
error(
"OS not recognized. Please set project.react.hermesCommand " +
"to the path of a working Hermes compiler."
)
"to the path of a working Hermes compiler.")
}
internal fun projectPathToLibraryName(projectPath: String): String =
@@ -23,12 +23,11 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent()
)
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent())
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).isEmpty()
@@ -39,24 +38,23 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
}
}
}
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
}
}
"""
.trimIndent()
)
}
}
}
"""
.trimIndent())
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).containsExactly("implementation" to ":react-native_oss-library-example")
@@ -67,25 +65,24 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react",
"dependencyConfiguration": "compileOnly"
}
}
}
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react",
"dependencyConfiguration": "compileOnly"
}
}
"""
.trimIndent()
)
}
}
}
"""
.trimIndent())
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).containsExactly("compileOnly" to ":react-native_oss-library-example")
@@ -96,25 +93,24 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react",
"buildTypes": ["debug", "release"]
}
}
}
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react",
"buildTypes": ["debug", "release"]
}
}
"""
.trimIndent()
)
}
}
}
"""
.trimIndent())
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps)
@@ -129,34 +125,33 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
}
}
},
"@react-native/another-library-for-testing": {
"root": "./node_modules/@react-native/another-library-for-testing",
"name": "@react-native/another-library-for-testing",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
}
}
}
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
}
}
"""
.trimIndent()
)
},
"@react-native/another-library-for-testing": {
"root": "./node_modules/@react-native/another-library-for-testing",
"name": "@react-native/another-library-for-testing",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
}
}
}
}
}
"""
.trimIndent())
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps)
@@ -171,27 +166,26 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/oss-library-example.podspec",
"version": "0.0.0",
"configurations": [],
"scriptPhases": []
},
"android": null
}
}
}
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/oss-library-example.podspec",
"version": "0.0.0",
"configurations": [],
"scriptPhases": []
},
"android": null
}
"""
.trimIndent()
)
}
}
}
"""
.trimIndent())
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).isEmpty()
@@ -202,35 +196,34 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/android-example",
"name": "@react-native/android-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
}
}
},
"@react-native/another-library-for-testing": {
"root": "./node_modules/@react-native/cxx-testing",
"name": "@react-native/cxx-testing",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react",
"isPureCxxDependency": true
}
}
}
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/android-example",
"name": "@react-native/android-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
}
}
"""
.trimIndent()
)
},
"@react-native/another-library-for-testing": {
"root": "./node_modules/@react-native/cxx-testing",
"name": "@react-native/cxx-testing",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react",
"isPureCxxDependency": true
}
}
}
}
}
"""
.trimIndent())
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).containsExactly("implementation" to ":react-native_android-example")
@@ -41,8 +41,7 @@ class ModelAutolinkingDependenciesJsonTest {
"@this*is~a(more)complicated/example!of~weird)packages",
null,
)
.nameCleansed
)
.nameCleansed)
.isEqualTo("this_is_a_more_complicated_example_of_weird_packages")
}
}
@@ -72,11 +72,9 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
name = "a-dependency",
platforms =
ModelAutolinkingDependenciesPlatformJson(android = null),
)
),
)),
project = null,
)
)
))
assertThat(result).isEmpty()
}
@@ -103,11 +101,9 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
name = "a-dependency",
platforms =
ModelAutolinkingDependenciesPlatformJson(android = android),
)
),
)),
project = null,
)
)
))
assertThat(result).containsExactly(android)
}
@@ -134,8 +130,7 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
)
"""
.trimIndent()
)
.trimIndent())
}
@Test
@@ -165,8 +160,7 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
another_cxxModule
)
"""
.trimIndent()
)
.trimIndent())
}
@Test
@@ -210,8 +204,7 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
} // namespace react
} // namespace facebook
"""
.trimIndent()
)
.trimIndent())
}
@Test
@@ -267,8 +260,7 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
} // namespace react
} // namespace facebook
"""
.trimIndent()
)
.trimIndent())
}
@Test
@@ -148,8 +148,7 @@ class GenerateCodegenArtifactsTaskTest {
}
}
"""
.trimIndent()
)
.trimIndent())
}
val task =
@@ -178,8 +177,7 @@ class GenerateCodegenArtifactsTaskTest {
}
}
"""
.trimIndent()
)
.trimIndent())
}
val task =
@@ -86,7 +86,6 @@ class GenerateEntryPointTaskTest {
}
}
"""
.trimIndent()
)
.trimIndent())
}
}
@@ -64,8 +64,7 @@ class GeneratePackageListTaskTest {
// @react-native/another-package
import com.facebook.react.anotherPackage;
"""
.trimIndent()
)
.trimIndent())
}
@Test
@@ -89,8 +88,7 @@ class GeneratePackageListTaskTest {
new APackage(),
new AnotherPackage()
"""
.trimIndent()
)
.trimIndent())
}
@Test
@@ -149,11 +147,9 @@ class GeneratePackageListTaskTest {
name = "a-dependency",
platforms =
ModelAutolinkingDependenciesPlatformJson(android = null),
)
),
)),
project = null,
)
)
))
assertThat(result)
.isEqualTo(emptyMap<String, ModelAutolinkingDependenciesPlatformAndroidJson>())
}
@@ -181,11 +177,9 @@ class GeneratePackageListTaskTest {
name = "a-dependency",
platforms =
ModelAutolinkingDependenciesPlatformJson(android = android),
)
),
)),
project = null,
)
)
))
assertThat(result.entries.size).isEqualTo(1)
assertThat(result["a-dependency"]).isEqualTo(android)
}
@@ -214,11 +208,9 @@ class GeneratePackageListTaskTest {
name = "a-pure-cxx-dependency",
platforms =
ModelAutolinkingDependenciesPlatformJson(android = android),
)
),
)),
project = null,
)
)
))
assertThat(result)
.isEqualTo(emptyMap<String, ModelAutolinkingDependenciesPlatformAndroidJson>())
}
@@ -297,8 +289,7 @@ class GeneratePackageListTaskTest {
}
}
"""
.trimIndent()
)
.trimIndent())
}
@Test
@@ -380,8 +371,7 @@ class GeneratePackageListTaskTest {
}
}
"""
.trimIndent()
)
.trimIndent())
}
private val testDependencies =
@@ -26,8 +26,7 @@ class PrepareBoostTaskTest {
assertThatThrownBy { task.taskAction() }
.isInstanceOf(IllegalStateException::class.java)
.hasMessage(
"Cannot query the value of task ':PrepareBoostTask' property 'boostVersion' because it has no value available."
)
"Cannot query the value of task ':PrepareBoostTask' property 'boostVersion' because it has no value available.")
}
@Test
@@ -125,8 +125,7 @@ typedef unsigned __int64 uint64;
#endif
} // namespace GFLAGS_NAMESPACE
"""
)
""")
}
File(gflagspath, "gflags-1.0.0/src/config.h.in").apply {
parentFile.mkdirs()
@@ -55,8 +55,7 @@ class PreparePrefabHeadersTaskTest {
createTestTask<PreparePrefabHeadersTask>(project = project) {
it.outputDir.set(outputDir)
it.input.set(
listOf(PrefabPreprocessingEntry("sample_library", "input/" to expectedPrefix))
)
listOf(PrefabPreprocessingEntry("sample_library", "input/" to expectedPrefix)))
}
task.taskAction()
@@ -77,8 +76,7 @@ class PreparePrefabHeadersTaskTest {
createTestTask<PreparePrefabHeadersTask>(project = project) {
it.outputDir.set(outputDir)
it.input.set(
listOf(PrefabPreprocessingEntry("sample_library", "input/" to expectedPrefix))
)
listOf(PrefabPreprocessingEntry("sample_library", "input/" to expectedPrefix)))
}
task.taskAction()
@@ -104,8 +102,7 @@ class PreparePrefabHeadersTaskTest {
"sample_library",
listOf("input/component1/" to "", "input/component2/" to ""),
),
)
)
))
}
task.taskAction()
@@ -128,8 +125,7 @@ class PreparePrefabHeadersTaskTest {
listOf(
PrefabPreprocessingEntry("libraryone", "input/lib1/" to ""),
PrefabPreprocessingEntry("librarytwo", "input/lib2/" to ""),
)
)
))
}
task.taskAction()
@@ -159,8 +155,7 @@ class PreparePrefabHeadersTaskTest {
"librarytwo",
listOf("input/lib2/" to "", "input/shared/" to "shared/"),
),
)
)
))
}
task.taskAction()
@@ -37,8 +37,7 @@ class AgpConfiguratorUtilsTest {
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
"""
.trimIndent()
)
.trimIndent())
}
val actual = getPackageNameFromManifest(manifest)
@@ -56,8 +55,7 @@ class AgpConfiguratorUtilsTest {
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.facebook.react" >
</manifest>
"""
.trimIndent()
)
.trimIndent())
}
val actual = getPackageNameFromManifest(manifest)
@@ -40,8 +40,7 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == localMavenURI
}
)
})
.isNotNull()
}
@@ -55,8 +54,7 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
}
)
})
.isNotNull()
}
@@ -70,8 +68,7 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
}
)
})
.isNotNull()
}
@@ -85,8 +82,7 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
}
)
})
.isNotNull()
}
@@ -100,8 +96,7 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
}
)
})
.isNotNull()
}
@@ -121,8 +116,7 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
}
)
})
.isNotNull()
}
@@ -137,8 +131,7 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
}
)
})
.isNull()
// We test both with scoped and unscoped property
@@ -150,8 +143,7 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
}
)
})
.isNull()
}
@@ -166,8 +158,7 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
}
)
})
.isNotNull()
// We test both with scoped and unscoped property
@@ -179,8 +170,7 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
}
)
})
.isNotNull()
}
@@ -236,14 +226,12 @@ class DependencyUtilsTest {
assertThat(
appProject.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
}
)
})
.isNotNull()
assertThat(
libProject.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
}
)
})
.isNotNull()
}
@@ -266,8 +254,7 @@ class DependencyUtilsTest {
assertThat(
libProject.repositories.count {
it is MavenArtifactRepository && it.url == repositoryURI
}
)
})
.isEqualTo(2)
}
@@ -345,15 +332,13 @@ class DependencyUtilsTest {
assertThat("com.facebook.react:react-android:0.42.0")
.isEqualTo(dependencySubstitutions[0].second)
assertThat(
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210."
)
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.")
.isEqualTo(dependencySubstitutions[0].third)
assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first)
assertThat("com.facebook.react:hermes-android:0.42.0")
.isEqualTo(dependencySubstitutions[1].second)
assertThat(
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210."
)
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.")
.isEqualTo(dependencySubstitutions[1].third)
}
@@ -364,14 +349,12 @@ class DependencyUtilsTest {
assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first)
assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[0].second)
assertThat(
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210."
)
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.")
.isEqualTo(dependencySubstitutions[0].third)
assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first)
assertThat("io.github.test:hermes-android:0.42.0").isEqualTo(dependencySubstitutions[1].second)
assertThat(
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210."
)
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.")
.isEqualTo(dependencySubstitutions[1].third)
assertThat("com.facebook.react:react-android").isEqualTo(dependencySubstitutions[2].first)
assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[2].second)
@@ -392,8 +375,7 @@ class DependencyUtilsTest {
VERSION_NAME=1000.0.0
ANOTHER_PROPERTY=true
"""
.trimIndent()
)
.trimIndent())
}
val versionString = readVersionAndGroupStrings(propertiesFile).first
@@ -410,8 +392,7 @@ class DependencyUtilsTest {
VERSION_NAME=0.0.0-20221101-2019-cfe811ab1
ANOTHER_PROPERTY=true
"""
.trimIndent()
)
.trimIndent())
}
val versionString = readVersionAndGroupStrings(propertiesFile).first
@@ -427,8 +408,7 @@ class DependencyUtilsTest {
"""
ANOTHER_PROPERTY=true
"""
.trimIndent()
)
.trimIndent())
}
val versionString = readVersionAndGroupStrings(propertiesFile).first
@@ -444,8 +424,7 @@ class DependencyUtilsTest {
VERSION_NAME=
ANOTHER_PROPERTY=true
"""
.trimIndent()
)
.trimIndent())
}
val versionString = readVersionAndGroupStrings(propertiesFile).first
@@ -461,8 +440,7 @@ class DependencyUtilsTest {
react.internal.publishingGroup=io.github.test
ANOTHER_PROPERTY=true
"""
.trimIndent()
)
.trimIndent())
}
val groupString = readVersionAndGroupStrings(propertiesFile).second
@@ -478,8 +456,7 @@ class DependencyUtilsTest {
"""
ANOTHER_PROPERTY=true
"""
.trimIndent()
)
.trimIndent())
}
val groupString = readVersionAndGroupStrings(propertiesFile).second
@@ -147,8 +147,7 @@ class PathUtilsTest {
tempFolder.newFolder("node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/")
val expected =
tempFolder.newFile(
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc"
)
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc")
assertThat(detectOSAwareHermesCommand(tempFolder.root, "")).isEqualTo(expected.toString())
}
@@ -190,8 +189,7 @@ class PathUtilsTest {
tempFolder.newFolder("node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/")
val expected =
tempFolder.newFile(
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc"
)
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc")
tempFolder.newFolder("node_modules/react-native/sdks/hermesc/osx-bin/")
tempFolder.newFile("node_modules/react-native/sdks/hermesc/osx-bin/hermesc")
@@ -205,8 +203,7 @@ class PathUtilsTest {
File(
tempFolder.root,
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc",
)
)
))
}
@Test
@@ -217,8 +214,7 @@ class PathUtilsTest {
File(
tempFolder.root,
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc.exe",
)
)
))
}
@Test
@@ -315,8 +311,7 @@ class PathUtilsTest {
"codegenConfig": {}
}
"""
.trimIndent()
)
.trimIndent())
}
val project = ProjectBuilder.builder().withProjectDir(moduleFolder).build()
project.plugins.apply("com.android.library")
@@ -128,8 +128,7 @@ class ProjectUtilsTest {
"codegenConfig": {}
}
"""
.trimIndent()
)
.trimIndent())
}
extension.root.set(tempFolder.root)
assertThat(project.needsCodegenFromPackageJson(extension.root)).isTrue()
@@ -147,8 +146,7 @@ class ProjectUtilsTest {
"name": "a-library"
}
"""
.trimIndent()
)
.trimIndent())
}
extension.root.set(tempFolder.root)
assertThat(project.needsCodegenFromPackageJson(extension.root)).isFalse()
@@ -58,8 +58,7 @@ tasks.withType<KotlinCompile>().configureEach {
// See comment above on JDK 11 support
jvmTarget.set(JvmTarget.JVM_11)
allWarningsAsErrors.set(
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
)
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false)
}
}
@@ -158,8 +158,9 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings
logger.error(message)
if (cacheJsonConfig.length() != 0L) {
logger.error(
cacheJsonConfig.readText().substring(0, min(1024, cacheJsonConfig.length().toInt()))
)
cacheJsonConfig
.readText()
.substring(0, min(1024, cacheJsonConfig.length().toInt())))
}
cacheJsonConfig.delete()
throw GradleException(message)
@@ -29,12 +29,11 @@ class ReactSettingsExtensionTest {
val validFile =
createJsonFile(
"""
{
"value": "¯\\_(ツ)_/¯"
}
"""
.trimIndent()
)
{
"value": "¯\\_(ツ)_/¯"
}
"""
.trimIndent())
assertThat(computeSha256(validFile))
.isEqualTo("838aa9a72a16fdd55b0d49b510a82e264a30f59333b5fdd97c7798a29146f6a8")
}
@@ -44,12 +43,11 @@ class ReactSettingsExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent()
)
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent())
val map = getLibrariesToAutolink(validJsonFile)
assertThat(map.keys).isEmpty()
@@ -60,42 +58,41 @@ class ReactSettingsExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
},
"android": {
"sourceDir": "./node_modules/@react-native/oss-library-example/android",
"packageImportPath": "import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;",
"packageInstance": "new OSSLibraryExamplePackage()",
"buildTypes": ["staging", "debug", "release"],
"libraryName": "OSSLibraryExampleSpec",
"componentDescriptors": [
"SampleNativeComponentComponentDescriptor"
],
"cmakeListsPath": "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
"cxxModuleCMakeListsModuleName": null,
"cxxModuleCMakeListsPath": null,
"cxxModuleHeaderName": null,
"dependencyConfiguration": "implementation",
"isPureCxxDependency": false
}
}
}
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
},
"android": {
"sourceDir": "./node_modules/@react-native/oss-library-example/android",
"packageImportPath": "import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;",
"packageInstance": "new OSSLibraryExamplePackage()",
"buildTypes": ["staging", "debug", "release"],
"libraryName": "OSSLibraryExampleSpec",
"componentDescriptors": [
"SampleNativeComponentComponentDescriptor"
],
"cmakeListsPath": "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
"cxxModuleCMakeListsModuleName": null,
"cxxModuleCMakeListsPath": null,
"cxxModuleHeaderName": null,
"dependencyConfiguration": "implementation",
"isPureCxxDependency": false
}
}
"""
.trimIndent()
)
}
}
}
"""
.trimIndent())
val map = getLibrariesToAutolink(validJsonFile)
assertThat(map.keys).containsExactly(":react-native_oss-library-example")
@@ -108,26 +105,25 @@ class ReactSettingsExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
}
}
}
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
}
}
"""
.trimIndent()
)
}
}
}
"""
.trimIndent())
val map = getLibrariesToAutolink(validJsonFile)
assertThat(map.keys).isEmpty()
@@ -262,8 +258,7 @@ class ReactSettingsExtensionTest {
}
}
"""
.trimIndent()
)
.trimIndent())
}
tempFolder.newFile("yarn.lock").apply { writeText("I'm a lockfile") }
val lockfileCollection = project.files("yarn.lock")
@@ -316,8 +311,7 @@ class ReactSettingsExtensionTest {
}
}
"""
.trimIndent()
)
.trimIndent())
}
tempFolder.newFile("yarn.lock").apply { writeText("I'm a lockfile") }
val lockfileCollection = project.files("yarn.lock")
@@ -362,10 +356,9 @@ class ReactSettingsExtensionTest {
val invalidConfigFile =
createJsonFile(
"""
{}
"""
.trimIndent()
)
{}
"""
.trimIndent())
assertThat(ReactSettingsExtension.isCacheDirty(invalidConfigFile, buildFolder, lockfiles))
.isTrue()
@@ -384,12 +377,11 @@ class ReactSettingsExtensionTest {
val invalidConfigFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent()
)
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent())
assertThat(ReactSettingsExtension.isCacheDirty(invalidConfigFile, buildFolder, lockfiles))
.isTrue()
@@ -408,13 +400,12 @@ class ReactSettingsExtensionTest {
val invalidConfigFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {}
}
"""
.trimIndent()
)
{
"reactNativeVersion": "1000.0.0",
"dependencies": {}
}
"""
.trimIndent())
assertThat(ReactSettingsExtension.isCacheDirty(invalidConfigFile, buildFolder, lockfiles))
.isTrue()
@@ -433,26 +424,25 @@ class ReactSettingsExtensionTest {
val invalidConfigFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
}
}
}
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
}
}
"""
.trimIndent()
)
}
}
}
"""
.trimIndent())
assertThat(ReactSettingsExtension.isCacheDirty(invalidConfigFile, buildFolder, lockfiles))
.isTrue()
@@ -31,8 +31,7 @@ tasks.withType<KotlinCompile>().configureEach {
// See comment above on JDK 11 support
jvmTarget.set(JvmTarget.JVM_11)
allWarningsAsErrors.set(
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
)
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false)
}
}
@@ -37,8 +37,7 @@ tasks.withType<KotlinCompile>().configureEach {
// See comment above on JDK 11 support
jvmTarget.set(JvmTarget.JVM_11)
allWarningsAsErrors.set(
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
)
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false)
}
}
@@ -39,21 +39,20 @@ class JsonUtilsTest {
val oldJsonConfig =
createJsonFile(
"""
{
"name": "yet another npm package",
"codegenConfig": {
"libraries": [
{
"name": "yet another npm package",
"codegenConfig": {
"libraries": [
{
"name": "an awesome library",
"jsSrcsDir": "../js/",
"android": {}
}
]
}
"name": "an awesome library",
"jsSrcsDir": "../js/",
"android": {}
}
"""
.trimIndent()
)
]
}
}
"""
.trimIndent())
val parsed = JsonUtils.fromPackageJson(oldJsonConfig)!!
@@ -67,22 +66,21 @@ class JsonUtilsTest {
val validJson =
createJsonFile(
"""
{
"name": "yet another npm package",
"codegenConfig": {
"name": "an awesome library",
"jsSrcsDir": "../js/",
"android": {
"javaPackageName": "com.awesome.library"
},
"ios": {
"other ios only keys": "which are ignored during parsing"
}
}
}
"""
.trimIndent()
)
{
"name": "yet another npm package",
"codegenConfig": {
"name": "an awesome library",
"jsSrcsDir": "../js/",
"android": {
"javaPackageName": "com.awesome.library"
},
"ios": {
"other ios only keys": "which are ignored during parsing"
}
}
}
"""
.trimIndent())
val parsed = JsonUtils.fromPackageJson(validJson)!!
@@ -113,12 +111,11 @@ class JsonUtilsTest {
val validJson =
createJsonFile(
"""
{
"version": "1000.0.0"
}
"""
.trimIndent()
)
{
"version": "1000.0.0"
}
"""
.trimIndent())
val parsed = JsonUtils.fromPackageJson(validJson)!!
assertThat("1000.0.0").isEqualTo(parsed.version)
@@ -136,12 +133,11 @@ class JsonUtilsTest {
val validJson =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent()
)
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent())
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
assertThat("1000.0.0").isEqualTo(parsed.reactNativeVersion)
@@ -152,33 +148,32 @@ class JsonUtilsTest {
val validJson =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"project": {
"ios": {
"sourceDir": "./packages/rn-tester",
"xcodeProject": {
"name": "RNTesterPods.xcworkspace",
"isWorkspace": true
},
"automaticPodsInstallation": false
},
"android": {
"sourceDir": "./packages/rn-tester",
"appName": "RN-Tester",
"packageName": "com.facebook.react.uiapp",
"applicationId": "com.facebook.react.uiapp",
"mainActivity": ".RNTesterActivity",
"watchModeCommandParams": [
"--mode HermesDebug"
],
"dependencyConfiguration": "implementation"
}
}
}
"""
.trimIndent()
)
{
"reactNativeVersion": "1000.0.0",
"project": {
"ios": {
"sourceDir": "./packages/rn-tester",
"xcodeProject": {
"name": "RNTesterPods.xcworkspace",
"isWorkspace": true
},
"automaticPodsInstallation": false
},
"android": {
"sourceDir": "./packages/rn-tester",
"appName": "RN-Tester",
"packageName": "com.facebook.react.uiapp",
"applicationId": "com.facebook.react.uiapp",
"mainActivity": ".RNTesterActivity",
"watchModeCommandParams": [
"--mode HermesDebug"
],
"dependencyConfiguration": "implementation"
}
}
}
"""
.trimIndent())
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
assertThat("./packages/rn-tester").isEqualTo(parsed.project!!.android!!.sourceDir)
@@ -197,37 +192,36 @@ class JsonUtilsTest {
val validJson =
createJsonFile(
"""
> AwesomeProject@0.0.1 npx
> rnc-cli config
{
"reactNativeVersion": "1000.0.0",
"project": {
"ios": {
"sourceDir": "./packages/rn-tester",
"xcodeProject": {
"name": "RNTesterPods.xcworkspace",
"isWorkspace": true
},
"automaticPodsInstallation": false
},
"android": {
"sourceDir": "./packages/rn-tester",
"appName": "RN-Tester",
"packageName": "com.facebook.react.uiapp",
"applicationId": "com.facebook.react.uiapp",
"mainActivity": ".RNTesterActivity",
"watchModeCommandParams": [
"--mode HermesDebug"
],
"dependencyConfiguration": "implementation"
}
}
}
"""
.trimIndent()
)
> AwesomeProject@0.0.1 npx
> rnc-cli config
{
"reactNativeVersion": "1000.0.0",
"project": {
"ios": {
"sourceDir": "./packages/rn-tester",
"xcodeProject": {
"name": "RNTesterPods.xcworkspace",
"isWorkspace": true
},
"automaticPodsInstallation": false
},
"android": {
"sourceDir": "./packages/rn-tester",
"appName": "RN-Tester",
"packageName": "com.facebook.react.uiapp",
"applicationId": "com.facebook.react.uiapp",
"mainActivity": ".RNTesterActivity",
"watchModeCommandParams": [
"--mode HermesDebug"
],
"dependencyConfiguration": "implementation"
}
}
}
"""
.trimIndent())
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
assertThat("./packages/rn-tester").isEqualTo(parsed.project!!.android!!.sourceDir)
@@ -245,42 +239,41 @@ class JsonUtilsTest {
val validJson =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
},
"android": {
"sourceDir": "./node_modules/@react-native/oss-library-example/android",
"packageImportPath": "import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;",
"packageInstance": "new OSSLibraryExamplePackage()",
"buildTypes": ["staging", "debug", "release"],
"libraryName": "OSSLibraryExampleSpec",
"componentDescriptors": [
"SampleNativeComponentComponentDescriptor"
],
"cmakeListsPath": "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
"cxxModuleCMakeListsModuleName": null,
"cxxModuleCMakeListsPath": null,
"cxxModuleHeaderName": null,
"dependencyConfiguration": "implementation",
"isPureCxxDependency": false
}
}
}
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
},
"android": {
"sourceDir": "./node_modules/@react-native/oss-library-example/android",
"packageImportPath": "import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;",
"packageInstance": "new OSSLibraryExamplePackage()",
"buildTypes": ["staging", "debug", "release"],
"libraryName": "OSSLibraryExampleSpec",
"componentDescriptors": [
"SampleNativeComponentComponentDescriptor"
],
"cmakeListsPath": "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
"cxxModuleCMakeListsModuleName": null,
"cxxModuleCMakeListsPath": null,
"cxxModuleHeaderName": null,
"dependencyConfiguration": "implementation",
"isPureCxxDependency": false
}
}
"""
.trimIndent()
)
}
}
}
"""
.trimIndent())
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
assertThat("./node_modules/@react-native/oss-library-example")
@@ -294,86 +287,73 @@ class JsonUtilsTest {
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.sourceDir
)
.sourceDir)
assertThat("import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;")
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.packageImportPath
)
.packageImportPath)
assertThat("new OSSLibraryExamplePackage()")
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.packageInstance
)
.packageInstance)
assertThat(listOf("staging", "debug", "release"))
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.buildTypes
)
.buildTypes)
assertThat("OSSLibraryExampleSpec")
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.libraryName
)
.libraryName)
assertThat(listOf("SampleNativeComponentComponentDescriptor"))
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.componentDescriptors
)
.componentDescriptors)
assertThat(
"./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt"
)
"./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt")
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.cmakeListsPath
)
.cmakeListsPath)
assertThat(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.cxxModuleHeaderName
)
.cxxModuleHeaderName)
.isNull()
assertThat(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.cxxModuleCMakeListsPath
)
.cxxModuleCMakeListsPath)
.isNull()
assertThat(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.cxxModuleCMakeListsModuleName
)
.cxxModuleCMakeListsModuleName)
.isNull()
assertThat("implementation")
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.dependencyConfiguration
)
.dependencyConfiguration)
assertThat(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.isPureCxxDependency!!
)
.isPureCxxDependency!!)
.isFalse()
}
@@ -108,25 +108,21 @@ val preparePrefab by
// react_devtoolsruntimesettings
Pair(
"../ReactCommon/react/devtoolsruntimesettings/",
"react/devtoolsruntimesettings/",
),
"react/devtoolsruntimesettings/"),
// react_renderer_animations
Pair(
"../ReactCommon/react/renderer/animations/",
"react/renderer/animations/",
),
"react/renderer/animations/"),
// react_renderer_bridging
Pair("../ReactCommon/react/renderer/bridging/", "react/renderer/bridging/"),
// react_renderer_componentregistry
Pair(
"../ReactCommon/react/renderer/componentregistry/",
"react/renderer/componentregistry/",
),
"react/renderer/componentregistry/"),
// react_renderer_consistency
Pair(
"../ReactCommon/react/renderer/consistency/",
"react/renderer/consistency/",
),
"react/renderer/consistency/"),
// react_renderer_core
Pair("../ReactCommon/react/renderer/core/", "react/renderer/core/"),
// react_renderer_css
@@ -141,8 +137,7 @@ val preparePrefab by
// react_renderer_imagemanager
Pair(
"../ReactCommon/react/renderer/imagemanager/",
"react/renderer/imagemanager/",
),
"react/renderer/imagemanager/"),
Pair("../ReactCommon/react/renderer/imagemanager/platform/cxx/", ""),
// react_renderer_mounting
Pair("../ReactCommon/react/renderer/mounting/", "react/renderer/mounting/"),
@@ -155,45 +150,37 @@ val preparePrefab by
// rrc_image
Pair(
"../ReactCommon/react/renderer/components/image/",
"react/renderer/components/image/",
),
"react/renderer/components/image/"),
// rrc_view
Pair(
"../ReactCommon/react/renderer/components/view/",
"react/renderer/components/view/",
),
"react/renderer/components/view/"),
Pair("../ReactCommon/react/renderer/components/view/platform/android/", ""),
// rrc_root
Pair(
"../ReactCommon/react/renderer/components/root/",
"react/renderer/components/root/",
),
"react/renderer/components/root/"),
// runtimeexecutor
Pair("../ReactCommon/runtimeexecutor/", ""),
// react_renderer_textlayoutmanager
Pair(
"../ReactCommon/react/renderer/textlayoutmanager/",
"react/renderer/textlayoutmanager/",
),
"react/renderer/textlayoutmanager/"),
Pair("../ReactCommon/react/renderer/textlayoutmanager/platform/android/", ""),
// rrc_text
Pair(
"../ReactCommon/react/renderer/components/text/",
"react/renderer/components/text/",
),
"react/renderer/components/text/"),
Pair(
"../ReactCommon/react/renderer/attributedstring",
"react/renderer/attributedstring",
),
"react/renderer/attributedstring"),
// rrc_textinput
Pair(
"../ReactCommon/react/renderer/components/textinput/",
"react/renderer/components/textinput/",
),
"react/renderer/components/textinput/"),
Pair(
"../ReactCommon/react/renderer/components/textinput/platform/android/",
"",
),
""),
// react_newarchdefaults
Pair("src/main/jni/react/newarchdefaults", ""),
// react_nativemodule_core
@@ -210,24 +197,20 @@ val preparePrefab by
Pair("../ReactCommon/react/nativemodule/core/platform/android/", ""),
Pair(
"../ReactCommon/react/renderer/componentregistry/",
"react/renderer/componentregistry/",
),
"react/renderer/componentregistry/"),
Pair(
"../ReactCommon/react/renderer/components/root/",
"react/renderer/components/root/",
),
"react/renderer/components/root/"),
Pair("../ReactCommon/react/renderer/core/", "react/renderer/core/"),
Pair("../ReactCommon/react/renderer/debug/", "react/renderer/debug/"),
Pair(
"../ReactCommon/react/renderer/leakchecker/",
"react/renderer/leakchecker/",
),
"react/renderer/leakchecker/"),
Pair("../ReactCommon/react/renderer/mapbuffer/", "react/renderer/mapbuffer/"),
Pair("../ReactCommon/react/renderer/mounting/", "react/renderer/mounting/"),
Pair(
"../ReactCommon/react/renderer/runtimescheduler/",
"react/renderer/runtimescheduler/",
),
"react/renderer/runtimescheduler/"),
Pair("../ReactCommon/react/renderer/scheduler/", "react/renderer/scheduler/"),
Pair("../ReactCommon/react/renderer/telemetry/", "react/renderer/telemetry/"),
Pair("../ReactCommon/react/renderer/uimanager/", "react/renderer/uimanager/"),
@@ -239,32 +222,26 @@ val preparePrefab by
// react_performance_timeline
Pair(
"../ReactCommon/react/performance/timeline/",
"react/performance/timeline/",
),
"react/performance/timeline/"),
// react_performance_cdpmetrics
Pair(
"../ReactCommon/react/performance/cdpmetrics/",
"react/performance/cdpmetrics/",
),
"react/performance/cdpmetrics/"),
// react_renderer_observers_events
Pair(
"../ReactCommon/react/renderer/observers/events/",
"react/renderer/observers/events/",
),
"react/renderer/observers/events/"),
// react_timing
Pair("../ReactCommon/react/timing/", "react/timing/"),
// yoga
Pair("../ReactCommon/yoga/", ""),
Pair("src/main/jni/first-party/yogajni/jni", ""),
),
),
)),
PrefabPreprocessingEntry(
"hermestooling",
// hermes_executor
Pair("../ReactCommon/hermes/inspector-modern/", "hermes/inspector-modern/"),
),
)
)
Pair("../ReactCommon/hermes/inspector-modern/", "hermes/inspector-modern/")),
))
outputDir.set(prefabHeadersDir)
}
@@ -279,8 +256,7 @@ val downloadBoost by
tasks.registering(Download::class) {
dependsOn(createNativeDepsDirectories)
src(
"https://archives.boost.io/release/${BOOST_VERSION.replace("_", ".")}/source/boost_${BOOST_VERSION}.tar.gz"
)
"https://archives.boost.io/release/${BOOST_VERSION.replace("_", ".")}/source/boost_${BOOST_VERSION}.tar.gz")
onlyIfModified(true)
overwrite(false)
retries(5)
@@ -303,8 +279,7 @@ val downloadDoubleConversion by
tasks.registering(Download::class) {
dependsOn(createNativeDepsDirectories)
src(
"https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz"
)
"https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz")
onlyIfModified(true)
overwrite(false)
retries(5)
@@ -443,8 +418,7 @@ val buildCodegenCLI by
fileTree(codegenDir) {
include("lib/**/*.js")
include("lib/**/*.js.flow")
}
)
})
rootProjectName.set(rootProject.name)
}
@@ -555,8 +529,7 @@ android {
"-DANDROID_STL=c++_shared",
"-DANDROID_TOOLCHAIN=clang",
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON",
"-DCMAKE_POLICY_DEFAULT_CMP0069=NEW",
)
"-DCMAKE_POLICY_DEFAULT_CMP0069=NEW")
targets(
"reactnative",
@@ -581,13 +554,11 @@ android {
buildCodegenCLI,
"generateCodegenArtifactsFromSchema",
prepareNative3pDependencies,
preparePrefab,
)
preparePrefab)
tasks.getByName("generateCodegenSchemaFromJavaScript").dependsOn(buildCodegenCLI)
prepareKotlinBuildScriptModel.dependsOn("preBuild")
prepareKotlinBuildScriptModel.dependsOn(
":packages:react-native:ReactAndroid:hermes-engine:preBuild"
)
":packages:react-native:ReactAndroid:hermes-engine:preBuild")
sourceSets.getByName("main") {
res.setSrcDirs(
@@ -597,9 +568,7 @@ android {
"src/main/res/views/alert",
"src/main/res/views/modal",
"src/main/res/views/uimanager",
"src/main/res/views/view",
)
)
"src/main/res/views/view"))
java.exclude("com/facebook/react/processing")
java.exclude("com/facebook/react/module/processing")
}
@@ -129,8 +129,7 @@ val installCMake by
tasks.registering(CustomExecTask::class) {
onlyIfProvidedPathDoesNotExists.set(cmakePath)
commandLine(
windowsAwareCommandLine(getSDKManagerPath(), "--install", "cmake;${cmakeVersion}")
)
windowsAwareCommandLine(getSDKManagerPath(), "--install", "cmake;${cmakeVersion}"))
}
val configureBuildForHermes by
@@ -265,8 +264,7 @@ android {
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True",
// We intentionally build Hermes with Intl support only. This is to simplify
// the build setup and to avoid overcomplicating the build-type matrix.
"-DHERMES_ENABLE_INTL=True",
)
"-DHERMES_ENABLE_INTL=True")
targets("libhermes")
}
@@ -304,8 +302,7 @@ android {
arguments(
"-DCMAKE_BUILD_TYPE=MinSizeRel",
// For release builds, we don't want to enable the Hermes Debugger.
"-DHERMES_ENABLE_DEBUGGER=False",
)
"-DHERMES_ENABLE_DEBUGGER=False")
}
}
}
@@ -25,8 +25,7 @@ public abstract class BaseReactPackage : ReactPackage {
@Deprecated("Migrate to [BaseReactPackage] and implement [getModule] instead.")
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
throw UnsupportedOperationException(
"createNativeModules method is not supported. Use getModule() method instead."
)
"createNativeModules method is not supported. Use getModule() method instead.")
}
/**
@@ -67,10 +66,8 @@ public abstract class BaseReactPackage : ReactPackage {
// This Iterator is used to create the NativeModule registry. The NativeModule
// registry must not have TurboModules. Therefore, if TurboModules are enabled, and
// the current NativeModule is a TurboModule, we need to skip iterating over it.
if (
ReactNativeNewArchitectureFeatureFlags.useTurboModules() &&
reactModuleInfo.isTurboModule
) {
if (ReactNativeNewArchitectureFeatureFlags.useTurboModules() &&
reactModuleInfo.isTurboModule) {
continue
}
@@ -54,8 +54,7 @@ import com.facebook.systrace.Systrace
SourceCodeModule::class,
TimingModule::class,
com.facebook.react.uimanager.UIManagerModule::class,
]
)
])
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
@@ -154,8 +153,7 @@ internal class CoreModulesPackage(
DeviceInfoModule.NAME -> DeviceInfoModule(reactContext)
else ->
throw IllegalArgumentException(
"In CoreModulesPackage, could not find Native module for $name"
)
"In CoreModulesPackage, could not find Native module for $name")
}
}
@@ -26,8 +26,7 @@ public class DebugCorePackage public constructor() :
lazy(LazyThreadSafetyMode.NONE) {
mapOf(
DebuggingOverlayManager.REACT_CLASS to
ModuleSpec.viewManagerSpec { DebuggingOverlayManager() }
)
ModuleSpec.viewManagerSpec { DebuggingOverlayManager() })
}
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider {
@@ -145,8 +145,7 @@ public abstract class HeadlessJsTaskService : Service(), HeadlessJsTaskEventList
invokeStartTask(context, taskConfig)
reactHost.removeReactInstanceEventListener(this)
}
}
)
})
reactHost.start()
} else {
val reactInstanceManager = reactNativeHost.reactInstanceManager
@@ -156,8 +155,7 @@ public abstract class HeadlessJsTaskService : Service(), HeadlessJsTaskEventList
invokeStartTask(context, taskConfig)
reactInstanceManager.removeReactInstanceEventListener(this)
}
}
)
})
reactInstanceManager.createReactContextInBackground()
}
}
@@ -25,10 +25,8 @@ internal class ReactAndroidHWInputDeviceHelper {
fun handleKeyEvent(ev: KeyEvent, context: ReactContext) {
val eventKeyCode = ev.keyCode
val eventKeyAction = ev.action
if (
(eventKeyAction == KeyEvent.ACTION_UP || eventKeyAction == KeyEvent.ACTION_DOWN) &&
KEY_EVENTS_ACTIONS.containsKey(eventKeyCode)
) {
if ((eventKeyAction == KeyEvent.ACTION_UP || eventKeyAction == KeyEvent.ACTION_DOWN) &&
KEY_EVENTS_ACTIONS.containsKey(eventKeyCode)) {
dispatchEvent(context, KEY_EVENTS_ACTIONS[eventKeyCode], lastFocusedViewId, eventKeyAction)
}
}
@@ -59,8 +59,7 @@ public open class ReactDelegate {
* used for New Architecture.
*/
@Deprecated(
"Use one of the other constructors instead to account for New Architecture. Deprecated since 0.75.0"
)
"Use one of the other constructors instead to account for New Architecture. Deprecated since 0.75.0")
public constructor(
activity: Activity,
reactNativeHost: ReactNativeHost?,
@@ -105,14 +104,11 @@ public open class ReactDelegate {
private val devSupportManager: DevSupportManager?
get() =
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost?.devSupportManager != null
) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost?.devSupportManager != null) {
reactHost?.devSupportManager
} else if (
reactNativeHost?.hasInstance() == true && reactNativeHost?.reactInstanceManager != null
) {
} else if (reactNativeHost?.hasInstance() == true &&
reactNativeHost?.reactInstanceManager != null) {
reactNativeHost?.reactInstanceManager?.devSupportManager
} else {
null
@@ -121,12 +117,10 @@ public open class ReactDelegate {
public fun onHostResume() {
if (activity !is DefaultHardwareBackBtnHandler) {
throw ClassCastException(
"Host Activity `${activity.javaClass.simpleName}` does not implement DefaultHardwareBackBtnHandler"
)
"Host Activity `${activity.javaClass.simpleName}` does not implement DefaultHardwareBackBtnHandler")
}
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
reactHost?.onHostResume(activity, activity as DefaultHardwareBackBtnHandler)
} else {
if (reactNativeHost?.hasInstance() == true) {
@@ -138,9 +132,8 @@ public open class ReactDelegate {
}
public fun onUserLeaveHint() {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
reactHost?.onHostLeaveHint(activity)
} else {
if (reactNativeHost?.hasInstance() == true) {
@@ -150,9 +143,8 @@ public open class ReactDelegate {
}
public fun onHostPause() {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
reactHost?.onHostPause(activity)
} else {
if (reactNativeHost?.hasInstance() == true) {
@@ -163,9 +155,8 @@ public open class ReactDelegate {
public fun onHostDestroy() {
unloadApp()
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
reactHost?.onHostDestroy(activity)
} else {
if (reactNativeHost?.hasInstance() == true) {
@@ -175,9 +166,8 @@ public open class ReactDelegate {
}
public fun onBackPressed(): Boolean {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
reactHost?.onBackPressed()
return true
} else {
@@ -190,9 +180,8 @@ public open class ReactDelegate {
}
public fun onNewIntent(intent: Intent): Boolean {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
reactHost?.onNewIntent(intent)
return true
} else {
@@ -210,11 +199,9 @@ public open class ReactDelegate {
data: Intent?,
shouldForwardToReactInstance: Boolean,
) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null &&
shouldForwardToReactInstance
) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null &&
shouldForwardToReactInstance) {
reactHost?.onActivityResult(activity, requestCode, resultCode, data)
} else {
if (reactNativeHost?.hasInstance() == true && shouldForwardToReactInstance) {
@@ -226,9 +213,8 @@ public open class ReactDelegate {
}
public fun onWindowFocusChanged(hasFocus: Boolean) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
reactHost?.onWindowFocusChange(hasFocus)
} else {
if (reactNativeHost?.hasInstance() == true) {
@@ -238,9 +224,8 @@ public open class ReactDelegate {
}
public fun onConfigurationChanged(newConfig: Configuration?) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
reactHost?.onConfigurationChanged(checkNotNull(activity))
} else {
if (reactNativeHost?.hasInstance() == true) {
@@ -250,13 +235,11 @@ public open class ReactDelegate {
}
public fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
if (
keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD &&
((ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost?.devSupportManager != null) ||
(reactNativeHost?.hasInstance() == true &&
reactNativeHost?.useDeveloperSupport == true))
) {
if (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD &&
((ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost?.devSupportManager != null) ||
(reactNativeHost?.hasInstance() == true &&
reactNativeHost?.useDeveloperSupport == true))) {
event.startTracking()
return true
}
@@ -265,9 +248,8 @@ public open class ReactDelegate {
public fun onKeyLongPress(keyCode: Int): Boolean {
if (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD || keyCode == KeyEvent.KEYCODE_BACK) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
val devSupportManager = reactHost?.devSupportManager
// onKeyLongPress is a Dev API and not supported in RELEASE mode.
if (devSupportManager != null && devSupportManager !is ReleaseDevSupportManager) {
@@ -275,9 +257,8 @@ public open class ReactDelegate {
return true
}
} else {
if (
reactNativeHost?.hasInstance() == true && reactNativeHost?.useDeveloperSupport == true
) {
if (reactNativeHost?.hasInstance() == true &&
reactNativeHost?.useDeveloperSupport == true) {
reactNativeHost?.reactInstanceManager?.showDevOptionsDialog()
return true
}
@@ -296,10 +277,8 @@ public open class ReactDelegate {
reactHost?.reload("ReactDelegate.reload()")
} else {
runOnUiThread {
if (
reactNativeHost?.hasInstance() == true &&
reactNativeHost?.reactInstanceManager != null
) {
if (reactNativeHost?.hasInstance() == true &&
reactNativeHost?.reactInstanceManager != null) {
reactNativeHost?.reactInstanceManager?.recreateReactContextInBackground()
}
}
@@ -410,8 +389,7 @@ public open class ReactDelegate {
}
@Deprecated(
"Do not access [ReactInstanceManager] directly. This class is going away in the New Architecture. You should use [ReactHost] instead."
)
"Do not access [ReactInstanceManager] directly. This class is going away in the New Architecture. You should use [ReactHost] instead.")
public fun getReactInstanceManager(): ReactInstanceManager {
val nonNullReactNativeHost =
checkNotNull(reactNativeHost) {
@@ -203,8 +203,7 @@ public open class ReactFragment : Fragment(), PermissionAwareActivity {
public fun build(): ReactFragment = newInstance(componentName, launchOptions, fabricEnabled)
@Deprecated(
"You should not change call ReactFragment.setFabricEnabled. Instead enable the NewArchitecture for the whole application with newArchEnabled=true in your gradle.properties file"
)
"You should not change call ReactFragment.setFabricEnabled. Instead enable the NewArchitecture for the whole application with newArchEnabled=true in your gradle.properties file")
public fun setFabricEnabled(fabricEnabled: Boolean): Builder {
this.fabricEnabled = fabricEnabled
return this
@@ -217,8 +216,7 @@ public open class ReactFragment : Fragment(), PermissionAwareActivity {
protected const val ARG_FABRIC_ENABLED: String = "arg_fabric_enabled"
@Deprecated(
"We will remove this and use a different solution for handling Fragment lifecycle events."
)
"We will remove this and use a different solution for handling Fragment lifecycle events.")
protected const val ARG_DISABLE_HOST_LIFECYCLE_EVENTS: String =
"arg_disable_host_lifecycle_events"
@@ -42,8 +42,7 @@ import com.facebook.react.packagerconnection.RequestHandler
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING,
)
level = DeprecationLevel.WARNING)
public class ReactInstanceManagerBuilder {
private val packages: MutableList<ReactPackage> = mutableListOf()
private var jsBundleAssetUrl: String? = null
@@ -135,10 +135,8 @@ public abstract class ReactPackageTurboModuleManagerDelegate : TurboModuleManage
for (moduleProvider in moduleProviders) {
val moduleInfo: ReactModuleInfo? = packageModuleInfos[moduleProvider]?.get(moduleName)
if (
moduleInfo?.isTurboModule == true &&
(resolvedModule == null || moduleInfo.canOverrideExistingModule)
) {
if (moduleInfo?.isTurboModule == true &&
(resolvedModule == null || moduleInfo.canOverrideExistingModule)) {
val module = moduleProvider.getModule(moduleName)
if (module != null) {
resolvedModule = module
@@ -184,10 +182,8 @@ public abstract class ReactPackageTurboModuleManagerDelegate : TurboModuleManage
for (moduleProvider in moduleProviders) {
val moduleInfo: ReactModuleInfo? = packageModuleInfos[moduleProvider]?.get(moduleName)
if (
moduleInfo?.isTurboModule == false &&
(resolvedModule == null || moduleInfo.canOverrideExistingModule)
) {
if (moduleInfo?.isTurboModule == false &&
(resolvedModule == null || moduleInfo.canOverrideExistingModule)) {
val module = moduleProvider.getModule(moduleName)
if (module != null) {
resolvedModule = module
@@ -42,8 +42,7 @@ internal class AdditionAnimatedNode(
acc + animatedNode.getValue()
} else {
throw JSApplicationCausedNativeException(
"Illegal node ID set as an input for Animated.Add node"
)
"Illegal node ID set as an input for Animated.Add node")
}
},
)
@@ -35,7 +35,6 @@ internal abstract class AnimationDriver {
*/
open fun resetConfig(config: ReadableMap) {
throw JSApplicationCausedNativeException(
"Animation config for ${javaClass.simpleName} cannot be reset"
)
"Animation config for ${javaClass.simpleName} cannot be reset")
}
}
@@ -40,8 +40,7 @@ internal class DiffClampAnimatedNode(
val animatedNode = nativeAnimatedNodesManager.getNodeById(inputNodeTag)
if (animatedNode == null || animatedNode !is ValueAnimatedNode) {
throw JSApplicationCausedNativeException(
"Illegal node ID set as an input for Animated.DiffClamp node"
)
"Illegal node ID set as an input for Animated.DiffClamp node")
}
return animatedNode.getValue()
}
@@ -39,15 +39,13 @@ internal class DivisionAnimatedNode(
nodeValue = v
} else if (v == 0.0) {
throw JSApplicationCausedNativeException(
"Detected a division by zero in Animated.divide node with Animated ID $tag"
)
"Detected a division by zero in Animated.divide node with Animated ID $tag")
} else {
nodeValue /= v
}
} else {
throw JSApplicationCausedNativeException(
"Illegal node ID set as an input for Animated.divide node with Animated ID $tag"
)
"Illegal node ID set as an input for Animated.divide node with Animated ID $tag")
}
}
}
@@ -173,8 +173,7 @@ internal class InterpolationAnimatedNode(config: ReadableMap) : ValueAnimatedNod
EXTRAPOLATE_TYPE_EXTEND -> {}
else ->
throw JSApplicationIllegalArgumentException(
"Invalid extrapolation type " + extrapolateLeft + "for left extrapolation"
)
"Invalid extrapolation type " + extrapolateLeft + "for left extrapolation")
}
}
if (result > inputMax) {
@@ -184,8 +183,7 @@ internal class InterpolationAnimatedNode(config: ReadableMap) : ValueAnimatedNod
EXTRAPOLATE_TYPE_EXTEND -> {}
else ->
throw JSApplicationIllegalArgumentException(
"Invalid extrapolation type " + extrapolateRight + "for right extrapolation"
)
"Invalid extrapolation type " + extrapolateRight + "for right extrapolation")
}
}
if (outputMin == outputMax) {
@@ -25,8 +25,7 @@ internal class ModulusAnimatedNode(
nodeValue = (animatedNodeValue % modulus + modulus) % modulus
} else {
throw JSApplicationCausedNativeException(
"Illegal node ID set as an input for Animated.modulus node"
)
"Illegal node ID set as an input for Animated.modulus node")
}
}
@@ -39,8 +39,7 @@ internal class MultiplicationAnimatedNode(
animatedNode.getValue()
} else {
throw JSApplicationCausedNativeException(
"Illegal node ID set as an input for Animated.multiply node"
)
"Illegal node ID set as an input for Animated.multiply node")
}
nodeValue *= multiplier
}
@@ -311,10 +311,8 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
if (operations.isEmpty && preOperations.isEmpty) {
return
}
if (
uiManagerType == UIManagerType.FABRIC ||
ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE
) {
if (uiManagerType == UIManagerType.FABRIC ||
ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE) {
return
}
@@ -423,8 +421,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
ReactSoftExceptionLogger.logSoftException(
NAME,
RuntimeException(
"initializeLifecycleEventListenersForViewTag could not get NativeAnimatedNodesManager"
),
"initializeLifecycleEventListenersForViewTag could not get NativeAnimatedNodesManager"),
)
}
@@ -469,17 +466,13 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
// If there are ongoing Fabric animations from a previous screen,
// and we tear down the current non-Fabric screen, we should expect
// the animation mode to switch back - and vice-versa.
if (
numNonFabricAnimations == 0 &&
numFabricAnimations > 0 &&
uiManagerType != UIManagerType.FABRIC
) {
if (numNonFabricAnimations == 0 &&
numFabricAnimations > 0 &&
uiManagerType != UIManagerType.FABRIC) {
uiManagerType = UIManagerType.FABRIC
} else if (
numFabricAnimations == 0 &&
numNonFabricAnimations > 0 &&
uiManagerType != UIManagerType.LEGACY
) {
} else if (numFabricAnimations == 0 &&
numNonFabricAnimations > 0 &&
uiManagerType != UIManagerType.LEGACY) {
uiManagerType = UIManagerType.LEGACY
}
}
@@ -508,8 +501,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.createAnimatedNode(tag, config)
}
}
)
})
}
override fun updateAnimatedNodeConfig(tagDouble: Double, config: ReadableMap) {
@@ -526,8 +518,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.updateAnimatedNodeConfig(tag, config)
}
}
)
})
}
override fun startListeningToAnimatedNodeValue(tagDouble: Double) {
@@ -555,8 +546,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.startListeningToAnimatedNodeValue(tag, listener)
}
}
)
})
}
override fun stopListeningToAnimatedNodeValue(tagDouble: Double) {
@@ -573,8 +563,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.stopListeningToAnimatedNodeValue(tag)
}
}
)
})
}
override fun dropAnimatedNode(tagDouble: Double) {
@@ -591,8 +580,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.dropAnimatedNode(tag)
}
}
)
})
}
override fun setAnimatedNodeValue(tagDouble: Double, value: Double) {
@@ -609,8 +597,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.setAnimatedNodeValue(tag, value)
}
}
)
})
}
override fun setAnimatedNodeOffset(tagDouble: Double, value: Double) {
@@ -627,8 +614,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.setAnimatedNodeOffset(tag, value)
}
}
)
})
}
override fun flattenAnimatedNodeOffset(tagDouble: Double) {
@@ -645,8 +631,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.flattenAnimatedNodeOffset(tag)
}
}
)
})
}
override fun extractAnimatedNodeOffset(tagDouble: Double) {
@@ -663,8 +648,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.extractAnimatedNodeOffset(tag)
}
}
)
})
}
override fun startAnimatingNode(
@@ -692,8 +676,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
endCallback,
)
}
}
)
})
}
override fun stopAnimation(animationIdDouble: Double) {
@@ -710,8 +693,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.stopAnimation(animationId)
}
}
)
})
}
override fun connectAnimatedNodes(parentNodeTagDouble: Double, childNodeTagDouble: Double) {
@@ -732,8 +714,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.connectAnimatedNodes(parentNodeTag, childNodeTag)
}
}
)
})
}
override fun disconnectAnimatedNodes(parentNodeTagDouble: Double, childNodeTagDouble: Double) {
@@ -754,8 +735,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.disconnectAnimatedNodes(parentNodeTag, childNodeTag)
}
}
)
})
}
override fun connectAnimatedNodeToView(animatedNodeTagDouble: Double, viewTagDouble: Double) {
@@ -781,8 +761,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.connectAnimatedNodeToView(animatedNodeTag, viewTag)
}
}
)
})
}
override fun disconnectAnimatedNodeFromView(
@@ -808,8 +787,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.disconnectAnimatedNodeFromView(animatedNodeTag, viewTag)
}
}
)
})
}
override fun restoreDefaultValues(animatedNodeTagDouble: Double) {
@@ -826,8 +804,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.restoreDefaultValues(animatedNodeTag)
}
}
)
})
}
override fun addAnimatedEventToView(
@@ -856,8 +833,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.addAnimatedEventToView(viewTag, eventName, eventMapping)
}
}
)
})
}
override fun removeAnimatedEventFromView(
@@ -887,8 +863,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
animatedNodesManager.removeAnimatedEventFromView(viewTag, eventName, animatedValueTag)
}
}
)
})
}
override fun addListener(eventName: String) {
@@ -906,8 +881,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
override fun execute(animatedNodesManager: NativeAnimatedNodesManager) {
animatedNodesManager.getValue(animatedValueNodeTag, callback)
}
}
)
})
}
override fun invalidate() {
@@ -1107,8 +1081,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
}
}
}
)
})
finishOperationBatch()
}
@@ -103,8 +103,7 @@ public class NativeAnimatedNodesManager(
public fun createAnimatedNode(tag: Int, config: ReadableMap) {
if (animatedNodes.get(tag) != null) {
throw JSApplicationIllegalArgumentException(
"createAnimatedNode: Animated node [$tag] already exists"
)
"createAnimatedNode: Animated node [$tag] already exists")
}
val node =
when (val type = config.getString("type")) {
@@ -134,8 +133,7 @@ public class NativeAnimatedNodesManager(
val node =
animatedNodes.get(tag)
?: throw JSApplicationIllegalArgumentException(
"updateAnimatedNode: Animated node [$tag] does not exist"
)
"updateAnimatedNode: Animated node [$tag] does not exist")
if (node is AnimatedNodeWithUpdateableConfig) {
stopAnimationsForNode(node)
@@ -155,8 +153,7 @@ public class NativeAnimatedNodesManager(
val node = animatedNodes[tag]
if (node == null || node !is ValueAnimatedNode) {
throw JSApplicationIllegalArgumentException(
("startListeningToAnimatedNodeValue: Animated node [${tag}] does not exist, or is not a 'value' node")
)
("startListeningToAnimatedNodeValue: Animated node [${tag}] does not exist, or is not a 'value' node"))
}
node.setValueListener(listener)
}
@@ -166,8 +163,7 @@ public class NativeAnimatedNodesManager(
val node = animatedNodes.get(tag)
if (node == null || node !is ValueAnimatedNode) {
throw JSApplicationIllegalArgumentException(
("startListeningToAnimatedNodeValue: Animated node [${tag}] does not exist, or is not a 'value' node")
)
("startListeningToAnimatedNodeValue: Animated node [${tag}] does not exist, or is not a 'value' node"))
}
node.setValueListener(null)
}
@@ -177,8 +173,7 @@ public class NativeAnimatedNodesManager(
val node = animatedNodes.get(tag)
if (node == null || node !is ValueAnimatedNode) {
throw JSApplicationIllegalArgumentException(
("setAnimatedNodeValue: Animated node [${tag}] does not exist, or is not a 'value' node")
)
("setAnimatedNodeValue: Animated node [${tag}] does not exist, or is not a 'value' node"))
}
stopAnimationsForNode(node)
node.nodeValue = value
@@ -190,8 +185,7 @@ public class NativeAnimatedNodesManager(
val node = animatedNodes.get(tag)
if (node == null || node !is ValueAnimatedNode) {
throw JSApplicationIllegalArgumentException(
("setAnimatedNodeOffset: Animated node [${tag}] does not exist, or is not a 'value' node")
)
("setAnimatedNodeOffset: Animated node [${tag}] does not exist, or is not a 'value' node"))
}
node.offset = offset
updatedNodes.put(tag, node)
@@ -202,8 +196,7 @@ public class NativeAnimatedNodesManager(
val node = animatedNodes.get(tag)
if (node == null || node !is ValueAnimatedNode) {
throw JSApplicationIllegalArgumentException(
("flattenAnimatedNodeOffset: Animated node [${tag}] does not exist, or is not a 'value' node")
)
("flattenAnimatedNodeOffset: Animated node [${tag}] does not exist, or is not a 'value' node"))
}
node.flattenOffset()
}
@@ -213,8 +206,7 @@ public class NativeAnimatedNodesManager(
val node = animatedNodes.get(tag)
if (node == null || node !is ValueAnimatedNode) {
throw JSApplicationIllegalArgumentException(
("extractAnimatedNodeOffset: Animated node [${tag}] does not exist, or is not a 'value' node")
)
("extractAnimatedNodeOffset: Animated node [${tag}] does not exist, or is not a 'value' node"))
}
node.extractOffset()
}
@@ -229,12 +221,10 @@ public class NativeAnimatedNodesManager(
val node =
animatedNodes.get(animatedNodeTag)
?: throw JSApplicationIllegalArgumentException(
"startAnimatingNode: Animated node [$animatedNodeTag] does not exist"
)
"startAnimatingNode: Animated node [$animatedNodeTag] does not exist")
if (node !is ValueAnimatedNode) {
throw JSApplicationIllegalArgumentException(
("startAnimatingNode: Animated node [${animatedNodeTag}] should be of type ${ValueAnimatedNode::class.java.name}")
)
("startAnimatingNode: Animated node [${animatedNodeTag}] should be of type ${ValueAnimatedNode::class.java.name}"))
}
val existingDriver = activeAnimations[animationId]
@@ -252,8 +242,7 @@ public class NativeAnimatedNodesManager(
"decay" -> DecayAnimation(animationConfig)
else -> {
throw JSApplicationIllegalArgumentException(
"startAnimatingNode: Unsupported animation type [$animatedNodeTag]: $type"
)
"startAnimatingNode: Unsupported animation type [$animatedNodeTag]: $type")
}
}
animation.id = animationId
@@ -354,13 +343,11 @@ public class NativeAnimatedNodesManager(
val parentNode =
animatedNodes.get(parentNodeTag)
?: throw JSApplicationIllegalArgumentException(
("connectAnimatedNodes: Animated node with tag (parent) [${parentNodeTag}] does not exist")
)
("connectAnimatedNodes: Animated node with tag (parent) [${parentNodeTag}] does not exist"))
val childNode =
animatedNodes.get(childNodeTag)
?: throw JSApplicationIllegalArgumentException(
("connectAnimatedNodes: Animated node with tag (child) [${childNodeTag}] does not exist")
)
("connectAnimatedNodes: Animated node with tag (child) [${childNodeTag}] does not exist"))
parentNode.addChild(childNode)
updatedNodes.put(childNodeTag, childNode)
}
@@ -369,13 +356,11 @@ public class NativeAnimatedNodesManager(
val parentNode =
animatedNodes.get(parentNodeTag)
?: throw JSApplicationIllegalArgumentException(
("disconnectAnimatedNodes: Animated node with tag (parent) [${parentNodeTag}] does not exist")
)
("disconnectAnimatedNodes: Animated node with tag (parent) [${parentNodeTag}] does not exist"))
val childNode =
animatedNodes.get(childNodeTag)
?: throw JSApplicationIllegalArgumentException(
("disconnectAnimatedNodes: Animated node with tag (child) [${childNodeTag}] does not exist")
)
("disconnectAnimatedNodes: Animated node with tag (child) [${childNodeTag}] does not exist"))
parentNode.removeChild(childNode)
updatedNodes.put(childNodeTag, childNode)
}
@@ -385,12 +370,10 @@ public class NativeAnimatedNodesManager(
val node =
animatedNodes.get(animatedNodeTag)
?: throw JSApplicationIllegalArgumentException(
("connectAnimatedNodeToView: Animated node with tag [${animatedNodeTag}] does not exist")
)
("connectAnimatedNodeToView: Animated node with tag [${animatedNodeTag}] does not exist"))
if (node !is PropsAnimatedNode) {
throw JSApplicationIllegalArgumentException(
("connectAnimatedNodeToView: Animated node connected to view [${viewTag}] should be of type ${PropsAnimatedNode::class.java.name}")
)
("connectAnimatedNodeToView: Animated node connected to view [${viewTag}] should be of type ${PropsAnimatedNode::class.java.name}"))
}
checkNotNull(reactApplicationContext) {
("connectAnimatedNodeToView: Animated node could not be connected, no ReactApplicationContext: $viewTag")
@@ -401,8 +384,7 @@ public class NativeAnimatedNodesManager(
ReactSoftExceptionLogger.logSoftException(
TAG,
ReactNoCrashSoftException(
("connectAnimatedNodeToView: Animated node could not be connected to UIManager - uiManager disappeared for tag: $viewTag")
),
("connectAnimatedNodeToView: Animated node could not be connected to UIManager - uiManager disappeared for tag: $viewTag")),
)
return
}
@@ -416,12 +398,10 @@ public class NativeAnimatedNodesManager(
val node =
animatedNodes.get(animatedNodeTag)
?: throw JSApplicationIllegalArgumentException(
("disconnectAnimatedNodeFromView: Animated node with tag [${animatedNodeTag}] does not exist")
)
("disconnectAnimatedNodeFromView: Animated node with tag [${animatedNodeTag}] does not exist"))
if (node !is PropsAnimatedNode) {
throw JSApplicationIllegalArgumentException(
("disconnectAnimatedNodeFromView: Animated node connected to view [${viewTag}] should be of type ${PropsAnimatedNode::class.java.name}")
)
("disconnectAnimatedNodeFromView: Animated node connected to view [${viewTag}] should be of type ${PropsAnimatedNode::class.java.name}"))
}
node.disconnectFromView(viewTag)
}
@@ -431,8 +411,7 @@ public class NativeAnimatedNodesManager(
val node = animatedNodes.get(tag)
if (node == null || node !is ValueAnimatedNode) {
throw JSApplicationIllegalArgumentException(
"getValue: Animated node with tag [$tag] does not exist or is not a 'value' node"
)
"getValue: Animated node with tag [$tag] does not exist or is not a 'value' node")
}
val value = node.getValue()
if (callback != null) {
@@ -463,8 +442,7 @@ public class NativeAnimatedNodesManager(
// default values since it will never actually update the view.
if (node !is PropsAnimatedNode) {
throw JSApplicationIllegalArgumentException(
"Animated node connected to view [?] should be of type ${PropsAnimatedNode::class.java.name}"
)
"Animated node connected to view [?] should be of type ${PropsAnimatedNode::class.java.name}")
}
node.restoreDefaultValues()
}
@@ -479,12 +457,10 @@ public class NativeAnimatedNodesManager(
val node =
animatedNodes.get(nodeTag)
?: throw JSApplicationIllegalArgumentException(
"addAnimatedEventToView: Animated node with tag [$nodeTag] does not exist"
)
"addAnimatedEventToView: Animated node with tag [$nodeTag] does not exist")
if (node !is ValueAnimatedNode) {
throw JSApplicationIllegalArgumentException(
("addAnimatedEventToView: Animated node on view [${viewTag}] connected to event handler (${eventHandlerName}) should be of type ${ValueAnimatedNode::class.java.name}")
)
("addAnimatedEventToView: Animated node on view [${viewTag}] connected to event handler (${eventHandlerName}) should be of type ${ValueAnimatedNode::class.java.name}"))
}
val path = checkNotNull(eventMapping.getArray("nativeEventPath"))
@@ -771,8 +747,7 @@ public class NativeAnimatedNodesManager(
val reason = if (cyclesDetected > 0) ("cycles ($cyclesDetected)") else "disconnected regions"
val ex =
IllegalStateException(
("Looks like animated nodes graph has ${reason}, there are $activeNodesCount but toposort visited only $updatedNodesCount")
)
("Looks like animated nodes graph has ${reason}, there are $activeNodesCount but toposort visited only $updatedNodesCount"))
if (eventListenerInitializedForFabric && cyclesDetected == 0) {
// TODO T71377544: investigate these SoftExceptions and see if we can remove entirely
// or fix the root cause
@@ -45,11 +45,9 @@ internal class ObjectAnimatedNode(
ReadableType.String -> result.pushString(source.getString(i))
ReadableType.Map -> {
val map = source.getMap(i)
if (
map != null &&
map.hasKey(NODE_TAG_KEY) &&
map.getType(NODE_TAG_KEY) == ReadableType.Number
) {
if (map != null &&
map.hasKey(NODE_TAG_KEY) &&
map.getType(NODE_TAG_KEY) == ReadableType.Number) {
val node = nativeAnimatedNodesManager.getNodeById(map.getInt(NODE_TAG_KEY))
requireNotNull(node) { "Mapped value node does not exist" }
if (node is ValueAnimatedNode) {
@@ -87,11 +85,9 @@ internal class ObjectAnimatedNode(
ReadableType.String -> result.putString(propKey, source.getString(propKey))
ReadableType.Map -> {
val map = source.getMap(propKey)
if (
map != null &&
map.hasKey(NODE_TAG_KEY) &&
map.getType(NODE_TAG_KEY) == ReadableType.Number
) {
if (map != null &&
map.hasKey(NODE_TAG_KEY) &&
map.getType(NODE_TAG_KEY) == ReadableType.Number) {
val node = nativeAnimatedNodesManager.getNodeById(map.getInt(NODE_TAG_KEY))
requireNotNull(node) { "Mapped value node does not exist" }
if (node is ValueAnimatedNode) {
@@ -43,8 +43,7 @@ internal class PropsAnimatedNode(
fun connectToView(viewTag: Int, uiManager: UIManager?) {
if (connectedViewTag != -1) {
throw JSApplicationIllegalArgumentException(
"Animated node $tag is already attached to a view: $connectedViewTag"
)
"Animated node $tag is already attached to a view: $connectedViewTag")
}
connectedViewTag = viewTag
connectedViewUIManager = uiManager
@@ -55,8 +54,7 @@ internal class PropsAnimatedNode(
throw JSApplicationIllegalArgumentException(
"Attempting to disconnect view that has " +
"not been connected with the given animated node: $viewTag " +
"but is connected to view $connectedViewTag"
)
"but is connected to view $connectedViewTag")
}
connectedViewTag = -1
}
@@ -105,8 +103,7 @@ internal class PropsAnimatedNode(
node.collectViewUpdates(key, propMap)
} else {
throw IllegalArgumentException(
"Unsupported type of node used in property node ${node.javaClass}"
)
"Unsupported type of node used in property node ${node.javaClass}")
}
}
connectedViewUIManager?.synchronouslyUpdateViewOnUIThread(connectedViewTag, propMap)
@@ -52,8 +52,7 @@ internal class StyleAnimatedNode(
node.collectViewUpdates(key, propsMap)
} else {
throw IllegalArgumentException(
"Unsupported type of node used in property node ${node.javaClass}"
)
"Unsupported type of node used in property node ${node.javaClass}")
}
}
}
@@ -42,8 +42,7 @@ internal class SubtractionAnimatedNode(
}
} else {
throw JSApplicationCausedNativeException(
"Illegal node ID set as an input for Animated.subtract node"
)
"Illegal node ID set as an input for Animated.subtract node")
}
}
}
@@ -60,8 +60,7 @@ internal class TransformAnimatedNode(
throw IllegalArgumentException(
"Unsupported type of node used as a transform child " +
"node " +
node.javaClass
)
node.javaClass)
}
} else {
(transformConfig as StaticTransformConfig).value
@@ -75,8 +75,7 @@ public object Arguments {
get() = java.lang.reflect.Array.getLength(objects)
override fun get(index: Int): Any? = java.lang.reflect.Array.get(objects, index)
}
)
})
}
private fun addEntry(nativeMap: WritableNativeMap, key: String, value: Any?) {
@@ -134,8 +133,7 @@ public object Arguments {
@Suppress("UNCHECKED_CAST")
@JvmStatic
@Deprecated(
"Use fromJavaArgs(Array<Any?>) instead. This method is added only to retain compatibility with Java consumers."
)
"Use fromJavaArgs(Array<Any?>) instead. This method is added only to retain compatibility with Java consumers.")
public fun fromJavaArgs(args: Any?): WritableNativeArray = fromJavaArgs(args as Array<Any?>)
@JvmStatic
@@ -26,8 +26,7 @@ internal class CallbackImpl(private val jsInstance: JSInstance, private val call
override fun invoke(vararg args: Any?) {
if (invoked) {
throw RuntimeException(
"Illegal callback invocation from native module. This callback type only permits a single invocation from native code."
)
"Illegal callback invocation from native module. This callback type only permits a single invocation from native code.")
}
@Suppress("UNCHECKED_CAST")
jsInstance.invokeCallback(callbackId, Arguments.fromJavaArgs(args as Array<Any?>))
@@ -23,8 +23,7 @@ import com.facebook.react.turbomodule.core.interfaces.NativeMethodCallInvokerHol
*/
@Deprecated(
message =
"This class is deprecated, please to migrate to new architecture using [com.facebook.react.defaults.DefaultReactHost] instead."
)
"This class is deprecated, please to migrate to new architecture using [com.facebook.react.defaults.DefaultReactHost] instead.")
@DoNotStrip
@LegacyArchitecture
public interface CatalystInstance : MemoryPressureListener, JSInstance, JSBundleLoaderDelegate {
@@ -129,19 +128,16 @@ public interface CatalystInstance : MemoryPressureListener, JSInstance, JSBundle
@Deprecated(
message =
"This method is deprecated, please to migrate to new architecture using [com.facebook.react.defaults.DefaultReactHost] instead."
)
"This method is deprecated, please to migrate to new architecture using [com.facebook.react.defaults.DefaultReactHost] instead.")
public fun setTurboModuleRegistry(turboModuleRegistry: TurboModuleRegistry)
@Deprecated(
message =
"This method is deprecated, please to migrate to new architecture using [com.facebook.react.defaults.DefaultReactHost] instead."
)
"This method is deprecated, please to migrate to new architecture using [com.facebook.react.defaults.DefaultReactHost] instead.")
public fun setFabricUIManager(fabricUIManager: UIManager)
@Deprecated(
message =
"This method is deprecated, please to migrate to new architecture using [com.facebook.react.defaults.DefaultReactHost] instead."
)
"This method is deprecated, please to migrate to new architecture using [com.facebook.react.defaults.DefaultReactHost] instead.")
public fun getFabricUIManager(): UIManager?
}
@@ -54,8 +54,7 @@ public object ColorPropConverter {
val resourcePaths =
value.getArray(JSON_KEY)
?: throw JSApplicationCausedNativeException(
"ColorValue: The `$JSON_KEY` must be an array of color resource path strings."
)
"ColorValue: The `$JSON_KEY` must be an array of color resource path strings.")
for (i in 0 until resourcePaths.size()) {
val result = resolveResourcePath(context, resourcePaths.getString(i))
@@ -65,8 +64,7 @@ public object ColorPropConverter {
}
throw JSApplicationCausedNativeException(
"ColorValue: None of the paths in the `$JSON_KEY` array resolved to a color resource."
)
"ColorValue: None of the paths in the `$JSON_KEY` array resolved to a color resource.")
}
throw JSApplicationCausedNativeException("ColorValue: the value must be a number or Object.")
@@ -103,8 +101,7 @@ public object ColorPropConverter {
val resourcePaths =
value.getArray(JSON_KEY)
?: throw JSApplicationCausedNativeException(
"ColorValue: The `$JSON_KEY` must be an array of color resource path strings."
)
"ColorValue: The `$JSON_KEY` must be an array of color resource path strings.")
for (i in 0 until resourcePaths.size()) {
val result = resolveResourcePath(context, resourcePaths.getString(i))
@@ -114,8 +111,7 @@ public object ColorPropConverter {
}
throw JSApplicationCausedNativeException(
"ColorValue: None of the paths in the `$JSON_KEY` array resolved to a color resource."
)
"ColorValue: None of the paths in the `$JSON_KEY` array resolved to a color resource.")
}
throw JSApplicationCausedNativeException("ColorValue: the value must be a number or Object.")
@@ -33,8 +33,7 @@ protected constructor(
}
@Deprecated(
"The method canOverrideExistingModule is not used in the New Architecture and will be removed in a future release."
)
"The method canOverrideExistingModule is not used in the New Architecture and will be removed in a future release.")
override fun canOverrideExistingModule(): Boolean = false
override fun invalidate() {
@@ -20,8 +20,7 @@ internal class DimensionPropConverter {
is String -> YogaValue.parse(value)
else ->
throw JSApplicationCausedNativeException(
"DimensionValue: the value must be a number or string."
)
"DimensionValue: the value must be a number or string.")
}
}
}
@@ -190,8 +190,7 @@ internal class JavaMethodWrapper(
if (jsArgumentsNeeded != parameters.size()) {
throw NativeArgumentsParseException(
"$traceName got ${parameters.size()} arguments, expected $jsArgumentsNeeded"
)
"$traceName got ${parameters.size()} arguments, expected $jsArgumentsNeeded")
}
var i = 0
@@ -98,8 +98,7 @@ public class JavaOnlyMap() : ReadableMap, WritableMap {
value is Dynamic -> value.type
else -> {
throw IllegalArgumentException(
"Invalid value $value for key $name contained in JavaOnlyMap"
)
"Invalid value $value for key $name contained in JavaOnlyMap")
}
}
}
@@ -57,8 +57,7 @@ public class JavaScriptModuleRegistry {
for (method in moduleInterface.declaredMethods) {
if (!methodNames.add(method.name)) {
throw AssertionError(
"Method overloading is unsupported: ${moduleInterface.name}#${method.name}"
)
"Method overloading is unsupported: ${moduleInterface.name}#${method.name}")
}
}
}
@@ -43,8 +43,7 @@ public class NativeModuleRegistry(
}
@get:JvmName(
"getCxxModules"
) // This is needed till there are Java Consumer of this API inside React
"getCxxModules") // This is needed till there are Java Consumer of this API inside React
// Native
internal val cxxModules: List<ModuleHolder>
get() = buildList {
@@ -57,8 +56,7 @@ public class NativeModuleRegistry(
/** Adds any new modules to the current module registry */
@JvmName(
"registerModules"
) // This is needed till there are Java Consumer of this API inside React
"registerModules") // This is needed till there are Java Consumer of this API inside React
// Native
internal fun registerModules(newRegister: NativeModuleRegistry) {
check(reactApplicationContext == newRegister.reactApplicationContext) {
@@ -75,8 +73,7 @@ public class NativeModuleRegistry(
}
@JvmName(
"notifyJSInstanceDestroy"
) // This is needed till there are Java Consumer of this API inside
"notifyJSInstanceDestroy") // This is needed till there are Java Consumer of this API inside
// React Native
internal fun notifyJSInstanceDestroy() {
reactApplicationContext.assertOnNativeModulesQueueThread()
@@ -95,8 +92,7 @@ public class NativeModuleRegistry(
internal fun notifyJSInstanceInitialized() {
reactApplicationContext.assertOnNativeModulesQueueThread(
"From version React Native v0.44, " +
"native modules are explicitly not initialized on the UI thread."
)
"native modules are explicitly not initialized on the UI thread.")
logMarker(ReactMarkerConstants.NATIVE_MODULE_INITIALIZE_START)
beginSection(Systrace.TRACE_TAG_REACT, "NativeModuleRegistry_notifyJSInstanceInitialized")
try {
@@ -63,8 +63,7 @@ public open class ReadableNativeMap protected constructor() : NativeMap(), Reada
private inline fun <reified T> checkInstance(name: String, instance: Any?, type: Class<T>): T =
instance as? T
?: throw UnexpectedNativeTypeException(
"Value for $name cannot be cast from ${instance?.javaClass?.simpleName ?: "NULL"} to ${type.simpleName}"
)
"Value for $name cannot be cast from ${instance?.javaClass?.simpleName ?: "NULL"} to ${type.simpleName}")
private fun getValue(name: String): Any {
if (hasKey(name)) {
@@ -133,8 +132,7 @@ public open class ReadableNativeMap protected constructor() : NativeMap(), Reada
override fun setValue(newValue: Any): Any {
throw UnsupportedOperationException(
"Can't set a value while iterating over a ReadableNativeMap"
)
"Can't set a value while iterating over a ReadableNativeMap")
}
}
}
@@ -91,8 +91,7 @@ public object DefaultNewArchitectureEntryPoint {
when (releaseLevel) {
ReleaseLevel.EXPERIMENTAL -> {
ReactNativeFeatureFlags.override(
ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android()
)
ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android())
}
ReleaseLevel.CANARY -> {
ReactNativeFeatureFlags.override(ReactNativeFeatureFlagsOverrides_RNOSS_Canary_Android())
@@ -103,8 +102,7 @@ public object DefaultNewArchitectureEntryPoint {
fabricEnabled,
bridgelessEnabled,
turboModulesEnabled,
)
)
))
}
}
@@ -191,8 +191,7 @@ public object DefaultReactHost {
exceptionHandler: (Exception) -> Unit,
bindingsInstaller: BindingsInstaller?,
): ReactHost
"""
),
"""),
)
@JvmStatic
public fun getDefaultReactHost(
@@ -252,8 +251,7 @@ public object DefaultReactHost {
useDevSupport: Boolean,
cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage>,
): ReactHost
"""
),
"""),
)
@JvmStatic
public fun getDefaultReactHost(
@@ -43,8 +43,7 @@ protected constructor(
DefaultTurboModuleManagerDelegate.Builder()
} else {
error(
"Overriding isNewArchEnabled to false is not supported anymore since React Native 0.82. Please check your MainApplication.kt file, and remove the override for `isNewArchEnabled`."
)
"Overriding isNewArchEnabled to false is not supported anymore since React Native 0.82. Please check your MainApplication.kt file, and remove the override for `isNewArchEnabled`.")
}
override fun getUIManagerProvider(): UIManagerProvider? =
@@ -61,12 +60,10 @@ protected constructor(
reactInstanceManager.createViewManager(viewManagerName)
override fun getViewManagerNames() = reactInstanceManager.viewManagerNames
}
)
})
} else {
ViewManagerRegistry(
reactInstanceManager.getOrCreateViewManagers(reactApplicationContext)
)
reactInstanceManager.getOrCreateViewManagers(reactApplicationContext))
}
FabricUIManagerProviderImpl(componentFactory, viewManagerRegistry)
@@ -74,8 +71,7 @@ protected constructor(
}
} else {
error(
"Overriding isNewArchEnabled to false is not supported anymore since React Native 0.82. Please check your MainApplication.kt file, and remove the override for `isNewArchEnabled`."
)
"Overriding isNewArchEnabled to false is not supported anymore since React Native 0.82. Please check your MainApplication.kt file, and remove the override for `isNewArchEnabled`.")
}
override fun clear() {
@@ -36,8 +36,7 @@ private constructor(
override fun initHybrid(): HybridData {
throw UnsupportedOperationException(
"DefaultTurboModuleManagerDelegate.initHybrid() must never be called!"
)
"DefaultTurboModuleManagerDelegate.initHybrid() must never be called!")
}
public class Builder : ReactPackageTurboModuleManagerDelegate.Builder() {
@@ -92,28 +92,23 @@ public class BundleDownloader public constructor(private val client: OkHttpClien
object : Callback {
override fun onFailure(call: Call, e: IOException) {
// ignore callback if call was cancelled
if (
downloadBundleFromURLCall == null ||
downloadBundleFromURLCall?.isCanceled() == true
) {
if (downloadBundleFromURLCall == null ||
downloadBundleFromURLCall?.isCanceled() == true) {
downloadBundleFromURLCall = null
return
}
downloadBundleFromURLCall = null
val url = call.request().url().toString()
callback.onFailure(
makeGeneric(url, "Could not connect to development server.", "URL: $url", e)
)
makeGeneric(url, "Could not connect to development server.", "URL: $url", e))
}
@Throws(IOException::class)
override fun onResponse(call: Call, response: Response) {
response.use { resp ->
// ignore callback if call was cancelled
if (
downloadBundleFromURLCall == null ||
downloadBundleFromURLCall?.isCanceled() == true
) {
if (downloadBundleFromURLCall == null ||
downloadBundleFromURLCall?.isCanceled() == true) {
downloadBundleFromURLCall = null
return
}
@@ -151,8 +146,7 @@ public class BundleDownloader public constructor(private val client: OkHttpClien
}
}
}
}
)
})
}
@Throws(IOException::class)
@@ -176,9 +170,7 @@ public class BundleDownloader public constructor(private val client: OkHttpClien
"""
.trimIndent())
)
)
.trimIndent())))
return
}
val source = checkNotNull(response.body()?.source())
@@ -212,10 +204,8 @@ public class BundleDownloader public constructor(private val client: OkHttpClien
callback,
)
} else {
if (
!headers.containsKey("Content-Type") ||
headers["Content-Type"] != "application/json"
) {
if (!headers.containsKey("Content-Type") ||
headers["Content-Type"] != "application/json") {
return
}
@@ -251,8 +241,7 @@ public class BundleDownloader public constructor(private val client: OkHttpClien
)
}
}
}
)
})
if (!completed) {
callback.onFailure(
DebugServerException(
@@ -265,9 +254,7 @@ public class BundleDownloader public constructor(private val client: OkHttpClien
"""
.trimIndent())
)
)
.trimIndent())))
}
}
@@ -52,8 +52,7 @@ internal class DebugOverlayController(private val reactContext: ReactContext) {
windowManager.removeView(fpsDebugViewContainer)
fpsDebugViewContainer = null
}
}
)
})
}
companion object {
@@ -29,8 +29,7 @@ internal class DefaultDevSupportManagerFactory : DevSupportManagerFactory {
"Use the other create() method with useDevSupport parameter for New Architecture. This method will be removed in a future release.",
replaceWith =
ReplaceWith(
"create(applicationContext, reactInstanceManagerHelper, packagerPathForJSBundleName, enableOnCreate, redBoxHandler, devBundleDownloadListener, minNumShakes, customPackagerCommandHandlers, surfaceDelegateFactory, devLoadingViewManager, pausedInDebuggerOverlayManager)"
),
"create(applicationContext, reactInstanceManagerHelper, packagerPathForJSBundleName, enableOnCreate, redBoxHandler, devBundleDownloadListener, minNumShakes, customPackagerCommandHandlers, surfaceDelegateFactory, devLoadingViewManager, pausedInDebuggerOverlayManager)"),
)
override fun create(
applicationContext: Context,
@@ -59,11 +59,9 @@ internal class DevInternalSettings(applicationContext: Context, private val list
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
if (listener != null) {
if (
PREFS_FPS_DEBUG_KEY == key ||
PREFS_JS_DEV_MODE_DEBUG_KEY == key ||
PREFS_JS_MINIFY_DEBUG_KEY == key
) {
if (PREFS_FPS_DEBUG_KEY == key ||
PREFS_JS_DEV_MODE_DEBUG_KEY == key ||
PREFS_JS_MINIFY_DEBUG_KEY == key) {
listener.onInternalSettingsChanged()
}
}
@@ -58,8 +58,7 @@ import okio.Okio
* - Genymotion emulator with default settings: 10.0.3.2
*/
@SuppressLint(
"StaticFieldLeak"
) // TODO: This entire class should be rewritten to don't use AsyncTask
"StaticFieldLeak") // TODO: This entire class should be rewritten to don't use AsyncTask
public open class DevServerHelper(
private val settings: DeveloperSettings,
private val applicationContext: Context,
@@ -362,8 +361,7 @@ public open class DevServerHelper(
"http://%s/open-debugger?device=%s",
packagerConnectionSettings.debugServerHost,
Uri.encode(inspectorDeviceId),
)
)
))
if (landingView != null) {
requestUrlBuilder.append("&landingView=" + Uri.encode(landingView))
@@ -384,8 +382,7 @@ public open class DevServerHelper(
}
override fun onResponse(call: Call, response: Response) = Unit
}
)
})
}
private companion object {
@@ -210,14 +210,11 @@ public abstract class DevSupportManagerBase(
return@Supplier null
}
context
}
)
})
}
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
ReactNativeFeatureFlags.perfMonitorV2Enabled() &&
perfMonitorOverlayManager == null
) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
ReactNativeFeatureFlags.perfMonitorV2Enabled() &&
perfMonitorOverlayManager == null) {
perfMonitorOverlayManager =
PerfMonitorOverlayViewManager(
Supplier {
@@ -227,8 +224,7 @@ public abstract class DevSupportManagerBase(
}
context
},
{ openDebugger() },
)
{ openDebugger() })
}
}
@@ -354,8 +350,7 @@ public abstract class DevSupportManagerBase(
val debuggerItemString =
applicationContext.getString(
if (isConnected) R.string.catalyst_debug_open
else R.string.catalyst_debug_open_disabled
)
else R.string.catalyst_debug_open_disabled)
if (!isConnected) {
disabledItemKeys.add(debuggerItemString)
}
@@ -613,16 +608,14 @@ public abstract class DevSupportManagerBase(
applicationContext.getString(
R.string.catalyst_loading_from_url,
parsedURL.host + ":" + port,
)
)
))
devLoadingViewVisible = true
}
@UiThread
protected fun showDevLoadingViewForRemoteJSEnabled() {
devLoadingViewManager?.showMessage(
applicationContext.getString(R.string.catalyst_debug_connecting)
)
applicationContext.getString(R.string.catalyst_debug_connecting))
devLoadingViewVisible = true
}
@@ -903,10 +896,8 @@ public abstract class DevSupportManagerBase(
exported: Boolean,
) {
@SuppressLint("UnspecifiedRegisterReceiverFlag")
if (
Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE &&
context.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE &&
context.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
context.registerReceiver(
receiver,
filter,
@@ -921,8 +912,7 @@ public abstract class DevSupportManagerBase(
devServerHelper.openDebugger(
currentReactContext,
applicationContext.getString(R.string.catalyst_open_debugger_error),
ChromeDevToolsViewKeys.Performance.value,
)
ChromeDevToolsViewKeys.Performance.value)
}
override fun showPausedInDebuggerOverlay(
@@ -944,12 +934,7 @@ public abstract class DevSupportManagerBase(
) {
perfMonitorOverlayManager?.update(
PerfMonitorOverlayManager.PerfMonitorUpdateData(
eventName,
durationMs,
responsivenessScore,
ttl,
)
)
eventName, durationMs, responsivenessScore, ttl))
}
override fun setAdditionalOptionForPackager(name: String, value: String) {
@@ -27,8 +27,7 @@ public interface DevSupportManagerFactory {
"Use the other create() method with useDevSupport parameter for New Architecture. This method will be removed in a future release.",
replaceWith =
ReplaceWith(
"create(applicationContext, reactInstanceManagerHelper, packagerPathForJSBundleName, enableOnCreate, redBoxHandler, devBundleDownloadListener, minNumShakes, customPackagerCommandHandlers, surfaceDelegateFactory, devLoadingViewManager, pausedInDebuggerOverlayManager)"
),
"create(applicationContext, reactInstanceManagerHelper, packagerPathForJSBundleName, enableOnCreate, redBoxHandler, devBundleDownloadListener, minNumShakes, customPackagerCommandHandlers, surfaceDelegateFactory, devLoadingViewManager, pausedInDebuggerOverlayManager)"),
)
public fun create(
applicationContext: Context,
@@ -52,8 +52,7 @@ internal class LogBoxDialogSurfaceDelegate(private val devSupportManager: DevSup
if (context == null || context.isFinishing) {
e(
"Unable to launch logbox because react activity " +
"is not available, here is the error that logbox would've displayed: "
)
"is not available, here is the error that logbox would've displayed: ")
return
}
dialog = LogBoxDialog(context, reactRootView)
@@ -86,8 +86,7 @@ internal class PackagerStatusCheck {
}
callback.onPackagerStatusFetched(true)
}
}
)
})
}
private companion object {
@@ -155,8 +155,7 @@ internal class PerfMonitorOverlayViewManager(
textSize = TEXT_SIZE_PRIMARY
setTextColor(Color.WHITE)
typeface = TYPEFACE_BOLD
}
)
})
buttonInner.addView(
TextView(context).apply {
text = "cmd + A"
@@ -164,8 +163,7 @@ internal class PerfMonitorOverlayViewManager(
setTextColor(Color.WHITE)
alpha = 0.7f
typeface = TYPEFACE_BOLD
}
)
})
val buttonView =
LinearLayout(context).apply {
orientation = LinearLayout.VERTICAL
@@ -139,8 +139,7 @@ internal class RedBoxContentView(
holder.fileView.text = StackTraceHelper.formatFrameSource(frame)
holder.methodView.setTextColor(if (frame.isCollapsed) 0xFFAAAAAA.toInt() else Color.WHITE)
holder.fileView.setTextColor(
if (frame.isCollapsed) 0xFF808080.toInt() else 0xFFB3B3B3.toInt()
)
if (frame.isCollapsed) 0xFF808080.toInt() else 0xFFB3B3B3.toInt())
return frameView
}
}
@@ -188,8 +187,7 @@ internal class RedBoxContentView(
"methodName" to frame.method,
"lineNumber" to frame.line,
"column" to frame.column,
)
)
))
}
}
@@ -155,8 +155,7 @@ internal class RedBoxDialogSurfaceDelegate(private val devSupportManager: DevSup
override fun onHostPause() = Unit
override fun onHostDestroy() = Unit
}
)
})
}
}
}
@@ -210,8 +210,7 @@ public object StackTraceHelper {
frame.lineNumber?.let { putDouble(LINE_NUMBER_KEY, it.toDouble()) }
putString(FILE_KEY, frame.file)
putString(METHOD_NAME_KEY, frame.methodName)
}
)
})
}
return JavaOnlyMap().apply {
@@ -256,7 +255,6 @@ public object StackTraceHelper {
LINE_NUMBER_KEY to line,
COLUMN_KEY to column,
COLLAPSE_KEY to isCollapsed,
)
)
))
}
}
@@ -83,7 +83,6 @@ internal object InspectorNetworkHelper {
listener.onError(e.message)
}
}
}
)
})
}
}
@@ -13,7 +13,7 @@ internal interface PerfMonitorOverlayManager {
val eventName: String,
val durationMs: Int,
val responsivenessScore: Int,
val ttl: Int,
val ttl: Int
)
/** Enable the Perf Monitor overlay. Will be shown when updates are received. */
@@ -69,8 +69,7 @@ public class FabricUIManagerProviderImpl(
} else {
throw IllegalStateException(
"Unable to register FabricUIManager with CatalystInstance, runtimeExecutor and" +
" runtimeScheduler must not be null"
)
" runtimeScheduler must not be null")
}
Systrace.endSection(Systrace.TRACE_TAG_REACT)
@@ -86,8 +86,7 @@ internal class MountingManager(
logSoftException(
TAG,
IllegalStateException(
"Called startSurface more than once for the SurfaceId [$surfaceId]"
),
"Called startSurface more than once for the SurfaceId [$surfaceId]"),
)
}
@@ -159,8 +158,7 @@ internal class MountingManager(
fun getSurfaceManagerEnforced(surfaceId: Int, context: String): SurfaceMountingManager =
getSurfaceManager(surfaceId)
?: throw RetryableMountingLayerException(
("Unable to find SurfaceMountingManager for surfaceId: [$surfaceId]. Context: $context")
)
("Unable to find SurfaceMountingManager for surfaceId: [$surfaceId]. Context: $context"))
fun surfaceIsStopped(surfaceId: Int): Boolean {
if (stoppedSurfaceIds.contains(surfaceId)) {
@@ -216,8 +214,7 @@ internal class MountingManager(
fun getSurfaceManagerForViewEnforced(reactTag: Int): SurfaceMountingManager =
getSurfaceManagerForView(reactTag)
?: throw RetryableMountingLayerException(
"Unable to find SurfaceMountingManager for tag: [$reactTag]"
)
"Unable to find SurfaceMountingManager for tag: [$reactTag]")
fun getViewExists(reactTag: Int): Boolean = getSurfaceManagerForView(reactTag) != null
@@ -178,8 +178,7 @@ internal class IntBufferBatchMountItem(
}
else -> {
throw IllegalArgumentException(
"Invalid type argument to IntBufferBatchMountItem: $type at index: $i"
)
"Invalid type argument to IntBufferBatchMountItem: $type at index: $i")
}
}
}
@@ -218,8 +217,7 @@ internal class IntBufferBatchMountItem(
intBuffer[i++],
intBuffer[i++],
fabricComponentName,
)
)
))
}
INSTRUCTION_DELETE ->
s.append(String.format(Locale.ROOT, "DELETE [%d]\n", intBuffer[i++]))
@@ -231,8 +229,7 @@ internal class IntBufferBatchMountItem(
intBuffer[i++],
intBuffer[i++],
intBuffer[i++],
)
)
))
INSTRUCTION_REMOVE ->
s.append(
String.format(
@@ -241,16 +238,15 @@ internal class IntBufferBatchMountItem(
intBuffer[i++],
intBuffer[i++],
intBuffer[i++],
)
)
))
INSTRUCTION_UPDATE_PROPS -> {
val props = objBuffer[j++]
val propsString =
if (FabricUIManager.IS_DEVELOPMENT_ENVIRONMENT) (props?.toString() ?: "<null>")
else "<hidden>"
s.append(
String.format(Locale.ROOT, "UPDATE PROPS [%d]: %s\n", intBuffer[i++], propsString)
)
String.format(
Locale.ROOT, "UPDATE PROPS [%d]: %s\n", intBuffer[i++], propsString))
}
INSTRUCTION_UPDATE_STATE -> {
val state: StateWrapper? = objBuffer[j++] as StateWrapper?
@@ -258,8 +254,8 @@ internal class IntBufferBatchMountItem(
if (FabricUIManager.IS_DEVELOPMENT_ENVIRONMENT) (state?.toString() ?: "<null>")
else "<hidden>"
s.append(
String.format(Locale.ROOT, "UPDATE STATE [%d]: %s\n", intBuffer[i++], stateString)
)
String.format(
Locale.ROOT, "UPDATE STATE [%d]: %s\n", intBuffer[i++], stateString))
}
INSTRUCTION_UPDATE_LAYOUT ->
s.append(
@@ -275,8 +271,7 @@ internal class IntBufferBatchMountItem(
intBuffer[i++],
intBuffer[i++],
intBuffer[i++],
)
)
))
INSTRUCTION_UPDATE_PADDING ->
s.append(
String.format(
@@ -287,8 +282,7 @@ internal class IntBufferBatchMountItem(
intBuffer[i++],
intBuffer[i++],
intBuffer[i++],
)
)
))
INSTRUCTION_UPDATE_OVERFLOW_INSET ->
s.append(
String.format(
@@ -299,8 +293,7 @@ internal class IntBufferBatchMountItem(
intBuffer[i++],
intBuffer[i++],
intBuffer[i++],
)
)
))
INSTRUCTION_UPDATE_EVENT_EMITTER -> {
j += 1
s.append(String.format(Locale.ROOT, "UPDATE EVENTEMITTER [%d]\n", intBuffer[i++]))
@@ -308,8 +301,7 @@ internal class IntBufferBatchMountItem(
else -> {
FLog.e(TAG, "String so far: $s")
throw IllegalArgumentException(
"Invalid type argument to IntBufferBatchMountItem: $type at index: $i"
)
"Invalid type argument to IntBufferBatchMountItem: $type at index: $i")
}
}
}
@@ -50,8 +50,7 @@ internal class InteropEventEmitter(private val reactContext: ReactContext) : RCT
changedIndices: WritableArray,
) {
throw UnsupportedOperationException(
"EventEmitter#receiveTouches is not supported by the Fabric Interop Layer"
)
"EventEmitter#receiveTouches is not supported by the Fabric Interop Layer")
}
@VisibleForTesting
@@ -56,11 +56,9 @@ internal object TurboModuleInteropUtils {
if (returnType != MutableMap::class.java) {
throw ParsingException(moduleName, "getConstants must return a Map")
}
} else if (
(annotation != null) &&
((annotation.isBlockingSynchronousMethod && returnType == Void.TYPE) ||
(!annotation.isBlockingSynchronousMethod && returnType != Void.TYPE))
) {
} else if ((annotation != null) &&
((annotation.isBlockingSynchronousMethod && returnType == Void.TYPE) ||
(!annotation.isBlockingSynchronousMethod && returnType != Void.TYPE))) {
throw ParsingException(
moduleName,
"TurboModule system assumes returnType == void iff the method is synchronous.",
@@ -73,8 +71,7 @@ internal object TurboModuleInteropUtils {
createJniSignature(moduleName, methodName, paramClasses, returnType),
createJSIReturnKind(moduleName, methodName, paramClasses, returnType),
getJsArgCount(moduleName, methodName, paramClasses),
)
)
))
}
return methodDescriptors
@@ -128,18 +125,16 @@ internal object TurboModuleInteropUtils {
return "F"
}
if (
paramClass == Boolean::class.javaObjectType ||
paramClass == Int::class.javaObjectType ||
paramClass == Double::class.javaObjectType ||
paramClass == Float::class.javaObjectType ||
paramClass == String::class.java ||
paramClass == Callback::class.java ||
paramClass == Promise::class.java ||
paramClass == ReadableMap::class.java ||
paramClass == ReadableArray::class.java ||
paramClass == Dynamic::class.java
) {
if (paramClass == Boolean::class.javaObjectType ||
paramClass == Int::class.javaObjectType ||
paramClass == Double::class.javaObjectType ||
paramClass == Float::class.javaObjectType ||
paramClass == String::class.java ||
paramClass == Callback::class.java ||
paramClass == Promise::class.java ||
paramClass == ReadableMap::class.java ||
paramClass == ReadableArray::class.java ||
paramClass == Dynamic::class.java) {
return convertClassToJniType(paramClass)
}
@@ -175,16 +170,14 @@ internal object TurboModuleInteropUtils {
return "V"
}
if (
returnClass == Boolean::class.javaObjectType ||
returnClass == Integer::class.javaObjectType ||
returnClass == Double::class.javaObjectType ||
returnClass == Float::class.javaObjectType ||
returnClass == String::class.java ||
returnClass == WritableMap::class.java ||
returnClass == WritableArray::class.java ||
returnClass == MutableMap::class.java
) {
if (returnClass == Boolean::class.javaObjectType ||
returnClass == Integer::class.javaObjectType ||
returnClass == Double::class.javaObjectType ||
returnClass == Float::class.javaObjectType ||
returnClass == String::class.java ||
returnClass == WritableMap::class.java ||
returnClass == WritableArray::class.java ||
returnClass == MutableMap::class.java) {
return convertClassToJniType(returnClass)
}
@@ -247,21 +240,17 @@ internal object TurboModuleInteropUtils {
i += 1
}
if (
returnClass == Boolean::class.javaPrimitiveType ||
returnClass == Boolean::class.javaObjectType
) {
if (returnClass == Boolean::class.javaPrimitiveType ||
returnClass == Boolean::class.javaObjectType) {
return "BooleanKind"
}
if (
returnClass == Double::class.javaPrimitiveType ||
returnClass == Double::class.javaObjectType ||
returnClass == Float::class.javaPrimitiveType ||
returnClass == Float::class.javaObjectType ||
returnClass == Int::class.javaPrimitiveType ||
returnClass == Int::class.javaObjectType
) {
if (returnClass == Double::class.javaPrimitiveType ||
returnClass == Double::class.javaObjectType ||
returnClass == Float::class.javaPrimitiveType ||
returnClass == Float::class.javaObjectType ||
returnClass == Int::class.javaPrimitiveType ||
returnClass == Int::class.javaObjectType) {
return "NumberKind"
}
@@ -300,15 +289,13 @@ internal object TurboModuleInteropUtils {
moduleName: String,
message: String,
) : super(
("Unable to parse @ReactMethod annotations from native module: ${moduleName}. Details: ${message}")
)
("Unable to parse @ReactMethod annotations from native module: ${moduleName}. Details: ${message}"))
constructor(
moduleName: String,
methodName: String,
message: String,
) : super(
("Unable to parse @ReactMethod annotation from native module method: ${moduleName}.${methodName}(). Details: ${message}")
)
("Unable to parse @ReactMethod annotation from native module method: ${moduleName}.${methodName}(). Details: ${message}"))
}
}
@@ -76,10 +76,9 @@ public class HeadlessJsTaskContext private constructor(reactContext: ReactContex
)
check(
!(reactContext.lifecycleState == LifecycleState.RESUMED &&
!taskConfig.isAllowedInForeground)
) {
"Tried to start task ${taskConfig.taskKey} while in foreground, but this is not allowed."
}
!taskConfig.isAllowedInForeground)) {
"Tried to start task ${taskConfig.taskKey} while in foreground, but this is not allowed."
}
activeTasks.add(taskId)
activeTaskConfigs[taskId] = HeadlessJsTaskConfig(taskConfig)
if (reactContext.hasActiveReactInstance()) {

Some files were not shown because too many files have changed in this diff Show More