mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Compare commits
21
Commits
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
+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 =
|
||||
"""
|
||||
|
||||
+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,
|
||||
|
||||
+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) {
|
||||
|
||||
@@ -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];
|
||||
|
||||
+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
@@ -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],
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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
|
||||
@@ -3616,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;
|
||||
@@ -8183,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
|
||||
|
||||
@@ -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,\
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ package com.facebook.debug.debugoverlay.model
|
||||
* @param description Description to display in settings.
|
||||
* @param color Color for tag display.
|
||||
*/
|
||||
public class DebugOverlayTag(
|
||||
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
|
||||
}
|
||||
|
||||
+10
-10
@@ -11,35 +11,35 @@ import android.graphics.Color
|
||||
import com.facebook.debug.debugoverlay.model.DebugOverlayTag
|
||||
|
||||
/** Category for debug overlays. */
|
||||
public object ReactDebugOverlayTags {
|
||||
internal object ReactDebugOverlayTags {
|
||||
@JvmField
|
||||
public val PERFORMANCE: DebugOverlayTag =
|
||||
val PERFORMANCE: DebugOverlayTag =
|
||||
DebugOverlayTag("Performance", "Markers for Performance", Color.GREEN)
|
||||
@JvmField
|
||||
public val NAVIGATION: DebugOverlayTag =
|
||||
val NAVIGATION: DebugOverlayTag =
|
||||
DebugOverlayTag("Navigation", "Tag for navigation", Color.rgb(0x9C, 0x27, 0xB0))
|
||||
@JvmField
|
||||
public val RN_CORE: DebugOverlayTag =
|
||||
val RN_CORE: DebugOverlayTag =
|
||||
DebugOverlayTag("RN Core", "Tag for React Native Core", Color.BLACK)
|
||||
@JvmField
|
||||
public val BRIDGE_CALLS: DebugOverlayTag =
|
||||
val BRIDGE_CALLS: DebugOverlayTag =
|
||||
DebugOverlayTag("Bridge Calls", "JS to Java calls (warning: this is spammy)", Color.MAGENTA)
|
||||
@JvmField
|
||||
public val NATIVE_MODULE: DebugOverlayTag =
|
||||
val NATIVE_MODULE: DebugOverlayTag =
|
||||
DebugOverlayTag("Native Module", "Native Module init", Color.rgb(0x80, 0x00, 0x80))
|
||||
@JvmField
|
||||
public val UI_MANAGER: DebugOverlayTag =
|
||||
val UI_MANAGER: DebugOverlayTag =
|
||||
DebugOverlayTag(
|
||||
"UI Manager",
|
||||
"UI Manager View Operations (requires restart\nwarning: this is spammy)",
|
||||
Color.CYAN)
|
||||
@JvmField
|
||||
public val FABRIC_UI_MANAGER: DebugOverlayTag =
|
||||
val FABRIC_UI_MANAGER: DebugOverlayTag =
|
||||
DebugOverlayTag("FabricUIManager", "Fabric UI Manager View Operations", Color.CYAN)
|
||||
@JvmField
|
||||
public val FABRIC_RECONCILER: DebugOverlayTag =
|
||||
val FABRIC_RECONCILER: DebugOverlayTag =
|
||||
DebugOverlayTag("FabricReconciler", "Reconciler for Fabric", Color.CYAN)
|
||||
@JvmField
|
||||
public val RELAY: DebugOverlayTag =
|
||||
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();
|
||||
|
||||
+19
-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,7 +590,7 @@ 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);
|
||||
@@ -664,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) {
|
||||
@@ -679,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) {
|
||||
@@ -705,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() {
|
||||
@@ -783,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;
|
||||
}
|
||||
@@ -864,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(
|
||||
@@ -1160,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) {
|
||||
|
||||
+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"
|
||||
}
|
||||
|
||||
+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},
|
||||
|
||||
+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() {
|
||||
|
||||
+8
-6
@@ -538,9 +538,9 @@ void YogaLayoutableShadowNode::setSize(Size size) const {
|
||||
|
||||
auto style = yogaNode_.style();
|
||||
style.setDimension(
|
||||
yoga::Dimension::Width, yoga::StyleLength::points(size.width));
|
||||
yoga::Dimension::Width, yoga::StyleSizeLength::points(size.width));
|
||||
style.setDimension(
|
||||
yoga::Dimension::Height, yoga::StyleLength::points(size.height));
|
||||
yoga::Dimension::Height, yoga::StyleSizeLength::points(size.height));
|
||||
yogaNode_.setStyle(style);
|
||||
yogaNode_.setDirty(true);
|
||||
}
|
||||
@@ -631,16 +631,18 @@ void YogaLayoutableShadowNode::layoutTree(
|
||||
auto ownerHeight = yogaFloatFromFloat(maximumSize.height);
|
||||
|
||||
yogaStyle.setMaxDimension(
|
||||
yoga::Dimension::Width, yoga::StyleLength::points(maximumSize.width));
|
||||
yoga::Dimension::Width, yoga::StyleSizeLength::points(maximumSize.width));
|
||||
|
||||
yogaStyle.setMaxDimension(
|
||||
yoga::Dimension::Height, yoga::StyleLength::points(maximumSize.height));
|
||||
yoga::Dimension::Height,
|
||||
yoga::StyleSizeLength::points(maximumSize.height));
|
||||
|
||||
yogaStyle.setMinDimension(
|
||||
yoga::Dimension::Width, yoga::StyleLength::points(minimumSize.width));
|
||||
yoga::Dimension::Width, yoga::StyleSizeLength::points(minimumSize.width));
|
||||
|
||||
yogaStyle.setMinDimension(
|
||||
yoga::Dimension::Height, yoga::StyleLength::points(minimumSize.height));
|
||||
yoga::Dimension::Height,
|
||||
yoga::StyleSizeLength::points(minimumSize.height));
|
||||
|
||||
auto direction =
|
||||
yogaDirectionFromLayoutDirection(layoutConstraints.layoutDirection);
|
||||
|
||||
@@ -92,18 +92,15 @@ inline yoga::FloatOptional yogaOptionalFloatFromFloat(Float value) {
|
||||
inline std::optional<Float> optionalFloatFromYogaValue(
|
||||
const yoga::Style::Length& length,
|
||||
std::optional<Float> base = {}) {
|
||||
switch (length.unit()) {
|
||||
case yoga::Unit::Undefined:
|
||||
return {};
|
||||
case yoga::Unit::Point:
|
||||
return floatFromYogaOptionalFloat(length.value());
|
||||
case yoga::Unit::Percent:
|
||||
return base.has_value()
|
||||
? std::optional<Float>(
|
||||
base.value() * floatFromYogaOptionalFloat(length.value()))
|
||||
: std::optional<Float>();
|
||||
case yoga::Unit::Auto:
|
||||
return {};
|
||||
if (length.isPoints()) {
|
||||
return floatFromYogaOptionalFloat(length.value());
|
||||
} else if (length.isPercent()) {
|
||||
return base.has_value()
|
||||
? std::optional<Float>(
|
||||
base.value() * floatFromYogaOptionalFloat(length.value()))
|
||||
: std::optional<Float>();
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,6 +443,47 @@ inline void fromRawValue(
|
||||
LOG(ERROR) << "Could not parse yoga::Display: " << stringValue;
|
||||
}
|
||||
|
||||
inline void fromRawValue(
|
||||
const PropsParserContext& /*context*/,
|
||||
const RawValue& value,
|
||||
yoga::Style::SizeLength& result) {
|
||||
if (value.hasType<Float>()) {
|
||||
result = yoga::StyleSizeLength::points((float)value);
|
||||
return;
|
||||
} else if (value.hasType<std::string>()) {
|
||||
const auto stringValue = (std::string)value;
|
||||
if (stringValue == "auto") {
|
||||
result = yoga::StyleSizeLength::ofAuto();
|
||||
return;
|
||||
} else if (stringValue == "max-content") {
|
||||
result = yoga::StyleSizeLength::ofMaxContent();
|
||||
return;
|
||||
} else if (stringValue == "stretch") {
|
||||
result = yoga::StyleSizeLength::ofStretch();
|
||||
return;
|
||||
} else if (stringValue == "fit-content") {
|
||||
result = yoga::StyleSizeLength::ofFitContent();
|
||||
return;
|
||||
} else {
|
||||
if (stringValue.back() == '%') {
|
||||
auto tryValue = folly::tryTo<float>(
|
||||
std::string_view(stringValue).substr(0, stringValue.length() - 1));
|
||||
if (tryValue.hasValue()) {
|
||||
result = yoga::StyleSizeLength::percent(tryValue.value());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
auto tryValue = folly::tryTo<float>(stringValue);
|
||||
if (tryValue.hasValue()) {
|
||||
result = yoga::StyleSizeLength::points(tryValue.value());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result = yoga::StyleSizeLength::undefined();
|
||||
}
|
||||
|
||||
inline void fromRawValue(
|
||||
const PropsParserContext& context,
|
||||
const RawValue& value,
|
||||
@@ -1370,15 +1408,36 @@ inline std::string toString(const yoga::Display& value) {
|
||||
}
|
||||
|
||||
inline std::string toString(const yoga::Style::Length& length) {
|
||||
switch (length.unit()) {
|
||||
case yoga::Unit::Undefined:
|
||||
return "undefined";
|
||||
case yoga::Unit::Point:
|
||||
return std::to_string(length.value().unwrap());
|
||||
case yoga::Unit::Percent:
|
||||
return std::to_string(length.value().unwrap()) + "%";
|
||||
case yoga::Unit::Auto:
|
||||
return "auto";
|
||||
if (length.isUndefined()) {
|
||||
return "undefined";
|
||||
} else if (length.isAuto()) {
|
||||
return "auto";
|
||||
} else if (length.isPoints()) {
|
||||
return std::to_string(length.value().unwrap());
|
||||
} else if (length.isPercent()) {
|
||||
return std::to_string(length.value().unwrap()) + "%";
|
||||
} else {
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string toString(const yoga::Style::SizeLength& length) {
|
||||
if (length.isUndefined()) {
|
||||
return "undefined";
|
||||
} else if (length.isAuto()) {
|
||||
return "auto";
|
||||
} else if (length.isPoints()) {
|
||||
return std::to_string(length.value().unwrap());
|
||||
} else if (length.isPercent()) {
|
||||
return std::to_string(length.value().unwrap()) + "%";
|
||||
} else if (length.isMaxContent()) {
|
||||
return "max-content";
|
||||
} else if (length.isFitContent()) {
|
||||
return "fit-content";
|
||||
} else if (length.isStretch()) {
|
||||
return "stretch";
|
||||
} else {
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -77,8 +77,8 @@ class LayoutTest : public ::testing::Test {
|
||||
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({
|
||||
@@ -90,8 +90,8 @@ class LayoutTest : public ::testing::Test {
|
||||
auto &props = *sharedProps;
|
||||
auto &yogaStyle = props.yogaStyle;
|
||||
yogaStyle.setPositionType(yoga::PositionType::Absolute);
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(50));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(50));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(50));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(50));
|
||||
return sharedProps;
|
||||
})
|
||||
.children({
|
||||
@@ -105,8 +105,8 @@ class LayoutTest : public ::testing::Test {
|
||||
yogaStyle.setPositionType(yoga::PositionType::Absolute);
|
||||
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(10));
|
||||
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(10));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(30));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(90));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(30));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(90));
|
||||
|
||||
if (testCase == TRANSFORM_SCALE) {
|
||||
props.transform = props.transform * Transform::Scale(2, 2, 1);
|
||||
@@ -138,8 +138,8 @@ class LayoutTest : public ::testing::Test {
|
||||
yogaStyle.setPositionType(yoga::PositionType::Absolute);
|
||||
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(10));
|
||||
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(10));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(110));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(20));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(110));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(20));
|
||||
return sharedProps;
|
||||
})
|
||||
.children({
|
||||
@@ -153,8 +153,8 @@ class LayoutTest : public ::testing::Test {
|
||||
yogaStyle.setPositionType(yoga::PositionType::Absolute);
|
||||
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(70));
|
||||
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(-50));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(30));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(60));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(30));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(60));
|
||||
return sharedProps;
|
||||
})
|
||||
}),
|
||||
@@ -168,8 +168,8 @@ class LayoutTest : public ::testing::Test {
|
||||
yogaStyle.setPositionType(yoga::PositionType::Absolute);
|
||||
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(-60));
|
||||
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(50));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(70));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(20));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(70));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(20));
|
||||
return sharedProps;
|
||||
})
|
||||
})
|
||||
|
||||
+10
-10
@@ -87,8 +87,8 @@ class PointerEventsProcessorTest : public ::testing::Test {
|
||||
listenToAllPointerEvents(props);
|
||||
props.layoutConstraints = LayoutConstraints{{0,0}, {500, 500}};
|
||||
auto &yogaStyle = props.yogaStyle;
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(400));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(400));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(400));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(400));
|
||||
yogaStyle.setDisplay(yoga::Display::Flex);
|
||||
yogaStyle.setFlexDirection(yoga::FlexDirection::Row);
|
||||
yogaStyle.setAlignItems(yoga::Align::Center);
|
||||
@@ -109,8 +109,8 @@ class PointerEventsProcessorTest : public ::testing::Test {
|
||||
yogaStyle.setFlexDirection(yoga::FlexDirection::Column);
|
||||
yogaStyle.setAlignItems(yoga::Align::FlexEnd);
|
||||
yogaStyle.setJustifyContent(yoga::Justify::Center);
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(150));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(300));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(150));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(300));
|
||||
return sharedProps;
|
||||
})
|
||||
.children({
|
||||
@@ -123,8 +123,8 @@ class PointerEventsProcessorTest : public ::testing::Test {
|
||||
auto &props = *sharedProps;
|
||||
listenToAllPointerEvents(props);
|
||||
auto &yogaStyle = props.yogaStyle;
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(100));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(100));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(200));
|
||||
return sharedProps;
|
||||
})
|
||||
}),
|
||||
@@ -141,8 +141,8 @@ class PointerEventsProcessorTest : public ::testing::Test {
|
||||
yogaStyle.setFlexDirection(yoga::FlexDirection::Column);
|
||||
yogaStyle.setAlignItems(yoga::Align::FlexStart);
|
||||
yogaStyle.setJustifyContent(yoga::Justify::Center);
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(150));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(300));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(150));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(300));
|
||||
return sharedProps;
|
||||
})
|
||||
.children({
|
||||
@@ -155,8 +155,8 @@ class PointerEventsProcessorTest : public ::testing::Test {
|
||||
auto &props = *sharedProps;
|
||||
listenToAllPointerEvents(props);
|
||||
auto &yogaStyle = props.yogaStyle;
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(100));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200));
|
||||
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(100));
|
||||
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(200));
|
||||
return sharedProps;
|
||||
})
|
||||
})
|
||||
|
||||
@@ -245,6 +245,12 @@ const char* YGUnitToString(const YGUnit value) {
|
||||
return "percent";
|
||||
case YGUnitAuto:
|
||||
return "auto";
|
||||
case YGUnitMaxContent:
|
||||
return "max-content";
|
||||
case YGUnitFitContent:
|
||||
return "fit-content";
|
||||
case YGUnitStretch:
|
||||
return "stretch";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
@@ -131,7 +131,10 @@ YG_ENUM_DECL(
|
||||
YGUnitUndefined,
|
||||
YGUnitPoint,
|
||||
YGUnitPercent,
|
||||
YGUnitAuto)
|
||||
YGUnitAuto,
|
||||
YGUnitMaxContent,
|
||||
YGUnitFitContent,
|
||||
YGUnitStretch)
|
||||
|
||||
YG_ENUM_DECL(
|
||||
YGWrap,
|
||||
|
||||
@@ -177,19 +177,34 @@ float YGNodeStyleGetFlexShrink(const YGNodeConstRef nodeRef) {
|
||||
|
||||
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
|
||||
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||
node, StyleLength::points(flexBasis));
|
||||
node, StyleSizeLength::points(flexBasis));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetFlexBasisPercent(
|
||||
const YGNodeRef node,
|
||||
const float flexBasisPercent) {
|
||||
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||
node, StyleLength::percent(flexBasisPercent));
|
||||
node, StyleSizeLength::percent(flexBasisPercent));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
|
||||
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||
node, StyleLength::ofAuto());
|
||||
node, StyleSizeLength::ofAuto());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetFlexBasisMaxContent(const YGNodeRef node) {
|
||||
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||
node, StyleSizeLength::ofMaxContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetFlexBasisFitContent(const YGNodeRef node) {
|
||||
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||
node, StyleSizeLength::ofFitContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetFlexBasisStretch(const YGNodeRef node) {
|
||||
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||
node, StyleSizeLength::ofStretch());
|
||||
}
|
||||
|
||||
YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
|
||||
@@ -308,17 +323,32 @@ YGBoxSizing YGNodeStyleGetBoxSizing(const YGNodeConstRef node) {
|
||||
|
||||
void YGNodeStyleSetWidth(YGNodeRef node, float points) {
|
||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||
node, Dimension::Width, StyleLength::points(points));
|
||||
node, Dimension::Width, StyleSizeLength::points(points));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
|
||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||
node, Dimension::Width, StyleLength::percent(percent));
|
||||
node, Dimension::Width, StyleSizeLength::percent(percent));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetWidthAuto(YGNodeRef node) {
|
||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||
node, Dimension::Width, StyleLength::ofAuto());
|
||||
node, Dimension::Width, StyleSizeLength::ofAuto());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetWidthMaxContent(YGNodeRef node) {
|
||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||
node, Dimension::Width, StyleSizeLength::ofMaxContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetWidthFitContent(YGNodeRef node) {
|
||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||
node, Dimension::Width, StyleSizeLength::ofFitContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetWidthStretch(YGNodeRef node) {
|
||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||
node, Dimension::Width, StyleSizeLength::ofStretch());
|
||||
}
|
||||
|
||||
YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
|
||||
@@ -327,17 +357,32 @@ YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
|
||||
|
||||
void YGNodeStyleSetHeight(YGNodeRef node, float points) {
|
||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||
node, Dimension::Height, StyleLength::points(points));
|
||||
node, Dimension::Height, StyleSizeLength::points(points));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
|
||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||
node, Dimension::Height, StyleLength::percent(percent));
|
||||
node, Dimension::Height, StyleSizeLength::percent(percent));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetHeightAuto(YGNodeRef node) {
|
||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||
node, Dimension::Height, StyleLength::ofAuto());
|
||||
node, Dimension::Height, StyleSizeLength::ofAuto());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetHeightMaxContent(YGNodeRef node) {
|
||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||
node, Dimension::Height, StyleSizeLength::ofMaxContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetHeightFitContent(YGNodeRef node) {
|
||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||
node, Dimension::Height, StyleSizeLength::ofFitContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetHeightStretch(YGNodeRef node) {
|
||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||
node, Dimension::Height, StyleSizeLength::ofStretch());
|
||||
}
|
||||
|
||||
YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
||||
@@ -346,12 +391,27 @@ YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
||||
|
||||
void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) {
|
||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||
node, Dimension::Width, StyleLength::points(minWidth));
|
||||
node, Dimension::Width, StyleSizeLength::points(minWidth));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) {
|
||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||
node, Dimension::Width, StyleLength::percent(minWidth));
|
||||
node, Dimension::Width, StyleSizeLength::percent(minWidth));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMinWidthMaxContent(const YGNodeRef node) {
|
||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||
node, Dimension::Width, StyleSizeLength::ofMaxContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMinWidthFitContent(const YGNodeRef node) {
|
||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||
node, Dimension::Width, StyleSizeLength::ofFitContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMinWidthStretch(const YGNodeRef node) {
|
||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||
node, Dimension::Width, StyleSizeLength::ofStretch());
|
||||
}
|
||||
|
||||
YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
||||
@@ -360,14 +420,29 @@ YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
||||
|
||||
void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) {
|
||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||
node, Dimension::Height, StyleLength::points(minHeight));
|
||||
node, Dimension::Height, StyleSizeLength::points(minHeight));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMinHeightPercent(
|
||||
const YGNodeRef node,
|
||||
const float minHeight) {
|
||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||
node, Dimension::Height, StyleLength::percent(minHeight));
|
||||
node, Dimension::Height, StyleSizeLength::percent(minHeight));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMinHeightMaxContent(const YGNodeRef node) {
|
||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||
node, Dimension::Height, StyleSizeLength::ofMaxContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMinHeightFitContent(const YGNodeRef node) {
|
||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||
node, Dimension::Height, StyleSizeLength::ofFitContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMinHeightStretch(const YGNodeRef node) {
|
||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||
node, Dimension::Height, StyleSizeLength::ofStretch());
|
||||
}
|
||||
|
||||
YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
||||
@@ -376,12 +451,27 @@ YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
||||
|
||||
void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) {
|
||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||
node, Dimension::Width, StyleLength::points(maxWidth));
|
||||
node, Dimension::Width, StyleSizeLength::points(maxWidth));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) {
|
||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||
node, Dimension::Width, StyleLength::percent(maxWidth));
|
||||
node, Dimension::Width, StyleSizeLength::percent(maxWidth));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMaxWidthMaxContent(const YGNodeRef node) {
|
||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||
node, Dimension::Width, StyleSizeLength::ofMaxContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMaxWidthFitContent(const YGNodeRef node) {
|
||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||
node, Dimension::Width, StyleSizeLength::ofFitContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMaxWidthStretch(const YGNodeRef node) {
|
||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||
node, Dimension::Width, StyleSizeLength::ofStretch());
|
||||
}
|
||||
|
||||
YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
||||
@@ -390,14 +480,29 @@ YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
||||
|
||||
void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) {
|
||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||
node, Dimension::Height, StyleLength::points(maxHeight));
|
||||
node, Dimension::Height, StyleSizeLength::points(maxHeight));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMaxHeightPercent(
|
||||
const YGNodeRef node,
|
||||
const float maxHeight) {
|
||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||
node, Dimension::Height, StyleLength::percent(maxHeight));
|
||||
node, Dimension::Height, StyleSizeLength::percent(maxHeight));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMaxHeightMaxContent(const YGNodeRef node) {
|
||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||
node, Dimension::Height, StyleSizeLength::ofMaxContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMaxHeightFitContent(const YGNodeRef node) {
|
||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||
node, Dimension::Height, StyleSizeLength::ofFitContent());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMaxHeightStretch(const YGNodeRef node) {
|
||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||
node, Dimension::Height, StyleSizeLength::ofStretch());
|
||||
}
|
||||
|
||||
YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
|
||||
|
||||
@@ -64,6 +64,9 @@ YG_EXPORT float YGNodeStyleGetFlexShrink(YGNodeConstRef node);
|
||||
YG_EXPORT void YGNodeStyleSetFlexBasis(YGNodeRef node, float flexBasis);
|
||||
YG_EXPORT void YGNodeStyleSetFlexBasisPercent(YGNodeRef node, float flexBasis);
|
||||
YG_EXPORT void YGNodeStyleSetFlexBasisAuto(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetFlexBasisMaxContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetFlexBasisFitContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetFlexBasisStretch(YGNodeRef node);
|
||||
YG_EXPORT YGValue YGNodeStyleGetFlexBasis(YGNodeConstRef node);
|
||||
|
||||
YG_EXPORT void
|
||||
@@ -101,27 +104,45 @@ YG_EXPORT YGBoxSizing YGNodeStyleGetBoxSizing(YGNodeConstRef node);
|
||||
YG_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float width);
|
||||
YG_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float width);
|
||||
YG_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetWidthMaxContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetWidthFitContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetWidthStretch(YGNodeRef node);
|
||||
YG_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node);
|
||||
|
||||
YG_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float height);
|
||||
YG_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float height);
|
||||
YG_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetHeightMaxContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetHeightFitContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetHeightStretch(YGNodeRef node);
|
||||
YG_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node);
|
||||
|
||||
YG_EXPORT void YGNodeStyleSetMinWidth(YGNodeRef node, float minWidth);
|
||||
YG_EXPORT void YGNodeStyleSetMinWidthPercent(YGNodeRef node, float minWidth);
|
||||
YG_EXPORT void YGNodeStyleSetMinWidthMaxContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetMinWidthFitContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetMinWidthStretch(YGNodeRef node);
|
||||
YG_EXPORT YGValue YGNodeStyleGetMinWidth(YGNodeConstRef node);
|
||||
|
||||
YG_EXPORT void YGNodeStyleSetMinHeight(YGNodeRef node, float minHeight);
|
||||
YG_EXPORT void YGNodeStyleSetMinHeightPercent(YGNodeRef node, float minHeight);
|
||||
YG_EXPORT void YGNodeStyleSetMinHeightMaxContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetMinHeightFitContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetMinHeightStretch(YGNodeRef node);
|
||||
YG_EXPORT YGValue YGNodeStyleGetMinHeight(YGNodeConstRef node);
|
||||
|
||||
YG_EXPORT void YGNodeStyleSetMaxWidth(YGNodeRef node, float maxWidth);
|
||||
YG_EXPORT void YGNodeStyleSetMaxWidthPercent(YGNodeRef node, float maxWidth);
|
||||
YG_EXPORT void YGNodeStyleSetMaxWidthMaxContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetMaxWidthFitContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetMaxWidthStretch(YGNodeRef node);
|
||||
YG_EXPORT YGValue YGNodeStyleGetMaxWidth(YGNodeConstRef node);
|
||||
|
||||
YG_EXPORT void YGNodeStyleSetMaxHeight(YGNodeRef node, float maxHeight);
|
||||
YG_EXPORT void YGNodeStyleSetMaxHeightPercent(YGNodeRef node, float maxHeight);
|
||||
YG_EXPORT void YGNodeStyleSetMaxHeightMaxContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetMaxHeightFitContent(YGNodeRef node);
|
||||
YG_EXPORT void YGNodeStyleSetMaxHeightStretch(YGNodeRef node);
|
||||
YG_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node);
|
||||
|
||||
YG_EXPORT void YGNodeStyleSetAspectRatio(YGNodeRef node, float aspectRatio);
|
||||
|
||||
@@ -65,6 +65,9 @@ inline bool operator==(const YGValue& lhs, const YGValue& rhs) {
|
||||
switch (lhs.unit) {
|
||||
case YGUnitUndefined:
|
||||
case YGUnitAuto:
|
||||
case YGUnitFitContent:
|
||||
case YGUnitMaxContent:
|
||||
case YGUnitStretch:
|
||||
return true;
|
||||
case YGUnitPoint:
|
||||
case YGUnitPercent:
|
||||
|
||||
@@ -749,7 +749,7 @@ static float distributeFreeSpaceSecondPass(
|
||||
marginCross;
|
||||
const bool isLoosePercentageMeasurement =
|
||||
currentLineChild->getProcessedDimension(dimension(crossAxis))
|
||||
.unit() == Unit::Percent &&
|
||||
.isPercent() &&
|
||||
sizingModeCrossDim != SizingMode::StretchFit;
|
||||
childCrossSizingMode =
|
||||
yoga::isUndefined(childCrossSize) || isLoosePercentageMeasurement
|
||||
|
||||
@@ -20,11 +20,14 @@ enum class Unit : uint8_t {
|
||||
Point = YGUnitPoint,
|
||||
Percent = YGUnitPercent,
|
||||
Auto = YGUnitAuto,
|
||||
MaxContent = YGUnitMaxContent,
|
||||
FitContent = YGUnitFitContent,
|
||||
Stretch = YGUnitStretch,
|
||||
};
|
||||
|
||||
template <>
|
||||
constexpr int32_t ordinalCount<Unit>() {
|
||||
return 4;
|
||||
return 7;
|
||||
}
|
||||
|
||||
constexpr Unit scopedEnum(YGUnit unscoped) {
|
||||
|
||||
@@ -314,16 +314,16 @@ void Node::setPosition(
|
||||
crossAxisTrailingEdge);
|
||||
}
|
||||
|
||||
Style::Length Node::processFlexBasis() const {
|
||||
Style::Length flexBasis = style_.flexBasis();
|
||||
if (flexBasis.unit() != Unit::Auto && flexBasis.unit() != Unit::Undefined) {
|
||||
Style::SizeLength Node::processFlexBasis() const {
|
||||
Style::SizeLength flexBasis = style_.flexBasis();
|
||||
if (!flexBasis.isAuto() && !flexBasis.isUndefined()) {
|
||||
return flexBasis;
|
||||
}
|
||||
if (style_.flex().isDefined() && style_.flex().unwrap() > 0.0f) {
|
||||
return config_->useWebDefaults() ? StyleLength::ofAuto()
|
||||
: StyleLength::points(0);
|
||||
return config_->useWebDefaults() ? StyleSizeLength::ofAuto()
|
||||
: StyleSizeLength::points(0);
|
||||
}
|
||||
return StyleLength::ofAuto();
|
||||
return StyleSizeLength::ofAuto();
|
||||
}
|
||||
|
||||
FloatOptional Node::resolveFlexBasis(
|
||||
|
||||
@@ -172,7 +172,7 @@ class YG_EXPORT Node : public ::YGNode {
|
||||
return isDirty_;
|
||||
}
|
||||
|
||||
Style::Length getProcessedDimension(Dimension dimension) const {
|
||||
Style::SizeLength getProcessedDimension(Dimension dimension) const {
|
||||
return processedDimensions_[static_cast<size_t>(dimension)];
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ class YG_EXPORT Node : public ::YGNode {
|
||||
void setPosition(Direction direction, float ownerWidth, float ownerHeight);
|
||||
|
||||
// Other methods
|
||||
Style::Length processFlexBasis() const;
|
||||
Style::SizeLength processFlexBasis() const;
|
||||
FloatOptional resolveFlexBasis(
|
||||
Direction direction,
|
||||
FlexDirection flexDirection,
|
||||
@@ -322,8 +322,8 @@ class YG_EXPORT Node : public ::YGNode {
|
||||
Node* owner_ = nullptr;
|
||||
std::vector<Node*> children_;
|
||||
const Config* config_;
|
||||
std::array<Style::Length, 2> processedDimensions_{
|
||||
{StyleLength::undefined(), StyleLength::undefined()}};
|
||||
std::array<Style::SizeLength, 2> processedDimensions_{
|
||||
{StyleSizeLength::undefined(), StyleSizeLength::undefined()}};
|
||||
};
|
||||
|
||||
inline Node* resolveRef(const YGNodeRef ref) {
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <yoga/enums/Wrap.h>
|
||||
#include <yoga/numeric/FloatOptional.h>
|
||||
#include <yoga/style/StyleLength.h>
|
||||
#include <yoga/style/StyleSizeLength.h>
|
||||
#include <yoga/style/StyleValuePool.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
@@ -37,6 +38,7 @@ namespace facebook::yoga {
|
||||
class YG_EXPORT Style {
|
||||
public:
|
||||
using Length = StyleLength;
|
||||
using SizeLength = StyleSizeLength;
|
||||
|
||||
static constexpr float DefaultFlexGrow = 0.0f;
|
||||
static constexpr float DefaultFlexShrink = 0.0f;
|
||||
@@ -133,10 +135,10 @@ class YG_EXPORT Style {
|
||||
pool_.store(flexShrink_, value);
|
||||
}
|
||||
|
||||
Style::Length flexBasis() const {
|
||||
return pool_.getLength(flexBasis_);
|
||||
Style::SizeLength flexBasis() const {
|
||||
return pool_.getSize(flexBasis_);
|
||||
}
|
||||
void setFlexBasis(Style::Length value) {
|
||||
void setFlexBasis(Style::SizeLength value) {
|
||||
pool_.store(flexBasis_, value);
|
||||
}
|
||||
|
||||
@@ -175,17 +177,17 @@ class YG_EXPORT Style {
|
||||
pool_.store(gap_[yoga::to_underlying(gutter)], value);
|
||||
}
|
||||
|
||||
Style::Length dimension(Dimension axis) const {
|
||||
return pool_.getLength(dimensions_[yoga::to_underlying(axis)]);
|
||||
Style::SizeLength dimension(Dimension axis) const {
|
||||
return pool_.getSize(dimensions_[yoga::to_underlying(axis)]);
|
||||
}
|
||||
void setDimension(Dimension axis, Style::Length value) {
|
||||
void setDimension(Dimension axis, Style::SizeLength value) {
|
||||
pool_.store(dimensions_[yoga::to_underlying(axis)], value);
|
||||
}
|
||||
|
||||
Style::Length minDimension(Dimension axis) const {
|
||||
return pool_.getLength(minDimensions_[yoga::to_underlying(axis)]);
|
||||
Style::SizeLength minDimension(Dimension axis) const {
|
||||
return pool_.getSize(minDimensions_[yoga::to_underlying(axis)]);
|
||||
}
|
||||
void setMinDimension(Dimension axis, Style::Length value) {
|
||||
void setMinDimension(Dimension axis, Style::SizeLength value) {
|
||||
pool_.store(minDimensions_[yoga::to_underlying(axis)], value);
|
||||
}
|
||||
|
||||
@@ -207,10 +209,10 @@ class YG_EXPORT Style {
|
||||
: FloatOptional{0.0});
|
||||
}
|
||||
|
||||
Style::Length maxDimension(Dimension axis) const {
|
||||
return pool_.getLength(maxDimensions_[yoga::to_underlying(axis)]);
|
||||
Style::SizeLength maxDimension(Dimension axis) const {
|
||||
return pool_.getSize(maxDimensions_[yoga::to_underlying(axis)]);
|
||||
}
|
||||
void setMaxDimension(Dimension axis, Style::Length value) {
|
||||
void setMaxDimension(Dimension axis, Style::SizeLength value) {
|
||||
pool_.store(maxDimensions_[yoga::to_underlying(axis)], value);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,11 @@ namespace facebook::yoga {
|
||||
* 3. A CSS <length-percentage> value:
|
||||
* a. <length> value (e.g. 10px)
|
||||
* b. <percentage> value of a reference <length>
|
||||
* 4. (soon) A math function which returns a <length-percentage> value
|
||||
*
|
||||
* References:
|
||||
* 1. https://www.w3.org/TR/css-values-4/#lengths
|
||||
* 2. https://www.w3.org/TR/css-values-4/#percentage-value
|
||||
* 3. https://www.w3.org/TR/css-values-4/#mixed-percentages
|
||||
* 4. https://www.w3.org/TR/css-values-4/#math
|
||||
*/
|
||||
class StyleLength {
|
||||
public:
|
||||
@@ -59,6 +57,14 @@ class StyleLength {
|
||||
return unit_ == Unit::Undefined;
|
||||
}
|
||||
|
||||
constexpr bool isPoints() const {
|
||||
return unit_ == Unit::Point;
|
||||
}
|
||||
|
||||
constexpr bool isPercent() const {
|
||||
return unit_ == Unit::Percent;
|
||||
}
|
||||
|
||||
constexpr bool isDefined() const {
|
||||
return !isUndefined();
|
||||
}
|
||||
@@ -67,10 +73,6 @@ class StyleLength {
|
||||
return value_;
|
||||
}
|
||||
|
||||
constexpr Unit unit() const {
|
||||
return unit_;
|
||||
}
|
||||
|
||||
constexpr FloatOptional resolve(float referenceLength) {
|
||||
switch (unit_) {
|
||||
case Unit::Point:
|
||||
@@ -90,6 +92,11 @@ class StyleLength {
|
||||
return value_ == rhs.value_ && unit_ == rhs.unit_;
|
||||
}
|
||||
|
||||
constexpr bool inexactEquals(const StyleLength& other) const {
|
||||
return unit_ == other.unit_ &&
|
||||
facebook::yoga::inexactEquals(value_, other.value_);
|
||||
}
|
||||
|
||||
private:
|
||||
// We intentionally do not allow direct construction using value and unit, to
|
||||
// avoid invalid, or redundant combinations.
|
||||
@@ -101,7 +108,7 @@ class StyleLength {
|
||||
};
|
||||
|
||||
inline bool inexactEquals(const StyleLength& a, const StyleLength& b) {
|
||||
return a.unit() == b.unit() && inexactEquals(a.value(), b.value());
|
||||
return a.inexactEquals(b);
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <yoga/enums/Unit.h>
|
||||
#include <yoga/numeric/FloatOptional.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
|
||||
/**
|
||||
* This class represents a CSS Value for sizes (e.g. width, height, min-width,
|
||||
* etc.). It may be one of:
|
||||
* 1. Undefined
|
||||
* 2. A keyword (e.g. auto, max-content, stretch, etc.)
|
||||
* 3. A CSS <length-percentage> value:
|
||||
* a. <length> value (e.g. 10px)
|
||||
* b. <percentage> value of a reference <length>
|
||||
*
|
||||
* References:
|
||||
* 1. https://www.w3.org/TR/css-values-4/#lengths
|
||||
* 2. https://www.w3.org/TR/css-values-4/#percentage-value
|
||||
* 3. https://www.w3.org/TR/css-values-4/#mixed-percentages
|
||||
*/
|
||||
class StyleSizeLength {
|
||||
public:
|
||||
constexpr StyleSizeLength() = default;
|
||||
|
||||
constexpr static StyleSizeLength points(float value) {
|
||||
return yoga::isUndefined(value) || yoga::isinf(value)
|
||||
? undefined()
|
||||
: StyleSizeLength{FloatOptional{value}, Unit::Point};
|
||||
}
|
||||
|
||||
constexpr static StyleSizeLength percent(float value) {
|
||||
return yoga::isUndefined(value) || yoga::isinf(value)
|
||||
? undefined()
|
||||
: StyleSizeLength{FloatOptional{value}, Unit::Percent};
|
||||
}
|
||||
|
||||
constexpr static StyleSizeLength ofAuto() {
|
||||
return StyleSizeLength{{}, Unit::Auto};
|
||||
}
|
||||
|
||||
constexpr static StyleSizeLength ofMaxContent() {
|
||||
return StyleSizeLength{{}, Unit::MaxContent};
|
||||
}
|
||||
|
||||
constexpr static StyleSizeLength ofFitContent() {
|
||||
return StyleSizeLength{{}, Unit::FitContent};
|
||||
}
|
||||
|
||||
constexpr static StyleSizeLength ofStretch() {
|
||||
return StyleSizeLength{{}, Unit::Stretch};
|
||||
}
|
||||
|
||||
constexpr static StyleSizeLength undefined() {
|
||||
return StyleSizeLength{{}, Unit::Undefined};
|
||||
}
|
||||
|
||||
constexpr bool isAuto() const {
|
||||
return unit_ == Unit::Auto;
|
||||
}
|
||||
|
||||
constexpr bool isMaxContent() const {
|
||||
return unit_ == Unit::MaxContent;
|
||||
}
|
||||
|
||||
constexpr bool isFitContent() const {
|
||||
return unit_ == Unit::FitContent;
|
||||
}
|
||||
|
||||
constexpr bool isStretch() const {
|
||||
return unit_ == Unit::Stretch;
|
||||
}
|
||||
|
||||
constexpr bool isUndefined() const {
|
||||
return unit_ == Unit::Undefined;
|
||||
}
|
||||
|
||||
constexpr bool isDefined() const {
|
||||
return !isUndefined();
|
||||
}
|
||||
|
||||
constexpr bool isPoints() const {
|
||||
return unit_ == Unit::Point;
|
||||
}
|
||||
|
||||
constexpr bool isPercent() const {
|
||||
return unit_ == Unit::Percent;
|
||||
}
|
||||
|
||||
constexpr FloatOptional value() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
constexpr FloatOptional resolve(float referenceLength) {
|
||||
switch (unit_) {
|
||||
case Unit::Point:
|
||||
return value_;
|
||||
case Unit::Percent:
|
||||
return FloatOptional{value_.unwrap() * referenceLength * 0.01f};
|
||||
default:
|
||||
return FloatOptional{};
|
||||
}
|
||||
}
|
||||
|
||||
explicit constexpr operator YGValue() const {
|
||||
return YGValue{value_.unwrap(), unscopedEnum(unit_)};
|
||||
}
|
||||
|
||||
constexpr bool operator==(const StyleSizeLength& rhs) const {
|
||||
return value_ == rhs.value_ && unit_ == rhs.unit_;
|
||||
}
|
||||
|
||||
constexpr bool inexactEquals(const StyleSizeLength& other) const {
|
||||
return unit_ == other.unit_ &&
|
||||
facebook::yoga::inexactEquals(value_, other.value_);
|
||||
}
|
||||
|
||||
private:
|
||||
// We intentionally do not allow direct construction using value and unit, to
|
||||
// avoid invalid, or redundant combinations.
|
||||
constexpr StyleSizeLength(FloatOptional value, Unit unit)
|
||||
: value_(value), unit_(unit) {}
|
||||
|
||||
FloatOptional value_{};
|
||||
Unit unit_{Unit::Undefined};
|
||||
};
|
||||
|
||||
inline bool inexactEquals(const StyleSizeLength& a, const StyleSizeLength& b) {
|
||||
return a.inexactEquals(b);
|
||||
}
|
||||
|
||||
} // namespace facebook::yoga
|
||||
@@ -62,8 +62,16 @@ class StyleValueHandle {
|
||||
Percent,
|
||||
Number,
|
||||
Auto,
|
||||
Keyword
|
||||
};
|
||||
|
||||
// Intentionally leaving out auto as a fast path
|
||||
enum class Keyword : uint8_t { MaxContent, FitContent, Stretch };
|
||||
|
||||
constexpr bool isKeyword(Keyword keyword) const {
|
||||
return type() == Type::Keyword && value() == static_cast<uint16_t>(keyword);
|
||||
}
|
||||
|
||||
constexpr Type type() const {
|
||||
return static_cast<Type>(repr_ & kHandleTypeMask);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <yoga/numeric/FloatOptional.h>
|
||||
#include <yoga/style/SmallValueBuffer.h>
|
||||
#include <yoga/style/StyleLength.h>
|
||||
#include <yoga/style/StyleSizeLength.h>
|
||||
#include <yoga/style/StyleValueHandle.h>
|
||||
|
||||
namespace facebook::yoga {
|
||||
@@ -32,13 +33,30 @@ class StyleValuePool {
|
||||
} else if (length.isAuto()) {
|
||||
handle.setType(StyleValueHandle::Type::Auto);
|
||||
} else {
|
||||
auto type = length.unit() == Unit::Point
|
||||
? StyleValueHandle::Type::Point
|
||||
: StyleValueHandle::Type::Percent;
|
||||
auto type = length.isPoints() ? StyleValueHandle::Type::Point
|
||||
: StyleValueHandle::Type::Percent;
|
||||
storeValue(handle, length.value().unwrap(), type);
|
||||
}
|
||||
}
|
||||
|
||||
void store(StyleValueHandle& handle, StyleSizeLength sizeValue) {
|
||||
if (sizeValue.isUndefined()) {
|
||||
handle.setType(StyleValueHandle::Type::Undefined);
|
||||
} else if (sizeValue.isAuto()) {
|
||||
handle.setType(StyleValueHandle::Type::Auto);
|
||||
} else if (sizeValue.isMaxContent()) {
|
||||
storeKeyword(handle, StyleValueHandle::Keyword::MaxContent);
|
||||
} else if (sizeValue.isStretch()) {
|
||||
storeKeyword(handle, StyleValueHandle::Keyword::Stretch);
|
||||
} else if (sizeValue.isFitContent()) {
|
||||
storeKeyword(handle, StyleValueHandle::Keyword::FitContent);
|
||||
} else {
|
||||
auto type = sizeValue.isPoints() ? StyleValueHandle::Type::Point
|
||||
: StyleValueHandle::Type::Percent;
|
||||
storeValue(handle, sizeValue.value().unwrap(), type);
|
||||
}
|
||||
}
|
||||
|
||||
void store(StyleValueHandle& handle, FloatOptional number) {
|
||||
if (number.isUndefined()) {
|
||||
handle.setType(StyleValueHandle::Type::Undefined);
|
||||
@@ -66,6 +84,31 @@ class StyleValuePool {
|
||||
}
|
||||
}
|
||||
|
||||
StyleSizeLength getSize(StyleValueHandle handle) const {
|
||||
if (handle.isUndefined()) {
|
||||
return StyleSizeLength::undefined();
|
||||
} else if (handle.isAuto()) {
|
||||
return StyleSizeLength::ofAuto();
|
||||
} else if (handle.isKeyword(StyleValueHandle::Keyword::MaxContent)) {
|
||||
return StyleSizeLength::ofMaxContent();
|
||||
} else if (handle.isKeyword(StyleValueHandle::Keyword::FitContent)) {
|
||||
return StyleSizeLength::ofFitContent();
|
||||
} else if (handle.isKeyword(StyleValueHandle::Keyword::Stretch)) {
|
||||
return StyleSizeLength::ofStretch();
|
||||
} else {
|
||||
assert(
|
||||
handle.type() == StyleValueHandle::Type::Point ||
|
||||
handle.type() == StyleValueHandle::Type::Percent);
|
||||
float value = (handle.isValueIndexed())
|
||||
? std::bit_cast<float>(buffer_.get32(handle.value()))
|
||||
: unpackInlineInteger(handle.value());
|
||||
|
||||
return handle.type() == StyleValueHandle::Type::Point
|
||||
? StyleSizeLength::points(value)
|
||||
: StyleSizeLength::percent(value);
|
||||
}
|
||||
}
|
||||
|
||||
FloatOptional getNumber(StyleValueHandle handle) const {
|
||||
if (handle.isUndefined()) {
|
||||
return FloatOptional{};
|
||||
@@ -98,6 +141,20 @@ class StyleValuePool {
|
||||
}
|
||||
}
|
||||
|
||||
void storeKeyword(
|
||||
StyleValueHandle& handle,
|
||||
StyleValueHandle::Keyword keyword) {
|
||||
handle.setType(StyleValueHandle::Type::Keyword);
|
||||
|
||||
if (handle.isValueIndexed()) {
|
||||
auto newIndex =
|
||||
buffer_.replace(handle.value(), static_cast<uint32_t>(keyword));
|
||||
handle.setValue(newIndex);
|
||||
} else {
|
||||
handle.setValue(static_cast<uint16_t>(keyword));
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr bool isIntegerPackable(float f) {
|
||||
constexpr uint16_t kMaxInlineAbsValue = (1 << 11) - 1;
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "^18.2.6",
|
||||
"react": "^19.0.0-rc-fb9a90fa48-20240614"
|
||||
"react": "^18.2.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
@@ -138,7 +138,7 @@
|
||||
"react-devtools-core": "^6.0.1",
|
||||
"react-refresh": "^0.14.0",
|
||||
"regenerator-runtime": "^0.13.2",
|
||||
"scheduler": "0.25.0-rc-fb9a90fa48-20240614",
|
||||
"scheduler": "0.24.0-canary-efb381bbf-20230505",
|
||||
"semver": "^7.1.3",
|
||||
"stacktrace-parser": "^0.1.10",
|
||||
"whatwg-fetch": "^3.0.0",
|
||||
|
||||
@@ -40,27 +40,15 @@ class NewArchitectureTests < Test::Unit::TestCase
|
||||
|
||||
assert_equal(installer.aggregate_targets[0].user_project.build_configurations[0].build_settings["CLANG_CXX_LANGUAGE_STANDARD"], "c++20")
|
||||
assert_equal(installer.aggregate_targets[1].user_project.build_configurations[0].build_settings["CLANG_CXX_LANGUAGE_STANDARD"], "c++20")
|
||||
assert_equal(installer.pods_project.targets[1].received_resolved_build_setting_parameters, [ReceivedCommonResolvedBuildSettings.new("CLANG_CXX_LANGUAGE_STANDARD", true)])
|
||||
assert_equal(Pod::UI.collected_messages, ["Setting CLANG_CXX_LANGUAGE_STANDARD to c++20 on /test/path.xcproj", "Setting CLANG_CXX_LANGUAGE_STANDARD to c++20 on /test/path2.xcproj"])
|
||||
end
|
||||
|
||||
def test_setClangCxxLanguageStandardIfNeeded_whenReactCoreIsNotPresent
|
||||
installer = prepare_mocked_installer_without_react_core
|
||||
NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer)
|
||||
|
||||
assert_equal(installer.aggregate_targets[0].user_project.build_configurations[0].build_settings["CLANG_CXX_LANGUAGE_STANDARD"], nil)
|
||||
assert_equal(installer.aggregate_targets[1].user_project.build_configurations[0].build_settings["CLANG_CXX_LANGUAGE_STANDARD"], nil)
|
||||
assert_equal(installer.pods_project.targets[0].received_resolved_build_setting_parameters, [])
|
||||
assert_equal(Pod::UI.collected_messages, [])
|
||||
end
|
||||
|
||||
def test_setClangCxxLanguageStandardIfNeeded_whenThereAreDifferentValuesForLanguageStandard_takesTheFirstValue
|
||||
installer = prepare_mocked_installer_with_react_core_and_different_language_standards
|
||||
NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer)
|
||||
|
||||
assert_equal(installer.aggregate_targets[0].user_project.build_configurations[0].build_settings["CLANG_CXX_LANGUAGE_STANDARD"], "c++20")
|
||||
assert_equal(installer.aggregate_targets[1].user_project.build_configurations[0].build_settings["CLANG_CXX_LANGUAGE_STANDARD"], "c++20")
|
||||
assert_equal(installer.pods_project.targets[1].received_resolved_build_setting_parameters, [ReceivedCommonResolvedBuildSettings.new("CLANG_CXX_LANGUAGE_STANDARD", true)])
|
||||
assert_equal(Pod::UI.collected_messages, ["Setting CLANG_CXX_LANGUAGE_STANDARD to c++20 on /test/path.xcproj", "Setting CLANG_CXX_LANGUAGE_STANDARD to c++20 on /test/path2.xcproj"])
|
||||
end
|
||||
|
||||
|
||||
@@ -701,9 +701,6 @@ class UtilsTests < Test::Unit::TestCase
|
||||
# Assert
|
||||
assert_equal(FileMock.exist_invocation_params, ["/.xcode.env", "/.xcode.env.local"])
|
||||
assert_equal($collected_commands[0], "echo 'export NODE_BINARY=$(command -v node)' > /.xcode.env")
|
||||
|
||||
assert_true($collected_commands[1].start_with? "echo 'export NODE_BINARY=")
|
||||
assert_true($collected_commands[1].end_with? "' > /.xcode.env.local")
|
||||
end
|
||||
|
||||
# ============================ #
|
||||
|
||||
@@ -16,6 +16,9 @@ export interface Spec extends TurboModule {
|
||||
+isReduceMotionEnabled: (
|
||||
onSuccess: (isReduceMotionEnabled: boolean) => void,
|
||||
) => void;
|
||||
+isInvertColorsEnabled?: (
|
||||
onSuccess: (isInvertColorsEnabled: boolean) => void,
|
||||
) => void;
|
||||
+isHighTextContrastEnabled?: (
|
||||
onSuccess: (isHighTextContrastEnabled: boolean) => void,
|
||||
) => void;
|
||||
|
||||
@@ -1341,12 +1341,6 @@ class EnabledExamples extends React.Component<{}> {
|
||||
eventListener="grayscaleChanged"
|
||||
/>
|
||||
</RNTesterBlock>
|
||||
<RNTesterBlock title="isInvertColorsEnabled()">
|
||||
<EnabledExample
|
||||
test="invert colors"
|
||||
eventListener="invertColorsChanged"
|
||||
/>
|
||||
</RNTesterBlock>
|
||||
<RNTesterBlock title="isReduceTransparencyEnabled()">
|
||||
<EnabledExample
|
||||
test="reduce transparency"
|
||||
@@ -1376,6 +1370,13 @@ class EnabledExamples extends React.Component<{}> {
|
||||
/>
|
||||
</RNTesterBlock>
|
||||
|
||||
<RNTesterBlock title="isInvertColorsEnabled()">
|
||||
<EnabledExample
|
||||
test="invert colors"
|
||||
eventListener="invertColorsChanged"
|
||||
/>
|
||||
</RNTesterBlock>
|
||||
|
||||
<RNTesterBlock title="isScreenReaderEnabled()">
|
||||
<EnabledExample
|
||||
test="screen reader"
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"nullthrows": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "19.0.0-rc-fb9a90fa48-20240614",
|
||||
"react": "18.3.1",
|
||||
"react-native": "*"
|
||||
},
|
||||
"codegenConfig": {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
"nullthrows": "^1.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"react-test-renderer": "19.0.0-rc-fb9a90fa48-20240614"
|
||||
"react-test-renderer": "18.3.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "^18.2.6",
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"react": "19.0.0-rc-fb9a90fa48-20240614",
|
||||
"react": "18.3.1",
|
||||
"react-native": "1000.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -6283,7 +6283,7 @@ logkitty@^0.7.1:
|
||||
dayjs "^1.8.15"
|
||||
yargs "^15.1.0"
|
||||
|
||||
loose-envify@^1.0.0, loose-envify@^1.4.0:
|
||||
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
|
||||
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
|
||||
@@ -7366,28 +7366,54 @@ react-devtools-core@^6.0.1:
|
||||
shell-quote "^1.6.1"
|
||||
ws "^7"
|
||||
|
||||
react-is@19.0.0-rc-fb9a90fa48-20240614, react-is@^16.13.1, react-is@^16.8.4, react-is@^17.0.1, react-is@^18.0.0:
|
||||
version "19.0.0-rc-fb9a90fa48-20240614"
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-19.0.0-rc-fb9a90fa48-20240614.tgz#6987893799abdedf2e9929e31541cb6d7dc8285a"
|
||||
integrity sha512-60qI7v1B9RhmZwjTCnAgzcuABOQsIH20vTbETQPaze96s1lY2lSawv9dvXAfF8Z1MIqOppWSKLNOshF0WsZ3OA==
|
||||
"react-is@^16.12.0 || ^17.0.0 || ^18.0.0", react-is@^18.0.0:
|
||||
version "18.2.0"
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
|
||||
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==
|
||||
|
||||
react-is@^16.13.1, react-is@^16.8.4:
|
||||
version "16.13.1"
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
|
||||
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
|
||||
|
||||
react-is@^17.0.1:
|
||||
version "17.0.2"
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
|
||||
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
|
||||
|
||||
react-is@^18.3.1:
|
||||
version "18.3.1"
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.3.1.tgz#e83557dc12eae63a99e003a46388b1dcbb44db7e"
|
||||
integrity sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==
|
||||
|
||||
react-refresh@^0.14.0:
|
||||
version "0.14.2"
|
||||
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.14.2.tgz#3833da01ce32da470f1f936b9d477da5c7028bf9"
|
||||
integrity sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA==
|
||||
|
||||
react-test-renderer@19.0.0-rc-fb9a90fa48-20240614:
|
||||
version "19.0.0-rc-fb9a90fa48-20240614"
|
||||
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-19.0.0-rc-fb9a90fa48-20240614.tgz#6657b3d05a533afad5ea0516f9ed29cadf72334f"
|
||||
integrity sha512-cV3mGgsKTJCB8f4tZxWIp0ot4PMgx791XTkwpapf06ZlUk5BCP3C1CbIqRXcKeiQODvFJClZX26TFTPAklTq7A==
|
||||
react-shallow-renderer@^16.15.0:
|
||||
version "16.15.0"
|
||||
resolved "https://registry.yarnpkg.com/react-shallow-renderer/-/react-shallow-renderer-16.15.0.tgz#48fb2cf9b23d23cde96708fe5273a7d3446f4457"
|
||||
integrity sha512-oScf2FqQ9LFVQgA73vr86xl2NaOIX73rh+YFqcOp68CWj56tSfgtGKrEbyhCj0rSijyG9M1CYprTh39fBi5hzA==
|
||||
dependencies:
|
||||
react-is "19.0.0-rc-fb9a90fa48-20240614"
|
||||
scheduler "0.25.0-rc-fb9a90fa48-20240614"
|
||||
object-assign "^4.1.1"
|
||||
react-is "^16.12.0 || ^17.0.0 || ^18.0.0"
|
||||
|
||||
react@19.0.0-rc-fb9a90fa48-20240614:
|
||||
version "19.0.0-rc-fb9a90fa48-20240614"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-19.0.0-rc-fb9a90fa48-20240614.tgz#90eb43a0b005e8cc3cbf0d801c14816d01df1b08"
|
||||
integrity sha512-nvE3Gy+IOIfH/DXhkyxFVQSrITarFcQz4+shzC/McxQXEUSonpw2oDy/Wi9hdDtV3hlP12VYuDL95iiBREedNQ==
|
||||
react-test-renderer@18.3.1:
|
||||
version "18.3.1"
|
||||
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-18.3.1.tgz#e693608a1f96283400d4a3afead6893f958b80b4"
|
||||
integrity sha512-KkAgygexHUkQqtvvx/otwxtuFu5cVjfzTCtjXLH9boS19/Nbtg84zS7wIQn39G8IlrhThBpQsMKkq5ZHZIYFXA==
|
||||
dependencies:
|
||||
react-is "^18.3.1"
|
||||
react-shallow-renderer "^16.15.0"
|
||||
scheduler "^0.23.2"
|
||||
|
||||
react@18.3.1:
|
||||
version "18.3.1"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-18.3.1.tgz#49ab892009c53933625bd16b2533fc754cab2891"
|
||||
integrity sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
|
||||
readable-stream@^2.0.6, readable-stream@~2.3.6:
|
||||
version "2.3.8"
|
||||
@@ -7737,10 +7763,19 @@ safe-regex-test@^1.0.3:
|
||||
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
|
||||
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
|
||||
|
||||
scheduler@0.25.0-rc-fb9a90fa48-20240614:
|
||||
version "0.25.0-rc-fb9a90fa48-20240614"
|
||||
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.25.0-rc-fb9a90fa48-20240614.tgz#9ee11063b7c0f47aef3fea53d9f1be3f13794dce"
|
||||
integrity sha512-HHqQ/SqbeiDfXXVKgNxTpbQTD4n7IUb4hZATvHjp03jr3TF7igehCyHdOjeYTrzIseLO93cTTfSb5f4qWcirMQ==
|
||||
scheduler@0.24.0-canary-efb381bbf-20230505:
|
||||
version "0.24.0-canary-efb381bbf-20230505"
|
||||
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.24.0-canary-efb381bbf-20230505.tgz#5dddc60e29f91cd7f8b983d7ce4a99c2202d178f"
|
||||
integrity sha512-ABvovCDe/k9IluqSh4/ISoq8tIJnW8euVAWYt5j/bg6dRnqwQwiGO1F/V4AyK96NGF/FB04FhOUDuWj8IKfABA==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
|
||||
scheduler@^0.23.2:
|
||||
version "0.23.2"
|
||||
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.23.2.tgz#414ba64a3b282892e944cf2108ecc078d115cdc3"
|
||||
integrity sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
|
||||
selfsigned@^2.4.1:
|
||||
version "2.4.1"
|
||||
|
||||
Reference in New Issue
Block a user