Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ target_link_libraries(react_renderer_observers_events
react_renderer_runtimescheduler
react_featureflags
react_renderer_uimanager
react_utils)
react_utils
rrc_view)
target_compile_reactnative_options(react_renderer_observers_events PRIVATE)
target_compile_options(react_renderer_observers_events PRIVATE -Wpedantic)
1 change: 1 addition & 0 deletions packages/react-native/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fmt="11.0.2"
folly="2024.11.18.00"
glog="0.3.5"
gflags="2.2.0"
nlohmannjson="3.11.2"

[libraries]
androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "androidx-annotation" }
Expand Down
61 changes: 55 additions & 6 deletions private/react-native-fantom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ plugins {
alias(libs.plugins.download)
}

val FOLLY_VERSION = libs.versions.folly.get()
val GFLAGS_VERSION = libs.versions.gflags.get()
val NLOHMANNJSON_VERSION = libs.versions.nlohmannjson.get()

val buildDir = project.layout.buildDirectory.get().asFile
val downloadsDir =
Expand All @@ -27,13 +29,28 @@ val downloadsDir =
val thirdParty = File("$buildDir/third-party")
val reactNativeRootDir = projectDir.parentFile.parentFile
val reactAndroidBuildDir = File("$reactNativeRootDir/packages/react-native/ReactAndroid/build")
val reactAndroidDownloasdDir =
File("$reactNativeRootDir/packages/react-native/ReactAndroid/build/downloads")

val createNativeDepsDirectories by
tasks.registering {
downloadsDir.mkdirs()
thirdParty.mkdirs()
}

val downloadFollyDest = File(reactAndroidDownloasdDir, "folly-${FOLLY_VERSION}.tar.gz")

val prepareFolly by
tasks.registering(Copy::class) {
dependsOn(listOf(":packages:react-native:ReactAndroid:downloadFolly"))
from(tarTree(downloadFollyDest))
from("tester/third-party/folly/")
include("folly-${FOLLY_VERSION}/folly/**/*", "CMakeLists.txt")
eachFile { path = path.substringAfter("/") }
includeEmptyDirs = false
into("$thirdParty/folly")
}

val downloadGflagsDest = File(downloadsDir, "gflags-${GFLAGS_VERSION}.tar.gz")
val downloadGflags by
tasks.registering(Download::class) {
Expand All @@ -55,16 +72,42 @@ val prepareGflags by
outputDir.set(File(thirdParty, "gflags"))
}

var codegenSrcDir = File("$reactAndroidBuildDir/generated/source/codegen/jni/react")
var codegenOutDir = File("$buildDir/codegen/react")
val downloadNlohmannJsonDest = File(downloadsDir, "nlohmann_json-${NLOHMANNJSON_VERSION}.tar.gz")
val downloadNlohmannJson by
tasks.registering(Download::class) {
dependsOn(createNativeDepsDirectories)
src("https://github.com/nlohmann/json/archive/v${NLOHMANNJSON_VERSION}.tar.gz")
onlyIfModified(true)
overwrite(false)
retries(5)
quiet(true)
dest(downloadNlohmannJsonDest)
}

val prepareNlohmannJson by
tasks.registering(Copy::class) {
dependsOn(listOf(downloadNlohmannJson))
from(tarTree(downloadNlohmannJsonDest))
from("tester/third-party/nlohmann_json/")
include(
"json-${NLOHMANNJSON_VERSION}/src/**/*",
"json-${NLOHMANNJSON_VERSION}/include/**/*",
"CMakeLists.txt")
eachFile { path = path.substringAfter("/") }
includeEmptyDirs = false
into("$thirdParty/nlohmann_json")
}

var codegenSrcDir = File("$reactAndroidBuildDir/generated/source/codegen/jni")
var codegenOutDir = File("$buildDir/codegen")
val prepareRNCodegen by
tasks.registering(Copy::class) {
dependsOn(":packages:react-native:ReactAndroid:generateCodegenArtifactsFromSchema")
from(codegenSrcDir)
from("tester/codegen/react")
include(
"**/FBReactNativeSpecJSI.h", "**/FBReactNativeSpecJSI-generated.cpp", "CMakeLists.txt")
from("tester/codegen")
include("react/**/*.h", "react/**/*.cpp", "CMakeLists.txt")
includeEmptyDirs = false
duplicatesStrategy = DuplicatesStrategy.INCLUDE
into(codegenOutDir)
}

Expand All @@ -80,7 +123,13 @@ val prepareNative3pDependencies by
tasks.registering {
dependsOn(
prepareGflags,
":packages:react-native:ReactAndroid:prepareNative3pDependencies",
prepareNlohmannJson,
prepareFolly,
":packages:react-native:ReactAndroid:prepareBoost",
":packages:react-native:ReactAndroid:prepareDoubleConversion",
":packages:react-native:ReactAndroid:prepareFastFloat",
":packages:react-native:ReactAndroid:prepareFmt",
":packages:react-native:ReactAndroid:prepareGlog",
)
}

Expand Down
2 changes: 1 addition & 1 deletion private/react-native-fantom/src/__tests__/Fantom-itest.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ describe('Fantom', () => {
expect(
root
.getRenderedOutput({
props: ['!width'],
props: ['^(?!width$).*$'],
})
.toJSX(),
).toEqual(<rn-view height="100.000000" />);
Expand Down
24 changes: 12 additions & 12 deletions private/react-native-fantom/src/getFantomRenderedOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import type {RootTag} from 'react-native';

// $FlowExpectedError[untyped-import]
import micromatch from 'micromatch';
import * as React from 'react';
import NativeFantom from 'react-native/src/private/testing/fantom/specs/NativeFantom';

Expand All @@ -30,8 +28,7 @@ type FantomJsonObject = {
type FantomJson = FantomJsonObject | $ReadOnlyArray<FantomJsonObject>;

type FantomRenderedOutputConfig = {
// micromatch pattern to match prop names
// see usage examples in https://github.com/micromatch/micromatch#examples
// RegExp patterns to match prop names
props?: $ReadOnlyArray<string>,
};

Expand Down Expand Up @@ -88,17 +85,20 @@ class FantomRenderedOutput {
props: FantomJsonObject['props'],
config: FantomRenderedOutputConfig,
): FantomJsonObject['props'] {
if (config.props == null) {
const patterns = config.props;
if (patterns == null) {
return {...props};
}

return micromatch(Object.keys(props), config.props ?? []).reduce(
(acc, name) => {
acc[name] = props[name];
return acc;
},
{},
);
return Object.keys(props)
.filter(key => patterns.some(pattern => new RegExp(pattern).test(key)))
.reduce(
(acc, name) => {
acc[name] = props[name];
return acc;
},
{} as FantomJsonObject['props'],
);
}
}

Expand Down
Loading
Loading