From 671520943fba80b9c8ce4a5279520c7d4a7b14a9 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Mon, 13 Jan 2025 07:00:12 -0800 Subject: [PATCH 001/911] Remove build codegen from Cocoapods (#48631) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48631 This step is already carried out by [generate-artifact-executor](https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/codegen/generate-artifacts-executor.js#L385) if needed. We can remove it from cocoapods and this will make it easier to migrate away from them. For 3rd party apps that uses a specific version of React Native, codegen is shipped in NPM as already built in the react-native/codegen package. This change really affects only the React Native monorepo. ## Changelog [Internal] - Remove build codegen step from cocoapods Reviewed By: cortinico Differential Revision: D68019743 fbshipit-source-id: 7aaf9275886ba8b86d38d943d2b26bd8eed11aa8 --- .../react-native/scripts/cocoapods/codegen.rb | 15 --------------- .../react-native/scripts/react_native_pods.rb | 2 -- 2 files changed, 17 deletions(-) diff --git a/packages/react-native/scripts/cocoapods/codegen.rb b/packages/react-native/scripts/cocoapods/codegen.rb index d1c2c58d26a8b5..cd76a0a7540cab 100644 --- a/packages/react-native/scripts/cocoapods/codegen.rb +++ b/packages/react-native/scripts/cocoapods/codegen.rb @@ -5,21 +5,6 @@ require_relative './helpers.rb' -# It builds the codegen CLI if it is not present -# -# Parameters: -# - react_native_path: the path to the react native installation -# - relative_installation_root: the path to the relative installation root of the pods -# - dir_manager: a class that implements the `Dir` interface. Defaults to `Dir`, the Dependency can be injected for testing purposes. -# @throws an error if it could not find the codegen folder. -def build_codegen!(react_native_path, relative_installation_root, dir_manager: Dir) - codegen_repo_path = "#{basePath(react_native_path, relative_installation_root)}/../react-native-codegen" - return unless dir_manager.exist?(codegen_repo_path) && !dir_manager.exist?("#{codegen_repo_path}/lib") - - Pod::UI.puts "[Codegen] building #{codegen_repo_path}" - system("#{codegen_repo_path}/scripts/oss/build.sh") -end - # keeping the run_codegen! method for testing purposes def run_codegen!( app_path, diff --git a/packages/react-native/scripts/react_native_pods.rb b/packages/react-native/scripts/react_native_pods.rb index 4115944b2e9ce2..74c4c23cd4fb51 100644 --- a/packages/react-native/scripts/react_native_pods.rb +++ b/packages/react-native/scripts/react_native_pods.rb @@ -96,8 +96,6 @@ def use_react_native! ( ReactNativePodsUtils.warn_if_not_on_arm64() - build_codegen!(prefix, relative_path_from_current) - # The Pods which should be included in all projects pod 'FBLazyVector', :path => "#{prefix}/Libraries/FBLazyVector" pod 'RCTRequired', :path => "#{prefix}/Libraries/Required" From fe8d1026632a42e0feb3927ecaf40ed944110242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 13 Jan 2025 07:01:03 -0800 Subject: [PATCH 002/911] Create placeholder for User Timing API tests (#48634) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48634 Changelog: [internal] Just a placeholder to add new tests in the future. Reviewed By: sammy-SC Differential Revision: D68093342 fbshipit-source-id: 1e1d7fd71865763ef66b3bb1c76ff8b8ebca9fd9 --- .../__tests__/UserTimingAPI-itest.js | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 packages/react-native/src/private/webapis/performance/__tests__/UserTimingAPI-itest.js diff --git a/packages/react-native/src/private/webapis/performance/__tests__/UserTimingAPI-itest.js b/packages/react-native/src/private/webapis/performance/__tests__/UserTimingAPI-itest.js new file mode 100644 index 00000000000000..f016bd20160882 --- /dev/null +++ b/packages/react-native/src/private/webapis/performance/__tests__/UserTimingAPI-itest.js @@ -0,0 +1,71 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + * @oncall react_native + * @fantom_flags enableLongTaskAPI:true + */ + +import setUpPerformanceObserver from '../../../setup/setUpPerformanceObserver'; +import ensureInstance from '../../../utilities/ensureInstance'; +import {PerformanceMark} from '../UserTiming'; +import {runWorkLoop} from '@react-native/fantom'; + +import '../../../../../Libraries/Core/InitializeCore.js'; + +setUpPerformanceObserver(); + +describe('User Timing API', () => { + describe('performance.mark()', () => { + it('reports marks to observers', () => { + const callback = jest.fn(); + + const observer = new PerformanceObserver(callback); + observer.observe({type: 'mark'}); + + expect(callback).not.toHaveBeenCalled(); + + const mark1Detail = Symbol('mark1Detail'); + performance.mark('mark1', { + startTime: 100, + detail: mark1Detail, + }); + + const mark2Detail = Symbol('mark2Detail'); + performance.mark('mark2', { + startTime: 200, + detail: mark2Detail, + }); + + expect(callback).not.toHaveBeenCalled(); + + runWorkLoop(); + + expect(callback).toHaveBeenCalledTimes(1); + + const entries = callback.mock.lastCall[0].getEntries(); + expect(entries.length).toBe(2); + + const mark1 = ensureInstance(entries[0], PerformanceMark); + const mark2 = ensureInstance(entries[1], PerformanceMark); + + expect(mark1.entryType).toBe('mark'); + expect(mark1.name).toBe('mark1'); + expect(mark1.startTime).toBe(100); + expect(mark1.duration).toBe(0); + // This doesn't work through PerformanceObserver yet + // expect(mark1.detail).toBe(mark1Detail); + + expect(mark2.entryType).toBe('mark'); + expect(mark2.name).toBe('mark2'); + expect(mark2.startTime).toBe(200); + expect(mark2.duration).toBe(0); + // This doesn't work through PerformanceObserver yet + // expect(mark2.detail).toBe(mark2Detail); + }); + }); +}); From c7785e7ead44e45d751b8bf2162f713e1dd82c83 Mon Sep 17 00:00:00 2001 From: Thomas Nardone Date: Mon, 13 Jan 2025 08:39:18 -0800 Subject: [PATCH 003/911] Convert ReactTextInlineImageShadowNode (#48576) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48576 Changelog: [Internal] Reviewed By: cortinico Differential Revision: D67981753 fbshipit-source-id: 5d8a2408af9af350c0d3b369677ff8ee00335554 --- .../ReactTextInlineImageShadowNode.java | 24 ------------------- .../ReactTextInlineImageShadowNode.kt | 21 ++++++++++++++++ 2 files changed, 21 insertions(+), 24 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/ReactTextInlineImageShadowNode.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/ReactTextInlineImageShadowNode.kt diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/ReactTextInlineImageShadowNode.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/ReactTextInlineImageShadowNode.java deleted file mode 100644 index dbb409dc06b8ce..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/ReactTextInlineImageShadowNode.java +++ /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. - */ - -package com.facebook.react.views.text.internal; - -import com.facebook.react.uimanager.LayoutShadowNode; -import com.facebook.react.views.text.internal.span.TextInlineImageSpan; -import com.facebook.yoga.YogaNode; - -/** Base class for {@link YogaNode}s that represent inline images. */ -public abstract class ReactTextInlineImageShadowNode extends LayoutShadowNode { - - /** - * Build a {@link TextInlineImageSpan} from this node. This will be added to the TextView in place - * of this node. - */ - public abstract TextInlineImageSpan buildInlineImageSpan(); - - public ReactTextInlineImageShadowNode() {} -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/ReactTextInlineImageShadowNode.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/ReactTextInlineImageShadowNode.kt new file mode 100644 index 00000000000000..923bdf87f75747 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/ReactTextInlineImageShadowNode.kt @@ -0,0 +1,21 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.views.text.internal + +import com.facebook.react.uimanager.LayoutShadowNode +import com.facebook.react.views.text.internal.span.TextInlineImageSpan +import com.facebook.yoga.YogaNode + +/** Base class for [YogaNode]s that represent inline images. */ +internal abstract class ReactTextInlineImageShadowNode : LayoutShadowNode() { + /** + * Build a [TextInlineImageSpan] from this node. This will be added to the TextView in place of + * this node. + */ + public abstract fun buildInlineImageSpan(): TextInlineImageSpan +} From 12e321daf07d312c6b4947e306a449a7985ac19a Mon Sep 17 00:00:00 2001 From: Parsa Nasirimehr Date: Mon, 13 Jan 2025 08:44:05 -0800 Subject: [PATCH 004/911] chore(Android): Migrate Hermes Executor to Kotlin (#48617) Summary: Migrating HermesExecutor and it's factory to Kotlin. Not sure if the TAG in HermesExecutorFactory is needed anymore or not, but the rest of the changes are pretty bog standard ## Changelog: [INTERNAL] [FIXED] - Migrate HermesExecutor and HermesExecutorFactory to Kotlin Pull Request resolved: https://github.com/facebook/react-native/pull/48617 Test Plan: `./gradlew test`: Screenshot 2025-01-11 at 04 01 12 Reviewed By: tdn120 Differential Revision: D68094681 Pulled By: cortinico fbshipit-source-id: 16eae5c7c24886421cbd2cbf213295134a9c01cf --- .../hermes/reactexecutor/HermesExecutor.java | 50 ---------------- .../hermes/reactexecutor/HermesExecutor.kt | 53 +++++++++++++++++ .../reactexecutor/HermesExecutorFactory.java | 57 ------------------- .../reactexecutor/HermesExecutorFactory.kt | 42 ++++++++++++++ 4 files changed, 95 insertions(+), 107 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.kt delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.kt diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java deleted file mode 100644 index 2073bb4ffdb13d..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java +++ /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. - */ - -package com.facebook.hermes.reactexecutor; - -import com.facebook.jni.HybridData; -import com.facebook.react.bridge.JavaScriptExecutor; -import com.facebook.react.common.build.ReactBuildConfig; -import com.facebook.soloader.SoLoader; -import javax.annotation.Nullable; - -public class HermesExecutor extends JavaScriptExecutor { - private static String mode_; - - static { - loadLibrary(); - } - - public static void loadLibrary() throws UnsatisfiedLinkError { - if (mode_ == null) { - // libhermes must be loaded explicitly to invoke its JNI_OnLoad. - SoLoader.loadLibrary("hermes"); - SoLoader.loadLibrary("hermes_executor"); - // libhermes_executor is built differently for Debug & Release so we load the proper mode. - mode_ = ReactBuildConfig.DEBUG ? "Debug" : "Release"; - } - } - - HermesExecutor(@Nullable RuntimeConfig config, boolean enableDebugger, String debuggerName) { - super( - config == null - ? initHybridDefaultConfig(enableDebugger, debuggerName) - : initHybrid(enableDebugger, debuggerName, config.getHeapSizeMB())); - } - - @Override - public String getName() { - return "HermesExecutor" + mode_; - } - - private static native HybridData initHybridDefaultConfig( - boolean enableDebugger, String debuggerName); - - private static native HybridData initHybrid( - boolean enableDebugger, String debuggerName, long heapSizeMB); -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.kt new file mode 100644 index 00000000000000..a71d0ed9188ff6 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.kt @@ -0,0 +1,53 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.hermes.reactexecutor + +import com.facebook.jni.HybridData +import com.facebook.react.bridge.JavaScriptExecutor +import com.facebook.react.common.build.ReactBuildConfig +import com.facebook.soloader.SoLoader + +public class HermesExecutor +internal constructor(config: RuntimeConfig?, enableDebugger: Boolean, debuggerName: String) : + JavaScriptExecutor( + config?.let { initHybrid(enableDebugger, debuggerName, it.heapSizeMB) } + ?: initHybridDefaultConfig(enableDebugger, debuggerName)) { + + override fun getName(): String = "HermesExecutor$mode" + + public companion object { + private var mode: String? = null + + init { + loadLibrary() + } + + @JvmStatic + @Throws(UnsatisfiedLinkError::class) + public fun loadLibrary() { + if (mode == null) { + // libhermes must be loaded explicitly to invoke its JNI_OnLoad. + SoLoader.loadLibrary("hermes") + SoLoader.loadLibrary("hermes_executor") + // libhermes_executor is built differently for Debug & Release so we load the proper mode. + mode = if (ReactBuildConfig.DEBUG) "Debug" else "Release" + } + } + + private external fun initHybridDefaultConfig( + enableDebugger: Boolean, + debuggerName: String + ): HybridData? + + private external fun initHybrid( + enableDebugger: Boolean, + debuggerName: String, + heapSizeMB: Long + ): HybridData? + } +} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java deleted file mode 100644 index a51d5825a26880..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.hermes.reactexecutor; - -import com.facebook.hermes.instrumentation.HermesSamplingProfiler; -import com.facebook.react.bridge.JavaScriptExecutor; -import com.facebook.react.bridge.JavaScriptExecutorFactory; - -public class HermesExecutorFactory implements JavaScriptExecutorFactory { - private static final String TAG = "Hermes"; - - private final RuntimeConfig mConfig; - private boolean mEnableDebugger = true; - private String mDebuggerName = ""; - - public HermesExecutorFactory() { - this(null); - } - - public HermesExecutorFactory(RuntimeConfig config) { - mConfig = config; - } - - public void setEnableDebugger(boolean enableDebugger) { - mEnableDebugger = enableDebugger; - } - - public void setDebuggerName(String debuggerName) { - mDebuggerName = debuggerName; - } - - @Override - public JavaScriptExecutor create() { - return new HermesExecutor(mConfig, mEnableDebugger, mDebuggerName); - } - - @Override - public void startSamplingProfiler() { - HermesSamplingProfiler.enable(); - } - - @Override - public void stopSamplingProfiler(String filename) { - HermesSamplingProfiler.dumpSampledTraceToFile(filename); - HermesSamplingProfiler.disable(); - } - - @Override - public String toString() { - return "JSIExecutor+HermesRuntime"; - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.kt new file mode 100644 index 00000000000000..8faf7799981183 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.kt @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.hermes.reactexecutor + +import com.facebook.hermes.instrumentation.HermesSamplingProfiler.disable +import com.facebook.hermes.instrumentation.HermesSamplingProfiler.dumpSampledTraceToFile +import com.facebook.hermes.instrumentation.HermesSamplingProfiler.enable +import com.facebook.react.bridge.JavaScriptExecutor +import com.facebook.react.bridge.JavaScriptExecutorFactory + +public class HermesExecutorFactory +@JvmOverloads +public constructor(private val config: RuntimeConfig? = null) : JavaScriptExecutorFactory { + private var enableDebugger = true + private var debuggerName = "" + + public fun setEnableDebugger(enableDebugger: Boolean) { + this.enableDebugger = enableDebugger + } + + public fun setDebuggerName(debuggerName: String) { + this.debuggerName = debuggerName + } + + override fun create(): JavaScriptExecutor = HermesExecutor(config, enableDebugger, debuggerName) + + override fun startSamplingProfiler() { + enable() + } + + override fun stopSamplingProfiler(filename: String) { + dumpSampledTraceToFile(filename) + disable() + } + + override fun toString(): String = "JSIExecutor+HermesRuntime" +} From 1e0009407d6f96c255191b85628699f4e77a3d08 Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Mon, 13 Jan 2025 08:59:43 -0800 Subject: [PATCH 005/911] Migrate rn-tester/js/components/TextInlineView.js to function components (#48640) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48640 As per title. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D68095013 fbshipit-source-id: a593af63029352844e544245d88e7b4c9d7eb75c --- .../rn-tester/js/components/TextInlineView.js | 184 ++++++++---------- 1 file changed, 83 insertions(+), 101 deletions(-) diff --git a/packages/rn-tester/js/components/TextInlineView.js b/packages/rn-tester/js/components/TextInlineView.js index 360a15a17cb140..c7e884ae2250a4 100644 --- a/packages/rn-tester/js/components/TextInlineView.js +++ b/packages/rn-tester/js/components/TextInlineView.js @@ -12,6 +12,7 @@ import RNTesterText from '../components/RNTesterText'; import React from 'react'; +import {useState} from 'react'; import {Image, TouchableHighlight, View} from 'react-native'; function Basic(): React.Node { @@ -105,116 +106,97 @@ function ClippedByText(): React.Node { ); } -type ChangeSizeState = {| - width: number, -|}; - -class ChangeImageSize extends React.Component { - state: ChangeSizeState = { - width: 50, - }; - - render(): React.Node { - return ( - - { - this.setState({width: this.state.width === 50 ? 100 : 50}); - }}> - - Change Image Width (width={this.state.width}) - - - - This is an - - inline image +function ChangeImageSize(): React.Node { + const [width, setWidth] = useState(50); + return ( + + { + setWidth(width === 50 ? 100 : 50); + }}> + + Change Image Width (width={width}) - - ); - } + + + This is an + + inline image + + + ); } -class ChangeViewSize extends React.Component { - state: ChangeSizeState = { - width: 50, - }; +function ChangeViewSize(): React.Node { + const [width, setWidth] = useState(50); + return ( + + { + setWidth(width === 50 ? 100 : 50); + }}> + + Change View Width (width={width}) + + + + This is an + + inline view + + + ); +} - render(): React.Node { - return ( - - { - this.setState({width: this.state.width === 50 ? 100 : 50}); - }}> - - Change View Width (width={this.state.width}) - - - - This is an +function ChangeInnerViewSize(): React.Node { + const [width, setWidth] = useState(50); + return ( + + { + setWidth(width === 50 ? 100 : 50); + }}> + {/* When updating `width`, it's important that the only thing that + changes is the width of the pink inline view. When we do this, we + demonstrate a bug in RN Android where the pink view doesn't get + rerendered and remains at its old size. If other things change + (e.g. we display `width` as text somewhere) it could circumvent + the bug and cause the pink view to be rerendered at its new size. */} + + Change Pink View Width + + + + This is an + - inline view - - - ); - } -} - -class ChangeInnerViewSize extends React.Component { - state: ChangeSizeState = { - width: 50, - }; - - render(): React.Node { - return ( - - { - this.setState({width: this.state.width === 50 ? 100 : 50}); - }}> - {/* When updating `state.width`, it's important that the only thing that - changes is the width of the pink inline view. When we do this, we - demonstrate a bug in RN Android where the pink view doesn't get - rerendered and remains at its old size. If other things change - (e.g. we display `state.width` as text somewhere) it could circumvent - the bug and cause the pink view to be rerendered at its new size. */} - - Change Pink View Width - - - - This is an - - - - inline view - - - ); - } + + inline view + + + ); } module.exports = { From 05e8007e12df92814d3189e15682c98fc1e105fe Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Mon, 13 Jan 2025 10:47:13 -0800 Subject: [PATCH 006/911] Migrate rn-tester/js/examples/OrientationChange/OrientationChangeExample.js to function components (#48643) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48643 As per title. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D68095232 fbshipit-source-id: fdf45a3bb64c590ea21222a02ae94d975579db49 --- .../OrientationChangeExample.js | 64 ++++++++----------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/packages/rn-tester/js/examples/OrientationChange/OrientationChangeExample.js b/packages/rn-tester/js/examples/OrientationChange/OrientationChangeExample.js index d7903ef3351e80..a6da8817b56a86 100644 --- a/packages/rn-tester/js/examples/OrientationChange/OrientationChangeExample.js +++ b/packages/rn-tester/js/examples/OrientationChange/OrientationChangeExample.js @@ -10,51 +10,41 @@ import RNTesterText from '../../components/RNTesterText'; import React from 'react'; +import {useEffect, useState} from 'react'; import {DeviceEventEmitter, View} from 'react-native'; -import {type EventSubscription} from 'react-native/Libraries/vendor/emitter/EventEmitter'; -class OrientationChangeExample extends React.Component<{...}, $FlowFixMeState> { - _orientationSubscription: EventSubscription; - - state: - | any - | { - currentOrientation: string, - isLandscape: boolean, - orientationDegrees: number, - } = { +const OrientationChangeExample = (): React.Node => { + const [state, setState] = useState({ currentOrientation: '', orientationDegrees: 0, isLandscape: false, - }; - - componentDidMount() { - this._orientationSubscription = DeviceEventEmitter.addListener( + }); + + useEffect(() => { + const onOrientationChange = (orientation: Object) => { + setState({ + currentOrientation: orientation.name, + orientationDegrees: orientation.rotationDegrees, + isLandscape: orientation.isLandscape, + }); + }; + + const orientationSubscription = DeviceEventEmitter.addListener( 'namedOrientationDidChange', - this._onOrientationChange, + onOrientationChange, ); - } - - componentWillUnmount() { - this._orientationSubscription.remove(); - } - _onOrientationChange = (orientation: Object) => { - this.setState({ - currentOrientation: orientation.name, - orientationDegrees: orientation.rotationDegrees, - isLandscape: orientation.isLandscape, - }); - }; - - render(): React.Node { - return ( - - {JSON.stringify(this.state)} - - ); - } -} + return () => { + orientationSubscription.remove(); + }; + }, []); + + return ( + + {JSON.stringify(state)} + + ); +}; exports.title = 'OrientationChangeExample'; exports.category = 'Basic'; From 90d2f653015dd0dcdc2d9025ce9a29ab19e781fd Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Mon, 13 Jan 2025 10:47:13 -0800 Subject: [PATCH 007/911] Migrate rn-tester/js/examples/AppState/AppStateExample.js to function components (#48644) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48644 As per title. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D68095480 fbshipit-source-id: 2487fa5e66d672883cbfde0c68348a90db09d484 --- .../js/examples/AppState/AppStateExample.js | 135 ++++++++---------- 1 file changed, 58 insertions(+), 77 deletions(-) diff --git a/packages/rn-tester/js/examples/AppState/AppStateExample.js b/packages/rn-tester/js/examples/AppState/AppStateExample.js index f4e132ba2d4b84..2415cb0c418ccf 100644 --- a/packages/rn-tester/js/examples/AppState/AppStateExample.js +++ b/packages/rn-tester/js/examples/AppState/AppStateExample.js @@ -11,109 +11,90 @@ 'use strict'; import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; -import type {AppStateValues} from 'react-native/Libraries/AppState/AppState'; -import type {EventSubscription} from 'react-native/Libraries/vendor/emitter/EventEmitter'; import RNTesterText from '../../components/RNTesterText'; import React from 'react'; +import {useEffect, useState} from 'react'; import {AppState, Platform, View} from 'react-native'; -class AppStateSubscription extends React.Component< - $FlowFixMeProps, - $FlowFixMeState, -> { - state: { - appState: ?string, - eventsDetected: Array, - memoryWarnings: number, - previousAppStates: Array, - } = { - appState: AppState.currentState, - previousAppStates: [], - memoryWarnings: 0, - eventsDetected: [], - }; +type Props = { + detectEvents?: boolean, + showCurrentOnly?: boolean, + showMemoryWarnings?: boolean, +}; - _subscriptions: ?Array; +function AppStateSubscription(props: Props) { + const [currentAppState, setCurrentAppState] = useState( + AppState.currentState, + ); + const [previousAppStates, setPreviousAppStates] = useState([]); + const [memoryWarnings, setMemoryWarnings] = useState(0); + const [eventsDetected, setEventsDetected] = useState([]); - componentDidMount() { - this._subscriptions = [ - AppState.addEventListener('change', this._handleAppStateChange), - AppState.addEventListener('memoryWarning', this._handleMemoryWarning), + useEffect(() => { + const subscriptions = [ + AppState.addEventListener('change', handleAppStateChange), + AppState.addEventListener('memoryWarning', handleMemoryWarning), ]; + if (Platform.OS === 'android') { - this._subscriptions.push( - AppState.addEventListener('focus', this._handleFocus), - AppState.addEventListener('blur', this._handleBlur), + subscriptions.push( + AppState.addEventListener('focus', handleFocus), + AppState.addEventListener('blur', handleBlur), ); } - } - componentWillUnmount() { - if (this._subscriptions != null) { - for (const subscription of this._subscriptions) { - subscription.remove(); - } - } - } + return () => { + subscriptions.forEach(subscription => subscription.remove()); + }; + }, []); - _handleMemoryWarning = () => { - this.setState({memoryWarnings: this.state.memoryWarnings + 1}); + const handleMemoryWarning = () => { + setMemoryWarnings(prev => prev + 1); }; - _handleBlur = () => { - const eventsDetected = this.state.eventsDetected.slice(); - eventsDetected.push('blur'); - this.setState({eventsDetected}); + const handleBlur = () => { + setEventsDetected(prev => [...prev, 'blur']); }; - _handleFocus = () => { - const eventsDetected = this.state.eventsDetected.slice(); - eventsDetected.push('focus'); - this.setState({eventsDetected}); + const handleFocus = () => { + setEventsDetected(prev => [...prev, 'focus']); }; - _handleAppStateChange = (appState: AppStateValues) => { - const previousAppStates = this.state.previousAppStates.slice(); - previousAppStates.push(this.state.appState); - this.setState({ - appState, - previousAppStates, - }); + const handleAppStateChange = (appState: string) => { + setPreviousAppStates(prev => [...prev, appState]); + setCurrentAppState(appState); }; - render(): React.Node { - if (this.props.showMemoryWarnings) { - return ( - - {this.state.memoryWarnings} - - ); - } - if (this.props.showCurrentOnly) { - return ( - - {this.state.appState} - - ); - } - if (this.props.detectEvents) { - return ( - - - {JSON.stringify(this.state.eventsDetected)} - - - ); - } + if (props.showMemoryWarnings) { + return ( + + {memoryWarnings} + + ); + } + + if (props.showCurrentOnly) { + return ( + + {currentAppState} + + ); + } + + if (props.detectEvents) { return ( - - {JSON.stringify(this.state.previousAppStates)} - + {JSON.stringify(eventsDetected)} ); } + + return ( + + {JSON.stringify(previousAppStates)} + + ); } exports.title = 'AppState'; From 5a290c4cab6f58744a9252687feefd8b6a8d3305 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Mon, 13 Jan 2025 10:54:37 -0800 Subject: [PATCH 008/911] Fix nullability of ViewManagerDelegate method args (#48602) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48602 See context in D64532446 / https://github.com/facebook/react-native/pull/47086 These argument types were already consumed as nullable in various OSS libraries, which prevents correct Kotlin migration of this code. Changelog: [Android][Changed] Deprecated ViewManagerDelegate#setProperty and ViewManagerDelegate#receiveCommand Reviewed By: mdvacca Differential Revision: D67277871 fbshipit-source-id: a0743584891c7b2b4b50fff11de15da0078d5a1a --- .../ReactAndroid/api/ReactAndroid.api | 8 +++-- .../uimanager/BaseViewManagerDelegate.kt | 7 ++-- .../react/uimanager/ViewManagerDelegate.kt | 34 +++++++++++++++---- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 26d6ca721334b8..4c95a6e04ab8ee 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -4041,6 +4041,8 @@ public abstract class com/facebook/react/uimanager/BaseViewManager : com/faceboo public abstract class com/facebook/react/uimanager/BaseViewManagerDelegate : com/facebook/react/uimanager/ViewManagerDelegate { protected final field mViewManager Lcom/facebook/react/uimanager/BaseViewManager; public fun (Lcom/facebook/react/uimanager/BaseViewManager;)V + public synthetic fun kotlinCompat$receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V + public synthetic fun kotlinCompat$setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V public fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V } @@ -5231,8 +5233,10 @@ public abstract class com/facebook/react/uimanager/ViewManager : com/facebook/re } public abstract interface class com/facebook/react/uimanager/ViewManagerDelegate { - public abstract fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V - public abstract fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V + public abstract synthetic fun kotlinCompat$receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V + public abstract synthetic fun kotlinCompat$setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V + public fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V + public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V } public class com/facebook/react/uimanager/ViewManagerPropertyUpdater { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.kt index 8c2a95fedb66e9..6c0c24890d874c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.kt @@ -23,8 +23,8 @@ public abstract class BaseViewManagerDelegate< T : View, U : BaseViewManager>( @Suppress("NoHungarianNotation") @JvmField protected val mViewManager: U ) : ViewManagerDelegate { - @Suppress("DEPRECATION") - override public fun setProperty(view: T, propName: String?, value: Any?) { + @Suppress("ACCIDENTAL_OVERRIDE", "DEPRECATION") + override public fun setProperty(view: T, propName: String, value: Any?) { when (propName) { ViewProps.ACCESSIBILITY_ACTIONS -> mViewManager.setAccessibilityActions(view, value as ReadableArray?) @@ -146,6 +146,7 @@ public abstract class BaseViewManagerDelegate< } } - override public fun receiveCommand(view: T, commandName: String?, args: ReadableArray?): Unit = + @Suppress("ACCIDENTAL_OVERRIDE") + override public fun receiveCommand(view: T, commandName: String, args: ReadableArray?): Unit = Unit } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.kt index 534384b0ecedf9..4e453238bfdd13 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.kt @@ -22,20 +22,42 @@ public interface ViewManagerDelegate { /** * Sets a property on a view managed by this view manager. * + * We mark this method as synthetic / hide it from JVM so Java callers will call the deprecated + * version and overrides work correctly. + * * @param view the view to set the property on - * @param propName the name of the property to set (NOTE: should be `String` but is kept as - * `String?` to avoid breaking changes) + * @param propName the name of the property to set * @param value the value to set the property to */ - public fun setProperty(view: T, propName: String?, value: Any?) + @Suppress("INAPPLICABLE_JVM_NAME") + @JvmName("kotlinCompat\$setProperty") + @JvmSynthetic + public fun setProperty(view: T, propName: String, value: Any?) + + @Suppress("INAPPLICABLE_JVM_NAME") + @Deprecated(message = "propName is not nullable, please update your method signature") + @JvmName("setProperty") + public fun javaCompat_setProperty(view: T, propName: String?, value: Any?): Unit = + setProperty(view, checkNotNull(propName), value) /** * Executes a command from JS to the view * + * We mark this method as synthetic / hide it from JVM so Java callers will call the deprecated + * version and overrides work correctly. + * * @param view the view to execute the command on - * @param commandName the name of the command to execute (NOTE: should be `String` but is kept as - * `String?` to avoid breaking changes) + * @param commandName the name of the command to execute * @param args the arguments to pass to the command */ - public fun receiveCommand(view: T, commandName: String?, args: ReadableArray?) + @Suppress("INAPPLICABLE_JVM_NAME") + @JvmName("kotlinCompat\$receiveCommand") + @JvmSynthetic + public fun receiveCommand(view: T, commandName: String, args: ReadableArray?) + + @Suppress("INAPPLICABLE_JVM_NAME") + @Deprecated(message = "commandName is not nullable, please update your method signature") + @JvmName("receiveCommand") + public fun javaCompat_receiveCommand(view: T, commandName: String?, args: ReadableArray?): Unit = + receiveCommand(view, checkNotNull(commandName), args) } From 980458c061580bbc004bf1ddc17f567fc51aaab8 Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Mon, 13 Jan 2025 13:07:44 -0800 Subject: [PATCH 009/911] Migrate rn-tester/js/components/RNTesterButton.js to function components (#48645) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48645 As per title. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D68098118 fbshipit-source-id: 09f9c318afc210ca2ce6967dac7109544ef6717c --- .../rn-tester/js/components/RNTesterButton.js | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/rn-tester/js/components/RNTesterButton.js b/packages/rn-tester/js/components/RNTesterButton.js index d760b3a00ea230..686301af61567b 100644 --- a/packages/rn-tester/js/components/RNTesterButton.js +++ b/packages/rn-tester/js/components/RNTesterButton.js @@ -12,8 +12,8 @@ import type {PressEvent} from 'react-native/Libraries/Types/CoreEventTypes'; -const React = require('react'); -const {Pressable, StyleSheet, Text} = require('react-native'); +import React from 'react'; +import {Pressable, StyleSheet, Text} from 'react-native'; type Props = $ReadOnly<{| testID?: string, @@ -22,17 +22,15 @@ type Props = $ReadOnly<{| onPress?: ?(event: PressEvent) => mixed, |}>; -class RNTesterButton extends React.Component { - render(): React.Node { - return ( - [styles.button, pressed && styles.pressed]}> - {this.props.children} - - ); - } +function RNTesterButton(props: Props): React.Node { + return ( + [styles.button, pressed && styles.pressed]}> + {props.children} + + ); } const styles = StyleSheet.create({ @@ -51,4 +49,4 @@ const styles = StyleSheet.create({ }, }); -module.exports = RNTesterButton; +export default RNTesterButton; From 2d320fbd765ee13983f9ca75cd6306f3bce7c4c5 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Mon, 13 Jan 2025 23:39:45 -0800 Subject: [PATCH 010/911] Cache ViewManagerDelegate on ViewManagers (#48550) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48550 Cache ViewManagerDelegate on ViewManagers changelog: [internal] internal Reviewed By: javache Differential Revision: D67957883 fbshipit-source-id: 8ec2f34fca04833e391b0bd5b9329cdc9ee12f08 --- .../facebook/react/uimanager/ViewManager.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java index 00e5d0a6501763..d5b567aab781ae 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java @@ -41,6 +41,9 @@ public abstract class ViewManager private static final String NAME = ViewManager.class.getSimpleName(); + private boolean mIsDelegateLoaded = false; + private @Nullable ViewManagerDelegate mDelegate = null; + /** * For View recycling: we store a Stack of unused, dead Views. This is null by default, and when * null signals that View Recycling is disabled. `enableViewRecycling` must be explicitly called @@ -88,7 +91,7 @@ protected void setupViewRecycling() { * @param props {@link ReactStylesDiffMap} props to update the view with */ public void updateProperties(@NonNull T viewToUpdate, ReactStylesDiffMap props) { - final ViewManagerDelegate delegate = getDelegate(); + final ViewManagerDelegate delegate = getOrCreateViewManagerDelegate(); if (delegate != null) { ViewManagerPropertyUpdater.updateProps(delegate, viewToUpdate, props); } else { @@ -109,11 +112,18 @@ public void updateProperties(@NonNull T viewToUpdate, ReactStylesDiffMap props) * @return an instance of {@link ViewManagerDelegate} if the props of the view managed by this * view manager should be set via this delegate */ - @Nullable - protected ViewManagerDelegate getDelegate() { + protected @Nullable ViewManagerDelegate getDelegate() { return null; } + private @Nullable ViewManagerDelegate getOrCreateViewManagerDelegate() { + if (!mIsDelegateLoaded) { + mDelegate = getDelegate(); + mIsDelegateLoaded = true; + } + return mDelegate; + } + /** Creates a view with knowledge of props and state. */ public @NonNull T createView( int reactTag, @@ -306,7 +316,7 @@ public void receiveCommand(@NonNull T root, int commandId, @Nullable ReadableArr * @param args optional arguments for the command */ public void receiveCommand(@NonNull T root, String commandId, @Nullable ReadableArray args) { - final ViewManagerDelegate delegate = getDelegate(); + final ViewManagerDelegate delegate = getOrCreateViewManagerDelegate(); if (delegate != null) { delegate.receiveCommand(root, commandId, args); } From 647ca90a3007f4c8d1f93ee9c262022e04e76ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Tue, 14 Jan 2025 02:59:52 -0800 Subject: [PATCH 011/911] Replace $FlowFixMe in AnimatedWeb (#48633) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48633 Changelog: [General][Changed] - Improved types in AnimatedWeb Reviewed By: huntie Differential Revision: D68092072 fbshipit-source-id: 396efffc64030b0b2d4085f969b92c422b227c0d --- .../Libraries/Animated/AnimatedWeb.js | 36 ++++++++++++++----- .../__snapshots__/public-api-test.js.snap | 6 ++-- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/packages/react-native/Libraries/Animated/AnimatedWeb.js b/packages/react-native/Libraries/Animated/AnimatedWeb.js index e23a04587a7061..167dafa6fe933b 100644 --- a/packages/react-native/Libraries/Animated/AnimatedWeb.js +++ b/packages/react-native/Libraries/Animated/AnimatedWeb.js @@ -10,17 +10,35 @@ 'use strict'; +import type {AnimatedComponentType} from './createAnimatedComponent'; + import AnimatedImplementation from './AnimatedImplementation'; +import React from 'react'; export default { ...AnimatedImplementation, - /* $FlowFixMe[incompatible-call] createAnimatedComponent expects to receive - * types. Plain intrinsic components can't be typed like this */ - div: (AnimatedImplementation.createAnimatedComponent('div'): $FlowFixMe), - /* $FlowFixMe[incompatible-call] createAnimatedComponent expects to receive - * types. Plain intrinsic components can't be typed like this */ - span: (AnimatedImplementation.createAnimatedComponent('span'): $FlowFixMe), - /* $FlowFixMe[incompatible-call] createAnimatedComponent expects to receive - * types. Plain intrinsic components can't be typed like this */ - img: (AnimatedImplementation.createAnimatedComponent('img'): $FlowFixMe), + div: AnimatedImplementation.createAnimatedComponent< + React.PropsOf<'div'>, + mixed, + >( + /* $FlowFixMe[incompatible-call] createAnimatedComponent expects to receive + * types. Plain intrinsic components can't be typed like this */ + 'div', + ) as AnimatedComponentType>, + span: AnimatedImplementation.createAnimatedComponent< + React.PropsOf<'span'>, + mixed, + >( + /* $FlowFixMe[incompatible-call] createAnimatedComponent expects to receive + * types. Plain intrinsic components can't be typed like this */ + 'span', + ) as AnimatedComponentType>, + img: AnimatedImplementation.createAnimatedComponent< + React.PropsOf<'img'>, + mixed, + >( + /* $FlowFixMe[incompatible-call] createAnimatedComponent expects to receive + * types. Plain intrinsic components can't be typed like this */ + 'img', + ) as AnimatedComponentType>, }; diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 32b72e85d0ba5d..375fd4ebfb272e 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -342,9 +342,9 @@ exports[`public API should not change unintentionally Libraries/Animated/Animate exports[`public API should not change unintentionally Libraries/Animated/AnimatedWeb.js 1`] = ` "declare export default { ...AnimatedImplementation, - div: $FlowFixMe, - span: $FlowFixMe, - img: $FlowFixMe, + div: AnimatedComponentType>, + span: AnimatedComponentType>, + img: AnimatedComponentType>, }; " `; From 2056794d24bd7edf84b95f5d23080da81c7c89e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Tue, 14 Jan 2025 03:08:44 -0800 Subject: [PATCH 012/911] Refactor import syntax that caused $FlowFixMe generation in snap (#48639) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48639 Changelog: [Internal] - refactored import syntax in File, ElementProperties, Inspector, InspectorOverlay, InspectorPanel, PerformanceOverlay, Modal, YellowBoxDeprecated Reviewed By: andrewdacenko Differential Revision: D68099152 fbshipit-source-id: a0d840a6000fd3974a3ce4673455180a8be66288 --- packages/react-native/Libraries/Blob/File.js | 3 ++- .../Libraries/Inspector/ElementProperties.js | 3 ++- .../Libraries/Inspector/Inspector.js | 2 +- .../Libraries/Inspector/InspectorOverlay.js | 3 ++- .../Libraries/Inspector/InspectorPanel.js | 2 +- .../Libraries/Inspector/PerformanceOverlay.js | 3 ++- .../react-native/Libraries/Modal/Modal.js | 2 +- .../YellowBox/YellowBoxDeprecated.js | 3 ++- .../__snapshots__/public-api-test.js.snap | 24 +++++++------------ 9 files changed, 21 insertions(+), 24 deletions(-) diff --git a/packages/react-native/Libraries/Blob/File.js b/packages/react-native/Libraries/Blob/File.js index 6f643307c5d021..e25411268013ca 100644 --- a/packages/react-native/Libraries/Blob/File.js +++ b/packages/react-native/Libraries/Blob/File.js @@ -12,7 +12,8 @@ import type {BlobOptions} from './BlobTypes'; -const Blob = require('./Blob'); +import Blob from './Blob'; + const invariant = require('invariant'); /** diff --git a/packages/react-native/Libraries/Inspector/ElementProperties.js b/packages/react-native/Libraries/Inspector/ElementProperties.js index 750eceb4f440e7..ba01f10d9f0002 100644 --- a/packages/react-native/Libraries/Inspector/ElementProperties.js +++ b/packages/react-native/Libraries/Inspector/ElementProperties.js @@ -13,6 +13,8 @@ import type {InspectorData} from '../Renderer/shims/ReactNativeTypes'; import type {ViewStyleProp} from '../StyleSheet/StyleSheet'; +import React from 'react'; + const TouchableHighlight = require('../Components/Touchable/TouchableHighlight'); const TouchableWithoutFeedback = require('../Components/Touchable/TouchableWithoutFeedback'); const View = require('../Components/View/View'); @@ -22,7 +24,6 @@ const Text = require('../Text/Text'); const mapWithSeparator = require('../Utilities/mapWithSeparator'); const BoxInspector = require('./BoxInspector'); const StyleInspector = require('./StyleInspector'); -const React = require('react'); type Props = $ReadOnly<{| hierarchy: ?InspectorData['hierarchy'], diff --git a/packages/react-native/Libraries/Inspector/Inspector.js b/packages/react-native/Libraries/Inspector/Inspector.js index d18216df0b1fbb..85a239b01b4630 100644 --- a/packages/react-native/Libraries/Inspector/Inspector.js +++ b/packages/react-native/Libraries/Inspector/Inspector.js @@ -19,6 +19,7 @@ import type {ViewStyleProp} from '../StyleSheet/StyleSheet'; import type {ReactDevToolsAgent} from '../Types/ReactDevToolsTypes'; import SafeAreaView from '../../src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE'; +import React from 'react'; const View = require('../Components/View/View'); const PressabilityDebug = require('../Pressability/PressabilityDebug'); @@ -29,7 +30,6 @@ const Platform = require('../Utilities/Platform'); const getInspectorDataForViewAtPoint = require('./getInspectorDataForViewAtPoint'); const InspectorOverlay = require('./InspectorOverlay'); const InspectorPanel = require('./InspectorPanel'); -const React = require('react'); const {useState} = React; diff --git a/packages/react-native/Libraries/Inspector/InspectorOverlay.js b/packages/react-native/Libraries/Inspector/InspectorOverlay.js index 33b7ce67d63515..46f332d5cb2a8f 100644 --- a/packages/react-native/Libraries/Inspector/InspectorOverlay.js +++ b/packages/react-native/Libraries/Inspector/InspectorOverlay.js @@ -13,10 +13,11 @@ import type {PressEvent} from '../Types/CoreEventTypes'; import type {InspectedElement} from './Inspector'; +import React from 'react'; + const View = require('../Components/View/View'); const StyleSheet = require('../StyleSheet/StyleSheet'); const ElementBox = require('./ElementBox'); -const React = require('react'); type Props = $ReadOnly<{| inspected?: ?InspectedElement, diff --git a/packages/react-native/Libraries/Inspector/InspectorPanel.js b/packages/react-native/Libraries/Inspector/InspectorPanel.js index de33fb46882a47..06dd6d69a4ef4b 100644 --- a/packages/react-native/Libraries/Inspector/InspectorPanel.js +++ b/packages/react-native/Libraries/Inspector/InspectorPanel.js @@ -13,6 +13,7 @@ import type {ElementsHierarchy, InspectedElement} from './Inspector'; import SafeAreaView from '../Components/SafeAreaView/SafeAreaView'; +import React from 'react'; const ScrollView = require('../Components/ScrollView/ScrollView'); const TouchableHighlight = require('../Components/Touchable/TouchableHighlight'); @@ -22,7 +23,6 @@ const Text = require('../Text/Text'); const ElementProperties = require('./ElementProperties'); const NetworkOverlay = require('./NetworkOverlay'); const PerformanceOverlay = require('./PerformanceOverlay'); -const React = require('react'); type Props = $ReadOnly<{| devtoolsIsOpen: boolean, diff --git a/packages/react-native/Libraries/Inspector/PerformanceOverlay.js b/packages/react-native/Libraries/Inspector/PerformanceOverlay.js index d1e8bbca30a429..ec30fbbb8bdbf6 100644 --- a/packages/react-native/Libraries/Inspector/PerformanceOverlay.js +++ b/packages/react-native/Libraries/Inspector/PerformanceOverlay.js @@ -10,11 +10,12 @@ 'use strict'; +import React from 'react'; + const View = require('../Components/View/View'); const StyleSheet = require('../StyleSheet/StyleSheet'); const Text = require('../Text/Text'); const PerformanceLogger = require('../Utilities/GlobalPerformanceLogger'); -const React = require('react'); class PerformanceOverlay extends React.Component<{...}> { render(): React.Node { diff --git a/packages/react-native/Libraries/Modal/Modal.js b/packages/react-native/Libraries/Modal/Modal.js index 3133a75c26f47e..8d0a85b15fb9ac 100644 --- a/packages/react-native/Libraries/Modal/Modal.js +++ b/packages/react-native/Libraries/Modal/Modal.js @@ -18,6 +18,7 @@ import ModalInjection from './ModalInjection'; import NativeModalManager from './NativeModalManager'; import RCTModalHostView from './RCTModalHostViewNativeComponent'; import {VirtualizedListContextResetter} from '@react-native/virtualized-lists'; +import React from 'react'; const ScrollView = require('../Components/ScrollView/ScrollView'); const View = require('../Components/View/View'); @@ -26,7 +27,6 @@ const I18nManager = require('../ReactNative/I18nManager'); const {RootTagContext} = require('../ReactNative/RootTag'); const StyleSheet = require('../StyleSheet/StyleSheet'); const Platform = require('../Utilities/Platform'); -const React = require('react'); type ModalEventDefinitions = { modalDismissed: [{modalID: number}], diff --git a/packages/react-native/Libraries/YellowBox/YellowBoxDeprecated.js b/packages/react-native/Libraries/YellowBox/YellowBoxDeprecated.js index 4a1a78dd4174f3..93c3926b0c7308 100644 --- a/packages/react-native/Libraries/YellowBox/YellowBoxDeprecated.js +++ b/packages/react-native/Libraries/YellowBox/YellowBoxDeprecated.js @@ -12,8 +12,9 @@ import type {IgnorePattern} from '../LogBox/Data/LogBoxData'; +import React from 'react'; + const LogBox = require('../LogBox/LogBox').default; -const React = require('react'); type Props = $ReadOnly<{||}>; diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 375fd4ebfb272e..c2bd3c12ebbb3b 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -1476,8 +1476,7 @@ export type BlobOptions = { `; exports[`public API should not change unintentionally Libraries/Blob/File.js 1`] = ` -"declare const Blob: $FlowFixMe; -declare class File extends Blob { +"declare class File extends Blob { constructor( parts: Array, name: string, @@ -5187,8 +5186,7 @@ declare module.exports: ElementBox; `; exports[`public API should not change unintentionally Libraries/Inspector/ElementProperties.js 1`] = ` -"declare const React: $FlowFixMe; -type Props = $ReadOnly<{| +"type Props = $ReadOnly<{| hierarchy: ?InspectorData[\\"hierarchy\\"], style?: ?ViewStyleProp, frame?: ?Object, @@ -5203,8 +5201,7 @@ declare module.exports: ElementProperties; `; exports[`public API should not change unintentionally Libraries/Inspector/Inspector.js 1`] = ` -"declare const React: $FlowFixMe; -export type InspectedElementFrame = TouchedViewDataAtPoint[\\"frame\\"]; +"export type InspectedElementFrame = TouchedViewDataAtPoint[\\"frame\\"]; export type InspectedElement = $ReadOnly<{ frame: InspectedElementFrame, style?: ViewStyleProp, @@ -5221,8 +5218,7 @@ declare module.exports: Inspector; `; exports[`public API should not change unintentionally Libraries/Inspector/InspectorOverlay.js 1`] = ` -"declare const React: $FlowFixMe; -type Props = $ReadOnly<{| +"type Props = $ReadOnly<{| inspected?: ?InspectedElement, onTouchPoint: (locationX: number, locationY: number) => void, |}>; @@ -5232,8 +5228,7 @@ declare module.exports: InspectorOverlay; `; exports[`public API should not change unintentionally Libraries/Inspector/InspectorPanel.js 1`] = ` -"declare const React: $FlowFixMe; -type Props = $ReadOnly<{| +"type Props = $ReadOnly<{| devtoolsIsOpen: boolean, inspecting: boolean, setInspecting: (val: boolean) => void, @@ -5316,8 +5311,7 @@ declare module.exports: NetworkOverlay; `; exports[`public API should not change unintentionally Libraries/Inspector/PerformanceOverlay.js 1`] = ` -"declare const React: $FlowFixMe; -declare class PerformanceOverlay extends React.Component<{ ... }> { +"declare class PerformanceOverlay extends React.Component<{ ... }> { render(): React.Node; } declare module.exports: PerformanceOverlay; @@ -6492,8 +6486,7 @@ declare export function getTextColor(opacity?: number): string; `; exports[`public API should not change unintentionally Libraries/Modal/Modal.js 1`] = ` -"declare const React: $FlowFixMe; -type OrientationChangeEvent = $ReadOnly<{| +"type OrientationChangeEvent = $ReadOnly<{| orientation: \\"portrait\\" | \\"landscape\\", |}>; export type Props = $ReadOnly<{| @@ -9566,8 +9559,7 @@ declare module.exports: WebSocketInterceptor; `; exports[`public API should not change unintentionally Libraries/YellowBox/YellowBoxDeprecated.js 1`] = ` -"declare const React: $FlowFixMe; -type Props = $ReadOnly<{||}>; +"type Props = $ReadOnly<{||}>; declare module.exports: Class> & { ignoreWarnings($ReadOnlyArray): void, install(): void, From 817cb17f7873ed45498b4c24c6d9315f1976c402 Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Tue, 14 Jan 2025 03:20:05 -0800 Subject: [PATCH 013/911] Migrate rn-tester/js/examples/Layout/LayoutExample.js to function components (#48646) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48646 As per title. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D68098856 fbshipit-source-id: ad878569f5b88afa57895b4b08de32c880ee8242 --- .../js/examples/Layout/LayoutExample.js | 324 +++++++++--------- 1 file changed, 163 insertions(+), 161 deletions(-) diff --git a/packages/rn-tester/js/examples/Layout/LayoutExample.js b/packages/rn-tester/js/examples/Layout/LayoutExample.js index 67ae250b9a8d0d..039d62cd3ef874 100644 --- a/packages/rn-tester/js/examples/Layout/LayoutExample.js +++ b/packages/rn-tester/js/examples/Layout/LayoutExample.js @@ -10,179 +10,181 @@ 'use strict'; +import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet'; + import RNTesterBlock from '../../components/RNTesterBlock'; import RNTesterPage from '../../components/RNTesterPage'; import RNTesterText from '../../components/RNTesterText'; import React from 'react'; import {StyleSheet, View} from 'react-native'; -class Circle extends React.Component<$FlowFixMeProps> { - render(): React.Node { - const size = this.props.size || 20; - const backgroundColor = this.props.bgColor || '#527fe4'; - return ( - - ); - } +type CicleProps = $ReadOnly<{ + backgroundColor?: string, + size?: number, +}>; + +function Circle({ + backgroundColor = '#527fe4', + size = 20, +}: CicleProps): React.Node { + return ( + + ); } -class CircleBlock extends React.Component<$FlowFixMeProps> { - render(): React.Node { - const circleStyle = { - flexDirection: 'row', - backgroundColor: '#f6f7f8', - borderWidth: 0.5, - borderColor: '#d6d7da', - marginBottom: 2, - }; - return ( - {this.props.children} - ); - } +type CircleBlockProps = $ReadOnly<{ + children: React.Node, + style: ViewStyleProp, +}>; + +function CircleBlock({children, style}: CircleBlockProps): React.Node { + const circleStyle = { + flexDirection: 'row', + backgroundColor: '#f6f7f8', + borderWidth: 0.5, + borderColor: '#d6d7da', + marginBottom: 2, + }; + return {children}; } -class LayoutExample extends React.Component<$FlowFixMeProps> { - render(): React.Node { - const fiveColoredCircles = [ - , - , - , - , - , - ]; +function LayoutExample(): React.Node { + const fiveColoredCircles = [ + , + , + , + , + , + ]; - return ( - - - row - - {fiveColoredCircles} - - row-reverse - - {fiveColoredCircles} - - column - - {fiveColoredCircles} - - column-reverse - - {fiveColoredCircles} - - - - {'top: 15, left: 160'} - - - + return ( + + + row + + {fiveColoredCircles} + + row-reverse + + {fiveColoredCircles} + + column + + {fiveColoredCircles} + + column-reverse + + {fiveColoredCircles} + + + + {'top: 15, left: 160'} + + + - - flex-start - - {fiveColoredCircles} - - center - - {fiveColoredCircles} - - flex-end - - {fiveColoredCircles} - - space-between - - {fiveColoredCircles} - - space-around - - {fiveColoredCircles} - - - - flex-start - - - - - - - - - - - - - - - - - - - - center - - - - - - - - - - - - - - - - - - - - flex-end - - - - - - - - - - - - - - - - - - - - - - - {'oooooooooooooooo'.split('').map((char, i) => ( - - ))} - - - - ); - } + + flex-start + + {fiveColoredCircles} + + center + + {fiveColoredCircles} + + flex-end + + {fiveColoredCircles} + + space-between + + {fiveColoredCircles} + + space-around + + {fiveColoredCircles} + + + + flex-start + + + + + + + + + + + + + + + + + + + + center + + + + + + + + + + + + + + + + + + + + flex-end + + + + + + + + + + + + + + + + + + + + + + + {'oooooooooooooooo'.split('').map((char, i) => ( + + ))} + + + + ); } const styles = StyleSheet.create({ From d95909ea1507f390ae200ad582ad80ef2ed384fa Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Tue, 14 Jan 2025 03:20:05 -0800 Subject: [PATCH 014/911] Migrate rn-tester/js/components/RNTesterTitle.js to function components (#48649) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48649 As per title. Changelog: [Internal] Reviewed By: rshest Differential Revision: D68099051 fbshipit-source-id: 867010b692e6d71e4683cc12b4455be730413268 --- .../rn-tester/js/components/RNTesterPage.js | 2 +- .../rn-tester/js/components/RNTesterTitle.js | 53 ++++++++++--------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/packages/rn-tester/js/components/RNTesterPage.js b/packages/rn-tester/js/components/RNTesterPage.js index c3bcd4ba633633..71342f255ba630 100644 --- a/packages/rn-tester/js/components/RNTesterPage.js +++ b/packages/rn-tester/js/components/RNTesterPage.js @@ -9,9 +9,9 @@ */ import {RNTesterThemeContext} from './RNTesterTheme'; +import RNTesterTitle from './RNTesterTitle'; import {useContext} from 'react'; -const RNTesterTitle = require('./RNTesterTitle'); const React = require('react'); const {SafeAreaView, ScrollView, StyleSheet, View} = require('react-native'); diff --git a/packages/rn-tester/js/components/RNTesterTitle.js b/packages/rn-tester/js/components/RNTesterTitle.js index 948a0e89ca6188..d5955fd2b21039 100644 --- a/packages/rn-tester/js/components/RNTesterTitle.js +++ b/packages/rn-tester/js/components/RNTesterTitle.js @@ -9,33 +9,34 @@ */ import {RNTesterThemeContext} from './RNTesterTheme'; +import React from 'react'; +import {StyleSheet, Text, View} from 'react-native'; -const React = require('react'); -const {StyleSheet, Text, View} = require('react-native'); +type Props = $ReadOnly<{ + title: string, +}>; -class RNTesterTitle extends React.Component<$FlowFixMeProps> { - render(): React.Node { - return ( - - {theme => { - return ( - - - {this.props.title} - - - ); - }} - - ); - } +function RNTesterTitle({title}: Props): React.Node { + return ( + + {theme => { + return ( + + + {title} + + + ); + }} + + ); } const styles = StyleSheet.create({ @@ -53,4 +54,4 @@ const styles = StyleSheet.create({ }, }); -module.exports = RNTesterTitle; +export default RNTesterTitle; From e4d969a4ab71693f38837271356361a3d9df8c5d Mon Sep 17 00:00:00 2001 From: Iwo Plaza Date: Tue, 14 Jan 2025 05:34:18 -0800 Subject: [PATCH 015/911] Migrate StyleSheet/*.js to use export statements (#48609) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48609 # Motivation This is an attempt at modernizing the export syntax in some of the files in `Libraries/StyleSheet/`. It will allow these files to get properly ingested by modern Flow tooling. # This diff - Migrates the use of `module.exports` into `export default` for files located in `Libraries/StyleSheet/*.js`. Some files were omitted due to ballooning complexity, but will be addressed in other Diffs. - Updating internal *require*s to use ".default", no product code seems to be affected. - Migrating `require`s into `import`s where applicable, taking into account the performance implications (context: https://fb.workplace.com/groups/react.technologies.discussions/permalink/3638114866420225/) - Updates the current iteration of API snapshots (intended). - Updates `react-native-codegen`'s require of processColorArray, analogous to D42346452. Changelog: [General][Breaking] - Deep imports from some files in `StyleSheet/` can break when using the `require()` syntax, but can be easily fixed by appending `.default` Reviewed By: javache Differential Revision: D68017325 fbshipit-source-id: 3c5b94742f101db0b2914c91efab6003dba2b61a --- .../__snapshots__/GenerateViewConfigJs-test.js.snap | 2 +- .../generators/components/GenerateViewConfigJs.js | 2 +- .../__snapshots__/GenerateViewConfigJs-test.js.snap | 2 +- .../ReactNative/getNativeComponentAttributes.js | 2 +- .../StyleSheet/PlatformColorValueTypes.ios.js | 2 +- .../StyleSheet/__flowtests__/StyleSheet-flowtest.js | 3 ++- .../StyleSheet/__tests__/normalizeColor-test.js | 4 ++-- .../StyleSheet/__tests__/processAspectRatio-test.js | 2 +- .../StyleSheet/__tests__/processColorArray-test.js | 2 +- .../StyleSheet/__tests__/processFontVariant-test.js | 2 +- .../StyleSheet/__tests__/processTransform-test.js | 2 +- .../__tests__/setNormalizedColorAlpha-test.js | 4 ++-- .../Libraries/StyleSheet/normalizeColor.js | 2 +- .../Libraries/StyleSheet/processAspectRatio.js | 2 +- .../Libraries/StyleSheet/processColor.js | 2 +- .../Libraries/StyleSheet/processColorArray.js | 2 +- .../Libraries/StyleSheet/processFontVariant.js | 2 +- .../Libraries/StyleSheet/processTransform.js | 2 +- .../Libraries/StyleSheet/setNormalizedColorAlpha.js | 2 +- .../__tests__/__snapshots__/public-api-test.js.snap | 12 ++++++------ 20 files changed, 28 insertions(+), 27 deletions(-) diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap index d74bb73cc85ea4..aa5b60893842a9 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateViewConfigJs-test.js.snap @@ -31,7 +31,7 @@ export const __INTERNAL_VIEW_CONFIG = { radii: true, colors: { - process: require('react-native/Libraries/StyleSheet/processColorArray'), + process: require('react-native/Libraries/StyleSheet/processColorArray').default, }, srcs: true, diff --git a/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js b/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js index f09b38c7885f52..c7e0227428c4bc 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js +++ b/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js @@ -91,7 +91,7 @@ function getReactDiffProcessValue(typeAnnotation: PropTypeAnnotation) { switch (typeAnnotation.elementType.name) { case 'ColorPrimitive': return j.template - .expression`{ process: require('react-native/Libraries/StyleSheet/processColorArray') }`; + .expression`{ process: require('react-native/Libraries/StyleSheet/processColorArray').default }`; case 'ImageSourcePrimitive': case 'PointPrimitive': case 'EdgeInsetsPrimitive': diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap index 0bb1612992fe9d..eecbbe3eb73044 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap @@ -31,7 +31,7 @@ export const __INTERNAL_VIEW_CONFIG = { radii: true, colors: { - process: require('react-native/Libraries/StyleSheet/processColorArray'), + process: require('react-native/Libraries/StyleSheet/processColorArray').default, }, srcs: true, diff --git a/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js b/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js index 2af83f4c4e5298..aae2d4d6796700 100644 --- a/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js +++ b/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js @@ -17,7 +17,7 @@ const resolveAssetSource = require('../Image/resolveAssetSource'); const processBackgroundImage = require('../StyleSheet/processBackgroundImage').default; const processColor = require('../StyleSheet/processColor').default; -const processColorArray = require('../StyleSheet/processColorArray'); +const processColorArray = require('../StyleSheet/processColorArray').default; const processFilter = require('../StyleSheet/processFilter').default; const insetsDiffer = require('../Utilities/differ/insetsDiffer'); const matricesDiffer = require('../Utilities/differ/matricesDiffer'); diff --git a/packages/react-native/Libraries/StyleSheet/PlatformColorValueTypes.ios.js b/packages/react-native/Libraries/StyleSheet/PlatformColorValueTypes.ios.js index 418df65ac95837..ba38455fd96471 100644 --- a/packages/react-native/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +++ b/packages/react-native/Libraries/StyleSheet/PlatformColorValueTypes.ios.js @@ -56,7 +56,7 @@ const _normalizeColorObject = ( // an ios semantic color return color; } else if ('dynamic' in color && color.dynamic !== undefined) { - const normalizeColor = require('./normalizeColor'); + const normalizeColor = require('./normalizeColor').default; // a dynamic, appearance aware color const dynamic = color.dynamic; diff --git a/packages/react-native/Libraries/StyleSheet/__flowtests__/StyleSheet-flowtest.js b/packages/react-native/Libraries/StyleSheet/__flowtests__/StyleSheet-flowtest.js index c8d564ac1c5f56..037eb5803d4010 100644 --- a/packages/react-native/Libraries/StyleSheet/__flowtests__/StyleSheet-flowtest.js +++ b/packages/react-native/Libraries/StyleSheet/__flowtests__/StyleSheet-flowtest.js @@ -12,7 +12,8 @@ import type {ImageStyleProp, TextStyleProp} from '../StyleSheet'; -const StyleSheet = require('../StyleSheet'); +import * as StyleSheet from '../StyleSheet'; + const imageStyle = {tintColor: 'rgb(0, 0, 0)'}; const textStyle = {color: 'rgb(0, 0, 0)'}; diff --git a/packages/react-native/Libraries/StyleSheet/__tests__/normalizeColor-test.js b/packages/react-native/Libraries/StyleSheet/__tests__/normalizeColor-test.js index a8c7e586224ea0..81cd20ad12d13f 100644 --- a/packages/react-native/Libraries/StyleSheet/__tests__/normalizeColor-test.js +++ b/packages/react-native/Libraries/StyleSheet/__tests__/normalizeColor-test.js @@ -11,12 +11,12 @@ 'use strict'; const {OS} = require('../../Utilities/Platform'); -const normalizeColor = require('../normalizeColor'); +const normalizeColor = require('../normalizeColor').default; it('forwards calls to @react-native/normalize-colors', () => { jest.resetModules().mock('@react-native/normalize-colors', () => jest.fn()); - expect(require('../normalizeColor')('#abc')).not.toBe(null); + expect(require('../normalizeColor').default('#abc')).not.toBe(null); expect(require('@react-native/normalize-colors')).toBeCalled(); }); diff --git a/packages/react-native/Libraries/StyleSheet/__tests__/processAspectRatio-test.js b/packages/react-native/Libraries/StyleSheet/__tests__/processAspectRatio-test.js index 1097d956203e12..95a089e8e370a6 100644 --- a/packages/react-native/Libraries/StyleSheet/__tests__/processAspectRatio-test.js +++ b/packages/react-native/Libraries/StyleSheet/__tests__/processAspectRatio-test.js @@ -10,7 +10,7 @@ 'use strict'; -const processAspectRatio = require('../processAspectRatio'); +import processAspectRatio from '../processAspectRatio'; describe('processAspectRatio', () => { it('should accept numbers', () => { diff --git a/packages/react-native/Libraries/StyleSheet/__tests__/processColorArray-test.js b/packages/react-native/Libraries/StyleSheet/__tests__/processColorArray-test.js index 0385dd7db757da..4f4b5685119d2b 100644 --- a/packages/react-native/Libraries/StyleSheet/__tests__/processColorArray-test.js +++ b/packages/react-native/Libraries/StyleSheet/__tests__/processColorArray-test.js @@ -17,7 +17,7 @@ const PlatformColorIOS = require('../PlatformColorValueTypes.ios').PlatformColor; const DynamicColorIOS = require('../PlatformColorValueTypesIOS.ios').DynamicColorIOS; -const processColorArray = require('../processColorArray'); +const processColorArray = require('../processColorArray').default; const platformSpecific = OS === 'android' diff --git a/packages/react-native/Libraries/StyleSheet/__tests__/processFontVariant-test.js b/packages/react-native/Libraries/StyleSheet/__tests__/processFontVariant-test.js index 1d9185178be52b..33b71522e54d59 100644 --- a/packages/react-native/Libraries/StyleSheet/__tests__/processFontVariant-test.js +++ b/packages/react-native/Libraries/StyleSheet/__tests__/processFontVariant-test.js @@ -10,7 +10,7 @@ 'use strict'; -const processFontVariant = require('../processFontVariant'); +const processFontVariant = require('../processFontVariant').default; describe('processFontVariant', () => { it('should accept arrays', () => { diff --git a/packages/react-native/Libraries/StyleSheet/__tests__/processTransform-test.js b/packages/react-native/Libraries/StyleSheet/__tests__/processTransform-test.js index fe7c5d2851505f..a794c9a978ad29 100644 --- a/packages/react-native/Libraries/StyleSheet/__tests__/processTransform-test.js +++ b/packages/react-native/Libraries/StyleSheet/__tests__/processTransform-test.js @@ -10,7 +10,7 @@ 'use strict'; -const processTransform = require('../processTransform'); +import processTransform from '../processTransform'; describe('processTransform', () => { describe('validation', () => { diff --git a/packages/react-native/Libraries/StyleSheet/__tests__/setNormalizedColorAlpha-test.js b/packages/react-native/Libraries/StyleSheet/__tests__/setNormalizedColorAlpha-test.js index 1f257514acfb3b..456b5cb3996c5d 100644 --- a/packages/react-native/Libraries/StyleSheet/__tests__/setNormalizedColorAlpha-test.js +++ b/packages/react-native/Libraries/StyleSheet/__tests__/setNormalizedColorAlpha-test.js @@ -10,8 +10,8 @@ 'use strict'; -const normalizeColor = require('../normalizeColor'); -const setNormalizedColorAlpha = require('../setNormalizedColorAlpha'); +const normalizeColor = require('../normalizeColor').default; +const setNormalizedColorAlpha = require('../setNormalizedColorAlpha').default; describe('setNormalizedColorAlpha', function () { it('should adjust the alpha of the color passed in', function () { diff --git a/packages/react-native/Libraries/StyleSheet/normalizeColor.js b/packages/react-native/Libraries/StyleSheet/normalizeColor.js index e181ec2892848e..0a565e83e01039 100755 --- a/packages/react-native/Libraries/StyleSheet/normalizeColor.js +++ b/packages/react-native/Libraries/StyleSheet/normalizeColor.js @@ -31,4 +31,4 @@ function normalizeColor( } } -module.exports = normalizeColor; +export default normalizeColor; diff --git a/packages/react-native/Libraries/StyleSheet/processAspectRatio.js b/packages/react-native/Libraries/StyleSheet/processAspectRatio.js index a47ee101bb50a2..6f5dce47bf1a9c 100644 --- a/packages/react-native/Libraries/StyleSheet/processAspectRatio.js +++ b/packages/react-native/Libraries/StyleSheet/processAspectRatio.js @@ -60,4 +60,4 @@ function processAspectRatio(aspectRatio?: number | string): ?number { return Number(matches[0]); } -module.exports = processAspectRatio; +export default processAspectRatio; diff --git a/packages/react-native/Libraries/StyleSheet/processColor.js b/packages/react-native/Libraries/StyleSheet/processColor.js index 2bac21b59bfbc5..d8d0e996d287da 100644 --- a/packages/react-native/Libraries/StyleSheet/processColor.js +++ b/packages/react-native/Libraries/StyleSheet/processColor.js @@ -13,7 +13,7 @@ import type {ColorValue, NativeColorValue} from './StyleSheet'; const Platform = require('../Utilities/Platform'); -const normalizeColor = require('./normalizeColor'); +const normalizeColor = require('./normalizeColor').default; export type ProcessedColorValue = number | NativeColorValue; diff --git a/packages/react-native/Libraries/StyleSheet/processColorArray.js b/packages/react-native/Libraries/StyleSheet/processColorArray.js index 7b3d53517ef157..7a0aade44b1d9e 100644 --- a/packages/react-native/Libraries/StyleSheet/processColorArray.js +++ b/packages/react-native/Libraries/StyleSheet/processColorArray.js @@ -32,4 +32,4 @@ function processColorElement(color: ColorValue): ProcessedColorValue { return value; } -module.exports = processColorArray; +export default processColorArray; diff --git a/packages/react-native/Libraries/StyleSheet/processFontVariant.js b/packages/react-native/Libraries/StyleSheet/processFontVariant.js index 32a72f879e6f9b..3019af2be5adb6 100644 --- a/packages/react-native/Libraries/StyleSheet/processFontVariant.js +++ b/packages/react-native/Libraries/StyleSheet/processFontVariant.js @@ -27,4 +27,4 @@ function processFontVariant( return match; } -module.exports = processFontVariant; +export default processFontVariant; diff --git a/packages/react-native/Libraries/StyleSheet/processTransform.js b/packages/react-native/Libraries/StyleSheet/processTransform.js index 8338e4f06d2b77..79cfdaeb33f2a0 100644 --- a/packages/react-native/Libraries/StyleSheet/processTransform.js +++ b/packages/react-native/Libraries/StyleSheet/processTransform.js @@ -266,4 +266,4 @@ function _validateTransform( } } -module.exports = processTransform; +export default processTransform; diff --git a/packages/react-native/Libraries/StyleSheet/setNormalizedColorAlpha.js b/packages/react-native/Libraries/StyleSheet/setNormalizedColorAlpha.js index 7cfce2dc9fb80a..581cc33d7482ec 100644 --- a/packages/react-native/Libraries/StyleSheet/setNormalizedColorAlpha.js +++ b/packages/react-native/Libraries/StyleSheet/setNormalizedColorAlpha.js @@ -28,4 +28,4 @@ function setNormalizedColorAlpha(input: number, alpha: number): number { return ((input & 0xffffff00) | alpha) >>> 0; } -module.exports = setNormalizedColorAlpha; +export default setNormalizedColorAlpha; diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index c2bd3c12ebbb3b..18454723d2ed80 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -8326,7 +8326,7 @@ exports[`public API should not change unintentionally Libraries/StyleSheet/norma "declare function normalizeColor( color: ?(ColorValue | ProcessedColorValue) ): ?ProcessedColorValue; -declare module.exports: normalizeColor; +declare export default typeof normalizeColor; " `; @@ -8374,7 +8374,7 @@ exports[`public API should not change unintentionally Libraries/StyleSheet/priva exports[`public API should not change unintentionally Libraries/StyleSheet/processAspectRatio.js 1`] = ` "declare function processAspectRatio(aspectRatio?: number | string): ?number; -declare module.exports: processAspectRatio; +declare export default typeof processAspectRatio; " `; @@ -8424,7 +8424,7 @@ exports[`public API should not change unintentionally Libraries/StyleSheet/proce "declare function processColorArray( colors: ?$ReadOnlyArray ): ?$ReadOnlyArray; -declare module.exports: processColorArray; +declare export default typeof processColorArray; " `; @@ -8456,7 +8456,7 @@ exports[`public API should not change unintentionally Libraries/StyleSheet/proce "declare function processFontVariant( fontVariant: ____FontVariantArray_Internal | string ): ?____FontVariantArray_Internal; -declare module.exports: processFontVariant; +declare export default typeof processFontVariant; " `; @@ -8464,7 +8464,7 @@ exports[`public API should not change unintentionally Libraries/StyleSheet/proce "declare function processTransform( transform: Array | string ): Array | Array; -declare module.exports: processTransform; +declare export default typeof processTransform; " `; @@ -8477,7 +8477,7 @@ exports[`public API should not change unintentionally Libraries/StyleSheet/proce exports[`public API should not change unintentionally Libraries/StyleSheet/setNormalizedColorAlpha.js 1`] = ` "declare function setNormalizedColorAlpha(input: number, alpha: number): number; -declare module.exports: setNormalizedColorAlpha; +declare export default typeof setNormalizedColorAlpha; " `; From 85f993903158164f42c0fa6eae78895fe6c07ebc Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 14 Jan 2025 06:12:00 -0800 Subject: [PATCH 016/911] Fix crash for Hermes Release due to HermesExecutor migration (#48660) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48660 RN-Tester is currently instacrashing on release due to a migration to Kotlin for HermesExecutor This fixes it. Changelog: [Internal] [Changed] - Fix crash for Hermes Release due to HermesExecutor migration Reviewed By: javache Differential Revision: D68151666 fbshipit-source-id: 31f404ec518831cf2151dc670cdf8553427ae8ab --- .../java/com/facebook/hermes/reactexecutor/HermesExecutor.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.kt index a71d0ed9188ff6..4fff48f23a2879 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.kt @@ -8,6 +8,7 @@ package com.facebook.hermes.reactexecutor import com.facebook.jni.HybridData +import com.facebook.jni.annotations.DoNotStrip import com.facebook.react.bridge.JavaScriptExecutor import com.facebook.react.common.build.ReactBuildConfig import com.facebook.soloader.SoLoader @@ -39,11 +40,15 @@ internal constructor(config: RuntimeConfig?, enableDebugger: Boolean, debuggerNa } } + @DoNotStrip + @JvmStatic private external fun initHybridDefaultConfig( enableDebugger: Boolean, debuggerName: String ): HybridData? + @DoNotStrip + @JvmStatic private external fun initHybrid( enableDebugger: Boolean, debuggerName: String, From b7eccf23de9b3816aa0f32176a1f77bf46d80842 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 14 Jan 2025 07:09:27 -0800 Subject: [PATCH 017/911] Back out "Do not reset rn-artifacts-version on release branch" (#48651) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48651 Original commit changeset: dace7c931ec3 Original Phabricator Diff: D67975049 Reviewed By: cipolleschi Differential Revision: D68114130 fbshipit-source-id: 9fb1707191037127b9ae985d2e3298a64e911590 --- .github/actions/build-android/action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/actions/build-android/action.yml b/.github/actions/build-android/action.yml index 4f32483d975a65..b18e605c8eb90d 100644 --- a/.github/actions/build-android/action.yml +++ b/.github/actions/build-android/action.yml @@ -20,8 +20,6 @@ runs: - name: Set React Native Version shell: bash run: node ./scripts/releases/set-rn-artifacts-version.js --build-type ${{ inputs.release-type }} - # We don't want to re-set the artifacts version if we're on the release branch. - if: ${{ !contains(github.ref, '-stable') }} - name: Setup gradle uses: ./.github/actions/setup-gradle with: From 8b5e2ea68387288c76e556428465d1965f0fcc05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Tue, 14 Jan 2025 07:16:41 -0800 Subject: [PATCH 018/911] Replace ExactReactElement_DEPRECATED in ScrollViewStickyHeader (#48659) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48659 Changelog: [Internal] - Replaced ExactReactElement_DEPRECATED with React.Node as a children type in ScrollViewStickyHeader Reviewed By: fabriziocucci Differential Revision: D68151420 fbshipit-source-id: d4406de67176ae1fea95b8b2ea85f41dc7f5045e --- .../Libraries/Components/ScrollView/ScrollViewStickyHeader.js | 2 +- .../Libraries/__tests__/__snapshots__/public-api-test.js.snap | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/packages/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js index 1615f3fe0b9671..2c11d50c849d31 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js @@ -19,7 +19,7 @@ import * as React from 'react'; import {useCallback, useEffect, useMemo, useRef, useState} from 'react'; export type Props = $ReadOnly<{ - children?: ExactReactElement_DEPRECATED<$FlowFixMe>, + children?: React.Node, nextHeaderLayoutY: ?number, onLayout: (event: LayoutEvent) => void, scrollAnimatedValue: Animated.Value, diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 18454723d2ed80..1123b59a8bef1f 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -2449,7 +2449,7 @@ exports[`public API should not change unintentionally Libraries/Components/Scrol exports[`public API should not change unintentionally Libraries/Components/ScrollView/ScrollViewStickyHeader.js 1`] = ` "export type Props = $ReadOnly<{ - children?: ExactReactElement_DEPRECATED<$FlowFixMe>, + children?: React.Node, nextHeaderLayoutY: ?number, onLayout: (event: LayoutEvent) => void, scrollAnimatedValue: Animated.Value, From 07769d4d7eb1d3000210c7a8dafd9a5411694444 Mon Sep 17 00:00:00 2001 From: Wojciech Lewicki Date: Tue, 14 Jan 2025 07:31:35 -0800 Subject: [PATCH 019/911] feat: Make DefaultReactNativeHost.clear() also invalidate DefaultReactHost (#48338) Summary: On bridgeless mode, `reactHost` is kept in memory even after destroying the `DefaultReactNativeHost` in brownfield scenario. Since it keeps references to the modules, they are not deallocated, and their `initialize` methods are not fired again when creating new instance of `react-native` later. It breaks the behavior of e.g. `react-native-screens`, which wants to listen for mutations and should get new `FabricUIManager`: https://github.com/software-mansion/react-native-screens/blob/20b7e83782cd5f79ddd0d61dadc13eeb4db4b258/android/src/main/java/com/swmansion/rnscreens/ScreensModule.kt#L45. In this commit we change the `DefaultReactNativeHost.clear()` method to also invalidate the instance retained inside `DefaultReactHost` ## Changelog: [ANDROID] [FIXED] - Make DefaultReactNativeHost.clear() also invalidate DefaultReactHost Pull Request resolved: https://github.com/facebook/react-native/pull/48338 Test Plan: In brownfield scenario, destroy the instance of RN and see that modules are also destroyed. Reviewed By: cipolleschi Differential Revision: D67977140 Pulled By: cortinico fbshipit-source-id: 1804f093ab1a905bef499078ddec32a13c50cc85 --- packages/react-native/ReactAndroid/api/ReactAndroid.api | 1 + .../java/com/facebook/react/defaults/DefaultReactHost.kt | 8 ++++++++ .../com/facebook/react/defaults/DefaultReactNativeHost.kt | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 4c95a6e04ab8ee..0e7b6d3363c112 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -2045,6 +2045,7 @@ public final class com/facebook/react/defaults/DefaultReactHost { public abstract class com/facebook/react/defaults/DefaultReactNativeHost : com/facebook/react/ReactNativeHost { protected fun (Landroid/app/Application;)V + public fun clear ()V protected fun getJSEngineResolutionAlgorithm ()Lcom/facebook/react/JSEngineResolutionAlgorithm; protected fun getReactPackageTurboModuleManagerDelegateBuilder ()Lcom/facebook/react/ReactPackageTurboModuleManagerDelegate$Builder; protected fun getUIManagerProvider ()Lcom/facebook/react/bridge/UIManagerProvider; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt index 9dab78f83a4fc0..f13228de45bee1 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt @@ -175,4 +175,12 @@ public object DefaultReactHost { } return reactNativeHost.toReactHost(context) } + + /** + * Cleanup function for brownfield scenarios where you want to remove the references kept by + * reactHost after destroying the RN instance. + */ + internal fun invalidate() { + reactHost = null + } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactNativeHost.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactNativeHost.kt index b816bad9ae6b27..2a278d10212c9a 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactNativeHost.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactNativeHost.kt @@ -76,6 +76,11 @@ protected constructor( null -> null } + override fun clear() { + super.clear() + DefaultReactHost.invalidate() + } + /** * Returns whether the user wants to use the New Architecture or not. * From 9f7bacaa6bfe2722552abe913e48b69e47c96cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Tue, 14 Jan 2025 07:31:54 -0800 Subject: [PATCH 020/911] Add explicit types for methods from AnimatedImplementation in AnimatedMock (#48610) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48610 Changelog: [Internal] - Improved typings for AnimatedImplementation methods exported from AnimatedMock Reviewed By: huntie Differential Revision: D68019816 fbshipit-source-id: ee73213c0b519be9b72b8dfb2e91a125021de63e --- .../Libraries/Animated/AnimatedMock.js | 2 +- .../__snapshots__/public-api-test.js.snap | 62 +------------------ 2 files changed, 2 insertions(+), 62 deletions(-) diff --git a/packages/react-native/Libraries/Animated/AnimatedMock.js b/packages/react-native/Libraries/Animated/AnimatedMock.js index c509c830f7d075..5613f27358a99e 100644 --- a/packages/react-native/Libraries/Animated/AnimatedMock.js +++ b/packages/react-native/Libraries/Animated/AnimatedMock.js @@ -192,4 +192,4 @@ export default { forkEvent: AnimatedImplementation.forkEvent, unforkEvent: AnimatedImplementation.unforkEvent, Event: AnimatedEvent, -}; +} as typeof AnimatedImplementation; diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 1123b59a8bef1f..e9573da33c79b1 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -269,68 +269,8 @@ exports[`public API should not change unintentionally Libraries/Animated/Animate _isUsingNativeDriver: () => boolean, ... }; -declare const spring: ( - value: AnimatedValue | AnimatedValueXY | AnimatedColor, - config: SpringAnimationConfig -) => CompositeAnimation; -declare const timing: ( - value: AnimatedValue | AnimatedValueXY | AnimatedColor, - config: TimingAnimationConfig -) => CompositeAnimation; -declare const decay: ( - value: AnimatedValue | AnimatedValueXY | AnimatedColor, - config: DecayAnimationConfig -) => CompositeAnimation; -declare const sequence: ( - animations: Array -) => CompositeAnimation; -type ParallelConfig = { stopTogether?: boolean, ... }; -declare const parallel: ( - animations: Array, - config?: ?ParallelConfig -) => CompositeAnimation; -declare const delay: (time: number) => CompositeAnimation; -declare const stagger: ( - time: number, - animations: Array -) => CompositeAnimation; -type LoopAnimationConfig = { - iterations: number, - resetBeforeIteration?: boolean, - ... -}; -declare const loop: ( - animation: CompositeAnimation, - LoopAnimationConfig -) => CompositeAnimation; export type { AnimatedNumeric as Numeric }; -declare export default { - Value: AnimatedValue, - ValueXY: AnimatedValueXY, - Color: AnimatedColor, - Interpolation: AnimatedInterpolation, - Node: AnimatedNode, - decay: decay, - timing: timing, - spring: spring, - add: $FlowFixMe, - subtract: $FlowFixMe, - divide: $FlowFixMe, - multiply: $FlowFixMe, - modulo: $FlowFixMe, - diffClamp: $FlowFixMe, - delay: delay, - sequence: sequence, - parallel: parallel, - stagger: stagger, - loop: loop, - event: $FlowFixMe, - createAnimatedComponent: createAnimatedComponent, - attachNativeEvent: attachNativeEvent, - forkEvent: $FlowFixMe, - unforkEvent: $FlowFixMe, - Event: AnimatedEvent, -}; +declare export default typeof AnimatedImplementation; " `; From f44ff97c474d72808fb644048d39cc2cef5440bc Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Tue, 14 Jan 2025 08:11:25 -0800 Subject: [PATCH 021/911] Properly test JSC for template_app e2e tests (#48656) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48656 While working on 0.78, I realize we were not testing the template app with JSC. This change should fix this. ## Changelog: [Internal] - Disable Hermes for the JSC E2E tests with Maestro Reviewed By: cortinico, fabriziocucci Differential Revision: D68147849 fbshipit-source-id: 4fbe005b5d04d6163a37041d1bd57fd48a9dfda8 --- .github/workflows/test-all.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml index fe6de2c89c6400..cbe2a66e6ed0c1 100644 --- a/.github/workflows/test-all.yml +++ b/.github/workflows/test-all.yml @@ -369,6 +369,11 @@ jobs: sed -i 's/newArchEnabled=true/newArchEnabled=false/' android/gradle.properties fi + if [[ ${{matrix.jsengine}} == "JSC" ]]; then + echo "Using JSC instead of Hermes" + sed -i 's/hermesEnabled=true/hermesEnabled=false/' android/gradle.properties + fi + # Build cd android CAPITALIZED_FLAVOR=$(echo "${{ matrix.flavor }}" | awk '{print toupper(substr($0, 1, 1)) substr($0, 2)}') From c799aa07e2148a2ca38939cb72468c949ed0c95f Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 14 Jan 2025 08:20:05 -0800 Subject: [PATCH 022/911] Back out "RN: Enable `useInsertionEffectsForAnimations`" (#48669) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48669 Original commit changeset: d09b2f1b7607 Original Phabricator Diff: D65906157 ## Changelog: [General] [Fixed] - Buttons becoming unresponsive when transform is animated Reviewed By: yungsters Differential Revision: D68152746 fbshipit-source-id: aa0c0aa3243c67c95128a75b40dd6aa1251abbca --- .../scripts/featureflags/ReactNativeFeatureFlags.config.js | 5 +++-- .../src/private/featureflags/ReactNativeFeatureFlags.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index 744e112311a77e..9be0b03e20a2ab 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -618,12 +618,13 @@ const definitions: FeatureFlagDefinitions = { }, }, useInsertionEffectsForAnimations: { - defaultValue: true, + defaultValue: false, metadata: { + dateAdded: '2024-09-12', description: 'Changes construction of the animation graph to `useInsertionEffect` instead of `useLayoutEffect`.', expectedReleaseValue: true, - purpose: 'release', + purpose: 'experimentation', }, }, useRefsForTextInputState: { diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index cebed3c31eafc8..9e3e918b870ee3 100644 --- a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js +++ b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<3037cf1c938dae492b656333cec9633c>> + * @generated SignedSource<<3bdec862f75745ce81e9cf23fef82468>> * @flow strict */ @@ -176,7 +176,7 @@ export const shouldUseSetNativePropsInFabric: Getter = createJavaScript /** * Changes construction of the animation graph to `useInsertionEffect` instead of `useLayoutEffect`. */ -export const useInsertionEffectsForAnimations: Getter = createJavaScriptFlagGetter('useInsertionEffectsForAnimations', true); +export const useInsertionEffectsForAnimations: Getter = createJavaScriptFlagGetter('useInsertionEffectsForAnimations', false); /** * Enable a variant of TextInput that moves some state to refs to avoid unnecessary re-renders From 8b8b0ba5dc23b24fd04171244fe2ded7d9e031f5 Mon Sep 17 00:00:00 2001 From: Thomas Nardone Date: Tue, 14 Jan 2025 08:28:03 -0800 Subject: [PATCH 023/911] Mark nullsafe fixmes in views/text/frescosupport (#48613) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48613 First step for nullsafe - annotate and mark fixmes Changelog: [Internal] Reviewed By: rshest Differential Revision: D67992721 fbshipit-source-id: 0c0a3ac7d4442d35bba1f48d6aabf13a3a1d47c2 --- .../FrescoBasedReactTextInlineImageShadowNode.java | 5 +++++ .../FrescoBasedReactTextInlineImageSpan.java | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageShadowNode.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageShadowNode.java index a512b20833caca..0c87fa495e05e7 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageShadowNode.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageShadowNode.java @@ -14,6 +14,7 @@ import com.facebook.common.logging.FLog; import com.facebook.common.util.UriUtil; import com.facebook.drawee.controller.AbstractDraweeControllerBuilder; +import com.facebook.infer.annotation.Nullsafe; import com.facebook.react.bridge.Dynamic; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; @@ -27,9 +28,11 @@ import java.util.Locale; /** Shadow node that represents an inline image. Loading is done using Fresco. */ +@Nullsafe(Nullsafe.Mode.LOCAL) class FrescoBasedReactTextInlineImageShadowNode extends ReactTextInlineImageShadowNode { private @Nullable Uri mUri; + // NULLSAFE_FIXME[Field Not Initialized] private ReadableMap mHeaders; private final AbstractDraweeControllerBuilder mDraweeControllerBuilder; private final @Nullable Object mCallerContext; @@ -47,6 +50,7 @@ public FrescoBasedReactTextInlineImageShadowNode( @ReactProp(name = "src") public void setSource(@Nullable ReadableArray sources) { final String source = + // NULLSAFE_FIXME[Nullable Dereference] (sources == null || sources.size() == 0) ? null : sources.getMap(0).getString("uri"); Uri uri = null; if (source != null) { @@ -145,6 +149,7 @@ public TextInlineImageSpan buildInlineImageSpan() { getHeaders(), getDraweeControllerBuilder(), getCallerContext(), + // NULLSAFE_FIXME[Parameter Not Nullable] mResizeMode); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageSpan.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageSpan.java index 2f3cf1cc3daa82..2bc55a1a0daf67 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageSpan.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageSpan.java @@ -23,6 +23,7 @@ import com.facebook.drawee.view.DraweeHolder; import com.facebook.imagepipeline.request.ImageRequest; import com.facebook.imagepipeline.request.ImageRequestBuilder; +import com.facebook.infer.annotation.Nullsafe; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.modules.fresco.ReactNetworkImageRequest; import com.facebook.react.uimanager.PixelUtil; @@ -40,6 +41,7 @@ *

Note: It borrows code from DynamicDrawableSpan and if that code updates how it computes size * or draws, we need to update this as well. */ +@Nullsafe(Nullsafe.Mode.LOCAL) class FrescoBasedReactTextInlineImageSpan extends TextInlineImageSpan { private @Nullable Drawable mDrawable; @@ -116,6 +118,7 @@ public int getSize(Paint paint, CharSequence text, int start, int end, Paint.Fon return mWidth; } + // NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation] public void setTextView(TextView textView) { mTextView = textView; } @@ -140,6 +143,7 @@ public void draw( mDraweeControllerBuilder .reset() .setOldController(mDraweeHolder.getController()) + // NULLSAFE_FIXME[Parameter Not Nullable] .setCallerContext(mCallerContext) .setImageRequest(imageRequest) .build(); @@ -147,10 +151,13 @@ public void draw( mDraweeControllerBuilder.reset(); mDrawable = mDraweeHolder.getTopLevelDrawable(); + // NULLSAFE_FIXME[Nullable Dereference] mDrawable.setBounds(0, 0, mWidth, mHeight); if (mTintColor != 0) { + // NULLSAFE_FIXME[Nullable Dereference] mDrawable.setColorFilter(mTintColor, PorterDuff.Mode.SRC_IN); } + // NULLSAFE_FIXME[Nullable Dereference] mDrawable.setCallback(mTextView); } @@ -161,9 +168,11 @@ public void draw( // Align to center int fontHeight = (int) (paint.descent() - paint.ascent()); int centerY = y + (int) paint.descent() - fontHeight / 2; + // NULLSAFE_FIXME[Nullable Dereference] int transY = centerY - (mDrawable.getBounds().bottom - mDrawable.getBounds().top) / 2; canvas.translate(x, transY); + // NULLSAFE_FIXME[Nullable Dereference] mDrawable.draw(canvas); canvas.restore(); } From a511c1bdeefb0b8a89ee804cb55bed793d761404 Mon Sep 17 00:00:00 2001 From: Thomas Nardone Date: Tue, 14 Jan 2025 08:28:03 -0800 Subject: [PATCH 024/911] Fix null safety in views/text/frescosupport (#48612) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48612 Manual fixes to resolve nullsafe issues. Changelog: [Internal] Reviewed By: rshest Differential Revision: D67992722 fbshipit-source-id: a26cde9788bc3456ec756326208b4907ad989d4e --- ...coBasedReactTextInlineImageShadowNode.java | 16 +++---- .../FrescoBasedReactTextInlineImageSpan.java | 44 ++++++++----------- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageShadowNode.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageShadowNode.java index 0c87fa495e05e7..aea8f6067dd162 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageShadowNode.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageShadowNode.java @@ -11,6 +11,7 @@ import android.content.res.Resources; import android.net.Uri; import androidx.annotation.Nullable; +import androidx.core.util.Preconditions; import com.facebook.common.logging.FLog; import com.facebook.common.util.UriUtil; import com.facebook.drawee.controller.AbstractDraweeControllerBuilder; @@ -32,8 +33,7 @@ class FrescoBasedReactTextInlineImageShadowNode extends ReactTextInlineImageShadowNode { private @Nullable Uri mUri; - // NULLSAFE_FIXME[Field Not Initialized] - private ReadableMap mHeaders; + private @Nullable ReadableMap mHeaders; private final AbstractDraweeControllerBuilder mDraweeControllerBuilder; private final @Nullable Object mCallerContext; private float mWidth = YogaConstants.UNDEFINED; @@ -49,9 +49,10 @@ public FrescoBasedReactTextInlineImageShadowNode( @ReactProp(name = "src") public void setSource(@Nullable ReadableArray sources) { - final String source = - // NULLSAFE_FIXME[Nullable Dereference] - (sources == null || sources.size() == 0) ? null : sources.getMap(0).getString("uri"); + final @Nullable String source = + (sources == null || sources.size() == 0 || sources.getType(0) != ReadableType.Map) + ? null + : Preconditions.checkNotNull(sources.getMap(0)).getString("uri"); Uri uri = null; if (source != null) { try { @@ -74,7 +75,7 @@ public void setSource(@Nullable ReadableArray sources) { } @ReactProp(name = "headers") - public void setHeaders(ReadableMap headers) { + public void setHeaders(@Nullable ReadableMap headers) { mHeaders = headers; } @@ -113,7 +114,7 @@ public void setResizeMode(@Nullable String resizeMode) { return mUri; } - public ReadableMap getHeaders() { + public @Nullable ReadableMap getHeaders() { return mHeaders; } @@ -149,7 +150,6 @@ public TextInlineImageSpan buildInlineImageSpan() { getHeaders(), getDraweeControllerBuilder(), getCallerContext(), - // NULLSAFE_FIXME[Parameter Not Nullable] mResizeMode); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageSpan.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageSpan.java index 2bc55a1a0daf67..4b44ddc717e8f6 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageSpan.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageSpan.java @@ -15,8 +15,8 @@ import android.net.Uri; import android.widget.TextView; import androidx.annotation.Nullable; +import androidx.core.util.Preconditions; import com.facebook.drawee.controller.AbstractDraweeControllerBuilder; -import com.facebook.drawee.drawable.ScalingUtils; import com.facebook.drawee.generic.GenericDraweeHierarchy; import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder; import com.facebook.drawee.interfaces.DraweeController; @@ -53,8 +53,8 @@ class FrescoBasedReactTextInlineImageSpan extends TextInlineImageSpan { private int mTintColor; private Uri mUri; private int mWidth; - private ReadableMap mHeaders; - private String mResizeMode; + private @Nullable ReadableMap mHeaders; + private @Nullable String mResizeMode; private @Nullable TextView mTextView; @@ -64,10 +64,10 @@ public FrescoBasedReactTextInlineImageSpan( int width, int tintColor, @Nullable Uri uri, - ReadableMap headers, + @Nullable ReadableMap headers, AbstractDraweeControllerBuilder draweeControllerBuilder, @Nullable Object callerContext, - String resizeMode) { + @Nullable String resizeMode) { mDraweeHolder = new DraweeHolder(GenericDraweeHierarchyBuilder.newInstance(resources).build()); mDraweeControllerBuilder = draweeControllerBuilder; mCallerContext = callerContext; @@ -118,8 +118,8 @@ public int getSize(Paint paint, CharSequence text, int start, int end, Paint.Fon return mWidth; } - // NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation] - public void setTextView(TextView textView) { + @Override + public void setTextView(@Nullable TextView textView) { mTextView = textView; } @@ -138,26 +138,24 @@ public void draw( ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(mUri); ImageRequest imageRequest = ReactNetworkImageRequest.fromBuilderWithHeaders(imageRequestBuilder, mHeaders); - mDraweeHolder.getHierarchy().setActualImageScaleType(getResizeMode(mResizeMode)); - DraweeController draweeController = - mDraweeControllerBuilder - .reset() - .setOldController(mDraweeHolder.getController()) - // NULLSAFE_FIXME[Parameter Not Nullable] - .setCallerContext(mCallerContext) - .setImageRequest(imageRequest) - .build(); + mDraweeHolder + .getHierarchy() + .setActualImageScaleType(ImageResizeMode.toScaleType(mResizeMode)); + mDraweeControllerBuilder.reset(); + mDraweeControllerBuilder.setOldController(mDraweeHolder.getController()); + if (mCallerContext != null) { + mDraweeControllerBuilder.setCallerContext(mCallerContext); + } + mDraweeControllerBuilder.setImageRequest(imageRequest); + DraweeController draweeController = mDraweeControllerBuilder.build(); mDraweeHolder.setController(draweeController); mDraweeControllerBuilder.reset(); - mDrawable = mDraweeHolder.getTopLevelDrawable(); - // NULLSAFE_FIXME[Nullable Dereference] + mDrawable = Preconditions.checkNotNull(mDraweeHolder.getTopLevelDrawable()); mDrawable.setBounds(0, 0, mWidth, mHeight); if (mTintColor != 0) { - // NULLSAFE_FIXME[Nullable Dereference] mDrawable.setColorFilter(mTintColor, PorterDuff.Mode.SRC_IN); } - // NULLSAFE_FIXME[Nullable Dereference] mDrawable.setCallback(mTextView); } @@ -168,19 +166,13 @@ public void draw( // Align to center int fontHeight = (int) (paint.descent() - paint.ascent()); int centerY = y + (int) paint.descent() - fontHeight / 2; - // NULLSAFE_FIXME[Nullable Dereference] int transY = centerY - (mDrawable.getBounds().bottom - mDrawable.getBounds().top) / 2; canvas.translate(x, transY); - // NULLSAFE_FIXME[Nullable Dereference] mDrawable.draw(canvas); canvas.restore(); } - private ScalingUtils.ScaleType getResizeMode(String resizeMode) { - return ImageResizeMode.toScaleType(resizeMode); - } - @Override public int getWidth() { return mWidth; From 51fb5ab87a31517b46cf3fe6857af0930271da0f Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Tue, 14 Jan 2025 08:45:21 -0800 Subject: [PATCH 025/911] Migrate rn-tester/IntegrationTests/AccessibilityManagerTest.js to function components (#48663) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48663 As per title. Changelog: [Internal] Reviewed By: javache Differential Revision: D68151132 fbshipit-source-id: 6fd9c4999a95a6888795c5200aafb15ff623479f --- .../AccessibilityManagerTest.js | 29 +++++++++++-------- .../IntegrationTests/IntegrationTestsApp.js | 17 +++++++---- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/packages/rn-tester/IntegrationTests/AccessibilityManagerTest.js b/packages/rn-tester/IntegrationTests/AccessibilityManagerTest.js index 45e1fab43cfc6e..ee14843aa96729 100644 --- a/packages/rn-tester/IntegrationTests/AccessibilityManagerTest.js +++ b/packages/rn-tester/IntegrationTests/AccessibilityManagerTest.js @@ -10,13 +10,14 @@ import invariant from 'invariant'; import * as React from 'react'; +import {useEffect} from 'react'; import {DeviceEventEmitter, NativeModules, View} from 'react-native'; import NativeAccessibilityManager from 'react-native/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager'; const {TestModule} = NativeModules; -class AccessibilityManagerTest extends React.Component<{...}> { - componentDidMount(): void { +function AccessibilityManagerTest(): React.Node { + useEffect(() => { invariant( NativeAccessibilityManager, "NativeAccessibilityManager doesn't exist", @@ -36,16 +37,20 @@ class AccessibilityManagerTest extends React.Component<{...}> { accessibilityExtraExtraLarge: 11.0, accessibilityExtraExtraExtraLarge: 12.0, }); - DeviceEventEmitter.addListener('didUpdateDimensions', update => { - TestModule.markTestPassed(update.window.fontScale === 4.0); - }); - } - render(): React.Node { - return ; - } -} + const subscription = DeviceEventEmitter.addListener( + 'didUpdateDimensions', + update => { + TestModule.markTestPassed(update.window.fontScale === 4.0); + }, + ); -AccessibilityManagerTest.displayName = 'AccessibilityManagerTest'; + return () => { + subscription.remove(); + }; + }, []); + + return ; +} -module.exports = AccessibilityManagerTest; +export default AccessibilityManagerTest; diff --git a/packages/rn-tester/IntegrationTests/IntegrationTestsApp.js b/packages/rn-tester/IntegrationTests/IntegrationTestsApp.js index 442e70327482e5..4da2f6a35da3a7 100644 --- a/packages/rn-tester/IntegrationTests/IntegrationTestsApp.js +++ b/packages/rn-tester/IntegrationTests/IntegrationTestsApp.js @@ -32,11 +32,14 @@ const TESTS = [ require('./GlobalEvalWithSourceUrlTest'), ]; -TESTS.forEach( - /* $FlowFixMe[incompatible-call] (>=0.54.0 site=react_native_fb,react_native_ - * oss) This comment suppresses an error found when Flow v0.54 was deployed. - * To see the error delete this comment and run Flow. */ - test => AppRegistry.registerComponent(test.displayName, () => test), +TESTS.forEach(test => + AppRegistry.registerComponent( + test.displayName || test.name || '', + /* $FlowFixMe[incompatible-call] (>=0.54.0 site=react_native_fb,react_native_ + * oss) This comment suppresses an error found when Flow v0.54 was deployed. + * To see the error delete this comment and run Flow. */ + () => test, + ), ); // Modules required for integration tests @@ -78,7 +81,9 @@ class IntegrationTestsApp extends React.Component<{...}, $FlowFixMeState> { * deployed. To see the error, delete this comment and run Flow. */ style={styles.row}> - {test.displayName} + + {test.displayName || test.name} + , , ])} From ef7f714f57b0d06d225adaef9ecf66688df2e1b6 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 14 Jan 2025 08:53:58 -0800 Subject: [PATCH 026/911] Remove unnecessary LICENSE-docs (#48670) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48670 The `LICENSE-docs` was needed when this repo was also containing the reactnative.dev docs. As this is not the case anymore, this file is unncessary. Changelog: [Internal] [Changed] - Remove unnecessary LICENSE-docs Reviewed By: cipolleschi Differential Revision: D68156336 fbshipit-source-id: 489bf2cb95916c20eb61bfb00e34b8e271bc08e3 --- LICENSE-docs | 393 --------------------------------------------------- 1 file changed, 393 deletions(-) delete mode 100644 LICENSE-docs diff --git a/LICENSE-docs b/LICENSE-docs deleted file mode 100644 index d21a91a914af92..00000000000000 --- a/LICENSE-docs +++ /dev/null @@ -1,393 +0,0 @@ -Attribution 4.0 International - -======================================================================= - -Creative Commons Corporation ("Creative Commons") is not a law firm and -does not provide legal services or legal advice. Distribution of -Creative Commons public licenses does not create a lawyer-client or -other relationship. Creative Commons makes its licenses and related -information available on an "as-is" basis. Creative Commons gives no -warranties regarding its licenses, any material licensed under their -terms and conditions, or any related information. Creative Commons -disclaims all liability for damages resulting from their use to the -fullest extent possible. - -Using Creative Commons Public Licenses - -Creative Commons public licenses provide a standard set of terms and -conditions that creators and other rights holders may use to share -original works of authorship and other material subject to copyright -and certain other rights specified in the public license below. The -following considerations are for informational purposes only, are not -exhaustive, and do not form part of our licenses. - - Considerations for licensors: Our public licenses are - intended for use by those authorized to give the public - permission to use material in ways otherwise restricted by - copyright and certain other rights. Our licenses are - irrevocable. Licensors should read and understand the terms - and conditions of the license they choose before applying it. - Licensors should also secure all rights necessary before - applying our licenses so that the public can reuse the - material as expected. Licensors should clearly mark any - material not subject to the license. This includes other CC- - licensed material, or material used under an exception or - limitation to copyright. More considerations for licensors: - wiki.creativecommons.org/Considerations_for_licensors - - Considerations for the public: By using one of our public - licenses, a licensor grants the public permission to use the - licensed material under specified terms and conditions. If - the licensor's permission is not necessary for any reason--for - example, because of any applicable exception or limitation to - copyright--then that use is not regulated by the license. Our - licenses grant only permissions under copyright and certain - other rights that a licensor has authority to grant. Use of - the licensed material may still be restricted for other - reasons, including because others have copyright or other - rights in the material. A licensor may make special requests, - such as asking that all changes be marked or described. - Although not required by our licenses, you are encouraged to - respect those requests where reasonable. More_considerations - for the public: - wiki.creativecommons.org/Considerations_for_licensees - -======================================================================= - -Creative Commons Attribution 4.0 International Public License - -By exercising the Licensed Rights (defined below), You accept and agree -to be bound by the terms and conditions of this Creative Commons -Attribution 4.0 International Public License ("Public License"). To the -extent this Public License may be interpreted as a contract, You are -granted the Licensed Rights in consideration of Your acceptance of -these terms and conditions, and the Licensor grants You such rights in -consideration of benefits the Licensor receives from making the -Licensed Material available under these terms and conditions. - - -Section 1 -- Definitions. - - a. Adapted Material means material subject to Copyright and Similar - Rights that is derived from or based upon the Licensed Material - and in which the Licensed Material is translated, altered, - arranged, transformed, or otherwise modified in a manner requiring - permission under the Copyright and Similar Rights held by the - Licensor. For purposes of this Public License, where the Licensed - Material is a musical work, performance, or sound recording, - Adapted Material is always produced where the Licensed Material is - synched in timed relation with a moving image. - - b. Adapter's License means the license You apply to Your Copyright - and Similar Rights in Your contributions to Adapted Material in - accordance with the terms and conditions of this Public License. - - c. Copyright and Similar Rights means copyright and/or similar rights - closely related to copyright including, without limitation, - performance, broadcast, sound recording, and Sui Generis Database - Rights, without regard to how the rights are labeled or - categorized. For purposes of this Public License, the rights - specified in Section 2(b)(1)-(2) are not Copyright and Similar - Rights. - - d. Effective Technological Measures means those measures that, in the - absence of proper authority, may not be circumvented under laws - fulfilling obligations under Article 11 of the WIPO Copyright - Treaty adopted on December 20, 1996, and/or similar international - agreements. - - e. Exceptions and Limitations means fair use, fair dealing, and/or - any other exception or limitation to Copyright and Similar Rights - that applies to Your use of the Licensed Material. - - f. Licensed Material means the artistic or literary work, database, - or other material to which the Licensor applied this Public - License. - - g. Licensed Rights means the rights granted to You subject to the - terms and conditions of this Public License, which are limited to - all Copyright and Similar Rights that apply to Your use of the - Licensed Material and that the Licensor has authority to license. - - h. Licensor means the individual(s) or entity(ies) granting rights - under this Public License. - - i. Share means to provide material to the public by any means or - process that requires permission under the Licensed Rights, such - as reproduction, public display, public performance, distribution, - dissemination, communication, or importation, and to make material - available to the public including in ways that members of the - public may access the material from a place and at a time - individually chosen by them. - - j. Sui Generis Database Rights means rights other than copyright - resulting from Directive 96/9/EC of the European Parliament and of - the Council of 11 March 1996 on the legal protection of databases, - as amended and/or succeeded, as well as other essentially - equivalent rights anywhere in the world. - - k. You means the individual or entity exercising the Licensed Rights - under this Public License. Your has a corresponding meaning. - - -Section 2 -- Scope. - - a. License grant. - - 1. Subject to the terms and conditions of this Public License, - the Licensor hereby grants You a worldwide, royalty-free, - non-sublicensable, non-exclusive, irrevocable license to - exercise the Licensed Rights in the Licensed Material to: - - a. reproduce and Share the Licensed Material, in whole or - in part; and - - b. produce, reproduce, and Share Adapted Material. - - 2. Exceptions and Limitations. For the avoidance of doubt, where - Exceptions and Limitations apply to Your use, this Public - License does not apply, and You do not need to comply with - its terms and conditions. - - 3. Term. The term of this Public License is specified in Section - 6(a). - - 4. Media and formats; technical modifications allowed. The - Licensor authorizes You to exercise the Licensed Rights in - all media and formats whether now known or hereafter created, - and to make technical modifications necessary to do so. The - Licensor waives and/or agrees not to assert any right or - authority to forbid You from making technical modifications - necessary to exercise the Licensed Rights, including - technical modifications necessary to circumvent Effective - Technological Measures. For purposes of this Public License, - simply making modifications authorized by this Section 2(a) - (4) never produces Adapted Material. - - 5. Downstream recipients. - - a. Offer from the Licensor -- Licensed Material. Every - recipient of the Licensed Material automatically - receives an offer from the Licensor to exercise the - Licensed Rights under the terms and conditions of this - Public License. - - b. No downstream restrictions. You may not offer or impose - any additional or different terms or conditions on, or - apply any Effective Technological Measures to, the - Licensed Material if doing so restricts exercise of the - Licensed Rights by any recipient of the Licensed - Material. - - 6. No endorsement. Nothing in this Public License constitutes or - may be construed as permission to assert or imply that You - are, or that Your use of the Licensed Material is, connected - with, or sponsored, endorsed, or granted official status by, - the Licensor or others designated to receive attribution as - provided in Section 3(a)(1)(A)(i). - - b. Other rights. - - 1. Moral rights, such as the right of integrity, are not - licensed under this Public License, nor are publicity, - privacy, and/or other similar personality rights; however, to - the extent possible, the Licensor waives and/or agrees not to - assert any such rights held by the Licensor to the limited - extent necessary to allow You to exercise the Licensed - Rights, but not otherwise. - - 2. Patent and trademark rights are not licensed under this - Public License. - - 3. To the extent possible, the Licensor waives any right to - collect royalties from You for the exercise of the Licensed - Rights, whether directly or through a collecting society - under any voluntary or waivable statutory or compulsory - licensing scheme. In all other cases the Licensor expressly - reserves any right to collect such royalties. - - -Section 3 -- License Conditions. - -Your exercise of the Licensed Rights is expressly made subject to the -following conditions. - - a. Attribution. - - 1. If You Share the Licensed Material (including in modified - form), You must: - - a. retain the following if it is supplied by the Licensor - with the Licensed Material: - - i. identification of the creator(s) of the Licensed - Material and any others designated to receive - attribution, in any reasonable manner requested by - the Licensor (including by pseudonym if - designated); - - ii. a copyright notice; - - iii. a notice that refers to this Public License; - - iv. a notice that refers to the disclaimer of - warranties; - - v. a URI or hyperlink to the Licensed Material to the - extent reasonably practicable; - - b. indicate if You modified the Licensed Material and - retain an indication of any previous modifications; and - - c. indicate the Licensed Material is licensed under this - Public License, and include the text of, or the URI or - hyperlink to, this Public License. - - 2. You may satisfy the conditions in Section 3(a)(1) in any - reasonable manner based on the medium, means, and context in - which You Share the Licensed Material. For example, it may be - reasonable to satisfy the conditions by providing a URI or - hyperlink to a resource that includes the required - information. - - 3. If requested by the Licensor, You must remove any of the - information required by Section 3(a)(1)(A) to the extent - reasonably practicable. - - 4. If You Share Adapted Material You produce, the Adapter's - License You apply must not prevent recipients of the Adapted - Material from complying with this Public License. - - -Section 4 -- Sui Generis Database Rights. - -Where the Licensed Rights include Sui Generis Database Rights that -apply to Your use of the Licensed Material: - - a. for the avoidance of doubt, Section 2(a)(1) grants You the right - to extract, reuse, reproduce, and Share all or a substantial - portion of the contents of the database; - - b. if You include all or a substantial portion of the database - contents in a database in which You have Sui Generis Database - Rights, then the database in which You have Sui Generis Database - Rights (but not its individual contents) is Adapted Material; and - - c. You must comply with the conditions in Section 3(a) if You Share - all or a substantial portion of the contents of the database. - -For the avoidance of doubt, this Section 4 supplements and does not -replace Your obligations under this Public License where the Licensed -Rights include other Copyright and Similar Rights. - - -Section 5 -- Disclaimer of Warranties and Limitation of Liability. - - a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE - EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS - AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF - ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, - IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, - WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR - PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, - ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT - KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT - ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. - - b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE - TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, - NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, - INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, - COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR - USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN - ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR - DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR - IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. - - c. The disclaimer of warranties and limitation of liability provided - above shall be interpreted in a manner that, to the extent - possible, most closely approximates an absolute disclaimer and - waiver of all liability. - - -Section 6 -- Term and Termination. - - a. This Public License applies for the term of the Copyright and - Similar Rights licensed here. However, if You fail to comply with - this Public License, then Your rights under this Public License - terminate automatically. - - b. Where Your right to use the Licensed Material has terminated under - Section 6(a), it reinstates: - - 1. automatically as of the date the violation is cured, provided - it is cured within 30 days of Your discovery of the - violation; or - - 2. upon express reinstatement by the Licensor. - - For the avoidance of doubt, this Section 6(b) does not affect any - right the Licensor may have to seek remedies for Your violations - of this Public License. - - c. For the avoidance of doubt, the Licensor may also offer the - Licensed Material under separate terms or conditions or stop - distributing the Licensed Material at any time; however, doing so - will not terminate this Public License. - - d. Sections 1, 5, 6, 7, and 8 survive termination of this Public - License. - - -Section 7 -- Other Terms and Conditions. - - a. The Licensor shall not be bound by any additional or different - terms or conditions communicated by You unless expressly agreed. - - b. Any arrangements, understandings, or agreements regarding the - Licensed Material not stated herein are separate from and - independent of the terms and conditions of this Public License. - - -Section 8 -- Interpretation. - - a. For the avoidance of doubt, this Public License does not, and - shall not be interpreted to, reduce, limit, restrict, or impose - conditions on any use of the Licensed Material that could lawfully - be made without permission under this Public License. - - b. To the extent possible, if any provision of this Public License is - deemed unenforceable, it shall be automatically reformed to the - minimum extent necessary to make it enforceable. If the provision - cannot be reformed, it shall be severed from this Public License - without affecting the enforceability of the remaining terms and - conditions. - - c. No term or condition of this Public License will be waived and no - failure to comply consented to unless expressly agreed to by the - Licensor. - - d. Nothing in this Public License constitutes or may be interpreted - as a limitation upon, or waiver of, any privileges and immunities - that apply to the Licensor or You, including from the legal - processes of any jurisdiction or authority. - - -======================================================================= - -Creative Commons is not a party to its public licenses. -Notwithstanding, Creative Commons may elect to apply one of its public -licenses to material it publishes and in those instances will be -considered the "Licensor." Except for the limited purpose of indicating -that material is shared under a Creative Commons public license or as -otherwise permitted by the Creative Commons policies published at -creativecommons.org/policies, Creative Commons does not authorize the -use of the trademark "Creative Commons" or any other trademark or logo -of Creative Commons without its prior written consent including, -without limitation, in connection with any unauthorized modifications -to any of its public licenses or any other arrangements, -understandings, or agreements concerning use of licensed material. For -the avoidance of doubt, this paragraph does not form part of the public -licenses. - -Creative Commons may be contacted at creativecommons.org. From 6368555ab0f80dcdd351fb90d49a1ddaee166cfc Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 14 Jan 2025 09:15:36 -0800 Subject: [PATCH 027/911] RN-Tester: Reorder buttons in the New Architecture sample (#48666) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48666 The New Architecture sample is getting too big and the two views are not visible anymore. I'm fixing this but having buttons side by side. Changelog: [Internal] [Changed] - Reviewed By: cipolleschi Differential Revision: D68153245 fbshipit-source-id: 5557fd40f81078fe3994d8efe0e73784e043ed78 --- .../NativeComponentExample/js/MyNativeView.js | 186 +++++++++--------- 1 file changed, 98 insertions(+), 88 deletions(-) diff --git a/packages/rn-tester/NativeComponentExample/js/MyNativeView.js b/packages/rn-tester/NativeComponentExample/js/MyNativeView.js index 5fe7c46c2dd6ce..11126e00222f18 100644 --- a/packages/rn-tester/NativeComponentExample/js/MyNativeView.js +++ b/packages/rn-tester/NativeComponentExample/js/MyNativeView.js @@ -169,84 +169,107 @@ export default function MyNativeView(props: {}): React.Node { Opacity: {opacity.toFixed(1)} -