mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Compare commits
48
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a429f4169c | ||
|
|
05f073d346 | ||
|
|
a0ca57538f | ||
|
|
292f3a4cab | ||
|
|
68231cb949 | ||
|
|
1f62529dc4 | ||
|
|
3956955eaa | ||
|
|
83d38501b8 | ||
|
|
d7d5535fe1 | ||
|
|
0e7ba9094e | ||
|
|
5a6a42c7d0 | ||
|
|
fe656be26e | ||
|
|
c9a96715ef | ||
|
|
027b8032c2 | ||
|
|
35f0e1cca2 | ||
|
|
dd472101b7 | ||
|
|
623d481991 | ||
|
|
cba1d4bae7 | ||
|
|
44f2a08371 | ||
|
|
d7550293a2 | ||
|
|
cc1d2853fb | ||
|
|
dc9db01665 | ||
|
|
91df5a4a0f | ||
|
|
4da586ead9 | ||
|
|
de3c1ee097 | ||
|
|
e1a1cead43 | ||
|
|
7211119d23 | ||
|
|
6ab7b70241 | ||
|
|
af384a914a | ||
|
|
566d30f88a | ||
|
|
4afc47a588 | ||
|
|
2cd48ef351 | ||
|
|
65cdd5b82c | ||
|
|
66a2f1d312 | ||
|
|
79d55542aa | ||
|
|
f8fc90e754 | ||
|
|
ec4ead59e1 | ||
|
|
fd273f83e0 | ||
|
|
ecd138e267 | ||
|
|
b91a449e7f | ||
|
|
6ba7cb3102 | ||
|
|
e5dd7d68bf | ||
|
|
a12036f7be | ||
|
|
3e46cb384c | ||
|
|
667ba76aef | ||
|
|
9a3958a619 | ||
|
|
4d90f84869 | ||
|
|
3a68f14ac2 |
@@ -8,7 +8,7 @@ runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Setup gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
with:
|
||||
gradle-version: wrapper
|
||||
# We want the Gradle cache to be written only on main/-stable branches run, and only for jobs with `cache-read-only` == false (i.e. `build_android`).
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
name: "Validate Gradle Wrapper"
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
validation:
|
||||
name: "Validation"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: gradle/actions/wrapper-validation@v3
|
||||
+2
-5
@@ -93,16 +93,13 @@
|
||||
"nullthrows": "^1.1.1",
|
||||
"prettier": "2.8.8",
|
||||
"prettier-plugin-hermes-parser": "0.24.0",
|
||||
"react": "19.0.0-rc-fb9a90fa48-20240614",
|
||||
"react-test-renderer": "19.0.0-rc-fb9a90fa48-20240614",
|
||||
"react": "18.3.1",
|
||||
"react-test-renderer": "18.3.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"shelljs": "^0.8.5",
|
||||
"signedsource": "^1.0.0",
|
||||
"supports-color": "^7.1.0",
|
||||
"typescript": "5.0.4",
|
||||
"ws": "^6.2.3"
|
||||
},
|
||||
"resolutions": {
|
||||
"react-is": "19.0.0-rc-fb9a90fa48-20240614"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ module.exports = {
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.js'],
|
||||
parser: 'hermes-eslint',
|
||||
parser: '@babel/eslint-parser',
|
||||
plugins: ['ft-flow'],
|
||||
rules: {
|
||||
// Flow Plugin
|
||||
@@ -51,7 +51,7 @@ module.exports = {
|
||||
},
|
||||
{
|
||||
files: ['*.jsx'],
|
||||
parser: 'hermes-eslint',
|
||||
parser: '@babel/eslint-parser',
|
||||
},
|
||||
{
|
||||
files: ['*.ts', '*.tsx'],
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@babel/eslint-parser": "^7.25.1",
|
||||
"@react-native/eslint-plugin": "0.77.0-main",
|
||||
"@typescript-eslint/eslint-plugin": "^7.1.1",
|
||||
"@typescript-eslint/parser": "^7.1.1",
|
||||
@@ -30,8 +31,7 @@
|
||||
"eslint-plugin-jest": "^27.9.0",
|
||||
"eslint-plugin-react": "^7.30.1",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-native": "^4.0.0",
|
||||
"hermes-eslint": "0.24.0"
|
||||
"eslint-plugin-react-native": "^4.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": ">=8",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[versions]
|
||||
agp = "8.7.1"
|
||||
agp = "8.7.2"
|
||||
gson = "2.8.9"
|
||||
guava = "31.0.1-jre"
|
||||
javapoet = "1.13.0"
|
||||
|
||||
+7
-4
@@ -59,15 +59,15 @@ abstract class GenerateAutolinkingNewArchitecturesFileTask : DefaultTask() {
|
||||
val cxxModuleCMakeListsPath = dep.cxxModuleCMakeListsPath
|
||||
if (libraryName != null && cmakeListsPath != null) {
|
||||
// If user provided a custom cmakeListsPath, let's honor it.
|
||||
val nativeFolderPath = cmakeListsPath.replace("CMakeLists.txt", "")
|
||||
val nativeFolderPath = sanitizeCmakeListsPath(cmakeListsPath)
|
||||
addDirectoryString +=
|
||||
"add_subdirectory($nativeFolderPath ${libraryName}_autolinked_build)"
|
||||
"add_subdirectory(\"$nativeFolderPath\" ${libraryName}_autolinked_build)"
|
||||
}
|
||||
if (cxxModuleCMakeListsPath != null) {
|
||||
// If user provided a custom cxxModuleCMakeListsPath, let's honor it.
|
||||
val nativeFolderPath = cxxModuleCMakeListsPath.replace("CMakeLists.txt", "")
|
||||
val nativeFolderPath = sanitizeCmakeListsPath(cxxModuleCMakeListsPath)
|
||||
addDirectoryString +=
|
||||
"\nadd_subdirectory($nativeFolderPath ${libraryName}_cxxmodule_autolinked_build)"
|
||||
"\nadd_subdirectory(\"$nativeFolderPath\" ${libraryName}_cxxmodule_autolinked_build)"
|
||||
}
|
||||
addDirectoryString
|
||||
}
|
||||
@@ -159,6 +159,9 @@ abstract class GenerateAutolinkingNewArchitecturesFileTask : DefaultTask() {
|
||||
const val COMPONENT_DESCRIPTOR_FILENAME = "ComponentDescriptors.h"
|
||||
const val COMPONENT_INCLUDE_PATH = "react/renderer/components"
|
||||
|
||||
internal fun sanitizeCmakeListsPath(cmakeListsPath: String): String =
|
||||
cmakeListsPath.replace("CMakeLists.txt", "").replace(" ", "\\ ")
|
||||
|
||||
// language=cmake
|
||||
val CMAKE_TEMPLATE =
|
||||
"""
|
||||
|
||||
+2
-5
@@ -53,11 +53,8 @@ internal object NdkConfiguratorUtils {
|
||||
if (cmakeArgs.none { it.startsWith("-DANDROID_STL") }) {
|
||||
cmakeArgs.add("-DANDROID_STL=c++_shared")
|
||||
}
|
||||
// Due to the new NDK toolchain file, the C++ flags gets overridden between compilation
|
||||
// units. This is causing some libraries to don't be compiled with -DANDROID and other
|
||||
// crucial flags. This can be revisited once we bump to NDK 25/26
|
||||
if (cmakeArgs.none { it.startsWith("-DANDROID_USE_LEGACY_TOOLCHAIN_FILE") }) {
|
||||
cmakeArgs.add("-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON")
|
||||
if (cmakeArgs.none { it.startsWith("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES") }) {
|
||||
cmakeArgs.add("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON")
|
||||
}
|
||||
|
||||
val architectures = project.getReactNativeArchitectures()
|
||||
|
||||
+23
-4
@@ -11,6 +11,7 @@ import com.facebook.react.model.ModelAutolinkingConfigJson
|
||||
import com.facebook.react.model.ModelAutolinkingDependenciesJson
|
||||
import com.facebook.react.model.ModelAutolinkingDependenciesPlatformAndroidJson
|
||||
import com.facebook.react.model.ModelAutolinkingDependenciesPlatformJson
|
||||
import com.facebook.react.tasks.GenerateAutolinkingNewArchitecturesFileTask.Companion.sanitizeCmakeListsPath
|
||||
import com.facebook.react.tests.createTestTask
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Rule
|
||||
@@ -145,9 +146,9 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
|
||||
# or link against a old prefab target (this is needed for React Native 0.76 on).
|
||||
set(REACTNATIVE_MERGED_SO true)
|
||||
|
||||
add_subdirectory(./a/directory/ aPackage_autolinked_build)
|
||||
add_subdirectory(./another/directory/ anotherPackage_autolinked_build)
|
||||
add_subdirectory(./another/directory/cxx/ anotherPackage_cxxmodule_autolinked_build)
|
||||
add_subdirectory("./a/directory/" aPackage_autolinked_build)
|
||||
add_subdirectory("./another/directory/with\ spaces/" anotherPackage_autolinked_build)
|
||||
add_subdirectory("./another/directory/cxx/" anotherPackage_cxxmodule_autolinked_build)
|
||||
|
||||
set(AUTOLINKED_LIBRARIES
|
||||
react_codegen_aPackage
|
||||
@@ -258,6 +259,24 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
|
||||
.trimIndent())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sanitizeCmakeListsPath_withPathEndingWithFileName_removesFilename() {
|
||||
val input = "./a/directory/CMakeLists.txt"
|
||||
assertThat(sanitizeCmakeListsPath(input)).isEqualTo("./a/directory/")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sanitizeCmakeListsPath_withSpaces_removesSpaces() {
|
||||
val input = "./a/dir ectory/with spaces/"
|
||||
assertThat(sanitizeCmakeListsPath(input)).isEqualTo("./a/dir\\ ectory/with\\ spaces/")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sanitizeCmakeListsPath_withPathEndingWithFileNameAndSpaces_sanitizesIt() {
|
||||
val input = "./a/dir ectory/CMakeLists.txt"
|
||||
assertThat(sanitizeCmakeListsPath(input)).isEqualTo("./a/dir\\ ectory/")
|
||||
}
|
||||
|
||||
private val testDependencies =
|
||||
listOf(
|
||||
ModelAutolinkingDependenciesPlatformAndroidJson(
|
||||
@@ -276,7 +295,7 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
|
||||
buildTypes = emptyList(),
|
||||
libraryName = "anotherPackage",
|
||||
componentDescriptors = listOf("AnotherPackageComponentDescriptor"),
|
||||
cmakeListsPath = "./another/directory/CMakeLists.txt",
|
||||
cmakeListsPath = "./another/directory/with spaces/CMakeLists.txt",
|
||||
cxxModuleCMakeListsPath = "./another/directory/cxx/CMakeLists.txt",
|
||||
cxxModuleHeaderName = "AnotherCxxModule",
|
||||
cxxModuleCMakeListsModuleName = "another_cxxModule",
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "19.0.0-rc-fb9a90fa48-20240614",
|
||||
"react": "18.3.1",
|
||||
"react-native": "1000.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -28,7 +28,7 @@
|
||||
"eslint": "^8.19.0",
|
||||
"jest": "^29.6.3",
|
||||
"listr2": "^8.2.1",
|
||||
"react-test-renderer": "19.0.0-rc-fb9a90fa48-20240614",
|
||||
"react-test-renderer": "18.3.1",
|
||||
"rxjs": "^7.8.1"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
+10
-3
@@ -286,6 +286,11 @@ export interface UnsafeAnyTypeAnnotation {
|
||||
readonly type: 'AnyTypeAnnotation',
|
||||
}
|
||||
|
||||
export interface NativeModuleNumberLiteralTypeAnnotation {
|
||||
readonly type: 'NumberLiteralTypeAnnotation';
|
||||
readonly value: number;
|
||||
}
|
||||
|
||||
export interface NativeModuleStringTypeAnnotation {
|
||||
readonly type: 'StringTypeAnnotation';
|
||||
}
|
||||
@@ -320,10 +325,10 @@ export interface NativeModuleBooleanTypeAnnotation {
|
||||
readonly type: 'BooleanTypeAnnotation';
|
||||
}
|
||||
|
||||
export type NativeModuleEnumMembers = readonly {
|
||||
export type NativeModuleEnumMember = {
|
||||
readonly name: string;
|
||||
readonly value: string | number;
|
||||
}[];
|
||||
};
|
||||
|
||||
export type NativeModuleEnumMemberType =
|
||||
| 'NumberTypeAnnotation'
|
||||
@@ -339,7 +344,7 @@ export interface NativeModuleEnumDeclarationWithMembers {
|
||||
name: string;
|
||||
type: 'EnumDeclarationWithMembers';
|
||||
memberType: NativeModuleEnumMemberType;
|
||||
members: NativeModuleEnumMembers;
|
||||
members: readonly NativeModuleEnumMember[];
|
||||
}
|
||||
|
||||
export interface NativeModuleGenericObjectTypeAnnotation {
|
||||
@@ -380,6 +385,7 @@ export type NativeModuleEventEmitterBaseTypeAnnotation =
|
||||
| NativeModuleFloatTypeAnnotation
|
||||
| NativeModuleInt32TypeAnnotation
|
||||
| NativeModuleNumberTypeAnnotation
|
||||
| NativeModuleNumberLiteralTypeAnnotation
|
||||
| NativeModuleStringTypeAnnotation
|
||||
| NativeModuleStringLiteralTypeAnnotation
|
||||
| NativeModuleStringLiteralUnionTypeAnnotation
|
||||
@@ -399,6 +405,7 @@ export type NativeModuleBaseTypeAnnotation =
|
||||
| NativeModuleStringLiteralTypeAnnotation
|
||||
| NativeModuleStringLiteralUnionTypeAnnotation
|
||||
| NativeModuleNumberTypeAnnotation
|
||||
| NativeModuleNumberLiteralTypeAnnotation
|
||||
| NativeModuleInt32TypeAnnotation
|
||||
| NativeModuleDoubleTypeAnnotation
|
||||
| NativeModuleFloatTypeAnnotation
|
||||
|
||||
+12
-7
@@ -37,6 +37,11 @@ export type Int32TypeAnnotation = $ReadOnly<{
|
||||
type: 'Int32TypeAnnotation',
|
||||
}>;
|
||||
|
||||
export type NumberLiteralTypeAnnotation = $ReadOnly<{
|
||||
type: 'NumberLiteralTypeAnnotation',
|
||||
value: number,
|
||||
}>;
|
||||
|
||||
export type StringTypeAnnotation = $ReadOnly<{
|
||||
type: 'StringTypeAnnotation',
|
||||
}>;
|
||||
@@ -304,12 +309,10 @@ export type NativeModuleNumberTypeAnnotation = $ReadOnly<{
|
||||
type: 'NumberTypeAnnotation',
|
||||
}>;
|
||||
|
||||
export type NativeModuleEnumMembers = $ReadOnlyArray<
|
||||
$ReadOnly<{
|
||||
name: string,
|
||||
value: string | number,
|
||||
}>,
|
||||
>;
|
||||
export type NativeModuleEnumMember = {
|
||||
name: string,
|
||||
value: string | number,
|
||||
};
|
||||
|
||||
export type NativeModuleEnumMemberType =
|
||||
| 'NumberTypeAnnotation'
|
||||
@@ -325,7 +328,7 @@ export type NativeModuleEnumDeclarationWithMembers = {
|
||||
name: string,
|
||||
type: 'EnumDeclarationWithMembers',
|
||||
memberType: NativeModuleEnumMemberType,
|
||||
members: NativeModuleEnumMembers,
|
||||
members: $ReadOnlyArray<NativeModuleEnumMember>,
|
||||
};
|
||||
|
||||
export type NativeModuleGenericObjectTypeAnnotation = $ReadOnly<{
|
||||
@@ -366,6 +369,7 @@ type NativeModuleEventEmitterBaseTypeAnnotation =
|
||||
| FloatTypeAnnotation
|
||||
| Int32TypeAnnotation
|
||||
| NativeModuleNumberTypeAnnotation
|
||||
| NumberLiteralTypeAnnotation
|
||||
| StringTypeAnnotation
|
||||
| StringLiteralTypeAnnotation
|
||||
| StringLiteralUnionTypeAnnotation
|
||||
@@ -385,6 +389,7 @@ export type NativeModuleBaseTypeAnnotation =
|
||||
| StringLiteralTypeAnnotation
|
||||
| StringLiteralUnionTypeAnnotation
|
||||
| NativeModuleNumberTypeAnnotation
|
||||
| NumberLiteralTypeAnnotation
|
||||
| Int32TypeAnnotation
|
||||
| DoubleTypeAnnotation
|
||||
| FloatTypeAnnotation
|
||||
|
||||
@@ -186,6 +186,8 @@ function serializeArg(
|
||||
return wrap(val => `${val}.asNumber()`);
|
||||
case 'Int32TypeAnnotation':
|
||||
return wrap(val => `${val}.asNumber()`);
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return wrap(val => `${val}.asNumber()`);
|
||||
case 'ArrayTypeAnnotation':
|
||||
return wrap(val => `${val}.asObject(rt).asArray(rt)`);
|
||||
case 'FunctionTypeAnnotation':
|
||||
|
||||
@@ -16,7 +16,7 @@ import type {
|
||||
import type {
|
||||
NativeModuleAliasMap,
|
||||
NativeModuleEnumMap,
|
||||
NativeModuleEnumMembers,
|
||||
NativeModuleEnumMember,
|
||||
NativeModuleEnumMemberType,
|
||||
NativeModuleEventEmitterShape,
|
||||
NativeModuleFunctionTypeAnnotation,
|
||||
@@ -179,6 +179,8 @@ function translatePrimitiveJSTypeToCpp(
|
||||
return wrapOptional('jsi::String', isRequired);
|
||||
case 'NumberTypeAnnotation':
|
||||
return wrapOptional('double', isRequired);
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return wrapOptional('double', isRequired);
|
||||
case 'DoubleTypeAnnotation':
|
||||
return wrapOptional('double', isRequired);
|
||||
case 'FloatTypeAnnotation':
|
||||
@@ -407,7 +409,7 @@ struct Bridging<${enumName}> {
|
||||
function generateEnum(
|
||||
hasteModuleName: string,
|
||||
origEnumName: string,
|
||||
members: NativeModuleEnumMembers,
|
||||
members: $ReadOnlyArray<NativeModuleEnumMember>,
|
||||
memberType: NativeModuleEnumMemberType,
|
||||
): string {
|
||||
const enumName = getEnumName(hasteModuleName, origEnumName);
|
||||
|
||||
+7
@@ -136,6 +136,7 @@ function translateEventEmitterTypeToJavaType(
|
||||
case 'StringLiteralUnionTypeAnnotation':
|
||||
return 'String';
|
||||
case 'NumberTypeAnnotation':
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
case 'FloatTypeAnnotation':
|
||||
case 'DoubleTypeAnnotation':
|
||||
case 'Int32TypeAnnotation':
|
||||
@@ -203,6 +204,8 @@ function translateFunctionParamToJavaType(
|
||||
return wrapOptional('String', isRequired);
|
||||
case 'NumberTypeAnnotation':
|
||||
return wrapOptional('double', isRequired);
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return wrapOptional('double', isRequired);
|
||||
case 'FloatTypeAnnotation':
|
||||
return wrapOptional('double', isRequired);
|
||||
case 'DoubleTypeAnnotation':
|
||||
@@ -297,6 +300,8 @@ function translateFunctionReturnTypeToJavaType(
|
||||
return wrapOptional('String', isRequired);
|
||||
case 'NumberTypeAnnotation':
|
||||
return wrapOptional('double', isRequired);
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return wrapOptional('double', isRequired);
|
||||
case 'FloatTypeAnnotation':
|
||||
return wrapOptional('double', isRequired);
|
||||
case 'DoubleTypeAnnotation':
|
||||
@@ -373,6 +378,8 @@ function getFalsyReturnStatementFromReturnType(
|
||||
return '';
|
||||
case 'NumberTypeAnnotation':
|
||||
return nullable ? 'return null;' : 'return 0;';
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return nullable ? 'return null;' : 'return 0;';
|
||||
case 'FloatTypeAnnotation':
|
||||
return nullable ? 'return null;' : 'return 0.0;';
|
||||
case 'DoubleTypeAnnotation':
|
||||
|
||||
@@ -197,6 +197,8 @@ function translateReturnTypeToKind(
|
||||
}
|
||||
case 'NumberTypeAnnotation':
|
||||
return 'NumberKind';
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return 'NumberKind';
|
||||
case 'DoubleTypeAnnotation':
|
||||
return 'NumberKind';
|
||||
case 'FloatTypeAnnotation':
|
||||
@@ -280,6 +282,8 @@ function translateParamTypeToJniType(
|
||||
}
|
||||
case 'NumberTypeAnnotation':
|
||||
return !isRequired ? 'Ljava/lang/Double;' : 'D';
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return !isRequired ? 'Ljava/lang/Double;' : 'D';
|
||||
case 'DoubleTypeAnnotation':
|
||||
return !isRequired ? 'Ljava/lang/Double;' : 'D';
|
||||
case 'FloatTypeAnnotation':
|
||||
@@ -360,6 +364,8 @@ function translateReturnTypeToJniType(
|
||||
}
|
||||
case 'NumberTypeAnnotation':
|
||||
return nullable ? 'Ljava/lang/Double;' : 'D';
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return nullable ? 'Ljava/lang/Double;' : 'D';
|
||||
case 'DoubleTypeAnnotation':
|
||||
return nullable ? 'Ljava/lang/Double;' : 'D';
|
||||
case 'FloatTypeAnnotation':
|
||||
|
||||
Vendored
+2
@@ -23,6 +23,7 @@ import type {
|
||||
NativeModuleObjectTypeAnnotation,
|
||||
NativeModuleTypeAliasTypeAnnotation,
|
||||
Nullable,
|
||||
NumberLiteralTypeAnnotation,
|
||||
ReservedTypeAnnotation,
|
||||
StringLiteralTypeAnnotation,
|
||||
StringLiteralUnionTypeAnnotation,
|
||||
@@ -63,6 +64,7 @@ export type StructTypeAnnotation =
|
||||
| StringLiteralTypeAnnotation
|
||||
| StringLiteralUnionTypeAnnotation
|
||||
| NativeModuleNumberTypeAnnotation
|
||||
| NumberLiteralTypeAnnotation
|
||||
| Int32TypeAnnotation
|
||||
| DoubleTypeAnnotation
|
||||
| FloatTypeAnnotation
|
||||
|
||||
+4
@@ -100,6 +100,8 @@ function toObjCType(
|
||||
return 'NSString *';
|
||||
case 'NumberTypeAnnotation':
|
||||
return wrapCxxOptional('double', isRequired);
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return wrapCxxOptional('double', isRequired);
|
||||
case 'FloatTypeAnnotation':
|
||||
return wrapCxxOptional('double', isRequired);
|
||||
case 'Int32TypeAnnotation':
|
||||
@@ -183,6 +185,8 @@ function toObjCValue(
|
||||
return value;
|
||||
case 'NumberTypeAnnotation':
|
||||
return wrapPrimitive('double');
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return wrapPrimitive('double');
|
||||
case 'FloatTypeAnnotation':
|
||||
return wrapPrimitive('double');
|
||||
case 'Int32TypeAnnotation':
|
||||
|
||||
+4
@@ -91,6 +91,8 @@ function toObjCType(
|
||||
return 'NSString *';
|
||||
case 'NumberTypeAnnotation':
|
||||
return wrapCxxOptional('double', isRequired);
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return wrapCxxOptional('double', isRequired);
|
||||
case 'FloatTypeAnnotation':
|
||||
return wrapCxxOptional('double', isRequired);
|
||||
case 'Int32TypeAnnotation':
|
||||
@@ -173,6 +175,8 @@ function toObjCValue(
|
||||
return RCTBridgingTo('String');
|
||||
case 'NumberTypeAnnotation':
|
||||
return RCTBridgingTo('Double');
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return RCTBridgingTo('Double');
|
||||
case 'FloatTypeAnnotation':
|
||||
return RCTBridgingTo('Double');
|
||||
case 'Int32TypeAnnotation':
|
||||
|
||||
Vendored
+1
@@ -25,6 +25,7 @@ function getEventEmitterTypeObjCType(
|
||||
case 'StringLiteralUnionTypeAnnotation':
|
||||
return 'NSString *_Nonnull';
|
||||
case 'NumberTypeAnnotation':
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return 'NSNumber *_Nonnull';
|
||||
case 'BooleanTypeAnnotation':
|
||||
return 'BOOL';
|
||||
|
||||
Vendored
+6
@@ -263,6 +263,8 @@ function getParamObjCType(
|
||||
return notStruct(wrapOptional('NSString *', !nullable));
|
||||
case 'NumberTypeAnnotation':
|
||||
return notStruct(isRequired ? 'double' : 'NSNumber *');
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return notStruct(isRequired ? 'double' : 'NSNumber *');
|
||||
case 'FloatTypeAnnotation':
|
||||
return notStruct(isRequired ? 'float' : 'NSNumber *');
|
||||
case 'DoubleTypeAnnotation':
|
||||
@@ -344,6 +346,8 @@ function getReturnObjCType(
|
||||
return wrapOptional('NSString *', isRequired);
|
||||
case 'NumberTypeAnnotation':
|
||||
return wrapOptional('NSNumber *', isRequired);
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return wrapOptional('NSNumber *', isRequired);
|
||||
case 'FloatTypeAnnotation':
|
||||
return wrapOptional('NSNumber *', isRequired);
|
||||
case 'DoubleTypeAnnotation':
|
||||
@@ -414,6 +418,8 @@ function getReturnJSType(
|
||||
return 'StringKind';
|
||||
case 'NumberTypeAnnotation':
|
||||
return 'NumberKind';
|
||||
case 'NumberLiteralTypeAnnotation':
|
||||
return 'NumberKind';
|
||||
case 'FloatTypeAnnotation':
|
||||
return 'NumberKind';
|
||||
case 'DoubleTypeAnnotation':
|
||||
|
||||
+1
@@ -126,6 +126,7 @@ import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
||||
export interface Spec extends TurboModule {
|
||||
+passBool?: (arg: boolean) => void;
|
||||
+passNumber: (arg: number) => void;
|
||||
+passNumberLiteral: (arg: 4) => void;
|
||||
+passString: (arg: string) => void;
|
||||
+passStringish: (arg: Stringish) => void;
|
||||
+passStringLiteral: (arg: 'A String Literal') => void;
|
||||
|
||||
+20
@@ -978,6 +978,26 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_BASIC_PA
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
'name': 'passNumberLiteral',
|
||||
'optional': false,
|
||||
'typeAnnotation': {
|
||||
'type': 'FunctionTypeAnnotation',
|
||||
'returnTypeAnnotation': {
|
||||
'type': 'VoidTypeAnnotation'
|
||||
},
|
||||
'params': [
|
||||
{
|
||||
'name': 'arg',
|
||||
'optional': false,
|
||||
'typeAnnotation': {
|
||||
'type': 'NumberLiteralTypeAnnotation',
|
||||
'value': 4
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
'name': 'passString',
|
||||
'optional': false,
|
||||
|
||||
@@ -38,6 +38,7 @@ const {
|
||||
emitCommonTypes,
|
||||
emitDictionary,
|
||||
emitFunction,
|
||||
emitNumberLiteral,
|
||||
emitPromise,
|
||||
emitRootTag,
|
||||
emitUnion,
|
||||
@@ -243,6 +244,9 @@ function translateTypeAnnotation(
|
||||
case 'UnionTypeAnnotation': {
|
||||
return emitUnion(nullable, hasteModuleName, typeAnnotation, parser);
|
||||
}
|
||||
case 'NumberLiteralTypeAnnotation': {
|
||||
return emitNumberLiteral(nullable, typeAnnotation.value);
|
||||
}
|
||||
case 'StringLiteralTypeAnnotation': {
|
||||
return wrapNullable(nullable, {
|
||||
type: 'StringLiteralTypeAnnotation',
|
||||
|
||||
@@ -15,7 +15,7 @@ import type {
|
||||
NamedShape,
|
||||
NativeModuleAliasMap,
|
||||
NativeModuleEnumMap,
|
||||
NativeModuleEnumMembers,
|
||||
NativeModuleEnumMember,
|
||||
NativeModuleEnumMemberType,
|
||||
NativeModuleParamTypeAnnotation,
|
||||
Nullable,
|
||||
@@ -227,7 +227,9 @@ class FlowParser implements Parser {
|
||||
});
|
||||
}
|
||||
|
||||
parseEnumMembers(typeAnnotation: $FlowFixMe): NativeModuleEnumMembers {
|
||||
parseEnumMembers(
|
||||
typeAnnotation: $FlowFixMe,
|
||||
): $ReadOnlyArray<NativeModuleEnumMember> {
|
||||
return typeAnnotation.members.map(member => ({
|
||||
name: member.id.name,
|
||||
value: member.init?.value ?? member.id.name,
|
||||
|
||||
+4
-2
@@ -15,7 +15,7 @@ import type {
|
||||
NamedShape,
|
||||
NativeModuleAliasMap,
|
||||
NativeModuleEnumMap,
|
||||
NativeModuleEnumMembers,
|
||||
NativeModuleEnumMember,
|
||||
NativeModuleEnumMemberType,
|
||||
NativeModuleParamTypeAnnotation,
|
||||
Nullable,
|
||||
@@ -240,7 +240,9 @@ export interface Parser {
|
||||
/**
|
||||
* Calculates enum's members
|
||||
*/
|
||||
parseEnumMembers(typeAnnotation: $FlowFixMe): NativeModuleEnumMembers;
|
||||
parseEnumMembers(
|
||||
typeAnnotation: $FlowFixMe,
|
||||
): $ReadOnlyArray<NativeModuleEnumMember>;
|
||||
|
||||
/**
|
||||
* Given a node, it returns true if it is a module interface
|
||||
|
||||
+4
-2
@@ -15,7 +15,7 @@ import type {
|
||||
NamedShape,
|
||||
NativeModuleAliasMap,
|
||||
NativeModuleEnumMap,
|
||||
NativeModuleEnumMembers,
|
||||
NativeModuleEnumMember,
|
||||
NativeModuleEnumMemberType,
|
||||
NativeModuleParamTypeAnnotation,
|
||||
Nullable,
|
||||
@@ -168,7 +168,9 @@ export class MockedParser implements Parser {
|
||||
return;
|
||||
}
|
||||
|
||||
parseEnumMembers(typeAnnotation: $FlowFixMe): NativeModuleEnumMembers {
|
||||
parseEnumMembers(
|
||||
typeAnnotation: $FlowFixMe,
|
||||
): $ReadOnlyArray<NativeModuleEnumMember> {
|
||||
return typeAnnotation.type === 'StringTypeAnnotation'
|
||||
? [
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@ import type {
|
||||
NativeModuleTypeAnnotation,
|
||||
NativeModuleUnionTypeAnnotation,
|
||||
Nullable,
|
||||
NumberLiteralTypeAnnotation,
|
||||
ObjectTypeAnnotation,
|
||||
ReservedTypeAnnotation,
|
||||
StringLiteralTypeAnnotation,
|
||||
@@ -170,6 +171,16 @@ function emitMixed(
|
||||
});
|
||||
}
|
||||
|
||||
function emitNumberLiteral(
|
||||
nullable: boolean,
|
||||
value: number,
|
||||
): Nullable<NumberLiteralTypeAnnotation> {
|
||||
return wrapNullable(nullable, {
|
||||
type: 'NumberLiteralTypeAnnotation',
|
||||
value,
|
||||
});
|
||||
}
|
||||
|
||||
function emitString(nullable: boolean): Nullable<StringTypeAnnotation> {
|
||||
return wrapNullable(nullable, {
|
||||
type: 'StringTypeAnnotation',
|
||||
@@ -762,6 +773,7 @@ module.exports = {
|
||||
emitInt32Prop,
|
||||
emitMixedProp,
|
||||
emitNumber,
|
||||
emitNumberLiteral,
|
||||
emitGenericObject,
|
||||
emitDictionary,
|
||||
emitObject,
|
||||
|
||||
+1
@@ -113,6 +113,7 @@ import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
||||
export interface Spec extends TurboModule {
|
||||
readonly passBool?: (arg: boolean) => void;
|
||||
readonly passNumber: (arg: number) => void;
|
||||
readonly passNumberLiteral: (arg: 4) => void;
|
||||
readonly passString: (arg: string) => void;
|
||||
readonly passStringish: (arg: Stringish) => void;
|
||||
readonly passStringLiteral: (arg: 'A String Literal') => void;
|
||||
|
||||
+20
@@ -1123,6 +1123,26 @@ exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_BA
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
'name': 'passNumberLiteral',
|
||||
'optional': false,
|
||||
'typeAnnotation': {
|
||||
'type': 'FunctionTypeAnnotation',
|
||||
'returnTypeAnnotation': {
|
||||
'type': 'VoidTypeAnnotation'
|
||||
},
|
||||
'params': [
|
||||
{
|
||||
'name': 'arg',
|
||||
'optional': false,
|
||||
'typeAnnotation': {
|
||||
'type': 'NumberLiteralTypeAnnotation',
|
||||
'value': 4
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
'name': 'passString',
|
||||
'optional': false,
|
||||
|
||||
@@ -37,6 +37,7 @@ const {
|
||||
emitCommonTypes,
|
||||
emitDictionary,
|
||||
emitFunction,
|
||||
emitNumberLiteral,
|
||||
emitPromise,
|
||||
emitRootTag,
|
||||
emitStringLiteral,
|
||||
@@ -403,6 +404,9 @@ function translateTypeAnnotation(
|
||||
case 'StringLiteral': {
|
||||
return emitStringLiteral(nullable, literal.value);
|
||||
}
|
||||
case 'NumericLiteral': {
|
||||
return emitNumberLiteral(nullable, literal.value);
|
||||
}
|
||||
default: {
|
||||
throw new UnsupportedTypeAnnotationParserError(
|
||||
hasteModuleName,
|
||||
|
||||
@@ -15,7 +15,7 @@ import type {
|
||||
NamedShape,
|
||||
NativeModuleAliasMap,
|
||||
NativeModuleEnumMap,
|
||||
NativeModuleEnumMembers,
|
||||
NativeModuleEnumMember,
|
||||
NativeModuleEnumMemberType,
|
||||
NativeModuleParamTypeAnnotation,
|
||||
Nullable,
|
||||
@@ -223,7 +223,9 @@ class TypeScriptParser implements Parser {
|
||||
});
|
||||
}
|
||||
|
||||
parseEnumMembers(typeAnnotation: $FlowFixMe): NativeModuleEnumMembers {
|
||||
parseEnumMembers(
|
||||
typeAnnotation: $FlowFixMe,
|
||||
): $ReadOnlyArray<NativeModuleEnumMember> {
|
||||
return typeAnnotation.members.map(member => ({
|
||||
name: member.id.name,
|
||||
value: member.initializer?.value ?? member.id.name,
|
||||
|
||||
@@ -16,5 +16,5 @@ import * as React from 'react';
|
||||
|
||||
export default (createAnimatedComponent(FlatList): AnimatedComponentType<
|
||||
React.ElementConfig<typeof FlatList>,
|
||||
React.ElementRef<typeof FlatList>,
|
||||
FlatList<mixed>,
|
||||
>);
|
||||
|
||||
+8
-1
@@ -55,6 +55,7 @@ const EventNames: Map<
|
||||
['highTextContrastChanged', 'highTextContrastDidChange'],
|
||||
['screenReaderChanged', 'touchExplorationDidChange'],
|
||||
['accessibilityServiceChanged', 'accessibilityServiceDidChange'],
|
||||
['invertColorsChanged', 'invertColorDidChange'],
|
||||
])
|
||||
: new Map([
|
||||
['announcementFinished', 'announcementFinished'],
|
||||
@@ -138,7 +139,13 @@ const AccessibilityInfo = {
|
||||
*/
|
||||
isInvertColorsEnabled(): Promise<boolean> {
|
||||
if (Platform.OS === 'android') {
|
||||
return Promise.resolve(false);
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityInfoAndroid?.isInvertColorsEnabled != null) {
|
||||
NativeAccessibilityInfoAndroid.isInvertColorsEnabled(resolve);
|
||||
} else {
|
||||
reject(null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityManagerIOS != null) {
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ export interface ImageURISource {
|
||||
* to a URL load request, no attempt is made to load the data from the originating source,
|
||||
* and the load is considered to have failed.
|
||||
*
|
||||
* @platform ios
|
||||
* @platform ios (for `force-cache`)
|
||||
*/
|
||||
cache?: 'default' | 'reload' | 'force-cache' | 'only-if-cached' | undefined;
|
||||
/**
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ export interface ImageURISource {
|
||||
* to a URL load request, no attempt is made to load the data from the originating source,
|
||||
* and the load is considered to have failed.
|
||||
*
|
||||
* @platform ios
|
||||
* @platform ios (for `force-cache`)
|
||||
*/
|
||||
+cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached');
|
||||
|
||||
|
||||
@@ -477,7 +477,10 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image, CGSize size, CGFloat scal
|
||||
|
||||
// Add missing png extension
|
||||
if (request.URL.fileURL && request.URL.pathExtension.length == 0) {
|
||||
mutableRequest.URL = [request.URL URLByAppendingPathExtension:@"png"];
|
||||
NSURL *pngRequestURL = [request.URL URLByAppendingPathExtension:@"png"];
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:pngRequestURL.path]) {
|
||||
mutableRequest.URL = pngRequestURL;
|
||||
}
|
||||
}
|
||||
if (_redirectDelegate != nil) {
|
||||
mutableRequest.URL = [_redirectDelegate redirectAssetsURL:mutableRequest.URL];
|
||||
|
||||
+2
-2
@@ -480,10 +480,10 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
this._checkProps(this.props);
|
||||
}
|
||||
|
||||
_listRef: ?React.ElementRef<typeof VirtualizedList>;
|
||||
_listRef: ?VirtualizedList;
|
||||
_virtualizedListPairs: Array<ViewabilityConfigCallbackPair> = [];
|
||||
|
||||
_captureRef = (ref: ?React.ElementRef<typeof VirtualizedList>) => {
|
||||
_captureRef = (ref: ?VirtualizedList) => {
|
||||
this._listRef = ref;
|
||||
};
|
||||
|
||||
|
||||
+26
-17
@@ -37,6 +37,8 @@ const COLORS = {
|
||||
'ansi-bright-white': 'rgb(247, 247, 247)',
|
||||
};
|
||||
|
||||
const LRM = '\u200E'; // Left-to-Right Mark
|
||||
|
||||
export default function Ansi({
|
||||
text,
|
||||
style,
|
||||
@@ -80,25 +82,28 @@ export default function Ansi({
|
||||
};
|
||||
|
||||
return (
|
||||
<View>
|
||||
<View style={styles.container}>
|
||||
{parsedLines.map((items, i) => (
|
||||
<View style={styles.line} key={i}>
|
||||
{items.map((bundle, key) => {
|
||||
const textStyle =
|
||||
bundle.fg && COLORS[bundle.fg]
|
||||
? {
|
||||
backgroundColor: bundle.bg && COLORS[bundle.bg],
|
||||
color: bundle.fg && COLORS[bundle.fg],
|
||||
}
|
||||
: {
|
||||
backgroundColor: bundle.bg && COLORS[bundle.bg],
|
||||
};
|
||||
return (
|
||||
<Text style={[style, textStyle]} key={key}>
|
||||
{getText(bundle.content, key)}
|
||||
</Text>
|
||||
);
|
||||
})}
|
||||
<Text>
|
||||
{LRM}
|
||||
{items.map((bundle, key) => {
|
||||
const textStyle =
|
||||
bundle.fg && COLORS[bundle.fg]
|
||||
? {
|
||||
backgroundColor: bundle.bg && COLORS[bundle.bg],
|
||||
color: bundle.fg && COLORS[bundle.fg],
|
||||
}
|
||||
: {
|
||||
backgroundColor: bundle.bg && COLORS[bundle.bg],
|
||||
};
|
||||
return (
|
||||
<Text style={[style, textStyle]} key={key}>
|
||||
{getText(bundle.content, key)}
|
||||
</Text>
|
||||
);
|
||||
})}
|
||||
</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
@@ -106,6 +111,10 @@ export default function Ansi({
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
minWidth: '100%',
|
||||
direction: 'ltr',
|
||||
},
|
||||
line: {
|
||||
flexDirection: 'row',
|
||||
},
|
||||
|
||||
@@ -59,7 +59,9 @@ function LogBoxInspectorCodeFrame(props: Props): React.Node {
|
||||
<LogBoxInspectorSection heading="Source" action={<AppInfo />}>
|
||||
<View style={styles.box}>
|
||||
<View style={styles.frame}>
|
||||
<ScrollView horizontal>
|
||||
<ScrollView
|
||||
horizontal
|
||||
contentContainerStyle={styles.contentContainer}>
|
||||
<AnsiHighlight style={styles.content} text={codeFrame.content} />
|
||||
</ScrollView>
|
||||
</View>
|
||||
@@ -138,6 +140,9 @@ const styles = StyleSheet.create({
|
||||
paddingTop: 10,
|
||||
paddingBottom: 10,
|
||||
},
|
||||
contentContainer: {
|
||||
minWidth: '100%',
|
||||
},
|
||||
content: {
|
||||
color: LogBoxStyle.getTextColor(1),
|
||||
fontSize: 12,
|
||||
|
||||
+10
@@ -26,6 +26,11 @@ exports[`LogBoxInspectorCodeFrame should render a code frame 1`] = `
|
||||
}
|
||||
>
|
||||
<ScrollView
|
||||
contentContainerStyle={
|
||||
Object {
|
||||
"minWidth": "100%",
|
||||
}
|
||||
}
|
||||
horizontal={true}
|
||||
>
|
||||
<Ansi
|
||||
@@ -108,6 +113,11 @@ exports[`LogBoxInspectorCodeFrame should render a code frame without a location
|
||||
}
|
||||
>
|
||||
<ScrollView
|
||||
contentContainerStyle={
|
||||
Object {
|
||||
"minWidth": "100%",
|
||||
}
|
||||
}
|
||||
horizontal={true}
|
||||
>
|
||||
<Ansi
|
||||
|
||||
+4
-4
@@ -80,7 +80,7 @@ describe('LogBox', () => {
|
||||
expect(mockWarn).not.toBeCalled();
|
||||
expect(console.error).toBeCalledTimes(1);
|
||||
expect(console.error.mock.calls[0]).toEqual([
|
||||
'Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.%s',
|
||||
'Warning: Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.%s',
|
||||
'\n\nCheck the render method of `DoesNotUseKey`.',
|
||||
'',
|
||||
expect.stringMatching('at DoesNotUseKey'),
|
||||
@@ -94,7 +94,7 @@ describe('LogBox', () => {
|
||||
componentStackType: 'stack',
|
||||
message: {
|
||||
content:
|
||||
'Warning: Each child in a list should have a unique "key" prop.\n\nCheck the render method of `DoesNotUseKey`. See https://react.dev/link/warning-keys for more information.',
|
||||
'Warning: Each child in a list should have a unique "key" prop.\n\nCheck the render method of `DoesNotUseKey`. See https://reactjs.org/link/warning-keys for more information.',
|
||||
substitutions: [
|
||||
{length: 45, offset: 62},
|
||||
{length: 0, offset: 107},
|
||||
@@ -106,7 +106,7 @@ describe('LogBox', () => {
|
||||
// We also interpolate the string before passing to the underlying console method.
|
||||
expect(mockError.mock.calls[0]).toEqual([
|
||||
expect.stringMatching(
|
||||
'Warning: Each child in a list should have a unique "key" prop.\n\nCheck the render method of `DoesNotUseKey`. See https://react.dev/link/warning-keys for more information.\n at ',
|
||||
'Warning: Each child in a list should have a unique "key" prop.\n\nCheck the render method of `DoesNotUseKey`. See https://reactjs.org/link/warning-keys for more information.\n at ',
|
||||
),
|
||||
]);
|
||||
});
|
||||
@@ -134,7 +134,7 @@ describe('LogBox', () => {
|
||||
expect(mockWarn).not.toBeCalled();
|
||||
expect(console.error).toBeCalledTimes(1);
|
||||
expect(console.error.mock.calls[0]).toEqual([
|
||||
'Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.%s',
|
||||
'Warning: Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.%s',
|
||||
'invalid',
|
||||
expect.stringMatching('at FragmentWithProp'),
|
||||
]);
|
||||
|
||||
+27141
-16426
File diff suppressed because it is too large
Load Diff
+1630
-2675
File diff suppressed because it is too large
Load Diff
+1682
-2945
File diff suppressed because it is too large
Load Diff
+27607
-16730
File diff suppressed because it is too large
Load Diff
+1652
-2709
File diff suppressed because it is too large
Load Diff
+1733
-2980
File diff suppressed because it is too large
Load Diff
@@ -683,7 +683,7 @@ exports[`public API should not change unintentionally Libraries/Animated/bezier.
|
||||
exports[`public API should not change unintentionally Libraries/Animated/components/AnimatedFlatList.js 1`] = `
|
||||
"declare export default AnimatedComponentType<
|
||||
React.ElementConfig<typeof FlatList>,
|
||||
React.ElementRef<typeof FlatList>,
|
||||
FlatList<mixed>,
|
||||
>;
|
||||
"
|
||||
`;
|
||||
@@ -5725,7 +5725,7 @@ declare class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
setNativeProps(props: { [string]: mixed, ... }): void;
|
||||
constructor(props: Props<ItemT>): void;
|
||||
componentDidUpdate(prevProps: Props<ItemT>): void;
|
||||
_listRef: ?React.ElementRef<typeof VirtualizedList>;
|
||||
_listRef: ?VirtualizedList;
|
||||
_virtualizedListPairs: Array<ViewabilityConfigCallbackPair>;
|
||||
_captureRef: $FlowFixMe;
|
||||
_checkProps(props: Props<ItemT>): void;
|
||||
|
||||
@@ -239,7 +239,10 @@ NSString *RCTMD5Hash(NSString *string)
|
||||
{
|
||||
const char *str = string.UTF8String;
|
||||
unsigned char result[CC_MD5_DIGEST_LENGTH];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
CC_MD5(str, (CC_LONG)strlen(str), result);
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
return [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
||||
result[0],
|
||||
|
||||
@@ -114,9 +114,6 @@ class LayoutAnimationDelegateProxy : public LayoutAnimationStatusDelegate, publi
|
||||
- (instancetype)initWithToolbox:(SchedulerToolbox)toolbox
|
||||
{
|
||||
if (self = [super init]) {
|
||||
auto reactNativeConfig =
|
||||
toolbox.contextContainer->at<std::shared_ptr<const ReactNativeConfig>>("ReactNativeConfig");
|
||||
|
||||
_delegateProxy = std::make_unique<SchedulerDelegateProxy>((__bridge void *)self);
|
||||
|
||||
if (ReactNativeFeatureFlags::enableLayoutAnimationsOnIOS()) {
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#import <React/RCTSurfaceView.h>
|
||||
#import <React/RCTUtils.h>
|
||||
|
||||
#import <react/config/ReactNativeConfig.h>
|
||||
#import <react/featureflags/ReactNativeFeatureFlags.h>
|
||||
#import <react/renderer/componentregistry/ComponentDescriptorFactory.h>
|
||||
#import <react/renderer/components/text/BaseTextProps.h>
|
||||
@@ -226,8 +225,6 @@ using namespace facebook::react;
|
||||
|
||||
- (RCTScheduler *)_createScheduler
|
||||
{
|
||||
auto reactNativeConfig = _contextContainer->at<std::shared_ptr<const ReactNativeConfig>>("ReactNativeConfig");
|
||||
|
||||
auto componentRegistryFactory =
|
||||
[factory = wrapManagedObject(_mountingManager.componentViewRegistry.componentViewFactory)](
|
||||
const EventDispatcher::Weak &eventDispatcher, const ContextContainer::Shared &contextContainer) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @lint-ignore-every LICENSELINT
|
||||
/*
|
||||
* Copyright (c) 2015 Daniel Kirchner
|
||||
*
|
||||
@@ -27,10 +28,6 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// magic constants :-)
|
||||
static const uint64_t PRIME1 = 11400714785074694791ULL;
|
||||
static const uint64_t PRIME2 = 14029467366897019727ULL;
|
||||
@@ -106,13 +103,18 @@ NS_INLINE uint64_t h32bytes(const char *p, uint64_t len, const uint64_t seed)
|
||||
return h32bytes_compute(p, len, seed + PRIME1 + PRIME2, seed + PRIME2, seed, seed - PRIME1);
|
||||
}
|
||||
|
||||
/*
|
||||
Primary APIs
|
||||
*/
|
||||
|
||||
NS_INLINE uint64_t meta_xxhash64(const char *p, uint64_t len, uint64_t seed)
|
||||
{
|
||||
return finalize((len >= 32 ? h32bytes(p, len, seed) : seed + PRIME5) + len, p + (len & ~0x1FULL), len & 0x1FULL);
|
||||
}
|
||||
|
||||
NS_INLINE uint64_t FBxxHash64(const char *p, uint64_t len, uint64_t seed)
|
||||
{
|
||||
return finalize((len >= 32 ? h32bytes(p, len, seed) : seed + PRIME5) + len, p + (len & ~0x1F), len & 0x1F);
|
||||
return meta_xxhash64(p, len, seed);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -121,8 +121,8 @@ using namespace facebook::react;
|
||||
auto &props = *sharedProps;
|
||||
props.layoutConstraints = LayoutConstraints{{0, 0}, {500, 500}};
|
||||
auto &yogaStyle = props.yogaStyle;
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(200));
|
||||
return sharedProps;
|
||||
})
|
||||
.children({
|
||||
@@ -136,8 +136,8 @@ using namespace facebook::react;
|
||||
yogaStyle.setPositionType(yoga::PositionType::Absolute);
|
||||
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0));
|
||||
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(0));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(200));
|
||||
return sharedProps;
|
||||
})
|
||||
.children({
|
||||
@@ -216,8 +216,8 @@ using namespace facebook::react;
|
||||
yogaStyle.setPositionType(yoga::PositionType::Absolute);
|
||||
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0));
|
||||
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(30));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(50));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(50));
|
||||
return sharedProps;
|
||||
})
|
||||
.children({
|
||||
@@ -260,8 +260,8 @@ using namespace facebook::react;
|
||||
yogaStyle.setPositionType(yoga::PositionType::Absolute);
|
||||
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0));
|
||||
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(90));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(50));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(50));
|
||||
return sharedProps;
|
||||
})
|
||||
.children({
|
||||
@@ -418,8 +418,8 @@ static ParagraphShadowNode::ConcreteState::Shared stateWithShadowNode(
|
||||
auto &props = *sharedProps;
|
||||
props.layoutConstraints = LayoutConstraints{{0, 0}, {500, 500}};
|
||||
auto &yogaStyle = props.yogaStyle;
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(200));
|
||||
return sharedProps;
|
||||
})
|
||||
.children({
|
||||
@@ -434,8 +434,8 @@ static ParagraphShadowNode::ConcreteState::Shared stateWithShadowNode(
|
||||
yogaStyle.setPositionType(yoga::PositionType::Absolute);
|
||||
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0));
|
||||
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(90));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(20));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(20));
|
||||
return sharedProps;
|
||||
})
|
||||
.children({
|
||||
|
||||
@@ -19,7 +19,7 @@ BOOL RCTBorderInsetsAreEqual(UIEdgeInsets borderInsets)
|
||||
|
||||
BOOL RCTCornerRadiiAreEqualAndSymmetrical(RCTCornerRadii cornerRadii)
|
||||
{
|
||||
return cornerRadii.topLeftHorizontal == cornerRadii.topLeftHorizontal &&
|
||||
return cornerRadii.topLeftHorizontal == cornerRadii.topLeftVertical &&
|
||||
cornerRadii.topRightHorizontal == cornerRadii.topRightVertical &&
|
||||
cornerRadii.bottomLeftHorizontal == cornerRadii.bottomLeftVertical &&
|
||||
cornerRadii.bottomRightHorizontal == cornerRadii.bottomRightVertical &&
|
||||
|
||||
@@ -87,6 +87,9 @@ CGFloat RCTCoreGraphicsFloatFromYogaValue(YGValue value, CGFloat baseFloatValue)
|
||||
return RCTCoreGraphicsFloatFromYogaFloat(value.value) * baseFloatValue;
|
||||
case YGUnitAuto:
|
||||
case YGUnitUndefined:
|
||||
case YGUnitMaxContent:
|
||||
case YGUnitFitContent:
|
||||
case YGUnitStretch:
|
||||
return baseFloatValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,9 @@ typedef NS_ENUM(unsigned int, meta_prop_t) {
|
||||
#define RCT_SET_YGVALUE(ygvalue, setter, ...) \
|
||||
switch (ygvalue.unit) { \
|
||||
case YGUnitAuto: \
|
||||
case YGUnitMaxContent: \
|
||||
case YGUnitFitContent: \
|
||||
case YGUnitStretch: \
|
||||
case YGUnitUndefined: \
|
||||
setter(__VA_ARGS__, YGUndefined); \
|
||||
break; \
|
||||
@@ -88,6 +91,35 @@ typedef NS_ENUM(unsigned int, meta_prop_t) {
|
||||
case YGUnitPercent: \
|
||||
setter##Percent(__VA_ARGS__, ygvalue.value); \
|
||||
break; \
|
||||
case YGUnitMaxContent: \
|
||||
case YGUnitFitContent: \
|
||||
case YGUnitStretch: \
|
||||
break; \
|
||||
}
|
||||
|
||||
#define RCT_SET_YGVALUE_AUTO_INTRINSIC(ygvalue, setter, ...) \
|
||||
switch (ygvalue.unit) { \
|
||||
case YGUnitAuto: \
|
||||
setter##Auto(__VA_ARGS__); \
|
||||
break; \
|
||||
case YGUnitMaxContent: \
|
||||
setter##MaxContent(__VA_ARGS__); \
|
||||
break; \
|
||||
case YGUnitFitContent: \
|
||||
setter##FitContent(__VA_ARGS__); \
|
||||
break; \
|
||||
case YGUnitStretch: \
|
||||
setter##Stretch(__VA_ARGS__); \
|
||||
break; \
|
||||
case YGUnitUndefined: \
|
||||
setter(__VA_ARGS__, YGUndefined); \
|
||||
break; \
|
||||
case YGUnitPoint: \
|
||||
setter(__VA_ARGS__, ygvalue.value); \
|
||||
break; \
|
||||
case YGUnitPercent: \
|
||||
setter##Percent(__VA_ARGS__, ygvalue.value); \
|
||||
break; \
|
||||
}
|
||||
|
||||
static void RCTProcessMetaPropsPadding(const YGValue metaProps[META_PROP_COUNT], YGNodeRef node)
|
||||
@@ -483,14 +515,14 @@ RCT_BORDER_PROPERTY(Start, START)
|
||||
RCT_BORDER_PROPERTY(End, END)
|
||||
|
||||
// Dimensions
|
||||
#define RCT_DIMENSION_PROPERTY(setProp, getProp, cssProp) \
|
||||
-(void)set##setProp : (YGValue)value \
|
||||
{ \
|
||||
RCT_SET_YGVALUE_AUTO(value, YGNodeStyleSet##cssProp, _yogaNode); \
|
||||
} \
|
||||
-(YGValue)getProp \
|
||||
{ \
|
||||
return YGNodeStyleGet##cssProp(_yogaNode); \
|
||||
#define RCT_DIMENSION_PROPERTY(setProp, getProp, cssProp) \
|
||||
-(void)set##setProp : (YGValue)value \
|
||||
{ \
|
||||
RCT_SET_YGVALUE_AUTO_INTRINSIC(value, YGNodeStyleSet##cssProp, _yogaNode); \
|
||||
} \
|
||||
-(YGValue)getProp \
|
||||
{ \
|
||||
return YGNodeStyleGet##cssProp(_yogaNode); \
|
||||
}
|
||||
|
||||
#define RCT_MIN_MAX_DIMENSION_PROPERTY(setProp, getProp, cssProp) \
|
||||
@@ -634,7 +666,7 @@ RCTShadowViewMeasure(YGNodeConstRef node, float width, YGMeasureMode widthMode,
|
||||
|
||||
- (void)setFlexBasis:(YGValue)value
|
||||
{
|
||||
RCT_SET_YGVALUE_AUTO(value, YGNodeStyleSetFlexBasis, _yogaNode);
|
||||
RCT_SET_YGVALUE_AUTO_INTRINSIC(value, YGNodeStyleSetFlexBasis, _yogaNode);
|
||||
}
|
||||
|
||||
- (YGValue)flexBasis
|
||||
|
||||
@@ -1644,13 +1644,6 @@ public final class com/facebook/react/bridge/WritableNativeMap : com/facebook/re
|
||||
public fun putString (Ljava/lang/String;Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public class com/facebook/react/bridge/interop/InteropModuleRegistry {
|
||||
public fun <init> ()V
|
||||
public fun getInteropModule (Ljava/lang/Class;)Lcom/facebook/react/bridge/JavaScriptModule;
|
||||
public fun registerInteropModule (Ljava/lang/Class;Ljava/lang/Object;)V
|
||||
public fun shouldReturnInteropModule (Ljava/lang/Class;)Z
|
||||
}
|
||||
|
||||
public abstract interface class com/facebook/react/bridge/queue/MessageQueueThread {
|
||||
public abstract fun assertIsOnThread ()V
|
||||
public abstract fun assertIsOnThread (Ljava/lang/String;)V
|
||||
@@ -2168,7 +2161,7 @@ public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/
|
||||
public fun fetchSplitBundleAndCreateBundleLoader (Ljava/lang/String;Lcom/facebook/react/devsupport/DevSupportManagerBase$CallbackWithBundleLoader;)V
|
||||
protected fun getApplicationContext ()Landroid/content/Context;
|
||||
public fun getCurrentActivity ()Landroid/app/Activity;
|
||||
protected fun getCurrentContext ()Lcom/facebook/react/bridge/ReactContext;
|
||||
public fun getCurrentReactContext ()Lcom/facebook/react/bridge/ReactContext;
|
||||
public fun getDevLoadingViewManager ()Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;
|
||||
public fun getDevServerHelper ()Lcom/facebook/react/devsupport/DevServerHelper;
|
||||
public fun getDevSettings ()Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;
|
||||
@@ -2341,6 +2334,7 @@ public class com/facebook/react/devsupport/ReleaseDevSupportManager : com/facebo
|
||||
public fun destroyRootView (Landroid/view/View;)V
|
||||
public fun downloadBundleResourceFromUrlSync (Ljava/lang/String;Ljava/io/File;)Ljava/io/File;
|
||||
public fun getCurrentActivity ()Landroid/app/Activity;
|
||||
public fun getCurrentReactContext ()Lcom/facebook/react/bridge/ReactContext;
|
||||
public fun getDevSettings ()Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;
|
||||
public fun getDevSupportEnabled ()Z
|
||||
public fun getDownloadedJSBundleFile ()Ljava/lang/String;
|
||||
@@ -2477,6 +2471,7 @@ public abstract interface class com/facebook/react/devsupport/interfaces/DevSupp
|
||||
public abstract fun destroyRootView (Landroid/view/View;)V
|
||||
public abstract fun downloadBundleResourceFromUrlSync (Ljava/lang/String;Ljava/io/File;)Ljava/io/File;
|
||||
public abstract fun getCurrentActivity ()Landroid/app/Activity;
|
||||
public abstract fun getCurrentReactContext ()Lcom/facebook/react/bridge/ReactContext;
|
||||
public abstract fun getDevSettings ()Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;
|
||||
public abstract fun getDevSupportEnabled ()Z
|
||||
public abstract fun getDownloadedJSBundleFile ()Ljava/lang/String;
|
||||
@@ -3319,17 +3314,6 @@ public final class com/facebook/react/modules/devloading/DevLoadingModule : com/
|
||||
public final class com/facebook/react/modules/devloading/DevLoadingModule$Companion {
|
||||
}
|
||||
|
||||
public final class com/facebook/react/modules/devtoolsruntimesettings/ReactDevToolsRuntimeSettingsModule : com/facebook/fbreact/specs/NativeReactDevToolsRuntimeSettingsModuleSpec {
|
||||
public static final field Companion Lcom/facebook/react/modules/devtoolsruntimesettings/ReactDevToolsRuntimeSettingsModule$Companion;
|
||||
public static final field NAME Ljava/lang/String;
|
||||
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
|
||||
public fun getReloadAndProfileConfig ()Lcom/facebook/react/bridge/WritableMap;
|
||||
public fun setReloadAndProfileConfig (Lcom/facebook/react/bridge/ReadableMap;)V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/modules/devtoolsruntimesettings/ReactDevToolsRuntimeSettingsModule$Companion {
|
||||
}
|
||||
|
||||
public class com/facebook/react/modules/dialog/AlertFragment : androidx/fragment/app/DialogFragment, android/content/DialogInterface$OnClickListener {
|
||||
public fun <init> ()V
|
||||
public fun <init> (Lcom/facebook/react/modules/dialog/DialogModule$AlertFragmentListener;Landroid/os/Bundle;)V
|
||||
@@ -3377,14 +3361,26 @@ public final class com/facebook/react/modules/fresco/FrescoModule$Companion {
|
||||
public final fun hasBeenInitialized ()Z
|
||||
}
|
||||
|
||||
public final class com/facebook/react/modules/fresco/ImageCacheControl : java/lang/Enum {
|
||||
public static final field DEFAULT Lcom/facebook/react/modules/fresco/ImageCacheControl;
|
||||
public static final field ONLY_IF_CACHED Lcom/facebook/react/modules/fresco/ImageCacheControl;
|
||||
public static final field RELOAD Lcom/facebook/react/modules/fresco/ImageCacheControl;
|
||||
public static fun getEntries ()Lkotlin/enums/EnumEntries;
|
||||
public static fun valueOf (Ljava/lang/String;)Lcom/facebook/react/modules/fresco/ImageCacheControl;
|
||||
public static fun values ()[Lcom/facebook/react/modules/fresco/ImageCacheControl;
|
||||
}
|
||||
|
||||
public final class com/facebook/react/modules/fresco/ReactNetworkImageRequest : com/facebook/imagepipeline/request/ImageRequest {
|
||||
public static final field Companion Lcom/facebook/react/modules/fresco/ReactNetworkImageRequest$Companion;
|
||||
public synthetic fun <init> (Lcom/facebook/imagepipeline/request/ImageRequestBuilder;Lcom/facebook/react/bridge/ReadableMap;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public synthetic fun <init> (Lcom/facebook/imagepipeline/request/ImageRequestBuilder;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/modules/fresco/ImageCacheControl;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public static final fun fromBuilderWithHeaders (Lcom/facebook/imagepipeline/request/ImageRequestBuilder;Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/modules/fresco/ReactNetworkImageRequest;
|
||||
public static final fun fromBuilderWithHeaders (Lcom/facebook/imagepipeline/request/ImageRequestBuilder;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/modules/fresco/ImageCacheControl;)Lcom/facebook/react/modules/fresco/ReactNetworkImageRequest;
|
||||
}
|
||||
|
||||
public final class com/facebook/react/modules/fresco/ReactNetworkImageRequest$Companion {
|
||||
public final fun fromBuilderWithHeaders (Lcom/facebook/imagepipeline/request/ImageRequestBuilder;Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/modules/fresco/ReactNetworkImageRequest;
|
||||
public final fun fromBuilderWithHeaders (Lcom/facebook/imagepipeline/request/ImageRequestBuilder;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/modules/fresco/ImageCacheControl;)Lcom/facebook/react/modules/fresco/ReactNetworkImageRequest;
|
||||
public static synthetic fun fromBuilderWithHeaders$default (Lcom/facebook/react/modules/fresco/ReactNetworkImageRequest$Companion;Lcom/facebook/imagepipeline/request/ImageRequestBuilder;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/modules/fresco/ImageCacheControl;ILjava/lang/Object;)Lcom/facebook/react/modules/fresco/ReactNetworkImageRequest;
|
||||
}
|
||||
|
||||
public final class com/facebook/react/modules/fresco/SystraceRequestListener : com/facebook/imagepipeline/listener/BaseRequestListener {
|
||||
@@ -3604,17 +3600,6 @@ public final class com/facebook/react/modules/permissions/PermissionsModule : co
|
||||
public final class com/facebook/react/modules/permissions/PermissionsModule$Companion {
|
||||
}
|
||||
|
||||
public final class com/facebook/react/modules/reactdevtoolssettings/ReactDevToolsSettingsManagerModule : com/facebook/fbreact/specs/NativeReactDevToolsSettingsManagerSpec {
|
||||
public static final field Companion Lcom/facebook/react/modules/reactdevtoolssettings/ReactDevToolsSettingsManagerModule$Companion;
|
||||
public static final field NAME Ljava/lang/String;
|
||||
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
|
||||
public fun getGlobalHookSettings ()Ljava/lang/String;
|
||||
public fun setGlobalHookSettings (Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/modules/reactdevtoolssettings/ReactDevToolsSettingsManagerModule$Companion {
|
||||
}
|
||||
|
||||
public final class com/facebook/react/modules/share/ShareModule : com/facebook/fbreact/specs/NativeShareModuleSpec {
|
||||
public static final field Companion Lcom/facebook/react/modules/share/ShareModule$Companion;
|
||||
public static final field ERROR_INVALID_CONTENT Ljava/lang/String;
|
||||
@@ -6707,8 +6692,10 @@ public class com/facebook/react/views/imagehelper/ImageSource {
|
||||
public fun <init> (Landroid/content/Context;Ljava/lang/String;)V
|
||||
public fun <init> (Landroid/content/Context;Ljava/lang/String;D)V
|
||||
public fun <init> (Landroid/content/Context;Ljava/lang/String;DD)V
|
||||
public synthetic fun <init> (Landroid/content/Context;Ljava/lang/String;DDILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (Landroid/content/Context;Ljava/lang/String;DDLcom/facebook/react/modules/fresco/ImageCacheControl;)V
|
||||
public synthetic fun <init> (Landroid/content/Context;Ljava/lang/String;DDLcom/facebook/react/modules/fresco/ImageCacheControl;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getCacheControl ()Lcom/facebook/react/modules/fresco/ImageCacheControl;
|
||||
public final fun getSize ()D
|
||||
public final fun getSource ()Ljava/lang/String;
|
||||
public static final fun getTransparentBitmapImageSource (Landroid/content/Context;)Lcom/facebook/react/views/imagehelper/ImageSource;
|
||||
@@ -8169,30 +8156,6 @@ public abstract interface class com/facebook/react/views/textinput/ScrollWatcher
|
||||
public abstract fun onScrollChanged (IIII)V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/views/unimplementedview/ReactUnimplementedView : android/widget/LinearLayout {
|
||||
public fun <init> (Landroid/content/Context;)V
|
||||
public final fun setName (Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/views/unimplementedview/ReactUnimplementedViewManager : com/facebook/react/uimanager/ViewGroupManager {
|
||||
public static final field Companion Lcom/facebook/react/views/unimplementedview/ReactUnimplementedViewManager$Companion;
|
||||
public static final field REACT_CLASS Ljava/lang/String;
|
||||
public fun <init> ()V
|
||||
public synthetic fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Landroid/view/View;
|
||||
public fun getName ()Ljava/lang/String;
|
||||
public final fun setName (Lcom/facebook/react/views/unimplementedview/ReactUnimplementedView;Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public class com/facebook/react/views/unimplementedview/ReactUnimplementedViewManager$$PropsSetter : com/facebook/react/uimanager/ViewManagerPropertyUpdater$ViewManagerSetter {
|
||||
public fun <init> ()V
|
||||
public fun getProperties (Ljava/util/Map;)V
|
||||
public synthetic fun setProperty (Lcom/facebook/react/uimanager/ViewManager;Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V
|
||||
public fun setProperty (Lcom/facebook/react/views/unimplementedview/ReactUnimplementedViewManager;Lcom/facebook/react/views/unimplementedview/ReactUnimplementedView;Ljava/lang/String;Ljava/lang/Object;)V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/views/unimplementedview/ReactUnimplementedViewManager$Companion {
|
||||
}
|
||||
|
||||
public final class com/facebook/react/views/view/ColorUtil {
|
||||
public static final field INSTANCE Lcom/facebook/react/views/view/ColorUtil;
|
||||
public static final fun normalize (DDDD)I
|
||||
|
||||
@@ -533,9 +533,7 @@ android {
|
||||
"-DREACT_BUILD_DIR=$buildDir",
|
||||
"-DANDROID_STL=c++_shared",
|
||||
"-DANDROID_TOOLCHAIN=clang",
|
||||
// Due to https://github.com/android/ndk/issues/1693 we're losing Android
|
||||
// specific compilation flags. This can be removed once we moved to NDK 25/26
|
||||
"-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON")
|
||||
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON")
|
||||
|
||||
targets(
|
||||
"reactnative",
|
||||
|
||||
@@ -41,7 +41,7 @@ if (PROJECT_ROOT_DIR)
|
||||
endif ()
|
||||
|
||||
file(GLOB input_SRC CONFIGURE_DEPENDS
|
||||
*.cpp
|
||||
${REACT_ANDROID_DIR}/cmake-utils/default-app-setup/*.cpp
|
||||
${BUILD_DIR}/generated/autolinking/src/main/jni/*.cpp)
|
||||
|
||||
add_library(${CMAKE_PROJECT_NAME} SHARED ${input_SRC})
|
||||
|
||||
@@ -8,7 +8,9 @@ android.useAndroidX=true
|
||||
react.internal.disableJavaVersionAlignment=true
|
||||
|
||||
# Binary Compatibility Validator properties
|
||||
binaryCompatibilityValidator.ignoredClasses=com.facebook.react.BuildConfig
|
||||
binaryCompatibilityValidator.ignoredClasses=com.facebook.react.BuildConfig,\
|
||||
com.facebook.react.views.unimplementedview.ReactUnimplementedViewManager$$PropsSetter
|
||||
|
||||
binaryCompatibilityValidator.ignoredPackages=com.facebook.debug,\
|
||||
com.facebook.fbreact,\
|
||||
com.facebook.hermes,\
|
||||
|
||||
@@ -228,6 +228,7 @@ android {
|
||||
"-DHERMES_IS_ANDROID=True",
|
||||
"-DANDROID_STL=c++_shared",
|
||||
"-DANDROID_PIE=True",
|
||||
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON",
|
||||
"-DIMPORT_HERMESC=${File(hermesBuildDir, "ImportHermesc.cmake").toString()}",
|
||||
"-DJSI_DIR=${jsiDir}",
|
||||
"-DHERMES_SLOW_DEBUG=False",
|
||||
@@ -235,10 +236,7 @@ android {
|
||||
"-DHERMES_RELEASE_VERSION=for RN ${version}",
|
||||
// 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",
|
||||
// Due to https://github.com/android/ndk/issues/1693 we're losing Android
|
||||
// specific compilation flags. This can be removed once we moved to NDK 25/26
|
||||
"-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON")
|
||||
"-DHERMES_ENABLE_INTL=True")
|
||||
|
||||
targets("libhermes")
|
||||
}
|
||||
@@ -262,11 +260,6 @@ android {
|
||||
// This has the (unlucky) side effect of letting AGP call the build
|
||||
// tasks `configureCMakeRelease` while is actually building the debug flavor.
|
||||
arguments("-DCMAKE_BUILD_TYPE=Release")
|
||||
// Adding -O3 to handle the issue here:
|
||||
// https://github.com/android/ndk/issues/1740#issuecomment-1198438260
|
||||
// The old NDK toolchain is not passing -O3 correctly for release CMake builds. This is
|
||||
// fixed in NDK 25 and can be removed once we're there.
|
||||
cppFlags("-O3")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -330,6 +323,11 @@ afterEvaluate {
|
||||
tasks.getByName("preBuild").dependsOn(prepareHeadersForPrefab)
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.compilerArgs.add("-Xlint:deprecation,unchecked")
|
||||
options.compilerArgs.add("-Werror")
|
||||
}
|
||||
|
||||
/* Publishing Configuration */
|
||||
apply(from = "../publish.gradle")
|
||||
|
||||
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.debug.debugoverlay.model;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/** Tag for a debug overlay log message. Name must be unique. */
|
||||
@Immutable
|
||||
public class DebugOverlayTag {
|
||||
|
||||
/** Name of tag. */
|
||||
public final String name;
|
||||
|
||||
/** Description to display in settings. */
|
||||
public final String description;
|
||||
|
||||
/** Color for tag display. */
|
||||
public final int color;
|
||||
|
||||
public DebugOverlayTag(String name, String description, int color) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.debug.debugoverlay.model
|
||||
|
||||
/**
|
||||
* Tag for a debug overlay log message. Name must be unique.
|
||||
*
|
||||
* @param name Name of tag.
|
||||
* @param description Description to display in settings.
|
||||
* @param color Color for tag display.
|
||||
*/
|
||||
internal class DebugOverlayTag(
|
||||
public val name: String,
|
||||
public val description: String,
|
||||
public val color: Int,
|
||||
)
|
||||
+4
-5
@@ -10,12 +10,11 @@ package com.facebook.debug.holder
|
||||
import com.facebook.debug.debugoverlay.model.DebugOverlayTag
|
||||
|
||||
/** No-op implementation of [Printer]. */
|
||||
public object NoopPrinter : Printer {
|
||||
internal object NoopPrinter : Printer {
|
||||
|
||||
public override fun logMessage(tag: DebugOverlayTag, message: String, vararg args: Any?): Unit =
|
||||
Unit
|
||||
override fun logMessage(tag: DebugOverlayTag, message: String, vararg args: Any?): Unit = Unit
|
||||
|
||||
public override fun logMessage(tag: DebugOverlayTag, message: String): Unit = Unit
|
||||
override fun logMessage(tag: DebugOverlayTag, message: String): Unit = Unit
|
||||
|
||||
public override fun shouldDisplayLogMessage(tag: DebugOverlayTag): Boolean = false
|
||||
override fun shouldDisplayLogMessage(tag: DebugOverlayTag): Boolean = false
|
||||
}
|
||||
|
||||
+4
-4
@@ -10,11 +10,11 @@ package com.facebook.debug.holder
|
||||
import com.facebook.debug.debugoverlay.model.DebugOverlayTag
|
||||
|
||||
/** Interface to debugging tool. */
|
||||
public interface Printer {
|
||||
internal interface Printer {
|
||||
|
||||
public fun logMessage(tag: DebugOverlayTag, message: String, vararg args: Any?)
|
||||
fun logMessage(tag: DebugOverlayTag, message: String, vararg args: Any?)
|
||||
|
||||
public fun logMessage(tag: DebugOverlayTag, message: String)
|
||||
fun logMessage(tag: DebugOverlayTag, message: String)
|
||||
|
||||
public fun shouldDisplayLogMessage(tag: DebugOverlayTag): Boolean
|
||||
fun shouldDisplayLogMessage(tag: DebugOverlayTag): Boolean
|
||||
}
|
||||
|
||||
+2
-2
@@ -8,6 +8,6 @@
|
||||
package com.facebook.debug.holder
|
||||
|
||||
/** Holder for debugging tool instance. */
|
||||
public object PrinterHolder {
|
||||
@JvmStatic public var printer: Printer = NoopPrinter
|
||||
internal object PrinterHolder {
|
||||
@JvmStatic var printer: Printer = NoopPrinter
|
||||
}
|
||||
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.debug.tags;
|
||||
|
||||
import android.graphics.Color;
|
||||
import com.facebook.debug.debugoverlay.model.DebugOverlayTag;
|
||||
|
||||
/** Category for debug overlays. */
|
||||
public class ReactDebugOverlayTags {
|
||||
|
||||
public static final DebugOverlayTag PERFORMANCE =
|
||||
new DebugOverlayTag("Performance", "Markers for Performance", Color.GREEN);
|
||||
public static final DebugOverlayTag NAVIGATION =
|
||||
new DebugOverlayTag("Navigation", "Tag for navigation", Color.rgb(0x9C, 0x27, 0xB0));
|
||||
public static final DebugOverlayTag RN_CORE =
|
||||
new DebugOverlayTag("RN Core", "Tag for React Native Core", Color.BLACK);
|
||||
public static final DebugOverlayTag BRIDGE_CALLS =
|
||||
new DebugOverlayTag(
|
||||
"Bridge Calls", "JS to Java calls (warning: this is spammy)", Color.MAGENTA);
|
||||
public static final DebugOverlayTag NATIVE_MODULE =
|
||||
new DebugOverlayTag("Native Module", "Native Module init", Color.rgb(0x80, 0x00, 0x80));
|
||||
public static final DebugOverlayTag UI_MANAGER =
|
||||
new DebugOverlayTag(
|
||||
"UI Manager",
|
||||
"UI Manager View Operations (requires restart\nwarning: this is spammy)",
|
||||
Color.CYAN);
|
||||
public static final DebugOverlayTag FABRIC_UI_MANAGER =
|
||||
new DebugOverlayTag("FabricUIManager", "Fabric UI Manager View Operations", Color.CYAN);
|
||||
public static final DebugOverlayTag FABRIC_RECONCILER =
|
||||
new DebugOverlayTag("FabricReconciler", "Reconciler for Fabric", Color.CYAN);
|
||||
public static final DebugOverlayTag RELAY =
|
||||
new DebugOverlayTag("Relay", "including prefetching", Color.rgb(0xFF, 0x99, 0x00));
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.debug.tags
|
||||
|
||||
import android.graphics.Color
|
||||
import com.facebook.debug.debugoverlay.model.DebugOverlayTag
|
||||
|
||||
/** Category for debug overlays. */
|
||||
internal object ReactDebugOverlayTags {
|
||||
@JvmField
|
||||
val PERFORMANCE: DebugOverlayTag =
|
||||
DebugOverlayTag("Performance", "Markers for Performance", Color.GREEN)
|
||||
@JvmField
|
||||
val NAVIGATION: DebugOverlayTag =
|
||||
DebugOverlayTag("Navigation", "Tag for navigation", Color.rgb(0x9C, 0x27, 0xB0))
|
||||
@JvmField
|
||||
val RN_CORE: DebugOverlayTag =
|
||||
DebugOverlayTag("RN Core", "Tag for React Native Core", Color.BLACK)
|
||||
@JvmField
|
||||
val BRIDGE_CALLS: DebugOverlayTag =
|
||||
DebugOverlayTag("Bridge Calls", "JS to Java calls (warning: this is spammy)", Color.MAGENTA)
|
||||
@JvmField
|
||||
val NATIVE_MODULE: DebugOverlayTag =
|
||||
DebugOverlayTag("Native Module", "Native Module init", Color.rgb(0x80, 0x00, 0x80))
|
||||
@JvmField
|
||||
val UI_MANAGER: DebugOverlayTag =
|
||||
DebugOverlayTag(
|
||||
"UI Manager",
|
||||
"UI Manager View Operations (requires restart\nwarning: this is spammy)",
|
||||
Color.CYAN)
|
||||
@JvmField
|
||||
val FABRIC_UI_MANAGER: DebugOverlayTag =
|
||||
DebugOverlayTag("FabricUIManager", "Fabric UI Manager View Operations", Color.CYAN)
|
||||
@JvmField
|
||||
val FABRIC_RECONCILER: DebugOverlayTag =
|
||||
DebugOverlayTag("FabricReconciler", "Reconciler for Fabric", Color.CYAN)
|
||||
@JvmField
|
||||
val RELAY: DebugOverlayTag =
|
||||
DebugOverlayTag("Relay", "including prefetching", Color.rgb(0xFF, 0x99, 0x00))
|
||||
}
|
||||
+2
@@ -63,6 +63,8 @@ public abstract class ReactContext extends ContextWrapper {
|
||||
private @Nullable JSExceptionHandler mExceptionHandlerWrapper;
|
||||
private @Nullable WeakReference<Activity> mCurrentActivity;
|
||||
|
||||
// NOTE: When converted to Kotlin, this field should be made internal due to
|
||||
// visibility restriction on InteropModuleRegistry otherwise it will be exposed to the public API.
|
||||
protected @Nullable InteropModuleRegistry mInteropModuleRegistry;
|
||||
private boolean mIsInitialized = false;
|
||||
|
||||
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.bridge.interop;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.JavaScriptModule;
|
||||
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* A utility class that takes care of returning {@link JavaScriptModule} which are used for the
|
||||
* Fabric Interop Layer. This allows us to override the returned classes once the user is invoking
|
||||
* `ReactContext.getJsModule()`.
|
||||
*
|
||||
* <p>Currently we only support a `RCTEventEmitter` re-implementation, being `InteropEventEmitter`
|
||||
* but this class can support other re-implementation in the future.
|
||||
*/
|
||||
public class InteropModuleRegistry {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private final HashMap<Class, Object> supportedModules;
|
||||
|
||||
public InteropModuleRegistry() {
|
||||
supportedModules = new HashMap<>();
|
||||
}
|
||||
|
||||
public <T extends JavaScriptModule> boolean shouldReturnInteropModule(Class<T> requestedModule) {
|
||||
return checkReactFeatureFlagsConditions() && supportedModules.containsKey(requestedModule);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T extends JavaScriptModule> T getInteropModule(Class<T> requestedModule) {
|
||||
if (checkReactFeatureFlagsConditions()) {
|
||||
//noinspection unchecked
|
||||
return (T) supportedModules.get(requestedModule);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends JavaScriptModule> void registerInteropModule(
|
||||
Class<T> interopModuleInterface, Object interopModule) {
|
||||
if (checkReactFeatureFlagsConditions()) {
|
||||
supportedModules.put(interopModuleInterface, interopModule);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkReactFeatureFlagsConditions() {
|
||||
return ReactNativeFeatureFlags.enableFabricRenderer()
|
||||
&& ReactNativeFeatureFlags.useFabricInterop();
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.bridge.interop
|
||||
|
||||
import com.facebook.react.bridge.JavaScriptModule
|
||||
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags.enableFabricRenderer
|
||||
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags.useFabricInterop
|
||||
|
||||
/**
|
||||
* A utility class that takes care of returning [JavaScriptModule] which are used for the Fabric
|
||||
* Interop Layer. This allows us to override the returned classes once the user is invoking
|
||||
* `ReactContext.getJsModule()`.
|
||||
*
|
||||
* Currently we only support a `RCTEventEmitter` re-implementation, being `InteropEventEmitter` but
|
||||
* this class can support other re-implementation in the future.
|
||||
*/
|
||||
internal class InteropModuleRegistry {
|
||||
private val supportedModules = mutableMapOf<Class<*>, Any?>()
|
||||
|
||||
fun <T : JavaScriptModule?> shouldReturnInteropModule(requestedModule: Class<T>): Boolean {
|
||||
return checkReactFeatureFlagsConditions() && supportedModules.containsKey(requestedModule)
|
||||
}
|
||||
|
||||
fun <T : JavaScriptModule?> getInteropModule(requestedModule: Class<T>): T? {
|
||||
return if (checkReactFeatureFlagsConditions()) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
supportedModules[requestedModule] as? T?
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : JavaScriptModule?> registerInteropModule(
|
||||
interopModuleInterface: Class<T>,
|
||||
interopModule: Any
|
||||
) {
|
||||
if (checkReactFeatureFlagsConditions()) {
|
||||
supportedModules[interopModuleInterface] = interopModule
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkReactFeatureFlagsConditions(): Boolean =
|
||||
enableFabricRenderer() && useFabricInterop()
|
||||
}
|
||||
+2
-2
@@ -97,8 +97,8 @@ public final class BridgeDevSupportManager extends DevSupportManagerBase {
|
||||
new CallbackWithBundleLoader() {
|
||||
@Override
|
||||
public void onSuccess(JSBundleLoader bundleLoader) {
|
||||
bundleLoader.loadScript(getCurrentContext().getCatalystInstance());
|
||||
getCurrentContext()
|
||||
bundleLoader.loadScript(getCurrentReactContext().getCatalystInstance());
|
||||
getCurrentReactContext()
|
||||
.getJSModule(HMRClient.class)
|
||||
.registerBundle(getDevServerHelper().getDevServerSplitBundleURL(bundlePath));
|
||||
callback.onSuccess();
|
||||
|
||||
+27
-17
@@ -107,7 +107,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
|
||||
private @Nullable DebugOverlayController mDebugOverlayController;
|
||||
private boolean mDevLoadingViewVisible = false;
|
||||
private int mPendingJSSplitBundleRequests = 0;
|
||||
private @Nullable ReactContext mCurrentContext;
|
||||
private @Nullable ReactContext mCurrentReactContext;
|
||||
private final DeveloperSettings mDevSettings;
|
||||
private boolean mIsReceiverRegistered = false;
|
||||
private boolean mIsShakeDetectorStarted = false;
|
||||
@@ -429,11 +429,11 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
|
||||
() -> {
|
||||
boolean nextEnabled = !mDevSettings.isHotModuleReplacementEnabled();
|
||||
mDevSettings.setHotModuleReplacementEnabled(nextEnabled);
|
||||
if (mCurrentContext != null) {
|
||||
if (mCurrentReactContext != null) {
|
||||
if (nextEnabled) {
|
||||
mCurrentContext.getJSModule(HMRClient.class).enable();
|
||||
mCurrentReactContext.getJSModule(HMRClient.class).enable();
|
||||
} else {
|
||||
mCurrentContext.getJSModule(HMRClient.class).disable();
|
||||
mCurrentReactContext.getJSModule(HMRClient.class).disable();
|
||||
}
|
||||
}
|
||||
if (nextEnabled && !mDevSettings.isJSDevModeEnabled()) {
|
||||
@@ -542,8 +542,10 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
|
||||
.setOnCancelListener(dialog -> mDevOptionsDialog = null)
|
||||
.create();
|
||||
mDevOptionsDialog.show();
|
||||
if (mCurrentContext != null) {
|
||||
mCurrentContext.getJSModule(RCTNativeAppEventEmitter.class).emit("RCTDevMenuShown", null);
|
||||
if (mCurrentReactContext != null) {
|
||||
mCurrentReactContext
|
||||
.getJSModule(RCTNativeAppEventEmitter.class)
|
||||
.emit("RCTDevMenuShown", null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,11 +590,19 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
|
||||
|
||||
@Override
|
||||
public void onReactInstanceDestroyed(ReactContext reactContext) {
|
||||
if (reactContext == mCurrentContext) {
|
||||
if (reactContext == mCurrentReactContext) {
|
||||
// only call reset context when the destroyed context matches the one that is currently set
|
||||
// for this manager
|
||||
resetCurrentContext(null);
|
||||
}
|
||||
|
||||
// If some JNI types (e.g. jni::HybridClass) are used in JSI (e.g. jsi::HostObject), they might
|
||||
// not be immediately deleted on an app refresh as both Java and JavaScript are
|
||||
// garbage-collected languages and the memory might float around for a while. For C++
|
||||
// developers, this will be hard to debug as destructors might be called at a later point, so in
|
||||
// this case we trigger a Java GC to maybe eagerly collect such objects when the app
|
||||
// reloads.
|
||||
System.gc();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -656,12 +666,12 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
|
||||
}
|
||||
|
||||
private void resetCurrentContext(@Nullable ReactContext reactContext) {
|
||||
if (mCurrentContext == reactContext) {
|
||||
if (mCurrentReactContext == reactContext) {
|
||||
// new context is the same as the old one - do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
mCurrentContext = reactContext;
|
||||
mCurrentReactContext = reactContext;
|
||||
|
||||
// Recreate debug overlay controller with new CatalystInstance object
|
||||
if (mDebugOverlayController != null) {
|
||||
@@ -671,13 +681,13 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
|
||||
mDebugOverlayController = new DebugOverlayController(reactContext);
|
||||
}
|
||||
|
||||
if (mCurrentContext != null) {
|
||||
if (mCurrentReactContext != null) {
|
||||
try {
|
||||
URL sourceUrl = new URL(getSourceUrl());
|
||||
String path = sourceUrl.getPath().substring(1); // strip initial slash in path
|
||||
String host = sourceUrl.getHost();
|
||||
int port = sourceUrl.getPort() != -1 ? sourceUrl.getPort() : sourceUrl.getDefaultPort();
|
||||
mCurrentContext
|
||||
mCurrentReactContext
|
||||
.getJSModule(HMRClient.class)
|
||||
.setup("android", path, host, port, mDevSettings.isHotModuleReplacementEnabled());
|
||||
} catch (MalformedURLException e) {
|
||||
@@ -697,8 +707,8 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
|
||||
}
|
||||
}
|
||||
|
||||
protected @Nullable ReactContext getCurrentContext() {
|
||||
return mCurrentContext;
|
||||
public @Nullable ReactContext getCurrentReactContext() {
|
||||
return mCurrentReactContext;
|
||||
}
|
||||
|
||||
public @Nullable String getJSAppBundleName() {
|
||||
@@ -775,7 +785,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
|
||||
public void onSuccess() {
|
||||
UiThreadUtil.runOnUiThread(() -> hideSplitBundleDevLoadingView());
|
||||
|
||||
@Nullable ReactContext context = mCurrentContext;
|
||||
@Nullable ReactContext context = mCurrentReactContext;
|
||||
if (context == null || !context.hasActiveReactInstance()) {
|
||||
return;
|
||||
}
|
||||
@@ -856,10 +866,10 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
|
||||
}
|
||||
|
||||
private void handleCaptureHeap(final Responder responder) {
|
||||
if (mCurrentContext == null) {
|
||||
if (mCurrentReactContext == null) {
|
||||
return;
|
||||
}
|
||||
JSCHeapCapture heapCapture = mCurrentContext.getNativeModule(JSCHeapCapture.class);
|
||||
JSCHeapCapture heapCapture = mCurrentReactContext.getNativeModule(JSCHeapCapture.class);
|
||||
|
||||
if (heapCapture != null) {
|
||||
heapCapture.captureHeap(
|
||||
@@ -1152,7 +1162,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
|
||||
@Override
|
||||
public void openDebugger() {
|
||||
mDevServerHelper.openDebugger(
|
||||
mCurrentContext, mApplicationContext.getString(R.string.catalyst_open_debugger_error));
|
||||
mCurrentReactContext, mApplicationContext.getString(R.string.catalyst_open_debugger_error));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+31
-2
@@ -21,6 +21,8 @@ import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.R;
|
||||
import com.facebook.react.bridge.LifecycleEventListener;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.common.SurfaceDelegate;
|
||||
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
||||
@@ -55,7 +57,7 @@ class RedBoxDialogSurfaceDelegate implements SurfaceDelegate {
|
||||
FLog.e(
|
||||
ReactConstants.TAG,
|
||||
"Unable to launch redbox because react activity "
|
||||
+ "is not available, here is the error that redbox would've displayed: "
|
||||
+ "are not available, here is the error that redbox would've displayed: "
|
||||
+ (message != null ? message : "N/A"));
|
||||
return;
|
||||
}
|
||||
@@ -82,9 +84,19 @@ class RedBoxDialogSurfaceDelegate implements SurfaceDelegate {
|
||||
@Nullable String message = mDevSupportManager.getLastErrorTitle();
|
||||
Activity context = mDevSupportManager.getCurrentActivity();
|
||||
if (context == null || context.isFinishing()) {
|
||||
final @Nullable ReactContext reactContext = mDevSupportManager.getCurrentReactContext();
|
||||
if (reactContext != null) {
|
||||
/**
|
||||
* If the activity isn't available, try again after the next onHostResume(). onHostResume()
|
||||
* is when the activity gets attached to the react native.
|
||||
*/
|
||||
runAfterHostResume(reactContext, this::show);
|
||||
return;
|
||||
}
|
||||
|
||||
FLog.e(
|
||||
ReactConstants.TAG,
|
||||
"Unable to launch redbox because react activity "
|
||||
"Unable to launch redbox because react activity and react context "
|
||||
+ "is not available, here is the error that redbox would've displayed: "
|
||||
+ (message != null ? message : "N/A"));
|
||||
return;
|
||||
@@ -140,6 +152,23 @@ class RedBoxDialogSurfaceDelegate implements SurfaceDelegate {
|
||||
mDialog.show();
|
||||
}
|
||||
|
||||
private static void runAfterHostResume(ReactContext reactContext, Runnable runnable) {
|
||||
reactContext.addLifecycleEventListener(
|
||||
new LifecycleEventListener() {
|
||||
@Override
|
||||
public void onHostResume() {
|
||||
runnable.run();
|
||||
reactContext.removeLifecycleEventListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHostPause() {}
|
||||
|
||||
@Override
|
||||
public void onHostDestroy() {}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
// dismiss redbox if exists
|
||||
|
||||
+3
@@ -147,6 +147,9 @@ public open class ReleaseDevSupportManager : DevSupportManager {
|
||||
override public val currentActivity: Activity?
|
||||
get() = null
|
||||
|
||||
override public val currentReactContext: ReactContext?
|
||||
get() = null
|
||||
|
||||
override public fun createSurfaceDelegate(moduleName: String?): SurfaceDelegate? = null
|
||||
|
||||
override public fun openDebugger(): Unit = Unit
|
||||
|
||||
+1
@@ -35,6 +35,7 @@ public interface DevSupportManager : JSExceptionHandler {
|
||||
public val lastErrorType: ErrorType?
|
||||
public val lastErrorCookie: Int
|
||||
public val currentActivity: Activity?
|
||||
public val currentReactContext: ReactContext?
|
||||
|
||||
public var devSupportEnabled: Boolean
|
||||
|
||||
|
||||
+29
@@ -86,6 +86,7 @@ internal class AccessibilityInfoModule(context: ReactApplicationContext) :
|
||||
private var touchExplorationEnabled = false
|
||||
private var accessibilityServiceEnabled = false
|
||||
private var recommendedTimeout = 0
|
||||
private var invertColorsEnabled = false
|
||||
|
||||
init {
|
||||
val appContext = context.applicationContext
|
||||
@@ -111,6 +112,17 @@ internal class AccessibilityInfoModule(context: ReactApplicationContext) :
|
||||
return parsedValue == 0f
|
||||
}
|
||||
|
||||
@get:TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private val isInvertColorsEnabledValue: Boolean
|
||||
get() {
|
||||
try {
|
||||
return Settings.Secure.getInt(
|
||||
contentResolver, Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED) == 1
|
||||
} catch (e: Settings.SettingNotFoundException) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@get:TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private val isHighTextContrastEnabledValue: Boolean
|
||||
get() {
|
||||
@@ -125,6 +137,10 @@ internal class AccessibilityInfoModule(context: ReactApplicationContext) :
|
||||
successCallback.invoke(reduceMotionEnabled)
|
||||
}
|
||||
|
||||
override fun isInvertColorsEnabled(successCallback: Callback) {
|
||||
successCallback.invoke(invertColorsEnabled)
|
||||
}
|
||||
|
||||
override fun isHighTextContrastEnabled(successCallback: Callback) {
|
||||
successCallback.invoke(highTextContrastEnabled)
|
||||
}
|
||||
@@ -148,6 +164,17 @@ internal class AccessibilityInfoModule(context: ReactApplicationContext) :
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateAndSendInvertColorsChangeEvent() {
|
||||
val isInvertColorsEnabled = isInvertColorsEnabledValue
|
||||
if (invertColorsEnabled != isInvertColorsEnabled) {
|
||||
invertColorsEnabled = isInvertColorsEnabled
|
||||
val reactApplicationContext = getReactApplicationContextIfActiveOrWarn()
|
||||
if (reactApplicationContext != null) {
|
||||
reactApplicationContext.emitDeviceEvent(INVERT_COLOR_EVENT_NAME, invertColorsEnabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateAndSendHighTextContrastChangeEvent() {
|
||||
val isHighTextContrastEnabled = isHighTextContrastEnabledValue
|
||||
if (highTextContrastEnabled != isHighTextContrastEnabled) {
|
||||
@@ -199,6 +226,7 @@ internal class AccessibilityInfoModule(context: ReactApplicationContext) :
|
||||
updateAndSendAccessibilityServiceChangeEvent(accessibilityManager?.isEnabled == true)
|
||||
updateAndSendReduceMotionChangeEvent()
|
||||
updateAndSendHighTextContrastChangeEvent()
|
||||
updateAndSendInvertColorsChangeEvent()
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@@ -263,5 +291,6 @@ internal class AccessibilityInfoModule(context: ReactApplicationContext) :
|
||||
private const val ACCESSIBILITY_SERVICE_EVENT_NAME = "accessibilityServiceDidChange"
|
||||
private const val ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED_CONSTANT =
|
||||
"high_text_contrast_enabled" // constant is marked with @hide
|
||||
private const val INVERT_COLOR_EVENT_NAME = "invertColorDidChange"
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -22,13 +22,13 @@ private class Settings {
|
||||
|
||||
@DoNotStripAny
|
||||
@ReactModule(name = NativeReactDevToolsRuntimeSettingsModuleSpec.NAME)
|
||||
public class ReactDevToolsRuntimeSettingsModule(reactContext: ReactApplicationContext?) :
|
||||
internal class ReactDevToolsRuntimeSettingsModule(reactContext: ReactApplicationContext?) :
|
||||
NativeReactDevToolsRuntimeSettingsModuleSpec(reactContext) {
|
||||
|
||||
public companion object {
|
||||
companion object {
|
||||
// static to persist across Turbo Module reloads
|
||||
private val settings = Settings()
|
||||
public const val NAME: String = NativeReactDevToolsRuntimeSettingsModuleSpec.NAME
|
||||
const val NAME: String = NativeReactDevToolsRuntimeSettingsModuleSpec.NAME
|
||||
}
|
||||
|
||||
override fun setReloadAndProfileConfig(map: ReadableMap) {
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.modules.fresco
|
||||
|
||||
public enum class ImageCacheControl {
|
||||
/** Uses OkHttp's default cache control policy with no store. */
|
||||
DEFAULT,
|
||||
/**
|
||||
* The data for the URL will be loaded from the originating source. No existing cache data should
|
||||
* be used to satisfy a URL load request.
|
||||
*/
|
||||
RELOAD,
|
||||
/**
|
||||
* The existing cache data will be used to satisfy a request, regardless of its age or expiration
|
||||
* date. If there is no existing data in the cache corresponding to a URL load request, no attempt
|
||||
* is made to load the data from the originating source, and the load is considered to have
|
||||
* failed.
|
||||
*/
|
||||
ONLY_IF_CACHED,
|
||||
}
|
||||
+6
-3
@@ -16,16 +16,19 @@ public class ReactNetworkImageRequest
|
||||
private constructor(
|
||||
builder: ImageRequestBuilder,
|
||||
/** Headers for the request */
|
||||
internal val headers: ReadableMap?
|
||||
internal val headers: ReadableMap?,
|
||||
internal val cacheControl: ImageCacheControl,
|
||||
) : ImageRequest(builder) {
|
||||
|
||||
public companion object {
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
public fun fromBuilderWithHeaders(
|
||||
builder: ImageRequestBuilder,
|
||||
headers: ReadableMap?
|
||||
headers: ReadableMap?,
|
||||
cacheControl: ImageCacheControl = ImageCacheControl.DEFAULT,
|
||||
): ReactNetworkImageRequest {
|
||||
return ReactNetworkImageRequest(builder, headers)
|
||||
return ReactNetworkImageRequest(builder, headers, cacheControl)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-5
@@ -35,22 +35,30 @@ internal class ReactOkHttpNetworkFetcher(private val okHttpClient: OkHttpClient)
|
||||
fetchState.submitTime = SystemClock.elapsedRealtime()
|
||||
val uri = fetchState.uri
|
||||
var requestHeaders: Map<String, String>? = null
|
||||
val cacheControlBuilder = CacheControl.Builder().noStore()
|
||||
if (fetchState.context.imageRequest is ReactNetworkImageRequest) {
|
||||
val networkImageRequest = fetchState.context.imageRequest as ReactNetworkImageRequest
|
||||
requestHeaders = getHeaders(networkImageRequest.headers)
|
||||
when (networkImageRequest.cacheControl) {
|
||||
ImageCacheControl.RELOAD -> {
|
||||
cacheControlBuilder.noCache()
|
||||
}
|
||||
ImageCacheControl.ONLY_IF_CACHED -> {
|
||||
cacheControlBuilder.onlyIfCached()
|
||||
}
|
||||
ImageCacheControl.DEFAULT -> {
|
||||
// No-op
|
||||
}
|
||||
}
|
||||
}
|
||||
val headers = OkHttpCompat.getHeadersFromMap(requestHeaders)
|
||||
val request =
|
||||
Request.Builder()
|
||||
.cacheControl(CacheControl.Builder().noStore().build())
|
||||
.cacheControl(cacheControlBuilder.build())
|
||||
.url(uri.toString())
|
||||
.headers(headers)
|
||||
.get()
|
||||
.build()
|
||||
fetchWithRequest(fetchState, callback, request)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val TAG = "ReactOkHttpNetworkFetcher"
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -14,20 +14,20 @@ import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.module.annotations.ReactModule
|
||||
|
||||
@ReactModule(name = NativeReactDevToolsSettingsManagerSpec.NAME)
|
||||
public class ReactDevToolsSettingsManagerModule(reactContext: ReactApplicationContext) :
|
||||
internal class ReactDevToolsSettingsManagerModule(reactContext: ReactApplicationContext) :
|
||||
NativeReactDevToolsSettingsManagerSpec(reactContext) {
|
||||
|
||||
private val sharedPreferences: SharedPreferences =
|
||||
reactContext.getSharedPreferences(SHARED_PREFERENCES_PREFIX, Context.MODE_PRIVATE)
|
||||
|
||||
public override fun setGlobalHookSettings(settings: String): Unit =
|
||||
override fun setGlobalHookSettings(settings: String): Unit =
|
||||
sharedPreferences.edit().putString(KEY_HOOK_SETTINGS, settings).apply()
|
||||
|
||||
public override fun getGlobalHookSettings(): String? =
|
||||
override fun getGlobalHookSettings(): String? =
|
||||
sharedPreferences.getString(KEY_HOOK_SETTINGS, null)
|
||||
|
||||
public companion object {
|
||||
public const val NAME: String = NativeReactDevToolsSettingsManagerSpec.NAME
|
||||
companion object {
|
||||
const val NAME: String = NativeReactDevToolsSettingsManagerSpec.NAME
|
||||
private const val SHARED_PREFERENCES_PREFIX = "ReactNative__DevToolsSettings"
|
||||
private const val KEY_HOOK_SETTINGS = "HookSettings"
|
||||
}
|
||||
|
||||
+36
-4
@@ -24,6 +24,7 @@ import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import com.facebook.common.references.CloseableReference
|
||||
import com.facebook.common.util.UriUtil
|
||||
import com.facebook.drawee.backends.pipeline.Fresco
|
||||
import com.facebook.drawee.controller.AbstractDraweeControllerBuilder
|
||||
import com.facebook.drawee.controller.ControllerListener
|
||||
import com.facebook.drawee.controller.ForwardingControllerListener
|
||||
@@ -40,6 +41,7 @@ import com.facebook.imagepipeline.image.ImageInfo
|
||||
import com.facebook.imagepipeline.postprocessors.IterativeBoxBlurPostProcessor
|
||||
import com.facebook.imagepipeline.request.BasePostprocessor
|
||||
import com.facebook.imagepipeline.request.ImageRequest
|
||||
import com.facebook.imagepipeline.request.ImageRequest.RequestLevel
|
||||
import com.facebook.imagepipeline.request.ImageRequestBuilder
|
||||
import com.facebook.imagepipeline.request.Postprocessor
|
||||
import com.facebook.react.bridge.ReactContext
|
||||
@@ -49,6 +51,7 @@ import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
||||
import com.facebook.react.common.annotations.VisibleForTesting
|
||||
import com.facebook.react.common.build.ReactBuildConfig
|
||||
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
|
||||
import com.facebook.react.modules.fresco.ImageCacheControl
|
||||
import com.facebook.react.modules.fresco.ReactNetworkImageRequest
|
||||
import com.facebook.react.uimanager.BackgroundStyleApplicator
|
||||
import com.facebook.react.uimanager.LengthPercentage
|
||||
@@ -268,7 +271,8 @@ public class ReactImageView(
|
||||
} else if (sources.size() == 1) {
|
||||
// Optimize for the case where we have just one uri, case in which we don't need the sizes
|
||||
val source = sources.getMap(0)
|
||||
var imageSource = ImageSource(context, source.getString("uri"))
|
||||
val cacheControl = computeCacheControl(source.getString("cache"))
|
||||
var imageSource = ImageSource(context, source.getString("uri"), cacheControl = cacheControl)
|
||||
if (Uri.EMPTY == imageSource.uri) {
|
||||
warnImageSource(source.getString("uri"))
|
||||
imageSource = getTransparentBitmapImageSource(context)
|
||||
@@ -277,12 +281,14 @@ public class ReactImageView(
|
||||
} else {
|
||||
for (idx in 0 until sources.size()) {
|
||||
val source = sources.getMap(idx)
|
||||
val cacheControl = computeCacheControl(source.getString("cache"))
|
||||
var imageSource =
|
||||
ImageSource(
|
||||
context,
|
||||
source.getString("uri"),
|
||||
source.getDouble("width"),
|
||||
source.getDouble("height"))
|
||||
source.getDouble("height"),
|
||||
cacheControl)
|
||||
if (Uri.EMPTY == imageSource.uri) {
|
||||
warnImageSource(source.getString("uri"))
|
||||
imageSource = getTransparentBitmapImageSource(context)
|
||||
@@ -301,6 +307,23 @@ public class ReactImageView(
|
||||
isDirty = true
|
||||
}
|
||||
|
||||
private fun computeCacheControl(cacheControl: String?): ImageCacheControl {
|
||||
return when (cacheControl) {
|
||||
null,
|
||||
"default" -> ImageCacheControl.DEFAULT
|
||||
"reload" -> ImageCacheControl.RELOAD
|
||||
"only-if-cached" -> ImageCacheControl.ONLY_IF_CACHED
|
||||
else -> ImageCacheControl.DEFAULT
|
||||
}
|
||||
}
|
||||
|
||||
private fun computeRequestLevel(cacheControl: ImageCacheControl): RequestLevel {
|
||||
return when (cacheControl) {
|
||||
ImageCacheControl.ONLY_IF_CACHED -> RequestLevel.DISK_CACHE
|
||||
else -> RequestLevel.FULL_FETCH
|
||||
}
|
||||
}
|
||||
|
||||
public fun setDefaultSource(name: String?) {
|
||||
val newDefaultDrawable = instance.getResourceDrawable(context, name)
|
||||
if (defaultImageDrawable != newDefaultDrawable) {
|
||||
@@ -409,7 +432,10 @@ public class ReactImageView(
|
||||
}
|
||||
|
||||
private fun maybeUpdateViewFromRequest(doResize: Boolean) {
|
||||
val uri = this.imageSource?.uri ?: return
|
||||
val imageSource = this.imageSource ?: return
|
||||
val uri = imageSource.uri
|
||||
val cacheControl = imageSource.cacheControl
|
||||
val requestLevel = computeRequestLevel(cacheControl)
|
||||
|
||||
val postprocessorList = mutableListOf<Postprocessor>()
|
||||
iterativeBoxBlurPostProcessor?.let { postprocessorList.add(it) }
|
||||
@@ -418,19 +444,25 @@ public class ReactImageView(
|
||||
|
||||
val resizeOptions = if (doResize) resizeOptions else null
|
||||
|
||||
if (cacheControl == ImageCacheControl.RELOAD) {
|
||||
val imagePipeline = Fresco.getImagePipeline()
|
||||
imagePipeline.evictFromCache(uri)
|
||||
}
|
||||
|
||||
val imageRequestBuilder =
|
||||
ImageRequestBuilder.newBuilderWithSource(uri)
|
||||
.setPostprocessor(postprocessor)
|
||||
.setResizeOptions(resizeOptions)
|
||||
.setAutoRotateEnabled(true)
|
||||
.setProgressiveRenderingEnabled(progressiveRenderingEnabled)
|
||||
.setLowestPermittedRequestLevel(requestLevel)
|
||||
|
||||
if (resizeMethod == ImageResizeMethod.NONE) {
|
||||
imageRequestBuilder.setDownsampleOverride(DownsampleMode.NEVER)
|
||||
}
|
||||
|
||||
val imageRequest: ImageRequest =
|
||||
ReactNetworkImageRequest.fromBuilderWithHeaders(imageRequestBuilder, headers)
|
||||
ReactNetworkImageRequest.fromBuilderWithHeaders(imageRequestBuilder, headers, cacheControl)
|
||||
|
||||
globalImageLoadListener?.onLoadAttempt(uri)
|
||||
|
||||
|
||||
+7
-4
@@ -9,6 +9,7 @@ package com.facebook.react.views.imagehelper
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import com.facebook.react.modules.fresco.ImageCacheControl
|
||||
import java.util.Objects
|
||||
|
||||
/** Class describing an image source (network URI or resource) and size. */
|
||||
@@ -19,7 +20,8 @@ constructor(
|
||||
/** Get the source of this image, as it was passed to the constructor. */
|
||||
public val source: String?,
|
||||
width: Double = 0.0,
|
||||
height: Double = 0.0
|
||||
height: Double = 0.0,
|
||||
public val cacheControl: ImageCacheControl = ImageCacheControl.DEFAULT,
|
||||
) {
|
||||
|
||||
/** Get the URI for this image - can be either a parsed network URI or a resource URI. */
|
||||
@@ -45,10 +47,11 @@ constructor(
|
||||
return java.lang.Double.compare(that.size, size) == 0 &&
|
||||
isResource == that.isResource &&
|
||||
uri == that.uri &&
|
||||
source == that.source
|
||||
source == that.source &&
|
||||
cacheControl == that.cacheControl
|
||||
}
|
||||
|
||||
override fun hashCode(): Int = Objects.hash(uri, source, size, isResource)
|
||||
override fun hashCode(): Int = Objects.hash(uri, source, size, isResource, cacheControl)
|
||||
|
||||
private fun computeUri(context: Context): Uri =
|
||||
try {
|
||||
@@ -70,6 +73,6 @@ constructor(
|
||||
|
||||
@JvmStatic
|
||||
public fun getTransparentBitmapImageSource(context: Context): ImageSource =
|
||||
ImageSource(context, TRANSPARENT_BITMAP_URI)
|
||||
ImageSource(context, TRANSPARENT_BITMAP_URI, cacheControl = ImageCacheControl.DEFAULT)
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -8,6 +8,7 @@
|
||||
package com.facebook.react.views.imagehelper
|
||||
|
||||
import com.facebook.imagepipeline.core.ImagePipelineFactory
|
||||
import com.facebook.react.modules.fresco.ImageCacheControl
|
||||
|
||||
/** Helper class for dealing with multisource images. */
|
||||
public object MultiSourceHelper {
|
||||
@@ -62,7 +63,10 @@ public object MultiSourceHelper {
|
||||
best = source
|
||||
}
|
||||
if (precision < bestCachePrecision &&
|
||||
source.cacheControl != ImageCacheControl.RELOAD &&
|
||||
(imagePipeline.isInBitmapMemoryCache(source.uri) ||
|
||||
// TODO: T206445115 isInDiskCacheSync is a blocking operation, we should move this to
|
||||
// a separate thread
|
||||
imagePipeline.isInDiskCacheSync(source.uri))) {
|
||||
bestCachePrecision = precision
|
||||
bestCached = source
|
||||
|
||||
+8
-1
@@ -300,7 +300,14 @@ public class ReactModalHostView(context: ThemedReactContext) :
|
||||
* changed. This has the pleasant side-effect of us not having to preface all Modals with "top:
|
||||
* statusBarHeight", since that margin will be included in the FrameLayout.
|
||||
*/
|
||||
get() = FrameLayout(context).apply { addView(dialogRootViewGroup) }
|
||||
get() =
|
||||
FrameLayout(context).apply {
|
||||
addView(dialogRootViewGroup)
|
||||
if (!statusBarTranslucent) {
|
||||
// this is needed to prevent content hiding behind systems bars < API 30
|
||||
this.fitsSystemWindows = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* updateProperties will update the properties that do not require us to recreate the dialog
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ import com.facebook.react.uimanager.annotations.ReactProp
|
||||
|
||||
/** ViewManager for [ReactUnimplementedView] to represent a component that is not yet supported. */
|
||||
@ReactModule(name = ReactUnimplementedViewManager.REACT_CLASS)
|
||||
public class ReactUnimplementedViewManager : ViewGroupManager<ReactUnimplementedView>() {
|
||||
internal class ReactUnimplementedViewManager : ViewGroupManager<ReactUnimplementedView>() {
|
||||
|
||||
protected override fun createViewInstance(
|
||||
reactContext: ThemedReactContext
|
||||
@@ -27,7 +27,7 @@ public class ReactUnimplementedViewManager : ViewGroupManager<ReactUnimplemented
|
||||
view.setName(name)
|
||||
}
|
||||
|
||||
public companion object {
|
||||
internal companion object {
|
||||
public const val REACT_CLASS: String = "UnimplementedNativeView"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,9 @@ public class YogaNative {
|
||||
static native void jni_YGNodeStyleSetFlexBasisJNI(long nativePointer, float flexBasis);
|
||||
static native void jni_YGNodeStyleSetFlexBasisPercentJNI(long nativePointer, float percent);
|
||||
static native void jni_YGNodeStyleSetFlexBasisAutoJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetFlexBasisMaxContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetFlexBasisFitContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetFlexBasisStretchJNI(long nativePointer);
|
||||
static native long jni_YGNodeStyleGetMarginJNI(long nativePointer, int edge);
|
||||
static native void jni_YGNodeStyleSetMarginJNI(long nativePointer, int edge, float margin);
|
||||
static native void jni_YGNodeStyleSetMarginPercentJNI(long nativePointer, int edge, float percent);
|
||||
@@ -91,22 +94,40 @@ public class YogaNative {
|
||||
static native void jni_YGNodeStyleSetWidthJNI(long nativePointer, float width);
|
||||
static native void jni_YGNodeStyleSetWidthPercentJNI(long nativePointer, float percent);
|
||||
static native void jni_YGNodeStyleSetWidthAutoJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetWidthMaxContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetWidthFitContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetWidthStretchJNI(long nativePointer);
|
||||
static native long jni_YGNodeStyleGetHeightJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetHeightJNI(long nativePointer, float height);
|
||||
static native void jni_YGNodeStyleSetHeightPercentJNI(long nativePointer, float percent);
|
||||
static native void jni_YGNodeStyleSetHeightAutoJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetHeightMaxContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetHeightFitContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetHeightStretchJNI(long nativePointer);
|
||||
static native long jni_YGNodeStyleGetMinWidthJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMinWidthJNI(long nativePointer, float minWidth);
|
||||
static native void jni_YGNodeStyleSetMinWidthPercentJNI(long nativePointer, float percent);
|
||||
static native void jni_YGNodeStyleSetMinWidthMaxContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMinWidthFitContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMinWidthStretchJNI(long nativePointer);
|
||||
static native long jni_YGNodeStyleGetMinHeightJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMinHeightJNI(long nativePointer, float minHeight);
|
||||
static native void jni_YGNodeStyleSetMinHeightPercentJNI(long nativePointer, float percent);
|
||||
static native void jni_YGNodeStyleSetMinHeightMaxContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMinHeightFitContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMinHeightStretchJNI(long nativePointer);
|
||||
static native long jni_YGNodeStyleGetMaxWidthJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMaxWidthJNI(long nativePointer, float maxWidth);
|
||||
static native void jni_YGNodeStyleSetMaxWidthPercentJNI(long nativePointer, float percent);
|
||||
static native void jni_YGNodeStyleSetMaxWidthMaxContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMaxWidthFitContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMaxWidthStretchJNI(long nativePointer);
|
||||
static native long jni_YGNodeStyleGetMaxHeightJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMaxHeightJNI(long nativePointer, float maxheight);
|
||||
static native void jni_YGNodeStyleSetMaxHeightPercentJNI(long nativePointer, float percent);
|
||||
static native void jni_YGNodeStyleSetMaxHeightMaxContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMaxHeightFitContentJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMaxHeightStretchJNI(long nativePointer);
|
||||
static native float jni_YGNodeStyleGetAspectRatioJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetAspectRatioJNI(long nativePointer, float aspectRatio);
|
||||
static native float jni_YGNodeStyleGetGapJNI(long nativePointer, int gutter);
|
||||
|
||||
@@ -124,6 +124,12 @@ public abstract class YogaNode implements YogaProps {
|
||||
|
||||
public abstract void setFlexBasisAuto();
|
||||
|
||||
public abstract void setFlexBasisMaxContent();
|
||||
|
||||
public abstract void setFlexBasisFitContent();
|
||||
|
||||
public abstract void setFlexBasisStretch();
|
||||
|
||||
public abstract YogaValue getMargin(YogaEdge edge);
|
||||
|
||||
public abstract void setMargin(YogaEdge edge, float margin);
|
||||
@@ -158,6 +164,12 @@ public abstract class YogaNode implements YogaProps {
|
||||
|
||||
public abstract void setWidthAuto();
|
||||
|
||||
public abstract void setWidthMaxContent();
|
||||
|
||||
public abstract void setWidthFitContent();
|
||||
|
||||
public abstract void setWidthStretch();
|
||||
|
||||
public abstract YogaValue getHeight();
|
||||
|
||||
public abstract void setHeight(float height);
|
||||
@@ -166,30 +178,60 @@ public abstract class YogaNode implements YogaProps {
|
||||
|
||||
public abstract void setHeightAuto();
|
||||
|
||||
public abstract void setHeightMaxContent();
|
||||
|
||||
public abstract void setHeightFitContent();
|
||||
|
||||
public abstract void setHeightStretch();
|
||||
|
||||
public abstract YogaValue getMinWidth();
|
||||
|
||||
public abstract void setMinWidth(float minWidth);
|
||||
|
||||
public abstract void setMinWidthPercent(float percent);
|
||||
|
||||
public abstract void setMinWidthMaxContent();
|
||||
|
||||
public abstract void setMinWidthFitContent();
|
||||
|
||||
public abstract void setMinWidthStretch();
|
||||
|
||||
public abstract YogaValue getMinHeight();
|
||||
|
||||
public abstract void setMinHeight(float minHeight);
|
||||
|
||||
public abstract void setMinHeightPercent(float percent);
|
||||
|
||||
public abstract void setMinHeightMaxContent();
|
||||
|
||||
public abstract void setMinHeightFitContent();
|
||||
|
||||
public abstract void setMinHeightStretch();
|
||||
|
||||
public abstract YogaValue getMaxWidth();
|
||||
|
||||
public abstract void setMaxWidth(float maxWidth);
|
||||
|
||||
public abstract void setMaxWidthPercent(float percent);
|
||||
|
||||
public abstract void setMaxWidthMaxContent();
|
||||
|
||||
public abstract void setMaxWidthFitContent();
|
||||
|
||||
public abstract void setMaxWidthStretch();
|
||||
|
||||
public abstract YogaValue getMaxHeight();
|
||||
|
||||
public abstract void setMaxHeight(float maxheight);
|
||||
|
||||
public abstract void setMaxHeightPercent(float percent);
|
||||
|
||||
public abstract void setMaxHeightMaxContent();
|
||||
|
||||
public abstract void setMaxHeightFitContent();
|
||||
|
||||
public abstract void setMaxHeightStretch();
|
||||
|
||||
public abstract float getAspectRatio();
|
||||
|
||||
public abstract void setAspectRatio(float aspectRatio);
|
||||
|
||||
+84
@@ -373,6 +373,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
YogaNative.jni_YGNodeStyleSetFlexBasisAutoJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setFlexBasisMaxContent() {
|
||||
YogaNative.jni_YGNodeStyleSetFlexBasisMaxContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setFlexBasisFitContent() {
|
||||
YogaNative.jni_YGNodeStyleSetFlexBasisFitContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setFlexBasisStretch() {
|
||||
YogaNative.jni_YGNodeStyleSetFlexBasisStretchJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public YogaValue getMargin(YogaEdge edge) {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMarginJNI(mNativePointer, edge.intValue()));
|
||||
}
|
||||
@@ -441,6 +453,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
YogaNative.jni_YGNodeStyleSetWidthAutoJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setWidthMaxContent() {
|
||||
YogaNative.jni_YGNodeStyleSetWidthMaxContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setWidthFitContent() {
|
||||
YogaNative.jni_YGNodeStyleSetWidthFitContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setWidthStretch() {
|
||||
YogaNative.jni_YGNodeStyleSetWidthStretchJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public YogaValue getHeight() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetHeightJNI(mNativePointer));
|
||||
}
|
||||
@@ -457,6 +481,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
YogaNative.jni_YGNodeStyleSetHeightAutoJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setHeightMaxContent() {
|
||||
YogaNative.jni_YGNodeStyleSetHeightMaxContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setHeightFitContent() {
|
||||
YogaNative.jni_YGNodeStyleSetHeightFitContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setHeightStretch() {
|
||||
YogaNative.jni_YGNodeStyleSetHeightStretchJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public YogaValue getMinWidth() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinWidthJNI(mNativePointer));
|
||||
}
|
||||
@@ -469,6 +505,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
YogaNative.jni_YGNodeStyleSetMinWidthPercentJNI(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public void setMinWidthMaxContent() {
|
||||
YogaNative.jni_YGNodeStyleSetMinWidthMaxContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setMinWidthFitContent() {
|
||||
YogaNative.jni_YGNodeStyleSetMinWidthFitContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setMinWidthStretch() {
|
||||
YogaNative.jni_YGNodeStyleSetMinWidthStretchJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public YogaValue getMinHeight() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinHeightJNI(mNativePointer));
|
||||
}
|
||||
@@ -481,6 +529,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
YogaNative.jni_YGNodeStyleSetMinHeightPercentJNI(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public void setMinHeightMaxContent() {
|
||||
YogaNative.jni_YGNodeStyleSetMinHeightMaxContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setMinHeightFitContent() {
|
||||
YogaNative.jni_YGNodeStyleSetMinHeightFitContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setMinHeightStretch() {
|
||||
YogaNative.jni_YGNodeStyleSetMinHeightStretchJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public YogaValue getMaxWidth() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxWidthJNI(mNativePointer));
|
||||
}
|
||||
@@ -493,6 +553,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
YogaNative.jni_YGNodeStyleSetMaxWidthPercentJNI(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public void setMaxWidthMaxContent() {
|
||||
YogaNative.jni_YGNodeStyleSetMaxWidthMaxContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setMaxWidthFitContent() {
|
||||
YogaNative.jni_YGNodeStyleSetMaxWidthFitContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setMaxWidthStretch() {
|
||||
YogaNative.jni_YGNodeStyleSetMaxWidthStretchJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public YogaValue getMaxHeight() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxHeightJNI(mNativePointer));
|
||||
}
|
||||
@@ -505,6 +577,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
YogaNative.jni_YGNodeStyleSetMaxHeightPercentJNI(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public void setMaxHeightMaxContent() {
|
||||
YogaNative.jni_YGNodeStyleSetMaxHeightMaxContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setMaxHeightFitContent() {
|
||||
YogaNative.jni_YGNodeStyleSetMaxHeightFitContentJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public void setMaxHeightStretch() {
|
||||
YogaNative.jni_YGNodeStyleSetMaxHeightStretchJNI(mNativePointer);
|
||||
}
|
||||
|
||||
public float getAspectRatio() {
|
||||
return YogaNative.jni_YGNodeStyleGetAspectRatioJNI(mNativePointer);
|
||||
}
|
||||
|
||||
@@ -15,15 +15,33 @@ public interface YogaProps {
|
||||
|
||||
void setWidthPercent(float percent);
|
||||
|
||||
void setWidthAuto();
|
||||
|
||||
void setWidthMaxContent();
|
||||
|
||||
void setWidthFitContent();
|
||||
|
||||
void setWidthStretch();
|
||||
|
||||
void setMinWidth(float minWidth);
|
||||
|
||||
void setMinWidthPercent(float percent);
|
||||
|
||||
void setMinWidthMaxContent();
|
||||
|
||||
void setMinWidthFitContent();
|
||||
|
||||
void setMinWidthStretch();
|
||||
|
||||
void setMaxWidth(float maxWidth);
|
||||
|
||||
void setMaxWidthPercent(float percent);
|
||||
|
||||
void setWidthAuto();
|
||||
void setMaxWidthMaxContent();
|
||||
|
||||
void setMaxWidthFitContent();
|
||||
|
||||
void setMaxWidthStretch();
|
||||
|
||||
/* Height properties */
|
||||
|
||||
@@ -31,15 +49,33 @@ public interface YogaProps {
|
||||
|
||||
void setHeightPercent(float percent);
|
||||
|
||||
void setHeightAuto();
|
||||
|
||||
void setHeightMaxContent();
|
||||
|
||||
void setHeightFitContent();
|
||||
|
||||
void setHeightStretch();
|
||||
|
||||
void setMinHeight(float minHeight);
|
||||
|
||||
void setMinHeightPercent(float percent);
|
||||
|
||||
void setMinHeightMaxContent();
|
||||
|
||||
void setMinHeightFitContent();
|
||||
|
||||
void setMinHeightStretch();
|
||||
|
||||
void setMaxHeight(float maxHeight);
|
||||
|
||||
void setMaxHeightPercent(float percent);
|
||||
|
||||
void setHeightAuto();
|
||||
void setMaxHeightMaxContent();
|
||||
|
||||
void setMaxHeightFitContent();
|
||||
|
||||
void setMaxHeightStretch();
|
||||
|
||||
/* Margin properties */
|
||||
|
||||
@@ -81,6 +117,12 @@ public interface YogaProps {
|
||||
|
||||
void setFlexBasis(float flexBasis);
|
||||
|
||||
void setFlexBasisMaxContent();
|
||||
|
||||
void setFlexBasisFitContent();
|
||||
|
||||
void setFlexBasisStretch();
|
||||
|
||||
void setFlexDirection(YogaFlexDirection direction);
|
||||
|
||||
void setFlexGrow(float flexGrow);
|
||||
|
||||
@@ -13,7 +13,10 @@ public enum YogaUnit {
|
||||
UNDEFINED(0),
|
||||
POINT(1),
|
||||
PERCENT(2),
|
||||
AUTO(3);
|
||||
AUTO(3),
|
||||
MAX_CONTENT(4),
|
||||
FIT_CONTENT(5),
|
||||
STRETCH(6);
|
||||
|
||||
private final int mIntValue;
|
||||
|
||||
@@ -31,6 +34,9 @@ public enum YogaUnit {
|
||||
case 1: return POINT;
|
||||
case 2: return PERCENT;
|
||||
case 3: return AUTO;
|
||||
case 4: return MAX_CONTENT;
|
||||
case 5: return FIT_CONTENT;
|
||||
case 6: return STRETCH;
|
||||
default: throw new IllegalArgumentException("Unknown enum value: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
+92
-7
@@ -429,6 +429,28 @@ static void jni_YGNodeCopyStyleJNI(
|
||||
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
|
||||
}
|
||||
|
||||
#define YG_NODE_JNI_STYLE_UNIT_PROP_AUTO_INTRINSIC(name) \
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(name) \
|
||||
YG_NODE_JNI_STYLE_UNIT_INTRINSIC(name)
|
||||
|
||||
#define YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(name) \
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
||||
YG_NODE_JNI_STYLE_UNIT_INTRINSIC(name)
|
||||
|
||||
#define YG_NODE_JNI_STYLE_UNIT_INTRINSIC(name) \
|
||||
static void jni_YGNodeStyleSet##name##MaxContentJNI( \
|
||||
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
|
||||
YGNodeStyleSet##name##MaxContent(_jlong2YGNodeRef(nativePointer)); \
|
||||
} \
|
||||
static void jni_YGNodeStyleSet##name##FitContentJNI( \
|
||||
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
|
||||
YGNodeStyleSet##name##FitContent(_jlong2YGNodeRef(nativePointer)); \
|
||||
} \
|
||||
static void jni_YGNodeStyleSet##name##StretchJNI( \
|
||||
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
|
||||
YGNodeStyleSet##name##Stretch(_jlong2YGNodeRef(nativePointer)); \
|
||||
}
|
||||
|
||||
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
|
||||
static jlong jni_YGNodeStyleGet##name##JNI( \
|
||||
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jint edge) { \
|
||||
@@ -483,13 +505,13 @@ YG_NODE_JNI_STYLE_PROP(jfloat, float, Flex);
|
||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
|
||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
|
||||
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(FlexBasis);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Width);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP(MinWidth);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP(MaxWidth);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Height);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP(MinHeight);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO_INTRINSIC(FlexBasis);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO_INTRINSIC(Width);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(MinWidth);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(MaxWidth);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO_INTRINSIC(Height);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(MinHeight);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(MaxHeight);
|
||||
|
||||
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(Position);
|
||||
|
||||
@@ -870,6 +892,15 @@ static JNINativeMethod methods[] = {
|
||||
{"jni_YGNodeStyleSetFlexBasisAutoJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetFlexBasisAutoJNI},
|
||||
{"jni_YGNodeStyleSetFlexBasisMaxContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetFlexBasisMaxContentJNI},
|
||||
{"jni_YGNodeStyleSetFlexBasisFitContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetFlexBasisFitContentJNI},
|
||||
{"jni_YGNodeStyleSetFlexBasisStretchJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetFlexBasisStretchJNI},
|
||||
{"jni_YGNodeStyleGetMarginJNI",
|
||||
"(JI)J",
|
||||
(void*)jni_YGNodeStyleGetMarginJNI},
|
||||
@@ -917,6 +948,15 @@ static JNINativeMethod methods[] = {
|
||||
{"jni_YGNodeStyleSetWidthAutoJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetWidthAutoJNI},
|
||||
{"jni_YGNodeStyleSetWidthMaxContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetWidthMaxContentJNI},
|
||||
{"jni_YGNodeStyleSetWidthFitContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetWidthFitContentJNI},
|
||||
{"jni_YGNodeStyleSetWidthStretchJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetWidthStretchJNI},
|
||||
{"jni_YGNodeStyleGetHeightJNI", "(J)J", (void*)jni_YGNodeStyleGetHeightJNI},
|
||||
{"jni_YGNodeStyleSetHeightJNI",
|
||||
"(JF)V",
|
||||
@@ -927,6 +967,15 @@ static JNINativeMethod methods[] = {
|
||||
{"jni_YGNodeStyleSetHeightAutoJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetHeightAutoJNI},
|
||||
{"jni_YGNodeStyleSetHeightMaxContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetHeightMaxContentJNI},
|
||||
{"jni_YGNodeStyleSetHeightFitContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetHeightFitContentJNI},
|
||||
{"jni_YGNodeStyleSetHeightStretchJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetHeightStretchJNI},
|
||||
{"jni_YGNodeStyleGetMinWidthJNI",
|
||||
"(J)J",
|
||||
(void*)jni_YGNodeStyleGetMinWidthJNI},
|
||||
@@ -936,6 +985,15 @@ static JNINativeMethod methods[] = {
|
||||
{"jni_YGNodeStyleSetMinWidthPercentJNI",
|
||||
"(JF)V",
|
||||
(void*)jni_YGNodeStyleSetMinWidthPercentJNI},
|
||||
{"jni_YGNodeStyleSetMinWidthMaxContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetMinWidthMaxContentJNI},
|
||||
{"jni_YGNodeStyleSetMinWidthFitContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetMinWidthFitContentJNI},
|
||||
{"jni_YGNodeStyleSetMinWidthStretchJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetMinWidthStretchJNI},
|
||||
{"jni_YGNodeStyleGetMinHeightJNI",
|
||||
"(J)J",
|
||||
(void*)jni_YGNodeStyleGetMinHeightJNI},
|
||||
@@ -945,6 +1003,15 @@ static JNINativeMethod methods[] = {
|
||||
{"jni_YGNodeStyleSetMinHeightPercentJNI",
|
||||
"(JF)V",
|
||||
(void*)jni_YGNodeStyleSetMinHeightPercentJNI},
|
||||
{"jni_YGNodeStyleSetMinHeightMaxContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetMinHeightMaxContentJNI},
|
||||
{"jni_YGNodeStyleSetMinHeightFitContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetMinHeightFitContentJNI},
|
||||
{"jni_YGNodeStyleSetMinHeightStretchJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetMinHeightStretchJNI},
|
||||
{"jni_YGNodeStyleGetMaxWidthJNI",
|
||||
"(J)J",
|
||||
(void*)jni_YGNodeStyleGetMaxWidthJNI},
|
||||
@@ -954,6 +1021,15 @@ static JNINativeMethod methods[] = {
|
||||
{"jni_YGNodeStyleSetMaxWidthPercentJNI",
|
||||
"(JF)V",
|
||||
(void*)jni_YGNodeStyleSetMaxWidthPercentJNI},
|
||||
{"jni_YGNodeStyleSetMaxWidthMaxContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetMaxWidthMaxContentJNI},
|
||||
{"jni_YGNodeStyleSetMaxWidthFitContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetMaxWidthFitContentJNI},
|
||||
{"jni_YGNodeStyleSetMaxWidthStretchJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetMaxWidthStretchJNI},
|
||||
{"jni_YGNodeStyleGetMaxHeightJNI",
|
||||
"(J)J",
|
||||
(void*)jni_YGNodeStyleGetMaxHeightJNI},
|
||||
@@ -963,6 +1039,15 @@ static JNINativeMethod methods[] = {
|
||||
{"jni_YGNodeStyleSetMaxHeightPercentJNI",
|
||||
"(JF)V",
|
||||
(void*)jni_YGNodeStyleSetMaxHeightPercentJNI},
|
||||
{"jni_YGNodeStyleSetMaxHeightMaxContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetMaxHeightMaxContentJNI},
|
||||
{"jni_YGNodeStyleSetMaxHeightFitContentJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetMaxHeightFitContentJNI},
|
||||
{"jni_YGNodeStyleSetMaxHeightStretchJNI",
|
||||
"(J)V",
|
||||
(void*)jni_YGNodeStyleSetMaxHeightStretchJNI},
|
||||
{"jni_YGNodeStyleGetAspectRatioJNI",
|
||||
"(J)F",
|
||||
(void*)jni_YGNodeStyleGetAspectRatioJNI},
|
||||
|
||||
+5
-4
@@ -495,7 +495,8 @@ void FabricMountingManager::executeMount(
|
||||
? allocatedViewsIterator->second
|
||||
: defaultAllocatedViews;
|
||||
if (allocatedViewsIterator == allocatedViewRegistry_.end()) {
|
||||
LOG(ERROR) << "Executing commit after surface was stopped!";
|
||||
LOG(ERROR) << "Executing commit after surface " << surfaceId
|
||||
<< " was stopped!";
|
||||
}
|
||||
|
||||
for (const auto& mutation : mutations) {
|
||||
@@ -529,7 +530,7 @@ void FabricMountingManager::executeMount(
|
||||
(maintainMutationOrder ? cppCommonMountItems : cppDeleteMountItems)
|
||||
.push_back(CppMountItem::DeleteMountItem(oldChildShadowView));
|
||||
if (allocatedViewTags.erase(oldChildShadowView.tag) != 1) {
|
||||
LOG(ERROR) << "Emitting delete for unallocated view. "
|
||||
LOG(ERROR) << "Emitting delete for unallocated view "
|
||||
<< oldChildShadowView.tag;
|
||||
}
|
||||
break;
|
||||
@@ -537,7 +538,7 @@ void FabricMountingManager::executeMount(
|
||||
case ShadowViewMutation::Update: {
|
||||
if (!isVirtual) {
|
||||
if (!allocatedViewTags.contains(newChildShadowView.tag)) {
|
||||
LOG(FATAL) << "Emitting update for unallocated view. "
|
||||
LOG(ERROR) << "Emitting update for unallocated view "
|
||||
<< newChildShadowView.tag;
|
||||
}
|
||||
|
||||
@@ -605,7 +606,7 @@ void FabricMountingManager::executeMount(
|
||||
bool shouldCreateView =
|
||||
!allocatedViewTags.contains(newChildShadowView.tag);
|
||||
if (shouldCreateView) {
|
||||
LOG(ERROR) << "Emitting insert for unallocated view. "
|
||||
LOG(ERROR) << "Emitting insert for unallocated view "
|
||||
<< newChildShadowView.tag;
|
||||
(maintainMutationOrder ? cppCommonMountItems
|
||||
: cppUpdatePropsMountItems)
|
||||
|
||||
+16
-25
@@ -157,6 +157,11 @@ void FabricUIManagerBinding::startSurfaceWithSurfaceHandler(
|
||||
}
|
||||
scheduler->registerSurface(surfaceHandler);
|
||||
|
||||
auto mountingManager = getMountingManager("startSurfaceWithSurfaceHandler");
|
||||
if (mountingManager != nullptr) {
|
||||
mountingManager->onSurfaceStart(surfaceId);
|
||||
}
|
||||
|
||||
surfaceHandler.start();
|
||||
|
||||
if (ReactNativeFeatureFlags::enableLayoutAnimationsOnAndroid()) {
|
||||
@@ -167,14 +172,8 @@ void FabricUIManagerBinding::startSurfaceWithSurfaceHandler(
|
||||
{
|
||||
std::unique_lock lock(surfaceHandlerRegistryMutex_);
|
||||
surfaceHandlerRegistry_.emplace(
|
||||
surfaceHandler.getSurfaceId(), jni::make_weak(surfaceHandlerBinding));
|
||||
surfaceId, jni::make_weak(surfaceHandlerBinding));
|
||||
}
|
||||
|
||||
auto mountingManager = getMountingManager("startSurfaceWithSurfaceHandler");
|
||||
if (!mountingManager) {
|
||||
return;
|
||||
}
|
||||
mountingManager->onSurfaceStart(surfaceHandler.getSurfaceId());
|
||||
}
|
||||
|
||||
// Used by non-bridgeless+Fabric
|
||||
@@ -206,6 +205,11 @@ void FabricUIManagerBinding::startSurface(
|
||||
|
||||
scheduler->registerSurface(surfaceHandler);
|
||||
|
||||
auto mountingManager = getMountingManager("startSurface");
|
||||
if (mountingManager != nullptr) {
|
||||
mountingManager->onSurfaceStart(surfaceId);
|
||||
}
|
||||
|
||||
surfaceHandler.start();
|
||||
|
||||
if (ReactNativeFeatureFlags::enableLayoutAnimationsOnAndroid()) {
|
||||
@@ -214,17 +218,9 @@ void FabricUIManagerBinding::startSurface(
|
||||
}
|
||||
|
||||
{
|
||||
SystraceSection s2("FabricUIManagerBinding::startSurface::surfaceId::lock");
|
||||
std::unique_lock lock(surfaceHandlerRegistryMutex_);
|
||||
SystraceSection s3("FabricUIManagerBinding::startSurface::surfaceId");
|
||||
surfaceHandlerRegistry_.emplace(surfaceId, std::move(surfaceHandler));
|
||||
}
|
||||
|
||||
auto mountingManager = getMountingManager("startSurface");
|
||||
if (!mountingManager) {
|
||||
return;
|
||||
}
|
||||
mountingManager->onSurfaceStart(surfaceId);
|
||||
}
|
||||
|
||||
// Used by non-bridgeless+Fabric
|
||||
@@ -278,6 +274,11 @@ void FabricUIManagerBinding::startSurfaceWithConstraints(
|
||||
|
||||
scheduler->registerSurface(surfaceHandler);
|
||||
|
||||
auto mountingManager = getMountingManager("startSurfaceWithConstraints");
|
||||
if (mountingManager != nullptr) {
|
||||
mountingManager->onSurfaceStart(surfaceId);
|
||||
}
|
||||
|
||||
surfaceHandler.start();
|
||||
|
||||
if (ReactNativeFeatureFlags::enableLayoutAnimationsOnAndroid()) {
|
||||
@@ -286,19 +287,9 @@ void FabricUIManagerBinding::startSurfaceWithConstraints(
|
||||
}
|
||||
|
||||
{
|
||||
SystraceSection s2(
|
||||
"FabricUIManagerBinding::startSurfaceWithConstraints::surfaceId::lock");
|
||||
std::unique_lock lock(surfaceHandlerRegistryMutex_);
|
||||
SystraceSection s3(
|
||||
"FabricUIManagerBinding::startSurfaceWithConstraints::surfaceId");
|
||||
surfaceHandlerRegistry_.emplace(surfaceId, std::move(surfaceHandler));
|
||||
}
|
||||
|
||||
auto mountingManager = getMountingManager("startSurfaceWithConstraints");
|
||||
if (!mountingManager) {
|
||||
return;
|
||||
}
|
||||
mountingManager->onSurfaceStart(surfaceId);
|
||||
}
|
||||
|
||||
// Used by non-bridgeless+Fabric
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.junit.Test
|
||||
@OptIn(UnstableReactNativeAPI::class)
|
||||
class InteropModuleRegistryTest {
|
||||
|
||||
lateinit var underTest: InteropModuleRegistry
|
||||
private lateinit var underTest: InteropModuleRegistry
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
|
||||
@@ -225,6 +225,13 @@ class RuntimeDecorator : public Base, private jsi::Instrumentation {
|
||||
return plain_.utf8(s);
|
||||
}
|
||||
|
||||
std::u16string utf16(const String& str) override {
|
||||
return plain_.utf16(str);
|
||||
}
|
||||
std::u16string utf16(const PropNameID& sym) override {
|
||||
return plain_.utf16(sym);
|
||||
}
|
||||
|
||||
Object createObject() override {
|
||||
return plain_.createObject();
|
||||
};
|
||||
@@ -674,6 +681,15 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
|
||||
return RD::utf8(s);
|
||||
}
|
||||
|
||||
std::u16string utf16(const String& str) override {
|
||||
Around around{with_};
|
||||
return RD::utf16(str);
|
||||
}
|
||||
std::u16string utf16(const PropNameID& sym) override {
|
||||
Around around{with_};
|
||||
return RD::utf16(sym);
|
||||
}
|
||||
|
||||
Value createValueFromJsonUtf8(const uint8_t* json, size_t length) override {
|
||||
Around around{with_};
|
||||
return RD::createValueFromJsonUtf8(json, length);
|
||||
|
||||
@@ -62,6 +62,107 @@ Value callGlobalFunction(Runtime& runtime, const char* name, const Value& arg) {
|
||||
return f.call(runtime, arg);
|
||||
}
|
||||
|
||||
// Given a sequence of UTF8 encoded bytes, advance the input to past where a
|
||||
// 32-bit unicode codepoint as been decoded and return the codepoint. If the
|
||||
// UTF8 encoding is invalid, then return the value with the unicode replacement
|
||||
// character (U+FFFD). This decoder also relies on zero termination at end of
|
||||
// the input for bound checks.
|
||||
// \param input char pointer pointing to the current character
|
||||
// \return Unicode codepoint
|
||||
uint32_t decodeUTF8(const char*& input) {
|
||||
uint32_t ch = (unsigned char)input[0];
|
||||
if (ch <= 0x7f) {
|
||||
input += 1;
|
||||
return ch;
|
||||
}
|
||||
uint32_t ret;
|
||||
constexpr uint32_t replacementCharacter = 0xFFFD;
|
||||
if ((ch & 0xE0) == 0xC0) {
|
||||
uint32_t ch1 = (unsigned char)input[1];
|
||||
if ((ch1 & 0xC0) != 0x80) {
|
||||
input += 1;
|
||||
return replacementCharacter;
|
||||
}
|
||||
ret = ((ch & 0x1F) << 6) | (ch1 & 0x3F);
|
||||
input += 2;
|
||||
if (ret <= 0x7F) {
|
||||
return replacementCharacter;
|
||||
}
|
||||
} else if ((ch & 0xF0) == 0xE0) {
|
||||
uint32_t ch1 = (unsigned char)input[1];
|
||||
if ((ch1 & 0x40) != 0 || (ch1 & 0x80) == 0) {
|
||||
input += 1;
|
||||
return replacementCharacter;
|
||||
}
|
||||
uint32_t ch2 = (unsigned char)input[2];
|
||||
if ((ch2 & 0x40) != 0 || (ch2 & 0x80) == 0) {
|
||||
input += 2;
|
||||
return replacementCharacter;
|
||||
}
|
||||
ret = ((ch & 0x0F) << 12) | ((ch1 & 0x3F) << 6) | (ch2 & 0x3F);
|
||||
input += 3;
|
||||
if (ret <= 0x7FF) {
|
||||
return replacementCharacter;
|
||||
}
|
||||
} else if ((ch & 0xF8) == 0xF0) {
|
||||
uint32_t ch1 = (unsigned char)input[1];
|
||||
if ((ch1 & 0x40) != 0 || (ch1 & 0x80) == 0) {
|
||||
input += 1;
|
||||
return replacementCharacter;
|
||||
}
|
||||
uint32_t ch2 = (unsigned char)input[2];
|
||||
if ((ch2 & 0x40) != 0 || (ch2 & 0x80) == 0) {
|
||||
input += 2;
|
||||
return replacementCharacter;
|
||||
}
|
||||
uint32_t ch3 = (unsigned char)input[3];
|
||||
if ((ch3 & 0x40) != 0 || (ch3 & 0x80) == 0) {
|
||||
input += 3;
|
||||
return replacementCharacter;
|
||||
}
|
||||
ret = ((ch & 0x07) << 18) | ((ch1 & 0x3F) << 12) | ((ch2 & 0x3F) << 6) |
|
||||
(ch3 & 0x3F);
|
||||
input += 4;
|
||||
if (ret <= 0xFFFF) {
|
||||
return replacementCharacter;
|
||||
}
|
||||
if (ret > 0x10FFFF) {
|
||||
return replacementCharacter;
|
||||
}
|
||||
} else {
|
||||
input += 1;
|
||||
return replacementCharacter;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Given a valid 32-bit unicode codepoint, encode it as UTF-16 into the output.
|
||||
void encodeUTF16(std::u16string& out, uint32_t cp) {
|
||||
if (cp < 0x10000) {
|
||||
out.push_back((uint16_t)cp);
|
||||
return;
|
||||
}
|
||||
cp -= 0x10000;
|
||||
uint16_t highSurrogate = 0xD800 + ((cp >> 10) & 0x3FF);
|
||||
out.push_back(highSurrogate);
|
||||
uint16_t lowSurrogate = 0xDC00 + (cp & 0x3FF);
|
||||
out.push_back(lowSurrogate);
|
||||
}
|
||||
|
||||
// Convert the UTF8 encoded string into a UTF16 encoded string. If the
|
||||
// input is not valid UTF8, the replacement character (U+FFFD) is used to
|
||||
// represent the invalid sequence.
|
||||
std::u16string convertUTF8ToUTF16(const std::string& utf8) {
|
||||
std::u16string ret;
|
||||
const char* curr = utf8.data();
|
||||
const char* end = curr + utf8.length();
|
||||
while (curr < end) {
|
||||
auto cp = decodeUTF8(curr);
|
||||
encodeUTF16(ret, cp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Buffer::~Buffer() = default;
|
||||
@@ -147,6 +248,16 @@ Value Runtime::createValueFromJsonUtf8(const uint8_t* json, size_t length) {
|
||||
return parseJson.call(*this, String::createFromUtf8(*this, json, length));
|
||||
}
|
||||
|
||||
std::u16string Runtime::utf16(const PropNameID& sym) {
|
||||
auto utf8Str = utf8(sym);
|
||||
return convertUTF8ToUTF16(utf8Str);
|
||||
}
|
||||
|
||||
std::u16string Runtime::utf16(const String& str) {
|
||||
auto utf8Str = utf8(str);
|
||||
return convertUTF8ToUTF16(utf8Str);
|
||||
}
|
||||
|
||||
Pointer& Pointer::operator=(Pointer&& other) {
|
||||
if (ptr_) {
|
||||
ptr_->invalidate();
|
||||
|
||||
@@ -399,6 +399,9 @@ class JSI_EXPORT Runtime {
|
||||
const jsi::Object& obj,
|
||||
size_t amount) = 0;
|
||||
|
||||
virtual std::u16string utf16(const String& str);
|
||||
virtual std::u16string utf16(const PropNameID& sym);
|
||||
|
||||
// These exist so derived classes can access the private parts of
|
||||
// Value, Symbol, String, and Object, which are all friends of Runtime.
|
||||
template <typename T>
|
||||
@@ -501,6 +504,11 @@ class JSI_EXPORT PropNameID : public Pointer {
|
||||
return runtime.utf8(*this);
|
||||
}
|
||||
|
||||
/// Copies the data in a PropNameID as utf16 into a C++ string.
|
||||
std::u16string utf16(Runtime& runtime) const {
|
||||
return runtime.utf16(*this);
|
||||
}
|
||||
|
||||
static bool compare(
|
||||
Runtime& runtime,
|
||||
const jsi::PropNameID& a,
|
||||
@@ -651,6 +659,11 @@ class JSI_EXPORT String : public Pointer {
|
||||
return runtime.utf8(*this);
|
||||
}
|
||||
|
||||
/// Copies the data in a JS string as utf16 into a C++ string.
|
||||
std::u16string utf16(Runtime& runtime) const {
|
||||
return runtime.utf16(*this);
|
||||
}
|
||||
|
||||
friend class Runtime;
|
||||
friend class Value;
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user