Compare commits

..
Author SHA1 Message Date
Nicola Corti 185443e299 Migrate RNTester to use {usesCleartextTraffic} Manifest Placeholder (#52620)
Summary:
This creates a `debugOptimized` build type for React Native Android, meaning that we can run C++ optimization on the debug build, while still having the debugger enabled. This is aimed at improving the developer experience for folks developing on low-end devices or emulators.

Users that intend to debug can still use the `debug` variant where the full debug symbols are shipped.

## Changelog:

[ANDROID] [ADDED] - Create a debugOptimized buildType for Android


Test Plan:
Tested locally with RNTester by doing:

```
./gradlew installDebugOptimized
```

This is the output of the 3 generated .aar. The size difference is a proof that we're correctly stripping out the C++ debug symbols:

<img width="193" height="54" alt="Screenshot 2025-07-15 at 17 49 50" src="https://github.com/user-attachments/assets/584a0e8d-2d17-40d4-ac29-da09049d6554" />
<img width="235" height="51" alt="Screenshot 2025-07-15 at 17 49 39" src="https://github.com/user-attachments/assets/eda8f9e7-3509-4334-8c16-990e55caa04d" />
<img width="184" height="52" alt="Screenshot 2025-07-15 at 17 49 32" src="https://github.com/user-attachments/assets/a5c94385-bc00-4484-b43e-088ee039827f" />

Rollback Plan:

Reviewed By: cipolleschi

Differential Revision: D78351347

Pulled By: cortinico
2025-07-18 07:43:44 -07:00
Jakub Piasecki 5cda3065ce Update font scale on Android when recreating RootView (#52595)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52595

Changelog: [ANDROID][FIXED] Update font scale when recreating `RootView`

At the moment `enableFontScaleChangesUpdatingLayout` flag only works when the activity is configured to handle font scale changes by itself (`configChanges="fontScale"` in the manifest).

When that configuration is missing, the OS handles the font scale changes by recreating the activity, but in this case the path responsible for updating internally kept font size isn't executed.

This diff updates the RootView, so that the display metrics are also updated when it's created. Alternative approach would be to do that on the Activity, but that assumes usage of `ReactActivity`.

Reviewed By: NickGerleman

Differential Revision: D78323174

fbshipit-source-id: e48583091767497b5dfd4f2d938329530de4068d
2025-07-18 06:50:29 -07:00
64 changed files with 2230 additions and 205 deletions
+1
View File
@@ -43,6 +43,7 @@ project.xcworkspace
/private/helloworld/android/app/build/
/private/helloworld/android/build/
/packages/react-native-popup-menu-android/android/build/
/packages/react-native-test-library/android/build/
# Buck
.buckd
@@ -18,6 +18,7 @@ import com.facebook.react.tasks.GenerateEntryPointTask
import com.facebook.react.tasks.GeneratePackageListTask
import com.facebook.react.utils.AgpConfiguratorUtils.configureBuildConfigFieldsForApp
import com.facebook.react.utils.AgpConfiguratorUtils.configureBuildConfigFieldsForLibraries
import com.facebook.react.utils.AgpConfiguratorUtils.configureBuildTypesForApp
import com.facebook.react.utils.AgpConfiguratorUtils.configureDevServerLocation
import com.facebook.react.utils.AgpConfiguratorUtils.configureNamespaceForLibraries
import com.facebook.react.utils.BackwardCompatUtils.configureBackwardCompatibilityReactMap
@@ -84,6 +85,7 @@ class ReactPlugin : Plugin<Project> {
configureAutolinking(project, extension)
configureCodegen(project, extension, rootExtension, isLibrary = false)
configureResources(project, extension)
configureBuildTypesForApp(project)
}
// Library Only Configuration
@@ -19,6 +19,7 @@ import java.net.Inet4Address
import java.net.NetworkInterface
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
import kotlin.plus
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.plugins.AppliedPlugin
@@ -27,6 +28,26 @@ import org.w3c.dom.Element
@Suppress("UnstableApiUsage")
internal object AgpConfiguratorUtils {
fun configureBuildTypesForApp(project: Project) {
val action =
Action<AppliedPlugin> {
project.extensions
.getByType(ApplicationAndroidComponentsExtension::class.java)
.finalizeDsl { ext ->
ext.buildTypes {
val debug =
getByName("debug").apply {
manifestPlaceholders["usesCleartextTraffic"] = "true"
}
getByName("release").apply {
manifestPlaceholders["usesCleartextTraffic"] = "false"
}
}
}
}
project.pluginManager.withPlugin("com.android.application", action)
}
fun configureBuildConfigFieldsForApp(project: Project, extension: ReactExtension) {
val action =
Action<AppliedPlugin> {
@@ -0,0 +1,24 @@
# 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.
require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
Pod::Spec.new do |s|
s.name = 'OSSLibraryExample'
s.version = package['version']
s.summary = package['description']
s.description = package['description']
s.homepage = package['homepage']
s.license = package['license']
s.platforms = min_supported_versions
s.author = 'Meta Platforms, Inc. and its affiliates'
s.source = { :git => package['repository']['url'], :tag => "#{s.version}" }
s.source_files = 'ios/**/*.{h,m,mm,cpp}'
install_modules_dependencies(s)
end
@@ -0,0 +1,9 @@
## Important
This package is for testing only. It is a subject to frequent change. It does not represent the recomended structure for React native libraries. It should not be used as a referece for such purposes.
## Building
```
yarn install
yarn build
npx react-native codegen
```
@@ -0,0 +1,32 @@
/*
* 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.
*/
plugins {
id("com.facebook.react")
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
}
android {
compileSdk = libs.versions.compileSdk.get().toInt()
buildToolsVersion = libs.versions.buildTools.get()
namespace = "com.facebook.react.osslibraryexample"
defaultConfig { minSdk = libs.versions.minSdk.get().toInt() }
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions { jvmTarget = "17" }
}
dependencies {
// Build React Native from source
implementation(project(":packages:react-native:ReactAndroid"))
}
@@ -0,0 +1,4 @@
# We want to have more fine grained control on the Java version for
# ReactAndroid, therefore we disable RGNP Java version alignment mechanism
react.internal.disableJavaVersionAlignment=true
@@ -0,0 +1,37 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleJavaSpec.js
*
* @nolint
*/
package com.facebook.fbreact.specs;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
import javax.annotation.Nonnull;
public abstract class NativeSampleModuleSpec extends ReactContextBaseJavaModule implements TurboModule {
public static final String NAME = "NativeSampleModule";
public NativeSampleModuleSpec(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public @Nonnull String getName() {
return NAME;
}
@ReactMethod(isBlockingSynchronousMethod = true)
@DoNotStrip
public abstract double getRandomNumber();
}
@@ -0,0 +1,30 @@
/*
* 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.osslibraryexample
import com.facebook.fbreact.specs.NativeSampleModuleSpec
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.module.annotations.ReactModule
@ReactModule(name = NativeSampleModuleSpec.NAME)
public class NativeSampleModule(reactContext: ReactApplicationContext?) :
ReactContextBaseJavaModule(reactContext) {
override fun getName(): String = NAME
private companion object {
const val NAME = "NativeSampleModule"
}
@ReactMethod
public fun getRandomNumber(): Int {
return (0..99).random()
}
}
@@ -0,0 +1,23 @@
/*
* 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.osslibraryexample
import com.facebook.react.ReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ViewManager
@Suppress("DEPRECATION")
public class OSSLibraryExamplePackage : ReactPackage {
@Deprecated("Migrate to [BaseReactPackage] and implement [getModule] instead.")
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> =
listOf(NativeSampleModule(reactContext))
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
listOf(SampleNativeComponentViewManager())
}
@@ -0,0 +1,105 @@
/*
* 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.osslibraryexample
import android.annotation.SuppressLint
import android.graphics.Color
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.uimanager.SimpleViewManager
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.ViewProps
import com.facebook.react.uimanager.annotations.ReactProp
import com.facebook.react.viewmanagers.SampleNativeComponentManagerInterface
/** Legacy View manager (non Fabric compatible) for {@link SampleNativeView} components. */
@ReactModule(name = SampleNativeComponentViewManager.REACT_CLASS)
internal class SampleNativeComponentViewManager :
SimpleViewManager<SampleNativeView>(), SampleNativeComponentManagerInterface<SampleNativeView> {
override fun getName(): String = REACT_CLASS
// @ReactProp(name = ViewProps.OPACITY, defaultFloat = 1f)
override fun setOpacity(view: SampleNativeView, opacity: Float) {
super.setOpacity(view, opacity)
}
@SuppressLint("BadMethodUse-android.view.View.setBackgroundColor")
@ReactProp(name = ViewProps.COLOR)
fun setColor(view: SampleNativeView, color: String) {
view.setBackgroundColor(Color.parseColor(color))
}
@ReactProp(name = "cornerRadius")
fun setCornerRadius(view: SampleNativeView, cornerRadius: Float) {
view.setCornerRadius(cornerRadius)
}
override fun createViewInstance(reactContext: ThemedReactContext): SampleNativeView =
SampleNativeView(reactContext)
@SuppressLint("BadMethodUse-android.view.View.setBackgroundColor")
override fun changeBackgroundColor(view: SampleNativeView, color: String) {
view.setBackgroundColor(Color.parseColor(color))
}
override fun getExportedViewConstants(): Map<String, Any> = mapOf("PI" to 3.14)
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
return mapOf(
"onColorChanged" to
mapOf(
"phasedRegistrationNames" to
mapOf(
"bubbled" to "onColorChanged",
"captured" to "onColorChangedCapture",
)),
"topIntArrayChanged" to
mapOf(
"phasedRegistrationNames" to
mapOf(
"bubbled" to "topIntArrayChanged",
"captured" to "topIntArrayChangedCapture",
)))
}
@SuppressLint("BadMethodUse-android.view.View.setBackgroundColor")
override fun receiveCommand(view: SampleNativeView, commandId: String, args: ReadableArray?) {
if (commandId.contentEquals("changeBackgroundColor")) {
val sentColor: Int = Color.parseColor(args?.getString(0))
view.setBackgroundColor(sentColor)
}
}
@Deprecated("Deprecated in Java")
@SuppressLint("BadMethodUse-android.view.View.setBackgroundColor")
@Suppress("DEPRECATION") // We intentionally want to test against the legacy API here.
override fun receiveCommand(view: SampleNativeView, commandId: Int, args: ReadableArray?) {
when (commandId) {
COMMAND_CHANGE_BACKGROUND_COLOR -> {
val sentColor: Int = Color.parseColor(args?.getString(0))
view.setBackgroundColor(sentColor)
}
}
}
override fun getCommandsMap(): Map<String, Int> =
mapOf("changeBackgroundColor" to COMMAND_CHANGE_BACKGROUND_COLOR)
companion object {
const val REACT_CLASS = "SampleNativeComponent"
const val COMMAND_CHANGE_BACKGROUND_COLOR = 42
}
@ReactProp(name = "values")
override fun setValues(view: SampleNativeView, value: ReadableArray?) {
val values = mutableListOf<Int>()
value?.toArrayList()?.forEach { values.add((it as Double).toInt()) }
view.emitOnArrayChangedEvent(values)
}
}
@@ -0,0 +1,97 @@
/*
* 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.osslibraryexample
import android.graphics.drawable.GradientDrawable
import android.view.View
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.ReactContext
import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.UIManagerHelper
import com.facebook.react.uimanager.events.Event
public class SampleNativeView(context: ThemedReactContext) : View(context) {
private var currentColor = 0
private var background: GradientDrawable = GradientDrawable()
private val reactContext: ReactContext = context.reactApplicationContext
override fun setBackgroundColor(color: Int) {
if (color != currentColor) {
background.setColor(color)
currentColor = color
setBackground(background)
}
}
public fun setCornerRadius(cornerRadius: Float) {
background.cornerRadius = cornerRadius
setBackground(background)
}
public fun emitOnArrayChangedEvent(ints: List<Int>) {
val newIntArray = Arguments.createArray()
val newBoolArray = Arguments.createArray()
val newFloatArray = Arguments.createArray()
val newDoubleArray = Arguments.createArray()
val newYesNoArray = Arguments.createArray()
val newStringArray = Arguments.createArray()
val newObjectArray = Arguments.createArray()
val newArrayArray = Arguments.createArray()
for (i in ints) {
newIntArray.pushInt(i * 2)
newBoolArray.pushBoolean(i % 2 == 1)
newFloatArray.pushDouble(i * 3.14)
newDoubleArray.pushDouble(i / 3.14)
newYesNoArray.pushString(if (i % 2 == 1) "yep" else "nope")
newStringArray.pushString(i.toString())
val latLon = Arguments.createMap()
latLon.putDouble("lat", -1.0 * i)
latLon.putDouble("lon", 2.0 * i)
newObjectArray.pushMap(latLon)
val innerArray: WritableArray = Arguments.createArray()
innerArray.pushInt(i)
innerArray.pushInt(i)
innerArray.pushInt(i)
newArrayArray.pushArray(innerArray)
}
val payload =
Arguments.createMap().apply {
putArray("values", newIntArray)
putArray("boolValues", newBoolArray)
putArray("floats", newFloatArray)
putArray("doubles", newDoubleArray)
putArray("yesNos", newYesNoArray)
putArray("strings", newStringArray)
putArray("latLons", newObjectArray)
putArray("multiArrays", newArrayArray)
}
val reactContext = context as ReactContext
val surfaceId = UIManagerHelper.getSurfaceId(reactContext)
val eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, id)
val event = OnIntArrayChangedEvent(surfaceId, id, payload)
eventDispatcher?.dispatchEvent(event)
}
private inner class OnIntArrayChangedEvent(
surfaceId: Int,
viewId: Int,
private val payload: WritableMap
) : Event<OnIntArrayChangedEvent>(surfaceId, viewId) {
override fun getEventName() = "topIntArrayChanged"
override fun getEventData() = payload
}
}
@@ -0,0 +1,45 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsJavaDelegate.js
*/
package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.LayoutShadowNode;
public class SampleNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & SampleNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public SampleNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
}
@Override
public void setProperty(T view, String propName, @Nullable Object value) {
switch (propName) {
case "opacity":
mViewManager.setOpacity(view, value == null ? 0f : ((Double) value).floatValue());
break;
case "values":
mViewManager.setValues(view, (ReadableArray) value);
break;
default:
super.setProperty(view, propName, value);
}
}
@Override
public void receiveCommand(T view, String commandName, @Nullable ReadableArray args) {
switch (commandName) {
case "changeBackgroundColor":
mViewManager.changeBackgroundColor(view, args.getString(0));
break;
}
}
}
@@ -0,0 +1,21 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsJavaInterface.js
*/
package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
public interface SampleNativeComponentManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setOpacity(T view, float value);
void setValues(T view, @Nullable ReadableArray value);
void changeBackgroundColor(T view, String color);
}
@@ -0,0 +1,26 @@
# 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.
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/OSSLibraryExampleSpec/*.cpp)
add_library(
react_codegen_OSSLibraryExampleSpec
OBJECT
${react_codegen_SRCS}
)
target_include_directories(react_codegen_OSSLibraryExampleSpec PUBLIC . react/renderer/components/OSSLibraryExampleSpec)
target_link_libraries(
react_codegen_OSSLibraryExampleSpec
fbjni
jsi
reactnative
)
target_compile_reactnative_options(react_codegen_OSSLibraryExampleSpec PRIVATE)
@@ -0,0 +1,32 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleJniCpp.js
*/
#include "OSSLibraryExampleSpec.h"
namespace facebook::react {
static facebook::jsi::Value __hostFunction_NativeSampleModuleSpecJSI_getRandomNumber(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
static jmethodID cachedMethodId = nullptr;
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, NumberKind, "getRandomNumber", "()D", args, count, cachedMethodId);
}
NativeSampleModuleSpecJSI::NativeSampleModuleSpecJSI(const JavaTurboModule::InitParams &params)
: JavaTurboModule(params) {
methodMap_["getRandomNumber"] = MethodMetadata {0, __hostFunction_NativeSampleModuleSpecJSI_getRandomNumber};
}
std::shared_ptr<TurboModule> OSSLibraryExampleSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
if (moduleName == "NativeSampleModule") {
return std::make_shared<NativeSampleModuleSpecJSI>(params);
}
return nullptr;
}
} // namespace facebook::react
@@ -0,0 +1,31 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleJniH.js
*/
#pragma once
#include <ReactCommon/JavaTurboModule.h>
#include <ReactCommon/TurboModule.h>
#include <jsi/jsi.h>
namespace facebook::react {
/**
* JNI C++ class for module 'NativeSampleModule'
*/
class JSI_EXPORT NativeSampleModuleSpecJSI : public JavaTurboModule {
public:
NativeSampleModuleSpecJSI(const JavaTurboModule::InitParams &params);
};
JSI_EXPORT
std::shared_ptr<TurboModule> OSSLibraryExampleSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
} // namespace facebook::react
@@ -0,0 +1,22 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateComponentDescriptorCpp.js
*/
#include "ComponentDescriptors.h"
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
namespace facebook::react {
void OSSLibraryExampleSpec_registerComponentDescriptorsFromCodegen(
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
registry->add(concreteComponentDescriptorProvider<SampleNativeComponentComponentDescriptor>());
}
} // namespace facebook::react
@@ -0,0 +1,24 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateComponentDescriptorH.js
*/
#pragma once
#include "ShadowNodes.h"
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
namespace facebook::react {
using SampleNativeComponentComponentDescriptor = ConcreteComponentDescriptor<SampleNativeComponentShadowNode>;
void OSSLibraryExampleSpec_registerComponentDescriptorsFromCodegen(
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
} // namespace facebook::react
@@ -0,0 +1,95 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateEventEmitterCpp.js
*/
#include "EventEmitters.h"
namespace facebook::react {
void SampleNativeComponentEventEmitter::onIntArrayChanged(OnIntArrayChanged $event) const {
dispatchEvent("intArrayChanged", [$event=std::move($event)](jsi::Runtime &runtime) {
auto $payload = jsi::Object(runtime);
auto values = jsi::Array(runtime, $event.values.size());
size_t valuesIndex = 0;
for (auto valuesValue : $event.values) {
values.setValueAtIndex(runtime, valuesIndex++, valuesValue);
}
$payload.setProperty(runtime, "values", values);
auto boolValues = jsi::Array(runtime, $event.boolValues.size());
size_t boolValuesIndex = 0;
for (auto boolValuesValue : $event.boolValues) {
boolValues.setValueAtIndex(runtime, boolValuesIndex++, (bool)boolValuesValue);
}
$payload.setProperty(runtime, "boolValues", boolValues);
auto floats = jsi::Array(runtime, $event.floats.size());
size_t floatsIndex = 0;
for (auto floatsValue : $event.floats) {
floats.setValueAtIndex(runtime, floatsIndex++, floatsValue);
}
$payload.setProperty(runtime, "floats", floats);
auto doubles = jsi::Array(runtime, $event.doubles.size());
size_t doublesIndex = 0;
for (auto doublesValue : $event.doubles) {
doubles.setValueAtIndex(runtime, doublesIndex++, doublesValue);
}
$payload.setProperty(runtime, "doubles", doubles);
auto yesNos = jsi::Array(runtime, $event.yesNos.size());
size_t yesNosIndex = 0;
for (auto yesNosValue : $event.yesNos) {
yesNos.setValueAtIndex(runtime, yesNosIndex++, toString(yesNosValue));
}
$payload.setProperty(runtime, "yesNos", yesNos);
auto strings = jsi::Array(runtime, $event.strings.size());
size_t stringsIndex = 0;
for (auto stringsValue : $event.strings) {
strings.setValueAtIndex(runtime, stringsIndex++, stringsValue);
}
$payload.setProperty(runtime, "strings", strings);
auto latLons = jsi::Array(runtime, $event.latLons.size());
size_t latLonsIndex = 0;
for (auto latLonsValue : $event.latLons) {
auto latLonsObject = jsi::Object(runtime);
latLonsObject.setProperty(runtime, "lat", latLonsValue.lat);
latLonsObject.setProperty(runtime, "lon", latLonsValue.lon);
latLons.setValueAtIndex(runtime, latLonsIndex++, latLonsObject);
}
$payload.setProperty(runtime, "latLons", latLons);
auto multiArrays = jsi::Array(runtime, $event.multiArrays.size());
size_t multiArraysIndex = 0;
for (auto multiArraysValue : $event.multiArrays) {
auto multiArraysArray = jsi::Array(runtime, multiArraysValue.size());
size_t multiArraysIndexInternal = 0;
for (auto multiArraysValueInternal : multiArraysValue) {
multiArraysArray.setValueAtIndex(runtime, multiArraysIndexInternal++, multiArraysValueInternal);
}
multiArrays.setValueAtIndex(runtime, multiArraysIndex++, multiArraysArray);
}
$payload.setProperty(runtime, "multiArrays", multiArrays);
return $payload;
});
}
} // namespace facebook::react
@@ -0,0 +1,49 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateEventEmitterH.js
*/
#pragma once
#include <react/renderer/components/view/ViewEventEmitter.h>
namespace facebook::react {
class SampleNativeComponentEventEmitter : public ViewEventEmitter {
public:
using ViewEventEmitter::ViewEventEmitter;
enum class OnIntArrayChangedYesNos {
Yep,
Nope
};
static char const *toString(const OnIntArrayChangedYesNos value) {
switch (value) {
case OnIntArrayChangedYesNos::Yep: return "yep";
case OnIntArrayChangedYesNos::Nope: return "nope";
}
}
struct OnIntArrayChangedLatLons {
double lat;
double lon;
};
struct OnIntArrayChanged {
std::vector<int> values;
std::vector<bool> boolValues;
std::vector<Float> floats;
std::vector<double> doubles;
std::vector<OnIntArrayChangedYesNos> yesNos;
std::vector<std::string> strings;
std::vector<OnIntArrayChangedLatLons> latLons;
std::vector<std::vector<int>> multiArrays;
};
void onIntArrayChanged(OnIntArrayChanged value) const;
};
} // namespace facebook::react
@@ -0,0 +1,26 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleCpp.js
*/
#include "OSSLibraryExampleSpecJSI.h"
namespace facebook::react {
static jsi::Value __hostFunction_NativeSampleModuleCxxSpecJSI_getRandomNumber(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<NativeSampleModuleCxxSpecJSI *>(&turboModule)->getRandomNumber(
rt
);
}
NativeSampleModuleCxxSpecJSI::NativeSampleModuleCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule("NativeSampleModule", jsInvoker) {
methodMap_["getRandomNumber"] = MethodMetadata {0, __hostFunction_NativeSampleModuleCxxSpecJSI_getRandomNumber};
}
} // namespace facebook::react
@@ -0,0 +1,67 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleH.js
*/
#pragma once
#include <ReactCommon/TurboModule.h>
#include <react/bridging/Bridging.h>
namespace facebook::react {
class JSI_EXPORT NativeSampleModuleCxxSpecJSI : public TurboModule {
protected:
NativeSampleModuleCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
public:
virtual double getRandomNumber(jsi::Runtime &rt) = 0;
};
template <typename T>
class JSI_EXPORT NativeSampleModuleCxxSpec : public TurboModule {
public:
jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
return delegate_.create(rt, propName);
}
static constexpr std::string_view kModuleName = "NativeSampleModule";
protected:
NativeSampleModuleCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule(std::string{NativeSampleModuleCxxSpec::kModuleName}, jsInvoker),
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
private:
class Delegate : public NativeSampleModuleCxxSpecJSI {
public:
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
NativeSampleModuleCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
}
double getRandomNumber(jsi::Runtime &rt) override {
static_assert(
bridging::getParameterCount(&T::getRandomNumber) == 1,
"Expected getRandomNumber(...) to have 1 parameters");
return bridging::callFromJs<double>(
rt, &T::getRandomNumber, jsInvoker_, instance_);
}
private:
friend class NativeSampleModuleCxxSpec;
T *instance_;
};
Delegate delegate_;
};
} // namespace facebook::react
@@ -0,0 +1,26 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsCpp.js
*/
#include "Props.h"
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/propsConversions.h>
namespace facebook::react {
SampleNativeComponentProps::SampleNativeComponentProps(
const PropsParserContext &context,
const SampleNativeComponentProps &sourceProps,
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
opacity(convertRawProp(context, rawProps, "opacity", sourceProps.opacity, {0.0})),
values(convertRawProp(context, rawProps, "values", sourceProps.values, {}))
{}
} // namespace facebook::react
@@ -0,0 +1,29 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsH.js
*/
#pragma once
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <vector>
namespace facebook::react {
class SampleNativeComponentProps final : public ViewProps {
public:
SampleNativeComponentProps() = default;
SampleNativeComponentProps(const PropsParserContext& context, const SampleNativeComponentProps &sourceProps, const RawProps &rawProps);
#pragma mark - Props
Float opacity{0.0};
std::vector<int> values{};
};
} // namespace facebook::react
@@ -0,0 +1,17 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateShadowNodeCpp.js
*/
#include "ShadowNodes.h"
namespace facebook::react {
extern const char SampleNativeComponentComponentName[] = "SampleNativeComponent";
} // namespace facebook::react
@@ -0,0 +1,32 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateShadowNodeH.js
*/
#pragma once
#include "EventEmitters.h"
#include "Props.h"
#include "States.h"
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <jsi/jsi.h>
namespace facebook::react {
JSI_EXPORT extern const char SampleNativeComponentComponentName[];
/*
* `ShadowNode` for <SampleNativeComponent> component.
*/
using SampleNativeComponentShadowNode = ConcreteViewShadowNode<
SampleNativeComponentComponentName,
SampleNativeComponentProps,
SampleNativeComponentEventEmitter,
SampleNativeComponentState>;
} // namespace facebook::react
@@ -0,0 +1,16 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateStateCpp.js
*/
#include "States.h"
namespace facebook::react {
} // namespace facebook::react
@@ -0,0 +1,29 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateStateH.js
*/
#pragma once
#ifdef RN_SERIALIZABLE_STATE
#include <folly/dynamic.h>
#endif
namespace facebook::react {
class SampleNativeComponentState {
public:
SampleNativeComponentState() = default;
#ifdef RN_SERIALIZABLE_STATE
SampleNativeComponentState(SampleNativeComponentState const &previousState, folly::dynamic data){};
folly::dynamic getDynamic() const {
return {};
};
#endif
};
} // namespace facebook::react
@@ -0,0 +1,18 @@
/**
* 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.
*
* @format
* @noflow
*/
module.exports = {
presets: [
[
'module:@react-native/babel-preset',
{disableStaticViewConfigsCodegen: false},
],
],
};
+16
View File
@@ -0,0 +1,16 @@
/**
* 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.
*
* @flow strict-local
* @format
*/
export {default as SampleNativeComponent} from './src/SampleNativeComponent';
export type {NativeComponentType} from './src/SampleNativeComponent';
import {Commands as SampleNativeComponentCommands} from './src/SampleNativeComponent';
export {SampleNativeComponentCommands};
export {default as NativeSampleModule} from './src/NativeSampleModule';
@@ -0,0 +1,22 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateComponentDescriptorCpp.js
*/
#include "ComponentDescriptors.h"
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
namespace facebook::react {
void OSSLibraryExampleSpec_registerComponentDescriptorsFromCodegen(
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
registry->add(concreteComponentDescriptorProvider<SampleNativeComponentComponentDescriptor>());
}
} // namespace facebook::react
@@ -0,0 +1,24 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateComponentDescriptorH.js
*/
#pragma once
#include "ShadowNodes.h"
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
namespace facebook::react {
using SampleNativeComponentComponentDescriptor = ConcreteComponentDescriptor<SampleNativeComponentShadowNode>;
void OSSLibraryExampleSpec_registerComponentDescriptorsFromCodegen(
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
} // namespace facebook::react
@@ -0,0 +1,95 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateEventEmitterCpp.js
*/
#include "EventEmitters.h"
namespace facebook::react {
void SampleNativeComponentEventEmitter::onIntArrayChanged(OnIntArrayChanged $event) const {
dispatchEvent("intArrayChanged", [$event=std::move($event)](jsi::Runtime &runtime) {
auto $payload = jsi::Object(runtime);
auto values = jsi::Array(runtime, $event.values.size());
size_t valuesIndex = 0;
for (auto valuesValue : $event.values) {
values.setValueAtIndex(runtime, valuesIndex++, valuesValue);
}
$payload.setProperty(runtime, "values", values);
auto boolValues = jsi::Array(runtime, $event.boolValues.size());
size_t boolValuesIndex = 0;
for (auto boolValuesValue : $event.boolValues) {
boolValues.setValueAtIndex(runtime, boolValuesIndex++, (bool)boolValuesValue);
}
$payload.setProperty(runtime, "boolValues", boolValues);
auto floats = jsi::Array(runtime, $event.floats.size());
size_t floatsIndex = 0;
for (auto floatsValue : $event.floats) {
floats.setValueAtIndex(runtime, floatsIndex++, floatsValue);
}
$payload.setProperty(runtime, "floats", floats);
auto doubles = jsi::Array(runtime, $event.doubles.size());
size_t doublesIndex = 0;
for (auto doublesValue : $event.doubles) {
doubles.setValueAtIndex(runtime, doublesIndex++, doublesValue);
}
$payload.setProperty(runtime, "doubles", doubles);
auto yesNos = jsi::Array(runtime, $event.yesNos.size());
size_t yesNosIndex = 0;
for (auto yesNosValue : $event.yesNos) {
yesNos.setValueAtIndex(runtime, yesNosIndex++, toString(yesNosValue));
}
$payload.setProperty(runtime, "yesNos", yesNos);
auto strings = jsi::Array(runtime, $event.strings.size());
size_t stringsIndex = 0;
for (auto stringsValue : $event.strings) {
strings.setValueAtIndex(runtime, stringsIndex++, stringsValue);
}
$payload.setProperty(runtime, "strings", strings);
auto latLons = jsi::Array(runtime, $event.latLons.size());
size_t latLonsIndex = 0;
for (auto latLonsValue : $event.latLons) {
auto latLonsObject = jsi::Object(runtime);
latLonsObject.setProperty(runtime, "lat", latLonsValue.lat);
latLonsObject.setProperty(runtime, "lon", latLonsValue.lon);
latLons.setValueAtIndex(runtime, latLonsIndex++, latLonsObject);
}
$payload.setProperty(runtime, "latLons", latLons);
auto multiArrays = jsi::Array(runtime, $event.multiArrays.size());
size_t multiArraysIndex = 0;
for (auto multiArraysValue : $event.multiArrays) {
auto multiArraysArray = jsi::Array(runtime, multiArraysValue.size());
size_t multiArraysIndexInternal = 0;
for (auto multiArraysValueInternal : multiArraysValue) {
multiArraysArray.setValueAtIndex(runtime, multiArraysIndexInternal++, multiArraysValueInternal);
}
multiArrays.setValueAtIndex(runtime, multiArraysIndex++, multiArraysArray);
}
$payload.setProperty(runtime, "multiArrays", multiArrays);
return $payload;
});
}
} // namespace facebook::react
@@ -0,0 +1,49 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateEventEmitterH.js
*/
#pragma once
#include <react/renderer/components/view/ViewEventEmitter.h>
namespace facebook::react {
class SampleNativeComponentEventEmitter : public ViewEventEmitter {
public:
using ViewEventEmitter::ViewEventEmitter;
enum class OnIntArrayChangedYesNos {
Yep,
Nope
};
static char const *toString(const OnIntArrayChangedYesNos value) {
switch (value) {
case OnIntArrayChangedYesNos::Yep: return "yep";
case OnIntArrayChangedYesNos::Nope: return "nope";
}
}
struct OnIntArrayChangedLatLons {
double lat;
double lon;
};
struct OnIntArrayChanged {
std::vector<int> values;
std::vector<bool> boolValues;
std::vector<Float> floats;
std::vector<double> doubles;
std::vector<OnIntArrayChangedYesNos> yesNos;
std::vector<std::string> strings;
std::vector<OnIntArrayChangedLatLons> latLons;
std::vector<std::vector<int>> multiArrays;
};
void onIntArrayChanged(OnIntArrayChanged value) const;
};
} // namespace facebook::react
@@ -0,0 +1,29 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleObjCpp
*
* We create an umbrella header (and corresponding implementation) here since
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
* must have a single output. More files => more genrule()s => slower builds.
*/
#import "OSSLibraryExampleSpec.h"
namespace facebook::react {
static facebook::jsi::Value __hostFunction_NativeSampleModuleSpecJSI_getRandomNumber(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, NumberKind, "getRandomNumber", @selector(getRandomNumber), args, count);
}
NativeSampleModuleSpecJSI::NativeSampleModuleSpecJSI(const ObjCTurboModule::InitParams &params)
: ObjCTurboModule(params) {
methodMap_["getRandomNumber"] = MethodMetadata {0, __hostFunction_NativeSampleModuleSpecJSI_getRandomNumber};
}
} // namespace facebook::react
@@ -0,0 +1,49 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleObjCpp
*
* We create an umbrella header (and corresponding implementation) here since
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
* must have a single output. More files => more genrule()s => slower builds.
*/
#ifndef __cplusplus
#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
#endif
// Avoid multiple includes of OSSLibraryExampleSpec symbols
#ifndef OSSLibraryExampleSpec_H
#define OSSLibraryExampleSpec_H
#import <Foundation/Foundation.h>
#import <RCTRequired/RCTRequired.h>
#import <RCTTypeSafety/RCTConvertHelpers.h>
#import <RCTTypeSafety/RCTTypedModuleConstants.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTCxxConvert.h>
#import <React/RCTManagedPointer.h>
#import <ReactCommon/RCTTurboModule.h>
#import <optional>
#import <vector>
@protocol NativeSampleModuleSpec <RCTBridgeModule, RCTTurboModule>
- (NSNumber *)getRandomNumber;
@end
namespace facebook::react {
/**
* ObjC++ class for module 'NativeSampleModule'
*/
class JSI_EXPORT NativeSampleModuleSpecJSI : public ObjCTurboModule {
public:
NativeSampleModuleSpecJSI(const ObjCTurboModule::InitParams &params);
};
} // namespace facebook::react
#endif // OSSLibraryExampleSpec_H
@@ -0,0 +1,26 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsCpp.js
*/
#include "Props.h"
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/propsConversions.h>
namespace facebook::react {
SampleNativeComponentProps::SampleNativeComponentProps(
const PropsParserContext &context,
const SampleNativeComponentProps &sourceProps,
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
opacity(convertRawProp(context, rawProps, "opacity", sourceProps.opacity, {0.0})),
values(convertRawProp(context, rawProps, "values", sourceProps.values, {}))
{}
} // namespace facebook::react
@@ -0,0 +1,29 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsH.js
*/
#pragma once
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <vector>
namespace facebook::react {
class SampleNativeComponentProps final : public ViewProps {
public:
SampleNativeComponentProps() = default;
SampleNativeComponentProps(const PropsParserContext& context, const SampleNativeComponentProps &sourceProps, const RawProps &rawProps);
#pragma mark - Props
Float opacity{0.0};
std::vector<int> values{};
};
} // namespace facebook::react
@@ -0,0 +1,50 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateComponentHObjCpp.js
*/
#import <Foundation/Foundation.h>
#import <React/RCTDefines.h>
#import <React/RCTLog.h>
NS_ASSUME_NONNULL_BEGIN
@protocol RCTSampleNativeComponentViewProtocol <NSObject>
- (void)changeBackgroundColor:(NSString *)color;
@end
RCT_EXTERN inline void RCTSampleNativeComponentHandleCommand(
id<RCTSampleNativeComponentViewProtocol> componentView,
NSString const *commandName,
NSArray const *args)
{
if ([commandName isEqualToString:@"changeBackgroundColor"]) {
#if RCT_DEBUG
if ([args count] != 1) {
RCTLogError(@"%@ command %@ received %d arguments, expected %d.", @"SampleNativeComponent", commandName, (int)[args count], 1);
return;
}
#endif
NSObject *arg0 = args[0];
#if RCT_DEBUG
if (!RCTValidateTypeOfViewCommandArgument(arg0, [NSString class], @"string", @"SampleNativeComponent", commandName, @"1st")) {
return;
}
#endif
NSString * color = (NSString *)arg0;
[componentView changeBackgroundColor:color];
return;
}
#if RCT_DEBUG
RCTLogError(@"%@ received command %@, which is not a supported command.", @"SampleNativeComponent", commandName);
#endif
}
NS_ASSUME_NONNULL_END
@@ -0,0 +1,17 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateShadowNodeCpp.js
*/
#include "ShadowNodes.h"
namespace facebook::react {
extern const char SampleNativeComponentComponentName[] = "SampleNativeComponent";
} // namespace facebook::react
@@ -0,0 +1,32 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateShadowNodeH.js
*/
#pragma once
#include "EventEmitters.h"
#include "Props.h"
#include "States.h"
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <jsi/jsi.h>
namespace facebook::react {
JSI_EXPORT extern const char SampleNativeComponentComponentName[];
/*
* `ShadowNode` for <SampleNativeComponent> component.
*/
using SampleNativeComponentShadowNode = ConcreteViewShadowNode<
SampleNativeComponentComponentName,
SampleNativeComponentProps,
SampleNativeComponentEventEmitter,
SampleNativeComponentState>;
} // namespace facebook::react
@@ -0,0 +1,16 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateStateCpp.js
*/
#include "States.h"
namespace facebook::react {
} // namespace facebook::react
@@ -0,0 +1,29 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateStateH.js
*/
#pragma once
#ifdef RN_SERIALIZABLE_STATE
#include <folly/dynamic.h>
#endif
namespace facebook::react {
class SampleNativeComponentState {
public:
SampleNativeComponentState() = default;
#ifdef RN_SERIALIZABLE_STATE
SampleNativeComponentState(SampleNativeComponentState const &previousState, folly::dynamic data){};
folly::dynamic getDynamic() const {
return {};
};
#endif
};
} // namespace facebook::react
@@ -0,0 +1,26 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleCpp.js
*/
#include "OSSLibraryExampleSpecJSI.h"
namespace facebook::react {
static jsi::Value __hostFunction_NativeSampleModuleCxxSpecJSI_getRandomNumber(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<NativeSampleModuleCxxSpecJSI *>(&turboModule)->getRandomNumber(
rt
);
}
NativeSampleModuleCxxSpecJSI::NativeSampleModuleCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule("NativeSampleModule", jsInvoker) {
methodMap_["getRandomNumber"] = MethodMetadata {0, __hostFunction_NativeSampleModuleCxxSpecJSI_getRandomNumber};
}
} // namespace facebook::react
@@ -0,0 +1,67 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleH.js
*/
#pragma once
#include <ReactCommon/TurboModule.h>
#include <react/bridging/Bridging.h>
namespace facebook::react {
class JSI_EXPORT NativeSampleModuleCxxSpecJSI : public TurboModule {
protected:
NativeSampleModuleCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
public:
virtual double getRandomNumber(jsi::Runtime &rt) = 0;
};
template <typename T>
class JSI_EXPORT NativeSampleModuleCxxSpec : public TurboModule {
public:
jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
return delegate_.create(rt, propName);
}
static constexpr std::string_view kModuleName = "NativeSampleModule";
protected:
NativeSampleModuleCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule(std::string{NativeSampleModuleCxxSpec::kModuleName}, jsInvoker),
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
private:
class Delegate : public NativeSampleModuleCxxSpecJSI {
public:
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
NativeSampleModuleCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
}
double getRandomNumber(jsi::Runtime &rt) override {
static_assert(
bridging::getParameterCount(&T::getRandomNumber) == 1,
"Expected getRandomNumber(...) to have 1 parameters");
return bridging::callFromJs<double>(
rt, &T::getRandomNumber, jsInvoker_, instance_);
}
private:
friend class NativeSampleModuleCxxSpec;
T *instance_;
};
Delegate delegate_;
};
} // namespace facebook::react
@@ -0,0 +1,47 @@
/*
* 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.
*/
#ifdef RCT_NEW_ARCH_ENABLED
#import "OSSLibraryExampleSpec/OSSLibraryExampleSpec.h"
#else
#import <React/RCTBridge.h>
#endif
#import <Foundation/Foundation.h>
#include <react/debug/react_native_assert.h>
#include <stdlib.h>
#ifdef RCT_NEW_ARCH_ENABLED
@interface RCTNativeSampleModule : NSObject <NativeSampleModuleSpec>
#else
@interface RCTNativeSampleModule : NSObject <RCTBridgeModule>
#endif
@end
@implementation RCTNativeSampleModule
RCT_EXPORT_MODULE();
#ifdef RCT_NEW_ARCH_ENABLED
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
return std::make_shared<facebook::react::NativeSampleModuleSpecJSI>(params);
}
#endif
#ifdef RCT_NEW_ARCH_ENABLED
- (NSNumber *)getRandomNumber
#else
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSNumber *, getRandomNumber)
#endif
{
return @(arc4random_uniform(99));
}
@end
@@ -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.
*/
#import "OSSLibraryExampleSpec/ComponentDescriptors.h"
#import "OSSLibraryExampleSpec/EventEmitters.h"
#import "OSSLibraryExampleSpec/Props.h"
#import "OSSLibraryExampleSpec/RCTComponentViewHelpers.h"
#import "RCTFabricComponentsPlugins.h"
#import <React/RCTComponent.h>
#import <React/RCTViewComponentView.h>
#import <UIKit/UIKit.h>
using namespace facebook::react;
static UIColor *UIColorFromHexString(const std::string hexString)
{
unsigned rgbValue = 0;
NSString *colorString = [NSString stringWithCString:hexString.c_str() encoding:[NSString defaultCStringEncoding]];
NSScanner *scanner = [NSScanner scannerWithString:colorString];
[scanner setScanLocation:1]; // bypass '#' character
[scanner scanHexInt:&rgbValue];
return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0
green:((rgbValue & 0xFF00) >> 8) / 255.0
blue:(rgbValue & 0xFF) / 255.0
alpha:1.0];
}
@interface RCTSampleNativeComponentComponentView : RCTViewComponentView <RCTSampleNativeComponentViewProtocol>
@property (nonatomic, copy) RCTBubblingEventBlock onIntArrayChanged;
@end
@implementation RCTSampleNativeComponentComponentView {
UIView *_view;
}
+ (ComponentDescriptorProvider)componentDescriptorProvider
{
return concreteComponentDescriptorProvider<SampleNativeComponentComponentDescriptor>();
}
// Load is not invoked if it is not defined, therefore, we must ask to update this.
// See the Apple documentation: https://developer.apple.com/documentation/objectivec/nsobject/1418815-load?language=objc
// "[...] but only if the newly loaded class or category implements a method that can respond."
+ (void)load
{
[super load];
}
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
static const auto defaultProps = std::make_shared<const SampleNativeComponentProps>();
_props = defaultProps;
_view = [[UIView alloc] init];
_view.backgroundColor = [UIColor redColor];
self.contentView = _view;
}
return self;
}
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
{
const auto &oldViewProps = *std::static_pointer_cast<const SampleNativeComponentProps>(_props);
const auto &newViewProps = *std::static_pointer_cast<const SampleNativeComponentProps>(props);
if (oldViewProps.values != newViewProps.values) {
if (_eventEmitter) {
std::vector<int> newVector = {};
std::vector<bool> newBoolVector = {};
std::vector<Float> newFloatVector = {};
std::vector<double> newDoubleVector = {};
std::vector<SampleNativeComponentEventEmitter::OnIntArrayChangedYesNos> newYesNoVector = {};
std::vector<std::string> newStringVector = {};
std::vector<SampleNativeComponentEventEmitter::OnIntArrayChangedLatLons> newLatLonVector = {};
std::vector<std::vector<int>> newIntVectorVector = {};
for (auto val : newViewProps.values) {
newVector.push_back(val * 2);
newBoolVector.push_back(val % 2 ? true : false);
newFloatVector.push_back(val * 3.14);
newDoubleVector.push_back(val / 3.14);
newYesNoVector.push_back(
val % 2 ? SampleNativeComponentEventEmitter::OnIntArrayChangedYesNos::Yep
: SampleNativeComponentEventEmitter::OnIntArrayChangedYesNos::Nope);
newStringVector.push_back(std::to_string(val));
newLatLonVector.push_back({-1.0 * val, 2.0 * val});
newIntVectorVector.push_back({val, val, val});
}
SampleNativeComponentEventEmitter::OnIntArrayChanged value = {
newVector,
newBoolVector,
newFloatVector,
newDoubleVector,
newYesNoVector,
newStringVector,
newLatLonVector,
newIntVectorVector};
std::static_pointer_cast<const SampleNativeComponentEventEmitter>(_eventEmitter)->onIntArrayChanged(value);
}
}
[super updateProps:props oldProps:oldProps];
}
- (void)onChange:(UIView *)sender
{
// No-op
// std::dynamic_pointer_cast<const ViewEventEmitter>(_eventEmitter)
// ->onChange(ViewEventEmitter::OnChange{.value = static_cast<bool>(sender.on)});
}
#pragma mark - Native Commands
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
{
RCTSampleNativeComponentHandleCommand(self, commandName, args);
}
- (void)changeBackgroundColor:(NSString *)color
{
_view.backgroundColor = UIColorFromHexString(std::string(color.UTF8String));
}
@end
Class<RCTComponentViewProtocol> SampleNativeComponentCls(void)
{
return RCTSampleNativeComponentComponentView.class;
}
@@ -0,0 +1,72 @@
/*
* 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.
*/
#import <React/RCTLog.h>
#import <React/RCTUIManager.h>
#import <React/RCTViewManager.h>
#import <string>
static UIColor *UIColorFromHexString(const std::string hexString)
{
unsigned rgbValue = 0;
NSString *colorString = [NSString stringWithCString:hexString.c_str() encoding:[NSString defaultCStringEncoding]];
NSScanner *scanner = [NSScanner scannerWithString:colorString];
[scanner setScanLocation:1]; // bypass '#' character
[scanner scanHexInt:&rgbValue];
return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0
green:((rgbValue & 0xFF00) >> 8) / 255.0
blue:(rgbValue & 0xFF) / 255.0
alpha:1.0];
}
@interface RCTSampleNativeComponentViewManager : RCTViewManager
@end
@implementation RCTSampleNativeComponentViewManager
RCT_EXPORT_MODULE(SampleNativeComponent)
RCT_REMAP_VIEW_PROPERTY(color, backgroundColor, UIColor)
RCT_REMAP_VIEW_PROPERTY(opacity, alpha, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(onColorChanged, RCTBubblingEventBlock)
RCT_CUSTOM_VIEW_PROPERTY(cornerRadius, CGFloat, UIView)
{
view.clipsToBounds = true;
NSNumber *cornerRadius = (NSNumber *)json;
view.layer.cornerRadius = [cornerRadius floatValue];
}
RCT_EXPORT_METHOD(changeBackgroundColor : (nonnull NSNumber *)reactTag color : (NSString *)color)
{
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
if (UIView *view = [RCTSampleNativeComponentViewManager getViewByTag:viewRegistry reactTag:reactTag]) {
view.backgroundColor = UIColorFromHexString(std::string(color.UTF8String));
}
}];
}
+ (UIView *)getViewByTag:(NSDictionary<NSNumber *, UIView *> *)viewRegistry reactTag:(nonnull NSNumber *)reactTag
{
UIView *view = viewRegistry[reactTag];
if (view == nil) {
RCTLogError(@"Cannot find view with tag #%@", reactTag);
}
return view;
}
- (UIView *)view
{
UIView *view = [UIView new];
view.backgroundColor = UIColor.redColor;
return view;
}
@end
@@ -0,0 +1,54 @@
{
"name": "@react-native/oss-library-example",
"version": "0.81.0-main",
"private": true,
"description": "Package that includes native module exapmle, native component example, targets both the old and the new architecture. It should serve as an example of a real-world OSS library.",
"license": "MIT",
"homepage": "https://github.com/facebook/react-native.git",
"repository": {
"type": "git",
"url": "https://github.com/facebook/react-native.git",
"directory": "packages/react-native-test-library"
},
"main": "./index.js",
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
"scripts": {
"build": "yarn clean && babel --out-dir lib src",
"clean": "rimraf lib",
"codegen": "npx react-native codegen",
"prepare": "yarn run codegen && yarn run build"
},
"files": [
"generated"
],
"devDependencies": {
"@babel/core": "^7.25.2",
"@react-native/babel-preset": "0.81.0-main",
"react-native": "1000.0.0"
},
"peerDependencies": {
"react": "*",
"react-native": "*"
},
"codegenConfig": {
"name": "OSSLibraryExampleSpec",
"type": "all",
"jsSrcsDir": "src",
"outputDir": {
"ios": "ios",
"android": "android/src/main"
},
"includesGeneratedCode": true,
"android": {
"javaPackageName": "com.reactnative.osslibraryexample"
},
"ios": {
"componentProvider": {
"SampleNativeComponent": "RCTSampleNativeComponentComponentView"
}
}
}
}
@@ -0,0 +1,19 @@
/**
* 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.
*
* @format
* @noflow
*/
module.exports = {
dependency: {
platforms: {
android: {
cmakeListsPath: '../android/src/main/jni/CMakeLists.txt',
},
},
},
};
@@ -0,0 +1,19 @@
/**
* 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.
*
* @flow strict-local
* @format
*/
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import {TurboModuleRegistry} from 'react-native';
export interface Spec extends TurboModule {
+getRandomNumber: () => number;
}
export default (TurboModuleRegistry.get<Spec>('NativeSampleModule'): ?Spec);
@@ -0,0 +1,59 @@
/**
* 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.
*
* @flow strict-local
* @format
*/
import type {HostComponent} from 'react-native';
import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
import type {
BubblingEventHandler,
Double,
Float,
Int32,
} from 'react-native/Libraries/Types/CodegenTypes';
import * as React from 'react';
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
type Event = $ReadOnly<{
values: $ReadOnlyArray<Int32>,
boolValues: $ReadOnlyArray<boolean>,
floats: $ReadOnlyArray<Float>,
doubles: $ReadOnlyArray<Double>,
yesNos: $ReadOnlyArray<'yep' | 'nope'>,
strings: $ReadOnlyArray<string>,
latLons: $ReadOnlyArray<{lat: Double, lon: Double}>,
multiArrays: $ReadOnlyArray<$ReadOnlyArray<Int32>>,
}>;
type NativeProps = $ReadOnly<{
...ViewProps,
opacity?: Float,
values: $ReadOnlyArray<Int32>,
// Events
onIntArrayChanged?: ?BubblingEventHandler<Event>,
}>;
export type NativeComponentType = HostComponent<NativeProps>;
interface NativeCommands {
+changeBackgroundColor: (
viewRef: React.ElementRef<NativeComponentType>,
color: string,
) => void;
}
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
supportedCommands: ['changeBackgroundColor'],
});
export default (codegenNativeComponent<NativeProps>(
'SampleNativeComponent',
): NativeComponentType);
@@ -135,6 +135,10 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
private void init() {
setRootViewTag(ReactRootViewTagGenerator.getNextRootViewTag());
setClipChildren(false);
if (ReactNativeFeatureFlags.enableFontScaleChangesUpdatingLayout()) {
DisplayMetricsHolder.initDisplayMetrics(getContext().getApplicationContext());
}
}
@Override
+1
View File
@@ -54,6 +54,7 @@ def pods(target_name, options = {})
pod 'ScreenshotManager', :path => "NativeModuleExample"
pod 'MyNativeView', :path => "NativeComponentExample"
pod 'NativeCxxModuleExample', :path => "NativeCxxModuleExample"
pod 'OSSLibraryExample', :path => '../react-native-test-library'
end
target 'RNTester' do
+107 -197
View File
@@ -16,7 +16,7 @@ PODS:
- hermes-engine/inspector (1000.0.0)
- hermes-engine/inspector_chrome (1000.0.0)
- hermes-engine/Public (1000.0.0)
- MyNativeView (0.81.0-main):
- MyNativeView (0.80.0-main):
- boost
- DoubleConversion
- fast_float
@@ -44,7 +44,7 @@ PODS:
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- NativeCxxModuleExample (0.81.0-main):
- NativeCxxModuleExample (0.80.0-main):
- boost
- DoubleConversion
- fast_float
@@ -73,6 +73,34 @@ PODS:
- SocketRocket
- Yoga
- OCMock (3.9.4)
- OSSLibraryExample (0.80.0-main):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- hermes-engine
- RCT-Folly
- RCT-Folly/Fabric
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-jsi
- React-NativeModulesApple
- React-RCTFabric
- React-renderercss
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- RCT-Folly (2024.11.18.00):
- boost
- DoubleConversion
@@ -556,7 +584,6 @@ PODS:
- RCT-Folly
- RCT-Folly/Fabric
- React-Fabric
- React-Fabric/bridging
- React-FabricComponents
- React-graphics
- React-jsi
@@ -582,7 +609,6 @@ PODS:
- React-debug
- React-Fabric/animations (= 1000.0.0)
- React-Fabric/attributedstring (= 1000.0.0)
- React-Fabric/bridging (= 1000.0.0)
- React-Fabric/componentregistry (= 1000.0.0)
- React-Fabric/componentregistrynative (= 1000.0.0)
- React-Fabric/components (= 1000.0.0)
@@ -658,31 +684,6 @@ PODS:
- React-utils
- ReactCommon/turbomodule/core
- SocketRocket
- React-Fabric/bridging (1000.0.0):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- hermes-engine
- RCT-Folly
- RCT-Folly/Fabric
- RCTRequired
- RCTTypeSafety
- React-Core
- React-cxxreact
- React-debug
- React-featureflags
- React-graphics
- React-jsi
- React-jsiexecutor
- React-logger
- React-rendererdebug
- React-runtimeexecutor
- React-runtimescheduler
- React-utils
- ReactCommon/turbomodule/core
- SocketRocket
- React-Fabric/componentregistry (1000.0.0):
- boost
- DoubleConversion
@@ -1242,14 +1243,11 @@ PODS:
- React-FabricComponents/components/inputaccessory (= 1000.0.0)
- React-FabricComponents/components/iostextinput (= 1000.0.0)
- React-FabricComponents/components/modal (= 1000.0.0)
- React-FabricComponents/components/rncore (= 1000.0.0)
- React-FabricComponents/components/safeareaview (= 1000.0.0)
- React-FabricComponents/components/scrollview (= 1000.0.0)
- React-FabricComponents/components/text (= 1000.0.0)
- React-FabricComponents/components/textinput (= 1000.0.0)
- React-FabricComponents/components/unimplementedview (= 1000.0.0)
- React-FabricComponents/components/virtualview (= 1000.0.0)
- React-FabricComponents/components/virtualviewexperimental (= 1000.0.0)
- React-featureflags
- React-graphics
- React-jsi
@@ -1343,33 +1341,6 @@ PODS:
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- React-FabricComponents/components/rncore (1000.0.0):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- hermes-engine
- RCT-Folly
- RCT-Folly/Fabric
- RCTRequired
- RCTTypeSafety
- React-Core
- React-cxxreact
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-jsi
- React-jsiexecutor
- React-logger
- React-RCTFBReactNativeSpec
- React-rendererdebug
- React-runtimescheduler
- React-utils
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- React-FabricComponents/components/safeareaview (1000.0.0):
- boost
- DoubleConversion
@@ -1505,60 +1476,6 @@ PODS:
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- React-FabricComponents/components/virtualview (1000.0.0):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- hermes-engine
- RCT-Folly
- RCT-Folly/Fabric
- RCTRequired
- RCTTypeSafety
- React-Core
- React-cxxreact
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-jsi
- React-jsiexecutor
- React-logger
- React-RCTFBReactNativeSpec
- React-rendererdebug
- React-runtimescheduler
- React-utils
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- React-FabricComponents/components/virtualviewexperimental (1000.0.0):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- hermes-engine
- RCT-Folly
- RCT-Folly/Fabric
- RCTRequired
- RCTTypeSafety
- React-Core
- React-cxxreact
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-jsi
- React-jsiexecutor
- React-logger
- React-RCTFBReactNativeSpec
- React-rendererdebug
- React-runtimescheduler
- React-utils
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- React-FabricComponents/textlayoutmanager (1000.0.0):
- boost
- DoubleConversion
@@ -2205,18 +2122,7 @@ PODS:
- React-utils
- SocketRocket
- React-runtimeexecutor (1000.0.0):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- RCT-Folly
- RCT-Folly/Fabric
- React-debug
- React-featureflags
- React-jsi (= 1000.0.0)
- React-utils
- SocketRocket
- React-RuntimeHermes (1000.0.0):
- boost
- DoubleConversion
@@ -2377,7 +2283,7 @@ PODS:
- React-perflogger (= 1000.0.0)
- React-utils (= 1000.0.0)
- SocketRocket
- ScreenshotManager (0.81.0-main):
- ScreenshotManager (0.80.0-main):
- boost
- DoubleConversion
- fast_float
@@ -2419,6 +2325,7 @@ DEPENDENCIES:
- MyNativeView (from `NativeComponentExample`)
- NativeCxxModuleExample (from `NativeCxxModuleExample`)
- OCMock (~> 3.9.1)
- OSSLibraryExample (from `../react-native-test-library`)
- RCT-Folly (from `../react-native/third-party-podspecs/RCT-Folly.podspec`)
- RCTDeprecation (from `../react-native/ReactApple/Libraries/RCTFoundation/RCTDeprecation`)
- RCTRequired (from `../react-native/Libraries/Required`)
@@ -2515,6 +2422,8 @@ EXTERNAL SOURCES:
:path: NativeComponentExample
NativeCxxModuleExample:
:path: NativeCxxModuleExample
OSSLibraryExample:
:path: "../react-native-test-library"
RCT-Folly:
:podspec: "../react-native/third-party-podspecs/RCT-Folly.podspec"
RCTDeprecation:
@@ -2656,83 +2565,84 @@ SPEC CHECKSUMS:
boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90
DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
fast_float: b32c788ed9c6a8c584d114d0047beda9664e7cc6
FBLazyVector: a67ac982f94e725e28eb5fdf00ae785a88fee122
FBLazyVector: d3c2dd739a63c1a124e775df075dc7c517a719cb
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
hermes-engine: 3350cd88070588a0c3ebf47ea6f81ba28c7aaf9f
MyNativeView: f9ac5b43a4d23e7d40f2e7c4337b40fc98f645cc
NativeCxxModuleExample: 9abb81d71be6898827e6c0bb65b1715f6f3b75a2
hermes-engine: fd5605ca4043c8317548d649d0b64e5dafc2a124
MyNativeView: 9b03b64f5cd9220bf7ef49fcdfc468effe704fa0
NativeCxxModuleExample: 2897d5f3aee8a02dd201a3dd41fbc94ada1aac5e
OCMock: 589f2c84dacb1f5aaf6e4cec1f292551fe748e74
RCT-Folly: 59ec0ac1f2f39672a0c6e6cecdd39383b764646f
OSSLibraryExample: bf5b5a4238613dae3c536faff58f87528e6191cf
RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669
RCTDeprecation: 3808e36294137f9ee5668f4df2e73dc079cd1dcf
RCTRequired: 2122b76857162ff9aa7e211de2575089ffe611d6
RCTTypeSafety: cda30ca2aadf5786d66ba137b5c06d2190e697e9
React: 662099b139948fd652fa9dc369f2a6aece1e18b2
React-callinvoker: 49a5a4449dbb4830fdac6341be9027ebf8ffc3bf
React-Core: 7e0f44e57d0dc4a814c1be194e8667ca6ee052b7
React-CoreModules: a82c6f0d605188a1261b020b4c43cd5c39a9e57f
React-cxxreact: bec05af5ce328afa9428fafa6d33730400e4b68c
React-debug: 40cbf9f72c96613c639f12f7fcc9a6cb8d54f588
React-defaultsnativemodule: 68c0affa6e5c4de5db8352aac0ff53eeace95035
React-domnativemodule: b9dc5b7141dbfb65e53039aa708f342c24ca2d30
React-Fabric: 15cced8cd4c50826215448b633362106dcfb98d4
React-FabricComponents: f6ef214976c812eb2bb59f8e9d10f4ada46ffe12
React-FabricImage: 32b54b2b17d61df7b22a0ff8b78b57de1245a588
React-featureflags: d2a5f1ee99706701567ad6ffacfefe54bf839813
React-featureflagsnativemodule: 722fa94f9d7ac24632df7d178b845c77ac794d36
React-graphics: aae15c16655f51e02f4ba211f108bb591d02f82a
React-hermes: afd04a013d8e73fcea46019a38724097d410c53c
React-idlecallbacksnativemodule: fdb1f69e1725303cd2fb302c6c104b117871dabc
React-ImageManager: c2119408bc90c98b037eb418855eac8484b79987
React-jserrorhandler: 710e7a368c42914e44a9065ad0f878286511c181
React-jsi: 6b6955a311c687ce2560fac466ed7ea6ae1ba851
React-jsiexecutor: a1837ded1bd224b94d57e36ee72bd26299cb0624
React-jsinspector: 99852440c65d84257ed9bb1a9f6a943ab3b2dc53
React-jsinspectorcdp: 51b7b9e98f69a5f43a200286e0f1809b8be2e7d6
React-jsinspectornetwork: 31c2d9f486c87f670ae8d76c5eee606995e9a994
React-jsinspectortracing: af188edab74f98d132a4170013a4073f13e02323
React-jsitooling: c16793498697b5bf00b2b5245529f5ad1bd7dc03
React-jsitracing: 1e5621e281f794777dd6933960b63b4001ff6688
React-logger: 6be7039c28299972c00f0b326591085037f2224b
React-Mapbuffer: c7da77a5d048ec7d7e1e050b3f946551241a768c
React-microtasksnativemodule: 394af907fa98cc28f993ed949975c6f4d3d53f5f
React-NativeModulesApple: 15bfbf94f0a1286ee7bf4fe0b0d3e8a04a9a3f26
React-oscompat: 496762720e2a4dd97786fa08f788e3f8763404ea
React-perflogger: 64a1b6eac6ff95474c02c3ee1734c8752a7a1da8
React-performancetimeline: 5bfcaa23bc90980d8cc4f0d4dd92e08fbdd10638
React-RCTActionSheet: fda681f38788c81040b6e0aebd7050580d5fd74d
React-RCTAnimation: 983a1257c6ca45998848a2129d1ea9ada70824a6
React-RCTAppDelegate: 15a4c95028249abb71d2769b9d5ec158ce81a9f8
React-RCTBlob: 8986952d547b4c81e2827f7dfa9d8457b36c673b
React-RCTFabric: 511cc7ff0f99c790330855d20ce7e7a7d28f548a
React-RCTFBReactNativeSpec: b4a3bfa2a45af3dcdba1cd13285a7b5c7da29b21
React-RCTImage: e4fa15c647802b7ed6c7e405d40db829e2146d02
React-RCTLinking: dc1cc3b29036a58f7c828d1ca0a6b24ea7801a97
React-RCTNetwork: dffe5f8de5ea63ba22baace02df4b84438e09986
React-RCTPushNotification: 4d8081e9d2c636469b7098e137ff39d141643a18
React-RCTRuntime: 0abb761a26d449eacfdd47f378ae365b830076c8
React-RCTSettings: 9ba77f0aebce1bf71582ee8845db723b264039f6
React-RCTTest: 09f99c5f8b2e5e00b9fa6b796ae81fd162843b2d
React-RCTText: 58b4e7484e6ce4903e5a9333c9fb744b84b16a05
React-RCTVibration: b65dc9f78e1c5d482599205e4a52ec33815c7a1c
React-rendererconsistency: 0d60f7275a5f39b37c3753d548e72186562c3a48
React-renderercss: 88f92ff8dc85711a2ff861f815876cf8e312fe49
React-rendererdebug: fa30da9cdff3556e43a29c5fd5468faee8615850
React-RuntimeApple: 415a26184ba8fc6cf372f39d351665b73f0ceeaf
React-RuntimeCore: a875f3c5479b1fc07ca3ae0c0797c623baf6516e
React-runtimeexecutor: 344502ff6d944ae095379ee587cea61720812751
React-RuntimeHermes: 8e0734f0dd51840d957bc2f5216ea84a599dad03
React-runtimescheduler: e3d95a3e38dd7c30b1faffdd808cf915fec0c991
React-timing: 1c3682ededd5ab4158b7f065404b9c493d1f97f9
React-utils: 99cab5ff9f585e8f6d57d97f35d2d38e1d51b4b7
ReactAppDependencyProvider: b3db1f6073cd2d5085705f812a6eef258aa9a9d7
ReactCodegen: 17ffed80c08ee934120f5962a19c8cdae62615f9
ReactCommon: 8135b5504e1ddab9348bb09a7e6c829eb1b21bc6
ReactCommon-Samples: 0fc23e4c63e23897cc41f2f6867f5358e7e60806
ScreenshotManager: 3b0059e34e3ac8ec152874e4ac9b7a304216ecca
RCTRequired: a00614e2da5344c2cda3d287050b6cee00e21dc6
RCTTypeSafety: 459a16418c6b413060d35434ba3e83f5b0bd2651
React: 170a01a19ba2525ab7f11243e2df6b19bf268093
React-callinvoker: f08f425e4043cd1998a158b6e39a6aed1fd1d718
React-Core: d35c5cf69898fd026e5cd93a0454b1d42e999d3e
React-CoreModules: 3ce1d43f6cc37f43759ec543ce1c0010080f1de1
React-cxxreact: 3169b106af8f405e182d131d3a0844201e3252e2
React-debug: 195df38487d3f48a7af04deddeb4a5c6d4440416
React-defaultsnativemodule: 8afea5a4bd07addb523bf48489b8a684ea1bdff0
React-domnativemodule: 8a813559774e65bc800fe489bbb454cd546f21d7
React-Fabric: e9846203f11ab49be8b1329c76301bbd399ef2ad
React-FabricComponents: 032d6f01f1d6966633418c0fece18f698ddb7897
React-FabricImage: 264c9ce5241e43e25b94c8de55ac6c3c8a046472
React-featureflags: 595651ea13c63a9f77f06d9a1973b665b4a28b7e
React-featureflagsnativemodule: 06823479a2ee210cfa0e9c19447c2722a8d995f2
React-graphics: 1f99b9b5515eac389f0cf9c85b03abc366d6a933
React-hermes: 745eb45a6d0aae7e890d0aae0def54670bbd103c
React-idlecallbacksnativemodule: 4e65f183318b8a0fbabc481a4eafc0f0d62d1cbf
React-ImageManager: a6833445e17879933378b7c0ba45ee42115c14bc
React-jserrorhandler: bec134a192c50338193544404d45df24fb8a19ca
React-jsi: 4ad77650fb0ca4229569eb2532db7a87e3d12662
React-jsiexecutor: fa5b80bdbe1ceffc33a892da20fc07b4dfa4df7a
React-jsinspector: 10b5dc4eef2a3d05b80be2114ed676496c5bf59c
React-jsinspectorcdp: 5fb266e5f23d3a2819ba848e9d4d0b6b00f95934
React-jsinspectornetwork: 1655a81f3fe14789df41e063bd56dd130cc3562a
React-jsinspectortracing: 5b0be488e06958a572e1badfe8509929ae1cc83b
React-jsitooling: 9e563b89f94cf4baf872fe47105d60ae83f4ce4d
React-jsitracing: ce443686f52538d1033ce7db1e7d643e866262f0
React-logger: 116c3ae5a9906671d157aa00882a5ee75a5a7ebc
React-Mapbuffer: fc937cfa41140d7724c559c3d16c50dd725361c8
React-microtasksnativemodule: 09899c7389250279bdcc5384f0281bb069979855
React-NativeModulesApple: d05b718ccd8b68c184e76dbc1efb63385197595b
React-oscompat: 7133e0e945cda067ae36b22502df663d73002864
React-perflogger: ada3cdf3dfc8b7cd1fabe3c91b672e23981611ab
React-performancetimeline: e7d5849d89ee39557dcd56dfb6e7b0d49003d925
React-RCTActionSheet: 1bf8cc8086ad1c15da3407dfb7bc9dd94dc7595d
React-RCTAnimation: 263593e66c89bf810604b1ace15dfa382a1ca2df
React-RCTAppDelegate: 3a99437ffa7460f85045de65f9bed6b1c47d5f09
React-RCTBlob: 7b76230c53fe87d305eeeb250b0aae031bb6cbae
React-RCTFabric: 2fd2ef899c7219fd39fd61c39750510f88a81434
React-RCTFBReactNativeSpec: 4ed3b463eb26726b04ac65c73797207ecab5634c
React-RCTImage: de404b6b0ebe53976a97e3a0dee819c83e12977b
React-RCTLinking: 06742cfad41c506091403a414370743a4ed75af3
React-RCTNetwork: b4577eec0092c16d8996e415e4cac7a372d6d362
React-RCTPushNotification: ea11178d499696516e0ff9ae335edbe99b06f94b
React-RCTRuntime: 925039e78fc530e0421c308ccc607f214f3c7be1
React-RCTSettings: d3c2dd305ec81f7faf42762ec598d57f07fd43be
React-RCTTest: 2db46eda60bc2228cb67622a580e8e86b00088d9
React-RCTText: e416825b80c530647040ef91d23ffd35ccc87981
React-RCTVibration: 1837a27fc16eeffc9509779c3334fde54c012bcc
React-rendererconsistency: 777c894edc43dde01499189917ac54ee76ae6a6a
React-renderercss: a9cb6ba7f49a80dc4b4f7008bae1590d12f27049
React-rendererdebug: fea8bde927403a198742b2d940a5f1cd8230c0b4
React-RuntimeApple: 6a0c164a8855edb4987b90da2d4d8601302de72d
React-RuntimeCore: 6dec37113b759b76641bd028bfbbbec8cf923356
React-runtimeexecutor: a16a24b964e964afe833a652d703e1bb39f10dc9
React-RuntimeHermes: d4f661204d3061219a63951eb4efed4dcaf3f12f
React-runtimescheduler: ae44fe8b4170a9d59f62e8b7d7b060c179db739d
React-timing: 9d49179631e5e3c759e6e82d4c613c73da80a144
React-utils: 0944df8d553d66b27f486282c42a84a969fd2f6c
ReactAppDependencyProvider: 68f2d2cefd6c9b9f2865246be2bfe86ebd49238d
ReactCodegen: 8fc4c8b6562a59409b5650e67f78719093d093bf
ReactCommon: a53973ab35d399560ace331ec9e2b26db0592cec
ReactCommon-Samples: dcc128cbf51ac38d2578791750d0a046d1b8a5e9
ScreenshotManager: 6ac0b11c7bbd5cf1abd9448fb3b856fe6fd65ff7
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: d4ae2f851e524b23cb324409594f60bc3f091403
Yoga: c4e80f1c2235fa6236d71a49e5bb2ee74d987921
PODFILE CHECKSUM: 995beda3236c2c76801e7a4efc7fedcd390220e6
PODFILE CHECKSUM: 8591f96a513620a2a83a0b9a125ad3fa32ea1369
COCOAPODS: 1.15.2
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
</manifest>
@@ -50,6 +50,7 @@
</queries>
<application
android:usesCleartextTraffic="${usesCleartextTraffic}"
android:name=".RNTesterApplication"
android:allowBackup="true"
android:banner="@drawable/tv_banner"
@@ -26,6 +26,7 @@ import com.facebook.react.defaults.DefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.module.model.ReactModuleInfo
import com.facebook.react.module.model.ReactModuleInfoProvider
import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage
import com.facebook.react.popupmenu.PopupMenuPackage
import com.facebook.react.shell.MainReactPackage
import com.facebook.react.soloader.OpenSourceMergedSoMapping
@@ -53,6 +54,7 @@ internal class RNTesterApplication : Application(), ReactApplication {
return listOf(
MainReactPackage(),
PopupMenuPackage(),
OSSLibraryExamplePackage(),
object : BaseReactPackage() {
override fun getModule(
name: String,
@@ -0,0 +1,130 @@
/**
* 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.
*
* @flow
* @format
*/
'use strict';
import type {RNTesterModuleExample} from '../../types/RNTesterTypes';
import type {NativeComponentType} from '@react-native/oss-library-example';
import RNTesterText from '../../components/RNTesterText';
import {
SampleNativeComponent,
SampleNativeComponentCommands,
} from '@react-native/oss-library-example';
import {NativeSampleModule} from '@react-native/oss-library-example';
import * as React from 'react';
import {useRef, useState} from 'react';
import {Button, View} from 'react-native';
import {StyleSheet} from 'react-native';
const colors = [
'#0000FF',
'#FF0000',
'#00FF00',
'#003300',
'#330000',
'#000033',
];
// $FlowFixMe[value-as-type]
const styles: StyleSheet = StyleSheet.create({
container: {
flex: 1,
},
column: {
flex: 2,
justifyContent: 'center',
paddingLeft: 5,
paddingRight: 5,
},
});
function SampleNativeComponentContainer(props: {}): React.Node {
const ref = useRef<React.ElementRef<NativeComponentType> | null>(null);
const [opacity, setOpacity] = useState(1.0);
const [arrayValues, setArrayValues] = useState([1, 2, 3]);
return (
<View style={{flex: 1}}>
<SampleNativeComponent
ref={ref}
style={{flex: 1}}
opacity={opacity}
values={arrayValues}
onIntArrayChanged={event => {
console.log(event.nativeEvent.values);
console.log(event.nativeEvent.boolValues);
console.log(event.nativeEvent.floats);
console.log(event.nativeEvent.doubles);
console.log(event.nativeEvent.yesNos);
console.log(event.nativeEvent.strings);
console.log(event.nativeEvent.latLons);
console.log(event.nativeEvent.multiArrays);
}}
/>
<Button
title="Change Background"
onPress={() => {
let newColor = colors[Math.floor(Math.random() * 5)];
SampleNativeComponentCommands.changeBackgroundColor(
// $FlowFixMe[incompatible-call]
ref.current,
newColor,
);
}}
/>
<Button
title="Set Opacity"
onPress={() => {
setOpacity(Math.random());
setArrayValues([
Math.floor(Math.random() * 100),
Math.floor(Math.random() * 100),
Math.floor(Math.random() * 100),
]);
}}
/>
</View>
);
}
function NativeSampleModuleWrapper(props: {}): React.Node {
const [randomNumber, setRandomNumber] = useState(0);
return (
<View style={styles.container}>
<Button
title="Get Random Number"
onPress={() => {
const x = NativeSampleModule?.getRandomNumber();
if (x != null) {
setRandomNumber(x);
}
}}
/>
<RNTesterText style={styles.column}>{randomNumber}</RNTesterText>
</View>
);
}
exports.title = 'OSS Library Example';
exports.description = 'OSS Library Example.';
exports.examples = [
{
title: 'OSS Library Example',
description: 'Click to change background and opacity',
render(): React.MixedElement {
return (
<>
<SampleNativeComponentContainer />
<NativeSampleModuleWrapper />
</>
);
},
},
] as Array<RNTesterModuleExample>;
@@ -146,6 +146,10 @@ const Components: Array<RNTesterModuleInfo> = [
category: 'Basic',
module: require('../examples/Performance/PerformanceComparisonExample'),
},
{
key: 'OSSLibraryExample',
module: require('../examples/OSSLibraryExample/OSSLibraryExample'),
},
...RNTesterListFbInternal.Components,
];
@@ -154,6 +154,10 @@ const Components: Array<RNTesterModuleInfo> = [
category: 'Basic',
module: require('../examples/Performance/PerformanceComparisonExample'),
},
{
key: 'OSSLibraryExample',
module: require('../examples/OSSLibraryExample/OSSLibraryExample'),
},
...RNTesterListFbInternal.Components,
];
+1
View File
@@ -31,6 +31,7 @@ const config = {
path.resolve(__dirname, '../normalize-color'),
path.resolve(__dirname, '../polyfills'),
path.resolve(__dirname, '../react-native'),
path.resolve(__dirname, '../react-native-test-library'),
path.resolve(__dirname, '../virtualized-lists'),
path.resolve(__dirname, '../react-native-popup-menu-android'),
],
+1
View File
@@ -26,6 +26,7 @@
"e2e-test-ios": "./scripts/maestro-test-ios.sh"
},
"dependencies": {
"@react-native/oss-library-example": "0.81.0-main",
"@react-native/new-app-screen": "0.81.0-main",
"@react-native/popup-menu-android": "0.81.0-main",
"flow-enums-runtime": "^0.0.6",