diff --git a/.circleci/config.yml b/.circleci/config.yml index 0d4246cd398a65..6e2ed31c14e0fe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -794,7 +794,7 @@ jobs: - run: name: Build & Test React Native using Gradle - command: ./gradlew buildAll + command: ./gradlew build - report_bundle_size: platform: android @@ -1512,9 +1512,9 @@ jobs: cp -r $HERMES_WS_DIR/win64-bin/* ./packages/react-native/sdks/hermesc/win64-bin/. cp -r $HERMES_WS_DIR/linux64-bin/* ./packages/react-native/sdks/hermesc/linux64-bin/. - mkdir -p ./ReactAndroid/external-artifacts/artifacts/ - cp $HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-debug.tar.gz ./ReactAndroid/external-artifacts/artifacts/hermes-ios-debug.tar.gz - cp $HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-release.tar.gz ./ReactAndroid/external-artifacts/artifacts/hermes-ios-release.tar.gz + mkdir -p ./packages/react-native/ReactAndroid/external-artifacts/artifacts/ + cp $HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-debug.tar.gz ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-ios-debug.tar.gz + cp $HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-release.tar.gz ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-ios-release.tar.gz - run_yarn - download_gradle_dependencies diff --git a/.flowconfig b/.flowconfig index 8a778a52f22380..a1c46dc0535566 100644 --- a/.flowconfig +++ b/.flowconfig @@ -79,4 +79,4 @@ untyped-import untyped-type-import [version] -^0.201.0 +^0.202.0 diff --git a/.flowconfig.android b/.flowconfig.android index 844d3ca66b28ff..f779acc957dc76 100644 --- a/.flowconfig.android +++ b/.flowconfig.android @@ -82,4 +82,4 @@ untyped-import untyped-type-import [version] -^0.201.0 +^0.202.0 diff --git a/.flowconfig.macos b/.flowconfig.macos index 347b60990c23df..98d32180e29bae 100644 --- a/.flowconfig.macos +++ b/.flowconfig.macos @@ -82,4 +82,4 @@ untyped-import untyped-type-import [version] -^0.201.0 +^0.202.0 diff --git a/build.gradle.kts b/build.gradle.kts index 15c9fcdafc9eae..9ee10211d6141d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -65,18 +65,9 @@ tasks.register("cleanAll", Delete::class.java) { delete(rootProject.file("./packages/rn-tester/android/app/.cxx")) } -tasks.register("buildAll") { +tasks.register("build") { description = "Build and test all the React Native relevant projects." dependsOn(gradle.includedBuild("react-native-gradle-plugin").task(":build")) - // This builds both the React Native framework for both debug and release - dependsOn(":packages:react-native:ReactAndroid:assemble") - // This creates all the Maven artifacts and makes them available in the /android folder - dependsOn(":packages:react-native:ReactAndroid:installArchives") - // This builds RN Tester for Hermes/JSC for debug and release - dependsOn(":packages:rn-tester:android:app:assemble") - // This compiles the Unit Test sources (without running them as they're partially broken) - dependsOn(":packages:react-native:ReactAndroid:compileDebugUnitTestSources") - dependsOn(":packages:react-native:ReactAndroid:compileReleaseUnitTestSources") } tasks.register("downloadAll") { diff --git a/jest.config.js b/jest.config.js index bfb4282e40e2cc..7ee720980c1912 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,7 +13,7 @@ module.exports = { transform: { '^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': '/packages/react-native/jest/assetFileTransformer.js', - '.*': './packages/react-native/jest/private/preprocessor.js', + '.*': './jest/preprocessor.js', }, setupFiles: ['./packages/react-native/jest/local-setup.js'], fakeTimers: { diff --git a/packages/react-native/jest/private/preprocessor.js b/jest/preprocessor.js similarity index 92% rename from packages/react-native/jest/private/preprocessor.js rename to jest/preprocessor.js index c908e48da773a3..515588aee688c3 100644 --- a/packages/react-native/jest/private/preprocessor.js +++ b/jest/preprocessor.js @@ -24,9 +24,11 @@ const nodeFiles = new RegExp( '/metro(?:-[^/]*)?/', // metro, metro-core, metro-source-map, metro-etc. ].join('|'), ); -const nodeOptions = babelRegisterOnly.config([nodeFiles]); -babelRegisterOnly([]); +// Use metro-babel-register to build the Babel configuration we need for Node +// files, but Jest takes care of hooking require so we don't actually register +// Babel here. +const nodeOptions = babelRegisterOnly.config([nodeFiles]); const transformer = require('metro-react-native-babel-transformer'); module.exports = { diff --git a/package.json b/package.json index 2133f6ac121087..5a3be1e19c770f 100644 --- a/package.json +++ b/package.json @@ -56,10 +56,12 @@ "@babel/generator": "^7.20.0", "@babel/plugin-transform-regenerator": "^7.0.0", "@definitelytyped/dtslint": "^0.0.127", + "@jest/create-cache-key-function": "^29.2.1", "@reactions/component": "^2.0.2", "@types/react": "^18.0.18", "@typescript-eslint/parser": "^5.30.5", "async": "^3.2.2", + "babel-plugin-transform-flow-enums":"^0.0.2", "clang-format": "^1.8.0", "connect": "^3.6.5", "coveralls": "^3.1.1", @@ -77,7 +79,7 @@ "eslint-plugin-react-native": "^4.0.0", "eslint-plugin-redundant-undefined": "^0.4.0", "eslint-plugin-relay": "^1.8.3", - "flow-bin": "^0.201.0", + "flow-bin": "^0.202.0", "hermes-eslint": "0.8.0", "inquirer": "^7.1.0", "jest": "^29.2.1", @@ -85,8 +87,9 @@ "jscodeshift": "^0.14.0", "metro-babel-register": "0.75.1", "metro-memory-fs": "0.75.1", - "mock-fs": "^5.1.4", + "metro-react-native-babel-transformer": "0.75.1", "mkdirp": "^0.5.1", + "mock-fs": "^5.1.4", "prettier": "^2.4.1", "react": "18.2.0", "react-test-renderer": "^18.2.0", diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/MixedPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/MixedPropNativeComponent.js new file mode 100644 index 00000000000000..41169339f738c3 --- /dev/null +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/MixedPropNativeComponent.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict-local + */ + +import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; +import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; +import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; +import type {UnsafeMixed} from 'react-native/Libraries/Types/CodegenTypes'; + +type NativeProps = $ReadOnly<{| + ...ViewProps, + + // Props + mixedProp?: UnsafeMixed, +|}>; + +export default (codegenNativeComponent( + 'MixedPropNativeComponentView', +): HostComponent); diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentDescriptorH-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentDescriptorH-test.js.snap index ea31662a596cfd..74f0e533357b01 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentDescriptorH-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentDescriptorH-test.js.snap @@ -330,6 +330,34 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate for 'MixedPropNativeComponent.js' 1`] = ` +Object { + "ComponentDescriptors.h": " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using MixedPropNativeComponentViewComponentDescriptor = ConcreteComponentDescriptor; + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentHObjCpp-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentHObjCpp-test.js.snap index af5f3ee0fb4d82..043dd5027e0ee7 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentHObjCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateComponentHObjCpp-test.js.snap @@ -300,6 +300,31 @@ NS_ASSUME_NONNULL_END", } `; +exports[`GenerateComponentHObjCpp can generate for 'MixedPropNativeComponent.js' 1`] = ` +Object { + "RCTComponentViewHelpers.h": "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTMixedPropNativeComponentViewViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + exports[`GenerateComponentHObjCpp can generate for 'MultiNativePropNativeComponent.js' 1`] = ` Object { "RCTComponentViewHelpers.h": "/** diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap index c7a0910f721e81..398b3cf4fece32 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap @@ -362,6 +362,31 @@ void InterfaceOnlyNativeComponentViewEventEmitter::onChange(OnChange event) cons }); } +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate for 'MixedPropNativeComponent.js' 1`] = ` +Object { + "EventEmitters.cpp": " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterH-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterH-test.js.snap index 406ead6ef65c44..ee30ee4cbd70e2 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterH-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateEventEmitterH-test.js.snap @@ -461,6 +461,40 @@ class JSI_EXPORT InterfaceOnlyNativeComponentViewEventEmitter : public ViewEvent }; void onChange(OnChange value) const; +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate for 'MixedPropNativeComponent.js' 1`] = ` +Object { + "EventEmitters.h": " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT MixedPropNativeComponentViewEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + }; } // namespace react diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap index 1b907467748503..08c596c6cc90c6 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap @@ -421,6 +421,39 @@ InterfaceOnlyNativeComponentViewProps::InterfaceOnlyNativeComponentViewProps( } `; +exports[`GeneratePropsCpp can generate for 'MixedPropNativeComponent.js' 1`] = ` +Object { + "Props.cpp": " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +MixedPropNativeComponentViewProps::MixedPropNativeComponentViewProps( + const PropsParserContext &context, + const MixedPropNativeComponentViewProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), + + mixedProp(convertRawProp(context, rawProps, \\"mixedProp\\", sourceProps.mixedProp, {})) + {} + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GeneratePropsCpp can generate for 'MultiNativePropNativeComponent.js' 1`] = ` Object { "Props.cpp": " diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap index 4666f4b9a34a5a..ebc4cd23016df7 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap @@ -625,6 +625,42 @@ class JSI_EXPORT InterfaceOnlyNativeComponentViewProps final : public ViewProps } `; +exports[`GeneratePropsH can generate for 'MixedPropNativeComponent.js' 1`] = ` +Object { + "Props.h": " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT MixedPropNativeComponentViewProps final : public ViewProps { + public: + MixedPropNativeComponentViewProps() = default; + MixedPropNativeComponentViewProps(const PropsParserContext& context, const MixedPropNativeComponentViewProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + folly::dynamic mixedProp{}; +}; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GeneratePropsH can generate for 'MultiNativePropNativeComponent.js' 1`] = ` Object { "Props.h": " diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsJavaDelegate-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsJavaDelegate-test.js.snap index 23434676375b57..ebc5a9b14945e3 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsJavaDelegate-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsJavaDelegate-test.js.snap @@ -505,6 +505,44 @@ public class InterfaceOnlyNativeComponentViewManagerDelegate & MixedPropNativeComponentViewManagerInterface> extends BaseViewManagerDelegate { + public MixedPropNativeComponentViewManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + switch (propName) { + case \\"mixedProp\\": + mViewManager.setMixedProp(view, new DynamicFromObject(value)); + break; + default: + super.setProperty(view, propName, value); + } + } +} +", +} +`; + exports[`GeneratePropsJavaDelegate can generate for 'MultiNativePropNativeComponent.js' 1`] = ` Object { "java/com/facebook/react/viewmanagers/MultiNativePropNativeComponentViewManagerDelegate.java": "/** diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsJavaInterface-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsJavaInterface-test.js.snap index 145e6d63229f23..1c3b62895ff6fa 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsJavaInterface-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsJavaInterface-test.js.snap @@ -296,6 +296,29 @@ public interface InterfaceOnlyNativeComponentViewManagerInterface { + void setMixedProp(T view, Dynamic value); +} +", +} +`; + exports[`GeneratePropsJavaInterface can generate for 'MultiNativePropNativeComponent.js' 1`] = ` Object { "java/com/facebook/react/viewmanagers/MultiNativePropNativeComponentViewManagerInterface.java": "/** diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeCpp-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeCpp-test.js.snap index 3aa7c5a35b717c..224a02cc2ca754 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeCpp-test.js.snap @@ -294,6 +294,31 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate for 'MixedPropNativeComponent.js' 1`] = ` +Object { + "ShadowNodes.cpp": " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char MixedPropNativeComponentViewComponentName[] = \\"MixedPropNativeComponentView\\"; + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeH-test.js.snap b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeH-test.js.snap index 53ba86ce5fc30c..d4d33cc34ad983 100644 --- a/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeH-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GenerateShadowNodeH-test.js.snap @@ -465,6 +465,46 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate for 'MixedPropNativeComponent.js' 1`] = ` +Object { + "ShadowNodes.h": " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char MixedPropNativeComponentViewComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using MixedPropNativeComponentViewShadowNode = ConcreteViewShadowNode< + MixedPropNativeComponentViewComponentName, + MixedPropNativeComponentViewProps, + MixedPropNativeComponentViewEventEmitter, + MixedPropNativeComponentViewState>; + } // namespace react } // namespace facebook ", 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 5630f8db49b7c7..fcfb25d973f431 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 @@ -509,6 +509,40 @@ export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL } `; +exports[`GenerateViewConfigJs can generate for 'MixedPropNativeComponent.js' 1`] = ` +Map { + "RNCodegenModuleFixturesNativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'MixedPropNativeComponentView'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'MixedPropNativeComponentView', + + validAttributes: { + mixedProp: true, + }, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + exports[`GenerateViewConfigJs can generate for 'MultiNativePropNativeComponent.js' 1`] = ` Map { "RNCodegenModuleFixturesNativeViewConfig.js" => " diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 17497531ed0803..6265482f91dbf8 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -58,6 +58,10 @@ export type ObjectTypeAnnotation<+T> = $ReadOnly<{ baseTypes?: $ReadOnlyArray, }>; +export type MixedTypeAnnotation = $ReadOnly<{ + type: 'MixedTypeAnnotation', +}>; + type FunctionTypeAnnotation<+P, +R> = $ReadOnly<{ type: 'FunctionTypeAnnotation', params: $ReadOnlyArray>, @@ -177,7 +181,8 @@ export type PropTypeAnnotation = type: 'ArrayTypeAnnotation', elementType: ObjectTypeAnnotation, }>, - }>; + }> + | MixedTypeAnnotation; export type ReservedPropTypeAnnotation = $ReadOnly<{ type: 'ReservedPropTypeAnnotation', diff --git a/packages/react-native-codegen/src/generators/components/ComponentsGeneratorUtils.js b/packages/react-native-codegen/src/generators/components/ComponentsGeneratorUtils.js index 046b9ed27919b4..c43768a1593439 100644 --- a/packages/react-native-codegen/src/generators/components/ComponentsGeneratorUtils.js +++ b/packages/react-native-codegen/src/generators/components/ComponentsGeneratorUtils.js @@ -122,6 +122,8 @@ function getNativeTypeFromAnnotation( return getEnumName(componentName, prop.name); case 'Int32EnumTypeAnnotation': return getEnumName(componentName, prop.name); + case 'MixedTypeAnnotation': + return 'folly::dynamic'; default: (typeAnnotation: empty); throw new Error( diff --git a/packages/react-native-codegen/src/generators/components/CppHelpers.js b/packages/react-native-codegen/src/generators/components/CppHelpers.js index cb3090df08cdfa..c7fbff186de863 100644 --- a/packages/react-native-codegen/src/generators/components/CppHelpers.js +++ b/packages/react-native-codegen/src/generators/components/CppHelpers.js @@ -200,6 +200,8 @@ function convertDefaultTypeToString( prop.name, typeAnnotation.default, )}`; + case 'MixedTypeAnnotation': + return ''; default: (typeAnnotation: empty); throw new Error(`Unsupported type annotation: ${typeAnnotation.type}`); diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js index 15a7fcc425a174..684153b23b5ea5 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js @@ -676,6 +676,8 @@ function generateStruct( } generateStruct(structs, componentName, nameParts.concat([name]), props); return; + case 'MixedTypeAnnotation': + return; default: (property.typeAnnotation.type: empty); throw new Error( diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js index d08dc617423ddb..68875b3b6caa6c 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js @@ -144,6 +144,8 @@ function getJavaValueForProp( return '(String) value'; case 'Int32EnumTypeAnnotation': return `value == null ? ${typeAnnotation.default} : ((Double) value).intValue()`; + case 'MixedTypeAnnotation': + return 'new DynamicFromObject(value)'; default: (typeAnnotation: empty); throw new Error('Received invalid typeAnnotation'); diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js index bc92d41b8ef8a8..a71f9b696ede6d 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js @@ -127,6 +127,8 @@ function getJavaValueForProp( case 'Int32EnumTypeAnnotation': addNullable(imports); return '@Nullable Integer value'; + case 'MixedTypeAnnotation': + return 'Dynamic value'; default: (typeAnnotation: empty); throw new Error('Received invalid typeAnnotation'); diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/PojoCollector.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/PojoCollector.js index eb7b1091dc7784..81829b99da8467 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/PojoCollector.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/PojoCollector.js @@ -20,6 +20,7 @@ import type { FloatTypeAnnotation, Int32TypeAnnotation, PropTypeAnnotation, + MixedTypeAnnotation, } from '../../../CodegenSchema'; const {capitalize} = require('../../Utils'); @@ -89,7 +90,8 @@ export type PojoTypeAnnotation = type: 'ArrayTypeAnnotation', elementType: PojoTypeAliasAnnotation, }>, - }>; + }> + | MixedTypeAnnotation; class PojoCollector { _pojos: Map = new Map(); diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/serializePojo.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/serializePojo.js index 99d009c8e2b72a..f9f7234931fee0 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/serializePojo.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/serializePojo.js @@ -24,6 +24,7 @@ function toJavaType( addImport('com.facebook.react.bridge.ReadableMap'); const importArrayList = () => addImport('java.util.ArrayList'); const importYogaValue = () => addImport('com.facebook.yoga.YogaValue'); + const importDynamic = () => addImport('com.facebook.react.bridge.Dynamic'); switch (typeAnnotation.type) { /** * Primitives @@ -222,6 +223,11 @@ function toJavaType( return `ArrayList<${elementTypeString}>`; } + case 'MixedTypeAnnotation': { + importDynamic(); + return 'Dynamic'; + } + default: { (typeAnnotation.type: empty); throw new Error( diff --git a/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js b/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js index 9307eb9398a88b..c8d96823129b78 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js +++ b/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js @@ -60,6 +60,7 @@ function getReactDiffProcessValue(typeAnnotation: PropTypeAnnotation) { case 'ObjectTypeAnnotation': case 'StringEnumTypeAnnotation': case 'Int32EnumTypeAnnotation': + case 'MixedTypeAnnotation': return j.literal(true); case 'ReservedPropTypeAnnotation': switch (typeAnnotation.name) { diff --git a/packages/react-native-codegen/src/generators/components/JavaHelpers.js b/packages/react-native-codegen/src/generators/components/JavaHelpers.js index 2d7b262cf032ae..48556d47db6636 100644 --- a/packages/react-native-codegen/src/generators/components/JavaHelpers.js +++ b/packages/react-native-codegen/src/generators/components/JavaHelpers.js @@ -117,6 +117,14 @@ function getImports( if (typeAnnotation.type === 'ObjectTypeAnnotation') { imports.add('import com.facebook.react.bridge.ReadableMap;'); } + + if (typeAnnotation.type === 'MixedTypeAnnotation') { + if (type === 'delegate') { + imports.add('import com.facebook.react.bridge.DynamicFromObject;'); + } else { + imports.add('import com.facebook.react.bridge.Dynamic;'); + } + } }); return imports; diff --git a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js index a8277a7a67b673..57997808f52192 100644 --- a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js @@ -1123,6 +1123,35 @@ const INT32_ENUM_PROP: SchemaType = { }, }; +const MIXED_PROP: SchemaType = { + modules: { + CustomView: { + type: 'Component', + components: { + MixedPropNativeComponent: { + extendsProps: [ + { + type: 'ReactNativeBuiltInType', + knownTypeName: 'ReactNativeCoreViewProps', + }, + ], + events: [], + props: [ + { + name: 'mixedProp', + optional: false, + typeAnnotation: { + type: 'MixedTypeAnnotation', + }, + }, + ], + commands: [], + }, + }, + }, + }, +}; + const EVENT_PROPS: SchemaType = { modules: { Switch: { @@ -1701,6 +1730,7 @@ module.exports = { MULTI_NATIVE_PROP, STRING_ENUM_PROP, INT32_ENUM_PROP, + MIXED_PROP, EVENT_PROPS, EVENTS_WITH_PAPER_NAME, EVENT_NESTED_OBJECT_PROPS, diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap index 21f4224e995e75..72653d4c56f282 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap @@ -555,6 +555,34 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture MIXED_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using MixedPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap index 13a2561d102446..b232a9446ff12f 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap @@ -634,6 +634,31 @@ NS_ASSUME_NONNULL_END", } `; +exports[`GenerateComponentHObjCpp can generate fixture MIXED_PROP 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GenerateComponentHObjCpp.js +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTMixedPropNativeComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + exports[`GenerateComponentHObjCpp can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap index 54d8ff0696dc66..e2a91512639f4e 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap @@ -558,6 +558,31 @@ void InterfaceOnlyComponentEventEmitter::onChange(OnChange event) const { }); } +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture MIXED_PROP 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap index 56580a3aa77b7c..62a430022e750a 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap @@ -733,6 +733,40 @@ class JSI_EXPORT InterfaceOnlyComponentEventEmitter : public ViewEventEmitter { }; void onChange(OnChange value) const; +}; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture MIXED_PROP 1`] = ` +Map { + "EventEmitters.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT MixedPropNativeComponentEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + + + }; } // namespace react diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap index e50d587ce6109a..0853ba4c34c038 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap @@ -694,6 +694,39 @@ InterfaceOnlyComponentProps::InterfaceOnlyComponentProps( } `; +exports[`GeneratePropsCpp can generate fixture MIXED_PROP 1`] = ` +Map { + "Props.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +MixedPropNativeComponentProps::MixedPropNativeComponentProps( + const PropsParserContext &context, + const MixedPropNativeComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), + + mixedProp(convertRawProp(context, rawProps, \\"mixedProp\\", sourceProps.mixedProp, {})) + {} + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GeneratePropsCpp can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "Props.cpp" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap index 2233888c128b24..7260cdda760c1b 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap @@ -999,6 +999,42 @@ class JSI_EXPORT InterfaceOnlyComponentProps final : public ViewProps { } `; +exports[`GeneratePropsH can generate fixture MIXED_PROP 1`] = ` +Map { + "Props.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT MixedPropNativeComponentProps final : public ViewProps { + public: + MixedPropNativeComponentProps() = default; + MixedPropNativeComponentProps(const PropsParserContext& context, const MixedPropNativeComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + folly::dynamic mixedProp{}; +}; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GeneratePropsH can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "Props.h" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap index 32e18daa15dee1..9bec5993102bd3 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap @@ -785,6 +785,44 @@ public class InterfaceOnlyComponentManagerDelegate "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; + +public class MixedPropNativeComponentManagerDelegate & MixedPropNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public MixedPropNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + switch (propName) { + case \\"mixedProp\\": + mViewManager.setMixedProp(view, new DynamicFromObject(value)); + break; + default: + super.setProperty(view, propName, value); + } + } +} +", +} +`; + exports[`GeneratePropsJavaDelegate can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/ImageColorPropNativeComponentManagerDelegate.java" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap index 350114d82c12e0..5b828b122d858f 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap @@ -458,6 +458,29 @@ public interface InterfaceOnlyComponentManagerInterface { } `; +exports[`GeneratePropsJavaInterface can generate fixture MIXED_PROP 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MixedPropNativeComponentManagerInterface.java" => "/** +* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). +* +* Do not edit this file as changes may cause incorrect behavior and will be lost +* once the code is regenerated. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import com.facebook.react.bridge.Dynamic; + +public interface MixedPropNativeComponentManagerInterface { + void setMixedProp(T view, Dynamic value); +} +", +} +`; + exports[`GeneratePropsJavaInterface can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/ImageColorPropNativeComponentManagerInterface.java" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap index 5bd56c08bfcf85..47ce16d68f18f5 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap @@ -758,6 +758,34 @@ public class InterfaceOnlyComponentProps { } `; +exports[`GeneratePropsJavaPojo can generate fixture MIXED_PROP 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/CustomView/MixedPropNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.CustomView; + +import com.facebook.proguard.annotations.DoNotStrip; +import com.facebook.react.bridge.Dynamic; + +@DoNotStrip +public class MixedPropNativeComponentProps { + private Dynamic mMixedProp; + @DoNotStrip + public Dynamic getMixedProp() { + return mMixedProp; + } +} +", +} +`; + exports[`GeneratePropsJavaPojo can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "java/com/facebook/react/viewmanagers/Slider/ImageColorPropNativeComponentProps.java" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap index 7184800ffe0c01..6172d9ae625739 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap @@ -495,6 +495,31 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeCpp can generate fixture MIXED_PROP 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char MixedPropNativeComponentComponentName[] = \\"MixedPropNativeComponent\\"; + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap index b8c9408db1718b..f8e76bfa9e41d2 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap @@ -787,6 +787,46 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateShadowNodeH can generate fixture MIXED_PROP 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char MixedPropNativeComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using MixedPropNativeComponentShadowNode = ConcreteViewShadowNode< + MixedPropNativeComponentComponentName, + MixedPropNativeComponentProps, + MixedPropNativeComponentEventEmitter, + MixedPropNativeComponentState>; + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateCpp-test.js.snap index 736f26f9d05f14..81112bcefb78cf 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateCpp-test.js.snap @@ -474,6 +474,30 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateStateCpp can generate fixture MIXED_PROP 1`] = ` +Map { + "States.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateCpp.js + */ +#include + +namespace facebook { +namespace react { + + + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateH-test.js.snap index 22bd441cff30fd..c295dcfc57a1fb 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateStateH-test.js.snap @@ -804,6 +804,47 @@ namespace react { +} // namespace react +} // namespace facebook", +} +`; + +exports[`GenerateStateH can generate fixture MIXED_PROP 1`] = ` +Map { + "States.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateStateH.js + */ +#pragma once + +#ifdef ANDROID +#include +#include +#include +#endif + +namespace facebook { +namespace react { + +class MixedPropNativeComponentState { +public: + MixedPropNativeComponentState() = default; + +#ifdef ANDROID + MixedPropNativeComponentState(MixedPropNativeComponentState const &previousState, folly::dynamic data){}; + folly::dynamic getDynamic() const { + return {}; + }; + MapBuffer getMapBuffer() const { + return MapBufferBuilder::EMPTY(); + }; +#endif +}; + } // namespace react } // namespace facebook", } diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap index 1ff57477166f7a..8eeed7604d0d42 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap @@ -899,6 +899,41 @@ TEST(InterfaceOnlyComponentProps_accessibilityHint, etc) { } `; +exports[`GenerateTests can generate fixture MIXED_PROP 1`] = ` +Map { + "Tests.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateTests.js + * */ + +#include +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(MixedPropNativeComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = MixedPropNativeComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + + ContextContainer contextContainer{}; + PropsParserContext parserContext{-1, contextContainer}; + + rawProps.parse(propParser, parserContext); + MixedPropNativeComponentProps(parserContext, sourceProps, rawProps); +}", +} +`; + exports[`GenerateTests can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "Tests.cpp" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap index 53593a306e6d0e..82f6247e94f4f0 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderH-test.js.snap @@ -41,6 +41,7 @@ Class ObjectPropsCls(void) __attribute__((used)); // O Class ImageColorPropNativeComponentCls(void) __attribute__((used)); // MULTI_NATIVE_PROP Class StringEnumPropsNativeComponentCls(void) __attribute__((used)); // STRING_ENUM_PROP Class Int32EnumPropsNativeComponentCls(void) __attribute__((used)); // INT32_ENUM_PROP +Class MixedPropNativeComponentCls(void) __attribute__((used)); // MIXED_PROP Class EventsNativeComponentCls(void) __attribute__((used)); // EVENT_PROPS Class InterfaceOnlyComponentCls(void) __attribute__((used)); // EVENTS_WITH_PAPER_NAME Class EventsNestedObjectNativeComponentCls(void) __attribute__((used)); // EVENT_NESTED_OBJECT_PROPS diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap index 9fbb881bc9cb2f..c766a6b679a9b5 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateThirdPartyFabricComponentsProviderObjCpp-test.js.snap @@ -58,6 +58,8 @@ Class RCTThirdPartyFabricComponentsProvider(const char {\\"Int32EnumPropsNativeComponent\\", Int32EnumPropsNativeComponentCls}, // INT32_ENUM_PROP + {\\"MixedPropNativeComponent\\", MixedPropNativeComponentCls}, // MIXED_PROP + {\\"EventsNativeComponent\\", EventsNativeComponentCls}, // EVENT_PROPS {\\"InterfaceOnlyComponent\\", InterfaceOnlyComponentCls}, // EVENTS_WITH_PAPER_NAME 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 3b8b77d0d2bf2d..1826f646289b8e 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 @@ -817,6 +817,40 @@ export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL } `; +exports[`GenerateViewConfigJs can generate fixture MIXED_PROP 1`] = ` +Map { + "MIXED_PROPNativeViewConfig.js" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @flow + * + * @generated by codegen project: GenerateViewConfigJs.js + */ + +'use strict'; + +const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry'); + +let nativeComponentName = 'MixedPropNativeComponent'; + + +export const __INTERNAL_VIEW_CONFIG = { + uiViewClassName: 'MixedPropNativeComponent', + + validAttributes: { + mixedProp: true, + }, +}; + +export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG); +", +} +`; + exports[`GenerateViewConfigJs can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "MULTI_NATIVE_PROPNativeViewConfig.js" => " diff --git a/packages/react-native-codegen/src/parsers/__tests__/parsers-commons-test.js b/packages/react-native-codegen/src/parsers/__tests__/parsers-commons-test.js index db591ef698d8bb..54217fc11bd989 100644 --- a/packages/react-native-codegen/src/parsers/__tests__/parsers-commons-test.js +++ b/packages/react-native-codegen/src/parsers/__tests__/parsers-commons-test.js @@ -21,6 +21,8 @@ import { buildSchema, parseModuleName, createComponentConfig, + getCommandOptions, + getOptions, } from '../parsers-commons'; import type {ParserType} from '../errors'; @@ -1277,3 +1279,133 @@ describe('createComponentConfig', () => { }); }); }); + +describe('getCommandOptions', () => { + it('returns null when commandOptionsExpression is null', () => { + const result = getCommandOptions(null); + expect(result).toBeNull(); + }); + + it('parses and returns command options correctly', () => { + const commandOptionsExpression = { + properties: [ + { + range: [], + loc: {}, + type: '', + key: { + name: 'hotspotUpdate', + loc: {}, + }, + value: { + elements: [ + { + value: 'value', + }, + ], + }, + }, + ], + }; + const result = getCommandOptions(commandOptionsExpression); + expect(result).toEqual({ + hotspotUpdate: ['value'], + }); + }); + + it('should throw an error if command options are not defined correctly', () => { + const commandOptionsExpression = { + properties: null, + }; + expect(() => getCommandOptions(commandOptionsExpression)).toThrowError( + 'Failed to parse command options, please check that they are defined correctly', + ); + }); +}); + +describe('getOptions', () => { + it('returns null if optionsExpression is falsy', () => { + expect(getOptions(null)).toBeNull(); + expect(getOptions(undefined)).toBeNull(); + expect(getOptions(false)).toBeNull(); + expect(getOptions(0)).toBeNull(); + expect(getOptions('')).toBeNull(); + }); + + it('parses and returns options correctly if codegen options are defined correctly', () => { + const optionsExpression = { + properties: [ + { + value: { + type: 'ArrayExpression', + value: 'value', + elements: [ + { + value: 'value1', + }, + ], + }, + key: { + name: 'keyName', + }, + }, + ], + }; + expect(getOptions(optionsExpression)).toEqual({ + keyName: ['value1'], + }); + }); + + it('throws an error if codegen options are not defined correctly', () => { + const optionsExpression = { + properties: null, + }; + expect(() => getOptions(optionsExpression)).toThrowError( + 'Failed to parse codegen options, please check that they are defined correctly', + ); + }); + + it('throws an error if both paperComponentName and paperComponentNameDeprecated are used', () => { + const optionsExpression = { + properties: [ + { + key: {name: 'paperComponentName'}, + value: {value: 'RCTRefreshControl'}, + }, + { + key: {name: 'paperComponentNameDeprecated'}, + value: {value: 'RCTSwitch'}, + }, + ], + }; + expect(() => getOptions(optionsExpression)).toThrowError( + 'Failed to parse codegen options, cannot use both paperComponentName and paperComponentNameDeprecated', + ); + }); + + it('returns options if only paperComponentName is used', () => { + const optionsExpression = { + properties: [ + { + key: {name: 'paperComponentName'}, + value: {value: 'RCTRefreshControl'}, + }, + ], + }; + const expectedOptions = {paperComponentName: 'RCTRefreshControl'}; + expect(getOptions(optionsExpression)).toEqual(expectedOptions); + }); + + it('returns options if only paperComponentNameDeprecated is used', () => { + const optionsExpression = { + properties: [ + { + key: {name: 'paperComponentNameDeprecated'}, + value: {value: 'RCTRefreshControl'}, + }, + ], + }; + const expectedOptions = {paperComponentNameDeprecated: 'RCTRefreshControl'}; + expect(getOptions(optionsExpression)).toEqual(expectedOptions); + }); +}); diff --git a/packages/react-native-codegen/src/parsers/__tests__/parsers-primitives-test.js b/packages/react-native-codegen/src/parsers/__tests__/parsers-primitives-test.js index 6c09b098daaf84..2574005f71e6b9 100644 --- a/packages/react-native-codegen/src/parsers/__tests__/parsers-primitives-test.js +++ b/packages/react-native-codegen/src/parsers/__tests__/parsers-primitives-test.js @@ -28,6 +28,8 @@ const { emitString, emitStringish, emitMixed, + emitPartial, + emitCommonTypes, typeAliasResolution, typeEnumResolution, Visitor, @@ -1253,3 +1255,243 @@ describe('Visitor', () => { }); }); }); + +describe('emitPartial', () => { + const hasteModuleName = 'SampleTurboModule'; + function emitPartialForUnitTest( + typeAnnotation: $FlowFixMe, + nullable: boolean, + ): $FlowFixMe { + return emitPartial( + hasteModuleName, + typeAnnotation, + /* types: TypeDeclarationMap */ + {}, + /* aliasMap: {...NativeModuleAliasMap} */ + {}, + /* enumMap: {...NativeModuleEnumMap} */ + {}, + /* tryParse: ParserErrorCapturer */ + // $FlowFixMe[missing-local-annot] + function (_: () => T) { + return null; + }, + /* cxxOnly: boolean */ + false, + nullable, + parser, + ); + } + + describe("when 'typeAnnotation' doesn't have exactly 'one' typeParameter", () => { + const nullable = false; + const typeAnnotation = { + typeParameters: { + params: [1, 2], + type: 'TypeParameterInstantiation', + }, + id: { + name: 'typeAnnotationName', + }, + }; + + it('throws an error', () => { + expect(() => emitPartialForUnitTest(typeAnnotation, nullable)).toThrow( + 'Partials only support annotating exactly one parameter.', + ); + }); + }); + + describe('when Partial Not annotating type parameter', () => { + const nullable = false; + const typeAnnotation = { + typeParameters: { + params: [ + { + id: { + name: 'TypeDeclaration', + }, + }, + ], + }, + id: { + name: 'typeAnnotationName', + }, + }; + + it('throws an error', () => { + expect(() => emitPartialForUnitTest(typeAnnotation, nullable)).toThrow( + 'Partials only support annotating a type parameter.', + ); + }); + }); +}); + +describe('emitCommonTypes', () => { + const hasteModuleName = 'SampleTurboModule'; + + function emitCommonTypesForUnitTest( + typeAnnotation: $FlowFixMe, + nullable: boolean, + ): $FlowFixMe { + return emitCommonTypes( + hasteModuleName, + /* types: TypeDeclarationMap */ + {}, + typeAnnotation, + /* aliasMap: {...NativeModuleAliasMap} */ + {}, + /* enumMap: {...NativeModuleEnumMap} */ + {}, + /* tryParse: ParserErrorCapturer */ + // $FlowFixMe[missing-local-annot] + function (_: () => T) { + return null; + }, + /* cxxOnly: boolean */ + false, + nullable, + parser, + ); + } + + describe("when 'typeAnnotation.id.name' is 'Stringish'", () => { + const typeAnnotation = { + typeParameters: { + params: [1, 2], + type: 'StringTypeAnnotation', + }, + id: { + name: 'Stringish', + }, + }; + const expected = { + type: 'StringTypeAnnotation', + }; + const result = emitCommonTypesForUnitTest(typeAnnotation, false); + + it("returns 'StringTypeAnnotation'", () => { + expect(result).toEqual(expected); + }); + }); + + describe("when 'typeAnnotation.id.name' is 'Int32'", () => { + const typeAnnotation = { + typeParameters: { + params: [1, 2], + type: 'Int32TypeAnnotation', + }, + id: { + name: 'Int32', + }, + }; + const expected = { + type: 'Int32TypeAnnotation', + }; + const result = emitCommonTypesForUnitTest(typeAnnotation, false); + + it("returns 'Int32TypeAnnotation'", () => { + expect(result).toEqual(expected); + }); + }); + + describe("when 'typeAnnotation.id.name' is 'Double'", () => { + const typeAnnotation = { + typeParameters: { + params: [1, 2], + type: 'DoubleTypeAnnotation', + }, + id: { + name: 'Double', + }, + }; + const expected = { + type: 'DoubleTypeAnnotation', + }; + const result = emitCommonTypesForUnitTest(typeAnnotation, false); + + it("returns 'DoubleTypeAnnotation'", () => { + expect(result).toEqual(expected); + }); + }); + + describe("when 'typeAnnotation.id.name' is 'Float'", () => { + const typeAnnotation = { + typeParameters: { + params: [1, 2], + type: 'FloatTypeAnnotation', + }, + id: { + name: 'Float', + }, + }; + const expected = { + type: 'FloatTypeAnnotation', + }; + const result = emitCommonTypesForUnitTest(typeAnnotation, false); + + it("returns 'FloatTypeAnnotation'", () => { + expect(result).toEqual(expected); + }); + }); + + describe("when 'typeAnnotation.id.name' is 'UnsafeObject'", () => { + const typeAnnotation = { + typeParameters: { + params: [1, 2], + type: 'GenericObjectTypeAnnotation', + }, + id: { + name: 'UnsafeObject', + }, + }; + const expected = { + type: 'GenericObjectTypeAnnotation', + }; + const result = emitCommonTypesForUnitTest(typeAnnotation, false); + + it("returns 'GenericObjectTypeAnnotation'", () => { + expect(result).toEqual(expected); + }); + }); + + describe("when 'typeAnnotation.id.name' is 'Object'", () => { + const typeAnnotation = { + typeParameters: { + params: [1, 2], + type: 'GenericObjectTypeAnnotation', + }, + id: { + name: 'Object', + }, + }; + const expected = { + type: 'GenericObjectTypeAnnotation', + }; + const result = emitCommonTypesForUnitTest(typeAnnotation, false); + + it("returns 'GenericObjectTypeAnnotation'", () => { + expect(result).toEqual(expected); + }); + }); + + describe("when 'typeAnnotation.id.name' is '$Partial' i.e. Object", () => { + const typeAnnotation = { + typeParameters: { + params: [1], + type: 'GenericObjectTypeAnnotation', + }, + id: { + name: 'Object', + }, + }; + const expected = { + type: 'GenericObjectTypeAnnotation', + }; + const result = emitCommonTypesForUnitTest(typeAnnotation, false); + + it("returns 'GenericObjectTypeAnnotation'", () => { + expect(result).toEqual(expected); + }); + }); +}); diff --git a/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/fixtures.js index e83299d3a5b0f2..3a724b3411172b 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/parsers/flow/components/__test_fixtures__/fixtures.js @@ -209,7 +209,7 @@ const ALL_PROP_TYPES_NO_EVENTS = ` const codegenNativeComponent = require('codegenNativeComponent'); -import type {Int32, Double, Float, WithDefault} from 'CodegenTypes'; +import type {Int32, Double, Float, WithDefault, UnsafeMixed} from 'CodegenTypes'; import type {ImageSource} from 'ImageSource'; import type {ColorValue, ColorArrayValue, PointValue, EdgeInsetsValue, DimensionValue} from 'StyleSheetTypes'; import type {ViewProps} from 'ViewPropTypes'; @@ -317,6 +317,10 @@ type ModuleProps = $ReadOnly<{| dimension_optional_key?: DimensionValue, dimension_optional_value: ?DimensionValue, dimension_optional_both?: ?DimensionValue, + + // Mixed props + mixed_required: UnsafeMixed, + mixed_optional_key?: UnsafeMixed, |}>; export default (codegenNativeComponent( diff --git a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap index 21ee4a352be74d..f3ec2606cfc16c 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap @@ -571,6 +571,20 @@ exports[`RN Codegen Flow Parser can generate fixture ALL_PROP_TYPES_NO_EVENTS 1` 'type': 'ReservedPropTypeAnnotation', 'name': 'DimensionPrimitive' } + }, + { + 'name': 'mixed_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'MixedTypeAnnotation' + } + }, + { + 'name': 'mixed_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'MixedTypeAnnotation' + } } ], 'commands': [] diff --git a/packages/react-native-codegen/src/parsers/flow/components/componentsUtils.js b/packages/react-native-codegen/src/parsers/flow/components/componentsUtils.js index 03458e525ad8b1..d694fe2f795e3a 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/componentsUtils.js +++ b/packages/react-native-codegen/src/parsers/flow/components/componentsUtils.js @@ -391,6 +391,10 @@ function getTypeAnnotation<+T>( throw new Error( `Cannot use "${type}" type annotation for "${name}": must use a specific numeric type like Int32, Double, or Float`, ); + case 'UnsafeMixed': + return { + type: 'MixedTypeAnnotation', + }; default: (type: empty); throw new Error( diff --git a/packages/react-native-codegen/src/parsers/flow/components/index.js b/packages/react-native-codegen/src/parsers/flow/components/index.js index 864915816c02b7..43aee56804580e 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/index.js +++ b/packages/react-native-codegen/src/parsers/flow/components/index.js @@ -11,19 +11,20 @@ 'use strict'; import type {Parser} from '../../parser'; import type {TypeDeclarationMap} from '../../utils'; -import type {CommandOptions} from './options'; +import type {CommandOptions} from '../../parsers-commons'; import type {ComponentSchemaBuilderConfig} from '../../schema.js'; const {getCommands} = require('./commands'); const {getEvents} = require('./events'); const {getExtendsProps, removeKnownExtends} = require('./extends'); -const {getCommandOptions, getOptions} = require('./options'); const {getProps} = require('./props'); const {getProperties} = require('./componentsUtils.js'); const {throwIfMoreThanOneCodegenNativecommands} = require('../../error-utils'); const { createComponentConfig, findNativeComponentType, + getCommandOptions, + getOptions, } = require('../../parsers-commons'); // $FlowFixMe[signature-verification-failure] there's no flowtype for AST diff --git a/packages/react-native-codegen/src/parsers/flow/components/options.js b/packages/react-native-codegen/src/parsers/flow/components/options.js deleted file mode 100644 index a83ba528b467d8..00000000000000 --- a/packages/react-native-codegen/src/parsers/flow/components/options.js +++ /dev/null @@ -1,87 +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. - * - * @flow strict - * @format - */ - -'use strict'; - -import type {OptionsShape} from '../../../CodegenSchema.js'; - -// $FlowFixMe[unclear-type] there's no flowtype for ASTs -type OptionsAST = Object; - -export type CommandOptions = $ReadOnly<{ - supportedCommands: $ReadOnlyArray, -}>; - -function getCommandOptions( - commandOptionsExpression: OptionsAST, -): ?CommandOptions { - if (commandOptionsExpression == null) { - return null; - } - - let foundOptions; - try { - foundOptions = commandOptionsExpression.properties.reduce( - (options, prop) => { - options[prop.key.name] = ( - (prop && prop.value && prop.value.elements) || - [] - ).map(element => element && element.value); - return options; - }, - {}, - ); - } catch (e) { - throw new Error( - 'Failed to parse command options, please check that they are defined correctly', - ); - } - - return foundOptions; -} - -function getOptions(optionsExpression: OptionsAST): ?OptionsShape { - if (!optionsExpression) { - return null; - } - let foundOptions; - try { - foundOptions = optionsExpression.properties.reduce((options, prop) => { - if (prop.value.type === 'ArrayExpression') { - options[prop.key.name] = prop.value.elements.map( - element => element.value, - ); - } else { - options[prop.key.name] = prop.value.value; - } - return options; - }, {}); - } catch (e) { - throw new Error( - 'Failed to parse codegen options, please check that they are defined correctly', - ); - } - - if ( - foundOptions.paperComponentName && - foundOptions.paperComponentNameDeprecated - ) { - throw new Error( - 'Failed to parse codegen options, cannot use both paperComponentName and paperComponentNameDeprecated', - ); - } - - return foundOptions; -} - -module.exports = { - getCommandOptions, - getOptions, -}; diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index 1ab013270c8b90..13c3fc91ca7f2f 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -32,20 +32,16 @@ const { const { emitArrayType, emitBoolean, - emitDouble, - emitFloat, emitFunction, emitNumber, - emitInt32, emitGenericObject, - emitObject, emitPromise, emitRootTag, emitVoid, emitString, - emitStringish, emitMixed, emitUnion, + emitCommonTypes, typeAliasResolution, typeEnumResolution, } = require('../../parsers-primitives'); @@ -55,11 +51,6 @@ const { UnsupportedGenericParserError, } = require('../../errors'); -const { - throwIfPartialNotAnnotatingTypeParameter, - throwIfPartialWithMoreParameter, -} = require('../../error-utils'); - function translateTypeAnnotation( hasteModuleName: string, /** @@ -132,55 +123,27 @@ function translateTypeAnnotation( return wrapNullable(nullable || isParamNullable, paramType); } - case 'Stringish': { - return emitStringish(nullable); - } - case 'Int32': { - return emitInt32(nullable); - } - case 'Double': { - return emitDouble(nullable); - } - case 'Float': { - return emitFloat(nullable); - } - case 'UnsafeObject': - case 'Object': { - return emitGenericObject(nullable); - } - case 'Partial': - case '$Partial': { - throwIfPartialWithMoreParameter(typeAnnotation); - - const annotatedElement = parser.extractAnnotatedElement( - typeAnnotation, - types, - ); - - throwIfPartialNotAnnotatingTypeParameter( - typeAnnotation, - types, - parser, - ); - - const properties = parser.computePartialProperties( - annotatedElement.right.properties, + default: { + const commonType = emitCommonTypes( hasteModuleName, types, + typeAnnotation, aliasMap, enumMap, tryParse, cxxOnly, - ); - - return emitObject(nullable, properties); - } - default: { - throw new UnsupportedGenericParserError( - hasteModuleName, - typeAnnotation, + nullable, parser, ); + + if (!commonType) { + throw new UnsupportedGenericParserError( + hasteModuleName, + typeAnnotation, + parser, + ); + } + return commonType; } } } diff --git a/packages/react-native-codegen/src/parsers/flow/parser.js b/packages/react-native-codegen/src/parsers/flow/parser.js index 46e3a882923b5f..f82a52dc18d5c9 100644 --- a/packages/react-native-codegen/src/parsers/flow/parser.js +++ b/packages/react-native-codegen/src/parsers/flow/parser.js @@ -313,6 +313,10 @@ class FlowParser implements Parser { componentName: funcArgumentParams[0].value, }; } + + getAnnotatedElementProperties(annotatedElement: $FlowFixMe): $FlowFixMe { + return annotatedElement.right.properties; + } } module.exports = { diff --git a/packages/react-native-codegen/src/parsers/parser.js b/packages/react-native-codegen/src/parsers/parser.js index 6195e640e86447..fc1777bda932c1 100644 --- a/packages/react-native-codegen/src/parsers/parser.js +++ b/packages/react-native-codegen/src/parsers/parser.js @@ -229,4 +229,11 @@ export interface Parser { typeArgumentParams: $FlowFixMe, funcArgumentParams: $FlowFixMe, ): {[string]: string}; + + /** + * Given a annotatedElement, it returns the properties of annotated element. + * @parameter annotatedElement: the annotated element. + * @returns: the properties of annotated element. + */ + getAnnotatedElementProperties(annotatedElement: $FlowFixMe): $FlowFixMe; } diff --git a/packages/react-native-codegen/src/parsers/parserMock.js b/packages/react-native-codegen/src/parsers/parserMock.js index 9e85fae12526ab..81c88c7e6cbcd3 100644 --- a/packages/react-native-codegen/src/parsers/parserMock.js +++ b/packages/react-native-codegen/src/parsers/parserMock.js @@ -227,4 +227,8 @@ export class MockedParser implements Parser { componentName: funcArgumentParams[0].value, }; } + + getAnnotatedElementProperties(annotatedElement: $FlowFixMe): $FlowFixMe { + return annotatedElement.right.properties; + } } diff --git a/packages/react-native-codegen/src/parsers/parsers-commons.js b/packages/react-native-codegen/src/parsers/parsers-commons.js index e0348838eb6f10..1a8d3025503ea5 100644 --- a/packages/react-native-codegen/src/parsers/parsers-commons.js +++ b/packages/react-native-codegen/src/parsers/parsers-commons.js @@ -22,6 +22,7 @@ import type { NativeModulePropertyShape, SchemaType, NativeModuleEnumMap, + OptionsShape, } from '../CodegenSchema.js'; import type {Parser} from './parser'; @@ -61,6 +62,13 @@ const { const invariant = require('invariant'); +export type CommandOptions = $ReadOnly<{ + supportedCommands: $ReadOnlyArray, +}>; + +// $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser +type OptionsAST = Object; + function wrapModuleSchema( nativeModuleSchema: NativeModuleSchema, hasteModuleName: string, @@ -699,6 +707,68 @@ function findNativeComponentType( } } +function getCommandOptions( + commandOptionsExpression: OptionsAST, +): ?CommandOptions { + if (commandOptionsExpression == null) { + return null; + } + + let foundOptions; + try { + foundOptions = commandOptionsExpression.properties.reduce( + (options, prop) => { + options[prop.key.name] = ( + (prop && prop.value && prop.value.elements) || + [] + ).map(element => element && element.value); + return options; + }, + {}, + ); + } catch (e) { + throw new Error( + 'Failed to parse command options, please check that they are defined correctly', + ); + } + + return foundOptions; +} + +function getOptions(optionsExpression: OptionsAST): ?OptionsShape { + if (!optionsExpression) { + return null; + } + let foundOptions; + try { + foundOptions = optionsExpression.properties.reduce((options, prop) => { + if (prop.value.type === 'ArrayExpression') { + options[prop.key.name] = prop.value.elements.map( + element => element.value, + ); + } else { + options[prop.key.name] = prop.value.value; + } + return options; + }, {}); + } catch (e) { + throw new Error( + 'Failed to parse codegen options, please check that they are defined correctly', + ); + } + + if ( + foundOptions.paperComponentName && + foundOptions.paperComponentNameDeprecated + ) { + throw new Error( + 'Failed to parse codegen options, cannot use both paperComponentName and paperComponentNameDeprecated', + ); + } + + return foundOptions; +} + module.exports = { wrapModuleSchema, unwrapNullable, @@ -714,4 +784,6 @@ module.exports = { parseModuleName, buildModuleSchema, findNativeComponentType, + getCommandOptions, + getOptions, }; diff --git a/packages/react-native-codegen/src/parsers/parsers-primitives.js b/packages/react-native-codegen/src/parsers/parsers-primitives.js index 13fcb2ce198fdc..ef2a3b605cd314 100644 --- a/packages/react-native-codegen/src/parsers/parsers-primitives.js +++ b/packages/react-native-codegen/src/parsers/parsers-primitives.js @@ -49,6 +49,8 @@ const { const { throwIfArrayElementTypeAnnotationIsUnsupported, + throwIfPartialNotAnnotatingTypeParameter, + throwIfPartialWithMoreParameter, } = require('./error-utils'); const {nullGuard} = require('./parsers-utils'); const { @@ -473,6 +475,92 @@ function Visitor(infoMap: {isComponent: boolean, isModule: boolean}): { }; } +function emitPartial( + hasteModuleName: string, + typeAnnotation: $FlowFixMe, + types: TypeDeclarationMap, + aliasMap: {...NativeModuleAliasMap}, + enumMap: {...NativeModuleEnumMap}, + tryParse: ParserErrorCapturer, + cxxOnly: boolean, + nullable: boolean, + parser: Parser, +): Nullable { + throwIfPartialWithMoreParameter(typeAnnotation); + + throwIfPartialNotAnnotatingTypeParameter(typeAnnotation, types, parser); + + const annotatedElement = parser.extractAnnotatedElement( + typeAnnotation, + types, + ); + const annotatedElementProperties = + parser.getAnnotatedElementProperties(annotatedElement); + + const partialProperties = parser.computePartialProperties( + annotatedElementProperties, + hasteModuleName, + types, + aliasMap, + enumMap, + tryParse, + cxxOnly, + ); + + return emitObject(nullable, partialProperties); +} + +function emitCommonTypes( + hasteModuleName: string, + types: TypeDeclarationMap, + typeAnnotation: $FlowFixMe, + aliasMap: {...NativeModuleAliasMap}, + enumMap: {...NativeModuleEnumMap}, + tryParse: ParserErrorCapturer, + cxxOnly: boolean, + nullable: boolean, + parser: Parser, +): $FlowFixMe { + const genericTypeAnnotationName = + parser.nameForGenericTypeAnnotation(typeAnnotation); + + switch (genericTypeAnnotationName) { + case 'Stringish': { + return emitStringish(nullable); + } + case 'Int32': { + return emitInt32(nullable); + } + case 'Double': { + return emitDouble(nullable); + } + case 'Float': { + return emitFloat(nullable); + } + case 'UnsafeObject': + case 'Object': { + return emitGenericObject(nullable); + } + case '$Partial': + case 'Partial': { + return emitPartial( + hasteModuleName, + typeAnnotation, + types, + aliasMap, + enumMap, + tryParse, + cxxOnly, + nullable, + parser, + ); + } + default: { + return null; + } + } +} + module.exports = { emitArrayType, emitBoolean, @@ -490,6 +578,8 @@ module.exports = { emitStringish, emitMixed, emitUnion, + emitPartial, + emitCommonTypes, typeAliasResolution, typeEnumResolution, translateArrayTypeAnnotation, diff --git a/packages/react-native-codegen/src/parsers/typescript/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/parsers/typescript/components/__test_fixtures__/fixtures.js index 8473fb54d3e21a..57aafa7b5562d4 100644 --- a/packages/react-native-codegen/src/parsers/typescript/components/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/parsers/typescript/components/__test_fixtures__/fixtures.js @@ -197,7 +197,7 @@ const ALL_PROP_TYPES_NO_EVENTS = ` const codegenNativeComponent = require('codegenNativeComponent'); -import type {Int32, Double, Float, WithDefault} from 'CodegenTypes'; +import type {Int32, Double, Float, WithDefault, UnsafeMixed} from 'CodegenTypes'; import type {ImageSource} from 'ImageSource'; import type { ColorValue, @@ -310,6 +310,10 @@ export interface ModuleProps extends ViewProps { dimension_optional_key?: DimensionValue; dimension_optional_value: DimensionValue | null | undefined; dimension_optional_both?: DimensionValue | null | undefined; + + // Mixed props + mixed_required: UnsafeMixed, + mixed_optional_key?: UnsafeMixed, } export default codegenNativeComponent( diff --git a/packages/react-native-codegen/src/parsers/typescript/components/__tests__/__snapshots__/typescript-component-parser-test.js.snap b/packages/react-native-codegen/src/parsers/typescript/components/__tests__/__snapshots__/typescript-component-parser-test.js.snap index d2f557d64cb407..4211709793e576 100644 --- a/packages/react-native-codegen/src/parsers/typescript/components/__tests__/__snapshots__/typescript-component-parser-test.js.snap +++ b/packages/react-native-codegen/src/parsers/typescript/components/__tests__/__snapshots__/typescript-component-parser-test.js.snap @@ -569,6 +569,20 @@ exports[`RN Codegen TypeScript Parser can generate fixture ALL_PROP_TYPES_NO_EVE 'type': 'ReservedPropTypeAnnotation', 'name': 'DimensionPrimitive' } + }, + { + 'name': 'mixed_required', + 'optional': false, + 'typeAnnotation': { + 'type': 'MixedTypeAnnotation' + } + }, + { + 'name': 'mixed_optional_key', + 'optional': true, + 'typeAnnotation': { + 'type': 'MixedTypeAnnotation' + } } ], 'commands': [] diff --git a/packages/react-native-codegen/src/parsers/typescript/components/componentsUtils.js b/packages/react-native-codegen/src/parsers/typescript/components/componentsUtils.js index e45bc52c53d458..8adc7e586dfcd1 100644 --- a/packages/react-native-codegen/src/parsers/typescript/components/componentsUtils.js +++ b/packages/react-native-codegen/src/parsers/typescript/components/componentsUtils.js @@ -262,6 +262,10 @@ function getCommonTypeAnnotation( return { type: 'StringTypeAnnotation', }; + case 'UnsafeMixed': + return { + type: 'MixedTypeAnnotation', + }; default: return undefined; } diff --git a/packages/react-native-codegen/src/parsers/typescript/components/index.js b/packages/react-native-codegen/src/parsers/typescript/components/index.js index f1ce04d0f338f8..4c41d7f1fdedbe 100644 --- a/packages/react-native-codegen/src/parsers/typescript/components/index.js +++ b/packages/react-native-codegen/src/parsers/typescript/components/index.js @@ -12,19 +12,20 @@ import type {ExtendsPropsShape} from '../../../CodegenSchema.js'; import type {Parser} from '../../parser'; import type {TypeDeclarationMap} from '../../utils'; -import type {CommandOptions} from './options'; +import type {CommandOptions} from '../../parsers-commons'; import type {ComponentSchemaBuilderConfig} from '../../schema.js'; const {getCommands} = require('./commands'); const {getEvents} = require('./events'); const {categorizeProps} = require('./extends'); -const {getCommandOptions, getOptions} = require('./options'); const {getProps} = require('./props'); const {getProperties} = require('./componentsUtils.js'); const {throwIfMoreThanOneCodegenNativecommands} = require('../../error-utils'); const { createComponentConfig, findNativeComponentType, + getCommandOptions, + getOptions, } = require('../../parsers-commons'); // $FlowFixMe[signature-verification-failure] TODO(T108222691): Use flow-types for @babel/parser diff --git a/packages/react-native-codegen/src/parsers/typescript/components/options.js b/packages/react-native-codegen/src/parsers/typescript/components/options.js deleted file mode 100644 index 96ea8abc75b1d5..00000000000000 --- a/packages/react-native-codegen/src/parsers/typescript/components/options.js +++ /dev/null @@ -1,87 +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. - * - * @flow strict - * @format - */ - -'use strict'; - -import type {OptionsShape} from '../../../CodegenSchema.js'; - -// $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser -type OptionsAST = Object; - -export type CommandOptions = $ReadOnly<{ - supportedCommands: $ReadOnlyArray, -}>; - -function getCommandOptions( - commandOptionsExpression: OptionsAST, -): ?CommandOptions { - if (commandOptionsExpression == null) { - return null; - } - - let foundOptions; - try { - foundOptions = commandOptionsExpression.properties.reduce( - (options, prop) => { - options[prop.key.name] = ( - (prop && prop.value && prop.value.elements) || - [] - ).map(element => element && element.value); - return options; - }, - {}, - ); - } catch (e) { - throw new Error( - 'Failed to parse command options, please check that they are defined correctly', - ); - } - - return foundOptions; -} - -function getOptions(optionsExpression: OptionsAST): ?OptionsShape { - if (!optionsExpression) { - return null; - } - let foundOptions; - try { - foundOptions = optionsExpression.properties.reduce((options, prop) => { - if (prop.value.type === 'ArrayExpression') { - options[prop.key.name] = prop.value.elements.map( - element => element.value, - ); - } else { - options[prop.key.name] = prop.value.value; - } - return options; - }, {}); - } catch (e) { - throw new Error( - 'Failed to parse codegen options, please check that they are defined correctly', - ); - } - - if ( - foundOptions.paperComponentName && - foundOptions.paperComponentNameDeprecated - ) { - throw new Error( - 'Failed to parse codegen options, cannot use both paperComponentName and paperComponentNameDeprecated', - ); - } - - return foundOptions; -} - -module.exports = { - getCommandOptions, - getOptions, -}; diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/index.js b/packages/react-native-codegen/src/parsers/typescript/modules/index.js index 056e5dfd496c47..130cfea9419a15 100644 --- a/packages/react-native-codegen/src/parsers/typescript/modules/index.js +++ b/packages/react-native-codegen/src/parsers/typescript/modules/index.js @@ -31,26 +31,22 @@ const {flattenProperties} = require('../components/componentsUtils'); const {resolveTypeAnnotation} = require('../utils'); const {parseObjectProperty} = require('../../parsers-commons'); -const {typeEnumResolution} = require('../../parsers-primitives'); const { emitArrayType, emitBoolean, - emitDouble, - emitFloat, emitFunction, emitNumber, - emitInt32, emitGenericObject, - emitObject, emitPromise, emitRootTag, emitVoid, emitString, - emitStringish, emitMixed, emitUnion, + emitCommonTypes, typeAliasResolution, + typeEnumResolution, translateArrayTypeAnnotation, } = require('../../parsers-primitives'); @@ -59,11 +55,6 @@ const { UnsupportedTypeAnnotationParserError, } = require('../../errors'); -const { - throwIfPartialNotAnnotatingTypeParameter, - throwIfPartialWithMoreParameter, -} = require('../../error-utils'); - function translateObjectTypeAnnotation( hasteModuleName: string, /** @@ -166,50 +157,27 @@ function translateTypeReferenceAnnotation( translateTypeAnnotation, ); } - case 'Stringish': { - return emitStringish(nullable); - } - case 'Int32': { - return emitInt32(nullable); - } - case 'Double': { - return emitDouble(nullable); - } - case 'Float': { - return emitFloat(nullable); - } - case 'UnsafeObject': - case 'Object': { - return emitGenericObject(nullable); - } - case 'Partial': { - throwIfPartialWithMoreParameter(typeAnnotation); - - const annotatedElement = parser.extractAnnotatedElement( - typeAnnotation, - types, - ); - - throwIfPartialNotAnnotatingTypeParameter(typeAnnotation, types, parser); - - const properties = parser.computePartialProperties( - annotatedElement.typeAnnotation.members, + default: { + const commonType = emitCommonTypes( hasteModuleName, types, + typeAnnotation, aliasMap, enumMap, tryParse, cxxOnly, - ); - - return emitObject(nullable, properties); - } - default: { - throw new UnsupportedGenericParserError( - hasteModuleName, - typeAnnotation, + nullable, parser, ); + + if (!commonType) { + throw new UnsupportedGenericParserError( + hasteModuleName, + typeAnnotation, + parser, + ); + } + return commonType; } } } diff --git a/packages/react-native-codegen/src/parsers/typescript/parser.js b/packages/react-native-codegen/src/parsers/typescript/parser.js index 464f2ef5fe8b5d..e5dd58f80a4571 100644 --- a/packages/react-native-codegen/src/parsers/typescript/parser.js +++ b/packages/react-native-codegen/src/parsers/typescript/parser.js @@ -299,6 +299,10 @@ class TypeScriptParser implements Parser { componentName: funcArgumentParams[0].value, }; } + + getAnnotatedElementProperties(annotatedElement: $FlowFixMe): $FlowFixMe { + return annotatedElement.typeAnnotation.members; + } } module.exports = { diff --git a/packages/react-native/Libraries/Animated/NativeAnimatedHelper.js b/packages/react-native/Libraries/Animated/NativeAnimatedHelper.js index 0bbc7c760faf7c..9193eddd17f37d 100644 --- a/packages/react-native/Libraries/Animated/NativeAnimatedHelper.js +++ b/packages/react-native/Libraries/Animated/NativeAnimatedHelper.js @@ -588,8 +588,8 @@ export default { assertNativeAnimatedModule, shouldUseNativeDriver, transformDataType, - // $FlowExpectedError[unsafe-getters-setters] - unsafe getter lint suppresion - // $FlowExpectedError[missing-type-arg] - unsafe getter lint suppresion + // $FlowExpectedError[unsafe-getters-setters] - unsafe getter lint suppression + // $FlowExpectedError[missing-type-arg] - unsafe getter lint suppression get nativeEventEmitter(): NativeEventEmitter { if (!nativeEventEmitter) { // $FlowFixMe[underconstrained-implicit-instantiation] diff --git a/packages/react-native/Libraries/Animated/__tests__/AnimatedNative-test.js b/packages/react-native/Libraries/Animated/__tests__/AnimatedNative-test.js index d62b6e95ca9ec8..23e6a2123ddf8d 100644 --- a/packages/react-native/Libraries/Animated/__tests__/AnimatedNative-test.js +++ b/packages/react-native/Libraries/Animated/__tests__/AnimatedNative-test.js @@ -270,7 +270,7 @@ describe('Native Animated', () => { ); }); - it('shoud map AnimatedValueXY', () => { + it('should map AnimatedValueXY', () => { const value = new Animated.ValueXY({x: 0, y: 0}); value.__makeNative(); const event = Animated.event([{nativeEvent: {state: value}}], { diff --git a/packages/react-native/Libraries/Animated/useAnimatedProps.js b/packages/react-native/Libraries/Animated/useAnimatedProps.js index 31c2ccbb5c72e0..ac64cc88a39066 100644 --- a/packages/react-native/Libraries/Animated/useAnimatedProps.js +++ b/packages/react-native/Libraries/Animated/useAnimatedProps.js @@ -53,7 +53,7 @@ export default function useAnimatedProps( // 2) Update `onUpdateRef`. // 3) Update listeners for `AnimatedEvent` props. // - // Ideally, each of these would be separat "effects" so that they are not + // Ideally, each of these would be separate "effects" so that they are not // unnecessarily re-run when irrelevant dependencies change. For example, we // should be able to hoist all `AnimatedEvent` props and only do #3 if either // the `AnimatedEvent` props change or `instance` changes. diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h index 7a9dd6408ef1e2..7163c38b478db4 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h @@ -24,7 +24,7 @@ * @end * ``` * - * All the methods implemented by the RCTAppDelegate can be overriden by your AppDelegate if you need to provide a + * All the methods implemented by the RCTAppDelegate can be overridden by your AppDelegate if you need to provide a custom implementation. * If you need to customize the default implementation, you can invoke `[super ]` and use the returned object. diff --git a/packages/react-native/Libraries/BatchedBridge/NativeModules.d.ts b/packages/react-native/Libraries/BatchedBridge/NativeModules.d.ts index ba35cca1e1bcb3..384b198bf48e54 100644 --- a/packages/react-native/Libraries/BatchedBridge/NativeModules.d.ts +++ b/packages/react-native/Libraries/BatchedBridge/NativeModules.d.ts @@ -8,7 +8,7 @@ */ /** - * Interface for NativeModules which allows to augment NativeModules with type informations. + * Interface for NativeModules which allows to augment NativeModules with type information. * See react-native-sensor-manager for example. */ interface NativeModulesStatic { diff --git a/packages/react-native/Libraries/Components/Pressable/Pressable.js b/packages/react-native/Libraries/Components/Pressable/Pressable.js index 601758f999449f..2b4249252ba942 100644 --- a/packages/react-native/Libraries/Components/Pressable/Pressable.js +++ b/packages/react-native/Libraries/Components/Pressable/Pressable.js @@ -312,7 +312,7 @@ type Props = $ReadOnly<{| */ unstable_pressDelay?: ?number, /** - * Web to Native Accessibilty props + * Web to Native Accessibility props * https://github.com/facebook/react-native/issues/34424 */ 'aria-label'?: ?string, diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts b/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts index e102f97ac03bf3..82c62bf8ccc10e 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts @@ -272,6 +272,16 @@ export interface TextInputIOSProps { * If false, scrolling of the text view will be disabled. The default value is true. Only works with multiline={true} */ scrollEnabled?: boolean | undefined; + + /** + * Set line break strategy on iOS. + */ + lineBreakStrategyIOS?: + | 'none' + | 'standard' + | 'hangul-word' + | 'push-out' + | undefined; } // [macOS diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js b/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js index 7b091a6a5885c3..5485c08bdbc2b6 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js @@ -685,7 +685,7 @@ export type Props = $ReadOnly<{| * On Android devices manufactured by Xiaomi with Android Q, * when keyboardType equals 'email-address'this will be set * in native to 'true' to prevent a system related crash. This - * will cause cursor to be diabled as a side-effect. + * will cause cursor to be disabled as a side-effect. * */ caretHidden?: ?boolean, diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.js b/packages/react-native/Libraries/Components/TextInput/TextInput.js index d7c4333223548a..1e6a3f6cc376c8 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.js @@ -740,7 +740,7 @@ export type Props = $ReadOnly<{| * On Android devices manufactured by Xiaomi with Android Q, * when keyboardType equals 'email-address'this will be set * in native to 'true' to prevent a system related crash. This - * will cause cursor to be diabled as a side-effect. + * will cause cursor to be disabled as a side-effect. * */ caretHidden?: ?boolean, diff --git a/packages/react-native/Libraries/Components/Touchable/Touchable.d.ts b/packages/react-native/Libraries/Components/Touchable/Touchable.d.ts index 6915dd27927d62..3c0065c9e02bbb 100644 --- a/packages/react-native/Libraries/Components/Touchable/Touchable.d.ts +++ b/packages/react-native/Libraries/Components/Touchable/Touchable.d.ts @@ -13,7 +13,7 @@ import {GestureResponderEvent} from '../../Types/CoreEventTypes'; /** * //FIXME: need to find documentation on which component is a TTouchable and can implement that interface - * @see React.DOMAtributes + * @see React.DOMAttributes */ export interface Touchable { onTouchStart?: ((event: GestureResponderEvent) => void) | undefined; diff --git a/packages/react-native/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js b/packages/react-native/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js index cee4d0efdb98bd..5444d52695cb37 100644 --- a/packages/react-native/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js +++ b/packages/react-native/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js @@ -64,7 +64,7 @@ let devToolsAgent: ?Agent; export default function TraceUpdateOverlay(): React.Node { const [overlayDisabled, setOverlayDisabled] = useState(false); - // This effect is designed to be explictly shown here to avoid re-subscribe from the same + // This effect is designed to be explicitly shown here to avoid re-subscribe from the same // overlay component. useEffect(() => { if (!isNativeComponentReady) { diff --git a/packages/react-native/Libraries/Components/View/ViewAccessibility.d.ts b/packages/react-native/Libraries/Components/View/ViewAccessibility.d.ts index 86f08bf88fa438..acb833ef7fbe5e 100644 --- a/packages/react-native/Libraries/Components/View/ViewAccessibility.d.ts +++ b/packages/react-native/Libraries/Components/View/ViewAccessibility.d.ts @@ -274,7 +274,7 @@ export interface AccessibilityPropsIOS { accessibilityViewIsModal?: boolean | undefined; /** - * When accessibile is true, the system will invoke this function when the user performs the escape gesture (scrub with two fingers). + * When accessible is true, the system will invoke this function when the user performs the escape gesture (scrub with two fingers). * @platform ios */ onAccessibilityEscape?: (() => void) | undefined; diff --git a/packages/react-native/Libraries/Core/Timers/queueMicrotask.js b/packages/react-native/Libraries/Core/Timers/queueMicrotask.js index 7c33d9f30036b9..5cb8529decd43b 100644 --- a/packages/react-native/Libraries/Core/Timers/queueMicrotask.js +++ b/packages/react-native/Libraries/Core/Timers/queueMicrotask.js @@ -13,7 +13,7 @@ let resolvedPromise; /** - * Polyfill for the microtask queuening API defined by WHATWG HTMP spec. + * Polyfill for the microtask queueing API defined by WHATWG HTML spec. * https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask * * The method must queue a microtask to invoke @param {function} callback, and diff --git a/packages/react-native/Libraries/Core/setUpTimers.js b/packages/react-native/Libraries/Core/setUpTimers.js index b2b036fdc9d069..86d73869f5ef9c 100644 --- a/packages/react-native/Libraries/Core/setUpTimers.js +++ b/packages/react-native/Libraries/Core/setUpTimers.js @@ -61,7 +61,7 @@ if (global.RN$Bridgeless !== true) { * as the Promise. */ if (hasPromiseQueuedToJSVM) { - // When promise queues to the JSVM microtasks queue, we shim the immedaite + // When promise queues to the JSVM microtasks queue, we shim the immediate // APIs via `queueMicrotask` to maintain the backward compatibility. polyfillGlobal( 'setImmediate', @@ -95,7 +95,7 @@ if (hasHermesPromiseQueuedToJSVM) { // Fast path for Hermes. polyfillGlobal('queueMicrotask', () => global.HermesInternal?.enqueueJob); } else { - // Polyfill it with promise (regardless it's polyfiled or native) otherwise. + // Polyfill it with promise (regardless it's polyfilled or native) otherwise. polyfillGlobal( 'queueMicrotask', () => require('./Timers/queueMicrotask.js').default, diff --git a/packages/react-native/Libraries/DOM/Nodes/ReactNativeElement.js b/packages/react-native/Libraries/DOM/Nodes/ReactNativeElement.js new file mode 100644 index 00000000000000..1f9e9b77b0a3b5 --- /dev/null +++ b/packages/react-native/Libraries/DOM/Nodes/ReactNativeElement.js @@ -0,0 +1,75 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict + */ + +// flowlint unsafe-getters-setters:off + +import type { + HostComponent, + MeasureInWindowOnSuccessCallback, + MeasureLayoutOnSuccessCallback, + MeasureOnSuccessCallback, +} from '../../Renderer/shims/ReactNativeTypes'; +import type {ElementRef} from 'react'; + +import ReadOnlyElement from './ReadOnlyElement'; + +export default class ReactNativeElement extends ReadOnlyElement { + get offsetHeight(): number { + throw new TypeError('Unimplemented'); + } + + get offsetLeft(): number { + throw new TypeError('Unimplemented'); + } + + get offsetParent(): ReadOnlyElement | null { + throw new TypeError('Unimplemented'); + } + + get offsetTop(): number { + throw new TypeError('Unimplemented'); + } + + get offsetWidth(): number { + throw new TypeError('Unimplemented'); + } + + /** + * React Native compatibility methods + */ + + blur(): void { + throw new TypeError('Unimplemented'); + } + + focus(): void { + throw new TypeError('Unimplemented'); + } + + measure(callback: MeasureOnSuccessCallback): void { + throw new TypeError('Unimplemented'); + } + + measureInWindow(callback: MeasureInWindowOnSuccessCallback): void { + throw new TypeError('Unimplemented'); + } + + measureLayout( + relativeToNativeNode: number | ElementRef>, + onSuccess: MeasureLayoutOnSuccessCallback, + onFail?: () => void /* currently unused */, + ): void { + throw new TypeError('Unimplemented'); + } + + setNativeProps(nativeProps: {...}): void { + throw new TypeError('Unimplemented'); + } +} diff --git a/packages/react-native/Libraries/DOM/Nodes/ReadOnlyElement.js b/packages/react-native/Libraries/DOM/Nodes/ReadOnlyElement.js new file mode 100644 index 00000000000000..1307ba57c8b01c --- /dev/null +++ b/packages/react-native/Libraries/DOM/Nodes/ReadOnlyElement.js @@ -0,0 +1,89 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict + */ + +// flowlint unsafe-getters-setters:off + +import type HTMLCollection from '../OldStyleCollections/HTMLCollection'; + +import ReadOnlyNode from './ReadOnlyNode'; + +export default class ReadOnlyElement extends ReadOnlyNode { + get childElementCount(): number { + throw new TypeError('Unimplemented'); + } + + get children(): HTMLCollection { + throw new TypeError('Unimplemented'); + } + + get clientHeight(): number { + throw new TypeError('Unimplemented'); + } + + get clientLeft(): number { + throw new TypeError('Unimplemented'); + } + + get clientTop(): number { + throw new TypeError('Unimplemented'); + } + + get clientWidth(): number { + throw new TypeError('Unimplemented'); + } + + get firstElementChild(): ReadOnlyElement | null { + throw new TypeError('Unimplemented'); + } + + get id(): string { + throw new TypeError('Unimplemented'); + } + + get lastElementChild(): ReadOnlyElement | null { + throw new TypeError('Unimplemented'); + } + + get nextElementSibling(): ReadOnlyElement | null { + throw new TypeError('Unimplemented'); + } + + get previousElementSibling(): ReadOnlyElement | null { + throw new TypeError('Unimplemented'); + } + + get scrollHeight(): number { + throw new TypeError('Unimplemented'); + } + + get scrollLeft(): number { + throw new TypeError('Unimplemented'); + } + + get scrollTop(): number { + throw new TypeError('Unimplemented'); + } + + get scrollWidth(): number { + throw new TypeError('Unimplemented'); + } + + get tagName(): string { + throw new TypeError('Unimplemented'); + } + + getBoundingClientRect(): DOMRect { + throw new TypeError('Unimplemented'); + } + + getClientRects(): DOMRectList { + throw new TypeError('Unimplemented'); + } +} diff --git a/packages/react-native/Libraries/DOM/Nodes/ReadOnlyNode.js b/packages/react-native/Libraries/DOM/Nodes/ReadOnlyNode.js new file mode 100644 index 00000000000000..d6cc6b878f4eaf --- /dev/null +++ b/packages/react-native/Libraries/DOM/Nodes/ReadOnlyNode.js @@ -0,0 +1,167 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict + */ + +// flowlint unsafe-getters-setters:off + +import type NodeList from '../OldStyleCollections/NodeList'; +import type ReadOnlyElement from './ReadOnlyElement'; + +export default class ReadOnlyNode { + get childNodes(): NodeList { + throw new TypeError('Unimplemented'); + } + + get firstChild(): ReadOnlyNode | null { + throw new TypeError('Unimplemented'); + } + + get isConnected(): boolean { + throw new TypeError('Unimplemented'); + } + + get lastChild(): ReadOnlyNode | null { + throw new TypeError('Unimplemented'); + } + + get nextSibling(): ReadOnlyNode | null { + throw new TypeError('Unimplemented'); + } + + get nodeName(): string { + throw new TypeError('Unimplemented'); + } + + get nodeType(): number { + throw new TypeError('Unimplemented'); + } + + get nodeValue(): string | null { + throw new TypeError('Unimplemented'); + } + + get parentElement(): ReadOnlyElement | null { + throw new TypeError('Unimplemented'); + } + + get parentNode(): ReadOnlyNode | null { + throw new TypeError('Unimplemented'); + } + + get previousSibling(): ReadOnlyNode | null { + throw new TypeError('Unimplemented'); + } + + get textContent(): string | null { + throw new TypeError('Unimplemented'); + } + + compareDocumentPosition(otherNode: ReadOnlyNode): number { + throw new TypeError('Unimplemented'); + } + + contains(otherNode: ReadOnlyNode): boolean { + throw new TypeError('Unimplemented'); + } + + getRootNode(): ReadOnlyNode { + throw new TypeError('Unimplemented'); + } + + hasChildNodes(): boolean { + throw new TypeError('Unimplemented'); + } + + /* + * Node types, as returned by the `nodeType` property. + */ + + /** + * Type of Element, HTMLElement and ReactNativeElement instances. + */ + static ELEMENT_NODE: number = 1; + /** + * Currently Unused in React Native. + */ + static ATTRIBUTE_NODE: number = 2; + /** + * Text nodes. + */ + static TEXT_NODE: number = 3; + /** + * @deprecated Unused in React Native. + */ + static CDATA_SECTION_NODE: number = 4; + /** + * @deprecated + */ + static ENTITY_REFERENCE_NODE: number = 5; + /** + * @deprecated + */ + static ENTITY_NODE: number = 6; + /** + * @deprecated Unused in React Native. + */ + static PROCESSING_INSTRUCTION_NODE: number = 7; + /** + * @deprecated Unused in React Native. + */ + static COMMENT_NODE: number = 8; + /** + * @deprecated Unused in React Native. + */ + static DOCUMENT_NODE: number = 9; + /** + * @deprecated Unused in React Native. + */ + static DOCUMENT_TYPE_NODE: number = 10; + /** + * @deprecated Unused in React Native. + */ + static DOCUMENT_FRAGMENT_NODE: number = 11; + /** + * @deprecated + */ + static NOTATION_NODE: number = 12; + + /* + * Document position flags. Used to check the return value of + * `compareDocumentPosition()`. + */ + + /** + * Both nodes are in different documents. + */ + static DOCUMENT_POSITION_DISCONNECTED: number = 1; + /** + * `otherNode` precedes the node in either a pre-order depth-first traversal of a tree containing both + * (e.g., as an ancestor or previous sibling or a descendant of a previous sibling or previous sibling of an ancestor) + * or (if they are disconnected) in an arbitrary but consistent ordering. + */ + static DOCUMENT_POSITION_PRECEDING: number = 2; + /** + * `otherNode` follows the node in either a pre-order depth-first traversal of a tree containing both + * (e.g., as a descendant or following sibling or a descendant of a following sibling or following sibling of an ancestor) + * or (if they are disconnected) in an arbitrary but consistent ordering. + */ + static DOCUMENT_POSITION_FOLLOWING: number = 4; + /** + * `otherNode` is an ancestor of the node. + */ + static DOCUMENT_POSITION_CONTAINS: number = 8; + /** + * `otherNode` is a descendant of the node. + */ + static DOCUMENT_POSITION_CONTAINED_BY: number = 16; + /** + * @deprecated Unused in React Native. + */ + static DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number = 32; +} diff --git a/packages/react-native/Libraries/DOM/OldStyleCollections/ArrayLikeUtils.js b/packages/react-native/Libraries/DOM/OldStyleCollections/ArrayLikeUtils.js new file mode 100644 index 00000000000000..d906b080df0a06 --- /dev/null +++ b/packages/react-native/Libraries/DOM/OldStyleCollections/ArrayLikeUtils.js @@ -0,0 +1,46 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict + */ + +/** + * This definition is different from the current built-in type `$ArrayLike` + * provided by Flow, in that this is an interface and that one is an object. + * + * The difference is important because, when using objects, Flow thinks + * a `length` property would be copied over when using the spread operator, + * which is incorrect. + */ +export interface ArrayLike extends Iterable { + // This property should've been read-only as well, but Flow doesn't handle + // read-only indexers correctly (thinks reads are writes and fails). + [indexer: number]: T; + +length: number; +} + +export function* createValueIterator(arrayLike: ArrayLike): Iterator { + for (let i = 0; i < arrayLike.length; i++) { + yield arrayLike[i]; + } +} + +export function* createKeyIterator( + arrayLike: ArrayLike, +): Iterator { + for (let i = 0; i < arrayLike.length; i++) { + yield i; + } +} + +export function* createEntriesIterator( + arrayLike: ArrayLike, +): Iterator<[number, T]> { + for (let i = 0; i < arrayLike.length; i++) { + yield [i, arrayLike[i]]; + } +} diff --git a/packages/react-native/Libraries/DOM/OldStyleCollections/DOMRectList.js b/packages/react-native/Libraries/DOM/OldStyleCollections/DOMRectList.js new file mode 100644 index 00000000000000..9365a9a5a29f7b --- /dev/null +++ b/packages/react-native/Libraries/DOM/OldStyleCollections/DOMRectList.js @@ -0,0 +1,76 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict + */ + +// flowlint unsafe-getters-setters:off + +import type DOMRectReadOnly from '../Geometry/DOMRectReadOnly'; +import type {ArrayLike} from './ArrayLikeUtils'; + +import {createValueIterator} from './ArrayLikeUtils'; + +// IMPORTANT: The Flow type definition for this module is defined in `DOMRectList.js.flow` +// because Flow only supports indexers in classes in declaration files. + +// $FlowIssue[prop-missing] Flow doesn't understand [Symbol.iterator]() {} and thinks this class doesn't implement the Iterable interface. +export default class DOMRectList implements Iterable { + _length: number; + + /** + * Use `createDOMRectList` to create instances of this class. + * + * @private This is not defined in the declaration file, so users will not see + * the signature of the constructor. + */ + constructor(elements: $ReadOnlyArray) { + for (let i = 0; i < elements.length; i++) { + Object.defineProperty(this, i, { + value: elements[i], + enumerable: true, + configurable: false, + writable: false, + }); + } + + this._length = elements.length; + } + + get length(): number { + return this._length; + } + + item(index: number): DOMRectReadOnly | null { + if (index < 0 || index >= this._length) { + return null; + } + + // assigning to the interface allows us to access the indexer property in a + // type-safe way. + // eslint-disable-next-line consistent-this + const arrayLike: ArrayLike = this; + return arrayLike[index]; + } + + // $FlowIssue[unsupported-syntax] Flow does not support computed properties in classes. + [Symbol.iterator](): Iterator { + return createValueIterator(this); + } +} + +/** + * This is an internal method to create instances of `DOMRectList`, + * which avoids leaking its constructor to end users. + * We can do that because the external definition of `DOMRectList` lives in + * `DOMRectList.js.flow`, not here. + */ +export function createDOMRectList( + elements: $ReadOnlyArray, +): DOMRectList { + return new DOMRectList(elements); +} diff --git a/packages/react-native/Libraries/DOM/OldStyleCollections/DOMRectList.js.flow b/packages/react-native/Libraries/DOM/OldStyleCollections/DOMRectList.js.flow new file mode 100644 index 00000000000000..cb2cc2620ae515 --- /dev/null +++ b/packages/react-native/Libraries/DOM/OldStyleCollections/DOMRectList.js.flow @@ -0,0 +1,27 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict + */ + +import type {ArrayLike} from './ArrayLikeUtils'; +import type DOMRectReadOnly from '../Geometry/DOMRectReadOnly'; + +declare export default class DOMRectList + implements Iterable, ArrayLike +{ + // This property should've been read-only as well, but Flow doesn't handle + // read-only indexers correctly (thinks reads are writes and fails). + [index: number]: DOMRectReadOnly; + +length: number; + item(index: number): DOMRectReadOnly | null; + @@iterator(): Iterator; +} + +declare export function createDOMRectList( + domRects: $ReadOnlyArray, +): DOMRectList; diff --git a/packages/react-native/Libraries/DOM/OldStyleCollections/HTMLCollection.js b/packages/react-native/Libraries/DOM/OldStyleCollections/HTMLCollection.js new file mode 100644 index 00000000000000..18cbd0af9e52b9 --- /dev/null +++ b/packages/react-native/Libraries/DOM/OldStyleCollections/HTMLCollection.js @@ -0,0 +1,82 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict + */ + +// flowlint unsafe-getters-setters:off + +import type {ArrayLike} from './ArrayLikeUtils'; + +import {createValueIterator} from './ArrayLikeUtils'; + +// IMPORTANT: The type definition for this module is defined in `HTMLCollection.js.flow` +// because Flow only supports indexers in classes in declaration files. + +// $FlowIssue[prop-missing] Flow doesn't understand [Symbol.iterator]() {} and thinks this class doesn't implement the Iterable interface. +export default class HTMLCollection implements Iterable, ArrayLike { + _length: number; + + /** + * Use `createHTMLCollection` to create instances of this class. + * + * @private This is not defined in the declaration file, so users will not see + * the signature of the constructor. + */ + constructor(elements: $ReadOnlyArray) { + for (let i = 0; i < elements.length; i++) { + Object.defineProperty(this, i, { + value: elements[i], + enumerable: true, + configurable: false, + writable: false, + }); + } + + this._length = elements.length; + } + + get length(): number { + return this._length; + } + + item(index: number): T | null { + if (index < 0 || index >= this._length) { + return null; + } + + // assigning to the interface allows us to access the indexer property in a + // type-safe way. + // eslint-disable-next-line consistent-this + const arrayLike: ArrayLike = this; + return arrayLike[index]; + } + + /** + * @deprecated Unused in React Native. + */ + namedItem(name: string): T | null { + return null; + } + + // $FlowIssue[unsupported-syntax] Flow does not support computed properties in classes. + [Symbol.iterator](): Iterator { + return createValueIterator(this); + } +} + +/** + * This is an internal method to create instances of `HTMLCollection`, + * which avoids leaking its constructor to end users. + * We can do that because the external definition of `HTMLCollection` lives in + * `HTMLCollection.js.flow`, not here. + */ +export function createHTMLCollection( + elements: $ReadOnlyArray, +): HTMLCollection { + return new HTMLCollection(elements); +} diff --git a/packages/react-native/Libraries/DOM/OldStyleCollections/HTMLCollection.js.flow b/packages/react-native/Libraries/DOM/OldStyleCollections/HTMLCollection.js.flow new file mode 100644 index 00000000000000..8f14d1d098c7ec --- /dev/null +++ b/packages/react-native/Libraries/DOM/OldStyleCollections/HTMLCollection.js.flow @@ -0,0 +1,27 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict + */ + +import type {ArrayLike} from './ArrayLikeUtils'; + +declare export default class HTMLCollection<+T> + implements Iterable, ArrayLike +{ + // This property should've been read-only as well, but Flow doesn't handle + // read-only indexers correctly (thinks reads are writes and fails). + [index: number]: T; + +length: number; + item(index: number): T | null; + namedItem(name: string): T | null; + @@iterator(): Iterator; +} + +declare export function createHTMLCollection( + elements: $ReadOnlyArray, +): HTMLCollection; diff --git a/packages/react-native/Libraries/DOM/OldStyleCollections/NodeList.js b/packages/react-native/Libraries/DOM/OldStyleCollections/NodeList.js new file mode 100644 index 00000000000000..592919e4680611 --- /dev/null +++ b/packages/react-native/Libraries/DOM/OldStyleCollections/NodeList.js @@ -0,0 +1,104 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict + */ + +// flowlint unsafe-getters-setters:off + +import type {ArrayLike} from './ArrayLikeUtils'; + +import { + createEntriesIterator, + createKeyIterator, + createValueIterator, +} from './ArrayLikeUtils'; + +// IMPORTANT: The Flow type definition for this module is defined in `NodeList.js.flow` +// because Flow only supports indexers in classes in declaration files. + +// $FlowIssue[prop-missing] Flow doesn't understand [Symbol.iterator]() {} and thinks this class doesn't implement the Iterable interface. +export default class NodeList implements Iterable, ArrayLike { + _length: number; + + /** + * Use `createNodeList` to create instances of this class. + * + * @private This is not defined in the declaration file, so users will not see + * the signature of the constructor. + */ + constructor(elements: $ReadOnlyArray) { + for (let i = 0; i < elements.length; i++) { + Object.defineProperty(this, i, { + value: elements[i], + writable: false, + }); + } + this._length = elements.length; + } + + get length(): number { + return this._length; + } + + item(index: number): T | null { + if (index < 0 || index >= this._length) { + return null; + } + + // assigning to the interface allows us to access the indexer property in a + // type-safe way. + // eslint-disable-next-line consistent-this + const arrayLike: ArrayLike = this; + return arrayLike[index]; + } + + entries(): Iterator<[number, T]> { + return createEntriesIterator(this); + } + + forEach( + callbackFn: (value: T, index: number, array: NodeList) => mixed, + thisArg?: ThisType, + ): void { + // assigning to the interface allows us to access the indexer property in a + // type-safe way. + // eslint-disable-next-line consistent-this + const arrayLike: ArrayLike = this; + + for (let index = 0; index < this._length; index++) { + if (thisArg == null) { + callbackFn(arrayLike[index], index, this); + } else { + callbackFn.call(thisArg, arrayLike[index], index, this); + } + } + } + + keys(): Iterator { + return createKeyIterator(this); + } + + values(): Iterator { + return createValueIterator(this); + } + + // $FlowIssue[unsupported-syntax] Flow does not support computed properties in classes. + [Symbol.iterator](): Iterator { + return createValueIterator(this); + } +} + +/** + * This is an internal method to create instances of `NodeList`, + * which avoids leaking its constructor to end users. + * We can do that because the external definition of `NodeList` lives in + * `NodeList.js.flow`, not here. + */ +export function createNodeList(elements: $ReadOnlyArray): NodeList { + return new NodeList(elements); +} diff --git a/packages/react-native/Libraries/DOM/OldStyleCollections/NodeList.js.flow b/packages/react-native/Libraries/DOM/OldStyleCollections/NodeList.js.flow new file mode 100644 index 00000000000000..89e02eef540f91 --- /dev/null +++ b/packages/react-native/Libraries/DOM/OldStyleCollections/NodeList.js.flow @@ -0,0 +1,31 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict + */ + +import type {ArrayLike} from './ArrayLikeUtils'; + +declare export default class NodeList<+T> implements Iterable, ArrayLike { + // This property should've been read-only as well, but Flow doesn't handle + // read-only indexers correctly (thinks reads are writes and fails). + [index: number]: T; + +length: number; + item(index: number): T | null; + entries(): Iterator<[number, T]>; + forEach( + callbackFn: (value: T, index: number, array: NodeList) => mixed, + thisArg?: ThisType, + ): void; + keys(): Iterator; + values(): Iterator; + @@iterator(): Iterator; +} + +declare export function createNodeList( + elements: $ReadOnlyArray, +): NodeList; diff --git a/packages/react-native/Libraries/DOM/OldStyleCollections/__tests__/DOMRectList-test.js b/packages/react-native/Libraries/DOM/OldStyleCollections/__tests__/DOMRectList-test.js new file mode 100644 index 00000000000000..c91abc26947367 --- /dev/null +++ b/packages/react-native/Libraries/DOM/OldStyleCollections/__tests__/DOMRectList-test.js @@ -0,0 +1,85 @@ +/** + * 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 + */ + +import DOMRectReadOnly from '../../Geometry/DOMRectReadOnly'; +import {createDOMRectList} from '../DOMRectList'; + +const domRectA = new DOMRectReadOnly(); +const domRectB = new DOMRectReadOnly(); +const domRectC = new DOMRectReadOnly(); + +describe('DOMRectList', () => { + it('provides an array-like interface', () => { + const collection = createDOMRectList([domRectA, domRectB, domRectC]); + + expect(collection[0]).toBe(domRectA); + expect(collection[1]).toBe(domRectB); + expect(collection[2]).toBe(domRectC); + expect(collection[3]).toBe(undefined); + expect(collection.length).toBe(3); + }); + + it('is immutable (loose mode)', () => { + const collection = createDOMRectList([domRectA, domRectB, domRectC]); + + collection[0] = new DOMRectReadOnly(); + expect(collection[0]).toBe(domRectA); + + // $FlowExpectedError[cannot-write] + collection.length = 100; + expect(collection.length).toBe(3); + }); + + it('is immutable (strict mode)', () => { + 'use strict'; + + const collection = createDOMRectList([domRectA, domRectB, domRectC]); + + expect(() => { + collection[0] = new DOMRectReadOnly(); + }).toThrow(TypeError); + expect(collection[0]).toBe(domRectA); + + expect(() => { + // $FlowExpectedError[cannot-write] + collection.length = 100; + }).toThrow(TypeError); + expect(collection.length).toBe(3); + }); + + it('can be converted to an array through common methods', () => { + const collection = createDOMRectList([domRectA, domRectB, domRectC]); + + expect(Array.from(collection)).toEqual([domRectA, domRectB, domRectC]); + expect([...collection]).toEqual([domRectA, domRectB, domRectC]); + }); + + it('can be traversed with for-of', () => { + const collection = createDOMRectList([domRectA, domRectB, domRectC]); + + let i = 0; + for (const value of collection) { + expect(value).toBe(collection[i]); + i++; + } + }); + + describe('item()', () => { + it('returns elements at the specified position, or null', () => { + const collection = createDOMRectList([domRectA, domRectB, domRectC]); + + expect(collection.item(0)).toBe(domRectA); + expect(collection.item(1)).toBe(domRectB); + expect(collection.item(2)).toBe(domRectC); + expect(collection.item(3)).toBe(null); + }); + }); +}); diff --git a/packages/react-native/Libraries/DOM/OldStyleCollections/__tests__/HTMLCollection-test.js b/packages/react-native/Libraries/DOM/OldStyleCollections/__tests__/HTMLCollection-test.js new file mode 100644 index 00000000000000..8000e1551bfd6d --- /dev/null +++ b/packages/react-native/Libraries/DOM/OldStyleCollections/__tests__/HTMLCollection-test.js @@ -0,0 +1,80 @@ +/** + * 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 + */ + +import {createHTMLCollection} from '../HTMLCollection'; + +describe('HTMLCollection', () => { + it('provides an array-like interface', () => { + const collection = createHTMLCollection(['a', 'b', 'c']); + + expect(collection[0]).toBe('a'); + expect(collection[1]).toBe('b'); + expect(collection[2]).toBe('c'); + expect(collection[3]).toBe(undefined); + expect(collection.length).toBe(3); + }); + + it('is immutable (loose mode)', () => { + const collection = createHTMLCollection(['a', 'b', 'c']); + + collection[0] = 'replacement'; + expect(collection[0]).toBe('a'); + + // $FlowExpectedError[cannot-write] + collection.length = 100; + expect(collection.length).toBe(3); + }); + + it('is immutable (strict mode)', () => { + 'use strict'; + + const collection = createHTMLCollection(['a', 'b', 'c']); + + expect(() => { + collection[0] = 'replacement'; + }).toThrow(TypeError); + expect(collection[0]).toBe('a'); + + expect(() => { + // $FlowExpectedError[cannot-write] + collection.length = 100; + }).toThrow(TypeError); + expect(collection.length).toBe(3); + }); + + it('can be converted to an array through common methods', () => { + const collection = createHTMLCollection(['a', 'b', 'c']); + + expect(Array.from(collection)).toEqual(['a', 'b', 'c']); + expect([...collection]).toEqual(['a', 'b', 'c']); + }); + + it('can be traversed with for-of', () => { + const collection = createHTMLCollection(['a', 'b', 'c']); + + let i = 0; + for (const value of collection) { + expect(value).toBe(collection[i]); + i++; + } + }); + + describe('item()', () => { + it('returns elements at the specified position, or null', () => { + const collection = createHTMLCollection(['a', 'b', 'c']); + + expect(collection.item(0)).toBe('a'); + expect(collection.item(1)).toBe('b'); + expect(collection.item(2)).toBe('c'); + expect(collection.item(3)).toBe(null); + }); + }); +}); diff --git a/packages/react-native/Libraries/DOM/OldStyleCollections/__tests__/NodeList-test.js b/packages/react-native/Libraries/DOM/OldStyleCollections/__tests__/NodeList-test.js new file mode 100644 index 00000000000000..8f42e30bb55ab4 --- /dev/null +++ b/packages/react-native/Libraries/DOM/OldStyleCollections/__tests__/NodeList-test.js @@ -0,0 +1,161 @@ +/** + * 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 + */ + +import {createNodeList} from '../NodeList'; + +describe('NodeList', () => { + it('provides an array-like interface', () => { + const collection = createNodeList(['a', 'b', 'c']); + + expect(collection[0]).toBe('a'); + expect(collection[1]).toBe('b'); + expect(collection[2]).toBe('c'); + expect(collection[3]).toBe(undefined); + expect(collection.length).toBe(3); + }); + + it('provides indexed access through the item method', () => { + const collection = createNodeList(['a', 'b', 'c']); + + expect(collection.item(0)).toBe('a'); + expect(collection.item(1)).toBe('b'); + expect(collection.item(2)).toBe('c'); + expect(collection.item(3)).toBe(null); + }); + + it('is immutable (loose mode)', () => { + const collection = createNodeList(['a', 'b', 'c']); + + collection[0] = 'replacement'; + expect(collection[0]).toBe('a'); + + // $FlowExpectedError[cannot-write] + collection.length = 100; + expect(collection.length).toBe(3); + }); + + it('is immutable (strict mode)', () => { + 'use strict'; + + const collection = createNodeList(['a', 'b', 'c']); + + expect(() => { + collection[0] = 'replacement'; + }).toThrow(TypeError); + expect(collection[0]).toBe('a'); + + expect(() => { + // $FlowExpectedError[cannot-write] + collection.length = 100; + }).toThrow(TypeError); + expect(collection.length).toBe(3); + }); + + it('can be converted to an array through common methods', () => { + const collection = createNodeList(['a', 'b', 'c']); + + expect(Array.from(collection)).toEqual(['a', 'b', 'c']); + expect([...collection]).toEqual(['a', 'b', 'c']); + }); + + it('can be traversed with for-of', () => { + const collection = createNodeList(['a', 'b', 'c']); + + let i = 0; + for (const value of collection) { + expect(value).toBe(collection[i]); + i++; + } + }); + + describe('keys()', () => { + it('returns an iterator for keys', () => { + const collection = createNodeList(['a', 'b', 'c']); + + const keys = collection.keys(); + expect(keys.next()).toEqual({value: 0, done: false}); + expect(keys.next()).toEqual({value: 1, done: false}); + expect(keys.next()).toEqual({value: 2, done: false}); + expect(keys.next()).toEqual({done: true}); + + let i = 0; + for (const key of collection.keys()) { + expect(key).toBe(i); + i++; + } + }); + }); + + describe('values()', () => { + it('returns an iterator for values', () => { + const collection = createNodeList(['a', 'b', 'c']); + + const values = collection.values(); + expect(values.next()).toEqual({value: 'a', done: false}); + expect(values.next()).toEqual({value: 'b', done: false}); + expect(values.next()).toEqual({value: 'c', done: false}); + expect(values.next()).toEqual({done: true}); + + let i = 0; + for (const value of collection.values()) { + expect(value).toBe(collection[i]); + i++; + } + }); + }); + + describe('entries()', () => { + it('returns an iterator for entries', () => { + const collection = createNodeList(['a', 'b', 'c']); + + const entries = collection.entries(); + expect(entries.next()).toEqual({value: [0, 'a'], done: false}); + expect(entries.next()).toEqual({value: [1, 'b'], done: false}); + expect(entries.next()).toEqual({value: [2, 'c'], done: false}); + expect(entries.next()).toEqual({done: true}); + + let i = 0; + for (const entry of collection.entries()) { + expect(entry).toEqual([i, collection[i]]); + i++; + } + }); + }); + + describe('forEach()', () => { + it('iterates over the elements like array.forEach (implicit `this`)', () => { + const collection = createNodeList(['a', 'b', 'c']); + + let i = 0; + collection.forEach(function (this: mixed, value, index, list) { + expect(value).toBe(collection[i]); + expect(index).toBe(i); + expect(list).toBe(collection); + expect(this).toBe(window); + i++; + }); + }); + + it('iterates over the elements like array.forEach (explicit `this`)', () => { + const collection = createNodeList(['a', 'b', 'c']); + + let i = 0; + const explicitThis = {id: 'foo'}; + collection.forEach(function (this: mixed, value, index, list) { + expect(value).toBe(collection[i]); + expect(index).toBe(i); + expect(list).toBe(collection); + expect(this).toBe(explicitThis); + i++; + }, explicitThis); + }); + }); +}); diff --git a/packages/react-native/Libraries/Image/RCTImageCache.h b/packages/react-native/Libraries/Image/RCTImageCache.h index 0e445ca3f47042..038eb2293d8f8b 100644 --- a/packages/react-native/Libraries/Image/RCTImageCache.h +++ b/packages/react-native/Libraries/Image/RCTImageCache.h @@ -39,7 +39,7 @@ @interface RCTImageCache : NSObject RCT_EXTERN void RCTSetImageCacheLimits( - NSUInteger maxCachableDecodedImageSizeInBytes, + NSUInteger maxCacheableDecodedImageSizeInBytes, NSUInteger imageCacheTotalCostLimit); @end diff --git a/packages/react-native/Libraries/Image/RCTImageCache.m b/packages/react-native/Libraries/Image/RCTImageCache.m index 4d969265f363c6..947bf378b99fbe 100644 --- a/packages/react-native/Libraries/Image/RCTImageCache.m +++ b/packages/react-native/Libraries/Image/RCTImageCache.m @@ -18,12 +18,12 @@ #import -static NSUInteger RCTMaxCachableDecodedImageSizeInBytes = 2 * 1024 * 1024; +static NSUInteger RCTMaxCacheableDecodedImageSizeInBytes = 2 * 1024 * 1024; static NSUInteger RCTImageCacheTotalCostLimit = 20 * 1024 * 1024; -void RCTSetImageCacheLimits(NSUInteger maxCachableDecodedImageSizeInBytes, NSUInteger imageCacheTotalCostLimit) +void RCTSetImageCacheLimits(NSUInteger maxCacheableDecodedImageSizeInBytes, NSUInteger imageCacheTotalCostLimit) { - RCTMaxCachableDecodedImageSizeInBytes = maxCachableDecodedImageSizeInBytes; + RCTMaxCacheableDecodedImageSizeInBytes = maxCacheableDecodedImageSizeInBytes; RCTImageCacheTotalCostLimit = imageCacheTotalCostLimit; } @@ -77,7 +77,7 @@ - (void)addImageToCache:(UIImage *)image forKey:(NSString *)cacheKey return; } NSInteger bytes = image.reactDecodedImageBytes; - if (bytes <= RCTMaxCachableDecodedImageSizeInBytes) { + if (bytes <= RCTMaxCacheableDecodedImageSizeInBytes) { [self->_decodedImageCache setObject:image forKey:cacheKey cost:bytes]; } } diff --git a/packages/react-native/Libraries/Image/RCTImageView.mm b/packages/react-native/Libraries/Image/RCTImageView.mm index 4701b8bfabdf1a..509afad872dd16 100644 --- a/packages/react-native/Libraries/Image/RCTImageView.mm +++ b/packages/react-native/Libraries/Image/RCTImageView.mm @@ -220,7 +220,7 @@ - (void)updateWithImage:(UIImage *)image } #endif // macOS] - // Apply trilinear filtering to smooth out mis-sized images + // Apply trilinear filtering to smooth out missized images _imageView.layer.minificationFilter = kCAFilterTrilinear; _imageView.layer.magnificationFilter = kCAFilterTrilinear; diff --git a/packages/react-native/Libraries/Inspector/DevtoolsOverlay.js b/packages/react-native/Libraries/Inspector/DevtoolsOverlay.js index cdb874ef610909..37d1ebb30eb305 100644 --- a/packages/react-native/Libraries/Inspector/DevtoolsOverlay.js +++ b/packages/react-native/Libraries/Inspector/DevtoolsOverlay.js @@ -174,7 +174,7 @@ export default function DevtoolsOverlay({ [findViewForLocation], ); - const shouldSetResponser = useCallback( + const shouldSetResponder = useCallback( (e: PressEvent): boolean => { onResponderMove(e); return true; @@ -193,7 +193,7 @@ export default function DevtoolsOverlay({ onPointerUp: stopInspecting, } : { - onStartShouldSetResponder: shouldSetResponser, + onStartShouldSetResponder: shouldSetResponder, onResponderMove: onResponderMove, onResponderRelease: stopInspecting, }; diff --git a/packages/react-native/Libraries/Inspector/InspectorOverlay.js b/packages/react-native/Libraries/Inspector/InspectorOverlay.js index 0c239f2db51411..c8973baea394bf 100644 --- a/packages/react-native/Libraries/Inspector/InspectorOverlay.js +++ b/packages/react-native/Libraries/Inspector/InspectorOverlay.js @@ -36,7 +36,7 @@ class InspectorOverlay extends React.Component { this.props.onTouchPoint(locationX, locationY); }; - shouldSetResponser: (e: PressEvent) => boolean = (e: PressEvent): boolean => { + shouldSetResponder: (e: PressEvent) => boolean = (e: PressEvent): boolean => { this.findViewForTouchEvent(e); return true; }; @@ -54,7 +54,7 @@ class InspectorOverlay extends React.Component { return ( diff --git a/packages/react-native/Libraries/Interaction/JSEventLoopWatchdog.js b/packages/react-native/Libraries/Interaction/JSEventLoopWatchdog.js index 3eae297b74184b..113d073ee7000c 100644 --- a/packages/react-native/Libraries/Interaction/JSEventLoopWatchdog.js +++ b/packages/react-native/Libraries/Interaction/JSEventLoopWatchdog.js @@ -27,7 +27,7 @@ type Handler = { * other events from being processed in a timely manner. * * The "stall" time is defined as the amount of time in access of the acceptable - * threshold, which is typically around 100-200ms. So if the treshold is set to + * threshold, which is typically around 100-200ms. So if the threshold is set to * 100 and a timer fires 150 ms later than it was scheduled because the event * loop was tied up, that would be considered a 50ms stall. * diff --git a/packages/react-native/Libraries/Lists/FlatList.d.ts b/packages/react-native/Libraries/Lists/FlatList.d.ts index 24d9a06481c420..4a10e52093cf53 100644 --- a/packages/react-native/Libraries/Lists/FlatList.d.ts +++ b/packages/react-native/Libraries/Lists/FlatList.d.ts @@ -41,7 +41,7 @@ export interface FlatListProps extends VirtualizedListProps { /** * An array (or array-like list) of items to render. Other data types can be - * used by targetting VirtualizedList directly. + * used by targeting VirtualizedList directly. */ data: ArrayLike | null | undefined; diff --git a/packages/react-native/Libraries/Lists/FlatList.js b/packages/react-native/Libraries/Lists/FlatList.js index 0f628df497391b..f2c6f19cd354aa 100644 --- a/packages/react-native/Libraries/Lists/FlatList.js +++ b/packages/react-native/Libraries/Lists/FlatList.js @@ -34,7 +34,7 @@ const React = require('react'); type RequiredProps = {| /** * An array (or array-like list) of items to render. Other data types can be - * used by targetting VirtualizedList directly. + * used by targeting VirtualizedList directly. */ data: ?$ArrayLike, |}; diff --git a/packages/react-native/Libraries/LogBox/Data/LogBoxData.js b/packages/react-native/Libraries/LogBox/Data/LogBoxData.js index 6c5e160dfe0f46..d3e06b0451303c 100644 --- a/packages/react-native/Libraries/LogBox/Data/LogBoxData.js +++ b/packages/react-native/Libraries/LogBox/Data/LogBoxData.js @@ -154,7 +154,7 @@ function appendNewLog(newLog: LogBoxLog) { if (newLog.level === 'fatal') { // If possible, to avoid jank, we don't want to open the error before // it's symbolicated. To do that, we optimistically wait for - // sybolication for up to a second before adding the log. + // symbolication for up to a second before adding the log. const OPTIMISTIC_WAIT_TIME = 1000; let addPendingLog: ?() => void = () => { diff --git a/packages/react-native/Libraries/LogBox/Data/__tests__/LogBoxData-test.js b/packages/react-native/Libraries/LogBox/Data/__tests__/LogBoxData-test.js index e1a3d1e2bbe845..f26d6cc8c64b45 100644 --- a/packages/react-native/Libraries/LogBox/Data/__tests__/LogBoxData-test.js +++ b/packages/react-native/Libraries/LogBox/Data/__tests__/LogBoxData-test.js @@ -527,7 +527,7 @@ describe('LogBoxData', () => { flushToObservers(); expect(observer.mock.calls.length).toBe(2); - // We expect observers to recieve the same Set object in sequential updates + // We expect observers to receive the same Set object in sequential updates // so that it doesn't break memoization for components observing state. expect(observer.mock.calls[0][0].logs).toBe(observer.mock.calls[1][0].logs); }); diff --git a/packages/react-native/Libraries/LogBox/Data/parseLogBoxLog.js b/packages/react-native/Libraries/LogBox/Data/parseLogBoxLog.js index f0abc77961d10e..7b91d697a880e2 100644 --- a/packages/react-native/Libraries/LogBox/Data/parseLogBoxLog.js +++ b/packages/react-native/Libraries/LogBox/Data/parseLogBoxLog.js @@ -302,7 +302,7 @@ export function parseLogBoxException( } // Most `console.error` calls won't have a componentStack. We parse them like - // regular logs which have the component stack burried in the message. + // regular logs which have the component stack buried in the message. return { level: 'error', stack: error.stack, diff --git a/packages/react-native/Libraries/LogBox/UI/LogBoxMessage.js b/packages/react-native/Libraries/LogBox/UI/LogBoxMessage.js index 38f4e0436b2a34..805b47efec8987 100644 --- a/packages/react-native/Libraries/LogBox/UI/LogBoxMessage.js +++ b/packages/react-native/Libraries/LogBox/UI/LogBoxMessage.js @@ -146,12 +146,12 @@ function LogBoxMessage(props: Props): React.Node { createUnderLength(key, prevPart); } - const substititionPart = content.substr( + const substitutionPart = content.substr( substitution.offset, substitution.length, ); - createUnderLength(key + '.5', substititionPart, substitutionStyle); + createUnderLength(key + '.5', substitutionPart, substitutionStyle); return substitution.offset + substitution.length; }, 0); diff --git a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorMesageHeader-test.js b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorMessageHeader-test.js similarity index 100% rename from packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorMesageHeader-test.js rename to packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorMessageHeader-test.js diff --git a/packages/react-native/Libraries/LogBox/UI/__tests__/__snapshots__/LogBoxInspectorMesageHeader-test.js.snap b/packages/react-native/Libraries/LogBox/UI/__tests__/__snapshots__/LogBoxInspectorMessageHeader-test.js.snap similarity index 100% rename from packages/react-native/Libraries/LogBox/UI/__tests__/__snapshots__/LogBoxInspectorMesageHeader-test.js.snap rename to packages/react-native/Libraries/LogBox/UI/__tests__/__snapshots__/LogBoxInspectorMessageHeader-test.js.snap diff --git a/packages/react-native/Libraries/LogBox/__tests__/LogBox-test.js b/packages/react-native/Libraries/LogBox/__tests__/LogBox-test.js index 689c05fd578930..70c0ca496e1f85 100644 --- a/packages/react-native/Libraries/LogBox/__tests__/LogBox-test.js +++ b/packages/react-native/Libraries/LogBox/__tests__/LogBox-test.js @@ -108,7 +108,7 @@ describe('LogBox', () => { jest.mock('../Data/LogBoxData'); const mockError = new Error('Simulated error'); - // Picking a random implemention detail to simulate throwing. + // Picking a random implementation detail to simulate throwing. (LogBoxData.isMessageIgnored: any).mockImplementation(() => { throw mockError; }); diff --git a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTPropsAnimatedNode.m b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTPropsAnimatedNode.m index 9b732b347c2f7c..fdc5f88d1020d5 100644 --- a/packages/react-native/Libraries/NativeAnimation/Nodes/RCTPropsAnimatedNode.m +++ b/packages/react-native/Libraries/NativeAnimation/Nodes/RCTPropsAnimatedNode.m @@ -76,7 +76,7 @@ - (void)restoreDefaultValues { if (_managedByFabric) { // Restoring to default values causes render of inconsistent state - // to the user because it isn't synchonised with Fabric's UIManager. + // to the user because it isn't synchronised with Fabric's UIManager. return; } // Restore the default value for all props that were modified by this node. diff --git a/packages/react-native/Libraries/NativeAnimation/RCTAnimationUtils.m b/packages/react-native/Libraries/NativeAnimation/RCTAnimationUtils.m index fab1173440b81a..566ba6d25e3748 100644 --- a/packages/react-native/Libraries/NativeAnimation/RCTAnimationUtils.m +++ b/packages/react-native/Libraries/NativeAnimation/RCTAnimationUtils.m @@ -104,8 +104,8 @@ uint32_t RCTInterpolateColorInRange(CGFloat value, NSArray *inputRan uint32_t RCTColorFromComponents(CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha) { - return ((uint32_t)round(alpha * 255) & 0xFF) << 24 | ((uint32_t)round(red) & 0xFF) << 16 | ((uint32_t)round(green) & 0xFF) << 8 | - ((uint32_t)round(blue) & 0xFF); + return ((uint32_t)round(alpha * 255) & 0xFF) << 24 | ((uint32_t)round(red) & 0xFF) << 16 | + ((uint32_t)round(green) & 0xFF) << 8 | ((uint32_t)round(blue) & 0xFF); } #if TARGET_IPHONE_SIMULATOR diff --git a/packages/react-native/Libraries/NativeComponent/NativeComponentRegistryUnstable.js b/packages/react-native/Libraries/NativeComponent/NativeComponentRegistryUnstable.js index df9b0786d95c6f..cb6ac57f52ec29 100644 --- a/packages/react-native/Libraries/NativeComponent/NativeComponentRegistryUnstable.js +++ b/packages/react-native/Libraries/NativeComponent/NativeComponentRegistryUnstable.js @@ -14,7 +14,7 @@ let componentNameToExists: Map = new Map(); * Unstable API. Do not use! * * This method returns if the component with name received as a parameter - * is registed in the native platform. + * is registered in the native platform. */ export function unstable_hasComponent(name: string): boolean { let hasNativeComponent = componentNameToExists.get(name); diff --git a/packages/react-native/Libraries/Pressability/Pressability.js b/packages/react-native/Libraries/Pressability/Pressability.js index d7044b45abaeb3..b3a220e8ba92e8 100644 --- a/packages/react-native/Libraries/Pressability/Pressability.js +++ b/packages/react-native/Libraries/Pressability/Pressability.js @@ -136,7 +136,7 @@ export type PressabilityConfig = $ReadOnly<{| onLongPress?: ?(event: PressEvent) => mixed, /** - * Called when a press gestute has been triggered. + * Called when a press gesture has been triggered. */ onPress?: ?(event: PressEvent) => mixed, diff --git a/packages/react-native/Libraries/ReactNative/FabricUIManager.js b/packages/react-native/Libraries/ReactNative/FabricUIManager.js index 4adf2cc2f63d09..e37261a153bbd5 100644 --- a/packages/react-native/Libraries/ReactNative/FabricUIManager.js +++ b/packages/react-native/Libraries/ReactNative/FabricUIManager.js @@ -57,6 +57,20 @@ export type Spec = {| ) => void, +sendAccessibilityEvent: (node: Node, eventType: string) => void, +findShadowNodeByTag_DEPRECATED: (reactTag: number) => ?Node, + +getBoundingClientRect: ( + node: Node, + ) => [ + /* x:*/ number, + /* y:*/ number, + /* width:*/ number, + /* height:*/ number, + ], + +setNativeProps: (node: Node, newProps: NodeProps) => void, + +dispatchCommand: ( + node: Node, + commandName: string, + args: Array, + ) => void, |}; // This is exposed as a getter because apps using the legacy renderer AND diff --git a/packages/react-native/Libraries/Text/Text.d.ts b/packages/react-native/Libraries/Text/Text.d.ts index a52f4467e1babe..bee0c632372ea0 100644 --- a/packages/react-native/Libraries/Text/Text.d.ts +++ b/packages/react-native/Libraries/Text/Text.d.ts @@ -53,6 +53,16 @@ export interface TextPropsIOS { * default, a gray oval highlights the text on press down. */ suppressHighlighting?: boolean | undefined; + + /** + * Set line break strategy on iOS. + */ + lineBreakStrategyIOS?: + | 'none' + | 'standard' + | 'hangul-word' + | 'push-out' + | undefined; } export interface TextPropsAndroid { diff --git a/packages/react-native/Libraries/Text/Text/NSTextStorage+FontScaling.m b/packages/react-native/Libraries/Text/Text/NSTextStorage+FontScaling.m index 764b81923bf8b8..692d2f3d8c3d26 100644 --- a/packages/react-native/Libraries/Text/Text/NSTextStorage+FontScaling.m +++ b/packages/react-native/Libraries/Text/Text/NSTextStorage+FontScaling.m @@ -30,11 +30,11 @@ - (void)scaleFontSizeToFitSize:(CGSize)size while (true) { [self scaleFontSizeWithRatio:ratio minimumFontSize:minimumFontSize maximumFontSize:maximumFontSize]; - RCTTextSizeComparisonOptions comparsion = [self compareToSize:size thresholdRatio:0.01]; + RCTTextSizeComparisonOptions comparison = [self compareToSize:size thresholdRatio:0.01]; - if ((comparsion & RCTTextSizeComparisonWithinRange) && (comparsion & RCTTextSizeComparisonSmaller)) { + if ((comparison & RCTTextSizeComparisonWithinRange) && (comparison & RCTTextSizeComparisonSmaller)) { return; - } else if (comparsion & RCTTextSizeComparisonSmaller) { + } else if (comparison & RCTTextSizeComparisonSmaller) { bottomRatio = ratio; lastRatioWhichFits = ratio; } else { diff --git a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m index c202dcfcd1a894..595fd90abde535 100644 --- a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m +++ b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m @@ -483,7 +483,7 @@ - (CGSize)contentSize CGSize contentSize = super.intrinsicContentSize; CGSize placeholderSize = self.placeholderSize; #endif // macOS] - // When a text input is empty, it actually displays a placehoder. + // When a text input is empty, it actually displays a placeholder. // So, we have to consider `placeholderSize` as a minimum `contentSize`. // Returning size DOES contain `textContainerInset` (aka `padding`). return CGSizeMake(MAX(contentSize.width, placeholderSize.width), MAX(contentSize.height, placeholderSize.height)); diff --git a/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m b/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m index fd2cfd40b1413d..a0d56510004973 100644 --- a/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m +++ b/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m @@ -29,7 +29,7 @@ @implementation RCTBaseTextInputView { NSInteger _ghostTextPosition; // [macOS] only valid if _ghostText != nil - BOOL _hasInputAccesoryView; + BOOL _hasInputAccessoryView; // [macOS] remove explicit _predictedText ivar declaration BOOL _didMoveToWindow; } @@ -844,18 +844,18 @@ - (void)setDefaultInputAccessoryView // These keyboard types (all are number pads) don't have a "Done" button by default, // so we create an `inputAccessoryView` with this button for them. - BOOL shouldHaveInputAccesoryView = + BOOL shouldHaveInputAccessoryView = (keyboardType == UIKeyboardTypeNumberPad || keyboardType == UIKeyboardTypePhonePad || keyboardType == UIKeyboardTypeDecimalPad || keyboardType == UIKeyboardTypeASCIICapableNumberPad) && textInputView.returnKeyType == UIReturnKeyDone; - if (_hasInputAccesoryView == shouldHaveInputAccesoryView) { + if (_hasInputAccessoryView == shouldHaveInputAccessoryView) { return; } - _hasInputAccesoryView = shouldHaveInputAccesoryView; + _hasInputAccessoryView = shouldHaveInputAccessoryView; - if (shouldHaveInputAccesoryView) { + if (shouldHaveInputAccessoryView) { UIToolbar *toolbarView = [UIToolbar new]; [toolbarView sizeToFit]; UIBarButtonItem *flexibleSpace = diff --git a/packages/react-native/Libraries/Types/CodegenTypes.js b/packages/react-native/Libraries/Types/CodegenTypes.js index ca43a6b01724dc..737e2f290b1049 100644 --- a/packages/react-native/Libraries/Types/CodegenTypes.js +++ b/packages/react-native/Libraries/Types/CodegenTypes.js @@ -29,6 +29,7 @@ export type Double = number; export type Float = number; export type Int32 = number; export type UnsafeObject = $FlowFixMe; // Object is forbidden in strict mode +export type UnsafeMixed = mixed; type DefaultTypes = number | boolean | string | $ReadOnlyArray; // Default handling, ignore the unused value diff --git a/packages/react-native/Libraries/vendor/emitter/EventEmitter.d.ts b/packages/react-native/Libraries/vendor/emitter/EventEmitter.d.ts index 148bff33d0a868..0365dd003ea014 100644 --- a/packages/react-native/Libraries/vendor/emitter/EventEmitter.d.ts +++ b/packages/react-native/Libraries/vendor/emitter/EventEmitter.d.ts @@ -48,7 +48,7 @@ declare class EventSubscriptionVendor { * Removes a bulk set of the subscriptions. * * @param eventType - Optional name of the event type whose - * registered supscriptions to remove, if null remove all subscriptions. + * registered subscriptions to remove, if null remove all subscriptions. */ removeAllSubscriptions(eventType?: string): void; diff --git a/packages/react-native/README.md b/packages/react-native/README.md deleted file mode 100644 index ad530bcb39cf52..00000000000000 --- a/packages/react-native/README.md +++ /dev/null @@ -1,113 +0,0 @@ -

React Native for macOS

- -

- Build native macOS apps with React. -

- -

- - React Native for macOS is released under the MIT license. - - - Current npm package version. - - - PRs welcome! - -

- -> See the official [React Native website](https://reactnative.dev/) for an introduction to React Native. - -[React Native](https://reactnative.dev) is a framework developed by Facebook that enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and [React](https://reactjs.org/). The focus of React Native is on developer efficiency across all the platforms you care about - learn once, write anywhere. - -- **Declarative.** React makes it painless to create interactive UIs. Declarative views make your code more predictable and easier to debug. -- **Component-Based.** Build encapsulated components that manage their state, then compose them to make complex UIs. -- **Developer Velocity.** See local changes in seconds. Changes to JavaScript code can be live reloaded without rebuilding the native app. -- **Portability.** Reuse code across iOS, Android, and [other platforms][p]. - -React Native is developed and supported by many companies and individual core contributors. Find out more in our [ecosystem overview][e]. - -[r]: https://reactjs.org/ -[p]: https://reactnative.dev/docs/out-of-tree-platforms -[e]: https://github.com/facebook/react-native/blob/HEAD/ECOSYSTEM.md - -This repository is a working fork of **facebook/react-native** that adds support for the official React Native for macOS implementation from Microsoft. - -You can read more about the macOS implementation in our website - [React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/). You can read about how we manage this fork in our [docs](docs/) folder. - -## Contents - -- [Requirements](#-requirements) -- [Building your first React Native app](#-building-your-first-react-native-app) -- [Documentation](#documentation) -- [How to Contribute](#contributing) -- [Code of Conduct](#code-of-conduct) -- [License](#license) - - -## 📋 Requirements - -React Native apps may target iOS 12.4 and Android 5.0 (API 21) or newer. You may use Windows, macOS, or Linux as your development operating system, though building and running iOS apps is limited to macOS. Tools like [Expo](https://expo.dev) can be used to work around this. - -## 🎉 Building your first React Native app - -Follow the [Getting Started guide](https://reactnative.dev/docs/getting-started). The recommended way to install React Native depends on your project. Here you can find short guides for the most common scenarios: - -- [Trying out React Native][hello-world] -- [Creating a New Application][new-app] -- [Adding React Native to an Existing Application][existing] - -[hello-world]: https://snack.expo.dev/@samples/hello-world -[new-app]: https://reactnative.dev/docs/getting-started -[existing]: https://reactnative.dev/docs/integration-with-existing-apps - -## Requirements - -You can run React Native for macOS apps on Mac devices with versions Catalina (10.15) or newer. - -For a full and detailed list of the system requirements and how to set up your development platform, see our [System Requirements](https://microsoft.github.io/react-native-windows/docs/rnm-dependencies) documentation on our website. - -## Getting Started - -See the [Getting Started Guide](https://microsoft.github.io/react-native-windows/docs/rnm-getting-started) on our React Native for Windows + macOS website to build your first React Native for macOS app. - -### Logging Issues - -Search the [existing issues](https://github.com/microsoft/react-native-macos/issues) and try to make sure your problem doesn’t already exist before opening a new issue. If your issue doesn't exist yet, try to make sure you provide as much information as possible to us so we can help you sooner. It’s helpful if you include information like: - -- The version of macOS, React Native, React Native macOS extension where you ran into the issue. -- A stack trace and reduced repro case when possible. -- Ensure the [appropriate template](https://github.com/microsoft/react-native-macos/issues/new/choose) is used when filing your issue(s). - -## Contributing - -See [Contributing guidelines](https://github.com/microsoft/react-native-macos/blob/master/CONTRIBUTING.md) for how to set up your fork of the repo and start a PR to contribute to React Native for macOS. - -[Good First Issue](https://github.com/microsoft/react-native-macos/labels/good%20first%20issue) and [help wanted](https://github.com/microsoft/react-native-macos/labels/help%20wanted) are great starting points for PRs. - -## Documentation - -The full documentation for React Native can be found on the [documentation website][docs]. The React Native documentation discusses components, APIs, and topics that are specific to React Native. For further documentation on the React API that is shared between React Native and React DOM, refer to the [React documentation][r-docs]. - -The source for the React Native documentation and website is hosted on a separate repo, [**@facebook/react-native-website**][repo-website]. - -[React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/) has its own separate documentation site where Windows and macOS -specific information, like API docs and blog updates live. We are still working on the documentation for macOS, contributions are welcome! - -If you're looking for sample code, just browse the [RNTester folder](https://github.com/microsoft/react-native-macos/tree/master/packages/rn-tester) for examples - -### Git flow and syncing with upstream - -For more details on how this fork handles keeping up with upstream, and how the general git flow works, check out [this dedicated document](./docs/GitFlow.md). - -## License - -The React Native for macOS extension, including modifications to the original Facebook source code, and all newly contributed code is provided under the [MIT License](LICENSE). Portions of the React Native for macOS extension derived from React Native are copyright Facebook. - -## Code of Conduct - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. - -[docs]: https://reactnative.dev/docs/getting-started -[r-docs]: https://reactjs.org/docs/getting-started.html -[repo-website]: https://github.com/facebook/react-native-website diff --git a/packages/react-native/React/Base/RCTBridge+Private.h b/packages/react-native/React/Base/RCTBridge+Private.h index 8412f1095fa63b..fc4639dec0a1a7 100644 --- a/packages/react-native/React/Base/RCTBridge+Private.h +++ b/packages/react-native/React/Base/RCTBridge+Private.h @@ -97,7 +97,7 @@ RCT_EXTERN void RCTRegisterModule(Class); - (void)registerModuleForFrameUpdates:(id)module withModuleData:(RCTModuleData *)moduleData; /** - * Dispatch work to a module's queue - this is also suports the fake RCTJSThread + * Dispatch work to a module's queue - this is also supports the fake RCTJSThread * queue. Exposed for the RCTProfiler */ - (void)dispatchBlock:(dispatch_block_t)block queue:(dispatch_queue_t)queue; diff --git a/packages/react-native/React/Base/RCTBridge.h b/packages/react-native/React/Base/RCTBridge.h index 6bf0ca4b18c45b..ddd209d5288a83 100644 --- a/packages/react-native/React/Base/RCTBridge.h +++ b/packages/react-native/React/Base/RCTBridge.h @@ -75,7 +75,7 @@ RCT_EXTERN void RCTSetTurboModuleCleanupMode(RCTTurboModuleCleanupMode mode); * * All the interaction with the JavaScript context should be done using the bridge * instance of the RCTBridgeModules. Modules will be automatically instantiated - * using the default contructor, but you can optionally pass in an array of + * using the default constructor, but you can optionally pass in an array of * pre-initialized module instances if they require additional init parameters * or configuration. */ @@ -87,7 +87,7 @@ RCT_EXTERN void RCTSetTurboModuleCleanupMode(RCTTurboModuleCleanupMode mode); * The designated initializer. This creates a new bridge on top of the specified * executor. The bridge should then be used for all subsequent communication * with the JavaScript code running in the executor. Modules will be automatically - * instantiated using the default contructor, but you can optionally pass in an + * instantiated using the default constructor, but you can optionally pass in an * array of pre-initialized module instances if they require additional init * parameters or configuration. */ diff --git a/packages/react-native/React/Base/RCTBridgeModuleDecorator.h b/packages/react-native/React/Base/RCTBridgeModuleDecorator.h index 225fef40c10961..e7860967d1a7f8 100644 --- a/packages/react-native/React/Base/RCTBridgeModuleDecorator.h +++ b/packages/react-native/React/Base/RCTBridgeModuleDecorator.h @@ -13,7 +13,7 @@ @class RCTViewRegistry; /** - RCTBridgeModuleDecorator contains instances that can be intialized with @synthesize + RCTBridgeModuleDecorator contains instances that can be initialized with @synthesize in RCTBridgeModules. For the Fabric interop layer. In Bridgeless, @synthesize ivars are passed from RCTBridgeModuleDecorator. diff --git a/packages/react-native/React/Base/RCTRootContentView.h b/packages/react-native/React/Base/RCTRootContentView.h index c3f58d46393059..762c7c4feffd11 100644 --- a/packages/react-native/React/Base/RCTRootContentView.h +++ b/packages/react-native/React/Base/RCTRootContentView.h @@ -27,6 +27,6 @@ - (instancetype)initWithFrame:(CGRect)frame bridge:(RCTBridge *)bridge reactTag:(NSNumber *)reactTag - sizeFlexiblity:(RCTRootViewSizeFlexibility)sizeFlexibility NS_DESIGNATED_INITIALIZER; + sizeFlexibility:(RCTRootViewSizeFlexibility)sizeFlexibility NS_DESIGNATED_INITIALIZER; @end diff --git a/packages/react-native/React/Base/RCTRootContentView.m b/packages/react-native/React/Base/RCTRootContentView.m index 92ba66ab108585..37fc70c1055202 100644 --- a/packages/react-native/React/Base/RCTRootContentView.m +++ b/packages/react-native/React/Base/RCTRootContentView.m @@ -26,7 +26,7 @@ @implementation RCTRootContentView - (instancetype)initWithFrame:(CGRect)frame bridge:(RCTBridge *)bridge reactTag:(NSNumber *)reactTag - sizeFlexiblity:(RCTRootViewSizeFlexibility)sizeFlexibility + sizeFlexibility:(RCTRootViewSizeFlexibility)sizeFlexibility { if ((self = [super initWithFrame:frame])) { _bridge = bridge; diff --git a/packages/react-native/React/Base/RCTRootView.m b/packages/react-native/React/Base/RCTRootView.m index 2d17c076c9f129..389697ddaaea4a 100644 --- a/packages/react-native/React/Base/RCTRootView.m +++ b/packages/react-native/React/Base/RCTRootView.m @@ -321,7 +321,7 @@ - (void)bundleFinishedLoading:(RCTBridge *)bridge _contentView = [[RCTRootContentView alloc] initWithFrame:self.bounds bridge:bridge reactTag:self.reactTag - sizeFlexiblity:_sizeFlexibility]; + sizeFlexibility:_sizeFlexibility]; [self runApplication:bridge]; _contentView.passThroughTouches = _passThroughTouches; diff --git a/packages/react-native/React/Base/Surface/RCTSurfaceRootShadowViewDelegate.h b/packages/react-native/React/Base/Surface/RCTSurfaceRootShadowViewDelegate.h index 856f46c326d741..0a417efc6f3d32 100644 --- a/packages/react-native/React/Base/Surface/RCTSurfaceRootShadowViewDelegate.h +++ b/packages/react-native/React/Base/Surface/RCTSurfaceRootShadowViewDelegate.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol RCTSurfaceRootShadowViewDelegate -- (void)rootShadowView:(RCTSurfaceRootShadowView *)rootShadowView didChangeIntrinsicSize:(CGSize)instrinsicSize; +- (void)rootShadowView:(RCTSurfaceRootShadowView *)rootShadowView didChangeIntrinsicSize:(CGSize)intrinsicSize; - (void)rootShadowViewDidStartRendering:(RCTSurfaceRootShadowView *)rootShadowView; - (void)rootShadowViewDidStartLayingOut:(RCTSurfaceRootShadowView *)rootShadowView; diff --git a/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.h b/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.h index a61829c0278e9b..0bdb778de4bea6 100644 --- a/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.h +++ b/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.h @@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Designated initializer. - * Instanciates a view with given Surface object. + * Instantiates a view with given Surface object. * Note: The view retains the surface object. */ - (instancetype)initWithSurface:(id)surface @@ -44,8 +44,8 @@ NS_ASSUME_NONNULL_BEGIN /** * Convenience initializer. - * Instanciates a Surface object with given `bridge`, `moduleName`, and - * `initialProperties`, and then use it to instanciate a view. + * Instantiates a Surface object with given `bridge`, `moduleName`, and + * `initialProperties`, and then use it to instantiate a view. */ - (instancetype)initWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName diff --git a/packages/react-native/React/CoreModules/RCTAccessibilityManager+Internal.h b/packages/react-native/React/CoreModules/RCTAccessibilityManager+Internal.h index 36842eeb214d45..6e180007fdcaa9 100644 --- a/packages/react-native/React/CoreModules/RCTAccessibilityManager+Internal.h +++ b/packages/react-native/React/CoreModules/RCTAccessibilityManager+Internal.h @@ -16,7 +16,7 @@ RCT_EXTERN_C_BEGIN // Only to be used for testing and internal tooling. Do not use this in // production. void RCTAccessibilityManagerSetIsVoiceOverEnabled( - RCTAccessibilityManager *accessibiltyManager, + RCTAccessibilityManager *accessibilityManager, BOOL isVoiceOverEnabled); RCT_EXTERN_C_END diff --git a/packages/react-native/React/CxxBridge/RCTCxxBridge.mm b/packages/react-native/React/CxxBridge/RCTCxxBridge.mm index 01f78f000479c9..b6d98e411907c5 100644 --- a/packages/react-native/React/CxxBridge/RCTCxxBridge.mm +++ b/packages/react-native/React/CxxBridge/RCTCxxBridge.mm @@ -1005,7 +1005,7 @@ - (void)registerAdditionalModuleClasses:(NSArray *)modules withDispatchGroup:NULL lazilyDiscovered:YES]; assert(_reactInstance); // at this point you must have reactInstance as you already called - // reactInstance->initialzeBridge + // reactInstance->initializeBridge _reactInstance->getModuleRegistry().registerModules(createNativeModules(newModules, self, _reactInstance)); } else { [self registerModulesForClasses:modules]; diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index 6a982a3842012c..99b2bf5764fa04 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -199,7 +199,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & } #endif // [macOS] - // Traits `blurOnSubmit`, `clearTextOnFocus`, and `selectTextOnFocus` were omitted intentially here + // Traits `blurOnSubmit`, `clearTextOnFocus`, and `selectTextOnFocus` were omitted intentionally here // because they are being checked on-demand. // Other props: @@ -557,16 +557,16 @@ - (void)setDefaultInputAccessoryView // These keyboard types (all are number pads) don't have a "Done" button by default, // so we create an `inputAccessoryView` with this button for them. - BOOL shouldHaveInputAccesoryView = - (keyboardType == UIKeyboardTypeNumberPad || keyboardType == UIKeyboardTypePhonePad || - keyboardType == UIKeyboardTypeDecimalPad || keyboardType == UIKeyboardTypeASCIICapableNumberPad) && - _backedTextInputView.returnKeyType == UIReturnKeyDone; + BOOL shouldHaveInputAccessoryView = + (keyboardType == UIKeyboardTypeNumberPad || keyboardType == UIKeyboardTypePhonePad || + keyboardType == UIKeyboardTypeDecimalPad || keyboardType == UIKeyboardTypeASCIICapableNumberPad) && + _backedTextInputView.returnKeyType == UIReturnKeyDone; - if ((_backedTextInputView.inputAccessoryView != nil) == shouldHaveInputAccesoryView) { + if ((_backedTextInputView.inputAccessoryView != nil) == shouldHaveInputAccessoryView) { return; } - if (shouldHaveInputAccesoryView) { + if (shouldHaveInputAccessoryView) { UIToolbar *toolbarView = [UIToolbar new]; [toolbarView sizeToFit]; UIBarButtonItem *flexibleSpace = diff --git a/packages/react-native/React/Fabric/RCTSurfacePointerHandler.mm b/packages/react-native/React/Fabric/RCTSurfacePointerHandler.mm index 5cfb0345c5daad..ac1229e0623b76 100644 --- a/packages/react-native/React/Fabric/RCTSurfacePointerHandler.mm +++ b/packages/react-native/React/Fabric/RCTSurfacePointerHandler.mm @@ -270,14 +270,27 @@ static void UpdatePointerEventModifierFlags(PointerEvent &event, UIKeyModifierFl } } -static PointerEvent CreatePointerEventFromActivePointer(ActivePointer activePointer, RCTPointerEventType eventType) +static PointerEvent CreatePointerEventFromActivePointer( + ActivePointer activePointer, + RCTPointerEventType eventType, + UIView *rootComponentView) { PointerEvent event = {}; event.pointerId = activePointer.identifier; event.pointerType = PointerTypeCStringFromUITouchType(activePointer.touchType); - event.clientPoint = RCTPointFromCGPoint(activePointer.clientPoint); - event.screenPoint = RCTPointFromCGPoint(activePointer.screenPoint); - event.offsetPoint = RCTPointFromCGPoint(activePointer.offsetPoint); + + if (eventType == RCTPointerEventTypeCancel) { + event.clientPoint = RCTPointFromCGPoint(CGPointZero); + event.screenPoint = + RCTPointFromCGPoint([rootComponentView convertPoint:CGPointZero + toCoordinateSpace:rootComponentView.window.screen.coordinateSpace]); + event.offsetPoint = RCTPointFromCGPoint([rootComponentView convertPoint:CGPointZero + toView:activePointer.componentView]); + } else { + event.clientPoint = RCTPointFromCGPoint(activePointer.clientPoint); + event.screenPoint = RCTPointFromCGPoint(activePointer.screenPoint); + event.offsetPoint = RCTPointFromCGPoint(activePointer.offsetPoint); + } event.pressure = activePointer.force; if (@available(iOS 13.4, *)) { @@ -676,7 +689,7 @@ - (void)_dispatchActivePointers:(std::vector)activePointers event { #if !TARGET_OS_OSX // [macOS] for (const auto &activePointer : activePointers) { - PointerEvent pointerEvent = CreatePointerEventFromActivePointer(activePointer, eventType); + PointerEvent pointerEvent = CreatePointerEventFromActivePointer(activePointer, eventType, _rootComponentView); NSOrderedSet *eventPathViews = [self handleIncomingPointerEvent:pointerEvent onView:activePointer.componentView]; @@ -708,6 +721,7 @@ - (void)_dispatchActivePointers:(std::vector)activePointers event } case RCTPointerEventTypeCancel: { eventEmitter->onPointerCancel(pointerEvent); + [self handleIncomingPointerEvent:pointerEvent onView:nil]; break; } } @@ -920,7 +934,7 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer * Private method which is used for tracking the location of pointer events to manage the entering/leaving events. * The primary idea is that a pointer's presence & movement is dicated by a variety of underlying events such as down, * move, and up — and they should all be treated the same when it comes to tracking the entering & leaving of pointers - * to views. This method accomplishes that by recieving the pointer event, the target view (can be null in cases when + * to views. This method accomplishes that by receiving the pointer event, the target view (can be null in cases when * the event indicates that the pointer has left the screen entirely), and a block/callback where the underlying event * should be fired. */ @@ -954,7 +968,7 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer // Leaving - // pointerleave events need to be emited from the deepest target to the root but + // pointerleave events need to be emitted from the deepest target to the root but // we also need to efficiently keep track of if a view has a parent which is listening to the leave events, // so we first iterate from the root to the target, collecting the views which need events fired for, of which // we reverse iterate (now from target to root), actually emitting the events. @@ -999,7 +1013,7 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer // We only want to emit events to JS if there is a view that is currently listening to said event // so we only send those event to the JS side if the element which has been entered is itself listening, // or if one of its parents is listening in case those listeners care about the capturing phase. Adding the ability - // for native to distingusih between capturing listeners and not could be an optimization to futher reduce the number + // for native to distinguish between capturing listeners and not could be an optimization to further reduce the number // of events we send to JS BOOL hasParentEnterListener = NO; for (RCTReactTaggedView *taggedView in [eventPathViews reverseObjectEnumerator]) { diff --git a/packages/react-native/React/Fabric/RCTSurfacePresenter.h b/packages/react-native/React/Fabric/RCTSurfacePresenter.h index 0129e23ec4a8a4..ff5c36c7f09cfc 100644 --- a/packages/react-native/React/Fabric/RCTSurfacePresenter.h +++ b/packages/react-native/React/Fabric/RCTSurfacePresenter.h @@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN /* * Suspends/resumes all surfaces associated with the presenter. - * Suspending is a process or gracefull stopping all surfaces and destroying all underlying infrastructure + * Suspending is a process or graceful stopping all surfaces and destroying all underlying infrastructure * with a future possibility of recreating the infrastructure and restarting the surfaces from scratch. * Suspending is usually a part of a bundle reloading process. * Can be called on any thread. diff --git a/packages/react-native/React/Fabric/Utils/RCTReactTaggedView.h b/packages/react-native/React/Fabric/Utils/RCTReactTaggedView.h index 165731dea33803..db5c37443f3823 100644 --- a/packages/react-native/React/Fabric/Utils/RCTReactTaggedView.h +++ b/packages/react-native/React/Fabric/Utils/RCTReactTaggedView.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN * Lightweight wrapper class around a UIView with a react tag which registers a * constant react tag at initialization time for a stable hash and provides the * udnerlying view to a caller if that underlying view's react tag has not - * changed from the one provided at initalization time (i.e. recycled). + * changed from the one provided at initialization time (i.e. recycled). */ @interface RCTReactTaggedView : NSObject { RCTPlatformView *_view; // [macOS] diff --git a/packages/react-native/React/Modules/RCTEventEmitter.m b/packages/react-native/React/Modules/RCTEventEmitter.m index 38650c34f0dd45..7ad3513ae8c558 100644 --- a/packages/react-native/React/Modules/RCTEventEmitter.m +++ b/packages/react-native/React/Modules/RCTEventEmitter.m @@ -142,7 +142,7 @@ - (void)invalidate #pragma mark - Test utilities // For testing purposes only. -// This is supposed to be overriden by a subclass in the Tests +// This is supposed to be overridden by a subclass in the Tests // to verified that the error message is actually emitted. // This is the less intrusive way found to mock the RCTLogError function in unit tests. - (void)_log:(NSString *)message diff --git a/packages/react-native/React/Profiler/RCTProfileTrampoline-x86_64.S b/packages/react-native/React/Profiler/RCTProfileTrampoline-x86_64.S index f7bb214b14e6f2..246a810d675295 100644 --- a/packages/react-native/React/Profiler/RCTProfileTrampoline-x86_64.S +++ b/packages/react-native/React/Profiler/RCTProfileTrampoline-x86_64.S @@ -90,7 +90,7 @@ SYMBOL_NAME(RCTProfileTrampoline): movq $0x10, %rdi callq SYMBOL_NAME_PIC(RCTProfileMalloc) - // store the initial value of calle saved registers %r13 and %r14 + // store the initial value of caller saved registers %r13 and %r14 movq %r13, 0x0(%rax) movq %r14, 0x8(%rax) diff --git a/packages/react-native/React/Views/SafeAreaView/RCTSafeAreaShadowView.m b/packages/react-native/React/Views/SafeAreaView/RCTSafeAreaShadowView.m index a9a7bee303e301..9b7dbf34d10e0d 100644 --- a/packages/react-native/React/Views/SafeAreaView/RCTSafeAreaShadowView.m +++ b/packages/react-native/React/Views/SafeAreaView/RCTSafeAreaShadowView.m @@ -32,7 +32,7 @@ - (void)setLocalData:(RCTSafeAreaViewLocalData *)localData /** * Removing support for setting padding from any outside code - * to prevent interferring this with local data. + * to prevent interfering this with local data. */ - (void)setPadding:(__unused YGValue)value { diff --git a/packages/react-native/ReactAndroid/build.gradle b/packages/react-native/ReactAndroid/build.gradle index 54dfbd11eb991a..f473ba011bd06a 100644 --- a/packages/react-native/ReactAndroid/build.gradle +++ b/packages/react-native/ReactAndroid/build.gradle @@ -518,6 +518,17 @@ android { } } + buildTypes { + debug { + externalNativeBuild { + cmake { + // We want to build Gtest suite only for the debug variant. + targets "reactnative_unittest" + } + } + } + } + preBuild.dependsOn(prepareJSC, prepareBoost, prepareDoubleConversion, prepareFmt, prepareFolly, prepareGlog, prepareLibevent) preBuild.dependsOn("generateCodegenArtifactsFromSchema") preBuild.dependsOn(preparePrefab) @@ -647,6 +658,17 @@ android { includeBuildTypeValues('debug', 'release') } } + + testOptions { + unitTests.all { + // Robolectric tests are downloading JARs at runtime. This allows to specify + // a local file mirror with REACT_NATIVE_ROBOLECTRIC_MIRROR to go in offline more. + if (System.getenv("REACT_NATIVE_ROBOLECTRIC_MIRROR") != null) { + systemProperty 'robolectric.offline', 'true' + systemProperty 'robolectric.dependency.dir', System.getenv("REACT_NATIVE_ROBOLECTRIC_MIRROR") + } + } + } } dependencies { @@ -681,6 +703,7 @@ dependencies { testImplementation("org.powermock:powermock-classloading-xstream:${POWERMOCK_VERSION}") testImplementation("org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}") testImplementation("org.robolectric:robolectric:${ROBOLECTRIC_VERSION}") + testImplementation("com.thoughtworks.xstream:xstream:1.4.20") androidTestImplementation(fileTree(dir: "src/main/third-party/java/buck-android-support/", include: ["*.jar"])) androidTestImplementation("androidx.test:runner:${ANDROIDX_TEST_VERSION}") @@ -701,6 +724,26 @@ react { jsRootDir = file("../Libraries") } +tasks.withType(Test).all { + // We add --add-opens flags to make sure we can run PowerMock tests on JDK >= 17 + if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) { + jvmArgs += [ + "-XX:+AllowRedefinitionToAddDeleteMethods", + "--illegal-access=permit", + "--add-opens=java.base/java.lang=ALL-UNNAMED", + "--add-opens=java.base/java.xml.internal=ALL-UNNAMED", + "--add-opens=java.base/java.util=ALL-UNNAMED", + "--add-opens=java.base/java.util.concurrent=ALL-UNNAMED", + "--add-opens=java.base/java.net=ALL-UNNAMED", + "--add-opens=java.base/java.security=ALL-UNNAMED", + "--add-opens=java.base/java.io=ALL-UNNAMED", + "--add-opens=java.base/java.nio=ALL-UNNAMED", + "--add-opens=java.base/java.nio.charset=ALL-UNNAMED", + "--add-opens=java.base/jdk.xml.internal=ALL-UNNAMED", + ] + } +} + apply plugin: "org.jetbrains.kotlin.android" /* Publishing Configuration */ diff --git a/packages/react-native/ReactAndroid/gradle.properties b/packages/react-native/ReactAndroid/gradle.properties index 1801c32f949219..5843fa9dfbb21a 100644 --- a/packages/react-native/ReactAndroid/gradle.properties +++ b/packages/react-native/ReactAndroid/gradle.properties @@ -12,13 +12,13 @@ FRESCO_VERSION=2.5.0 INFER_ANNOTATIONS_VERSION=0.18.0 JAVAX_INJECT_VERSION=1 JSR305_VERSION=3.0.2 -JUNIT_VERSION=4.12 -MOCKITO_CORE_VERSION=2.26.0 +JUNIT_VERSION=4.13.2 +MOCKITO_CORE_VERSION=2.28.2 OKHTTP_VERSION=4.9.2 OKIO_VERSION=2.9.0 -POWERMOCK_VERSION=2.0.2 +POWERMOCK_VERSION=2.0.9 PROGUARD_ANNOTATIONS_VERSION=1.19.0 -ROBOLECTRIC_VERSION=4.4 +ROBOLECTRIC_VERSION=4.9.2 SO_LOADER_VERSION=0.10.5 SWIPEREFRESH_LAYOUT_VERSION=1.0.0 diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 2921c45924a853..844050e739eb1f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -387,7 +387,7 @@ public void registerCxxErrorHandlerFunc() { try { handleCxxErrorFunc = ReactInstanceManager.class.getMethod("handleCxxError", parameterTypes); } catch (NoSuchMethodException e) { - FLog.e("ReactInstanceHolder", "Failed to set cxx error hanlder function", e); + FLog.e("ReactInstanceHolder", "Failed to set cxx error handler function", e); } ReactCxxErrorHandler.setHandleErrorFunc(this, handleCxxErrorFunc); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/AnimationDriver.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/AnimationDriver.java index cd627d2809a443..fc77deed5bb51b 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/AnimationDriver.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/AnimationDriver.java @@ -31,7 +31,7 @@ /** * This method will get called when some of the configuration gets updated while the animation is * running. In that case animation should restart keeping its internal state to provide a smooth - * transision. E.g. in case of a spring animation we want to keep the current value and speed and + * transition. E.g. in case of a spring animation we want to keep the current value and speed and * start animating with the new properties (different destination or spring settings) */ public void resetConfig(ReadableMap config) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java index 06ffc04af6bab1..c0b4517f7e39a9 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java @@ -17,7 +17,7 @@ /** * A higher level API on top of the asynchronous JSC bridge. This provides an environment allowing - * the invocation of JavaScript methods and lets a set of Java APIs be invokable from JavaScript as + * the invocation of JavaScript methods and lets a set of Java APIs be invocable from JavaScript as * well. */ @DoNotStrip diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java index 3fef9e8f284735..2c8346471a2841 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java @@ -46,7 +46,7 @@ public class ModuleHolder { private final ReactModuleInfo mReactModuleInfo; private @Nullable Provider mProvider; - // Outside of the constructur, these should only be checked or set when synchronized on this + // Outside of the constructor, these should only be checked or set when synchronized on this private @Nullable @GuardedBy("this") NativeModule mModule; // These are used to communicate phases of creation and initialization across threads diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java index c5ea09166e882d..82cc5b393c90f8 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java @@ -973,7 +973,7 @@ public void reloadJSFromServer(final String bundleURL, final BundleLoadCallback public void onSuccess() { hideDevLoadingView(); synchronized (DevSupportManagerBase.this) { - mBundleStatus.isLastDownloadSucess = true; + mBundleStatus.isLastDownloadSuccess = true; mBundleStatus.updateTimestamp = System.currentTimeMillis(); } if (mBundleDownloadListener != null) { @@ -998,7 +998,7 @@ public void onProgress( public void onFailure(final Exception cause) { hideDevLoadingView(); synchronized (DevSupportManagerBase.this) { - mBundleStatus.isLastDownloadSucess = false; + mBundleStatus.isLastDownloadSuccess = false; } if (mBundleDownloadListener != null) { mBundleDownloadListener.onFailure(cause); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java index b3cf5afcf098e1..75b5865371759b 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java @@ -157,7 +157,7 @@ private JSONArray getPages() throws JSONException { jsonPage.put("title", page.getTitle()); jsonPage.put("app", mPackageName); jsonPage.put("vm", page.getVM()); - jsonPage.put("isLastBundleDownloadSuccess", bundleStatus.isLastDownloadSucess); + jsonPage.put("isLastBundleDownloadSuccess", bundleStatus.isLastDownloadSuccess); jsonPage.put("bundleUpdateTimestamp", bundleStatus.updateTimestamp); array.put(jsonPage); } @@ -319,11 +319,11 @@ private void closeWebSocketQuietly() { } public static class BundleStatus { - public Boolean isLastDownloadSucess; + public Boolean isLastDownloadSuccess; public long updateTimestamp = -1; - public BundleStatus(Boolean isLastDownloadSucess, long updateTimestamp) { - this.isLastDownloadSucess = isLastDownloadSucess; + public BundleStatus(Boolean isLastDownloadSuccess, long updateTimestamp) { + this.isLastDownloadSuccess = isLastDownloadSuccess; this.updateTimestamp = updateTimestamp; } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/.clang-tidy b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/.clang-tidy +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/DevToolsReactPerfLogger.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/DevToolsReactPerfLogger.java index d62ae267cbe38b..9a233ec5b052fc 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/DevToolsReactPerfLogger.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/DevToolsReactPerfLogger.java @@ -180,7 +180,7 @@ public long getUpdateUIMainThreadEnd() { return getValue(FABRIC_UPDATE_UI_MAIN_THREAD_END); } - // Duration calcuations + // Duration calculations public long getCommitDuration() { return getCommitEnd() - getCommitStart(); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java index f514ade64b2821..124c35f974d6fe 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java @@ -1468,7 +1468,7 @@ public void doFrameGuarded(long frameTimeNanos) { // subtree instead of recursing further. if (childrenAreManaged) { try { - // This can happen if the removeAllViews method is overriden to throw, + // This can happen if the removeAllViews method is overridden to throw, // which it is explicitly in some cases (for example embedded Litho views, // but there could be other cases). In those cases, we want to fail silently // and then assume the subtree is /not/ managed by React Native. diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/.clang-tidy b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/.clang-tidy +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/AccessibilityInfoModule.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/AccessibilityInfoModule.java index af15c861c56557..a21b048c97937f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/AccessibilityInfoModule.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/AccessibilityInfoModule.java @@ -100,10 +100,15 @@ public AccessibilityInfoModule(ReactApplicationContext context) { @TargetApi(Build.VERSION_CODES.LOLLIPOP) private boolean getIsReduceMotionEnabledValue() { - String value = + // Disabling animations in developer settings will set the animation scale to "0.0" + // but setting "reduce motion" / "disable animations" will set the animation scale to "0". + String rawValue = Settings.Global.getString(mContentResolver, Settings.Global.TRANSITION_ANIMATION_SCALE); - return value != null && value.equals("0.0"); + // Parse the value as a float so we can check for a single value. + Float parsedValue = rawValue != null ? Float.parseFloat(rawValue) : 1f; + + return parsedValue == 0f; } @Override diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/.clang-tidy b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/.clang-tidy +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java index 1a87bb7de2e84d..09ee5ea42b6bca 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java @@ -115,7 +115,7 @@ protected T prepareToRecycleView(@NonNull ThemedReactContext reactContext, T vie view.setNextFocusRightId(View.NO_ID); view.setNextFocusUpId(View.NO_ID); - // This is possibly subject to change and overrideable per-platform, but these + // This is possibly subject to change and overridable per-platform, but these // are the default view flags in View.java: // https://android.googlesource.com/platform/frameworks/base/+/a175a5b/core/java/android/view/View.java#2712 // `mViewFlags = SOUND_EFFECTS_ENABLED | HAPTIC_FEEDBACK_ENABLED | LAYOUT_DIRECTION_INHERIT` diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java index 2015936aab549d..c2e3023d026955 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -373,7 +373,7 @@ private Set getPendingDeletionsForTag(int tag) { /** * @param tag react tag of the node we want to manage - * @param indicesToRemove ordered (asc) list of indicies at which view should be removed + * @param indicesToRemove ordered (asc) list of indices at which view should be removed * @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent * a view which should be added at the specified index * @param tagsToDelete list of tags corresponding to views that should be removed diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index b6cca3dee09ab7..ed4ec63c05d5b3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -301,7 +301,7 @@ protected void handleUpdateView( * Invoked when there is a mutation in a node tree. * * @param tag react tag of the node we want to manage - * @param indicesToRemove ordered (asc) list of indicies at which view should be removed + * @param indicesToRemove ordered (asc) list of indices at which view should be removed * @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent * a view which should be added at the specified index * @param tagsToDelete list of tags corresponding to views that should be removed 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 17f975e63dc9d5..6c5a085af7fb51 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 @@ -234,7 +234,7 @@ public void onDropViewInstance(@NonNull T view) { } /** - * Called when a View is removed from the hierachy. This should be used to reset any properties. + * Called when a View is removed from the hierarchy. This should be used to reset any properties. */ protected T prepareToRecycleView(@NonNull ThemedReactContext reactContext, @NonNull T view) { return view; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java index 01b355def8b8be..2178af11f7a8ce 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java @@ -77,7 +77,7 @@ protected void init(int surfaceId, int viewTag, long timestampMs) { // // Why does this matter? // Events can be sent to Views that are part of the View hierarchy *but not directly managed - // by React Native*. For example, embedded custom hierachies, Litho hierachies, etc. + // by React Native*. For example, embedded custom hierarchies, Litho hierarchies, etc. // In those cases it's important to know that the Event should be sent to the Fabric or // non-Fabric UIManager, and we cannot use the ViewTag for inference since it's not controlled // by RN and is essentially a random number. diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java index f681465620f8e4..f148dcda3bec00 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java @@ -90,8 +90,8 @@ public void setDecelerationRate(ReactHorizontalScrollView view, float decelerati @ReactProp(name = "disableIntervalMomentum") public void setDisableIntervalMomentum( - ReactHorizontalScrollView view, boolean disbaleIntervalMomentum) { - view.setDisableIntervalMomentum(disbaleIntervalMomentum); + ReactHorizontalScrollView view, boolean disableIntervalMomentum) { + view.setDisableIntervalMomentum(disableIntervalMomentum); } @ReactProp(name = "snapToInterval") diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java index e6464ab6ef2dec..46e0ccf36c6e9d 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java @@ -89,8 +89,8 @@ public void setDecelerationRate(ReactScrollView view, float decelerationRate) { } @ReactProp(name = "disableIntervalMomentum") - public void setDisableIntervalMomentum(ReactScrollView view, boolean disbaleIntervalMomentum) { - view.setDisableIntervalMomentum(disbaleIntervalMomentum); + public void setDisableIntervalMomentum(ReactScrollView view, boolean disableIntervalMomentum) { + view.setDisableIntervalMomentum(disableIntervalMomentum); } @ReactProp(name = "snapToInterval") diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index 6e2e24cc29eaa1..07c95b243db62e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -587,7 +587,7 @@ public void maybeSetText(ReactTextUpdate reactTextUpdate) { manageSpans(spannableStringBuilder, reactTextUpdate.mContainsMultipleFragments); // Mitigation for https://github.com/facebook/react-native/issues/35936 (S318090) - stripAtributeEquivalentSpans(spannableStringBuilder); + stripAttributeEquivalentSpans(spannableStringBuilder); mContainsImages = reactTextUpdate.containsImages(); @@ -662,7 +662,7 @@ private void manageSpans( } } - private void stripAtributeEquivalentSpans(SpannableStringBuilder sb) { + private void stripAttributeEquivalentSpans(SpannableStringBuilder sb) { // We have already set a font size on the EditText itself. We can safely remove sizing spans // which are the same as the set font size, and not otherwise overlapped. final int effectiveFontSize = mTextAttributes.getEffectiveFontSize(); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index 43aaa140697831..706b0f0515e50a 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -191,10 +191,10 @@ public ReactEditText createViewInstance(ThemedReactContext context) { int inputType = editText.getInputType(); editText.setInputType(inputType & (~InputType.TYPE_TEXT_FLAG_MULTI_LINE)); editText.setReturnKeyType("done"); - // Set defult layoutParams to avoid NullPointerException to be thrown by Android EditTextView + // Set default layoutParams to avoid NullPointerException to be thrown by Android EditTextView // when update props (PlaceHolder) is executed before the view is layout. // This change should not affect layout for TextInput components because layout will be - // overriden on the first RN commit. + // overridden on the first RN commit. editText.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); @@ -883,7 +883,7 @@ public void setKeyboardType(ReactEditText view, @Nullable String keyboardType) { } else if (KEYBOARD_TYPE_PHONE_PAD.equalsIgnoreCase(keyboardType)) { flagsToSet = InputType.TYPE_CLASS_PHONE; } else if (KEYBOARD_TYPE_VISIBLE_PASSWORD.equalsIgnoreCase(keyboardType)) { - // This will supercede secureTextEntry={false}. If it doesn't, due to the way + // This will supersede secureTextEntry={false}. If it doesn't, due to the way // the flags work out, the underlying field will end up a URI-type field. flagsToSet = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD; } else if (KEYBOARD_TYPE_URI.equalsIgnoreCase(keyboardType)) { diff --git a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt index 64f91231eb3727..824d4216c95724 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt @@ -78,6 +78,7 @@ add_react_common_subdir(react/renderer/telemetry) add_react_common_subdir(react/renderer/templateprocessor) add_react_common_subdir(react/renderer/uimanager) add_react_common_subdir(react/renderer/core) +add_react_common_subdir(react/renderer/element) add_react_common_subdir(react/renderer/graphics) add_react_common_subdir(react/renderer/debug) add_react_common_subdir(react/renderer/imagemanager) @@ -116,3 +117,109 @@ add_react_android_subdir(src/main/jni/react/fabric) add_react_android_subdir(src/main/jni/react/newarchdefaults) add_react_android_subdir(src/main/jni/react/hermes/reactexecutor) add_react_android_subdir(src/main/jni/react/hermes/instrumentation/) + +# GTest setup +set(GOOGLETEST_ROOT ${ANDROID_NDK}/sources/third_party/googletest) +add_library(gtest STATIC ${GOOGLETEST_ROOT}/src/gtest_main.cc ${GOOGLETEST_ROOT}/src/gtest-all.cc) +target_include_directories(gtest PRIVATE ${GOOGLETEST_ROOT}) +target_include_directories(gtest PUBLIC ${GOOGLETEST_ROOT}/include) + +# GTest dependencies +add_executable(reactnative_unittest + ${REACT_COMMON_DIR}/cxxreact/tests/jsarg_helpers.cpp + ${REACT_COMMON_DIR}/cxxreact/tests/jsbigstring.cpp + ${REACT_COMMON_DIR}/cxxreact/tests/methodcall.cpp + ${REACT_COMMON_DIR}/cxxreact/tests/RecoverableErrorTest.cpp + ${REACT_COMMON_DIR}/hermes/inspector/chrome/tests/MessageTests.cpp + ${REACT_COMMON_DIR}/hermes/inspector/chrome/tests/RemoteObjectsTableTest.cpp + ${REACT_COMMON_DIR}/react/bridging/tests/BridgingTest.cpp + ${REACT_COMMON_DIR}/react/renderer/attributedstring/tests/AttributedStringBoxTest.cpp + ${REACT_COMMON_DIR}/react/renderer/attributedstring/tests/AttributedStringTest.cpp + ${REACT_COMMON_DIR}/react/renderer/attributedstring/tests/ParagraphAttributesTest.cpp + ${REACT_COMMON_DIR}/react/renderer/attributedstring/tests/TextAttributesTest.cpp + ${REACT_COMMON_DIR}/react/renderer/components/image/tests/ImageTest.cpp + ${REACT_COMMON_DIR}/react/renderer/components/root/tests/RootShadowNodeTest.cpp + ${REACT_COMMON_DIR}/react/renderer/components/scrollview/tests/ScrollViewTest.cpp + ${REACT_COMMON_DIR}/react/renderer/components/text/tests/ParagraphLocalDataTest.cpp + ${REACT_COMMON_DIR}/react/renderer/components/text/tests/TextTest.cpp + ${REACT_COMMON_DIR}/react/renderer/components/view/tests/LayoutTest.cpp + ${REACT_COMMON_DIR}/react/renderer/components/view/tests/ViewTest.cpp + ${REACT_COMMON_DIR}/react/renderer/core/tests/DynamicPropsUtilitiesTest.cpp + ${REACT_COMMON_DIR}/react/renderer/core/tests/EventQueueProcessorTest.cpp + ${REACT_COMMON_DIR}/react/renderer/core/tests/FindNodeAtPointTest.cpp + ${REACT_COMMON_DIR}/react/renderer/core/tests/LayoutableShadowNodeTest.cpp + ${REACT_COMMON_DIR}/react/renderer/core/tests/PrimitivesTest.cpp + ${REACT_COMMON_DIR}/react/renderer/core/tests/RawPropsTest.cpp + ${REACT_COMMON_DIR}/react/renderer/core/tests/ShadowNodeFamilyTest.cpp + ${REACT_COMMON_DIR}/react/renderer/core/tests/traitCastTest.cpp + ${REACT_COMMON_DIR}/react/renderer/debug/tests/DebugStringConvertibleTest.cpp + ${REACT_COMMON_DIR}/react/renderer/element/tests/ElementTest.cpp + ${REACT_COMMON_DIR}/react/renderer/graphics/tests/GraphicsTest.cpp + ${REACT_COMMON_DIR}/react/renderer/graphics/tests/TransformTest.cpp + ${REACT_COMMON_DIR}/react/renderer/imagemanager/tests/ImageManagerTest.cpp + ${REACT_COMMON_DIR}/react/renderer/mapbuffer/tests/MapBufferTest.cpp + ${REACT_COMMON_DIR}/react/renderer/mounting/tests/StackingContextTest.cpp + ${REACT_COMMON_DIR}/react/renderer/mounting/tests/StateReconciliationTest.cpp + ${REACT_COMMON_DIR}/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp + ${REACT_COMMON_DIR}/react/renderer/runtimescheduler/tests/SchedulerPriorityTest.cpp + ${REACT_COMMON_DIR}/react/renderer/telemetry/tests/TransactionTelemetryTest.cpp + ${REACT_COMMON_DIR}/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp + ${REACT_COMMON_DIR}/react/renderer/textlayoutmanager/tests/TextLayoutManagerTest.cpp + ${REACT_COMMON_DIR}/react/renderer/uimanager/tests/FabricUIManagerTest.cpp + + ########## (COMPILE BUT FAIL ON ASSERTS) ########### + # ${REACT_COMMON_DIR}/react/renderer/animations/tests/LayoutAnimationTest.cpp + # ${REACT_COMMON_DIR}/react/renderer/mounting/tests/MountingTest.cpp + # ${REACT_COMMON_DIR}/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp + + ########## (COMPILE BUT FAIL WITH RUNTIME EXCEPTIONS) ########### + # ${REACT_COMMON_DIR}/hermes/inspector/chrome/tests/ConnectionDemuxTests.cpp + # ${REACT_COMMON_DIR}/hermes/inspector/detail/tests/SerialExecutorTests.cpp + # ${REACT_COMMON_DIR}/hermes/inspector/tests/InspectorTests.cpp + + ########## (DO NOT COMPILE) ########### + # ${REACT_COMMON_DIR}/react/renderer/core/tests/ShadowNodeTest.cpp + # ${REACT_COMMON_DIR}/react/renderer/core/tests/ConcreteShadowNodeTest.cpp + # ${REACT_COMMON_DIR}/react/renderer/core/tests/ComponentDescriptorTest.cpp + # ${REACT_COMMON_DIR}/hermes/inspector/chrome/tests/ConnectionTests.cpp + ) + target_compile_options(reactnative_unittest + PRIVATE + -Wall + -Werror + -fexceptions + -frtti + -std=c++17 + -DANDROID + -DHERMES_ENABLE_DEBUGGER) + + target_link_libraries(reactnative_unittest + folly_runtime + folly_futures + glog + glog_init + gtest + hermes-engine::libhermes + hermes_inspector + jsi + react_codegen_rncore + react_debug + react_render_animations + react_render_attributedstring + react_render_core + react_render_debug + react_render_element + react_render_graphics + react_render_mapbuffer + react_render_mounting + react_render_templateprocessor + react_render_textlayoutmanager + react_render_uimanager + react_utils + reactnative + rrc_modal + rrc_scrollview + rrc_text + rrc_view + yoga +) diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/.clang-tidy b/packages/react-native/ReactAndroid/src/main/jni/first-party/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/.clang-tidy +++ b/packages/react-native/ReactAndroid/src/main/jni/first-party/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/.clang-tidy b/packages/react-native/ReactAndroid/src/main/jni/react/jni/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/.clang-tidy +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jni/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-af/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-af/strings.xml index 2ac5f222d3ddcf..24e1b69fe6b4ef 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-af/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-af/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ar/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ar/strings.xml index f493c38e051890..9ee5b1218296dd 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ar/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ar/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-as/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-as/strings.xml index 6f7fecbce1a5d7..7224dbc28d87b8 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-as/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-as/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-az/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-az/strings.xml index ad4b43e7f07b06..8d1df4784531c0 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-az/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-az/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-be/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-be/strings.xml new file mode 100644 index 00000000000000..ce84b2af7e3b2d --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-be/strings.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-bg/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-bg/strings.xml index 0dbf0001273d9d..09b7b31c671dab 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-bg/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-bg/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-bn/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-bn/strings.xml index 4af0c011730c03..b5d516623ef92f 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-bn/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-bn/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-bs/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-bs/strings.xml index 83bfd3e44a5700..6360c5c0799ee6 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-bs/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-bs/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ca/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ca/strings.xml index 18a70667d257e2..d839c0b739be71 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ca/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ca/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-cb/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-cb/strings.xml index a936c2b60046d5..89de99e2b6bf58 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-cb/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-cb/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-cs/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-cs/strings.xml index 1d7a37be546f94..b556b85f3bc390 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-cs/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-cs/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-da/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-da/strings.xml index ee825766595051..1fd6723b3bae1f 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-da/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-da/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-de/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-de/strings.xml index e1b0f2a0868948..b4629c93404814 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-de/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-de/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-el/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-el/strings.xml index 53281c136f91aa..0604fa12ac1e99 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-el/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-el/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-en-rGB/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-en-rGB/strings.xml index 4ce9e91aec791f..49147780ee63b5 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-en-rGB/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-en-rGB/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-es-rES/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-es-rES/strings.xml index ee27f4a0f34130..025a080a25a9f8 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-es-rES/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-es-rES/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-es/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-es/strings.xml index 228d615198d11e..bfb1514177a8c5 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-es/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-es/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-et/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-et/strings.xml index ccb6ac6b138265..e17476d14d8823 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-et/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-et/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fa/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fa/strings.xml index d571b0a8e8a66e..72270d97102a7c 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fa/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fa/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fb-rLS/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fb-rLS/strings.xml index 3e5736ed0a40d6..d531cc7909261f 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fb-rLS/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fb-rLS/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fb/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fb/strings.xml index 57006902eaa3be..aee984ff543edb 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fb/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fb/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fi/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fi/strings.xml index 621122257609d8..7c49d51816ed44 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fi/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fi/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fr-rCA/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fr-rCA/strings.xml index a91bb8ab1152b6..d5fe3fb4a959d0 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fr-rCA/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fr-rCA/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fr/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fr/strings.xml index 56588926319f67..64b98fc6a925f6 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fr/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-fr/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-gu/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-gu/strings.xml index f3174fd2091212..2a2946b617eb63 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-gu/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-gu/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ha/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ha/strings.xml new file mode 100644 index 00000000000000..084b1b6aac0de0 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ha/strings.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hi/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hi/strings.xml index 41f3ba790ab367..3bca368f01586b 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hi/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hi/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hr/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hr/strings.xml index 0112dc17382391..97250a3e1f6a4c 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hr/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hr/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hu/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hu/strings.xml index ca3ba7246645d7..7c28e052110cd6 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hu/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hu/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hy/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hy/strings.xml new file mode 100644 index 00000000000000..9fc19db9a6a210 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-hy/strings.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-in/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-in/strings.xml index dee75b1336ba11..6d32bd7238156f 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-in/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-in/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-is/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-is/strings.xml index 86daafa18f13c9..e4a30caa711f08 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-is/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-is/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-it/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-it/strings.xml index eb0618ab43872e..89dcf449cfb41d 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-it/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-it/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-iw/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-iw/strings.xml index 2ee633a590b3d4..dcca08e175b5d0 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-iw/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-iw/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ja/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ja/strings.xml index afe0efd6bc18c7..437a25fe2bea8f 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ja/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ja/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-jv/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-jv/strings.xml new file mode 100644 index 00000000000000..5bc93b9a564110 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-jv/strings.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ka/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ka/strings.xml index a2d62ddd0301f7..1c2a251fabd607 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ka/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ka/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-kk/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-kk/strings.xml new file mode 100644 index 00000000000000..f2afa0349f18f9 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-kk/strings.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-km/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-km/strings.xml index b9f9cb3c28f9de..d6ed5fadf8cf0f 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-km/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-km/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-kn/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-kn/strings.xml index 249740599094f2..b4a93b39ff0be2 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-kn/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-kn/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ko/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ko/strings.xml index a06e326655cb42..ba310011f0d554 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ko/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ko/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ku/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ku/strings.xml new file mode 100644 index 00000000000000..60ec646388c582 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ku/strings.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ky/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ky/strings.xml new file mode 100644 index 00000000000000..8bdeee47c0d67f --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ky/strings.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-lo/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-lo/strings.xml index 72a0480d3d46ea..d35f4bd7efb9eb 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-lo/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-lo/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-lt/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-lt/strings.xml index 0a9ee397a3d843..c3177bbf23299d 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-lt/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-lt/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-lv/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-lv/strings.xml index a617e2c5f6b15a..a66be9d1d970c9 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-lv/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-lv/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-mk/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-mk/strings.xml index b519c79b5d30a0..1c76e1bb07c64e 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-mk/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-mk/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ml/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ml/strings.xml index 0421596adc473a..5d568f33232987 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ml/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ml/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-mn/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-mn/strings.xml index d2249cef82b692..2f27b04d30db45 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-mn/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-mn/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-mr/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-mr/strings.xml index 06650b35cde3bf..ad239221c0e924 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-mr/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-mr/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ms/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ms/strings.xml index 3254e7a4de1852..443eca7a57e1f8 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ms/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ms/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-my/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-my/strings.xml index 35aed12121980e..65abfdbf7bd192 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-my/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-my/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-nb/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-nb/strings.xml index ab5d7818ff708a..873742c208ac05 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-nb/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-nb/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ne/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ne/strings.xml index e986ad9ab7c83c..47a8e78d014c40 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ne/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ne/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-nl/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-nl/strings.xml index dc4c14ae831434..75355cf16bd979 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-nl/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-nl/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pa/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pa/strings.xml index f1994ddd214354..ea45e686429267 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pa/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pa/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pl/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pl/strings.xml index 1f396b72c3f19f..4f53d3ec705bb8 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pl/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pl/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ps/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ps/strings.xml new file mode 100644 index 00000000000000..d86dbade5fa188 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ps/strings.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pt-rPT/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pt-rPT/strings.xml index 2081dde129f293..a0d4564f7f0932 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pt-rPT/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pt-rPT/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pt/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pt/strings.xml index ebe70acac7e0b2..3a24466f7006cd 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pt/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-pt/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-qz/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-qz/strings.xml index 2bad18d0dfe269..57089df8cbebff 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-qz/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-qz/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ro/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ro/strings.xml index 551623e97e361d..445f1af124553e 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ro/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ro/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ru/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ru/strings.xml index 38e533eaf81cab..1105ec010ea037 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ru/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ru/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-si/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-si/strings.xml index 48b45a522bec6a..2153d88a0669fb 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-si/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-si/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sk/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sk/strings.xml index a7b69ad9337c3d..2d1768d211d54d 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sk/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sk/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sl/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sl/strings.xml index 2fde2cc7cc9b96..a8d2a680928b58 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sl/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sl/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sn/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sn/strings.xml index a585ebb08157d6..ed69640542f946 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sn/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sn/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-so/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-so/strings.xml new file mode 100644 index 00000000000000..bf64cbaf06b979 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-so/strings.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sq/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sq/strings.xml index 0004bf85b658a4..a225539656b409 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sq/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sq/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sr/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sr/strings.xml index 44a106992d3ed8..47782d7cf1000e 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sr/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sr/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sv/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sv/strings.xml index 3b69b622d30a89..2eed9288127946 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sv/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sv/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sw/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sw/strings.xml index 9a632fd5131307..6dea5b85bb9a65 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sw/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-sw/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ta/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ta/strings.xml index 4f2782cb2ea799..f8bfd1c350e5e0 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ta/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ta/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-te/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-te/strings.xml index 87a19868db8e0f..241b213130fe0a 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-te/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-te/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tg/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tg/strings.xml new file mode 100644 index 00000000000000..330b5d77cf1e83 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tg/strings.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-th/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-th/strings.xml index 21c5c6becd58e6..a4206503879525 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-th/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-th/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tk/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tk/strings.xml new file mode 100644 index 00000000000000..abee0e9ebcd3f8 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tk/strings.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tl/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tl/strings.xml index 83fab2e66d3e6d..dadacb703c930c 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tl/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tl/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tr/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tr/strings.xml index 4b59dbd4bcbc8b..755cf862c5eb9e 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tr/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-tr/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-uk/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-uk/strings.xml index ba21f8c7e73053..bf3cc46d1cb490 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-uk/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-uk/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ur/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ur/strings.xml index 20afa4784dcead..6d76f390ea068a 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ur/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-ur/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-uz/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-uz/strings.xml new file mode 100644 index 00000000000000..9d4667fa9877e6 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-uz/strings.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-vi/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-vi/strings.xml index d6f0df91310d87..706622a3be9832 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-vi/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-vi/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-wo/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-wo/strings.xml index f052e42adf9a5b..b7de40359f547d 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-wo/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-wo/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zh-rCN/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zh-rCN/strings.xml index d3c30bf0c25374..c50c06c1a71bf2 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zh-rCN/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zh-rCN/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zh-rHK/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zh-rHK/strings.xml index 29bd2a96566a3e..067865f00e1e61 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zh-rHK/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zh-rHK/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zh-rTW/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zh-rTW/strings.xml index 2e57ad05c5952e..c56baa9ccc27f0 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zh-rTW/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zh-rTW/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zu/strings.xml b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zu/strings.xml index cf05696f4b856e..44cf81d27ef227 100644 --- a/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zu/strings.xml +++ b/packages/react-native/ReactAndroid/src/main/res/devsupport/values-zu/strings.xml @@ -2,6 +2,5 @@ - diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/ReactActivityDelegateTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/ReactActivityDelegateTest.kt index fbea7048f02fcf..dcf9da8ed02ee3 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/ReactActivityDelegateTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/ReactActivityDelegateTest.kt @@ -22,7 +22,7 @@ class ReactActivityDelegateTest { object : ReactActivityDelegate(null, "test-delegate") { override fun isFabricEnabled() = true public val inspectLaunchOptions: Bundle? - get() = getLaunchOptions() + get() = composeLaunchOptions() } assertNotNull(delegate.inspectLaunchOptions) @@ -36,7 +36,7 @@ class ReactActivityDelegateTest { object : ReactActivityDelegate(null, "test-delegate") { override fun isFabricEnabled() = false public val inspectLaunchOptions: Bundle? - get() = getLaunchOptions() + get() = composeLaunchOptions() } assertNull(delegate.inspectLaunchOptions) @@ -50,7 +50,7 @@ class ReactActivityDelegateTest { override fun getLaunchOptions(): Bundle = Bundle().apply { putString("test-property", "test-value") } public val inspectLaunchOptions: Bundle? - get() = getLaunchOptions() + get() = composeLaunchOptions() } assertNotNull(delegate.inspectLaunchOptions) diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java index 273b01af56b48e..3346b5205526e8 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.java @@ -8,8 +8,8 @@ package com.facebook.react; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.spy; diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.java index 4a77639eec142e..a587bcb2c4c693 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.java @@ -8,9 +8,9 @@ package com.facebook.react.animated; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.atMost; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/BaseJavaModuleTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/BaseJavaModuleTest.java index 27537562e590a4..6e88e4d9f67fdd 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/BaseJavaModuleTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/BaseJavaModuleTest.java @@ -12,6 +12,7 @@ import com.facebook.soloader.SoLoader; import java.util.List; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -25,6 +26,7 @@ @PrepareForTest({ReadableNativeArray.class, SoLoader.class}) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) @RunWith(RobolectricTestRunner.class) +@Ignore("Ignored due to unsupported mocking mechanism with JDK 18") public class BaseJavaModuleTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java index ba1511ee9ae611..f85c34332e1042 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java @@ -7,12 +7,18 @@ package com.facebook.react.devsupport; -import static org.mockito.Mockito.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isA; +import static org.mockito.ArgumentMatchers.nullable; +import static org.mockito.Mockito.never; import com.facebook.react.common.JavascriptException; import java.util.HashMap; import okhttp3.WebSocket; import okio.ByteString; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -25,6 +31,7 @@ @PrepareForTest({JSDebuggerWebSocketClient.class}) @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore("Ignored due to unsupported mocking mechanism with JDK 18") public class JSDebuggerWebSocketClientTest { @Rule public PowerMockRule rule = new PowerMockRule(); @@ -76,7 +83,8 @@ public void test_onMessage_WithInvalidContentType_ShouldNotTriggerCallbacks() th JSDebuggerWebSocketClient client = PowerMockito.spy(new JSDebuggerWebSocketClient()); client.onMessage( - mock(WebSocket.class), ByteString.encodeUtf8("{\"replyID\":0, \"result\":\"OK\"}")); + PowerMockito.mock(WebSocket.class), + ByteString.encodeUtf8("{\"replyID\":0, \"result\":\"OK\"}")); PowerMockito.verifyPrivate(client, never()) .invoke("triggerRequestSuccess", anyInt(), nullable(String.class)); PowerMockito.verifyPrivate(client, never()).invoke("triggerRequestFailure", anyInt(), any()); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.java index eb748ea20892b9..03ab6bc78100df 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.java @@ -11,8 +11,8 @@ import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; -import static org.powermock.api.mockito.PowerMockito.doAnswer; -import static org.powermock.api.mockito.PowerMockito.mock; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; import android.util.DisplayMetrics; import android.view.MotionEvent; @@ -27,7 +27,6 @@ import com.facebook.react.uimanager.events.TouchEvent; import com.facebook.react.uimanager.events.TouchEventCoalescingKeyHelper; import com.facebook.react.uimanager.events.TouchEventType; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -35,7 +34,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.ArgumentMatchers; +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.powermock.api.mockito.PowerMockito; @@ -451,6 +451,8 @@ public class TouchEventDispatchTest { List mDispatchedEvents; FabricEventEmitter mEventEmitter; + FabricUIManager mUIManager; + @Before public void setUp() { PowerMockito.mockStatic(Arguments.class); @@ -478,26 +480,8 @@ public Object answer(InvocationOnMock invocation) { metrics.density = 1f; DisplayMetricsHolder.setWindowDisplayMetrics(metrics); - FabricUIManager fabricUIManager = mock(FabricUIManager.class); - mDispatchedEvents = new ArrayList<>(); - doAnswer( - new Answer() { - @Override - public Void answer(InvocationOnMock invocation) { - mDispatchedEvents.add(invocation.getArgument(5)); - return null; - } - }) - .when(fabricUIManager) - .receiveEvent( - anyInt(), - anyInt(), - anyString(), - anyBoolean(), - anyInt(), - ArgumentMatchers.any(), - anyInt()); - mEventEmitter = new FabricEventEmitter(fabricUIManager); + mUIManager = Mockito.mock(FabricUIManager.class); + mEventEmitter = new FabricEventEmitter(mUIManager); } @Test @@ -505,8 +489,12 @@ public void testFabric_startMoveEnd() { for (TouchEvent event : mStartMoveEndSequence) { event.dispatchModern(mEventEmitter); } + ArgumentCaptor argument = ArgumentCaptor.forClass(WritableMap.class); + verify(mUIManager, times(4)) + .receiveEvent( + anyInt(), anyInt(), anyString(), anyBoolean(), anyInt(), argument.capture(), anyInt()); - assertEquals(mStartMoveEndExpectedSequence, mDispatchedEvents); + assertEquals(mStartMoveEndExpectedSequence, argument.getAllValues()); } @Test @@ -514,8 +502,12 @@ public void testFabric_startMoveCancel() { for (TouchEvent event : mStartMoveCancelSequence) { event.dispatchModern(mEventEmitter); } + ArgumentCaptor argument = ArgumentCaptor.forClass(WritableMap.class); + verify(mUIManager, times(6)) + .receiveEvent( + anyInt(), anyInt(), anyString(), anyBoolean(), anyInt(), argument.capture(), anyInt()); - assertEquals(mStartMoveCancelExpectedSequence, mDispatchedEvents); + assertEquals(mStartMoveCancelExpectedSequence, argument.getAllValues()); } @Test @@ -523,8 +515,12 @@ public void testFabric_startPointerUpCancel() { for (TouchEvent event : mStartPointerMoveUpSequence) { event.dispatchModern(mEventEmitter); } + ArgumentCaptor argument = ArgumentCaptor.forClass(WritableMap.class); + verify(mUIManager, times(6)) + .receiveEvent( + anyInt(), anyInt(), anyString(), anyBoolean(), anyInt(), argument.capture(), anyInt()); - assertEquals(mStartPointerMoveUpExpectedSequence, mDispatchedEvents); + assertEquals(mStartPointerMoveUpExpectedSequence, argument.getAllValues()); } private TouchEvent createTouchEvent( diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/deviceinfo/DeviceInfoModuleTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/deviceinfo/DeviceInfoModuleTest.java index 51ac9605797961..d80a81872038b3 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/deviceinfo/DeviceInfoModuleTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/deviceinfo/DeviceInfoModuleTest.java @@ -8,9 +8,9 @@ package com.facebook.react.modules.deviceinfo; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -80,7 +80,7 @@ public void test_itDoesNotEmitAnEvent_whenDisplayMetricsNotChanged() { mDeviceInfoModule.getTypedExportedConstants(); mDeviceInfoModule.emitUpdateDimensionsEvent(); - verify(mContext, times(0)).emitDeviceEvent(anyString(), anyObject()); + verify(mContext, times(0)).emitDeviceEvent(anyString(), any()); } @Test diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/dialog/DialogModuleTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/dialog/DialogModuleTest.java index 2bde2d61bc4f74..4d0614f3d85f3d 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/dialog/DialogModuleTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/dialog/DialogModuleTest.java @@ -7,9 +7,11 @@ package com.facebook.react.modules.dialog; +import static android.os.Looper.getMainLooper; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.robolectric.Shadows.shadowOf; import android.app.AlertDialog; import android.content.DialogInterface; @@ -19,6 +21,7 @@ import com.facebook.react.bridge.ReactApplicationContext; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.api.mockito.PowerMockito; @@ -29,6 +32,7 @@ @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore("Ignored due to unsupported mocking mechanism with JDK 18") public class DialogModuleTest { private ActivityController mActivityController; @@ -86,8 +90,10 @@ public void testAllOptions() { options.putBoolean("cancelable", false); mDialogModule.showAlert(options, null, null); + shadowOf(getMainLooper()).idle(); final AlertFragment fragment = getFragment(); + assertNotNull("Fragment was not displayed", fragment); assertFalse(fragment.isCancelable()); @@ -104,9 +110,11 @@ public void testCallbackPositive() { final SimpleCallback actionCallback = new SimpleCallback(); mDialogModule.showAlert(options, null, actionCallback); + shadowOf(getMainLooper()).idle(); final AlertDialog dialog = (AlertDialog) getFragment().getDialog(); dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick(); + shadowOf(getMainLooper()).idle(); assertEquals(1, actionCallback.getCalls()); assertEquals(DialogModule.ACTION_BUTTON_CLICKED, actionCallback.getArgs()[0]); @@ -120,9 +128,11 @@ public void testCallbackNegative() { final SimpleCallback actionCallback = new SimpleCallback(); mDialogModule.showAlert(options, null, actionCallback); + shadowOf(getMainLooper()).idle(); final AlertDialog dialog = (AlertDialog) getFragment().getDialog(); dialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick(); + shadowOf(getMainLooper()).idle(); assertEquals(1, actionCallback.getCalls()); assertEquals(DialogModule.ACTION_BUTTON_CLICKED, actionCallback.getArgs()[0]); @@ -136,9 +146,11 @@ public void testCallbackNeutral() { final SimpleCallback actionCallback = new SimpleCallback(); mDialogModule.showAlert(options, null, actionCallback); + shadowOf(getMainLooper()).idle(); final AlertDialog dialog = (AlertDialog) getFragment().getDialog(); dialog.getButton(DialogInterface.BUTTON_NEUTRAL).performClick(); + shadowOf(getMainLooper()).idle(); assertEquals(1, actionCallback.getCalls()); assertEquals(DialogModule.ACTION_BUTTON_CLICKED, actionCallback.getArgs()[0]); @@ -151,8 +163,10 @@ public void testCallbackDismiss() { final SimpleCallback actionCallback = new SimpleCallback(); mDialogModule.showAlert(options, null, actionCallback); + shadowOf(getMainLooper()).idle(); getFragment().getDialog().dismiss(); + shadowOf(getMainLooper()).idle(); assertEquals(1, actionCallback.getCalls()); assertEquals(DialogModule.ACTION_DISMISSED, actionCallback.getArgs()[0]); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.java index d1dc43893059d0..a49e6ebc2c857a 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.java @@ -37,6 +37,7 @@ import okhttp3.RequestBody; import okio.Buffer; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -66,6 +67,7 @@ }) @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore("Ignored due to unsupported mocking mechanism with JDK 18") public class NetworkingModuleTest { private NetworkingModule mNetworkingModule; private OkHttpClient mHttpClient; diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/share/ShareModuleTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/share/ShareModuleTest.java index 2ca9110d5a4cb9..1e245d7789a4db 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/share/ShareModuleTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/share/ShareModuleTest.java @@ -23,6 +23,7 @@ import com.facebook.react.bridge.WritableMap; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -50,6 +51,7 @@ "org.springframework.context.*", "org.apache.log4j.*" }) +@Ignore("Ignored due to unsupported mocking mechanism with JDK 18") public class ShareModuleTest { private Activity mActivity; diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/timing/TimingModuleTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/timing/TimingModuleTest.java index 79b45b2faaeb4c..613fb81773b0a1 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/timing/TimingModuleTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/timing/TimingModuleTest.java @@ -21,6 +21,7 @@ import com.facebook.react.modules.core.ReactChoreographer; import com.facebook.react.modules.core.TimingModule; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -34,10 +35,10 @@ /** Tests for {@link TimingModule}. */ // DISABLED, BROKEN https://circleci.com/gh/facebook/react-native/12068 -// t=13905097 @PrepareForTest({Arguments.class, SystemClock.class, ReactChoreographer.class}) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) @RunWith(RobolectricTestRunner.class) +@Ignore // TODO T13905097 public class TimingModuleTest { private static final long FRAME_TIME_NS = 17 * 1000 * 1000; // 17 ms diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BaseViewManagerTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BaseViewManagerTest.java index b922a06cd23983..95642f5edd9538 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BaseViewManagerTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BaseViewManagerTest.java @@ -18,6 +18,7 @@ import com.facebook.react.views.view.ReactViewManager; import java.util.Locale; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,6 +34,7 @@ @PrepareForTest({Arguments.class}) @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T14964130 public class BaseViewManagerTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/LayoutPropertyApplicatorTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/LayoutPropertyApplicatorTest.java index d089f565fbc3f9..f47d9ee9f4daf2 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/LayoutPropertyApplicatorTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/LayoutPropertyApplicatorTest.java @@ -8,10 +8,10 @@ package com.facebook.react.uimanager; import static junit.framework.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyFloat; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyFloat; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.spy; @@ -28,6 +28,7 @@ import com.facebook.yoga.YogaPositionType; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -41,6 +42,7 @@ @PrepareForTest({PixelUtil.class}) @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T14964130 public class LayoutPropertyApplicatorTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.java index 319586c3c34aa1..aab77b77bbfb72 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/MatrixMathHelperTest.java @@ -9,12 +9,14 @@ import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; /** Test for {@link MatrixMathHelper} */ @RunWith(RobolectricTestRunner.class) +@Ignore // TODO T14964130 public class MatrixMathHelperTest { private void verifyZRotatedMatrix(double degrees, double rotX, double rotY, double rotZ) { diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterSpecTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterSpecTest.java index 7c088e9bb931e1..193845d4c9030c 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterSpecTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterSpecTest.java @@ -11,6 +11,7 @@ import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactPropGroup; import java.util.Date; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -21,6 +22,7 @@ /** Test that verifies that spec of methods annotated with @ReactProp is correct */ @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T14964130 public class ReactPropAnnotationSetterSpecTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterTest.java index 9739dcb697594d..c88f4e237340c0 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropAnnotationSetterTest.java @@ -22,6 +22,7 @@ import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactPropGroup; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -35,6 +36,7 @@ */ @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T14964130 public class ReactPropAnnotationSetterTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java index 62e9497380ff0e..505127b691afed 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java @@ -20,6 +20,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -31,6 +32,7 @@ /** Verifies that prop constants are generated properly based on {@code ReactProp} annotation. */ @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T14964130 public class ReactPropConstantsTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSetterTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSetterTest.java index 8dd914535a1214..67f285f8cd8232 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSetterTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSetterTest.java @@ -19,6 +19,7 @@ import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactPropGroup; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,6 +34,7 @@ */ @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T14964130 public class ReactPropForShadowNodeSetterTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.java index 545b891a2ddf21..99e4049a2f4b4b 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.java @@ -11,6 +11,7 @@ import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactPropGroup; import java.util.Map; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -24,6 +25,7 @@ */ @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T14964130 public class ReactPropForShadowNodeSpecTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/SimpleViewPropertyTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/SimpleViewPropertyTest.java index e031f7c80014cd..c1ccc3c233064a 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/SimpleViewPropertyTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/SimpleViewPropertyTest.java @@ -21,6 +21,7 @@ import com.facebook.react.uimanager.annotations.ReactProp; import java.util.Map; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,6 +33,7 @@ /** Verify {@link View} view property being applied properly by {@link SimpleViewManager} */ @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T14964130 public class SimpleViewPropertyTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java index 4a8ce0c8dd4a12..0aa3e1c90cde92 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java @@ -18,6 +18,7 @@ import java.util.Map; import org.assertj.core.data.MapEntry; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -28,6 +29,7 @@ @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T14964130 public class UIManagerModuleConstantsTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java index 2aae5ed152d5d4..2408455eff1ddc 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java @@ -8,7 +8,7 @@ package com.facebook.react.uimanager; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -35,6 +35,7 @@ import java.util.Arrays; import java.util.List; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -51,6 +52,7 @@ @PrepareForTest({Arguments.class, ReactChoreographer.class}) @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T14964130 public class UIManagerModuleTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/image/ImageResizeModeTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/image/ImageResizeModeTest.java index 21ce26fb140b94..a1b8e68a9c07ff 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/image/ImageResizeModeTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/image/ImageResizeModeTest.java @@ -10,6 +10,7 @@ import static org.assertj.core.api.Assertions.assertThat; import com.facebook.drawee.drawable.ScalingUtils; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -19,6 +20,7 @@ @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T110934492 public class ImageResizeModeTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/image/ReactImagePropertyTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/image/ReactImagePropertyTest.java index 4240993a2a698c..66a127c802c760 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/image/ReactImagePropertyTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/image/ReactImagePropertyTest.java @@ -30,6 +30,7 @@ import com.facebook.soloader.SoLoader; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -49,6 +50,7 @@ @PrepareForTest({Arguments.class, RNLog.class}) @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T110934492 public class ReactImagePropertyTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/CustomLineHeightSpanTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/CustomLineHeightSpanTest.java index 1bb4ee2c4f4eda..c8a5839e4ace43 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/CustomLineHeightSpanTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/CustomLineHeightSpanTest.java @@ -10,6 +10,7 @@ import static org.assertj.core.api.Assertions.assertThat; import android.graphics.Paint; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PowerMockIgnore; @@ -17,6 +18,7 @@ @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T110934492 public class CustomLineHeightSpanTest { @Test diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java index 5c6790bcfb4b77..5048afaefa8b53 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java @@ -8,7 +8,7 @@ package com.facebook.react.views.text; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; @@ -40,6 +40,7 @@ import java.util.Arrays; import java.util.List; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -56,6 +57,7 @@ @PrepareForTest({Arguments.class, ReactChoreographer.class}) @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T110934492 public class ReactTextTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.java index edf798ab86e2c7..0d191fdef742fb 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.java @@ -28,6 +28,7 @@ import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.views.text.DefaultStyleValuesUtil; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -39,6 +40,7 @@ /** Verify {@link EditText} view property being applied properly by {@link ReactTextInputManager} */ @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T110934492 public class ReactTextInputPropertyTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java index b029e5160f0b43..7df47a12f696a6 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java @@ -8,7 +8,7 @@ package com.facebook.react.views.textinput; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; @@ -28,6 +28,7 @@ import java.util.Arrays; import java.util.List; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -44,6 +45,7 @@ @PrepareForTest({Arguments.class, ReactChoreographer.class}) @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T110934492 public class TextInputTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/view/ColorUtilTest.java b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/view/ColorUtilTest.java index a7ea56f0e2ac65..4a1dff17f58e60 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/view/ColorUtilTest.java +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/view/ColorUtilTest.java @@ -10,6 +10,7 @@ import static org.junit.Assert.*; import android.graphics.PixelFormat; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -20,6 +21,7 @@ /** Based on Fresco's DrawableUtilsTest (https://github.com/facebook/fresco). */ @RunWith(RobolectricTestRunner.class) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "androidx.*", "android.*"}) +@Ignore // TODO T110934492 public class ColorUtilTest { @Rule public PowerMockRule rule = new PowerMockRule(); diff --git a/packages/react-native/ReactCommon/callinvoker/.clang-tidy b/packages/react-native/ReactCommon/callinvoker/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactCommon/callinvoker/.clang-tidy +++ b/packages/react-native/ReactCommon/callinvoker/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactCommon/cxxreact/.clang-tidy b/packages/react-native/ReactCommon/cxxreact/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactCommon/cxxreact/.clang-tidy +++ b/packages/react-native/ReactCommon/cxxreact/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactCommon/cxxreact/Instance.h b/packages/react-native/ReactCommon/cxxreact/Instance.h index 12bfd86d7b4b7a..cf20a3529e5a86 100644 --- a/packages/react-native/ReactCommon/cxxreact/Instance.h +++ b/packages/react-native/ReactCommon/cxxreact/Instance.h @@ -111,7 +111,7 @@ class RN_EXPORT Instance { * When all queued NativeModule method calls are flushed by a call from * Native -> JS, if that queue was non-zero in size, JsToNativeBridge * dispatches onBatchComplete. When we turn our NativeModules to - * TurboModuels, there will be less and less pending NativeModule method + * TurboModules, there will be less and less pending NativeModule method * calls, so onBatchComplete will not fire as often. Therefore, the bridge * needs to know how many TurboModule async method calls have been completed * since the last time the bridge was flushed. If this number is non-zero, @@ -120,7 +120,7 @@ class RN_EXPORT Instance { * Why can't we just create and return a new native CallInvoker? * * - On Android, we have one NativeModule thread. That thread is created and - * managed outisde of NativeToJsBridge. On iOS, we have one MethodQueue per + * managed outside of NativeToJsBridge. On iOS, we have one MethodQueue per * module. Those MethodQueues are also created and managed outside of * NativeToJsBridge. Therefore, we need to pass in a CallInvoker that * schedules work on the respective thread. diff --git a/packages/react-native/ReactCommon/cxxreact/JSBigString.h b/packages/react-native/ReactCommon/cxxreact/JSBigString.h index bd7297e992c241..691bb1ac3ee5bf 100644 --- a/packages/react-native/ReactCommon/cxxreact/JSBigString.h +++ b/packages/react-native/ReactCommon/cxxreact/JSBigString.h @@ -126,11 +126,11 @@ class RN_EXPORT JSBigFileString : public JSBigString { const std::string &sourceURL); private: - int m_fd; // The file descriptor being mmaped - size_t m_size; // The size of the mmaped region - mutable off_t m_pageOff; // The offset in the mmaped region to the data. - off_t m_mapOff; // The offset in the file to the mmaped region. - mutable const char *m_data; // Pointer to the mmaped region. + int m_fd; // The file descriptor being mmapped + size_t m_size; // The size of the mmapped region + mutable off_t m_pageOff; // The offset in the mmapped region to the data. + off_t m_mapOff; // The offset in the file to the mmapped region. + mutable const char *m_data; // Pointer to the mmapped region. }; } // namespace react diff --git a/packages/react-native/ReactCommon/cxxreact/MethodCall.cpp b/packages/react-native/ReactCommon/cxxreact/MethodCall.cpp index d3e84330075f60..c5e068195d3ec0 100644 --- a/packages/react-native/ReactCommon/cxxreact/MethodCall.cpp +++ b/packages/react-native/ReactCommon/cxxreact/MethodCall.cpp @@ -15,7 +15,7 @@ namespace react { #define REQUEST_MODULE_IDS 0 #define REQUEST_METHOD_IDS 1 -#define REQUEST_PARAMSS 2 +#define REQUEST_PARAMS 2 #define REQUEST_CALLID 3 static const char *errorPrefix = "Malformed calls from JS: "; @@ -30,14 +30,14 @@ std::vector parseMethodCalls(folly::dynamic &&jsonData) { errorPrefix, "input isn't array but ", jsonData.typeName())); } - if (jsonData.size() < REQUEST_PARAMSS + 1) { + if (jsonData.size() < REQUEST_PARAMS + 1) { throw std::invalid_argument( folly::to(errorPrefix, "size == ", jsonData.size())); } auto &moduleIds = jsonData[REQUEST_MODULE_IDS]; auto &methodIds = jsonData[REQUEST_METHOD_IDS]; - auto ¶ms = jsonData[REQUEST_PARAMSS]; + auto ¶ms = jsonData[REQUEST_PARAMS]; int callId = -1; if (!moduleIds.isArray() || !methodIds.isArray() || !params.isArray()) { diff --git a/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.h b/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.h index 2b68a3c572ef3a..55d9c0b6b045b3 100644 --- a/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.h +++ b/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.h @@ -83,7 +83,7 @@ class RN_EXPORT ModuleRegistry { // Function will be called if a module was requested but was not found. // If the function returns true, ModuleRegistry will try to find the module - // again (assuming it's registered) If the functon returns false, + // again (assuming it's registered) If the function returns false, // ModuleRegistry will not try to find the module and return nullptr instead. ModuleNotFoundCallback moduleNotFoundCallback_; }; diff --git a/packages/react-native/ReactCommon/hermes/.clang-tidy b/packages/react-native/ReactCommon/hermes/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactCommon/hermes/.clang-tidy +++ b/packages/react-native/ReactCommon/hermes/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactCommon/hermes/inspector/Inspector.h b/packages/react-native/ReactCommon/hermes/inspector/Inspector.h index 50ab88eada70b7..672bfad6b4a0ff 100644 --- a/packages/react-native/ReactCommon/hermes/inspector/Inspector.h +++ b/packages/react-native/ReactCommon/hermes/inspector/Inspector.h @@ -176,7 +176,7 @@ class Inspector : public facebook::hermes::debugger::EventObserver, /** * resume and step methods are only valid when the VM is currently paused. The - * returned future suceeds when the VM resumes execution, or fails with an + * returned future succeeds when the VM resumes execution, or fails with an * InvalidStateException otherwise. */ folly::Future resume(); @@ -186,7 +186,7 @@ class Inspector : public facebook::hermes::debugger::EventObserver, /** * pause can be issued at any time while the inspector is enabled. It requests - * the VM to asynchronously break execution. The returned future suceeds if + * the VM to asynchronously break execution. The returned future succeeds if * the VM can be paused in this state and fails with InvalidStateException if * otherwise. */ diff --git a/packages/react-native/ReactCommon/hermes/inspector/RuntimeAdapter.h b/packages/react-native/ReactCommon/hermes/inspector/RuntimeAdapter.h index 0e7f06140a9280..253c9879b92e7f 100644 --- a/packages/react-native/ReactCommon/hermes/inspector/RuntimeAdapter.h +++ b/packages/react-native/ReactCommon/hermes/inspector/RuntimeAdapter.h @@ -49,7 +49,7 @@ class INSPECTOR_EXPORT RuntimeAdapter { /// the ability to force the process to enter the Hermes interpreter loop /// soon. This is important because the inspector can only do a number of /// important operations (like manipulating breakpoints) within the context of - /// a Hermes interperter loop. + /// a Hermes interpreter loop. /// /// The default implementation does nothing. virtual void tickleJs(); diff --git a/packages/react-native/ReactCommon/hermes/inspector/chrome/tests/MessageTests.cpp b/packages/react-native/ReactCommon/hermes/inspector/chrome/tests/MessageTests.cpp index 9458d05dad2d0b..c8a94d6ebc83c6 100644 --- a/packages/react-native/ReactCommon/hermes/inspector/chrome/tests/MessageTests.cpp +++ b/packages/react-native/ReactCommon/hermes/inspector/chrome/tests/MessageTests.cpp @@ -955,7 +955,7 @@ TEST(MessageTests, testSetInstrumentationBreakpointRequest) { "id": 1, "method": "Debugger.setInstrumentationBreakpoint", "params": { - "instrumentation": "TODO: THIS SHOUD NOT BE ACCEPTED BY ENUM" + "instrumentation": "TODO: THIS SHOULD NOT BE ACCEPTED BY ENUM" } } )"; @@ -977,7 +977,8 @@ TEST(MessageTests, testSetInstrumentationBreakpointRequest) { EXPECT_EQ(resolvedReq->id, 1); EXPECT_EQ(resolvedReq->method, "Debugger.setInstrumentationBreakpoint"); EXPECT_EQ( - resolvedReq->instrumentation, "TODO: THIS SHOUD NOT BE ACCEPTED BY ENUM"); + resolvedReq->instrumentation, + "TODO: THIS SHOULD NOT BE ACCEPTED BY ENUM"); EXPECT_EQ(resolvedReq->id, deserializedReq.id); EXPECT_EQ(resolvedReq->method, deserializedReq.method); @@ -990,7 +991,7 @@ TEST(MessageTests, testSetPauseOnExceptionsRequest) { "id": 1, "method": "Debugger.setPauseOnExceptions", "params": { - "state": "TODO: THIS SHOUD NOT BE ACCEPTED BY ENUM" + "state": "TODO: THIS SHOULD NOT BE ACCEPTED BY ENUM" } } )"; @@ -1011,7 +1012,7 @@ TEST(MessageTests, testSetPauseOnExceptionsRequest) { // Specifics EXPECT_EQ(resolvedReq->id, 1); EXPECT_EQ(resolvedReq->method, "Debugger.setPauseOnExceptions"); - EXPECT_EQ(resolvedReq->state, "TODO: THIS SHOUD NOT BE ACCEPTED BY ENUM"); + EXPECT_EQ(resolvedReq->state, "TODO: THIS SHOULD NOT BE ACCEPTED BY ENUM"); EXPECT_EQ(resolvedReq->id, deserializedReq.id); EXPECT_EQ(resolvedReq->method, deserializedReq.method); diff --git a/packages/react-native/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.cpp b/packages/react-native/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.cpp index 57223de420ccea..2bfe58434ae996 100644 --- a/packages/react-native/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.cpp +++ b/packages/react-native/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.cpp @@ -38,9 +38,9 @@ std::string prettify(const std::string &str) { } // namespace -class SyncConnection::RemoteConnnection : public IRemoteConnection { +class SyncConnection::RemoteConnection : public IRemoteConnection { public: - RemoteConnnection(SyncConnection &conn) : conn_(conn) {} + RemoteConnection(SyncConnection &conn) : conn_(conn) {} void onMessage(std::string message) override { conn_.onReply(message); @@ -59,7 +59,7 @@ SyncConnection::SyncConnection( std::make_unique(runtime), "testConn", waitForDebugger) { - connection_.connect(std::make_unique(*this)); + connection_.connect(std::make_unique(*this)); } void SyncConnection::send(const std::string &str) { diff --git a/packages/react-native/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.h b/packages/react-native/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.h index e760aa0306aff1..e8864f0fea52d0 100644 --- a/packages/react-native/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.h +++ b/packages/react-native/ReactCommon/hermes/inspector/chrome/tests/SyncConnection.h @@ -49,8 +49,8 @@ class SyncConnection { std::chrono::milliseconds timeout = std::chrono::milliseconds(2500)); private: - class RemoteConnnection; - friend class RemoteConnnection; + class RemoteConnection; + friend class RemoteConnection; void onReply(const std::string &message); diff --git a/packages/react-native/ReactCommon/jsengineinstance/.clang-tidy b/packages/react-native/ReactCommon/jsengineinstance/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactCommon/jsengineinstance/.clang-tidy +++ b/packages/react-native/ReactCommon/jsengineinstance/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactCommon/jserrorhandler/BUCK b/packages/react-native/ReactCommon/jserrorhandler/BUCK index 9edd6729f64e64..05b20d883a23e1 100644 --- a/packages/react-native/ReactCommon/jserrorhandler/BUCK +++ b/packages/react-native/ReactCommon/jserrorhandler/BUCK @@ -1,6 +1,6 @@ load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "CXX", "react_native_xplat_target", "rn_xplat_cxx_library") -# TODO: Expolre merging this module into venice so we don't to load this library seperately +# TODO: Expolre merging this module into venice so we don't to load this library separately rn_xplat_cxx_library( name = "jserrorhandler", srcs = glob(["*.cpp"]), diff --git a/packages/react-native/ReactCommon/jsi/.clang-tidy b/packages/react-native/ReactCommon/jsi/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactCommon/jsi/.clang-tidy +++ b/packages/react-native/ReactCommon/jsi/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactCommon/jsiexecutor/.clang-tidy b/packages/react-native/ReactCommon/jsiexecutor/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactCommon/jsiexecutor/.clang-tidy +++ b/packages/react-native/ReactCommon/jsiexecutor/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp index 6460c7888983c4..3e72ed8e25bb80 100644 --- a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp +++ b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp @@ -206,7 +206,7 @@ void JSIExecutor::registerBundle( // Looping on \c drainMicrotasks until it completes or hits the retries bound. static void performMicrotaskCheckpoint(jsi::Runtime &runtime) { uint8_t retries = 0; - // A heuristic number to guard inifinite or absurd numbers of retries. + // A heuristic number to guard infinite or absurd numbers of retries. const static unsigned int kRetriesBound = 255; while (retries < kRetriesBound) { diff --git a/packages/react-native/ReactCommon/jsinspector/.clang-tidy b/packages/react-native/ReactCommon/jsinspector/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactCommon/jsinspector/.clang-tidy +++ b/packages/react-native/ReactCommon/jsinspector/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactCommon/react/bridging/tests/BridgingTest.cpp b/packages/react-native/ReactCommon/react/bridging/tests/BridgingTest.cpp index ab609bdf4e7b26..995bce42e62d2a 100644 --- a/packages/react-native/ReactCommon/react/bridging/tests/BridgingTest.cpp +++ b/packages/react-native/ReactCommon/react/bridging/tests/BridgingTest.cpp @@ -420,7 +420,7 @@ TEST_F(BridgingTest, pointerTest) { auto str = "hi"s; auto unique = std::make_unique(str); auto shared = std::make_shared(str); - auto weak = std::weak_ptr(shared); + auto weak = std::weak_ptr(shared); EXPECT_EQ(str, bridging::toJs(rt, unique, invoker).asString(rt).utf8(rt)); EXPECT_EQ(str, bridging::toJs(rt, shared, invoker).asString(rt).utf8(rt)); diff --git a/packages/react-native/ReactCommon/react/config/.clang-tidy b/packages/react-native/ReactCommon/react/config/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactCommon/react/config/.clang-tidy +++ b/packages/react-native/ReactCommon/react/config/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactCommon/react/nativemodule/.clang-tidy b/packages/react-native/ReactCommon/react/nativemodule/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/.clang-tidy +++ b/packages/react-native/ReactCommon/react/nativemodule/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTBlockGuard.h b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTBlockGuard.h index a4bbb8b6e6c932..0e34516bedaa14 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTBlockGuard.h +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTBlockGuard.h @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN /** * RCTBlockGuard is designed to be used with obj-c blocks to assist with manual deallocation of C++ resources * tied to lifetime of a block. If C++ resources needs to be manually released at the end of block or when the block - * is deallocated, place the clean up code inside constructor and make sure the instace of the class is references in + * is deallocated, place the clean up code inside constructor and make sure the instance of the class is references in * the block. */ @interface RCTBlockGuard : NSObject diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm index 2a937891011645..9bfea510a57104 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm @@ -452,7 +452,7 @@ - (TurboModuleHolder *)_getOrCreateTurboModuleHolder:(const char *)moduleName /** * TODO(T65905574): * If the thread responsible for creating and initializing the NativeModule stalls, we'll wait here indefinitely. - * This is the behaviour in legacy NativeModuels. Changing this now could lead to more crashes/problems in + * This is the behaviour in legacy NativeModules. Changing this now could lead to more crashes/problems in * TurboModules than in NativeModules, which'll make it more difficult to test the TurboModules infra. Therefore, * we should consider making it post TurboModule 100% rollout. */ diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedString.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedString.h index 2f1858c6f11c88..69ef92b379a1e0 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedString.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedString.h @@ -25,7 +25,7 @@ class AttributedString; using SharedAttributedString = std::shared_ptr; /* - * Simple, cross-platfrom, React-specific implementation of attributed string + * Simple, cross-platform, React-specific implementation of attributed string * (aka spanned string). * `AttributedString` is basically a list of `Fragments` which have `string` and * `textAttributes` + `shadowNode` associated with the `string`. diff --git a/packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h b/packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h index 9ef8068f2698ac..d905063a7a46d6 100644 --- a/packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h +++ b/packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h @@ -37,7 +37,7 @@ class ComponentDescriptorProviderRegistry final { /* * ComponenDescriptorRegistry will call the `request` in case if a component * with given name wasn't registered yet. - * The request handler must register a ComponentDescripor with requested name + * The request handler must register a ComponentDescriptor with requested name * synchronously during handling the request. * The request can be called on any thread. * The methods can be called on any thread. diff --git a/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm b/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm index 575182b18f4171..b273be148db343 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm +++ b/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm @@ -51,7 +51,7 @@ - (instancetype)initWithComponentData:(RCTComponentData *)componentData // During bridge mode, RCTBridgeModules will be decorated with these APIs by the bridge. RCTAssert( _bridge == nil, - @"RCTLegacyViewManagerInteropCoordinator should not be intialized with RCTBridgeModuleDecorator in bridge mode."); + @"RCTLegacyViewManagerInteropCoordinator should not be initialized with RCTBridgeModuleDecorator in bridge mode."); } _eventInterceptors = [NSMutableDictionary new]; diff --git a/packages/react-native/ReactCommon/react/renderer/components/root/RootProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/root/RootProps.cpp index 777e7998bd0a74..cb85133094cad3 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/root/RootProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/root/RootProps.cpp @@ -13,8 +13,8 @@ namespace facebook::react { // Note that a default/empty context may be passed here from RootShadowNode. -// If that's a problem and the context is necesary here, refactor RootShadowNode -// first. +// If that's a problem and the context is necessary here, refactor +// RootShadowNode first. RootProps::RootProps( const PropsParserContext &context, RootProps const &sourceProps, @@ -22,8 +22,8 @@ RootProps::RootProps( : ViewProps(context, sourceProps, rawProps) {} // Note that a default/empty context may be passed here from RootShadowNode. -// If that's a problem and the context is necesary here, refactor RootShadowNode -// first. +// If that's a problem and the context is necessary here, refactor +// RootShadowNode first. RootProps::RootProps( const PropsParserContext & /*context*/, RootProps const & /*sourceProps*/, diff --git a/packages/react-native/ReactCommon/react/renderer/components/root/tests/RootShadowNodeTest.cpp b/packages/react-native/ReactCommon/react/renderer/components/root/tests/RootShadowNodeTest.cpp index 659ce017f081fe..2ed4e066e9d1eb 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/root/tests/RootShadowNodeTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/root/tests/RootShadowNodeTest.cpp @@ -36,11 +36,11 @@ TEST(RootShadowNodeTest, cloneWithLayoutConstraints) { EXPECT_TRUE(rootShadowNode->layoutIfNeeded()); EXPECT_TRUE(rootShadowNode->getIsLayoutClean()); - auto clonedWithDiffentLayoutConstraints = rootShadowNode->clone( + auto clonedWithDifferentLayoutConstraints = rootShadowNode->clone( parserContext, LayoutConstraints{{0, 0}, {10, 10}}, {}); - EXPECT_FALSE(clonedWithDiffentLayoutConstraints->getIsLayoutClean()); - EXPECT_TRUE(clonedWithDiffentLayoutConstraints->layoutIfNeeded()); + EXPECT_FALSE(clonedWithDifferentLayoutConstraints->getIsLayoutClean()); + EXPECT_TRUE(clonedWithDifferentLayoutConstraints->layoutIfNeeded()); } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/tests/ParagraphLocalDataTest.cpp b/packages/react-native/ReactCommon/react/renderer/components/text/tests/ParagraphLocalDataTest.cpp index 1c09c5d052bfcf..afa6723bc43300 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/text/tests/ParagraphLocalDataTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/text/tests/ParagraphLocalDataTest.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -34,21 +33,19 @@ TEST(ParagraphLocalDataTest, testSomething) { text.fontWeight = FontWeight::Thin; text.fontVariant = FontVariant::TabularNums; fragment.textAttributes = text; - attString.prependFragment(fragment); + attributedString.prependFragment(fragment); auto paragraphState = ParagraphState{}; - paragraphLocalData.attributedString = attributedString; + paragraphState.attributedString = attributedString; auto result = toDynamic(paragraphState)["attributedString"]; - react_native_assert(result["string"] == fragment.string); + EXPECT_EQ(result["string"], fragment.string); auto textAttribute = result["fragments"][0]["textAttributes"]; - react_native_assert( - textAttribute["foregroundColor"] == toDynamic(text.foregroundColor)); - react_native_assert(textAttribute["opacity"] == text.opacity); - react_native_assert(textAttribute["fontStyle"] == toString(*text.fontStyle)); - react_native_assert( - textAttribute["fontWeight"] == toString(*text.fontWeight)); + EXPECT_EQ(textAttribute["foregroundColor"], toDynamic(text.foregroundColor)); + EXPECT_EQ(textAttribute["opacity"], text.opacity); + EXPECT_EQ(textAttribute["fontStyle"], toString(*text.fontStyle)); + EXPECT_EQ(textAttribute["fontWeight"], toString(*text.fontWeight)); } #endif diff --git a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h index 0d89f9553ec6dc..3ae47a556da617 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h @@ -30,7 +30,7 @@ class UnimplementedViewComponentDescriptor final ComponentName getComponentName() const override; /* - * In addtion to base implementation, stores a component name inside cloned + * In addition to base implementation, stores a component name inside cloned * `Props` object. */ Props::Shared cloneProps( diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp index 84581375c554ea..8e20136627a6a1 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -80,7 +80,7 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode( yogaNode_(&initializeYogaConfig(yogaConfig_)) { yogaNode_.setContext(this); - // Newly created node must be `dirty` just becasue it is new. + // Newly created node must be `dirty` just because it is new. // This is not a default for `YGNode`. yogaNode_.setDirty(true); @@ -215,7 +215,7 @@ void YogaLayoutableShadowNode::appendChild( ensureUnsealed(); ensureConsistency(); - // Calling the base class (`ShadowNode`) mehtod. + // Calling the base class (`ShadowNode`) method. LayoutableShadowNode::appendChild(childNode); if (getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)) { @@ -505,7 +505,7 @@ void YogaLayoutableShadowNode::layoutTree( react_native_assert(minimumSize.height >= 0); react_native_assert(maximumSize.width >= 0); react_native_assert(maximumSize.height >= 0); - // Mimimum size cannot be infinity. + // Minimum size cannot be infinity. react_native_assert(!std::isinf(minimumSize.width)); react_native_assert(!std::isinf(minimumSize.height)); diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.h b/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.h index 4a25898f70d80c..6371bb3dc70d11 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.h @@ -42,7 +42,7 @@ class YogaStylableProps : public Props { YGStyle yogaStyle{}; // Duplicates of existing properties with different names, taking - // precendence. E.g. "marginBlock" instead of "marginVertical" + // precedence. E.g. "marginBlock" instead of "marginVertical" CompactValue inset; CompactValue insetInline; CompactValue insetInlineEnd; diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h b/packages/react-native/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h index c3ebe5608ee1fc..b6b16a7cc47bed 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h @@ -202,11 +202,11 @@ inline void fromRawValue( } else if (string == "no-hide-descendants") { result = ImportantForAccessibility::NoHideDescendants; } else { - LOG(ERROR) << "Unsupported ImportantForAccessiblity value: " << string; + LOG(ERROR) << "Unsupported ImportantForAccessibility value: " << string; react_native_expect(false); } } else { - LOG(ERROR) << "Unsupported ImportantForAccessiblity type"; + LOG(ERROR) << "Unsupported ImportantForAccessibility type"; } } diff --git a/packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h index fb44c8dbb49a8c..5a9cf373898bf0 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h @@ -195,7 +195,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { protected: /* - * Called immediatelly after `ShadowNode` is created or cloned. + * Called immediately after `ShadowNode` is created or cloned. * * Override this method to pass information from custom `ComponentDescriptor` * to new instance of `ShadowNode`. diff --git a/packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.h b/packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.h index a3a9625e82b3d8..e9672d647e2d3b 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.h +++ b/packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.h @@ -12,7 +12,7 @@ namespace react { /* * Contains the set of feature flags for the renderer core. - * Some of them are temporary and may be eventualy phased out + * Some of them are temporary and may be eventually phased out * as soon as the feature is fully implemented. */ class CoreFeatures { diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventBeat.h b/packages/react-native/ReactCommon/react/renderer/core/EventBeat.h index 05388edd5bf6bf..10245c572e26c9 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/EventBeat.h +++ b/packages/react-native/ReactCommon/react/renderer/core/EventBeat.h @@ -77,7 +77,7 @@ class EventBeat { protected: /* - * Should be used by sublasses to send a beat. + * Should be used by subclasses to send a beat. * Receiver might ignore the call if a beat was not requested. */ void beat(jsi::Runtime &runtime) const; diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.cpp b/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.cpp index 55c4cd3744eed9..64e04ca2085e4d 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.cpp @@ -19,7 +19,7 @@ namespace facebook::react { EventDispatcher::EventDispatcher( EventQueueProcessor const &eventProcessor, EventBeat::Factory const &synchonousEventBeatFactory, - EventBeat::Factory const &asynchonousEventBeatFactory, + EventBeat::Factory const &asynchronousEventBeatFactory, EventBeat::SharedOwnerBox const &ownerBox) : synchronousUnbatchedQueue_(std::make_unique( eventProcessor, @@ -29,10 +29,10 @@ EventDispatcher::EventDispatcher( synchonousEventBeatFactory(ownerBox))), asynchronousUnbatchedQueue_(std::make_unique( eventProcessor, - asynchonousEventBeatFactory(ownerBox))), + asynchronousEventBeatFactory(ownerBox))), asynchronousBatchedQueue_(std::make_unique( eventProcessor, - asynchonousEventBeatFactory(ownerBox))) {} + asynchronousEventBeatFactory(ownerBox))) {} void EventDispatcher::dispatchEvent(RawEvent &&rawEvent, EventPriority priority) const { diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.h b/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.h index 19f1fabb7e7b70..6dd3e28f7c7829 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.h +++ b/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.h @@ -32,7 +32,7 @@ class EventDispatcher { EventDispatcher( EventQueueProcessor const &eventProcessor, EventBeat::Factory const &synchonousEventBeatFactory, - EventBeat::Factory const &asynchonousEventBeatFactory, + EventBeat::Factory const &asynchronousEventBeatFactory, EventBeat::SharedOwnerBox const &ownerBox); /* diff --git a/packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.h b/packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.h index 56b59c55644ae4..4fd992081c8fe0 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.h +++ b/packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.h @@ -152,7 +152,7 @@ class LayoutableShadowNode : public ShadowNode { virtual Float lastBaseline(Size size) const; /* - * Returns layoutable children to interate on. + * Returns layoutable children to iterate on. */ LayoutableShadowNode::UnsharedList getLayoutableChildNodes() const; diff --git a/packages/react-native/ReactCommon/react/renderer/core/RawProps.h b/packages/react-native/ReactCommon/react/renderer/core/RawProps.h index 08cdcdd5d03429..3f3aae117bce5e 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/RawProps.h +++ b/packages/react-native/ReactCommon/react/renderer/core/RawProps.h @@ -138,7 +138,7 @@ class RawProps final { small_vector keyIndexToValueIndex_; mutable butter:: - small_vector + small_vector values_; }; diff --git a/packages/react-native/ReactCommon/react/renderer/core/RawPropsKeyMap.h b/packages/react-native/ReactCommon/react/renderer/core/RawPropsKeyMap.h index f71dd094e5da95..ad50c5529fd3b9 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/RawPropsKeyMap.h +++ b/packages/react-native/ReactCommon/react/renderer/core/RawPropsKeyMap.h @@ -55,7 +55,7 @@ class RawPropsKeyMap final { Item const &rhs) noexcept; static bool hasSameName(Item const &lhs, Item const &rhs) noexcept; - butter::small_vector items_{}; + butter::small_vector items_{}; butter::small_vector buckets_{}; }; diff --git a/packages/react-native/ReactCommon/react/renderer/core/RawPropsPrimitives.h b/packages/react-native/ReactCommon/react/renderer/core/RawPropsPrimitives.h index cb2d9d1c19612b..89855f84ee6323 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/RawPropsPrimitives.h +++ b/packages/react-native/ReactCommon/react/renderer/core/RawPropsPrimitives.h @@ -27,7 +27,7 @@ using RawPropsPropNameHash = uint32_t; * The number which is *usually* bigger than a number of explicitly specified * props for some component. */ -constexpr static int kNumberOfExplicitlySpecifedPropsSoftCap = 16; +constexpr static int kNumberOfExplicitlySpecifiedPropsSoftCap = 16; /* * Special value of `RawPropsValueIndex` which is used to represent `no value`. diff --git a/packages/react-native/ReactCommon/react/renderer/core/Sealable.h b/packages/react-native/ReactCommon/react/renderer/core/Sealable.h index 0bfd4d5e7fed72..d0a95dcf57edad 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/Sealable.h +++ b/packages/react-native/ReactCommon/react/renderer/core/Sealable.h @@ -26,7 +26,7 @@ namespace react { * even if they are explicitly marked as `const`. It means that in some special * cases those objects can be const-casted-away and then mutated. That comes * from the fact that we share some object's life-cycle responsibilities with - * React and the immutability is guaranteed by some logic splitted between + * React and the immutability is guaranteed by some logic split between * native and JavaScript worlds (which makes it impossible to fully use * immutability enforcement at a language level). To detect possible errors as * early as possible we additionally mark objects as *sealed* after some stages diff --git a/packages/react-native/ReactCommon/react/renderer/core/graphicsConversions.h b/packages/react-native/ReactCommon/react/renderer/core/graphicsConversions.h index c142b8e57bf8c0..e91cbd44dc44c3 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/graphicsConversions.h +++ b/packages/react-native/ReactCommon/react/renderer/core/graphicsConversions.h @@ -57,6 +57,9 @@ inline void fromRawValue( inline int toAndroidRepr(const SharedColor &color) { return *color; } +inline folly::dynamic toDynamic(const SharedColor &color) { + return *color; +} #endif inline std::string toString(const SharedColor &value) { diff --git a/packages/react-native/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp b/packages/react-native/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp index 28d85cef6d696d..e88013b9e555b6 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp @@ -6,7 +6,7 @@ */ #include -#include +#include #include #include #include @@ -58,7 +58,7 @@ TEST_F(EventQueueProcessorTest, singleUnspecifiedEvent) { EXPECT_EQ(eventPriorities_[0], ReactEventPriority::Discrete); } -TEST_F(EventQueueProcessorTest, continiousEvent) { +TEST_F(EventQueueProcessorTest, continuousEvent) { eventProcessor_->flushEvents( *runtime_, {RawEvent( diff --git a/packages/react-native/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp b/packages/react-native/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp index c2b444ba534b0a..9be2fae835cc64 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp @@ -462,7 +462,7 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnSameTransformedNode) { * │ └────────────────┘│ * └────────────────────────┘ */ -TEST(LayoutableShadowNodeTest, relativeLayourMetricsOnClonedNode) { +TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnClonedNode) { auto builder = simpleComponentBuilder(); auto childShadowNode = std::shared_ptr{}; diff --git a/packages/react-native/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp b/packages/react-native/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp index a620d3c96dc136..5c0068782a5642 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp @@ -131,7 +131,7 @@ class PropsMultiLookup : public Props { "floatValue", sourceProps.floatValue, 17.5)), - // While this specific pattern is uncommon, it's a simplication of a + // While this specific pattern is uncommon, it's a simplification of a // pattern that does occur a lot: nested structs that access props we // have already accessed populating Props derivedFloatValue( diff --git a/packages/react-native/ReactCommon/react/renderer/element/CMakeLists.txt b/packages/react-native/ReactCommon/react/renderer/element/CMakeLists.txt new file mode 100644 index 00000000000000..d0af2a29e44a11 --- /dev/null +++ b/packages/react-native/ReactCommon/react/renderer/element/CMakeLists.txt @@ -0,0 +1,29 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options( + -fexceptions + -frtti + -std=c++17 + -Wall + -Wpedantic + -Wno-gnu-zero-variadic-macro-arguments + -DLOG_TAG=\"Fabric\") + +file(GLOB react_render_element_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_render_element SHARED ${react_render_element_SRC}) + +target_include_directories(react_render_element PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_render_element + folly_runtime + glog + react_render_core + react_render_componentregistry +) + diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/Transform.h b/packages/react-native/ReactCommon/react/renderer/graphics/Transform.h index 8ccd908b577476..97bd076f885ce0 100644 --- a/packages/react-native/ReactCommon/react/renderer/graphics/Transform.h +++ b/packages/react-native/ReactCommon/react/renderer/graphics/Transform.h @@ -199,7 +199,7 @@ Size operator*(Size const &size, Transform const &transform); Rect operator*(Rect const &rect, Transform const &transform); /* - * Applies tranformation to the given EdgeInsets. + * Applies transformation to the given EdgeInsets. * ONLY SUPPORTS scale transformation. */ EdgeInsets operator*(EdgeInsets const &edgeInsets, Transform const &transform); diff --git a/packages/react-native/ReactCommon/react/renderer/imagemanager/ImageRequest.h b/packages/react-native/ReactCommon/react/renderer/imagemanager/ImageRequest.h index 7d46def8a2c3a1..8cad25f16e25ce 100644 --- a/packages/react-native/ReactCommon/react/renderer/imagemanager/ImageRequest.h +++ b/packages/react-native/ReactCommon/react/renderer/imagemanager/ImageRequest.h @@ -86,7 +86,7 @@ class ImageRequest final { std::shared_ptr telemetry_{}; /* - * Event coordinator associated with the reqest. + * Event coordinator associated with the request. */ std::shared_ptr coordinator_{}; diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/Differentiator.cpp b/packages/react-native/ReactCommon/react/renderer/mounting/Differentiator.cpp index aae7253470635f..873d62f6acdacc 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/Differentiator.cpp +++ b/packages/react-native/ReactCommon/react/renderer/mounting/Differentiator.cpp @@ -503,7 +503,7 @@ static void updateMatchedPairSubtrees( * * Here we have (and need) knowledge of whether a node was found during * in-order traversal, or out-of-order via a map lookup. Nodes are only REMOVEd - * or INSERTed when they are encountered via in-order-traversal, to ensure + * or INSERTTed when they are encountered via in-order-traversal, to ensure * correct ordering of INSERT and REMOVE mutations. */ static void updateMatchedPair( diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.h b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.h index 0e8d5f32486924..ec88f9e00d318b 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.h +++ b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.h @@ -60,7 +60,7 @@ class ShadowTree final { // Indicates if mounting will be triggered synchronously and React will // not get a chance to interrupt painting. - // This should be set to `false` when a commit is comming from React. It + // This should be set to `false` when a commit is coming from React. It // will then let React run layout effects and apply updates before paint. // For all other commits, should be true. bool mountSynchronously{true}; diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp b/packages/react-native/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp index 9d6c2ddbdfce0b..3837509311fff5 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp @@ -332,7 +332,7 @@ static void testShadowNodeTreeLifeCycleExtensiveFlatteningUnflattening( using namespace facebook::react; TEST( - ShadowTreeLifecyleTest, + ShadowTreeLifecycleTest, stableBiggerTreeFewerIterationsOptimizedMovesFlattener) { testShadowNodeTreeLifeCycle( /* seed */ 0, @@ -342,7 +342,7 @@ TEST( } TEST( - ShadowTreeLifecyleTest, + ShadowTreeLifecycleTest, stableBiggerTreeFewerIterationsOptimizedMovesFlattener2) { testShadowNodeTreeLifeCycle( /* seed */ 1, @@ -352,7 +352,7 @@ TEST( } TEST( - ShadowTreeLifecyleTest, + ShadowTreeLifecycleTest, stableSmallerTreeMoreIterationsOptimizedMovesFlattener) { testShadowNodeTreeLifeCycle( /* seed */ 0, @@ -362,7 +362,7 @@ TEST( } TEST( - ShadowTreeLifecyleTest, + ShadowTreeLifecycleTest, unstableSmallerTreeFewerIterationsExtensiveFlatteningUnflattening) { testShadowNodeTreeLifeCycleExtensiveFlatteningUnflattening( /* seed */ 1337, @@ -372,7 +372,7 @@ TEST( } TEST( - ShadowTreeLifecyleTest, + ShadowTreeLifecycleTest, unstableBiggerTreeFewerIterationsExtensiveFlatteningUnflattening) { testShadowNodeTreeLifeCycleExtensiveFlatteningUnflattening( /* seed */ 1337, @@ -382,7 +382,7 @@ TEST( } TEST( - ShadowTreeLifecyleTest, + ShadowTreeLifecycleTest, unstableSmallerTreeMoreIterationsExtensiveFlatteningUnflattening) { testShadowNodeTreeLifeCycleExtensiveFlatteningUnflattening( /* seed */ 1337, @@ -393,7 +393,7 @@ TEST( // failing test case found 4-25-2021 TEST( - ShadowTreeLifecyleTest, + ShadowTreeLifecycleTest, unstableSmallerTreeMoreIterationsExtensiveFlatteningUnflattening_1167342011) { testShadowNodeTreeLifeCycleExtensiveFlatteningUnflattening( /* seed */ 1167342011, @@ -404,7 +404,7 @@ TEST( // You may uncomment this - locally only! - to generate failing seeds. // TEST( -// ShadowTreeLifecyleTest, +// ShadowTreeLifecycleTest, // unstableSmallerTreeMoreIterationsExtensiveFlatteningUnflatteningManyRandom) // { // std::random_device device; diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp b/packages/react-native/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp index 45b59ffd092b58..8f28c6aa090f46 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp @@ -769,16 +769,16 @@ TEST_F(StackingContextTest, zIndexAndFlattenedNodes) { testViewTree_([](StubViewTree const &viewTree) { // 5 views in total. - EXPECT_EQ(viewTree.size(), 5); + EXPECT_EQ(viewTree.size(), 8); - // The root view has all 4 subviews. - EXPECT_EQ(viewTree.getRootStubView().children.size(), 4); + // The root view has all 5 subviews. + EXPECT_EQ(viewTree.getRootStubView().children.size(), 5); - // The root view subviews are [10, 9, 5, 3]. - EXPECT_EQ(viewTree.getRootStubView().children.at(0)->tag, 10); - EXPECT_EQ(viewTree.getRootStubView().children.at(1)->tag, 9); - EXPECT_EQ(viewTree.getRootStubView().children.at(2)->tag, 5); - EXPECT_EQ(viewTree.getRootStubView().children.at(3)->tag, 3); + // The root view subviews are [6, 10, 9, 5]. + EXPECT_EQ(viewTree.getRootStubView().children.at(0)->tag, 6); + EXPECT_EQ(viewTree.getRootStubView().children.at(1)->tag, 10); + EXPECT_EQ(viewTree.getRootStubView().children.at(2)->tag, 9); + EXPECT_EQ(viewTree.getRootStubView().children.at(3)->tag, 5); }); } diff --git a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp b/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp index 48cf27042df085..79d317f11b1efe 100644 --- a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp +++ b/packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp @@ -151,7 +151,7 @@ jsi::Value RuntimeSchedulerBinding::get( }); } - // TODO: remmove this, as it's deprecated in the JS scheduler + // TODO: remove this, as it's deprecated in the JS scheduler if (propertyName == "unstable_getCurrentPriorityLevel") { return jsi::Function::createFromHostFunction( runtime, diff --git a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp b/packages/react-native/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp index ed43bab9a25078..0a3ebdf2db0453 100644 --- a/packages/react-native/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp @@ -6,7 +6,7 @@ */ #include -#include +#include #include #include #include diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceHandler.h b/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceHandler.h index 2736b4effba05e..7b70ecf85c9eb9 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceHandler.h +++ b/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceHandler.h @@ -183,7 +183,7 @@ class SurfaceHandler { }; /* - * Represents an underlying link to a `ShadowTree` and an `UIMananger`. + * Represents an underlying link to a `ShadowTree` and an `UIManager`. * Registering, unregistering, starting, and stopping the surface requires * acquiring a unique lock; other access needs only a shared lock. */ diff --git a/packages/react-native/ReactCommon/react/renderer/telemetry/tests/TransactionTelemetryTest.cpp b/packages/react-native/ReactCommon/react/renderer/telemetry/tests/TransactionTelemetryTest.cpp index 656ea81067f716..74732127363df5 100644 --- a/packages/react-native/ReactCommon/react/renderer/telemetry/tests/TransactionTelemetryTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/telemetry/tests/TransactionTelemetryTest.cpp @@ -26,7 +26,7 @@ MockClock::time_point MockClock::time_ = {}; * The OS might decide right before the specified time elapsed to schedule * another thread/process, with the result that more time passes in reality than * the caller intended. Prefer the `MockClock` and only use this function to - * verify that at least the specifid time has passed but wihtout making exact + * verify that at least the specified time has passed but without making exact * verifications. */ static void sleepAtLeast(double durationInSeconds) { diff --git a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/NSTextStorage+FontScaling.m b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/NSTextStorage+FontScaling.m index 4c4cb670f48f68..ee391a20f6c271 100644 --- a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/NSTextStorage+FontScaling.m +++ b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/NSTextStorage+FontScaling.m @@ -30,11 +30,11 @@ - (void)scaleFontSizeToFitSize:(CGSize)size while (true) { [self scaleFontSizeWithRatio:ratio minimumFontSize:minimumFontSize maximumFontSize:maximumFontSize]; - RCTTextSizeComparisonOptions comparsion = [self compareToSize:size thresholdRatio:0.01]; + RCTTextSizeComparisonOptions comparison = [self compareToSize:size thresholdRatio:0.01]; - if ((comparsion & RCTTextSizeComparisonWithinRange) && (comparsion & RCTTextSizeComparisonSmaller)) { + if ((comparison & RCTTextSizeComparisonWithinRange) && (comparison & RCTTextSizeComparisonSmaller)) { return; - } else if (comparsion & RCTTextSizeComparisonSmaller) { + } else if (comparison & RCTTextSizeComparisonSmaller) { bottomRatio = ratio; lastRatioWhichFits = ratio; } else { diff --git a/packages/react-native/ReactCommon/react/renderer/timeline/TimelineController.h b/packages/react-native/ReactCommon/react/renderer/timeline/TimelineController.h index 997fb025a1a043..a50920f86d89c8 100644 --- a/packages/react-native/ReactCommon/react/renderer/timeline/TimelineController.h +++ b/packages/react-native/ReactCommon/react/renderer/timeline/TimelineController.h @@ -35,7 +35,7 @@ class TimelineController final : public UIManagerCommitHook { /* * Consumes and destroys a `TimelineHandler` instance triggering the - * destruction of all associated resources and stoping the introspection + * destruction of all associated resources and stopping the introspection * process. */ void disable(TimelineHandler &&handler) const; diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.cpp index e65992faacb648..14cb0235ed3317 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.cpp @@ -17,12 +17,12 @@ void SurfaceRegistryBinding::startSurface( jsi::Runtime &runtime, SurfaceId surfaceId, std::string const &moduleName, - folly::dynamic const &initalProps, + folly::dynamic const &initialProps, DisplayMode displayMode) { SystraceSection s("SurfaceRegistryBinding::startSurface"); folly::dynamic parameters = folly::dynamic::object(); parameters["rootTag"] = surfaceId; - parameters["initialProps"] = initalProps; + parameters["initialProps"] = initialProps; parameters["fabric"] = true; auto global = runtime.global(); @@ -70,12 +70,12 @@ void SurfaceRegistryBinding::setSurfaceProps( jsi::Runtime &runtime, SurfaceId surfaceId, std::string const &moduleName, - folly::dynamic const &initalProps, + folly::dynamic const &initialProps, DisplayMode displayMode) { SystraceSection s("UIManagerBinding::setSurfaceProps"); folly::dynamic parameters = folly::dynamic::object(); parameters["rootTag"] = surfaceId; - parameters["initialProps"] = initalProps; + parameters["initialProps"] = initialProps; parameters["fabric"] = true; auto global = runtime.global(); diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.h b/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.h index b688b0f61b04c6..dc4fe868cecd72 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.h +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.h @@ -24,7 +24,7 @@ class SurfaceRegistryBinding final { jsi::Runtime &runtime, SurfaceId surfaceId, std::string const &moduleName, - folly::dynamic const &initalProps, + folly::dynamic const &initialProps, DisplayMode displayMode); /* @@ -36,7 +36,7 @@ class SurfaceRegistryBinding final { jsi::Runtime &runtime, SurfaceId surfaceId, std::string const &moduleName, - folly::dynamic const &initalProps, + folly::dynamic const &initialProps, DisplayMode displayMode); /* diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h b/packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h index 006eb76262eaaa..07622b8549c902 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h @@ -103,7 +103,7 @@ inline static jsi::Value valueFromShadowNodeList( std::make_shared(std::move(shadowNodeList)); if (CoreFeatures::useNativeState) { // Use the wrapper for NativeState too, otherwise we can't implement - // the marker interface. Could be simplifed to a simple struct wrapper. + // the marker interface. Could be simplified to a simple struct wrapper. jsi::Object obj(runtime); obj.setNativeState(runtime, std::move(wrapper)); return obj; diff --git a/packages/react-native/ReactCommon/react/utils/.clang-tidy b/packages/react-native/ReactCommon/react/utils/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactCommon/react/utils/.clang-tidy +++ b/packages/react-native/ReactCommon/react/utils/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactCommon/reactperflogger/.clang-tidy b/packages/react-native/ReactCommon/reactperflogger/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactCommon/reactperflogger/.clang-tidy +++ b/packages/react-native/ReactCommon/reactperflogger/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/ReactCommon/runtimeexecutor/.clang-tidy b/packages/react-native/ReactCommon/runtimeexecutor/.clang-tidy index c98fd78ff64baa..9f33ef5a06d828 100644 --- a/packages/react-native/ReactCommon/runtimeexecutor/.clang-tidy +++ b/packages/react-native/ReactCommon/runtimeexecutor/.clang-tidy @@ -2,4 +2,5 @@ Checks: '> clang-diagnostic-*, ' +InheritParentConfig: true ... diff --git a/packages/react-native/flow/use-sync-external-store.js b/packages/react-native/flow/use-sync-external-store.js index 4edac0dbfa6d47..0cad445f741f4a 100644 --- a/packages/react-native/flow/use-sync-external-store.js +++ b/packages/react-native/flow/use-sync-external-store.js @@ -15,5 +15,6 @@ declare module 'use-sync-external-store/shim' { declare export function useSyncExternalStore( subscribe: (callback: Function) => () => void, getCurrentValue: () => Value, + getServerSnapshot?: () => Value, ): Value; } diff --git a/packages/react-native/package.json b/packages/react-native/package.json index 41bf9ce785765c..bf154752c8c56f 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -24,7 +24,6 @@ "interface.js", "jest-preset.js", "jest", - "!jest/private", "Libraries", "LICENSE", "local-cli", @@ -73,6 +72,9 @@ "third-party-podspecs", "types" ], + "scripts": { + "prepack": "cp ../../README.md ." + }, "peerDependencies": { "react": "18.2.0" }, @@ -97,7 +99,6 @@ "jest-environment-node": "^29.2.1", "jsc-android": "^250231.0.0", "memoize-one": "^5.0.0", - "metro-react-native-babel-transformer": "0.75.1", "metro-runtime": "0.75.1", "metro-source-map": "0.75.1", "mkdirp": "^0.5.1", diff --git a/packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb b/packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb index 8cd86bb699b9a4..a2cdee20b58c63 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb @@ -248,7 +248,7 @@ def testGetReactCodegenScriptPhases_whenAppPathNotDefined_abort CodegenUtils.new().get_react_codegen_script_phases(nil, file_manager: FileMock) } # Assert - assert_equal(Pod::UI.collected_warns, ["[Codegen] error: app_path is requried to use codegen discovery."]) + assert_equal(Pod::UI.collected_warns, ["[Codegen] error: app_path is required to use codegen discovery."]) end def testGetReactCodegenScriptPhases_returnTheScriptObject diff --git a/packages/react-native/scripts/cocoapods/codegen_utils.rb b/packages/react-native/scripts/cocoapods/codegen_utils.rb index 8eb3d5cb18d730..2565cb53d6c616 100644 --- a/packages/react-native/scripts/cocoapods/codegen_utils.rb +++ b/packages/react-native/scripts/cocoapods/codegen_utils.rb @@ -234,7 +234,7 @@ def get_react_codegen_script_phases( file_manager: File ) if !app_path - Pod::UI.warn '[Codegen] error: app_path is requried to use codegen discovery.' + Pod::UI.warn '[Codegen] error: app_path is required to use codegen discovery.' abort end diff --git a/packages/react-native/scripts/codegen/generate-artifacts-executor.js b/packages/react-native/scripts/codegen/generate-artifacts-executor.js index d85d460e8a01e1..78c75a1663db1c 100644 --- a/packages/react-native/scripts/codegen/generate-artifacts-executor.js +++ b/packages/react-native/scripts/codegen/generate-artifacts-executor.js @@ -493,7 +493,7 @@ function findCodegenEnabledLibraries( // // This function is needed since, after aligning the codegen between // iOS and Android, we have to create empty folders in advance and -// we don't know wheter they will be populated up until the end of the process. +// we don't know whether they will be populated up until the end of the process. // // @parameter filepath: the root path from which we want to remove the empty files and folders. function cleanupEmptyFilesAndFolders(filepath) { diff --git a/packages/react-native/scripts/react_native_pods.rb b/packages/react-native/scripts/react_native_pods.rb index 8d5c438f45dd26..21761e16ae8f98 100644 --- a/packages/react-native/scripts/react_native_pods.rb +++ b/packages/react-native/scripts/react_native_pods.rb @@ -23,8 +23,19 @@ $START_TIME = Time.now.to_i +# `@react-native-community/cli-platform-ios/native_modules` defines +# use_native_modules. We use node to resolve its path to allow for +# different packager and workspace setups. This is reliant on +# `@react-native-community/cli-platform-ios` being a direct dependency +# of `react-native`. +require Pod::Executable.execute_command('node', ['-p', + 'require.resolve( + "@react-native-community/cli-platform-ios/native_modules.rb", + {paths: [process.argv[1]]}, + )', __dir__]).strip + # This function returns the min iOS version supported by React Native -# By using this function, you won't have to manualy change your Podfile +# By using this function, you won't have to manually change your Podfile # when we change the minimum version supported by the framework. def min_ios_version_supported return '12.4' diff --git a/packages/react-native/scripts/react_native_pods_utils/script_phases.sh b/packages/react-native/scripts/react_native_pods_utils/script_phases.sh index f1f5b809ed8fbe..c2a64a2eb79852 100755 --- a/packages/react-native/scripts/react_native_pods_utils/script_phases.sh +++ b/packages/react-native/scripts/react_native_pods_utils/script_phases.sh @@ -109,7 +109,7 @@ moveOutputs () { ls -1 "$RCT_SCRIPT_OUTPUT_DIR" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1 } -withCodgenDiscovery () { +withCodegenDiscovery () { setup_dirs find_node find_codegen @@ -127,7 +127,7 @@ noCodegenDiscovery () { } if [ "$RCT_SCRIPT_TYPE" = "withCodegenDiscovery" ]; then - withCodgenDiscovery "$@" + withCodegenDiscovery "$@" else noCodegenDiscovery "$@" fi diff --git a/packages/react-native/template/ios/Podfile b/packages/react-native/template/ios/Podfile index 72f73ee8d3bff4..197230d1d6ea00 100644 --- a/packages/react-native/template/ios/Podfile +++ b/packages/react-native/template/ios/Podfile @@ -1,5 +1,9 @@ -require_relative '../node_modules/react-native/scripts/react_native_pods' -require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' +# Resolve react_native_pods.rb with node to allow for hoisting +require Pod::Executable.execute_command('node', ['-p', + 'require.resolve( + "react-native/scripts/react_native_pods.rb", + {paths: [process.argv[1]]}, + )', __dir__]).strip platform :ios, min_ios_version_supported prepare_react_native_project! @@ -50,6 +54,7 @@ target 'HelloWorld' do # https://github.com/facebook/react-native/blob/main/scripts/react_native_pods.rb#L197-L202 react_native_post_install( installer, + config[:reactNativePath], :mac_catalyst_enabled => false ) __apply_Xcode_12_5_M1_post_install_workaround(installer) diff --git a/packages/rn-tester/android/app/src/main/AndroidManifest.xml b/packages/rn-tester/android/app/src/main/AndroidManifest.xml index 224af0788a79dd..3e0f6056edda0b 100644 --- a/packages/rn-tester/android/app/src/main/AndroidManifest.xml +++ b/packages/rn-tester/android/app/src/main/AndroidManifest.xml @@ -8,10 +8,17 @@ + + + diff --git a/packages/rn-tester/package.json b/packages/rn-tester/package.json index cd21a3946efddb..28ae2dad4d0648 100644 --- a/packages/rn-tester/package.json +++ b/packages/rn-tester/package.json @@ -28,11 +28,6 @@ "react": "18.2.0", "react-native": "*" }, - "devDependencies": { - "babel-plugin-transform-flow-enums":"^0.0.2", - "connect": "^3.6.5", - "ws": "^6.2.2" - }, "codegenConfig": { "name": "AppSpecs", "type": "all", diff --git a/scripts/monorepo/__tests__/for-each-package-test.js b/scripts/monorepo/__tests__/for-each-package-test.js index 34ba8ecdb1c8a6..bcc688546a618c 100644 --- a/scripts/monorepo/__tests__/for-each-package-test.js +++ b/scripts/monorepo/__tests__/for-each-package-test.js @@ -38,7 +38,7 @@ describe('forEachPackage', () => { ); }); - it('filters react-native folder', () => { + it('filters react-native folder by default', () => { const callback = jest.fn(); readdirSync.mockImplementationOnce(() => [ {name: 'react-native', isDirectory: () => true}, @@ -48,4 +48,24 @@ describe('forEachPackage', () => { expect(callback).not.toHaveBeenCalled(); }); + + it('includes react-native, if such option is provided', () => { + const callback = jest.fn(); + const mockedPackageManifest = '{"name": "react-native"}'; + const mockedParsedPackageManifest = JSON.parse(mockedPackageManifest); + const mockedPackageName = 'react-native'; + + readdirSync.mockImplementationOnce(() => [ + {name: 'react-native', isDirectory: () => true}, + ]); + readFileSync.mockImplementationOnce(() => mockedPackageManifest); + + forEachPackage(callback, {includeReactNative: true}); + + expect(callback).toHaveBeenCalledWith( + path.join(__dirname, '..', '..', '..', 'packages', mockedPackageName), + path.join('packages', mockedPackageName), + mockedParsedPackageManifest, + ); + }); }); diff --git a/scripts/monorepo/align-package-versions.js b/scripts/monorepo/align-package-versions.js index f38f92d5a6706e..113efec171c45b 100644 --- a/scripts/monorepo/align-package-versions.js +++ b/scripts/monorepo/align-package-versions.js @@ -98,7 +98,7 @@ const alignPackageVersions = () => { process.exit(1); } - forEachPackage((packageAbsolutePath, _, packageManifest) => { + forEachPackage((_, __, packageManifest) => { checkIfShouldUpdateDependencyPackageVersion( ROOT_LOCATION, packageManifest.name, @@ -111,12 +111,14 @@ const alignPackageVersions = () => { packageManifest.version, ); - forEachPackage(pathToPackage => - checkIfShouldUpdateDependencyPackageVersion( - pathToPackage, - packageManifest.name, - packageManifest.version, - ), + forEachPackage( + pathToPackage => + checkIfShouldUpdateDependencyPackageVersion( + pathToPackage, + packageManifest.name, + packageManifest.version, + ), + {includeReactNative: true}, ); }); diff --git a/scripts/monorepo/for-each-package.js b/scripts/monorepo/for-each-package.js index 10991b5936da1d..f3d865dfdacffd 100644 --- a/scripts/monorepo/for-each-package.js +++ b/scripts/monorepo/for-each-package.js @@ -13,7 +13,7 @@ const {readdirSync, readFileSync} = require('fs'); const ROOT_LOCATION = path.join(__dirname, '..', '..'); const PACKAGES_LOCATION = path.join(ROOT_LOCATION, 'packages'); -const PACKAGES_BLOCK_LIST = ['react-native']; +const DEFAULT_OPTIONS = {includeReactNative: false}; /** * Function, which returns an array of all directories inside specified location @@ -37,11 +37,15 @@ const getDirectories = source => * Iterate through every package inside /packages (ignoring react-native) and call provided callback for each of them * * @param {forEachPackageCallback} callback The callback which will be called for each package + * @param {{includeReactNative: (boolean|undefined)}} [options={}] description */ -const forEachPackage = callback => { +const forEachPackage = (callback, options = DEFAULT_OPTIONS) => { + const {includeReactNative} = options; + // We filter react-native package on purpose, so that no CI's script will be executed for this package in future + // Unless includeReactNative options is provided const packagesDirectories = getDirectories(PACKAGES_LOCATION).filter( - directoryName => !PACKAGES_BLOCK_LIST.includes(directoryName), + directoryName => directoryName !== 'react-native' || includeReactNative, ); packagesDirectories.forEach(packageDirectory => { diff --git a/scripts/set-rn-version.js b/scripts/set-rn-version.js index 91f1b422b336ca..afa63887e4bd7c 100755 --- a/scripts/set-rn-version.js +++ b/scripts/set-rn-version.js @@ -60,7 +60,13 @@ const tmpVersioningFolder = fs.mkdtempSync( ); echo(`The temp versioning folder is ${tmpVersioningFolder}`); -saveFiles(['package.json', 'template/package.json'], tmpVersioningFolder); +saveFiles( + [ + 'packages/react-native/package.json', + 'packages/react-native/template/package.json', + ], + tmpVersioningFolder, +); fs.writeFileSync( 'packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java', diff --git a/tools/__tests__/no-dev-dependencies-in-tester-package.js b/tools/__tests__/no-dev-dependencies-in-tester-package.js new file mode 100644 index 00000000000000..aa6d1188121d96 --- /dev/null +++ b/tools/__tests__/no-dev-dependencies-in-tester-package.js @@ -0,0 +1,32 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +import path from 'path'; +import fs from 'fs'; + +const CURRENT_DIR = __dirname; +const PATH_TO_TESTER_PACKAGE_MANIFEST = path.join( + CURRENT_DIR, + '..', + '..', + 'packages', + 'rn-tester', + 'package.json', +); + +const manifest = JSON.parse( + fs.readFileSync(PATH_TO_TESTER_PACKAGE_MANIFEST).toString(), +); + +describe('@react-native/tester package', () => { + it('expected not to list any devDependencies', () => { + expect(manifest).not.toHaveProperty('devDependencies'); + }); +}); diff --git a/yarn.lock b/yarn.lock index 48237e4165d5a9..5588b60ab81982 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2467,12 +2467,6 @@ prompts "^2.4.0" semver "^6.3.0" -"@react-native-mac/virtualized-lists@^0.0.1": - version "0.1.0" - dependencies: - invariant "^2.2.4" - nullthrows "^1.1.1" - "@reactions/component@^2.0.2": version "2.0.2" resolved "https://registry.yarnpkg.com/@reactions/component/-/component-2.0.2.tgz#40f8c1c2c37baabe57a0c944edb9310dc1ec6642" @@ -5213,10 +5207,10 @@ flatted@^3.1.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== -flow-bin@^0.201.0: - version "0.201.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.201.0.tgz#bc8d7c3687526313d7a24dd920873a0273148d81" - integrity sha512-fqx6CMOhX9Xm4mN+tq/c7sqcm8aHFV1ipbLz2ZCzoNcPuUNZPoSVYm4p0qZqH0HyzMMEP1OWlU7dIkuSJ02cpg== +flow-bin@^0.202.0: + version "0.202.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.202.0.tgz#1e2eb221252c2ab55c997e5eb921902f3181cc4e" + integrity sha512-Yz+yNapJMWWV6Z6pZnBR+naMhFbFJbmMS8ZBQCFUHRqN1TTw7uwitYxRj8DyzLyTpcPReSAjWbWawWPsXJot3w== flow-enums-runtime@^0.0.5: version "0.0.5"