diff --git a/.circleci/config.yml b/.circleci/config.yml index aba87bae8d2d66..c77a41c2d4bd75 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,6 +30,17 @@ references: attach_workspace: at: *hermes_workspace_root + # ------------------------- + # Dependency Anchors + # ------------------------- + dependency_versions: + # The Xcode version used on CircleCI OSS tests must be kept in sync with + # the Xcode version used on Sandcastle OSS tests. See _XCODE_VERSION in + # tools/utd/migrated_nbtd_jobs/react_native_oss.td + xcode_version: &xcode_version "13.3.1" + nodelts_image: &nodelts_image "cimg/node:16.14" + nodeprevlts_image: &nodeprevlts_image "cimg/node:14.19" + # ------------------------- # Cache Key Anchors # ------------------------- @@ -71,12 +82,12 @@ executors: <<: *defaults docker: # Note: Version set separately for Windows builds, see below. - - image: cimg/node:16.14 + - image: *nodelts_image resource_class: "xlarge" nodeprevlts: <<: *defaults docker: - - image: cimg/node:14.19 + - image: *nodeprevlts_image resource_class: "xlarge" reactnativeandroid: <<: *defaults @@ -96,7 +107,7 @@ executors: reactnativeios: <<: *defaults macos: - xcode: &_XCODE_VERSION "13.3.0" + xcode: *xcode_version resource_class: macos.x86.medium.gen2 # ------------------------- diff --git a/.github/workflows/danger_pr.yml b/.github/workflows/danger_pr.yml index 8d93b77c41014e..4cde18a216d7eb 100644 --- a/.github/workflows/danger_pr.yml +++ b/.github/workflows/danger_pr.yml @@ -12,7 +12,8 @@ jobs: - run: yarn install working-directory: bots - name: Danger - run: yarn danger ci --use-github-checks --failOnErrors --id danger_pr + run: DANGER_GITHUB_API_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" yarn danger ci --use-github-checks --failOnErrors --id danger_pr working-directory: bots env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PUBLIC_PULLBOT_GITHUB_TOKEN_A: a6edf8e8d40ce4e8b11a + PUBLIC_PULLBOT_GITHUB_TOKEN_B: 150e1341f4dd9c944d2a diff --git a/Libraries/Animated/NativeAnimatedHelper.js b/Libraries/Animated/NativeAnimatedHelper.js index 8566df5172cfd5..629f13ab0bb68b 100644 --- a/Libraries/Animated/NativeAnimatedHelper.js +++ b/Libraries/Animated/NativeAnimatedHelper.js @@ -139,6 +139,14 @@ const API = { invariant(NativeAnimatedModule, 'Native animated module is not available'); flushQueueTimeout = null; + // Early returns before calling any APIs + if (useSingleOpBatching && singleOpQueue.length === 0) { + return; + } + if (!useSingleOpBatching && queue.length === 0) { + return; + } + if (useSingleOpBatching) { // Set up event listener for callbacks if it's not set up if ( diff --git a/Libraries/Animated/nodes/AnimatedProps.js b/Libraries/Animated/nodes/AnimatedProps.js index 76576de422ff23..44e4759750e741 100644 --- a/Libraries/Animated/nodes/AnimatedProps.js +++ b/Libraries/Animated/nodes/AnimatedProps.js @@ -41,11 +41,7 @@ class AnimatedProps extends AnimatedNode { for (const key in this._props) { const value = this._props[key]; if (value instanceof AnimatedNode) { - if (!value.__isNative || value instanceof AnimatedStyle) { - // We cannot use value of natively driven nodes this way as the value we have access from - // JS may not be up to date. - props[key] = value.__getValue(); - } + props[key] = value.__getValue(); } else if (value instanceof AnimatedEvent) { props[key] = value.__getHandler(); } else { diff --git a/Libraries/Animated/nodes/AnimatedStyle.js b/Libraries/Animated/nodes/AnimatedStyle.js index 92dfb3cc7c041d..0d70430b872681 100644 --- a/Libraries/Animated/nodes/AnimatedStyle.js +++ b/Libraries/Animated/nodes/AnimatedStyle.js @@ -39,11 +39,7 @@ class AnimatedStyle extends AnimatedWithChildren { for (const key in style) { const value = style[key]; if (value instanceof AnimatedNode) { - if (!value.__isNative) { - // We cannot use value of natively driven nodes this way as the value we have access from - // JS may not be up to date. - updatedStyle[key] = value.__getValue(); - } + updatedStyle[key] = value.__getValue(); } else if (value && !Array.isArray(value) && typeof value === 'object') { // Support animating nested values (for example: shadowOffset.height) updatedStyle[key] = this._walkStyleAndGetValues(value); diff --git a/Libraries/BatchedBridge/MessageQueue.js b/Libraries/BatchedBridge/MessageQueue.js index 9964abb6506e48..ed32d725da1d27 100644 --- a/Libraries/BatchedBridge/MessageQueue.js +++ b/Libraries/BatchedBridge/MessageQueue.js @@ -404,15 +404,22 @@ class MessageQueue { this.__spy({type: TO_JS, module, method, args}); } const moduleMethods = this.getCallableModule(module); - invariant( - !!moduleMethods, - `Module ${module} is not a registered callable module (calling ${method}). A frequent cause of the error is that the application entry file path is incorrect. - This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`, - ); - invariant( - !!moduleMethods[method], - `Method ${method} does not exist on module ${module}`, - ); + if (!moduleMethods) { + const callableModuleNames = Object.keys(this._lazyCallableModules); + const n = callableModuleNames.length; + const callableModuleNameList = callableModuleNames.join(', '); + invariant( + false, + `Failed to call into JavaScript module method ${module}.${method}(). Module has not been registered as callable. Registered callable JavaScript modules (n = ${n}): ${callableModuleNameList}. + A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`, + ); + } + if (!moduleMethods[method]) { + invariant( + false, + `Failed to call into JavaScript module method ${module}.${method}(). Module exists, but the method is undefined.`, + ); + } moduleMethods[method].apply(moduleMethods, args); Systrace.endEvent(); } diff --git a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js index 2edb9ed76690db..c94f580a1cbf42 100644 --- a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js +++ b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js @@ -108,8 +108,8 @@ describe('MessageQueue', function () { const unknownModule = 'UnknownModule', unknownMethod = 'UnknownMethod'; expect(() => queue.__callFunction(unknownModule, unknownMethod)).toThrow( - `Module ${unknownModule} is not a registered callable module (calling ${unknownMethod}). A frequent cause of the error is that the application entry file path is incorrect. - This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`, + `Failed to call into JavaScript module method ${unknownModule}.${unknownMethod}(). Module has not been registered as callable. Registered callable JavaScript modules (n = 1): MessageQueueTestModule. + A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`, ); }); diff --git a/React/CxxUtils/RCTFollyConvert.mm b/React/CxxUtils/RCTFollyConvert.mm index 4efcdcd3d8bf2f..f890c86ab4f75d 100644 --- a/React/CxxUtils/RCTFollyConvert.mm +++ b/React/CxxUtils/RCTFollyConvert.mm @@ -31,15 +31,22 @@ id convertFollyDynamicToId(const folly::dynamic &dyn) return [[NSString alloc] initWithBytes:dyn.c_str() length:dyn.size() encoding:NSUTF8StringEncoding]; case folly::dynamic::ARRAY: { NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:dyn.size()]; - for (auto &elem : dyn) { - [array addObject:convertFollyDynamicToId(elem)]; + for (const auto &elem : dyn) { + id value = convertFollyDynamicToId(elem); + if (value) { + [array addObject:value]; + } } return array; } case folly::dynamic::OBJECT: { NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:dyn.size()]; - for (auto &elem : dyn.items()) { - dict[convertFollyDynamicToId(elem.first)] = convertFollyDynamicToId(elem.second); + for (const auto &elem : dyn.items()) { + id key = convertFollyDynamicToId(elem.first); + id value = convertFollyDynamicToId(elem.second); + if (key && value) { + dict[key] = value; + } } return dict; } diff --git a/React/Fabric/RCTSurfacePresenter.mm b/React/Fabric/RCTSurfacePresenter.mm index 65e4c0095e618d..df612c2bbada53 100644 --- a/React/Fabric/RCTSurfacePresenter.mm +++ b/React/Fabric/RCTSurfacePresenter.mm @@ -289,7 +289,6 @@ - (RCTScheduler *)_createScheduler auto weakRuntimeScheduler = _contextContainer->find>("RuntimeScheduler"); auto runtimeScheduler = weakRuntimeScheduler.has_value() ? weakRuntimeScheduler.value().lock() : nullptr; if (runtimeScheduler) { - runtimeScheduler->setEnableYielding(true); runtimeExecutor = [runtimeScheduler](std::function &&callback) { runtimeScheduler->scheduleWork(std::move(callback)); }; diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/Android.mk b/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/Android.mk deleted file mode 100644 index 32f5844a453457..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/Android.mk +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - - -LOCAL_PATH := $(call my-dir) -REACT_NATIVE := $(LOCAL_PATH)/../../../../../../../.. - -include $(CLEAR_VARS) - -LOCAL_MODULE := jsijniprofiler - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi - -LOCAL_CPP_FEATURES := exceptions - -LOCAL_STATIC_LIBRARIES := libjsireact -LOCAL_SHARED_LIBRARIES := \ - libfb \ - libfbjni \ - libfolly_runtime \ - libhermes \ - libjsi \ - libreactnativejni - -include $(BUILD_SHARED_LIBRARY) - diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/Android.mk b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/Android.mk deleted file mode 100644 index be0d150037e2fc..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/Android.mk +++ /dev/null @@ -1,52 +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. - -LOCAL_PATH := $(call my-dir) -REACT_NATIVE := $(LOCAL_PATH)/../../../../../../../.. - -ifeq ($(APP_OPTIM),debug) - include $(CLEAR_VARS) - - LOCAL_MODULE := hermes-executor-debug - LOCAL_CFLAGS := -DHERMES_ENABLE_DEBUGGER=1 - - LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - - LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi - - LOCAL_CPP_FEATURES := exceptions - - LOCAL_STATIC_LIBRARIES := libjsireact libhermes-executor-common-debug - LOCAL_SHARED_LIBRARIES := \ - libfb \ - libfbjni \ - libfolly_runtime \ - libhermes \ - libjsi \ - libreactnativejni - - include $(BUILD_SHARED_LIBRARY) -else - include $(CLEAR_VARS) - - LOCAL_MODULE := hermes-executor-release - - LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - - LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi - - LOCAL_CPP_FEATURES := exceptions - - LOCAL_STATIC_LIBRARIES := libjsireact libhermes-executor-common-release - LOCAL_SHARED_LIBRARIES := \ - libfb \ - libfbjni \ - libfolly_runtime \ - libhermes \ - libjsi \ - libreactnativejni - - include $(BUILD_SHARED_LIBRARY) -endif diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 4f1aa1a747a6a1..f746f398f7ce72 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -338,7 +338,7 @@ public void requestChildFocus(View child, View focused) { super.requestChildFocus(child, focused); } - private void dispatchJSPointerEvent(MotionEvent event) { + protected void dispatchJSPointerEvent(MotionEvent event) { if (mReactInstanceManager == null || !mIsAttachedToInstance || mReactInstanceManager.getCurrentReactContext() == null) { @@ -361,7 +361,7 @@ private void dispatchJSPointerEvent(MotionEvent event) { } } - private void dispatchJSTouchEvent(MotionEvent event) { + protected void dispatchJSTouchEvent(MotionEvent event) { if (mReactInstanceManager == null || !mIsAttachedToInstance || mReactInstanceManager.getCurrentReactContext() == null) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java index af25f450616149..275fcdea53fa57 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java @@ -1047,6 +1047,7 @@ public void queueAndExecuteBatchedOperations(final ReadableArray opsAndArgs) { BatchExecutionOpCodes command = BatchExecutionOpCodes.fromId(opsAndArgs.getInt(i++)); switch (command) { case OP_CODE_GET_VALUE: + case OP_START_LISTENING_TO_ANIMATED_NODE_VALUE: case OP_STOP_LISTENING_TO_ANIMATED_NODE_VALUE: case OP_CODE_STOP_ANIMATION: case OP_CODE_FLATTEN_ANIMATED_NODE_OFFSET: @@ -1059,7 +1060,6 @@ public void queueAndExecuteBatchedOperations(final ReadableArray opsAndArgs) { break; case OP_CODE_CREATE_ANIMATED_NODE: case OP_CODE_UPDATE_ANIMATED_NODE_CONFIG: - case OP_START_LISTENING_TO_ANIMATED_NODE_VALUE: case OP_CODE_CONNECT_ANIMATED_NODES: case OP_CODE_DISCONNECT_ANIMATED_NODES: case OP_CODE_SET_ANIMATED_NODE_VALUE: @@ -1115,7 +1115,6 @@ public void execute(NativeAnimatedNodesManager animatedNodesManager) { break; case OP_START_LISTENING_TO_ANIMATED_NODE_VALUE: final int tag = opsAndArgs.getInt(i++); - final int value = opsAndArgs.getInt(i++); final AnimatedNodeValueListener listener = new AnimatedNodeValueListener() { public void onValueUpdate(double value) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/Android.mk deleted file mode 100644 index 48f83b0da7dbf3..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/Android.mk +++ /dev/null @@ -1,49 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := mapbufferjni - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/react/common/mapbuffer/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_SHARED_LIBRARIES := \ - libfb \ - libfbjni \ - libglog \ - libglog_init \ - libreact_debug \ - libreact_render_mapbuffer \ - libreact_utils \ - libreact_config \ - libyoga - -LOCAL_STATIC_LIBRARIES := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,fbgloginit) -$(call import-module,folly) -$(call import-module,fb) -$(call import-module,fbjni) -$(call import-module,yogajni) -$(call import-module,glog) - -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,react/config) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 1516c841e1dab3..6816b08ebe2485 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -74,16 +74,8 @@ public class ReactFeatureFlags { /** Feature flag to configure synchronized queue access for Animated module */ public static boolean enableSynchronizationForAnimated = false; - private static boolean mapBufferSerializationEnabled = false; - /** Enables or disables MapBuffer Serialization */ - public static void setMapBufferSerializationEnabled(boolean enabled) { - mapBufferSerializationEnabled = enabled; - } - - public static boolean isMapBufferSerializationEnabled() { - return mapBufferSerializationEnabled; - } + public static boolean mapBufferSerializationEnabled = false; /** Feature Flag to use overflowInset values provided by Yoga */ public static boolean useOverflowInset = false; @@ -116,4 +108,15 @@ public static boolean isMapBufferSerializationEnabled() { /** Feature Flag to control RN Android scrollEventThrottle prop. */ public static boolean enableScrollEventThrottle = false; + + /** + * Feature flag that controls how turbo modules are exposed to JS + * + * + */ + public static int turboModuleBindingMode = 0; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java index b381aec166722a..bbb76d993b251d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java @@ -45,7 +45,7 @@ public UIManager get() { Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.registerBinding"); final Binding binding = new Binding(); - if (ReactFeatureFlags.isMapBufferSerializationEnabled()) { + if (ReactFeatureFlags.mapBufferSerializationEnabled) { MapBufferSoLoader.staticInit(); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 57d669b395c0dd..642dd331dbaae0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -109,6 +109,54 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { public static final boolean ENABLE_FABRIC_PERF_LOGS = ENABLE_FABRIC_LOGS || false; public DevToolsReactPerfLogger mDevToolsReactPerfLogger; + private static final DevToolsReactPerfLogger.DevToolsReactPerfLoggerListener FABRIC_PERF_LOGGER = + new DevToolsReactPerfLogger.DevToolsReactPerfLoggerListener() { + @Override + public void onFabricCommitEnd(DevToolsReactPerfLogger.FabricCommitPoint commitPoint) { + long commitDuration = commitPoint.getCommitDuration(); + long layoutDuration = commitPoint.getLayoutDuration(); + long diffDuration = commitPoint.getDiffDuration(); + long transactionEndDuration = commitPoint.getTransactionEndDuration(); + long batchExecutionDuration = commitPoint.getBatchExecutionDuration(); + + DevToolsReactPerfLogger.mStreamingCommitStats.add(commitDuration); + DevToolsReactPerfLogger.mStreamingLayoutStats.add(layoutDuration); + DevToolsReactPerfLogger.mStreamingDiffStats.add(diffDuration); + DevToolsReactPerfLogger.mStreamingTransactionEndStats.add(transactionEndDuration); + DevToolsReactPerfLogger.mStreamingBatchExecutionStats.add(batchExecutionDuration); + + FLog.i( + TAG, + "Statistics of Fabric commit #%d:\n" + + " - Total commit time: %d ms. Avg: %.2f. Median: %.2f ms. Max: %d ms.\n" + + " - Layout time: %d ms. Avg: %.2f. Median: %.2f ms. Max: %d ms.\n" + + " - Diffing time: %d ms. Avg: %.2f. Median: %.2f ms. Max: %d ms.\n" + + " - FinishTransaction (Diffing + JNI serialization): %d ms. Avg: %.2f. Median: %.2f ms. Max: %d ms.\n" + + " - Mounting: %d ms. Avg: %.2f. Median: %.2f ms. Max: %d ms.\n", + commitPoint.getCommitNumber(), + commitDuration, + DevToolsReactPerfLogger.mStreamingCommitStats.getAverage(), + DevToolsReactPerfLogger.mStreamingCommitStats.getMedian(), + DevToolsReactPerfLogger.mStreamingCommitStats.getMax(), + layoutDuration, + DevToolsReactPerfLogger.mStreamingLayoutStats.getAverage(), + DevToolsReactPerfLogger.mStreamingLayoutStats.getMedian(), + DevToolsReactPerfLogger.mStreamingLayoutStats.getMax(), + diffDuration, + DevToolsReactPerfLogger.mStreamingDiffStats.getAverage(), + DevToolsReactPerfLogger.mStreamingDiffStats.getMedian(), + DevToolsReactPerfLogger.mStreamingDiffStats.getMax(), + transactionEndDuration, + DevToolsReactPerfLogger.mStreamingTransactionEndStats.getAverage(), + DevToolsReactPerfLogger.mStreamingTransactionEndStats.getMedian(), + DevToolsReactPerfLogger.mStreamingTransactionEndStats.getMax(), + batchExecutionDuration, + DevToolsReactPerfLogger.mStreamingBatchExecutionStats.getAverage(), + DevToolsReactPerfLogger.mStreamingBatchExecutionStats.getMedian(), + DevToolsReactPerfLogger.mStreamingBatchExecutionStats.getMax()); + } + }; + static { FabricSoLoader.staticInit(); } @@ -369,53 +417,8 @@ public void initialize() { mEventDispatcher.addBatchEventDispatchedListener(mEventBeatManager); if (ENABLE_FABRIC_PERF_LOGS) { mDevToolsReactPerfLogger = new DevToolsReactPerfLogger(); - mDevToolsReactPerfLogger.addDevToolsReactPerfLoggerListener( - new DevToolsReactPerfLogger.DevToolsReactPerfLoggerListener() { - @Override - public void onFabricCommitEnd(DevToolsReactPerfLogger.FabricCommitPoint commitPoint) { - long commitDuration = commitPoint.getCommitDuration(); - long layoutDuration = commitPoint.getLayoutDuration(); - long diffDuration = commitPoint.getDiffDuration(); - long transactionEndDuration = commitPoint.getTransactionEndDuration(); - long batchExecutionDuration = commitPoint.getBatchExecutionDuration(); - - DevToolsReactPerfLogger.mStreamingCommitStats.add(commitDuration); - DevToolsReactPerfLogger.mStreamingLayoutStats.add(layoutDuration); - DevToolsReactPerfLogger.mStreamingDiffStats.add(diffDuration); - DevToolsReactPerfLogger.mStreamingTransactionEndStats.add(transactionEndDuration); - DevToolsReactPerfLogger.mStreamingBatchExecutionStats.add(batchExecutionDuration); - - FLog.i( - TAG, - "Statistics of Fabric commit #%d:\n" - + " - Total commit time: %d ms. Avg: %.2f. Median: %.2f ms. Max: %d ms.\n" - + " - Layout time: %d ms. Avg: %.2f. Median: %.2f ms. Max: %d ms.\n" - + " - Diffing time: %d ms. Avg: %.2f. Median: %.2f ms. Max: %d ms.\n" - + " - FinishTransaction (Diffing + JNI serialization): %d ms. Avg: %.2f. Median: %.2f ms. Max: %d ms.\n" - + " - Mounting: %d ms. Avg: %.2f. Median: %.2f ms. Max: %d ms.\n", - commitPoint.getCommitNumber(), - commitDuration, - DevToolsReactPerfLogger.mStreamingCommitStats.getAverage(), - DevToolsReactPerfLogger.mStreamingCommitStats.getMedian(), - DevToolsReactPerfLogger.mStreamingCommitStats.getMax(), - layoutDuration, - DevToolsReactPerfLogger.mStreamingLayoutStats.getAverage(), - DevToolsReactPerfLogger.mStreamingLayoutStats.getMedian(), - DevToolsReactPerfLogger.mStreamingLayoutStats.getMax(), - diffDuration, - DevToolsReactPerfLogger.mStreamingDiffStats.getAverage(), - DevToolsReactPerfLogger.mStreamingDiffStats.getMedian(), - DevToolsReactPerfLogger.mStreamingDiffStats.getMax(), - transactionEndDuration, - DevToolsReactPerfLogger.mStreamingTransactionEndStats.getAverage(), - DevToolsReactPerfLogger.mStreamingTransactionEndStats.getMedian(), - DevToolsReactPerfLogger.mStreamingTransactionEndStats.getMax(), - batchExecutionDuration, - DevToolsReactPerfLogger.mStreamingBatchExecutionStats.getAverage(), - DevToolsReactPerfLogger.mStreamingBatchExecutionStats.getMedian(), - DevToolsReactPerfLogger.mStreamingBatchExecutionStats.getMax()); - } - }); + mDevToolsReactPerfLogger.addDevToolsReactPerfLoggerListener(FABRIC_PERF_LOGGER); + ReactMarker.addFabricListener(mDevToolsReactPerfLogger); } } @@ -428,6 +431,7 @@ public void onCatalystInstanceDestroy() { FLog.i(TAG, "FabricUIManager.onCatalystInstanceDestroy"); if (mDevToolsReactPerfLogger != null) { + mDevToolsReactPerfLogger.removeDevToolsReactPerfLoggerListener(FABRIC_PERF_LOGGER); ReactMarker.removeFabricListener(mDevToolsReactPerfLogger); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk deleted file mode 100644 index a32e9e10d1d5b8..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk +++ /dev/null @@ -1,105 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := fabricjni - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_SHARED_LIBRARIES := \ - libbutter \ - libfb \ - libfbjni \ - libfolly_runtime \ - libglog \ - libglog_init \ - libjsi \ - libmapbufferjni \ - libreact_codegen_rncore \ - libreact_debug \ - libreact_render_animations \ - libreact_render_attributedstring \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_imagemanager \ - libreact_render_mapbuffer \ - libreact_render_mounting \ - libreact_render_runtimescheduler \ - libreact_render_scheduler \ - libreact_render_telemetry \ - libreact_render_templateprocessor \ - libreact_render_textlayoutmanager \ - libreact_render_uimanager \ - libreact_utils \ - libreact_config \ - libreactnativeutilsjni \ - librrc_image \ - librrc_root \ - librrc_unimplementedview \ - librrc_view \ - libyoga \ - react_render_componentregistry \ - rrc_text - -LOCAL_STATIC_LIBRARIES := \ - librrc_slider \ - librrc_progressbar \ - librrc_switch \ - librrc_modal \ - librrc_scrollview \ - librrc_textinput - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,fbgloginit) -$(call import-module,folly) -$(call import-module,fb) -$(call import-module,fbjni) -$(call import-module,yogajni) -$(call import-module,glog) - -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,react/config) -$(call import-module,react/renderer/animations) -$(call import-module,react/renderer/attributedstring) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/components/image) -$(call import-module,react/renderer/components/modal) -$(call import-module,react/renderer/components/root) -$(call import-module,react/renderer/components/progressbar) -$(call import-module,react/renderer/components/scrollview) -$(call import-module,react/renderer/components/slider) -$(call import-module,react/renderer/components/switch) -$(call import-module,react/renderer/components/text) -$(call import-module,react/renderer/components/textinput) -$(call import-module,react/renderer/components/unimplementedview) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/imagemanager) -$(call import-module,react/renderer/mapbuffer) -$(call import-module,react/renderer/mounting) -$(call import-module,react/renderer/runtimescheduler) -$(call import-module,react/renderer/scheduler) -$(call import-module,react/renderer/templateprocessor) -$(call import-module,react/renderer/textlayoutmanager) -$(call import-module,react/renderer/uimanager) -$(call import-module,react/renderer/telemetry) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index 491288cd68d568..9957bfebdb947e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -78,25 +78,17 @@ Binding::getInspectorDataForInstance( return ReadableNativeMap::newObjectCxxArgs(result); } -bool getFeatureFlagValue(const char *name) { +constexpr static auto ReactFeatureFlagsJavaDescriptor = + "com/facebook/react/config/ReactFeatureFlags"; + +static bool getFeatureFlagValue(const char *name) { static const auto reactFeatureFlagsJavaDescriptor = - jni::findClassStatic(Binding::ReactFeatureFlagsJavaDescriptor); + jni::findClassStatic(ReactFeatureFlagsJavaDescriptor); const auto field = reactFeatureFlagsJavaDescriptor->getStaticField(name); return reactFeatureFlagsJavaDescriptor->getStaticFieldValue(field); } -bool isMapBufferSerializationEnabled() { - static const auto reactFeatureFlagsJavaDescriptor = - jni::findClassStatic(Binding::ReactFeatureFlagsJavaDescriptor); - static const auto isMapBufferSerializationEnabledMethod = - reactFeatureFlagsJavaDescriptor->getStaticMethod( - "isMapBufferSerializationEnabled"); - bool value = - isMapBufferSerializationEnabledMethod(reactFeatureFlagsJavaDescriptor); - return value; -} - void Binding::setPixelDensity(float pointScaleFactor) { pointScaleFactor_ = pointScaleFactor; } @@ -401,8 +393,6 @@ void Binding::installFabricUIManager( if (runtimeSchedulerHolder) { auto runtimeScheduler = runtimeSchedulerHolder->cthis()->get().lock(); if (runtimeScheduler) { - runtimeScheduler->setEnableYielding(config->getBool( - "react_native_new_architecture:runtimescheduler_enable_yielding_android")); runtimeExecutor = [runtimeScheduler]( std::function &&callback) { @@ -438,7 +428,8 @@ void Binding::installFabricUIManager( reactNativeConfig_ = config; contextContainer->insert( - "MapBufferSerializationEnabled", isMapBufferSerializationEnabled()); + "MapBufferSerializationEnabled", + getFeatureFlagValue("mapBufferSerializationEnabled")); disablePreallocateViews_ = reactNativeConfig_->getBool( "react_fabric:disabled_view_preallocation_android"); diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h index 38a392e929be32..ddfe7a5018b742 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h @@ -38,9 +38,6 @@ class Binding : public jni::HybridClass, constexpr static const char *const kJavaDescriptor = "Lcom/facebook/react/fabric/Binding;"; - constexpr static auto ReactFeatureFlagsJavaDescriptor = - "com/facebook/react/config/ReactFeatureFlags"; - static void registerNatives(); std::shared_ptr getScheduler(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/LayoutMetricsConversions.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/LayoutMetricsConversions.java index dba4d35cd67c0e..3054a94ae3e548 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/LayoutMetricsConversions.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/LayoutMetricsConversions.java @@ -13,7 +13,7 @@ import com.facebook.react.uimanager.PixelUtil; import com.facebook.yoga.YogaMeasureMode; -public class LayoutMetricsConversions { +public interface LayoutMetricsConversions { public static float getMinSize(int viewMeasureSpec) { int mode = View.MeasureSpec.getMode(viewMeasureSpec); diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchStringCommandMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchStringCommandMountItem.java index ffb2221c05773b..e99671aa355a09 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchStringCommandMountItem.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchStringCommandMountItem.java @@ -16,7 +16,7 @@ public class DispatchStringCommandMountItem extends DispatchCommandMountItem { private final int mSurfaceId; private final int mReactTag; - @NonNull private final String mCommandId; + private final @NonNull String mCommandId; private final @Nullable ReadableArray mCommandArgs; public DispatchStringCommandMountItem( diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java index 6644b942ba8dfe..0f247a845c6edf 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java @@ -53,8 +53,8 @@ public class IntBufferBatchMountItem implements MountItem { private final int mSurfaceId; private final int mCommitNumber; - @NonNull private final int[] mIntBuffer; - @NonNull private final Object[] mObjBuffer; + private final @NonNull int[] mIntBuffer; + private final @NonNull Object[] mObjBuffer; private final int mIntBufferLen; private final int mObjBufferLen; diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/PreAllocateViewMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/PreAllocateViewMountItem.java index 0cd7b721ce9278..0392f0846a0e3b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/PreAllocateViewMountItem.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/PreAllocateViewMountItem.java @@ -21,7 +21,7 @@ /** {@link MountItem} that is used to pre-allocate views for JS components. */ public class PreAllocateViewMountItem implements MountItem { - @NonNull private final String mComponent; + private final @NonNull String mComponent; private final int mSurfaceId; private final int mReactTag; private final @Nullable Object mProps; diff --git a/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/Android.mk deleted file mode 100644 index bb426b20829231..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/Android.mk +++ /dev/null @@ -1,26 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := jscexecutor - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fvisibility=hidden -fexceptions -frtti - -LOCAL_STATIC_LIBRARIES := libjsireact jscruntime -LOCAL_SHARED_LIBRARIES := \ - libfb \ - libfbjni \ - libfolly_runtime \ - libjsi \ - libreactnativejni - -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/Android.mk deleted file mode 100644 index df00d67b191aa1..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/Android.mk +++ /dev/null @@ -1,26 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := reactnativeblob - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fvisibility=hidden -fexceptions -frtti - -LOCAL_STATIC_LIBRARIES := libjsireact -LOCAL_SHARED_LIBRARIES := \ - libfb \ - libfbjni \ - libfolly_runtime \ - libjsi \ - libreactnativejni - -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactAndroid/src/main/java/com/facebook/react/reactperflogger/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/reactperflogger/jni/Android.mk deleted file mode 100644 index 04ab85dc02546d..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/reactperflogger/jni/Android.mk +++ /dev/null @@ -1,32 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -# Header search path for all source files in this module. -LOCAL_C_INCLUDES := $(LOCAL_PATH)/reactperflogger - -# Header search path for modules that depend on this module -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_LDLIBS += -landroid - -LOCAL_STATIC_LIBRARIES = libreactperflogger - -LOCAL_SHARED_LIBRARIES = libfb libfbjni - -# Name of this module. -LOCAL_MODULE := reactperfloggerjni - -# Compile all local c++ files -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/reactperflogger/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -# Build the files in this directory as a shared library -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/Android.mk deleted file mode 100644 index 1fd20f0bdc8a40..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/Android.mk +++ /dev/null @@ -1,64 +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. - -LOCAL_PATH := $(call my-dir) - -######################### -### callinvokerholder ### -######################### - -include $(CLEAR_VARS) - -# Header search path for all source files in this module. -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ReactCommon - -# Header search path for modules that depend on this module -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_SHARED_LIBRARIES = libfb libfbjni libreactnativeutilsjni libruntimeexecutor - -LOCAL_STATIC_LIBRARIES = libcallinvoker libreactperfloggerjni - -# Name of this module. -LOCAL_MODULE := callinvokerholder - -# Compile all local c++ files -LOCAL_SRC_FILES := $(LOCAL_PATH)/ReactCommon/CallInvokerHolder.cpp -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -# Build the files in this directory as a shared library -include $(BUILD_STATIC_LIBRARY) - -################################## -### react_nativemodule_manager ### -################################## - -include $(CLEAR_VARS) - -# Name of this module. -# TODO: rename to react_nativemodule_manager -LOCAL_MODULE := turbomodulejsijni - -# Header search path for all source files in this module. -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ReactCommon - -# Header search path for modules that depend on this module -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_SHARED_LIBRARIES = libfb libfbjni libreact_nativemodule_core libjsi - -LOCAL_STATIC_LIBRARIES = libcallinvokerholder libreactperfloggerjni - -# Compile all local c++ files -LOCAL_SRC_FILES := $(LOCAL_PATH)/ReactCommon/CompositeTurboModuleManagerDelegate.cpp $(LOCAL_PATH)/ReactCommon/OnLoad.cpp $(LOCAL_PATH)/ReactCommon/TurboModuleManager.cpp -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - - -# Build the files in this directory as a shared library -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp index 3097d8da52f11e..a4d1c1289d9108 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/TurboModuleManager.cpp @@ -20,6 +20,17 @@ namespace facebook { namespace react { +constexpr static auto ReactFeatureFlagsJavaDescriptor = + "com/facebook/react/config/ReactFeatureFlags"; + +static int getFeatureFlagValue(const char *name) { + static const auto reactFeatureFlagsJavaDescriptor = + jni::findClassStatic(ReactFeatureFlagsJavaDescriptor); + const auto field = + reactFeatureFlagsJavaDescriptor->getStaticField(name); + return reactFeatureFlagsJavaDescriptor->getStaticFieldValue(field); +} + TurboModuleManager::TurboModuleManager( jni::alias_ref jThis, RuntimeExecutor runtimeExecutor, @@ -169,12 +180,13 @@ void TurboModuleManager::installJSIBindings() { return nullptr; }; - if (longLivedObjectCollection_) { - TurboModuleBinding::install( - runtime, std::move(turboModuleProvider), longLivedObjectCollection_); - } else { - TurboModuleBinding::install(runtime, std::move(turboModuleProvider)); - } + TurboModuleBindingMode bindingMode = static_cast( + getFeatureFlagValue("turboModuleBindingMode")); + TurboModuleBinding::install( + runtime, + std::move(turboModuleProvider), + bindingMode, + longLivedObjectCollection_); }); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java index 0d7922ed01d42f..a37ba3fe15a5b0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java @@ -111,7 +111,13 @@ public void handleMotionEvent(MotionEvent motionEvent, EventDispatcher eventDisp if (!supportsHover) { dispatchNonBubblingEventForPathWhenListened( - EVENT.ENTER, EVENT.ENTER_CAPTURE, hitPath, eventDispatcher, surfaceId, motionEvent); + EVENT.ENTER, + EVENT.ENTER_CAPTURE, + hitPath, + eventDispatcher, + surfaceId, + motionEvent, + false); } boolean listeningForDown = @@ -196,7 +202,13 @@ public void handleMotionEvent(MotionEvent motionEvent, EventDispatcher eventDisp if (!supportsHover) { dispatchNonBubblingEventForPathWhenListened( - EVENT.LEAVE, EVENT.LEAVE_CAPTURE, hitPath, eventDispatcher, surfaceId, motionEvent); + EVENT.LEAVE, + EVENT.LEAVE_CAPTURE, + hitPath, + eventDispatcher, + surfaceId, + motionEvent, + false); } return; } @@ -227,22 +239,28 @@ private static boolean isAnyoneListeningForBubblingEvent( return false; } - /* - Dispatch event only if ancestor is listening to relevant event. - This should only be relevant for ENTER/LEAVE events. - @param hitPath - ordered from inner target to root + /** + * Dispatch event only if ancestor is listening to relevant capture event. This should only be + * relevant for ENTER/LEAVE events that need to be dispatched along every relevant view in the hit + * path. + * + * @param pointerEventType - Should only be ENTER/LEAVE events + * @param hitPath - ViewTargets ordered from target -> root + * @param dispatcher + * @param surfaceId + * @param motionEvent + * @param forceDispatch - Ignore if ancestor is listening and force the event to be dispatched */ - - /** Dispatch non-bubbling event along the hit path only when relevant listeners */ private static void dispatchNonBubblingEventForPathWhenListened( EVENT event, EVENT captureEvent, List hitPath, EventDispatcher dispatcher, int surfaceId, - MotionEvent motionEvent) { + MotionEvent motionEvent, + boolean forceDispatch) { - boolean ancestorListening = false; + boolean ancestorListening = forceDispatch; String eventName = PointerEventHelper.getDispatchableEventName(event); if (eventName == null) { return; @@ -312,54 +330,72 @@ private void handleHoverEvent( // hitState is list ordered from inner child -> parent tag // Traverse hitState back-to-front to find the first divergence with mLastHitState // FIXME: this may generate incorrect events when view collapsing changes the hierarchy - int firstDivergentIndex = 0; - while (firstDivergentIndex < Math.min(hitPath.size(), mLastHitPath.size()) + boolean nonDivergentListeningToEnter = false; + boolean nonDivergentListeningToLeave = false; + int firstDivergentIndexFromBack = 0; + while (firstDivergentIndexFromBack < Math.min(hitPath.size(), mLastHitPath.size()) && hitPath - .get(hitPath.size() - 1 - firstDivergentIndex) - .equals(mLastHitPath.get(mLastHitPath.size() - 1 - firstDivergentIndex))) { - firstDivergentIndex++; + .get(hitPath.size() - 1 - firstDivergentIndexFromBack) + .equals(mLastHitPath.get(mLastHitPath.size() - 1 - firstDivergentIndexFromBack))) { + + // Track if any non-diverging views are listening to enter/leave + View nonDivergentViewTargetView = + hitPath.get(hitPath.size() - 1 - firstDivergentIndexFromBack).getView(); + if (!nonDivergentListeningToEnter + && PointerEventHelper.isListening(nonDivergentViewTargetView, EVENT.ENTER_CAPTURE)) { + nonDivergentListeningToEnter = true; + } + if (!nonDivergentListeningToLeave + && PointerEventHelper.isListening(nonDivergentViewTargetView, EVENT.LEAVE_CAPTURE)) { + nonDivergentListeningToLeave = true; + } + + firstDivergentIndexFromBack++; } - boolean hasDiverged = firstDivergentIndex < Math.max(hitPath.size(), mLastHitPath.size()); + boolean hasDiverged = + firstDivergentIndexFromBack < Math.max(hitPath.size(), mLastHitPath.size()); - // Fire all relevant enter events if (hasDiverged) { // If something has changed in either enter/exit, let's start a new coalescing key mTouchEventCoalescingKeyHelper.incrementCoalescingKey(mHoverInteractionKey); - List enterViewTargets = hitPath.subList(0, hitPath.size() - firstDivergentIndex); + List enterViewTargets = + hitPath.subList(0, hitPath.size() - firstDivergentIndexFromBack); if (enterViewTargets.size() > 0) { - // root -> child - for (int i = enterViewTargets.size(); i-- > 0; ) { - eventDispatcher.dispatchEvent( - PointerEvent.obtain( - PointerEventHelper.POINTER_ENTER, - surfaceId, - enterViewTargets.get(i).getViewId(), - motionEvent)); - } + dispatchNonBubblingEventForPathWhenListened( + EVENT.ENTER, + EVENT.ENTER_CAPTURE, + enterViewTargets, + eventDispatcher, + surfaceId, + motionEvent, + nonDivergentListeningToEnter); } - // Fire all relevant exit events List exitViewTargets = - mLastHitPath.subList(0, mLastHitPath.size() - firstDivergentIndex); + mLastHitPath.subList(0, mLastHitPath.size() - firstDivergentIndexFromBack); if (exitViewTargets.size() > 0) { // child -> root - for (ViewTarget exitViewTarget : exitViewTargets) { - eventDispatcher.dispatchEvent( - PointerEvent.obtain( - PointerEventHelper.POINTER_LEAVE, - surfaceId, - exitViewTarget.getViewId(), - motionEvent)); - } + dispatchNonBubblingEventForPathWhenListened( + EVENT.LEAVE, + EVENT.LEAVE_CAPTURE, + enterViewTargets, + eventDispatcher, + surfaceId, + motionEvent, + nonDivergentListeningToLeave); } } int coalescingKey = mTouchEventCoalescingKeyHelper.getCoalescingKey(mHoverInteractionKey); - eventDispatcher.dispatchEvent( - PointerEvent.obtain( - PointerEventHelper.POINTER_MOVE, surfaceId, targetTag, motionEvent, coalescingKey)); + boolean listeningToMove = + isAnyoneListeningForBubblingEvent(hitPath, EVENT.MOVE, EVENT.MOVE_CAPTURE); + if (listeningToMove) { + eventDispatcher.dispatchEvent( + PointerEvent.obtain( + PointerEventHelper.POINTER_MOVE, surfaceId, targetTag, motionEvent, coalescingKey)); + } mLastHitPath = hitPath; mLastEventCoordinates[0] = x; @@ -389,7 +425,13 @@ private void dispatchCancelEvent( } dispatchNonBubblingEventForPathWhenListened( - EVENT.LEAVE, EVENT.LEAVE_CAPTURE, hitPath, eventDispatcher, surfaceId, motionEvent); + EVENT.LEAVE, + EVENT.LEAVE_CAPTURE, + hitPath, + eventDispatcher, + surfaceId, + motionEvent, + false); mTouchEventCoalescingKeyHelper.removeCoalescingKey(mDownStartTime); mDownStartTime = TouchEvent.UNSET; diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/uimanager/jni/Android.mk deleted file mode 100644 index 109b4a917cffbf..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/jni/Android.mk +++ /dev/null @@ -1,45 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := uimanagerjni - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_SHARED_LIBRARIES := \ - libfb \ - libfbjni \ - libglog \ - libglog_init \ - librrc_native \ - libyoga \ - react_render_componentregistry - -LOCAL_STATIC_LIBRARIES := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"ReacTNative\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,fbgloginit) -$(call import-module,folly) -$(call import-module,fb) -$(call import-module,fbjni) -$(call import-module,yogajni) -$(call import-module,glog) - -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/componentregistry/native) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java index c2a8b61428ba40..d70e13548bc557 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java @@ -107,7 +107,7 @@ public boolean needsCustomLayoutForChildren() { @Override public Object updateState( ReactTextView view, ReactStylesDiffMap props, StateWrapper stateWrapper) { - if (ReactFeatureFlags.isMapBufferSerializationEnabled()) { + if (ReactFeatureFlags.mapBufferSerializationEnabled) { MapBuffer stateMapBuffer = stateWrapper.getStateDataMapBuffer(); if (stateMapBuffer != null) { return getReactTextUpdate(view, props, stateMapBuffer); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java index bf59c915de0403..ecbf0d45489b8a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java @@ -29,6 +29,7 @@ import com.facebook.react.bridge.WritableArray; import com.facebook.react.common.build.ReactBuildConfig; import com.facebook.react.common.mapbuffer.MapBuffer; +import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.uimanager.PixelUtil; import com.facebook.yoga.YogaConstants; import com.facebook.yoga.YogaMeasureMode; @@ -205,19 +206,25 @@ public static Spannable getOrCreateSpannableForText( Spannable preparedSpannableText; - synchronized (sSpannableCacheLock) { - preparedSpannableText = sSpannableCache.get(attributedString); - if (preparedSpannableText != null) { - return preparedSpannableText; + if (ReactFeatureFlags.enableSpannableCache) { + synchronized (sSpannableCacheLock) { + preparedSpannableText = sSpannableCache.get(attributedString); + if (preparedSpannableText != null) { + return preparedSpannableText; + } } - } - preparedSpannableText = - createSpannableFromAttributedString( - context, attributedString, reactTextViewManagerCallback); + preparedSpannableText = + createSpannableFromAttributedString( + context, attributedString, reactTextViewManagerCallback); - synchronized (sSpannableCacheLock) { - sSpannableCache.put(attributedString, preparedSpannableText); + synchronized (sSpannableCacheLock) { + sSpannableCache.put(attributedString, preparedSpannableText); + } + } else { + preparedSpannableText = + createSpannableFromAttributedString( + context, attributedString, reactTextViewManagerCallback); } return preparedSpannableText; diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index d6ef3952e8d090..51deec2f262075 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -747,7 +747,10 @@ private void setIntrinsicContentSize() { // view, we don't need to construct one or apply it at all - it provides no use in Fabric. ReactContext reactContext = getReactContext(this); - if (!mFabricViewStateManager.hasStateWrapper() && !reactContext.isBridgeless()) { + if (mFabricViewStateManager != null + && !mFabricViewStateManager.hasStateWrapper() + && !reactContext.isBridgeless()) { + final ReactTextInputLocalData localData = new ReactTextInputLocalData(this); UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class); if (uiManager != null) { @@ -983,7 +986,7 @@ public FabricViewStateManager getFabricViewStateManager() { */ private void updateCachedSpannable(boolean resetStyles) { // Noops in non-Fabric - if (!mFabricViewStateManager.hasStateWrapper()) { + if (mFabricViewStateManager == null || !mFabricViewStateManager.hasStateWrapper()) { return; } // If this view doesn't have an ID yet, we don't have a cache key, so bail here diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index 29411fbcae31a9..f3134f9cb1dc8d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -1273,7 +1273,16 @@ public Object updateState( FLog.e(TAG, "updateState: [" + view.getId() + "]"); } - view.getFabricViewStateManager().setStateWrapper(stateWrapper); + FabricViewStateManager stateManager = view.getFabricViewStateManager(); + if (!stateManager.hasStateWrapper()) { + // HACK: In Fabric, we assume all components start off with zero padding, which is + // not true for TextInput components. We expose the theme's default padding via + // AndroidTextInputComponentDescriptor, which will be applied later though setPadding. + // TODO T58784068: move this constructor once Fabric is shipped + view.setPadding(0, 0, 0, 0); + } + + stateManager.setStateWrapper(stateWrapper); ReadableNativeMap state = stateWrapper.getStateData(); if (state == null) { diff --git a/ReactAndroid/src/main/jni/Application.mk b/ReactAndroid/src/main/jni/Application.mk deleted file mode 100644 index 40ff08e84acbe2..00000000000000 --- a/ReactAndroid/src/main/jni/Application.mk +++ /dev/null @@ -1,34 +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. - -APP_BUILD_SCRIPT := Android.mk - -APP_ABI := armeabi-v7a x86 arm64-v8a x86_64 -APP_PLATFORM := android-21 - -APP_MK_DIR := $(dir $(lastword $(MAKEFILE_LIST))) - -# What is NDK_MODULE_PATH? -# This is comparable to the PATH environment variable in Linux. The purpose -# of NDK_MODULE_PATH is to provide a list of directories that contain modules -# we want ndk-build to compile. -# -# What is HOST_DIRSEP? -# In PATH, the directories are separated by a ':'. -# In NDK_MODULE_PATH, the directories are separated by $(HOST_DIRSEP). -# -# Where are APP_MK_DIR, THIRD_PARTY_NDK_DIR, etc. defined? -# The directories inside NDK_MODULE_PATH (ex: APP_MK_DIR, THIRD_PARTY_NDK_DIR, -# etc.) are defined inside build.gradle. -NDK_MODULE_PATH := $(APP_MK_DIR)$(HOST_DIRSEP)$(THIRD_PARTY_NDK_DIR)$(HOST_DIRSEP)$(REACT_COMMON_DIR)$(HOST_DIRSEP)$(APP_MK_DIR)first-party$(HOST_DIRSEP)$(REACT_SRC_DIR)$(HOST_DIRSEP)$(REACT_GENERATED_SRC_DIR) - -APP_STL := c++_shared - -APP_CFLAGS := -Wall -Werror -fexceptions -frtti -DWITH_INSPECTOR=1 -APP_CPPFLAGS := -std=c++1y -# Make sure every shared lib includes a .note.gnu.build-id header -APP_LDFLAGS := -Wl,--build-id - -NDK_TOOLCHAIN_VERSION := clang diff --git a/ReactAndroid/src/main/jni/first-party/fb/Android.mk b/ReactAndroid/src/main/jni/first-party/fb/Android.mk deleted file mode 100644 index b43c52c620b191..00000000000000 --- a/ReactAndroid/src/main/jni/first-party/fb/Android.mk +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - assert.cpp \ - log.cpp \ - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include - -LOCAL_CFLAGS := -DLOG_TAG=\"libfb\" -DDISABLE_CPUCAP -DDISABLE_XPLAT -fexceptions -frtti -# include/utils/threads.h has unused parameters -LOCAL_CFLAGS += -Wno-unused-parameter -ifeq ($(TOOLCHAIN_PERMISSIVE),true) - LOCAL_CFLAGS += -Wno-error=unused-but-set-variable -endif -LOCAL_CFLAGS += -DHAVE_POSIX_CLOCKS - -LOCAL_LDLIBS := -llog -ldl -landroid -LOCAL_EXPORT_LDLIBS := -llog -LOCAL_MODULE := libfb - -include $(BUILD_SHARED_LIBRARY) - diff --git a/ReactAndroid/src/main/jni/first-party/fbgloginit/Android.mk b/ReactAndroid/src/main/jni/first-party/fbgloginit/Android.mk deleted file mode 100644 index 357332be368b8f..00000000000000 --- a/ReactAndroid/src/main/jni/first-party/fbgloginit/Android.mk +++ /dev/null @@ -1,23 +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. - -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - glog_init.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS := -fexceptions -fno-omit-frame-pointer - -LOCAL_LDLIBS := -llog - -LOCAL_SHARED_LIBRARIES := libglog - -LOCAL_MODULE := libglog_init - -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactAndroid/src/main/jni/first-party/yogajni/Android.mk b/ReactAndroid/src/main/jni/first-party/yogajni/Android.mk deleted file mode 100644 index c12312d2ea3402..00000000000000 --- a/ReactAndroid/src/main/jni/first-party/yogajni/Android.mk +++ /dev/null @@ -1,26 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := yoga - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/jni/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/jni - -LOCAL_CFLAGS += -fvisibility=hidden -fexceptions -frtti -O3 - -LOCAL_LDLIBS += -landroid -llog -LOCAL_STATIC_LIBRARIES := libyogacore -LOCAL_SHARED_LIBRARIES := libfb libfbjni - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,yoga) -$(call import-module,fb) -$(call import-module,fbjni) diff --git a/ReactAndroid/src/main/jni/react/jni/Android.mk b/ReactAndroid/src/main/jni/react/jni/Android.mk deleted file mode 100644 index f07858762685de..00000000000000 --- a/ReactAndroid/src/main/jni/react/jni/Android.mk +++ /dev/null @@ -1,176 +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. - - -########################## -### React Native Utils ### -########################## - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -# Include . in the header search path for all source files in this module. -LOCAL_C_INCLUDES := $(LOCAL_PATH) - -# Include ./../../ in the header search path for modules that depend on -# reactnativejni. This will allow external modules to require this module's -# headers using #include .h>, assuming: -# . == jni -# ./../ == react -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. - -LOCAL_CFLAGS += -fexceptions -frtti -Wno-unused-lambda-capture -std=c++17 - -LOCAL_LDLIBS += -landroid - -# The dynamic libraries (.so files) that this module depends on. -LOCAL_SHARED_LIBRARIES := \ - libfb \ - libfbjni \ - libfolly_runtime \ - libglog_init \ - libreact_render_runtimescheduler \ - libruntimeexecutor \ - libyoga - -# The static libraries (.a files) that this module depends on. -LOCAL_STATIC_LIBRARIES := libreactnative libcallinvokerholder - -# Name of this module. -# -# Other modules can depend on this one by adding libreactnativejni to their -# LOCAL_SHARED_LIBRARIES variable. -LOCAL_MODULE := reactnativeutilsjni - -# Compile all local c++ files. -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -ifeq ($(APP_OPTIM),debug) - # Keep symbols by overriding the strip command invoked by ndk-build. - # Note that this will apply to all shared libraries, - # i.e. shared libraries will NOT be stripped - # even though we override it in this Android.mk - cmd-strip := -endif - -# Build the files in this directory as a shared library -include $(BUILD_SHARED_LIBRARY) - - - - - -###################### -### reactnativejni ### -###################### - -include $(CLEAR_VARS) - -# Include . in the header search path for all source files in this module. -LOCAL_C_INCLUDES := $(LOCAL_PATH) - -# Include ./../../ in the header search path for modules that depend on -# reactnativejni. This will allow external modules to require this module's -# headers using #include .h>, assuming: -# . == jni -# ./../ == react -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. - -LOCAL_CFLAGS += -fexceptions -frtti -Wno-unused-lambda-capture -std=c++17 - -LOCAL_LDLIBS += -landroid - -# The dynamic libraries (.so files) that this module depends on. -LOCAL_SHARED_LIBRARIES := \ - libfb \ - libfbjni \ - libfolly_runtime \ - libglog_init \ - libreact_render_runtimescheduler \ - libreactnativeutilsjni \ - libruntimeexecutor \ - libyoga \ - logger - -# The static libraries (.a files) that this module depends on. -LOCAL_STATIC_LIBRARIES := libreactnative libcallinvokerholder - -# Name of this module. -# -# Other modules can depend on this one by adding libreactnativejni to their -# LOCAL_SHARED_LIBRARIES variable. -LOCAL_MODULE := reactnativejni - -# Compile all local c++ files. -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -ifeq ($(APP_OPTIM),debug) - # Keep symbols by overriding the strip command invoked by ndk-build. - # Note that this will apply to all shared libraries, - # i.e. shared libraries will NOT be stripped - # even though we override it in this Android.mk - cmd-strip := -endif - -# Build the files in this directory as a shared library -include $(BUILD_SHARED_LIBRARY) - -# Compile the c++ dependencies required for ReactAndroid -# -# How does the import-module function work? -# For each $(call import-module,), you search the directories in -# NDK_MODULE_PATH. (This variable is defined in Application.mk). If you find a -# /Android.mk you in a directory , you run: -# include //Android.mk -# -# What does it mean to include an Android.mk file? -# Whenever you encounter an include //Android.mk, you -# tell andorid-ndk to compile the module in / according -# to the specification inside //Android.mk. -$(call import-module,butter) -$(call import-module,folly) -$(call import-module,fb) -$(call import-module,fbjni) -$(call import-module,jsc) -$(call import-module,fbgloginit) -$(call import-module,yogajni) -$(call import-module,cxxreact) -$(call import-module,jsi) -$(call import-module,jsiexecutor) -$(call import-module,logger) -$(call import-module,callinvoker) -$(call import-module,reactperflogger) -$(call import-module,runtimeexecutor) -$(call import-module,react/renderer/runtimescheduler) -$(call import-module,react/nativemodule/core) - -# This block is needed only because we build the project on NDK r17 internally. -ifneq ($(call ndk-major-at-least,21),true) - $(call import-add-path,$(NDK_GRADLE_INJECTED_IMPORT_PATH)) -endif - -$(call import-module,prefab/hermes-engine) - - -include $(REACT_SRC_DIR)/reactperflogger/jni/Android.mk -# TODO (T48588859): Restructure this target to align with dir structure: "react/nativemodule/..." -# Note: Update this only when ready to minimize breaking changes. -include $(REACT_SRC_DIR)/turbomodule/core/jni/Android.mk -include $(REACT_SRC_DIR)/fabric/jni/Android.mk -include $(REACT_SRC_DIR)/common/mapbuffer/jni/Android.mk - -# TODO(ramanpreet): -# Why doesn't this import-module call generate a jscexecutor.so file? -# $(call import-module,jscexecutor) - -include $(REACT_SRC_DIR)/jscexecutor/Android.mk -include $(REACT_SRC_DIR)/../hermes/reactexecutor/Android.mk -include $(REACT_SRC_DIR)/../hermes/instrumentation/Android.mk -include $(REACT_SRC_DIR)/modules/blob/jni/Android.mk - -include $(REACT_GENERATED_SRC_DIR)/codegen/jni/Android.mk diff --git a/ReactAndroid/src/main/jni/third-party/boost/Android.mk b/ReactAndroid/src/main/jni/third-party/boost/Android.mk deleted file mode 100644 index 9560de94eda528..00000000000000 --- a/ReactAndroid/src/main/jni/third-party/boost/Android.mk +++ /dev/null @@ -1,15 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -# These ASM files are picked from the boost release separately, -# because the react native version does not include anything outside of headers. -# They are required for Folly futures to compile successfully. -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/asm/$(TARGET_ARCH_ABI)/*.S) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/boost_1_76_0 -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/boost_1_76_0 - -LOCAL_MODULE := boost - -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactAndroid/src/main/jni/third-party/double-conversion/Android.mk b/ReactAndroid/src/main/jni/third-party/double-conversion/Android.mk deleted file mode 100644 index 64f7e67e8ad51f..00000000000000 --- a/ReactAndroid/src/main/jni/third-party/double-conversion/Android.mk +++ /dev/null @@ -1,22 +0,0 @@ -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := double-conversion - -LOCAL_SRC_FILES := \ - double-conversion/bignum.cc \ - double-conversion/bignum-dtoa.cc \ - double-conversion/cached-powers.cc \ - double-conversion/diy-fp.cc \ - double-conversion/double-conversion.cc \ - double-conversion/fast-dtoa.cc \ - double-conversion/fixed-dtoa.cc \ - double-conversion/strtod.cc - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -CXX11_FLAGS := -Wno-unused-variable -Wno-unused-local-typedefs -LOCAL_CFLAGS += $(CXX11_FLAGS) - -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactAndroid/src/main/jni/third-party/fmt/Android.mk b/ReactAndroid/src/main/jni/third-party/fmt/Android.mk deleted file mode 100644 index 11d070286749aa..00000000000000 --- a/ReactAndroid/src/main/jni/third-party/fmt/Android.mk +++ /dev/null @@ -1,15 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := fmt - -LOCAL_SRC_FILES := \ - src/format.cc - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include/ - -LOCAL_CFLAGS += -std=c++11 -fexceptions - -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactAndroid/src/main/jni/third-party/folly/Android.mk b/ReactAndroid/src/main/jni/third-party/folly/Android.mk deleted file mode 100644 index 59b721767c1611..00000000000000 --- a/ReactAndroid/src/main/jni/third-party/folly/Android.mk +++ /dev/null @@ -1,128 +0,0 @@ -LOCAL_PATH:= $(call my-dir) - -FOLLY_FLAGS := \ - -DFOLLY_NO_CONFIG=1 \ - -DFOLLY_HAVE_CLOCK_GETTIME=1 \ - -DFOLLY_USE_LIBCPP=1 \ - -DFOLLY_MOBILE=1 \ - -DFOLLY_HAVE_RECVMMSG=1 \ - -DFOLLY_HAVE_PTHREAD=1 - -# If APP_PLATFORM in Application.mk targets android-23 above, please comment this line. -# NDK uses GNU style stderror_r() after API 23. -FOLLY_FLAGS += -DFOLLY_HAVE_XSI_STRERROR_R=1 - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - folly/SharedMutex.cpp \ - folly/concurrency/CacheLocality.cpp \ - folly/detail/Futex.cpp \ - folly/lang/SafeAssert.cpp \ - folly/lang/ToAscii.cpp \ - folly/synchronization/ParkingLot.cpp \ - folly/system/ThreadId.cpp \ - folly/system/ThreadName.cpp \ - folly/json.cpp \ - folly/Unicode.cpp \ - folly/Conv.cpp \ - folly/Demangle.cpp \ - folly/memory/detail/MallocImpl.cpp \ - folly/String.cpp \ - folly/dynamic.cpp \ - folly/FileUtil.cpp \ - folly/Format.cpp \ - folly/net/NetOps.cpp \ - folly/json_pointer.cpp \ - folly/lang/CString.cpp \ - folly/detail/UniqueInstance.cpp \ - folly/hash/SpookyHashV2.cpp \ - folly/container/detail/F14Table.cpp \ - folly/ScopeGuard.cpp \ - folly/portability/SysUio.cpp - -ifeq ($(APP_OPTIM),debug) - LOCAL_SRC_FILES += \ - folly/lang/Assume.cpp -endif - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare -Wno-unused-variable -LOCAL_CFLAGS += $(FOLLY_FLAGS) -LOCAL_EXPORT_CPPFLAGS := $(FOLLY_FLAGS) - -LOCAL_MODULE := folly_runtime - -LOCAL_SHARED_LIBRARIES := libglog -LOCAL_STATIC_LIBRARIES := libboost libfmt libdouble-conversion - -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - folly/ExceptionWrapper.cpp \ - folly/ExceptionString.cpp \ - folly/Executor.cpp \ - folly/Singleton.cpp \ - folly/Try.cpp \ - folly/concurrency/CacheLocality.cpp \ - folly/detail/AsyncTrace.cpp \ - folly/detail/AtFork.cpp \ - folly/detail/MemoryIdler.cpp \ - folly/detail/SingletonStackTrace.cpp \ - folly/detail/StaticSingletonManager.cpp \ - folly/detail/ThreadLocalDetail.cpp \ - folly/fibers/Baton.cpp \ - folly/fibers/FiberManager.cpp \ - folly/fibers/Fiber.cpp \ - folly/fibers/GuardPageAllocator.cpp \ - folly/futures/detail/Core.cpp \ - folly/futures/Future.cpp \ - folly/futures/ThreadWheelTimekeeper.cpp \ - folly/executors/ExecutorWithPriority.cpp \ - folly/executors/InlineExecutor.cpp \ - folly/executors/TimedDrivableExecutor.cpp \ - folly/executors/QueuedImmediateExecutor.cpp \ - folly/io/async/AsyncTimeout.cpp \ - folly/io/async/EventBase.cpp \ - folly/io/async/EventBaseBackendBase.cpp \ - folly/io/async/EventBaseLocal.cpp \ - folly/io/async/EventHandler.cpp \ - folly/io/async/HHWheelTimer.cpp \ - folly/io/async/Request.cpp \ - folly/io/async/TimeoutManager.cpp \ - folly/io/async/VirtualEventBase.cpp \ - folly/lang/Exception.cpp \ - folly/memory/MallctlHelper.cpp \ - folly/portability/SysMembarrier.cpp \ - folly/synchronization/AsymmetricMemoryBarrier.cpp \ - folly/synchronization/Hazptr.cpp \ - folly/synchronization/WaitOptions.cpp \ - folly/synchronization/detail/Sleeper.cpp \ - folly/system/Pid.cpp - - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare -Wno-unused-variable - -LOCAL_CFLAGS += $(FOLLY_FLAGS) - -LOCAL_EXPORT_CPPFLAGS := $(FOLLY_FLAGS) - -LOCAL_MODULE := libfolly_futures - -LOCAL_SHARED_LIBRARIES := libglog libfolly_runtime -LOCAL_STATIC_LIBRARIES := libboost libevent libfmt libdouble-conversion - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,libevent) -$(call import-module,glog) -$(call import-module,double-conversion) -$(call import-module,boost) -$(call import-module,fmt) diff --git a/ReactAndroid/src/main/jni/third-party/glog/Android.mk b/ReactAndroid/src/main/jni/third-party/glog/Android.mk deleted file mode 100644 index 33ea07c9a26ab2..00000000000000 --- a/ReactAndroid/src/main/jni/third-party/glog/Android.mk +++ /dev/null @@ -1,32 +0,0 @@ -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - glog-0.3.5/src/demangle.cc \ - glog-0.3.5/src/logging.cc \ - glog-0.3.5/src/raw_logging.cc \ - glog-0.3.5/src/signalhandler.cc \ - glog-0.3.5/src/symbolize.cc \ - glog-0.3.5/src/utilities.cc \ - glog-0.3.5/src/vlog_is_on.cc - -LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/.. $(LOCAL_PATH)/glog-0.3.5/src/ - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/exported - -LOCAL_CFLAGS += \ - -Wwrite-strings \ - -Woverloaded-virtual \ - -Wno-sign-compare \ - -DNDEBUG \ - -g \ - -O2 \ - -D_START_GOOGLE_NAMESPACE_="namespace google {" \ - -D_END_GOOGLE_NAMESPACE_="}" \ - -DHAVE_PREAD=1 - - -LOCAL_MODULE := glog - -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactAndroid/src/main/jni/third-party/jsc/Android.mk b/ReactAndroid/src/main/jni/third-party/jsc/Android.mk deleted file mode 100644 index 25462a614df5d3..00000000000000 --- a/ReactAndroid/src/main/jni/third-party/jsc/Android.mk +++ /dev/null @@ -1,6 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) -LOCAL_MODULE:= jsc -LOCAL_SRC_FILES := jni/$(TARGET_ARCH_ABI)/libjsc.so -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) -include $(PREBUILT_SHARED_LIBRARY) \ No newline at end of file diff --git a/ReactAndroid/src/main/jni/third-party/libevent/Android.mk b/ReactAndroid/src/main/jni/third-party/libevent/Android.mk deleted file mode 100644 index e546d1b711f466..00000000000000 --- a/ReactAndroid/src/main/jni/third-party/libevent/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := libevent - -LOCAL_SRC_FILES := event.c \ - buffer.c \ - bufferevent.c \ - bufferevent_filter.c \ - bufferevent_pair.c \ - bufferevent_ratelim.c \ - bufferevent_sock.c \ - epoll.c \ - evmap.c \ - evthread.c \ - evthread_pthread.c \ - evutil.c \ - evutil_rand.c \ - evutil_time.c \ - listener.c \ - log.c \ - poll.c \ - signal.c \ - strlcpy.c \ - select.c - -LOCAL_CFLAGS := -DNDEBUG -O2 -Wno-unused-function -Wno-unneeded-internal-declaration -std=c11 - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include/ - -# link against libc as well -LOCAL_EXPORT_LDLIBS := -lc - -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/butter/Android.mk b/ReactCommon/butter/Android.mk deleted file mode 100644 index 36cf73b114cc4e..00000000000000 --- a/ReactCommon/butter/Android.mk +++ /dev/null @@ -1,27 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := butter - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Butter\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_SHARED_LIBRARIES := glog - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) diff --git a/ReactCommon/callinvoker/Android.mk b/ReactCommon/callinvoker/Android.mk deleted file mode 100644 index 0d6b90955f41aa..00000000000000 --- a/ReactCommon/callinvoker/Android.mk +++ /dev/null @@ -1,25 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -# Header search path for all source files in this module. -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ReactCommon - -# Header search path for modules that depend on this module -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -# Name of this module. -LOCAL_MODULE := callinvoker - -# Compile all local c++ files under ./ReactCommon -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/ReactCommon/*.cpp) - -# Build the files in this directory as a shared library -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/cxxreact/Android.mk b/ReactCommon/cxxreact/Android.mk deleted file mode 100644 index 4ff838da45af8e..00000000000000 --- a/ReactCommon/cxxreact/Android.mk +++ /dev/null @@ -1,50 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := reactnative - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"ReactNative\" - -LOCAL_CFLAGS += -fexceptions -frtti -Wno-unused-lambda-capture - -LOCAL_STATIC_LIBRARIES := \ - boost \ - callinvoker \ - jsi \ - reactperflogger - -LOCAL_SHARED_LIBRARIES := \ - glog \ - jsinspector \ - libfolly_runtime \ - libruntimeexecutor \ - logger - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,fb) -$(call import-module,folly) -$(call import-module,callinvoker) -$(call import-module,reactperflogger) -$(call import-module,jsc) -$(call import-module,glog) -$(call import-module,jsi) -$(call import-module,jsinspector) -$(call import-module,hermes/executor) -$(call import-module,logger) - -ifeq ($(APP_OPTIM),debug) - $(call import-module,hermes/inspector) -endif diff --git a/ReactCommon/hermes/executor/Android.mk b/ReactCommon/hermes/executor/Android.mk deleted file mode 100644 index a0e00a11a6e1c6..00000000000000 --- a/ReactCommon/hermes/executor/Android.mk +++ /dev/null @@ -1,40 +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. - -LOCAL_PATH := $(call my-dir) -REACT_NATIVE := $(LOCAL_PATH)/../../.. - -ifeq ($(APP_OPTIM),debug) - include $(CLEAR_VARS) - - LOCAL_MODULE := hermes-executor-common-debug - LOCAL_CFLAGS := -DHERMES_ENABLE_DEBUGGER=1 - - LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - - LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi - LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - - LOCAL_STATIC_LIBRARIES := libjsireact libhermes-inspector - LOCAL_SHARED_LIBRARIES := libhermes libjsi - - include $(BUILD_STATIC_LIBRARY) -else - include $(CLEAR_VARS) - - LOCAL_MODULE := hermes-executor-common-release - - LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - - LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi - LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - - LOCAL_STATIC_LIBRARIES := libjsireact - LOCAL_SHARED_LIBRARIES := libhermes libjsi - - include $(BUILD_STATIC_LIBRARY) -endif diff --git a/ReactCommon/hermes/inspector/Android.mk b/ReactCommon/hermes/inspector/Android.mk deleted file mode 100644 index a5e95b0f05fbd9..00000000000000 --- a/ReactCommon/hermes/inspector/Android.mk +++ /dev/null @@ -1,35 +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. - -LOCAL_PATH := $(call my-dir) -REACT_NATIVE := $(LOCAL_PATH)/../../.. - -include $(CLEAR_VARS) - -LOCAL_MODULE := hermes-inspector - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp $(LOCAL_PATH)/detail/*.cpp $(LOCAL_PATH)/chrome/*.cpp) - -LOCAL_C_ROOT := $(LOCAL_PATH)/../.. - -LOCAL_CFLAGS := -DHERMES_ENABLE_DEBUGGER=1 -DHERMES_INSPECTOR_FOLLY_KLUDGE=1 -LOCAL_C_INCLUDES := $(LOCAL_C_ROOT) $(REACT_NATIVE)/ReactCommon/jsi -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_ROOT) - -LOCAL_CPP_FEATURES := exceptions - -LOCAL_SHARED_LIBRARIES := \ - jsinspector \ - libfb \ - libfbjni \ - libfolly_runtime \ - libglog \ - libhermes \ - libjsi - -LOCAL_STATIC_LIBRARIES := \ - libfolly_futures - -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/jsi/Android.mk b/ReactCommon/jsi/Android.mk deleted file mode 100644 index f75a528e7467d5..00000000000000 --- a/ReactCommon/jsi/Android.mk +++ /dev/null @@ -1,39 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := jsi - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/jsi/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS := -fexceptions -frtti -O3 -LOCAL_SHARED_LIBRARIES := libfolly_runtime glog - -include $(BUILD_SHARED_LIBRARY) - - -include $(CLEAR_VARS) - -LOCAL_MODULE := jscruntime - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS := -fexceptions -frtti -O3 -LOCAL_SHARED_LIBRARIES := libfolly_runtime libjsc glog - -# TODO: Remove this flag when ready. -# Android has this enabled by default, but the flag is still needed for iOS. -LOCAL_CFLAGS += -DRN_FABRIC_ENABLED - -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/jsiexecutor/Android.mk b/ReactCommon/jsiexecutor/Android.mk deleted file mode 100644 index 9749ca7a36f27c..00000000000000 --- a/ReactCommon/jsiexecutor/Android.mk +++ /dev/null @@ -1,22 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := jsireact - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/jsireact/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) - -LOCAL_CFLAGS := -fexceptions -frtti -O3 - -LOCAL_STATIC_LIBRARIES := reactnative reactperflogger -LOCAL_SHARED_LIBRARIES := libfolly_runtime glog libjsi - -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/jsinspector/Android.mk b/ReactCommon/jsinspector/Android.mk deleted file mode 100644 index 64fdbd0e635136..00000000000000 --- a/ReactCommon/jsinspector/Android.mk +++ /dev/null @@ -1,19 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := jsinspector - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) - -LOCAL_CFLAGS += -fexceptions - -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/logger/Android.mk b/ReactCommon/logger/Android.mk deleted file mode 100644 index ca78f12e42ace3..00000000000000 --- a/ReactCommon/logger/Android.mk +++ /dev/null @@ -1,24 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := logger - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) - -LOCAL_CFLAGS += -fexceptions - -LOCAL_SHARED_LIBRARIES := glog - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) diff --git a/ReactCommon/react/bridging/Android.mk b/ReactCommon/react/bridging/Android.mk deleted file mode 100644 index 63ffe3603b3b29..00000000000000 --- a/ReactCommon/react/bridging/Android.mk +++ /dev/null @@ -1,27 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_bridging - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../ - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := jsi - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,butter) -$(call import-module,folly) -$(call import-module,jsi) diff --git a/ReactCommon/react/config/Android.mk b/ReactCommon/react/config/Android.mk deleted file mode 100644 index c4c2a409c70996..00000000000000 --- a/ReactCommon/react/config/Android.mk +++ /dev/null @@ -1,26 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_config - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := - -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/react/debug/Android.mk b/ReactCommon/react/debug/Android.mk deleted file mode 100644 index 09e3f381e05afe..00000000000000 --- a/ReactCommon/react/debug/Android.mk +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_debug - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SHARED_LIBRARIES := libfolly_runtime - -LOCAL_LDLIBS := -llog - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall -llog - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,folly) diff --git a/ReactCommon/react/nativemodule/core/Android.mk b/ReactCommon/react/nativemodule/core/Android.mk deleted file mode 100644 index 5a08467b2e962e..00000000000000 --- a/ReactCommon/react/nativemodule/core/Android.mk +++ /dev/null @@ -1,40 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_nativemodule_core - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ReactCommon $(LOCAL_PATH)/platform/android/ReactCommon - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/ReactCommon/*.cpp) $(wildcard $(LOCAL_PATH)/platform/android/ReactCommon/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH) $(LOCAL_PATH)/platform/android/ - -LOCAL_SHARED_LIBRARIES := \ - libfbjni \ - libfolly_runtime \ - libjsi \ - libreact_debug \ - libreactnativejni - -LOCAL_STATIC_LIBRARIES := \ - libreact_bridging \ - libreactperflogger - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"ReactNative\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,folly) -$(call import-module,jsi) -$(call import-module,reactperflogger) -$(call import-module,react/bridging) diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.cpp b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.cpp index 3e27164946a84c..89ac90bcd8362a 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.cpp +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.cpp @@ -15,5 +15,26 @@ TurboModule::TurboModule( std::shared_ptr jsInvoker) : name_(std::move(name)), jsInvoker_(std::move(jsInvoker)) {} +jsi::Value TurboModule::get( + jsi::Runtime &runtime, + const jsi::PropNameID &propName, + const MethodMetadata &meta) { + auto result = jsi::Function::createFromHostFunction( + runtime, + propName, + static_cast(meta.argCount), + [this, meta]( + jsi::Runtime &rt, + const jsi::Value &thisVal, + const jsi::Value *args, + size_t count) { return meta.invoker(rt, *this, args, count); }); + // If we have a JS wrapper, cache the result of this lookup + // We don't cache misses, to allow for methodMap_ to dynamically be extended + if (jsRepresentation_) { + jsRepresentation_->setProperty(runtime, propName, result); + } + return result; +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h index 4ca5b5c77f6fe7..e0788dcbf73ba4 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h @@ -32,6 +32,8 @@ enum TurboModuleMethodValueKind { PromiseKind, }; +class TurboModuleBinding; + /** * Base HostObject class for every module to be exposed to JS */ @@ -39,25 +41,21 @@ class JSI_EXPORT TurboModule : public facebook::jsi::HostObject { public: TurboModule(std::string name, std::shared_ptr jsInvoker); - virtual facebook::jsi::Value get( + // Note: keep this method declared inline to avoid conflicts + // between RTTI and non-RTTI compilation units + facebook::jsi::Value get( facebook::jsi::Runtime &runtime, const facebook::jsi::PropNameID &propName) override { - std::string propNameUtf8 = propName.utf8(runtime); - auto p = methodMap_.find(propNameUtf8); - if (p == methodMap_.end()) { - // Method was not found, let JS decide what to do. - return jsi::Value::undefined(); + { + std::string propNameUtf8 = propName.utf8(runtime); + auto p = methodMap_.find(propNameUtf8); + if (p == methodMap_.end()) { + // Method was not found, let JS decide what to do. + return facebook::jsi::Value::undefined(); + } else { + return get(runtime, propName, p->second); + } } - MethodMetadata meta = p->second; - return jsi::Function::createFromHostFunction( - runtime, - propName, - static_cast(meta.argCount), - [this, meta]( - facebook::jsi::Runtime &rt, - const facebook::jsi::Value &thisVal, - const facebook::jsi::Value *args, - size_t count) { return meta.invoker(rt, *this, args, count); }); } const std::string name_; @@ -73,7 +71,16 @@ class JSI_EXPORT TurboModule : public facebook::jsi::HostObject { size_t count); }; + facebook::jsi::Value get( + facebook::jsi::Runtime &runtime, + const facebook::jsi::PropNameID &propName, + const MethodMetadata &meta); + std::unordered_map methodMap_; + + private: + friend class TurboModuleBinding; + std::unique_ptr jsRepresentation_; }; /** diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp index 61c21a076e953e..77c8d222318a1e 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp @@ -22,45 +22,18 @@ namespace react { * Public API to install the TurboModule system. */ -TurboModuleBinding::TurboModuleBinding( - const TurboModuleProviderFunctionType &&moduleProvider) - : moduleProvider_(std::move(moduleProvider)), - longLivedObjectCollection_(nullptr), - disableGlobalLongLivedObjectCollection_(false) {} - TurboModuleBinding::TurboModuleBinding( const TurboModuleProviderFunctionType &&moduleProvider, + TurboModuleBindingMode bindingMode, std::shared_ptr longLivedObjectCollection) : moduleProvider_(std::move(moduleProvider)), - longLivedObjectCollection_(longLivedObjectCollection), - disableGlobalLongLivedObjectCollection_(true) {} - -void TurboModuleBinding::install( - jsi::Runtime &runtime, - const TurboModuleProviderFunctionType &&moduleProvider) { - runtime.global().setProperty( - runtime, - "__turboModuleProxy", - jsi::Function::createFromHostFunction( - runtime, - jsi::PropNameID::forAscii(runtime, "__turboModuleProxy"), - 1, - - // Create a TurboModuleBinding that uses the global - // LongLivedObjectCollection - [binding = - std::make_shared(std::move(moduleProvider))]( - jsi::Runtime &rt, - const jsi::Value &thisVal, - const jsi::Value *args, - size_t count) { - return binding->jsProxy(rt, thisVal, args, count); - })); -} + longLivedObjectCollection_(std::move(longLivedObjectCollection)), + bindingMode_(bindingMode) {} void TurboModuleBinding::install( jsi::Runtime &runtime, const TurboModuleProviderFunctionType &&moduleProvider, + TurboModuleBindingMode bindingMode, std::shared_ptr longLivedObjectCollection) { runtime.global().setProperty( runtime, @@ -69,42 +42,27 @@ void TurboModuleBinding::install( runtime, jsi::PropNameID::forAscii(runtime, "__turboModuleProxy"), 1, - // Create a TurboModuleBinding that doesn't use the global - // LongLivedObjectCollection - [binding = std::make_shared( - std::move(moduleProvider), longLivedObjectCollection)]( + [binding = TurboModuleBinding( + std::move(moduleProvider), + bindingMode, + std::move(longLivedObjectCollection))]( jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, - size_t count) { - return binding->jsProxy(rt, thisVal, args, count); + size_t count) mutable { + return binding.getModule(rt, thisVal, args, count); })); } TurboModuleBinding::~TurboModuleBinding() { - if (longLivedObjectCollection_ != nullptr) { + if (longLivedObjectCollection_) { longLivedObjectCollection_->clear(); - return; - } - - if (disableGlobalLongLivedObjectCollection_) { - return; - } - - LongLivedObjectCollection::get().clear(); -} - -std::shared_ptr TurboModuleBinding::getModule( - const std::string &name) { - std::shared_ptr module = nullptr; - { - SystraceSection s("TurboModuleBinding::getModule", "module", name); - module = moduleProvider_(name); + } else { + LongLivedObjectCollection::get().clear(); } - return module; } -jsi::Value TurboModuleBinding::jsProxy( +jsi::Value TurboModuleBinding::getModule( jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *args, @@ -114,14 +72,44 @@ jsi::Value TurboModuleBinding::jsProxy( "__turboModuleProxy must be called with at least 1 argument"); } std::string moduleName = args[0].getString(runtime).utf8(runtime); - jsi::Value nullSchema = jsi::Value::undefined(); - std::shared_ptr module = getModule(moduleName); - if (module == nullptr) { + std::shared_ptr module; + { + SystraceSection s( + "TurboModuleBinding::moduleProvider", "module", moduleName); + module = moduleProvider_(moduleName); + } + if (module) { + // Default behaviour + if (bindingMode_ == TurboModuleBindingMode::HostObject) { + return jsi::Object::createFromHostObject(runtime, std::move(module)); + } + + auto &jsRepresentation = module->jsRepresentation_; + if (!jsRepresentation) { + jsRepresentation = std::make_unique(runtime); + if (bindingMode_ == TurboModuleBindingMode::Prototype) { + // Option 1: create plain object, with it's prototype mapped back to the + // hostobject. Any properties accessed are stored on the plain object + auto hostObject = + jsi::Object::createFromHostObject(runtime, std::move(module)); + jsRepresentation->setProperty( + runtime, "__proto__", std::move(hostObject)); + } else { + // Option 2: eagerly install all hostfunctions at this point, avoids + // prototype + for (auto it = module->methodMap_.cbegin(); + it != module->methodMap_.cend(); + ++it) { + auto propName = jsi::PropNameID::forUtf8(runtime, it->first); + module->get(runtime, propName, it->second); + } + } + } + return jsi::Value(runtime, *jsRepresentation); + } else { return jsi::Value::null(); } - - return jsi::Object::createFromHostObject(runtime, std::move(module)); } } // namespace react diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h index 148d4d24f078a3..1791d4e272edcc 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h @@ -18,6 +18,12 @@ namespace react { class JSCallInvoker; +enum class TurboModuleBindingMode : uint8_t { + HostObject = 0, + Prototype = 1, + Eager = 2, +}; + /** * Represents the JavaScript binding for the TurboModule system. */ @@ -27,31 +33,24 @@ class TurboModuleBinding { * Installs TurboModuleBinding into JavaScript runtime. * Thread synchronization must be enforced externally. */ - static void install( - jsi::Runtime &runtime, - const TurboModuleProviderFunctionType &&moduleProvider); static void install( jsi::Runtime &runtime, const TurboModuleProviderFunctionType &&moduleProvider, + TurboModuleBindingMode bindingMode, std::shared_ptr longLivedObjectCollection); - TurboModuleBinding(const TurboModuleProviderFunctionType &&moduleProvider); + private: TurboModuleBinding( const TurboModuleProviderFunctionType &&moduleProvider, + TurboModuleBindingMode bindingMode, std::shared_ptr longLivedObjectCollection); virtual ~TurboModuleBinding(); - /** - * Get an TurboModule instance for the given module name. - */ - std::shared_ptr getModule(const std::string &name); - - private: /** * A lookup function exposed to JS to get an instance of a TurboModule * for the given name. */ - jsi::Value jsProxy( + jsi::Value getModule( jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *args, @@ -59,7 +58,7 @@ class TurboModuleBinding { TurboModuleProviderFunctionType moduleProvider_; std::shared_ptr longLivedObjectCollection_; - bool disableGlobalLongLivedObjectCollection_; + TurboModuleBindingMode bindingMode_; }; } // namespace react diff --git a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm index 6dfc6cb249c8ff..a6689b4e7ff334 100644 --- a/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm @@ -776,12 +776,14 @@ - (void)installJSBindingWithRuntimeExecutor:(facebook::react::RuntimeExecutor)ru if (RCTGetTurboModuleCleanupMode() == kRCTGlobalScope || RCTGetTurboModuleCleanupMode() == kRCTGlobalScopeUsingRetainJSCallback) { runtimeExecutor([turboModuleProvider = std::move(turboModuleProvider)](jsi::Runtime &runtime) { - react::TurboModuleBinding::install(runtime, std::move(turboModuleProvider)); + react::TurboModuleBinding::install( + runtime, std::move(turboModuleProvider), TurboModuleBindingMode::HostObject, nullptr); }); } else if (RCTGetTurboModuleCleanupMode() == kRCTTurboModuleManagerScope) { runtimeExecutor([turboModuleProvider = std::move(turboModuleProvider), longLivedObjectCollection = _longLivedObjectCollection](jsi::Runtime &runtime) { - react::TurboModuleBinding::install(runtime, std::move(turboModuleProvider), longLivedObjectCollection); + react::TurboModuleBinding::install( + runtime, std::move(turboModuleProvider), TurboModuleBindingMode::HostObject, longLivedObjectCollection); }); } } diff --git a/ReactCommon/react/renderer/animations/Android.mk b/ReactCommon/react/renderer/animations/Android.mk deleted file mode 100644 index c5168c4e0be853..00000000000000 --- a/ReactCommon/react/renderer/animations/Android.mk +++ /dev/null @@ -1,58 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_animations - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfolly_runtime \ - libglog_init \ - libjsi \ - libreact_debug \ - libreact_render_componentregistry \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_mounting \ - libreact_render_uimanager \ - libreact_config \ - librrc_view \ - libruntimeexecutor \ - libyoga - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,fbgloginit) -$(call import-module,glog) -$(call import-module,jsi) -$(call import-module,folly) -$(call import-module,react/config) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/mounting) -$(call import-module,react/renderer/uimanager) -$(call import-module,yogajni) -$(call import-module,runtimeexecutor) -$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/attributedstring/Android.mk b/ReactCommon/react/renderer/attributedstring/Android.mk deleted file mode 100644 index 687a29d580d4b8..00000000000000 --- a/ReactCommon/react/renderer/attributedstring/Android.mk +++ /dev/null @@ -1,53 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_attributedstring - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libbutter \ - libfolly_runtime \ - libglog_init \ - libreact_debug \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_mapbuffer \ - libreact_utils \ - librrc_view \ - libyoga - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,butter) -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/components/root) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,yogajni) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/componentregistry/Android.mk b/ReactCommon/react/renderer/componentregistry/Android.mk deleted file mode 100644 index 4be170a8b27e2f..00000000000000 --- a/ReactCommon/react/renderer/componentregistry/Android.mk +++ /dev/null @@ -1,42 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_componentregistry - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SHARED_LIBRARIES := \ - libfolly_runtime \ - libglog_init \ - libjsi \ - libreact_debug \ - libreact_render_core \ - libreact_render_debug \ - libreact_utils - - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,fbgloginit) -$(call import-module,folly) -$(call import-module,jsi) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/utils) -$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/componentregistry/native/Android.mk b/ReactCommon/react/renderer/componentregistry/native/Android.mk deleted file mode 100644 index a4fdc90c41950e..00000000000000 --- a/ReactCommon/react/renderer/componentregistry/native/Android.mk +++ /dev/null @@ -1,37 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_native - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_SHARED_LIBRARIES := \ - libfolly_runtime \ - libglog_init \ - libjsi \ - libreact_debug \ - libreact_render_core \ - libreact_render_debug \ - libreact_utils - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,fbgloginit) -$(call import-module,folly) -$(call import-module,jsi) diff --git a/ReactCommon/react/renderer/components/image/Android.mk b/ReactCommon/react/renderer/components/image/Android.mk deleted file mode 100644 index b67ca0d1673f5f..00000000000000 --- a/ReactCommon/react/renderer/components/image/Android.mk +++ /dev/null @@ -1,51 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_image - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfolly_runtime \ - libglog_init \ - libjsi \ - libreact_debug \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_imagemanager \ - libreact_render_mapbuffer \ - librrc_view \ - libyoga - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/imagemanager) -$(call import-module,react/renderer/components/view) -$(call import-module,yogajni) -$(call import-module,react/debug) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/components/modal/Android.mk b/ReactCommon/react/renderer/components/modal/Android.mk deleted file mode 100644 index 6506921bb6565f..00000000000000 --- a/ReactCommon/react/renderer/components/modal/Android.mk +++ /dev/null @@ -1,55 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_modal - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfolly_runtime \ - libglog_init \ - libreact_codegen_rncore \ - libreact_render_componentregistry \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_imagemanager \ - libreact_render_mapbuffer \ - libreact_render_uimanager \ - librrc_image \ - librrc_view \ - libyoga - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/imagemanager) -$(call import-module,react/renderer/uimanager) -$(call import-module,react/renderer/components/image) -$(call import-module,react/renderer/components/view) -$(call import-module,yogajni) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/components/progressbar/Android.mk b/ReactCommon/react/renderer/components/progressbar/Android.mk deleted file mode 100644 index 329a616717acb2..00000000000000 --- a/ReactCommon/react/renderer/components/progressbar/Android.mk +++ /dev/null @@ -1,53 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_progressbar - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/android/react/renderer/components/progressbar/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/android/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/android/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfbjni \ - libfolly_runtime \ - libglog_init \ - libreact_codegen_rncore \ - libreact_debug \ - libreact_render_componentregistry \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_uimanager \ - libreactnativeutilsjni \ - librrc_view \ - libyoga - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,fbjni) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,glog) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/uimanager) -$(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/components/root/Android.mk b/ReactCommon/react/renderer/components/root/Android.mk deleted file mode 100644 index 2fef31ee3a78ff..00000000000000 --- a/ReactCommon/react/renderer/components/root/Android.mk +++ /dev/null @@ -1,46 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_root - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfolly_runtime \ - libglog_init \ - libreact_debug \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - librrc_view \ - libyoga - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/debug) -$(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/components/scrollview/Android.mk b/ReactCommon/react/renderer/components/scrollview/Android.mk deleted file mode 100644 index 1183e69d2d929d..00000000000000 --- a/ReactCommon/react/renderer/components/scrollview/Android.mk +++ /dev/null @@ -1,49 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_scrollview - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfolly_runtime \ - libglog_init \ - libjsi \ - libreact_debug \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_mapbuffer \ - librrc_view \ - libyoga - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/debug) -$(call import-module,yogajni) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/components/slider/Android.mk b/ReactCommon/react/renderer/components/slider/Android.mk deleted file mode 100644 index f4ea402f1788ed..00000000000000 --- a/ReactCommon/react/renderer/components/slider/Android.mk +++ /dev/null @@ -1,59 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_slider - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/platform/android/react/renderer/components/slider/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ $(LOCAL_PATH)/platform/android/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ $(LOCAL_PATH)/platform/android/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfbjni \ - libfolly_runtime \ - libglog_init \ - libreact_codegen_rncore \ - libreact_debug \ - libreact_render_componentregistry \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_imagemanager \ - libreact_render_mapbuffer \ - libreact_render_uimanager \ - libreactnativeutilsjni \ - librrc_image \ - librrc_view \ - libyoga - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,fbjni) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,glog) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/imagemanager) -$(call import-module,react/renderer/components/image) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/uimanager) -$(call import-module,yogajni) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/components/switch/Android.mk b/ReactCommon/react/renderer/components/switch/Android.mk deleted file mode 100644 index 5595fc08a0ee16..00000000000000 --- a/ReactCommon/react/renderer/components/switch/Android.mk +++ /dev/null @@ -1,53 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_switch - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/androidswitch/react/renderer/components/androidswitch/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/androidswitch/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/androidswitch/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfbjni \ - libfolly_runtime \ - libglog_init \ - libreact_codegen_rncore \ - libreact_debug \ - libreact_render_componentregistry \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_uimanager \ - libreactnativeutilsjni \ - librrc_view \ - libyoga - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,fbjni) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,glog) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/uimanager) -$(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/components/text/Android.mk b/ReactCommon/react/renderer/components/text/Android.mk deleted file mode 100644 index fb849bfbcb8731..00000000000000 --- a/ReactCommon/react/renderer/components/text/Android.mk +++ /dev/null @@ -1,59 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_text - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfolly_runtime \ - libglog_init \ - libjsi \ - libreact_debug \ - libreact_render_attributedstring \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_mapbuffer \ - libreact_render_mounting \ - libreact_render_textlayoutmanager \ - libreact_render_uimanager \ - libreact_utils \ - librrc_view \ - libyoga - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/attributedstring) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/mounting) -$(call import-module,react/renderer/textlayoutmanager) -$(call import-module,react/renderer/uimanager) -$(call import-module,react/renderer/components/view) -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,react/renderer/mapbuffer) -$(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/components/textinput/Android.mk b/ReactCommon/react/renderer/components/textinput/Android.mk deleted file mode 100644 index 55bcbf7333f811..00000000000000 --- a/ReactCommon/react/renderer/components/textinput/Android.mk +++ /dev/null @@ -1,67 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_textinput - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/androidtextinput/react/renderer/components/androidtextinput/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/androidtextinput/react/renderer/components/androidtextinput/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/androidtextinput/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfolly_runtime \ - libglog_init \ - libjsi \ - libreact_debug \ - libreact_render_attributedstring \ - libreact_render_componentregistry \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_imagemanager \ - libreact_render_mapbuffer \ - libreact_render_mounting \ - libreact_render_textlayoutmanager \ - libreact_render_uimanager \ - libreact_utils \ - librrc_image \ - librrc_text \ - librrc_view \ - libyoga - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/attributedstring) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/imagemanager) -$(call import-module,react/renderer/mounting) -$(call import-module,react/renderer/textlayoutmanager) -$(call import-module,react/renderer/uimanager) -$(call import-module,react/renderer/components/image) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/components/text) -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,yogajni) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/components/unimplementedview/Android.mk b/ReactCommon/react/renderer/components/unimplementedview/Android.mk deleted file mode 100644 index 4b2790193eb333..00000000000000 --- a/ReactCommon/react/renderer/components/unimplementedview/Android.mk +++ /dev/null @@ -1,47 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_unimplementedview - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfolly_runtime \ - libglog_init \ - libjsi \ - libreact_debug \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - librrc_view \ - libyoga - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,yogajni) -$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/components/view/Android.mk b/ReactCommon/react/renderer/components/view/Android.mk deleted file mode 100644 index a72ada8f493dec..00000000000000 --- a/ReactCommon/react/renderer/components/view/Android.mk +++ /dev/null @@ -1,47 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := rrc_view - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfolly_runtime \ - libglog_init \ - libjsi \ - libreact_debug \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libyoga \ - logger \ - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,logger) -$(call import-module,yogajni) -$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/core/Android.mk b/ReactCommon/react/renderer/core/Android.mk deleted file mode 100644 index 0a632e9c5de6a5..00000000000000 --- a/ReactCommon/react/renderer/core/Android.mk +++ /dev/null @@ -1,41 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_core - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SHARED_LIBRARIES := \ - libfolly_runtime \ - libglog \ - libjsi \ - libreact_debug \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_utils - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,folly) -$(call import-module,jsi) -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/mapbuffer) diff --git a/ReactCommon/react/renderer/debug/Android.mk b/ReactCommon/react/renderer/debug/Android.mk deleted file mode 100644 index 03197646d6773c..00000000000000 --- a/ReactCommon/react/renderer/debug/Android.mk +++ /dev/null @@ -1,28 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_debug - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SHARED_LIBRARIES := libfolly_runtime - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,folly) diff --git a/ReactCommon/react/renderer/graphics/Android.mk b/ReactCommon/react/renderer/graphics/Android.mk deleted file mode 100644 index 72031a2ab8ae76..00000000000000 --- a/ReactCommon/react/renderer/graphics/Android.mk +++ /dev/null @@ -1,39 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_graphics - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp $(LOCAL_PATH)/platform/cxx/react/renderer/graphics/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfb \ - libfbjni \ - libfolly_runtime \ - libreact_debug - -LOCAL_STATIC_LIBRARIES := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/ - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,fbjni) -$(call import-module,fb) -$(call import-module,folly) -$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/imagemanager/Android.mk b/ReactCommon/react/renderer/imagemanager/Android.mk deleted file mode 100644 index d7cff3c77defa0..00000000000000 --- a/ReactCommon/react/renderer/imagemanager/Android.mk +++ /dev/null @@ -1,44 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_imagemanager - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp $(LOCAL_PATH)/platform/cxx/react/renderer/imagemanager/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_SHARED_LIBRARIES := \ - libfolly_runtime \ - libreact_debug \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_mounting \ - libyoga - -LOCAL_STATIC_LIBRARIES := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/ - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/mounting) -$(call import-module,react/debug) -$(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/leakchecker/Android.mk b/ReactCommon/react/renderer/leakchecker/Android.mk deleted file mode 100644 index 31dceaf7bebcce..00000000000000 --- a/ReactCommon/react/renderer/leakchecker/Android.mk +++ /dev/null @@ -1,33 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_leakchecker - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libreact_render_core \ - libruntimeexecutor - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,react/renderer/core) -$(call import-module,glog) -$(call import-module,runtimeexecutor) diff --git a/ReactCommon/react/renderer/mapbuffer/Android.mk b/ReactCommon/react/renderer/mapbuffer/Android.mk deleted file mode 100644 index 7b9250cf357ee4..00000000000000 --- a/ReactCommon/react/renderer/mapbuffer/Android.mk +++ /dev/null @@ -1,34 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_mapbuffer - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libglog_init \ - libreact_debug - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,fbgloginit) -$(call import-module,react/debug) diff --git a/ReactCommon/react/renderer/mounting/Android.mk b/ReactCommon/react/renderer/mounting/Android.mk deleted file mode 100644 index 432d11160aa481..00000000000000 --- a/ReactCommon/react/renderer/mounting/Android.mk +++ /dev/null @@ -1,55 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_mounting - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libbutter \ - libfolly_runtime \ - libglog_init \ - libjsi \ - libreact_debug \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_telemetry \ - libreact_utils \ - librrc_root \ - librrc_view \ - libyoga - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,butter) -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,fbgloginit) -$(call import-module,react/renderer/components/root) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,yogajni) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/telemetry) diff --git a/ReactCommon/react/renderer/runtimescheduler/Android.mk b/ReactCommon/react/renderer/runtimescheduler/Android.mk deleted file mode 100644 index 59aa098484ba7b..00000000000000 --- a/ReactCommon/react/renderer/runtimescheduler/Android.mk +++ /dev/null @@ -1,34 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_runtimescheduler - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_SHARED_LIBRARIES := \ - callinvoker \ - libjsi \ - libreact_debug \ - libreact_render_core \ - libruntimeexecutor \ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,runtimeexecutor) -$(call import-module,callinvoker) diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp index b12c4e390d0f87..fd041aca8a4c02 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp @@ -22,19 +22,13 @@ RuntimeScheduler::RuntimeScheduler( void RuntimeScheduler::scheduleWork( std::function callback) const { - if (enableYielding_) { - runtimeAccessRequests_ += 1; - runtimeExecutor_( - [this, callback = std::move(callback)](jsi::Runtime &runtime) { - runtimeAccessRequests_ -= 1; - callback(runtime); - startWorkLoop(runtime); - }); - } else { - runtimeExecutor_([callback = std::move(callback)](jsi::Runtime &runtime) { - callback(runtime); - }); - } + runtimeAccessRequests_ += 1; + runtimeExecutor_( + [this, callback = std::move(callback)](jsi::Runtime &runtime) { + runtimeAccessRequests_ -= 1; + callback(runtime); + startWorkLoop(runtime); + }); } std::shared_ptr RuntimeScheduler::scheduleTask( @@ -70,10 +64,6 @@ RuntimeSchedulerTimePoint RuntimeScheduler::now() const noexcept { return now_(); } -void RuntimeScheduler::setEnableYielding(bool enableYielding) { - enableYielding_ = enableYielding; -} - void RuntimeScheduler::executeNowOnTheSameThread( std::function callback) { runtimeAccessRequests_ += 1; diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h index f55d505221c6be..96dce49a47f311 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h @@ -105,7 +105,6 @@ class RuntimeScheduler final { * Thread synchronization must be enforced externally. */ void callExpiredTasks(jsi::Runtime &runtime); - void setEnableYielding(bool enableYielding); private: mutable std::priority_queue< @@ -144,15 +143,6 @@ class RuntimeScheduler final { */ mutable std::atomic_bool isWorkLoopScheduled_{false}; - /* - * Flag indicating if yielding is enabled. - * - * If set to true and Concurrent Mode is enabled on the surface, - * React Native will ask React to yield in case any work has been scheduled. - * Default value is false - */ - bool enableYielding_{false}; - /* * This flag is set while performing work, to prevent re-entrancy. */ diff --git a/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp b/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp index cc1603c06f62f7..d5561e04749ae8 100644 --- a/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp @@ -43,7 +43,6 @@ class RuntimeSchedulerTest : public testing::Test { runtimeScheduler_ = std::make_unique(runtimeExecutor, stubNow); - runtimeScheduler_->setEnableYielding(true); } jsi::Function createHostFunctionFromLambda( @@ -317,24 +316,6 @@ TEST_F(RuntimeSchedulerTest, getCurrentPriorityLevel) { SchedulerPriority::NormalPriority); } -TEST_F(RuntimeSchedulerTest, scheduleWork) { - runtimeScheduler_->setEnableYielding(false); - bool wasCalled = false; - runtimeScheduler_->scheduleWork( - [&](jsi::Runtime const &) { wasCalled = true; }); - - EXPECT_FALSE(wasCalled); - - EXPECT_FALSE(runtimeScheduler_->getShouldYield()); - - EXPECT_EQ(stubQueue_->size(), 1); - - stubQueue_->tick(); - - EXPECT_TRUE(wasCalled); - EXPECT_EQ(stubQueue_->size(), 0); -} - TEST_F(RuntimeSchedulerTest, scheduleWorkWithYielding) { bool wasCalled = false; runtimeScheduler_->scheduleWork( diff --git a/ReactCommon/react/renderer/scheduler/Android.mk b/ReactCommon/react/renderer/scheduler/Android.mk deleted file mode 100644 index 0eec52d2568bc0..00000000000000 --- a/ReactCommon/react/renderer/scheduler/Android.mk +++ /dev/null @@ -1,62 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_scheduler - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfolly_runtime \ - libjsi \ - libreact_debug \ - libreact_render_componentregistry \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_mounting \ - libreact_render_runtimescheduler \ - libreact_render_templateprocessor \ - libreact_render_uimanager \ - libreact_utils \ - libreact_config \ - librrc_root \ - librrc_view \ - libyoga - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,jsi) -$(call import-module,folly) -$(call import-module,react/config) -$(call import-module,react/renderer/components/root) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/mounting) -$(call import-module,react/renderer/uimanager) -$(call import-module,react/renderer/runtimescheduler) -$(call import-module,react/renderer/templateprocessor) -$(call import-module,react/utils) -$(call import-module,react/debug) -$(call import-module,yogajni) diff --git a/ReactCommon/react/renderer/telemetry/Android.mk b/ReactCommon/react/renderer/telemetry/Android.mk deleted file mode 100644 index 9ca9c7868d89f6..00000000000000 --- a/ReactCommon/react/renderer/telemetry/Android.mk +++ /dev/null @@ -1,43 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_telemetry - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libbutter \ - libfolly_runtime \ - libglog_init \ - libreact_debug \ - libreact_render_core \ - libreact_render_debug \ - libreact_utils \ - librrc_root \ - librrc_view \ - libyoga - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,butter) -$(call import-module,glog) -$(call import-module,folly) -$(call import-module,react/utils) diff --git a/ReactCommon/react/renderer/templateprocessor/Android.mk b/ReactCommon/react/renderer/templateprocessor/Android.mk deleted file mode 100644 index c810ecdaa098f4..00000000000000 --- a/ReactCommon/react/renderer/templateprocessor/Android.mk +++ /dev/null @@ -1,46 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_templateprocessor - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfolly_runtime \ - libjsi \ - libreact_render_componentregistry \ - libreact_render_core \ - libreact_render_debug \ - libreact_utils \ - libreact_config \ - react_render_uimanager - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,jsi) -$(call import-module,folly) -$(call import-module,react/config) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/uimanager) -$(call import-module,react/utils) -$(call import-module,react/renderer/componentregistry) diff --git a/ReactCommon/react/renderer/textlayoutmanager/Android.mk b/ReactCommon/react/renderer/textlayoutmanager/Android.mk deleted file mode 100644 index a57d0eee6f06ce..00000000000000 --- a/ReactCommon/react/renderer/textlayoutmanager/Android.mk +++ /dev/null @@ -1,63 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_textlayoutmanager - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp $(LOCAL_PATH)/platform/android/react/renderer/textlayoutmanager/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfb \ - libfbjni \ - libfolly_runtime \ - libglog_init \ - libmapbufferjni \ - libreact_debug \ - libreact_render_attributedstring \ - libreact_render_componentregistry \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_mapbuffer \ - libreact_render_mounting \ - libreact_render_telemetry \ - libreact_render_uimanager \ - libreact_utils \ - libreactnativeutilsjni \ - libyoga - -LOCAL_STATIC_LIBRARIES := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/android/ - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/android/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,fbjni) -$(call import-module,fb) -$(call import-module,folly) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/attributedstring) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/mounting) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/uimanager) -$(call import-module,react/utils) -$(call import-module,yogajni) -$(call import-module,react/renderer/mapbuffer) -$(call import-module,react/renderer/telemetry) diff --git a/ReactCommon/react/renderer/uimanager/Android.mk b/ReactCommon/react/renderer/uimanager/Android.mk deleted file mode 100644 index caf9cd09a7599e..00000000000000 --- a/ReactCommon/react/renderer/uimanager/Android.mk +++ /dev/null @@ -1,58 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_render_uimanager - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := \ - glog \ - libfolly_runtime \ - libjsi \ - libreact_debug \ - libreact_render_componentregistry \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - libreact_render_leakchecker \ - libreact_render_runtimescheduler \ - libreact_render_mounting \ - libreact_config \ - librrc_root \ - librrc_view \ - libruntimeexecutor - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,glog) -$(call import-module,jsi) -$(call import-module,folly) -$(call import-module,react/config) -$(call import-module,react/renderer/components/root) -$(call import-module,react/renderer/components/view) -$(call import-module,react/renderer/componentregistry) -$(call import-module,react/renderer/core) -$(call import-module,react/renderer/leakchecker) -$(call import-module,react/renderer/runtimescheduler) -$(call import-module,react/renderer/debug) -$(call import-module,react/renderer/graphics) -$(call import-module,react/renderer/mounting) -$(call import-module,react/debug) -$(call import-module,runtimeexecutor) diff --git a/ReactCommon/react/utils/Android.mk b/ReactCommon/react/utils/Android.mk deleted file mode 100644 index 625a8f54e25608..00000000000000 --- a/ReactCommon/react/utils/Android.mk +++ /dev/null @@ -1,33 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := react_utils - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/../../ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"Fabric\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := \ - libglog \ - libglog_init \ - libreact_debug - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,react/debug) -$(call import-module,fbgloginit) -$(call import-module,glog) diff --git a/ReactCommon/reactperflogger/Android.mk b/ReactCommon/reactperflogger/Android.mk deleted file mode 100644 index 863a865a25d2b8..00000000000000 --- a/ReactCommon/reactperflogger/Android.mk +++ /dev/null @@ -1,26 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -# Header search path for all source files in this module. -LOCAL_C_INCLUDES := $(LOCAL_PATH)/reactperflogger - -# Header search path for modules that depend on this module -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -# Name of this module. -LOCAL_MODULE := reactperflogger - -# Compile all local c++ files under ./ReactCommon -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/reactperflogger/*.cpp) -LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) - -# Build the files in this directory as a shared library -include $(BUILD_STATIC_LIBRARY) diff --git a/ReactCommon/runtimeexecutor/Android.mk b/ReactCommon/runtimeexecutor/Android.mk deleted file mode 100644 index 147b1b2034a9c1..00000000000000 --- a/ReactCommon/runtimeexecutor/Android.mk +++ /dev/null @@ -1,19 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := runtimeexecutor - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/ReactCommon/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ReactCommon -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) diff --git a/ReactCommon/yoga/Android.mk b/ReactCommon/yoga/Android.mk deleted file mode 100644 index 23231fa32979b7..00000000000000 --- a/ReactCommon/yoga/Android.mk +++ /dev/null @@ -1,20 +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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := yogacore - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/yoga/*.cpp) -LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/yoga/*/*.cpp) - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) - -LOCAL_CFLAGS := -fexceptions -frtti -O3 - -include $(BUILD_STATIC_LIBRARY) diff --git a/package.json b/package.json index ee79dff2b7765d..a5cd3da8f62ffe 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,8 @@ "scripts/codegen/codegen-utils.js", "scripts/codegen/generate-artifacts-executor.js", "scripts/codegen/generate-specs-cli-executor.js", + "scripts/hermes/hermes-utils.js", + "scripts/hermes/prepare-hermes-for-build.js", "scripts/ios-configure-glog.sh", "scripts/xcode/with-environment.sh", "scripts/launchPackager.bat", diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 5e152e001481ba..8776caaa9232a9 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -295,6 +295,10 @@ export type NativeModulePromiseTypeAnnotation = $ReadOnly<{ type: 'PromiseTypeAnnotation', }>; +export type NativeModuleMixedTypeAnnotation = $ReadOnly<{ + type: 'MixedTypeAnnotation', +}>; + export type NativeModuleBaseTypeAnnotation = | NativeModuleStringTypeAnnotation | NativeModuleNumberTypeAnnotation @@ -306,7 +310,8 @@ export type NativeModuleBaseTypeAnnotation = | ReservedTypeAnnotation | NativeModuleTypeAliasTypeAnnotation | NativeModuleArrayTypeAnnotation> - | NativeModuleObjectTypeAnnotation; + | NativeModuleObjectTypeAnnotation + | NativeModuleMixedTypeAnnotation; export type NativeModuleParamTypeAnnotation = | NativeModuleBaseTypeAnnotation diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js index 2e6da494e43117..5bc19c9b8f7b00 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js @@ -114,9 +114,9 @@ function serializeArg( realTypeAnnotation = resolveAlias(realTypeAnnotation.name); } - function wrap(suffix) { + function wrap(callback) { const val = `args[${index}]`; - const expression = `${val}${suffix}`; + const expression = callback(val); if (nullable) { return `${val}.isNull() || ${val}.isUndefined() ? std::nullopt : std::make_optional(${expression})`; @@ -129,7 +129,7 @@ function serializeArg( case 'ReservedTypeAnnotation': switch (realTypeAnnotation.name) { case 'RootTag': - return wrap('.getNumber()'); + return wrap(val => `${val}.getNumber()`); default: (realTypeAnnotation.name: empty); throw new Error( @@ -137,25 +137,27 @@ function serializeArg( ); } case 'StringTypeAnnotation': - return wrap('.asString(rt)'); + return wrap(val => `${val}.asString(rt)`); case 'BooleanTypeAnnotation': - return wrap('.asBool()'); + return wrap(val => `${val}.asBool()`); case 'NumberTypeAnnotation': - return wrap('.asNumber()'); + return wrap(val => `${val}.asNumber()`); case 'FloatTypeAnnotation': - return wrap('.asNumber()'); + return wrap(val => `${val}.asNumber()`); case 'DoubleTypeAnnotation': - return wrap('.asNumber()'); + return wrap(val => `${val}.asNumber()`); case 'Int32TypeAnnotation': - return wrap('.asNumber()'); + return wrap(val => `${val}.asNumber()`); case 'ArrayTypeAnnotation': - return wrap('.asObject(rt).asArray(rt)'); + return wrap(val => `${val}.asObject(rt).asArray(rt)`); case 'FunctionTypeAnnotation': - return wrap('.asObject(rt).asFunction(rt)'); + return wrap(val => `${val}.asObject(rt).asFunction(rt)`); case 'GenericObjectTypeAnnotation': - return wrap('.asObject(rt)'); + return wrap(val => `${val}.asObject(rt)`); case 'ObjectTypeAnnotation': - return wrap('.asObject(rt)'); + return wrap(val => `${val}.asObject(rt)`); + case 'MixedTypeAnnotation': + return wrap(val => `jsi::Value(rt, ${val})`); default: (realTypeAnnotation.type: empty); throw new Error( diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js index 17c4f927118b59..d21f33c928355c 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js @@ -156,6 +156,8 @@ function translatePrimitiveJSTypeToCpp( return wrap('jsi::Function'); case 'PromiseTypeAnnotation': return wrap('jsi::Value'); + case 'MixedTypeAnnotation': + return wrap('jsi::Value'); default: (realTypeAnnotation.type: empty); throw new Error(createErrorMessage(realTypeAnnotation.type)); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js index 940b721ad41647..538371a7c49520 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js @@ -156,7 +156,7 @@ function translateFunctionParamToJavaType( imports.add('com.facebook.react.bridge.Callback'); return 'Callback'; default: - (realTypeAnnotation.type: empty); + (realTypeAnnotation.type: 'MixedTypeAnnotation'); throw new Error(createErrorMessage(realTypeAnnotation.type)); } } @@ -220,7 +220,7 @@ function translateFunctionReturnTypeToJavaType( imports.add('com.facebook.react.bridge.WritableArray'); return wrapIntoNullableIfNeeded('WritableArray'); default: - (realTypeAnnotation.type: empty); + (realTypeAnnotation.type: 'MixedTypeAnnotation'); throw new Error(createErrorMessage(realTypeAnnotation.type)); } } @@ -272,7 +272,7 @@ function getFalsyReturnStatementFromReturnType( case 'ArrayTypeAnnotation': return 'return null;'; default: - (realTypeAnnotation.type: empty); + (realTypeAnnotation.type: 'MixedTypeAnnotation'); throw new Error(createErrorMessage(realTypeAnnotation.type)); } } diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js index 756bde5fa6bbb5..4adb37c943c56d 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js @@ -171,7 +171,7 @@ function translateReturnTypeToKind( case 'ArrayTypeAnnotation': return 'ArrayKind'; default: - (realTypeAnnotation.type: empty); + (realTypeAnnotation.type: 'MixedTypeAnnotation'); throw new Error( `Unknown prop type for returning value, found: ${realTypeAnnotation.type}"`, ); @@ -226,7 +226,7 @@ function translateParamTypeToJniType( case 'FunctionTypeAnnotation': return 'Lcom/facebook/react/bridge/Callback;'; default: - (realTypeAnnotation.type: empty); + (realTypeAnnotation.type: 'MixedTypeAnnotation'); throw new Error( `Unknown prop type for method arg, found: ${realTypeAnnotation.type}"`, ); @@ -278,7 +278,7 @@ function translateReturnTypeToJniType( case 'ArrayTypeAnnotation': return 'Lcom/facebook/react/bridge/WritableArray;'; default: - (realTypeAnnotation.type: empty); + (realTypeAnnotation.type: 'MixedTypeAnnotation'); throw new Error( `Unknown prop type for method return type, found: ${realTypeAnnotation.type}"`, ); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js index 725809dfdf65d0..e942ff3c978255 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js @@ -112,6 +112,8 @@ class StructCollector { this._insertAlias(typeAnnotation.name, structContext, resolveAlias); return wrapNullable(nullable, typeAnnotation); } + case 'MixedTypeAnnotation': + throw new Error('Mixed types are unsupported in structs'); default: { return wrapNullable(nullable, typeAnnotation); } diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js index bb258919c6bc4b..8bedb6cb61f929 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js @@ -338,7 +338,7 @@ function getReturnObjCType( case 'GenericObjectTypeAnnotation': return wrapIntoNullableIfNeeded('NSDictionary *'); default: - (typeAnnotation.type: empty); + (typeAnnotation.type: 'MixedTypeAnnotation'); throw new Error( `Unsupported return type for ${methodName}. Found: ${typeAnnotation.type}`, ); @@ -378,7 +378,7 @@ function getReturnJSType( case 'GenericObjectTypeAnnotation': return 'ObjectKind'; default: - (typeAnnotation.type: empty); + (typeAnnotation.type: 'MixedTypeAnnotation'); throw new Error( `Unsupported return type for ${methodName}. Found: ${typeAnnotation.type}`, ); diff --git a/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js index 48647b993c0105..16f6bd517ba44d 100644 --- a/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js @@ -1502,6 +1502,79 @@ const REAL_MODULE_EXAMPLE: SchemaType = { }, }; +const CXX_ONLY_NATIVE_MODULES: SchemaType = { + modules: { + NativeSampleTurboModule: { + type: 'NativeModule', + aliases: { + ObjectAlias: { + type: 'ObjectTypeAnnotation', + properties: [ + { + name: 'x', + optional: false, + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, + ], + }, + }, + spec: { + properties: [ + { + name: 'getMixed', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'MixedTypeAnnotation', + }, + params: [ + { + name: 'arg', + optional: false, + typeAnnotation: { + type: 'MixedTypeAnnotation', + }, + }, + ], + }, + }, + { + name: 'getNullableNumberFromNullableAlias', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, + params: [ + { + name: 'a', + optional: false, + typeAnnotation: { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'TypeAliasTypeAnnotation', + name: 'ObjectAlias', + }, + }, + }, + ], + }, + }, + ], + }, + moduleNames: ['SampleTurboModuleCxx'], + excludedPlatforms: ['iOS', 'android'], + }, + }, +}; + const SAMPLE_WITH_UPPERCASE_NAME: SchemaType = { modules: { NativeSampleTurboModule: { @@ -1522,5 +1595,6 @@ module.exports = { simple_native_modules: SIMPLE_NATIVE_MODULES, native_modules_with_type_aliases: NATIVE_MODULES_WITH_TYPE_ALIASES, real_module_example: REAL_MODULE_EXAMPLE, + cxx_only_native_modules: CXX_ONLY_NATIVE_MODULES, SampleWithUppercaseName: SAMPLE_WITH_UPPERCASE_NAME, }; diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap index c4713fb7431cf1..02017d09bf4e6f 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap @@ -83,6 +83,42 @@ NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared } +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateModuleCpp can generate fixture cxx_only_native_modules 1`] = ` +Map { + "cxx_only_native_modulesJSI-generated.cpp" => "/** + * 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 + */ + +#include \\"cxx_only_native_modulesJSI.h\\" + +namespace facebook { +namespace react { + +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getMixed(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getMixed(rt, jsi::Value(rt, args[0])); +} +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNullableNumberFromNullableAlias(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getNullableNumberFromNullableAlias(rt, args[0].isNull() || args[0].isUndefined() ? std::nullopt : std::make_optional(args[0].asObject(rt))); +} + +NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker) + : TurboModule(\\"SampleTurboModuleCxx\\", jsInvoker) { + methodMap_[\\"getMixed\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getMixed}; + methodMap_[\\"getNullableNumberFromNullableAlias\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getNullableNumberFromNullableAlias}; +} + + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap index 5bbd47d7380f70..7fce7ea931084a 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap @@ -183,6 +183,83 @@ private: } `; +exports[`GenerateModuleH can generate fixture cxx_only_native_modules 1`] = ` +Map { + "cxx_only_native_modulesJSI.h" => "/** + * 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 +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT NativeSampleTurboModuleCxxSpecJSI : public TurboModule { +protected: + NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); + +public: + virtual jsi::Value getMixed(jsi::Runtime &rt, jsi::Value arg) = 0; + virtual std::optional getNullableNumberFromNullableAlias(jsi::Runtime &rt, std::optional a) = 0; + +}; + +template +class JSI_EXPORT NativeSampleTurboModuleCxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } + +protected: + NativeSampleTurboModuleCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(\\"SampleTurboModuleCxx\\", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public NativeSampleTurboModuleCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeSampleTurboModuleCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + jsi::Value getMixed(jsi::Runtime &rt, jsi::Value arg) override { + static_assert( + bridging::getParameterCount(&T::getMixed) == 2, + \\"Expected getMixed(...) to have 2 parameters\\"); + + return bridging::callFromJs( + rt, &T::getMixed, jsInvoker_, instance_, std::move(arg)); + } + std::optional getNullableNumberFromNullableAlias(jsi::Runtime &rt, std::optional a) override { + static_assert( + bridging::getParameterCount(&T::getNullableNumberFromNullableAlias) == 2, + \\"Expected getNullableNumberFromNullableAlias(...) to have 2 parameters\\"); + + return bridging::callFromJs>( + rt, &T::getNullableNumberFromNullableAlias, jsInvoker_, instance_, std::move(a)); + } + + private: + T *instance_; + }; + + Delegate delegate_; +}; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateModuleH can generate fixture empty_native_modules 1`] = ` Map { "empty_native_modulesJSI.h" => "/** diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap index d17ebebe5f6644..07ab8ba9129c19 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap @@ -308,6 +308,41 @@ inline facebook::react::LazyVector "/** + * 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 +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import + + + ", } `; diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap index fed306c0cea645..3fec5218b9ffa3 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap @@ -100,6 +100,8 @@ public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaMo } `; +exports[`GenerateModuleJavaSpec can generate fixture cxx_only_native_modules 1`] = `Map {}`; + exports[`GenerateModuleJavaSpec can generate fixture empty_native_modules 1`] = ` Map { "java/com/facebook/fbreact/specs/NativeSampleTurboModuleSpec.java" => " diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap index 323cb75d3122b2..9d771b73dddaa2 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap @@ -113,6 +113,36 @@ std::shared_ptr complex_objects_ModuleProvider(const std::string &m } `; +exports[`GenerateModuleJniCpp can generate fixture cxx_only_native_modules 1`] = ` +Map { + "jni/cxx_only_native_modules-generated.cpp" => " +/** + * 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 \\"cxx_only_native_modules.h\\" + +namespace facebook { +namespace react { + + + +std::shared_ptr cxx_only_native_modules_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { + + return nullptr; +} + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateModuleJniCpp can generate fixture empty_native_modules 1`] = ` Map { "jni/empty_native_modules-generated.cpp" => " diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap index 2a041e62bb68ce..9f39609d66e8a8 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap @@ -218,6 +218,108 @@ target_compile_options( } `; +exports[`GenerateModuleJniH can generate fixture cxx_only_native_modules 1`] = ` +Map { + "jni/cxx_only_native_modules.h" => " +/** + * 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 +#include +#include + +namespace facebook { +namespace react { + + + +std::shared_ptr cxx_only_native_modules_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); + +} // namespace react +} // namespace facebook +", + "jni/Android.mk" => "# 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. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := react_codegen_cxx_only_native_modules + +LOCAL_C_INCLUDES := $(LOCAL_PATH) + +LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/react/renderer/components/cxx_only_native_modules/*.cpp) +LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(LOCAL_SRC_FILES)) + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/cxx_only_native_modules + +LOCAL_SHARED_LIBRARIES := libfbjni libfolly_runtime libglog libjsi libreact_codegen_rncore libreact_debug libreact_nativemodule_core libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libturbomodulejsijni libyoga + +LOCAL_CFLAGS := \\\\ + -DLOG_TAG=\\\\\\"ReactNative\\\\\\" + +LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall + +include $(BUILD_SHARED_LIBRARY) +", + "jni/CMakeLists.txt" => "# 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/cxx_only_native_modules/*.cpp) + +add_library( + react_codegen_cxx_only_native_modules + SHARED + \${react_codegen_SRCS} +) + +target_include_directories(react_codegen_cxx_only_native_modules PUBLIC . react/renderer/components/cxx_only_native_modules) + +target_link_libraries( + react_codegen_cxx_only_native_modules + fbjni + folly_runtime + glog + react_codegen_rncore + react_debug + react_nativemodule_core + react_render_core + react_render_debug + react_render_graphics + rrc_view + turbomodulejsijni + yoga +) + +target_compile_options( + react_codegen_cxx_only_native_modules + PRIVATE + -DLOG_TAG=\\\\\\"ReactNative\\\\\\" + -fexceptions + -frtti + -std=c++17 + -Wall +) +", +} +`; + exports[`GenerateModuleJniH can generate fixture empty_native_modules 1`] = ` Map { "jni/empty_native_modules.h" => " diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap index 584f1017ea5c05..3b2acb73c23930 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap @@ -146,6 +146,28 @@ namespace facebook { } `; +exports[`GenerateModuleMm can generate fixture cxx_only_native_modules 1`] = ` +Map { + "cxx_only_native_modules-generated.mm" => "/** + * 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 \\"cxx_only_native_modules.h\\" + + +", +} +`; + exports[`GenerateModuleMm can generate fixture empty_native_modules 1`] = ` Map { "empty_native_modules-generated.mm" => "/** diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js index ef8938c70efb6f..cbbc156c29f97c 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js @@ -161,7 +161,8 @@ export type ObjectAlias = {| y: number, label: string, truthy: boolean, -|} +|}; +export type ReadOnlyAlias = $ReadOnly; export interface Spec extends TurboModule { // Exported methods. @@ -169,6 +170,9 @@ export interface Spec extends TurboModule { +getVoid: () => Void; +getArray: (a: Array) => {| a: B |}; +getStringFromAlias: (a: ObjectAlias) => string; + +getStringFromNullableAlias: (a: ?ObjectAlias) => string; + +getStringFromReadOnlyAlias: (a: ReadOnlyAlias) => string; + +getStringFromNullableReadOnlyAlias: (a: ?ReadOnlyAlias) => string; } export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); @@ -591,6 +595,7 @@ import * as TurboModuleRegistry from '../TurboModuleRegistry'; export interface Spec extends TurboModule { +getCallback: () => () => void; + +getMixed: (arg: mixed) => mixed; } export default TurboModuleRegistry.getEnforcing('SampleTurboModuleCxx'); diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap index d6858f03512932..aef18a0ef6c783 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap @@ -58,6 +58,25 @@ exports[`RN Codegen Flow Parser can generate fixture CXX_ONLY_NATIVE_MODULE 1`] }, 'params': [] } + }, + { + 'name': 'getMixed', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'MixedTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'MixedTypeAnnotation' + } + } + ] + } } ] }, @@ -232,6 +251,72 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_ALIASES } ] } + }, + { + 'name': 'getStringFromNullableAlias', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'StringTypeAnnotation' + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'NullableTypeAnnotation', + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'ObjectAlias' + } + } + } + ] + } + }, + { + 'name': 'getStringFromReadOnlyAlias', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'StringTypeAnnotation' + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'ObjectAlias' + } + } + ] + } + }, + { + 'name': 'getStringFromNullableReadOnlyAlias', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'StringTypeAnnotation' + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'NullableTypeAnnotation', + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'ObjectAlias' + } + } + } + ] + } } ] }, diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index 293981660cef23..10153679a65767 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -173,14 +173,18 @@ function translateTypeAnnotation( typeAnnotation, ); - return translateTypeAnnotation( - hasteModuleName, - typeAnnotation.typeParameters.params[0], - types, - aliasMap, - tryParse, - cxxOnly, + const [paramType, isParamNullable] = unwrapNullable( + translateTypeAnnotation( + hasteModuleName, + typeAnnotation.typeParameters.params[0], + types, + aliasMap, + tryParse, + cxxOnly, + ), ); + + return wrapNullable(nullable || isParamNullable, paramType); } case 'Stringish': { return wrapNullable(nullable, { @@ -363,6 +367,14 @@ function translateTypeAnnotation( ), ); } + case 'MixedTypeAnnotation': { + if (cxxOnly) { + return wrapNullable(nullable, { + type: 'MixedTypeAnnotation', + }); + } + // Fallthrough + } default: { throw new UnsupportedFlowTypeAnnotationParserError( hasteModuleName, diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/parsers/typescript/modules/__test_fixtures__/fixtures.js index 553ac7becabd28..2d466d293d78b1 100644 --- a/packages/react-native-codegen/src/parsers/typescript/modules/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/parsers/typescript/modules/__test_fixtures__/fixtures.js @@ -146,6 +146,7 @@ export type ObjectAlias = { label: string; truthy: boolean; }; +export type ReadOnlyAlias = Readonly; export interface Spec extends TurboModule { // Exported methods. @@ -153,6 +154,9 @@ export interface Spec extends TurboModule { readonly getVoid: () => Void; readonly getArray: (a: Array) => {a: B}; readonly getStringFromAlias: (a: ObjectAlias) => string; + readonly getStringFromNullableAlias: (a: ObjectAlias | null) => string; + readonly getStringFromReadOnlyAlias: (a: ReadOnlyAlias) => string; + readonly getStringFromNullableReadOnlyAlias: (a: ReadOnlyAlias | null) => string; } export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); @@ -519,6 +523,7 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo export interface Spec extends TurboModule { readonly getCallback: () => () => void; + readonly getMixed: (arg: unknown) => unknown; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/__snapshots__/typescript-module-parser-snapshot-test.js.snap b/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/__snapshots__/typescript-module-parser-snapshot-test.js.snap index 68272d1141126f..8a49cb12a3d0e2 100644 --- a/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/__snapshots__/typescript-module-parser-snapshot-test.js.snap +++ b/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/__snapshots__/typescript-module-parser-snapshot-test.js.snap @@ -56,6 +56,25 @@ exports[`RN Codegen TypeScript Parser can generate fixture CXX_ONLY_NATIVE_MODUL }, 'params': [] } + }, + { + 'name': 'getMixed', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'MixedTypeAnnotation' + }, + 'params': [ + { + 'name': 'arg', + 'optional': false, + 'typeAnnotation': { + 'type': 'MixedTypeAnnotation' + } + } + ] + } } ] }, @@ -230,6 +249,72 @@ exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_AL } ] } + }, + { + 'name': 'getStringFromNullableAlias', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'StringTypeAnnotation' + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'NullableTypeAnnotation', + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'ObjectAlias' + } + } + } + ] + } + }, + { + 'name': 'getStringFromReadOnlyAlias', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'StringTypeAnnotation' + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'ObjectAlias' + } + } + ] + } + }, + { + 'name': 'getStringFromNullableReadOnlyAlias', + 'optional': false, + 'typeAnnotation': { + 'type': 'FunctionTypeAnnotation', + 'returnTypeAnnotation': { + 'type': 'StringTypeAnnotation' + }, + 'params': [ + { + 'name': 'a', + 'optional': false, + 'typeAnnotation': { + 'type': 'NullableTypeAnnotation', + 'typeAnnotation': { + 'type': 'TypeAliasTypeAnnotation', + 'name': 'ObjectAlias' + } + } + } + ] + } } ] }, diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/index.js b/packages/react-native-codegen/src/parsers/typescript/modules/index.js index 564497cf707d0b..66041f980dfa91 100644 --- a/packages/react-native-codegen/src/parsers/typescript/modules/index.js +++ b/packages/react-native-codegen/src/parsers/typescript/modules/index.js @@ -173,14 +173,18 @@ function translateTypeAnnotation( typeAnnotation, ); - return translateTypeAnnotation( - hasteModuleName, - typeAnnotation.typeParameters.params[0], - types, - aliasMap, - tryParse, - cxxOnly, + const [paramType, isParamNullable] = unwrapNullable( + translateTypeAnnotation( + hasteModuleName, + typeAnnotation.typeParameters.params[0], + types, + aliasMap, + tryParse, + cxxOnly, + ), ); + + return wrapNullable(nullable || isParamNullable, paramType); } case 'Stringish': { return wrapNullable(nullable, { @@ -363,6 +367,14 @@ function translateTypeAnnotation( ), ); } + case 'TSUnknownKeyword': { + if (cxxOnly) { + return wrapNullable(nullable, { + type: 'MixedTypeAnnotation', + }); + } + // Fallthrough + } default: { throw new UnsupportedTypeScriptTypeAnnotationParserError( hasteModuleName, diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index 91811ab85812e5..8ead6c2d6eb1ff 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -9,6 +9,8 @@ platform :ios, '12.4' install! 'cocoapods', :deterministic_uuids => false USE_FRAMEWORKS = ENV['USE_FRAMEWORKS'] == '1' +IN_CI = ENV['CI'] == 'true' + @prefix_path = "../.." if USE_FRAMEWORKS @@ -16,7 +18,7 @@ if USE_FRAMEWORKS use_frameworks! end -def pods(options = {}) +def pods(options = {}, use_flipper: false) project 'RNTesterPods.xcodeproj' fabric_enabled = true @@ -27,13 +29,15 @@ def pods(options = {}) # Custom fabric component is only supported when using codegen discovery. pod 'MyNativeView', :path => "NativeComponentExample" end - + use_react_native!( path: @prefix_path, fabric_enabled: fabric_enabled, hermes_enabled: hermes_enabled, + flipper_configuration: use_flipper ? FlipperConfiguration.enabled : FlipperConfiguration.disabled, app_path: "#{Dir.pwd}", config_file_dir: "#{Dir.pwd}/node_modules", + production: !ENV['PRODUCTION'].nil? ) pod 'ReactCommon/turbomodule/samples', :path => "#{@prefix_path}/ReactCommon" @@ -47,10 +51,7 @@ def pods(options = {}) end target 'RNTester' do - pods() - if !USE_FRAMEWORKS - use_flipper! - end + pods({}, :use_flipper => !IN_CI && !USE_FRAMEWORKS) end target 'RNTesterUnitTests' do diff --git a/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTest.js b/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTest.js new file mode 100644 index 00000000000000..4cff62e3743da2 --- /dev/null +++ b/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTest.js @@ -0,0 +1,74 @@ +/** + * 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 + * @flow + */ + +import type {PlatformTestComponentBaseProps} from './RNTesterPlatformTestTypes'; + +import * as React from 'react'; +import {StyleSheet, View, Text, ScrollView} from 'react-native'; + +import RNTesterPlatformTestInstructions from './RNTesterPlatformTestInstructions'; +import usePlatformTestHarness from './usePlatformTestHarness'; +import RNTesterPlatformTestResultView from './RNTesterPlatformTestResultView'; + +type Props = $ReadOnly<{| + title: string, + description: string, + instructions?: $ReadOnlyArray, + component: React.ComponentType, +|}>; + +export default function RNTesterPlatformTest(props: Props): React.MixedElement { + const { + title, + description, + instructions, + component: UnderTestComponent, + } = props; + + const {harness, reset, results, testKey} = usePlatformTestHarness(); + + return ( + + {title} + {description} + + + + + + + ); +} + +const styles = StyleSheet.create({ + block: { + marginBottom: 8, + }, + description: { + fontSize: 16, + }, + textBlock: { + marginBottom: 8, + }, + root: { + padding: 8, + }, + title: { + fontSize: 32, + fontWeight: '700', + }, +}); diff --git a/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestInstructions.js b/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestInstructions.js new file mode 100644 index 00000000000000..74c7a9ed9569f5 --- /dev/null +++ b/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestInstructions.js @@ -0,0 +1,44 @@ +/** + * 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 + * @flow + */ + +import * as React from 'react'; +import {View, Text, StyleSheet} from 'react-native'; + +import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet'; + +type Props = $ReadOnly<{| + instructions?: $ReadOnlyArray, + style?: ?ViewStyleProp, +|}>; +export default function RNTesterPlatformTestInstructions({ + instructions, + style, +}: Props): React.MixedElement | null { + if (instructions == null) { + return null; + } + return ( + + {instructions.map((instruction, idx) => { + return ( + + {idx + 1}. {instruction} + + ); + })} + + ); +} + +const styles = StyleSheet.create({ + instructionText: { + fontSize: 16, + }, +}); diff --git a/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestResultView.js b/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestResultView.js new file mode 100644 index 00000000000000..a4be4d8d666245 --- /dev/null +++ b/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestResultView.js @@ -0,0 +1,184 @@ +/** + * 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 + * @flow + */ + +import type { + ViewStyleProp, + TextStyle, +} from 'react-native/Libraries/StyleSheet/StyleSheet'; +import type { + PlatformTestResult, + PlatformTestResultStatus, +} from './RNTesterPlatformTestTypes'; + +import * as React from 'react'; +import {useMemo} from 'react'; +import {Button, View, Text, StyleSheet} from 'react-native'; + +const DISPLAY_STATUS_MAPPING: {[PlatformTestResultStatus]: string} = { + PASS: 'Pass', + FAIL: 'Fail', + ERROR: 'Error', +}; + +type Props = $ReadOnly<{| + reset: () => void, + results: $ReadOnlyArray, + style?: ?ViewStyleProp, +|}>; +export default function RNTesterPlatformTestResultView( + props: Props, +): React.MixedElement { + const {reset, results, style} = props; + + const {numPass, numFail, numError} = useMemo( + () => + results.reduce( + (acc, result) => { + switch (result.status) { + case 'PASS': + return {...acc, numPass: acc.numPass + 1}; + case 'FAIL': + return {...acc, numFail: acc.numFail + 1}; + case 'ERROR': + return {...acc, numError: acc.numError + 1}; + } + }, + { + numPass: 0, + numFail: 0, + numError: 0, + }, + ), + [results], + ); + + return ( + + + Results +