From 12e5842e11ecd53755f43e99c592135b58ac694b Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Fri, 2 Sep 2022 03:23:45 -0700 Subject: [PATCH 001/174] Fix/android (#34573) Summary: This PR should fix the issues introduced by commit c34659a5d3ef24e6a0ace2a5cac242487225fed0. The problem is that `Collections.emptyList` creates a `List` which is not compatible with the `List` type. ## Changelog [Android] [Fixed] - Make Android CI build again. Pull Request resolved: https://github.com/facebook/react-native/pull/34573 Test Plan: test_buck and the "test Docker android" must be green. Reviewed By: cipolleschi Differential Revision: D39235674 Pulled By: cortinico fbshipit-source-id: 574338e74aeb4635c67d91de28780fb784c9f405 --- .circleci/config.yml | 2 +- .../java/com/facebook/react/uimanager/JSPointerDispatcher.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a5e010bc47c79a..ee8f1a63da1f5f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -905,7 +905,7 @@ jobs: # ------------------------- prepare_hermes_workspace: docker: - - image: debian:bullseye + - image: debian:11.4 environment: - HERMES_WS_DIR: *hermes_workspace_root - HERMES_VERSION_FILE: "sdks/.hermesversion" diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java index f67e79a3b02432..8c10504d669b5a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java @@ -361,7 +361,7 @@ private void onMove( List lastHitPath = mLastHitPathByPointerId.containsKey(activePointerId) ? mLastHitPathByPointerId.get(activePointerId) - : Collections.emptyList(); + : new ArrayList(); float[] lastEventCoordinates = mLastEventCoodinatesByPointerId.containsKey(activePointerId) From 1dd74db31fb8943bb23fff405c4cb7b7680714b1 Mon Sep 17 00:00:00 2001 From: Gabriel Donadel Dall'Agnol Date: Mon, 5 Sep 2022 05:11:07 -0700 Subject: [PATCH 002/174] fix: Accessibility example typos (#34559) Summary: While working on https://github.com/facebook/react-native/pull/34552 I noticed that a couple of words inside the Accessibility example files were misspelled. ## Changelog [Internal] [Fixed] - Fix accessibility example typos Pull Request resolved: https://github.com/facebook/react-native/pull/34559 Test Plan: Shouldn't require much testing as this is just fixing some typos inside Accessibility example Reviewed By: cipolleschi Differential Revision: D39252742 Pulled By: jacdebug fbshipit-source-id: 0d3860f438c55d58d0816b9ae65e52925864c8d3 --- .../AccessibilityAndroidExample.android.js | 4 ++-- .../js/examples/Accessibility/AccessibilityExample.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/rn-tester/js/examples/Accessibility/AccessibilityAndroidExample.android.js b/packages/rn-tester/js/examples/Accessibility/AccessibilityAndroidExample.android.js index 35e1be366ca084..2daf0ba27c6709 100644 --- a/packages/rn-tester/js/examples/Accessibility/AccessibilityAndroidExample.android.js +++ b/packages/rn-tester/js/examples/Accessibility/AccessibilityAndroidExample.android.js @@ -153,7 +153,7 @@ class AccessibilityAndroidExample extends React.Component< In the following example, the words "test", "inline links", "another link", and "link that spans multiple lines because the text is so - long", should each be independantly focusable elements, announced as + long", should each be independently focusable elements, announced as their content followed by ", Link". @@ -162,7 +162,7 @@ class AccessibilityAndroidExample extends React.Component< Focusing on the paragraph itself should also announce that there are - "links avaialable", and opening Talkback's links menu should show + "links available", and opening Talkback's links menu should show these same links. diff --git a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js index e3c6e333300ea5..1db5bc2249f662 100644 --- a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js +++ b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js @@ -110,7 +110,7 @@ class AccessibilityExample extends React.Component<{}> { - + This is text one. This is text two. @@ -754,7 +754,7 @@ class AccessibilityActionsExample extends React.Component<{}> { onAccessibilityAction={event => { switch (event.nativeEvent.actionName) { case 'activate': - Alert.alert('Alert', 'Activate accessiblity action'); + Alert.alert('Alert', 'Activate accessibility action'); break; case 'copy': Alert.alert('Alert', 'copy action success'); @@ -762,7 +762,7 @@ class AccessibilityActionsExample extends React.Component<{}> { } }} onPress={() => Alert.alert('Button has been pressed!')} - title="Button with accessiblity action" + title="Button with accessibility action" /> @@ -776,7 +776,7 @@ class AccessibilityActionsExample extends React.Component<{}> { onAccessibilityAction={event => { switch (event.nativeEvent.actionName) { case 'activate': - Alert.alert('Alert', 'Activate accessiblity action'); + Alert.alert('Alert', 'Activate accessibility action'); break; case 'copy': Alert.alert('Alert', 'copy action success'); @@ -800,7 +800,7 @@ function SliderAccessibilityExample(): React.Node { Date: Mon, 5 Sep 2022 05:21:41 -0700 Subject: [PATCH 003/174] fix: image cache did not take into account request cache policy (#34556) Summary: Image Component cache = 'reload' prop not worked correct because inner Image cache did not take into account request cache (cache property convert in RCTConvert into request.cachePolicy). Fixes https://github.com/facebook/react-native/issues/9195 ## Changelog [IOS] [Fixed] - Image Component will not update correctly when passing in new url Pull Request resolved: https://github.com/facebook/react-native/pull/34556 Test Plan: Reproduce code: https://snack.expo.dev/rundbom/image-should-update Reviewed By: cipolleschi Differential Revision: D39206324 Pulled By: jacdebug fbshipit-source-id: 2293382279e92f3b2bfcd36b54af47d1813c5cdf --- Libraries/Image/RCTImageLoader.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/Image/RCTImageLoader.mm b/Libraries/Image/RCTImageLoader.mm index 85a1fbae64c4e1..bf64f9c852a254 100644 --- a/Libraries/Image/RCTImageLoader.mm +++ b/Libraries/Image/RCTImageLoader.mm @@ -501,6 +501,10 @@ - (RCTImageURLLoaderRequest *)_loadImageOrDataWithURLRequest:(NSURLRequest *)req BOOL cacheResult = [loadHandler respondsToSelector:@selector(shouldCacheLoadedImages)] ? [loadHandler shouldCacheLoadedImages] : YES; + if (request.cachePolicy == NSURLRequestReloadIgnoringLocalCacheData) { + cacheResult = NO; + } + if (cacheResult && partialLoadHandler) { UIImage *image = [[self imageCache] imageForUrl:request.URL.absoluteString size:size From 5c109b37a42d16b35d8ddf2371d42d47f4d49fb2 Mon Sep 17 00:00:00 2001 From: cyrus25 Date: Mon, 5 Sep 2022 05:37:35 -0700 Subject: [PATCH 004/174] feat: Added pointerEvents style equivalent to pointerEvents prop (#34586) Summary: This adds `pointerEvents` style which is equivalent to `pointerEvents` prop as requested in https://github.com/facebook/react-native/issues/34425 ## Changelog [General] [Added] - Added pointerEvents style equivalent to pointerEvents prop Pull Request resolved: https://github.com/facebook/react-native/pull/34586 Test Plan: ``` ``` Reviewed By: cipolleschi Differential Revision: D39252830 Pulled By: jacdebug fbshipit-source-id: 94f265a6b6940a4371e7985d5de3b8143693e069 --- .../View/ReactNativeStyleAttributes.js | 1 + Libraries/Components/View/View.js | 10 +- Libraries/StyleSheet/StyleSheetTypes.js | 1 + .../PointerEvents/PointerEventsExample.js | 132 ++++++++++++++++++ 4 files changed, 143 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/View/ReactNativeStyleAttributes.js b/Libraries/Components/View/ReactNativeStyleAttributes.js index 542bfd3a88eedd..620dd8fdad98e8 100644 --- a/Libraries/Components/View/ReactNativeStyleAttributes.js +++ b/Libraries/Components/View/ReactNativeStyleAttributes.js @@ -111,6 +111,7 @@ const ReactNativeStyleAttributes: {[string]: AnyAttributeType, ...} = { borderTopRightRadius: true, borderTopStartRadius: true, opacity: true, + pointerEvents: true, /** * Text diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js index 7822e8184f214b..20b6f90fecb2e7 100644 --- a/Libraries/Components/View/View.js +++ b/Libraries/Components/View/View.js @@ -12,6 +12,7 @@ import type {ViewProps} from './ViewPropTypes'; import ViewNativeComponent from './ViewNativeComponent'; import TextAncestor from '../../Text/TextAncestor'; +import flattenStyle from '../../StyleSheet/flattenStyle'; import * as React from 'react'; export type Props = ViewProps; @@ -27,12 +28,19 @@ const View: React.AbstractComponent< ViewProps, React.ElementRef, > = React.forwardRef( - ({tabIndex, focusable, ...otherProps}: ViewProps, forwardedRef) => { + ( + {tabIndex, focusable, style, pointerEvents, ...otherProps}: ViewProps, + forwardedRef, + ) => { + const flattendStyle = flattenStyle(style); + const newPointerEvents = pointerEvents || flattendStyle?.pointerEvents; return ( diff --git a/Libraries/StyleSheet/StyleSheetTypes.js b/Libraries/StyleSheet/StyleSheetTypes.js index 0ff1d26f64dd29..a78e58061d8be5 100644 --- a/Libraries/StyleSheet/StyleSheetTypes.js +++ b/Libraries/StyleSheet/StyleSheetTypes.js @@ -558,6 +558,7 @@ export type ____ViewStyle_InternalCore = $ReadOnly<{ borderTopWidth?: number | AnimatedNode, opacity?: number | AnimatedNode, elevation?: number, + pointerEvents?: 'auto' | 'none' | 'box-none' | 'box-only', }>; export type ____ViewStyle_Internal = $ReadOnly<{ diff --git a/packages/rn-tester/js/examples/PointerEvents/PointerEventsExample.js b/packages/rn-tester/js/examples/PointerEvents/PointerEventsExample.js index c07f11da6677c2..069ac9384f04da 100644 --- a/packages/rn-tester/js/examples/PointerEvents/PointerEventsExample.js +++ b/packages/rn-tester/js/examples/PointerEvents/PointerEventsExample.js @@ -95,6 +95,36 @@ class NoneExample extends React.Component<$FlowFixMeProps> { } } +class NoneStyleExample extends React.Component<$FlowFixMeProps> { + render(): React.Node { + return ( + this.props.onLog('A unspecified touched')} + style={styles.box}> + A: unspecified + this.props.onLog('B none touched')} + style={[ + styles.box, + styles.boxPassedThrough, + styles.pointerEventNone, + ]}> + + B: none + + this.props.onLog('C unspecified touched')} + style={[styles.box, styles.boxPassedThrough]}> + + C: unspecified + + + + + ); + } +} + /** * Special demo text that makes itself untouchable so that it doesn't destroy * the experiment and confuse the output. @@ -142,6 +172,41 @@ class BoxNoneExample extends React.Component<$FlowFixMeProps> { } } +class BoxNoneStyleExample extends React.Component<$FlowFixMeProps> { + render(): React.Node { + return ( + this.props.onLog('A unspecified touched')} + style={styles.box}> + A: unspecified + this.props.onLog('B box-none touched')} + style={[ + styles.box, + styles.boxPassedThrough, + styles.pointerEventBoxNone, + ]}> + + B: box-none + + this.props.onLog('C unspecified touched')} + style={styles.box}> + C: unspecified + + + this.props.onLog('C explicitly unspecified touched') + } + style={[styles.box, styles.pointerEventAuto]}> + C: explicitly unspecified + + + + ); + } +} + class BoxOnlyExample extends React.Component<$FlowFixMeProps> { render(): React.Node { return ( @@ -177,6 +242,43 @@ class BoxOnlyExample extends React.Component<$FlowFixMeProps> { } } +class BoxOnlyStyleExample extends React.Component<$FlowFixMeProps> { + render(): React.Node { + return ( + this.props.onLog('A unspecified touched')} + style={styles.box}> + A: unspecified + this.props.onLog('B box-only touched')} + style={[styles.box, styles.pointerEventBoxOnly]}> + B: box-only + this.props.onLog('C unspecified touched')} + style={[styles.box, styles.boxPassedThrough]}> + + C: unspecified + + + + this.props.onLog('C explicitly unspecified touched') + } + style={[ + styles.box, + styles.boxPassedThrough, + styles.pointerEventAuto, + ]}> + + C: explicitly unspecified + + + + + ); + } +} + type OverflowExampleProps = $ReadOnly<{| overflow: 'hidden' | 'visible', onLog: (msg: string) => void, @@ -242,18 +344,36 @@ const exampleClasses: Array = [ description: '`none` causes touch events on the container and its child components to pass through to the parent container.', }, + { + Component: NoneStyleExample, + title: '`none` style', + description: + '`none` causes touch events on the container and its child components to pass through to the parent container.', + }, { Component: BoxNoneExample, title: '`box-none`', description: '`box-none` causes touch events on the container to pass through and will only detect touch events on its child components.', }, + { + Component: BoxNoneStyleExample, + title: '`box-none` style', + description: + '`box-none` causes touch events on the container to pass through and will only detect touch events on its child components.', + }, { Component: BoxOnlyExample, title: '`box-only`', description: "`box-only` causes touch events on the container's child components to pass through and will only detect touch events on the container itself.", }, + { + Component: BoxOnlyStyleExample, + title: '`box-only` style', + description: + "`box-only` causes touch events on the container's child components to pass through and will only detect touch events on the container itself.", + }, { Component: OverflowVisibleExample, title: '`overflow: visible`', @@ -326,6 +446,18 @@ const styles = StyleSheet.create({ borderColor: '#f0f0f0', backgroundColor: '#f9f9f9', }, + pointerEventBoxNone: { + pointerEvents: 'box-none', + }, + pointerEventBoxOnly: { + pointerEvents: 'box-only', + }, + pointerEventNone: { + pointerEvents: 'none', + }, + pointerEventAuto: { + pointerEvents: 'auto', + }, }); exports.framework = 'React'; From 9c05f42d7fb085ff85c964c46b86fbac8bdbbec6 Mon Sep 17 00:00:00 2001 From: Thibault Malbranche Date: Mon, 5 Sep 2022 09:35:30 -0700 Subject: [PATCH 005/174] add changelog for 0.70 (#34202) Summary: # WIP Adds changelog for new release. ## Changelog [Internal] [Changed] - add changelog entry for 0.70.0 Pull Request resolved: https://github.com/facebook/react-native/pull/34202 Test Plan: N/A Reviewed By: cortinico, cipolleschi Differential Revision: D39258933 Pulled By: dmytrorykun fbshipit-source-id: 3aa19301b47aa8cacd5afe35015c2820e96ab4fa --- CHANGELOG.md | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 186 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d17b15bbf4c6a0..d49163d0c9cc82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,195 @@ # Changelog +## 0.70.0 + +### Breaking + +- Remove jest/preprocessor from the react-native package ([0301cb285b](https://github.com/facebook/react-native/commit/0301cb285b2e85b48a397fe58d565196654d9754) by [@motiz88](https://github.com/motiz88)) +- Remove nonstandard Promise.prototype.done ([018d5cf985](https://github.com/facebook/react-native/commit/018d5cf985497273dd700b56168cf1cf64f498d5) by [@motiz88](https://github.com/motiz88)) + +### Added + +- Support TypeScript array types for turbo module (module only) ([f0c4c291e1](https://github.com/facebook/react-native/commit/f0c4c291e12a8e76f91d3841d65291f0f1f16714) by [@ZihanChen-MSFT](https://github.com/ZihanChen-MSFT)) +- Added files for `avn`, `nodenv`, and other managers that set the node.js version in reactive native project including testing ([933fbb1b2b](https://github.com/facebook/react-native/commit/933fbb1b2b4d2b7c802bf1f2be4c47e5b442a850) by [@ramonmedel](https://github.com/ramonmedel)) +- Support BigInt in Hermes ([11bae63bb1](https://github.com/facebook/react-native/commit/11bae63bb1f833802ec6ce01342ebdd1d61e9252) by [@jpporto](https://github.com/jpporto)) +- The old Hermes instrumented stats migrated to the new one ([c37f719567](https://github.com/facebook/react-native/commit/c37f7195675df67d23c3c008ec5ab5fd7b8d0394) by [@jpporto](https://github.com/jpporto)) +- Modified **getDefaultJSExecutorFactory** method ([87cfd386cb](https://github.com/facebook/react-native/commit/87cfd386cb2e02bfa440c94706d9d0274f83070c) by [@KunalFarmah98](https://github.com/KunalFarmah98)) +- `EventEmitter#emit` now freezes the set of listeners before iterating over them, meaning listeners that are added or removed will not affect that iteration. ([e5c5dcd9e2](https://github.com/facebook/react-native/commit/e5c5dcd9e26e9443f59864d9763b049e0bda98e7) by [@yungsters](https://github.com/yungsters)) +- Added File and Blob globals to eslint community config ([d881c87231](https://github.com/facebook/react-native/commit/d881c872314e55e17b198a41c86528d79092d222) by [@shamilovtim](https://github.com/shamilovtim)) +- C++ TurboModule methods can now use mixed types ([3c569f546c](https://github.com/facebook/react-native/commit/3c569f546ca78b23fbcb9773a1273dd9710f8c60) by [@appden](https://github.com/appden)) +- Add useNativeDriver as a param for setValue for Animated ([73191edb72](https://github.com/facebook/react-native/commit/73191edb7255b1ba5e9a0955a25c14250186a676) by [@genkikondo](https://github.com/genkikondo)) +- Add `Animated.Numeric` Flow type ([9eb7629ac6](https://github.com/facebook/react-native/commit/9eb7629ac66abc23b91b81d420891d68bbd4f578) by [@motiz88](https://github.com/motiz88)) +- Add LTI annotations to function params ([c940eb0c49](https://github.com/facebook/react-native/commit/c940eb0c49518b82a3999dcac3027aa70018c763), [e7a4dbcefc](https://github.com/facebook/react-native/commit/e7a4dbcefc9e393c41f4a796d522211bc1e60b6f), [d96744e277](https://github.com/facebook/react-native/commit/d96744e27711c4fa4dfad1b5a796283a232e60af) by [@pieterv](https://github.com/pieterv)) + +#### Android specific + +- Accessibility announcement for list and grid in FlatList ([2d5882132f](https://github.com/facebook/react-native/commit/2d5882132fb2c533fe9bbba83576b8fac4aca727), [105a2397b6](https://github.com/facebook/react-native/commit/105a2397b6b187a9669ba1c028508a7bb9664009) by [@fabriziobertoglio1987](https://github.com/fabriziobertoglio1987)) +- Add READ_VOICEMAIL and WRITE_VOICEMAIL permissions to PermisionsAndroid library. ([8a2be3e143](https://github.com/facebook/react-native/commit/8a2be3e1438dd145ccb5374d6ef60811047d23aa) by [@zolbooo](https://github.com/zolbooo)) +- Add POST_NOTIFICATIONS, NEARBY_WIFI_DEVICES permission ([0a854c7c8b](https://github.com/facebook/react-native/commit/0a854c7c8b7ffc382c43fa460651a4b4de34c3c7) by [@vincent-paing](https://github.com/vincent-paing)) +- Extend the React Native Gradle plugin to accept a config from package.json ([5f3c5aa529](https://github.com/facebook/react-native/commit/5f3c5aa529ed75414eb339c3d8fd2c9628534621) by [@cortinico](https://github.com/cortinico)) +- Ability to pass a Typeface object to ReactFontManager in addition to a font resource ID ([e2dd2e2a6e](https://github.com/facebook/react-native/commit/e2dd2e2a6ed17b366a3e2ec0942ea1d82a404c5d) by [@thurn](https://github.com/thurn)) +- Option to enable lazyViewManager support with `ViewManagerOnDemandReactPackage` ([d4b59cd9d0](https://github.com/facebook/react-native/commit/d4b59cd9d02a8c4eda3ac4bf89cfe8161847adf0) by [@javache](https://github.com/javache)) +- Support for dataUri in form data ([c663c0ec9d](https://github.com/facebook/react-native/commit/c663c0ec9deee7281f819f222bb29ad79e99f3b8) by [@hetanthakkar1](https://github.com/hetanthakkar1)) +- Add android-only prop documentation at the TextInput js level. ([f2e23215ca](https://github.com/facebook/react-native/commit/f2e23215ca14c3c630aa931cdd114187589ac0fb)) +- Update template to gitignore `android/app/.cxx` ([542d43df9d](https://github.com/facebook/react-native/commit/542d43df9d84a88f742c273391f2596546b4c804) by [@leotm](https://github.com/leotm)) + +#### iOS specific + +- Add Mac Catalyst compatibility (can be enabled in Podfile) ([2fb6a3393d](https://github.com/facebook/react-native/commit/2fb6a3393d545a93518d1b2906bd9453458660a0) by [@Arkkeeper](https://github.com/Arkkeeper)) +- Enabled Hermes Intl ([3fa3aeba93](https://github.com/facebook/react-native/commit/3fa3aeba93f226b97e324f3643b98382947e5985) by [@neildhar](https://github.com/neildhar)) +- HTTP Response headers added to the error object passed to JS code. ([9eb2826f9b](https://github.com/facebook/react-native/commit/9eb2826f9beac5b7476f33e68803ca5a024867db)) +- Add userInterfaceStyle to Alert to override user interface style for iOS 13+ ([47bd78f64f](https://github.com/facebook/react-native/commit/47bd78f64f334b770edc7fabd4b9cceb07a7a503) by [@luoxuhai](https://github.com/luoxuhai)) +- Add function to cleanup codegen folders ([71692889b0](https://github.com/facebook/react-native/commit/71692889b0d89b033c07ef87ee3dbf6d62d79235) by [@cipolleschi](https://github.com/cipolleschi)) +- Cocoapods function to add the `CLANG_CXX_LANGUAGE_STANDARD` to all the targets if needed ([ca8174e15f](https://github.com/facebook/react-native/commit/ca8174e15f77cbeecb7ff7a5a583abb668817777) by [@f-meloni](https://github.com/f-meloni)) +- Support codegen from a single folder ([05aaba9514](https://github.com/facebook/react-native/commit/05aaba95145df0b7f541e391a9f64ba3402cac35) by [@cipolleschi](https://github.com/cipolleschi)) +- Run script phases tests in CI ([c171a6e157](https://github.com/facebook/react-native/commit/c171a6e1572f64b2ab9b26d431c07581d4ae832b) by [@cipolleschi](https://github.com/cipolleschi)) + +### Changed + +- Bump React Native Codegen to 0.70.0 ([a22ceecc84](https://github.com/facebook/react-native/commit/a22ceecc849fc62c926643f4d121cf1e4575c693) by [@dmytrorykun](https://github.com/dmytrorykun), [2a274c1a08](https://github.com/facebook/react-native/commit/2a274c1a082c3291d2df1a4b960bf654e217a4dd) by [@cortinico](https://github.com/cortinico), [ce4246a05c](https://github.com/facebook/react-native/commit/ce4246a05c96cd6fe805499960b105267ac044bb) by [@dmytrorykun](https://github.com/dmytrorykun)) +- Upgrade RN CLI to v9.0.0, Metro to 0.72.1 ([0c2fe96998](https://github.com/facebook/react-native/commit/0c2fe969984fff0676f99fe034b3e49d38ed7db6) by [@thymikee](https://github.com/thymikee), [7e580b97bf](https://github.com/facebook/react-native/commit/7e580b97bf63436978d053926e04adeb9ae6f75f) by [@kelset](https://github.com/kelset), [c504d038c4](https://github.com/facebook/react-native/commit/c504d038c470f7a13fb345f57261172c7c85248c) by [@thymikee](https://github.com/thymikee), [f1d624823f](https://github.com/facebook/react-native/commit/f1d624823fe23eb3d30de00cf78beb71dc1b8413) by [@kelset](https://github.com/kelset), [2b49ac6f8b](https://github.com/facebook/react-native/commit/2b49ac6f8b04953be4cd5bf0b1325986b117763c) by [@thymikee](https://github.com/thymikee)) +- Doc: fix minimum iOS version in requirements section ([ec3c8f4380](https://github.com/facebook/react-native/commit/ec3c8f43800a027a0a717367360421089e7293fd) by [@Simon-TechForm](https://github.com/Simon-TechForm)) +- Remove "Early" in Js error reporting pipeline ([0646551d76](https://github.com/facebook/react-native/commit/0646551d7690cd54847eb468f8e43d71ebebdda9) by [@sshic](https://github.com/sshic)) +- Update @react-native/eslint-plugin-specs to 0.70.0 ([d07fae9b23](https://github.com/facebook/react-native/commit/d07fae9b23c258a60045b666167efd5259b962ce), [afd76f69c7](https://github.com/facebook/react-native/commit/afd76f69c7d2408654ba67ac2ed4d612abfbe0ce) by [@dmytrorykun](https://github.com/dmytrorykun), [ea8d8e2f49](https://github.com/facebook/react-native/commit/ea8d8e2f49ea3ce15faeab500b661a1cacacf8a8) by [@cortinico](https://github.com/cortinico)) +- Do not depend on hermes-engine NPM package anymore ([78cd689f9a](https://github.com/facebook/react-native/commit/78cd689f9a634b152ea09ed6cb4fa858ee26e653) by [@cortinico](https://github.com/cortinico)) +- Add ability to pass `ItemSeparatorComponent` as React Element ([5854b11bf9](https://github.com/facebook/react-native/commit/5854b11bf9d42bab9dbe62b9152a3d3a94e42c13) by [@retyui](https://github.com/retyui)) +- Hermes version bump. ([0b4b7774e2](https://github.com/facebook/react-native/commit/0b4b7774e2d71259962ed36b7acb5c3989c3be9c) by [@dmytrorykun](https://github.com/dmytrorykun), [8c682ddd59](https://github.com/facebook/react-native/commit/8c682ddd599b75a547975104cb6f90eec8753daf) by [@dmytrorykun](https://github.com/dmytrorykun), [eb6767813a](https://github.com/facebook/react-native/commit/eb6767813a0efe04a9e79955b8f6ee909a4a76bf) by [@cortinico](https://github.com/cortinico)) +- Codemod `{...null}` to `{}` in xplat/js ([f392ba6725](https://github.com/facebook/react-native/commit/f392ba67254e95126974fafabf3e4ef0300e24e8) by [@gkz](https://github.com/gkz)) +- Fix TextInput dropping text when used as uncontrolled component with `defaultValue` ([51f49ca998](https://github.com/facebook/react-native/commit/51f49ca9982f24de08f5a5654a5210e547bb5b86)) +- Suppress errors ahead of launch ([67e12a19cb](https://github.com/facebook/react-native/commit/67e12a19cb236fbe0809fbbc9e516b37a5848a6a) by [@gkz](https://github.com/gkz)) +- Suppress missing 'this' annotations ([6c563a507f](https://github.com/facebook/react-native/commit/6c563a507fd8c41e04a1e62e2ba87993c6eb1e2f) by [@pieterv](https://github.com/pieterv)) +- Suppress missing annotations ([66c6a75650](https://github.com/facebook/react-native/commit/66c6a75650f91d61e7e87a8e661d87101e26cf9c) by [@pieterv](https://github.com/pieterv)) +- Use RuntimeConfig instead of VM Experiment Flag to set up the micro task queue. ([753038cf34](https://github.com/facebook/react-native/commit/753038cf345a45d95ab9b9343447f524e1b36840) by [@fbmal7](https://github.com/fbmal7)) +- Update direct Metro dependencies to 0.72.0 ([05dcebc211](https://github.com/facebook/react-native/commit/05dcebc21175a78c6533a8856aed644c45276169) by [@kelset](https://github.com/kelset), [64788cc9fe](https://github.com/facebook/react-native/commit/64788cc9fe42fbedc3e3b1c9c516a079cfa71cd1) by [@huntie](https://github.com/huntie), [bdeb4e0655](https://github.com/facebook/react-native/commit/bdeb4e065532dfb1bb4c9c1e87e8a869a737e48a) by [@jacdebug](https://github.com/jacdebug), [894f652639](https://github.com/facebook/react-native/commit/894f6526399098d825ef32c02eb201cd8ba41873) by [@robhogan](https://github.com/robhogan), [08ebc1cfd8](https://github.com/facebook/react-native/commit/08ebc1cfd88a629389c43abf23b40a2bdf1b1579) by [@arushikesarwani94](https://github.com/arushikesarwani94)) +- ECOSYSTEM.md: update Partner entries ([5471afeebf](https://github.com/facebook/react-native/commit/5471afeebf59853ce31df1ade6a4591414b6aa2f) by [@Simek](https://github.com/Simek)) +- Move ScrollView's contentOffset to common props ([7c581f3d30](https://github.com/facebook/react-native/commit/7c581f3d3007954413d68daf2e868ce93e120615) by [@genkikondo](https://github.com/genkikondo)) +- Upgrade react-native-gradle-plugin to 0.70.2 ([1518f838b7](https://github.com/facebook/react-native/commit/1518f838b70951882f7b414c90407d3eb584cab4), [2176173dcc](https://github.com/facebook/react-native/commit/2176173dcc029ab21bfcdfe5c9e150581db47409) by [@dmytrorykun](https://github.com/dmytrorykun)) +- Update a few metro deps as follow up from the commit from main ([7c7ba1babd](https://github.com/facebook/react-native/commit/7c7ba1babd41b6b60f0dc9f48c34d00235d2fef5) by [@kelset](https://github.com/kelset)) + +#### Android specific + +- Bump Android Gradle Plugin to 7.2.1 ([53c8fc9488](https://github.com/facebook/react-native/commit/53c8fc94882893dd8c337fd29543ae11fd467267) by [@leotm](https://github.com/leotm), [c274456e5b](https://github.com/facebook/react-native/commit/c274456e5b635825560852baa5787e96640800d8) by [@dulmandakh](https://github.com/dulmandakh)) +- Rename NativeModuleCallExceptionHandler to JSExceptionHandler for broader usage ([b6f7689d70](https://github.com/facebook/react-native/commit/b6f7689d701d0409c23ab364356aeb95710c20fa) by [@sshic](https://github.com/sshic)) +- Simplify the Android.mk file in the App Template ([7fb0bb40d2](https://github.com/facebook/react-native/commit/7fb0bb40d2206c734a1feb6b555c22d6d5f2436e) by [@cortinico](https://github.com/cortinico)) +- Make Hermes the default engine on Android ([a7db8df207](https://github.com/facebook/react-native/commit/a7db8df2076f68ae9451ce1c77d7eb09d8cfeb14) by [@cortinico](https://github.com/cortinico)) +- Revamp touch event dispatching methods ([089ff4555a](https://github.com/facebook/react-native/commit/089ff4555af27eec4561b1627298702b4ecee482) by [@sshic](https://github.com/sshic)) +- Demonstrating Dark Mode correctly in the `StatusBar` for the starter template App. ([763dc52387](https://github.com/facebook/react-native/commit/763dc5238721a21847b6d6670b5fa268e3bf2ed4) by [@mrbrentkelly](https://github.com/mrbrentkelly)) +- Bump Gradle to 7.5.0 ([5c8186623a](https://github.com/facebook/react-native/commit/5c8186623ae15388949cfc4143edae86863a447b) by [@leotm](https://github.com/leotm), [99e7373dd2](https://github.com/facebook/react-native/commit/99e7373dd2f20184153377109e0e8e48b5bf46f7) by [@dulmandakh](https://github.com/dulmandakh)) +- Generalized the return type of ViewManagerOnDemandReactPackage.getViewManagerNames ([51e029ec3c](https://github.com/facebook/react-native/commit/51e029ec3ce42ae8df3d367d8f553ec2148eeafc) by [@javache](https://github.com/javache)) +- Don't assert on current activity when call startActivityForResult ([bf6884dc90](https://github.com/facebook/react-native/commit/bf6884dc903154ae32daa50ce7983a9f014be781) by [@sshic](https://github.com/sshic)) +- Adapt template to new architecture autolinking on Android ([9ad7cbc3eb](https://github.com/facebook/react-native/commit/9ad7cbc3eb365190e0bfe290e1025553a807b298) by [@thymikee](https://github.com/thymikee)) +- Replaced reactnativeutilsjni with reactnativejni in the build process to reduce size ([54a4fcbfdc](https://github.com/facebook/react-native/commit/54a4fcbfdcc8111b3010b2c31ed3c1d48632ce4c) by [@SparshaSaha](https://github.com/SparshaSaha)) +- Bump Soloader to 0.10.4 ([b9adf2db20](https://github.com/facebook/react-native/commit/b9adf2db20bf9e1436fa58182d886fd9461df9af) by [@mikehardy](https://github.com/mikehardy)) +- Update the new app template to use CMake instead of Android.mk ([dfd7f70eff](https://github.com/facebook/react-native/commit/dfd7f70effeacfeb06d9c2d4762a279a079ee004) by [@cortinico](https://github.com/cortinico)) +- Refactored usage of kotlin plugin ([be35c6dafb](https://github.com/facebook/react-native/commit/be35c6dafbdb46d2ec165460d4bb12f34de6e878) by [@hurali97](https://github.com/hurali97)) +- Bump Gradle to 7.5.1 ([7a911e0730](https://github.com/facebook/react-native/commit/7a911e073094b533cb5a7ce76932c02f83f4fe5d) by [@AlexanderEggers](https://github.com/AlexanderEggers)) +- Fix error of release builds with Hermes enabled for Windows users ([7fcdb9d9d8](https://github.com/facebook/react-native/commit/7fcdb9d9d8f964d24a5ec3d423c67f49b7650ed8) by [@JoseLion](https://github.com/JoseLion)) + +#### iOS specific + +- Move and test Hermes setup from react_native_pods script into a dedicated file ([468b86bd37](https://github.com/facebook/react-native/commit/468b86bd3710b1d43a492c94fb314cc472f03b86) by [@cipolleschi](https://github.com/cipolleschi)) +- Use the correct operator to decide whether Hermes is enabled or not. ([61488449b9](https://github.com/facebook/react-native/commit/61488449b996da5881e4711e0813e9c90b6e57a1) by [@cipolleschi](https://github.com/cipolleschi)) +- Hermes is now the default engine on iOS. This setting is controlled via `flags[:hermes_enabled]` in the Podfile. ([1115bc77db](https://github.com/facebook/react-native/commit/1115bc77db1090042effc021837f70b28694fa09) by [@hramos](https://github.com/hramos)) +- Move LocalPodspecPatch to dedicated file ([8fe2b591c7](https://github.com/facebook/react-native/commit/8fe2b591c7e073d629e95cd7b67aa1dfa96ece38) by [@cipolleschi](https://github.com/cipolleschi)) +- Move the `modify_flags_for_new_architecture` method to separate ruby file ([71da21243c](https://github.com/facebook/react-native/commit/71da21243c85283445c6cefa64d1ace13823ab69) by [@cipolleschi](https://github.com/cipolleschi)) +- Refactoring part of the react_native_pods.rb script ([4f732ba9ee](https://github.com/facebook/react-native/commit/4f732ba9ee2a1e162729c97d5c12ea771b3a424a), [7a2704455f](https://github.com/facebook/react-native/commit/7a2704455f3edf203d2ecc8135fabf2667f718d8) by [@cipolleschi](https://github.com/cipolleschi)) +- When Hermes is enabled, it will use the same copy of JSI as React Native ([340612a200](https://github.com/facebook/react-native/commit/340612a200505ca829bae1f9bce800d3673dac04) by [@hramos](https://github.com/hramos)) +- Move `use_flipper` logic inside `use_react_native` and simplify the Flipper dependencies logic ([0bd5239553](https://github.com/facebook/react-native/commit/0bd523955385a3b1e622077b7ee4ea0df3c5c158) by [@f-meloni](https://github.com/f-meloni)) +- Export `flipper.rb` script file ([e07a7eb16b](https://github.com/facebook/react-native/commit/e07a7eb16b97e1222e23f935a3d4bb3dac848ef2) by [@cipolleschi](https://github.com/cipolleschi)) +- Use `outputDir` as base directory for the codegen and remove the possibility to customize the intermediate path. The generated code requires specific paths in the `#include` directive. ([e4d0153a67](https://github.com/facebook/react-native/commit/e4d0153a675fbdd8718f433b2e9f8bfdccec4b2f) by [@cipolleschi](https://github.com/cipolleschi)) +- Refactor part of the codegen scripts and add tests. ([0465c3fd10](https://github.com/facebook/react-native/commit/0465c3fd102525b005826f3c68923d7e9851d6b8), [305a054865](https://github.com/facebook/react-native/commit/305a0548652a405d9f638fb2c054781951dfc996) by [@cipolleschi](https://github.com/cipolleschi)) +- CodeGen now supports the `"all"` library type. ([6718500eaa](https://github.com/facebook/react-native/commit/6718500eaaeb92b8a74320dcee961ac96f6f12fa) by [@cipolleschi](https://github.com/cipolleschi)) +- Fix the test_ios_unit test ([fdbe4719e2](https://github.com/facebook/react-native/commit/fdbe4719e2e2b599e86d42c49d42c4da97ef431a) by [@cipolleschi](https://github.com/cipolleschi)) +- Update Podfile to allow `PRODUCTION=1 pod install` ([77752fc403](https://github.com/facebook/react-native/commit/77752fc4037e66d5b0a5851bae79c4d3285ed334) by [@leotm](https://github.com/leotm)) +- Destruct use_reactnative parameters and ad ddocumentation ([79a37e5a88](https://github.com/facebook/react-native/commit/79a37e5a88e179090ade7145a453a46719c87b3f) by [@cipolleschi](https://github.com/cipolleschi)) +- Move codegen in separate files ([7d069b2583](https://github.com/facebook/react-native/commit/7d069b25835ad20654a46ebb1e09631d826598e0) by [@cipolleschi](https://github.com/cipolleschi)) +- Silence warning due to react-native internal details. ([a4599225f5](https://github.com/facebook/react-native/commit/a4599225f5a6a2d6801dd80b7728c1bbe5b2ec3a) by [@cipolleschi](https://github.com/cipolleschi)) + +### Removed + +- Remove previously deprecated Transform style-attribute props ([7cfd77debd](https://github.com/facebook/react-native/commit/7cfd77debd36f867f5ddfdb9cc44fbe6137aaeba) by [@Zachinquarantine](https://github.com/Zachinquarantine)) +- Remove deprecated `isTVOS` constant. ([6075d64acf](https://github.com/facebook/react-native/commit/6075d64acf6f8d74e18ef6568c9438f73fe56d44) by [@Zachinquarantine](https://github.com/Zachinquarantine)) +- The diffs renames the required variable which was causing conflicts in names with Apple core SDK's ([086c13dd5f](https://github.com/facebook/react-native/commit/086c13dd5fba3f77acbc70c9bdedc9299118b526) by [@arinjay](https://github.com/arinjay)) +- Removed `EventEmitter.prototype.removeSubscription` method. ([870755fa7e](https://github.com/facebook/react-native/commit/870755fa7e7011ac46d269d5fb66d2a1d1543442) by [@yungsters](https://github.com/yungsters)) +- Remove deprecated removeListener methods ([2596b2f695](https://github.com/facebook/react-native/commit/2596b2f6954362d2cd34a1be870810ab90cbb916) by [@matinzd](https://github.com/matinzd)) +- Remove APPLETVOS variants from BUCk targets. ([cf2e27c388](https://github.com/facebook/react-native/commit/cf2e27c3888ded6f851ba267597ef13f1d0cfd8c) by [@d16r](https://github.com/d16r)) + +#### iOS specific + +- Remove `emulateUnlessSupported` ([c73e021a4b](https://github.com/facebook/react-native/commit/c73e021a4b11bbae3a7868670d140fe3d5dac6ae) by [@ken0nek](https://github.com/ken0nek)) +- Remove USE_CODEGEN_DISCOVERY flag ([2e720c3610](https://github.com/facebook/react-native/commit/2e720c361001d996ed35d8bfbf4dc67c31fb895d) by [@cipolleschi](https://github.com/cipolleschi)) + +### Fixed + +- Throw JSINativeException from asHostObject ([ef6ab3f5ca](https://github.com/facebook/react-native/commit/ef6ab3f5cad968d7b2c9127d834429b0f4e1b2cf) by [@neildhar](https://github.com/neildhar)) +- Use new Babel parser instead of deprecated one ([97291bfa31](https://github.com/facebook/react-native/commit/97291bfa3157ac171a2754e19a52d006040961fb) by [@Kerumen](https://github.com/Kerumen)) +- Fixed a crash on deserialization of props when using 'px'/'em' units. ([70788313fe](https://github.com/facebook/react-native/commit/70788313fedd40fe2e6d1cf15980ce3cca5adaac) by [@nlutsenko](https://github.com/nlutsenko)) +- Fix nullability lost on readonly types in TurboModule specs ([c006722e6c](https://github.com/facebook/react-native/commit/c006722e6cdbe02711cb50ea7a739e0d4d81c7e7) by [@appden](https://github.com/appden)) +- Make tests pass for windows ([9596bf045d](https://github.com/facebook/react-native/commit/9596bf045d527e27608ac4b7b2990a4e6846fdeb) by [@cipolleschi](https://github.com/cipolleschi)) +- Handle possible null exception on ReactEditText with AppCompat 1.4.0 ([24a1f5c66c](https://github.com/facebook/react-native/commit/24a1f5c66c8633f9b41eef45df3297ffc1d2b606) by [@mikemasam](https://github.com/mikemasam)) +- Fixed the disappearance of items when scrolling after zooming VirtualizedList. ([13a72e0ccc](https://github.com/facebook/react-native/commit/13a72e0ccceb2db6aeacd03b4f429d200392c17b) by [@islandryu](https://github.com/islandryu)) +- Improved Flow type inference in Animated `.interpolate()` ([7b86fa2b79](https://github.com/facebook/react-native/commit/7b86fa2b795647f5c89e04e4c3ee4b83bc27ef77) by [@motiz88](https://github.com/motiz88)) +- Add Jest mock for Vibration module ([79529a1c77](https://github.com/facebook/react-native/commit/79529a1c77e7e1b174fdbe8103a2199c9ac924ff) by [@hduprat](https://github.com/hduprat)) +- Allow ReactInstrumentationTest to use custom JSIModules ([eb2a83b0be](https://github.com/facebook/react-native/commit/eb2a83b0be4658654fc6ca6f4671e45f1898798d) by [@christophpurrer](https://github.com/christophpurrer)) +- Working around Long paths limitation on Windows ([883a93871c](https://github.com/facebook/react-native/commit/883a93871cb1fbca4434600a322f63afbba333da) by [@mganandraj](https://github.com/mganandraj)) +- Fix eslint-plugin-specs prepack npm lifecycle hook now that we use npm 8 ([8441c4a6f7](https://github.com/facebook/react-native/commit/8441c4a6f7bfeda73f89f076fe7d8d1132e4b9be) by [@kelset](https://github.com/kelset)) +- Codegen should ignore `.d.ts` files ([0f0d52067c](https://github.com/facebook/react-native/commit/0f0d52067cb89fdb39a99021f0745282ce087fc2) by [@tido64](https://github.com/tido64)) +- Avoid full copy of large folly::dynamic objects in JSIExecutor#defaultTimeoutInvoker ([521011d4cc](https://github.com/facebook/react-native/commit/521011d4cc713dfce97dc8872fd0f5171e587b5d) by [@christophpurrer](https://github.com/christophpurrer)) + +#### Android specific + +- Fixed HorizontalScrollView API scrollToEnd causing NPE in side-effects. ([e5ba6ab7b4](https://github.com/facebook/react-native/commit/e5ba6ab7b482c380e35765b898e522e9d4e1d3b0) by [@ryancat](https://github.com/ryancat)) +- Fix InputAccessoryView crash on Android ([afa5df1764](https://github.com/facebook/react-native/commit/afa5df1764324f2574d102abeae7199d4b02d183) by [@hduprat](https://github.com/hduprat)) +- Bring back non-rootview touch handling based on reactTag ([8b837268b4](https://github.com/facebook/react-native/commit/8b837268b49fd4e72a05f955c20702c457a68fab) by [@fkgozali](https://github.com/fkgozali)) +- Make Text not focusable by default ([8ced165e53](https://github.com/facebook/react-native/commit/8ced165e53135d9d33cfdc55a9d4660f8eb5b3c5) by [@kacieb](https://github.com/kacieb)) +- Revert [PR 33924](https://github.com/facebook/react-native/pull/33924) because of issues with TextInputs with numeric keyboard types not respecting the secureTextEntry prop ([edb27e3aa1](https://github.com/facebook/react-native/commit/edb27e3aa1210ef33d55c1840065457c31b19cb0) by [@charlesbdudley](https://github.com/charlesbdudley)) +- Fix edge case when we enqueue a pending event to views on stopped surface ([ea7c9f2ad9](https://github.com/facebook/react-native/commit/ea7c9f2ad9a78b16234306932edc1d78b783ac27) by [@ryancat](https://github.com/ryancat)) +- Fix a bug where the keyboard, once set as email, won't change back to default. ([ec307e0167](https://github.com/facebook/react-native/commit/ec307e0167deca7f17640cd3c5a60f6be5f47b62) by [@larkox](https://github.com/larkox)) +- NPE in `ReactEditText.setInputType` when React Native is used with some versions of a AppCompat 1.4.x. (and possibly others) ([92ebb298e2](https://github.com/facebook/react-native/commit/92ebb298e2e5ad640754e09ce3a37d3de1d28f58)) +- Fix NPE on `ReactEditText` due to null mFabricViewStateManager ([ba6bf5a3ce](https://github.com/facebook/react-native/commit/ba6bf5a3ce7039a7e407a6632ee41aa3d504f833) by [@cortinico](https://github.com/cortinico)) +- Scroll views would still receive scroll events when nested in a view with `pointer-events: "none"` ([fced96bf52](https://github.com/facebook/react-native/commit/fced96bf5202e8b89b804ccc1004abacc9f91660) by [@javache](https://github.com/javache)) +- Fixed an edge case that event dispatching is failed after pre-allocation of a view and before the view is mounted. ([a093fe5f2f](https://github.com/facebook/react-native/commit/a093fe5f2fae4e9996b0cbffdfccdce8e58e8cf1) by [@ryancat](https://github.com/ryancat)) +- Avoid crash by handling missing views in dispatchViewManagerCommand ([ee1a191cb1](https://github.com/facebook/react-native/commit/ee1a191cb1c10085722d57fc276734f83e86a4f3) by [@hsource](https://github.com/hsource)) +- Pass react build dir to cmake ([6ab7a99518](https://github.com/facebook/react-native/commit/6ab7a99518f8ba0d53e62e35d230ebec78e50217) by [@janicduplessis](https://github.com/janicduplessis)) +- Fix missing space in ReactPropertyException message ([24560b6718](https://github.com/facebook/react-native/commit/24560b67184da00e05491af38289865c4b934ee8) by [@markv](https://github.com/markv)) +- Fix import path breakage ([2e1e62f2bf](https://github.com/facebook/react-native/commit/2e1e62f2bf043ea0bf9926e1f5786ca54a22005e) by [@aniketmathur](https://github.com/aniketmathur)) +- When `onEndReachedThreshold` is set to 0 `onEndReached` function on `VirtualizedList` properly fires once the user scrolls to the bottom of the list. ([b869680c11](https://github.com/facebook/react-native/commit/b869680c1196a6549154a4b9cb7ffa10eab1989c)) +- Fix rendering of transparent borders in RN Android ([a9659ce86d](https://github.com/facebook/react-native/commit/a9659ce86d94dd34768b067763740a5c41917e42) by [@mdvacca](https://github.com/mdvacca)) +- Exception with `Cannot load WebView` message will initialising WebView (along with existing checks) ([9e0d8696cc](https://github.com/facebook/react-native/commit/9e0d8696cc68436a0d309cafde252c55fc337be4) by [@rachitmishra](https://github.com/rachitmishra)) +- Fix accessibilityState overwriting view's disabled state on Android ([f35d18caa3](https://github.com/facebook/react-native/commit/f35d18caa302351319840ec85337182f4f148e5e) by [@okwasniewski](https://github.com/okwasniewski)) +- Make sure *.ts files are considered for task avoidance in the Gradle Plugin ([1a9fb6cb68](https://github.com/facebook/react-native/commit/1a9fb6cb682aa5ff83462e1e2869eb99f3b873fd) by [@cortinico](https://github.com/cortinico)) +- Fix missing import on New Architecture build script in template ([a22f30d2ce](https://github.com/facebook/react-native/commit/a22f30d2ce866cb1488b26bb18eee0620a0ac259) by [@cortinico](https://github.com/cortinico)) + +#### iOS specific + +- Use `NODE_BINARY` from `.xcode.env` when running packager from Xcode ([ff785dbcf5](https://github.com/facebook/react-native/commit/ff785dbcf5c464a4d850fa738e977702efd8abd3) by [@elsurudo](https://github.com/elsurudo)) +- Bug with error message formatting when bundle is missing ([f501979f3d](https://github.com/facebook/react-native/commit/f501979f3d1e5c053eed16967a3d3385eab8e15f) by [@BenLorantfy](https://github.com/BenLorantfy)) +- Fix the race condition when calling readAsDataURL after new Blob(blobs) ([bd12e41188](https://github.com/facebook/react-native/commit/bd12e41188c8d85c0acbd713f10f0bd34ea0edca) by [@wood1986](https://github.com/wood1986)) +- Fix the way the orientation events are published, to avoid false publish on orientation change when app changes state to inactive ([7d42106d4c](https://github.com/facebook/react-native/commit/7d42106d4ce20c644bda4d928fb0abc163580cee) by [@lbaldy](https://github.com/lbaldy)) +- Fix sed error when installing `glog` ([4a7e4b9ca6](https://github.com/facebook/react-native/commit/4a7e4b9ca6ef4fb52611b6c3cb788f624d1f81a4) by [@alphashuro](https://github.com/alphashuro)) +- Don't validate ENTRY_FILE in react-native-xcode.sh ([780fe80fca](https://github.com/facebook/react-native/commit/780fe80fcaf213d84d9d087132af933bd02d1349) by [@janicduplessis](https://github.com/janicduplessis)) +- `_scrollViewComponentView` is set to `RCTPullToRefreshViewComponentView's` superview ([4e4b9e2111](https://github.com/facebook/react-native/commit/4e4b9e2111faaf5652ae1f5b885730b378f3de98) by [@dmytrorykun](https://github.com/dmytrorykun)) +- Use `GCC_PREPROCESSOR_DEFINITIONS` to set `FB_SONARKIT_ENABLED` ([77e6bff629](https://github.com/facebook/react-native/commit/77e6bff629312f20cdacb1e798cd2464ac50db9e) by [@janicduplessis](https://github.com/janicduplessis)) +- Fix Hermes not being properly downloaded during pod install ([d5e0659fcc](https://github.com/facebook/react-native/commit/d5e0659fccf2767beb7aae55461e9690ba335c81) by [@cortinico](https://github.com/cortinico)) +- Typo in the documation for the `automaticallyAdjustKeyboardInsets` prop ([927b43d47c](https://github.com/facebook/react-native/commit/927b43d47c2cd42538265cb06154b12cb0be6816) by [@jeremybarbet](https://github.com/jeremybarbet)) +- Deprecate iOS/tvOS SDK 11.0 support now that 12.4+ is required ([f56d701e56](https://github.com/facebook/react-native/commit/f56d701e567af0c252a2e297bf81cd4add59378a) by [@leotm](https://github.com/leotm)) +- Fix blank spaces that don't recover as you scroll when in an RTL locale and e.nativeEvent.zoomScale is -1. ([bc7b5c3011](https://github.com/facebook/react-native/commit/bc7b5c3011460935614a47a03cd077cd1059de72), [2f491bfa9f](https://github.com/facebook/react-native/commit/2f491bfa9f86c3db2e459e331f39bc3cf12e7239)) +- Fixed paddingTop not being applied when using padding and paddingVertical in multiline textinput ([2fb107c9a6](https://github.com/facebook/react-native/commit/2fb107c9a63aacd2c880ad6abedaad67ffb6022b) by [@hetanthakkar1](https://github.com/hetanthakkar1)) +- Fixed the ability to pass the port to use for Metro when running `react-native run-ios --port `. ([7dc0b5153e](https://github.com/facebook/react-native/commit/7dc0b5153e4eb91c333238a58fe8c75a47cb5f81) by [@lindboe](https://github.com/lindboe)) +- Fix missing imports ([c78babac39](https://github.com/facebook/react-native/commit/c78babac39b7c64e03e137d8fddd91e783303426)) +- Fix React-bridging headers import not found ([c4b51e8d76](https://github.com/facebook/react-native/commit/c4b51e8d7679c3c20b843072581acd23a931fc83) by [@Kudo](https://github.com/Kudo)) +- Fix Hermes executor not available when `use_frameworks` is enabled ([88b7b640a7](https://github.com/facebook/react-native/commit/88b7b640a74bafd918b8b1cd5d58e1f5ddfb730a) by [@Kudo](https://github.com/Kudo)) + +### Security + +- Add GitHub token permissions for workflows ([3da3d82320](https://github.com/facebook/react-native/commit/3da3d82320bd035c6bd361a82ea12a70dba4e851) by [@varunsh-coder](https://github.com/varunsh-coder)) +- Bump RCT-Folly to 2021-07-22 ([68f3a42fc7](https://github.com/facebook/react-native/commit/68f3a42fc7380051714253f43b42175de361f8bd) by [@luissantana](https://github.com/luissantana)) + ## v0.69.5 ### Changed -- Bump react-native-codegen to 0.69.2 ([df3d52bfbf](https://github.com/facebook/react-native/commit/df3d52bfbf4254cd16e1dc0ca0af2743cd7e11c1) by [@dmitryrykun](https://github.com/dmitryrykun)) +- Bump react-native-codegen to 0.69.2 ([df3d52bfbf](https://github.com/facebook/react-native/commit/df3d52bfbf4254cd16e1dc0ca0af2743cd7e11c1) by [@dmytrorykun](https://github.com/dmytrorykun)) #### Android specific From a50e6fb341eacd955071e4a7c6d734e7d3c94cd7 Mon Sep 17 00:00:00 2001 From: madhav23bansal Date: Mon, 5 Sep 2022 10:01:24 -0700 Subject: [PATCH 006/174] Feat/role to accessibility role mapping (#34538) Summary: This adds role alias for accessibilityRole, it unifies role and accessibilityRole as requested on https://github.com/facebook/react-native/issues/34424 ## Changelog [General][Added] - Added role alias for accessibilityRole. Pull Request resolved: https://github.com/facebook/react-native/pull/34538 Test Plan: ```js Dotted border style ``` Reviewed By: cipolleschi Differential Revision: D39169722 Pulled By: jacdebug fbshipit-source-id: cbcbda5ff900c18509b9f3c88e145a3f8700c78d --- Libraries/Components/View/View.js | 82 ++++++++++++++++++- .../Components/View/ViewAccessibility.js | 67 +++++++++++++++ Libraries/Components/View/ViewPropTypes.js | 6 ++ 3 files changed, 154 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js index 20b6f90fecb2e7..76ec6975c7c150 100644 --- a/Libraries/Components/View/View.js +++ b/Libraries/Components/View/View.js @@ -29,15 +29,95 @@ const View: React.AbstractComponent< React.ElementRef, > = React.forwardRef( ( - {tabIndex, focusable, style, pointerEvents, ...otherProps}: ViewProps, + { + tabIndex, + focusable, + role, + accessibilityRole, + pointerEvents, + style, + ...otherProps + }: ViewProps, forwardedRef, ) => { + // Map role values to AccessibilityRole values + const roleToAccessibilityRoleMapping = { + alert: 'alert', + alertdialog: undefined, + application: undefined, + article: undefined, + banner: undefined, + button: 'button', + cell: undefined, + checkbox: 'checkbox', + columnheader: undefined, + combobox: 'combobox', + complementary: undefined, + contentinfo: undefined, + definition: undefined, + dialog: undefined, + directory: undefined, + document: undefined, + feed: undefined, + figure: undefined, + form: undefined, + grid: 'grid', + group: undefined, + heading: 'header', + img: 'image', + link: 'link', + list: 'list', + listitem: undefined, + log: undefined, + main: undefined, + marquee: undefined, + math: undefined, + menu: 'menu', + menubar: 'menubar', + menuitem: 'menuitem', + meter: undefined, + navigation: undefined, + none: 'none', + note: undefined, + presentation: 'none', + progressbar: 'progressbar', + radio: 'radio', + radiogroup: 'radiogroup', + region: undefined, + row: undefined, + rowgroup: undefined, + rowheader: undefined, + scrollbar: 'scrollbar', + searchbox: 'search', + separator: undefined, + slider: 'adjustable', + spinbutton: 'spinbutton', + status: undefined, + summary: 'summary', + switch: 'switch', + tab: 'tab', + table: undefined, + tablist: 'tablist', + tabpanel: undefined, + term: undefined, + timer: 'timer', + toolbar: 'toolbar', + tooltip: undefined, + tree: undefined, + treegrid: undefined, + treeitem: undefined, + }; + const flattendStyle = flattenStyle(style); const newPointerEvents = pointerEvents || flattendStyle?.pointerEvents; + return ( Date: Mon, 5 Sep 2022 11:45:12 -0700 Subject: [PATCH 007/174] Attempt fix for `cellsAroundViewport` reaching out of bounds Summary: VirtualizedList would more gracefully handle out of range cells than VirtualizedList_EXPERIMENTAL, which treats it as an invariant violation. This attempts to fix an issue where recalculation of cells around viewport can include out of range cells. Reviewed By: rshest Differential Revision: D39244112 fbshipit-source-id: 20fe6ea552035061d9d00720fcab77b29a785771 --- Libraries/Lists/VirtualizeUtils.js | 2 +- Libraries/Lists/VirtualizedList_EXPERIMENTAL.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Libraries/Lists/VirtualizeUtils.js b/Libraries/Lists/VirtualizeUtils.js index 3936bf6f6491e9..3a70d9f683091e 100644 --- a/Libraries/Lists/VirtualizeUtils.js +++ b/Libraries/Lists/VirtualizeUtils.js @@ -128,7 +128,7 @@ export function computeWindowedRenderLimits( } { const itemCount = props.getItemCount(props.data); if (itemCount === 0) { - return prev; + return {first: 0, last: -1}; } const {offset, velocity, visibleLength, zoomScale = 1} = scrollMetrics; diff --git a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js index 4641ec0b0860d1..ebe059a01bd14f 100644 --- a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js +++ b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js @@ -641,7 +641,9 @@ class VirtualizedList extends StateSafePureComponent { !this._scrollMetrics.offset && Math.abs(distanceFromEnd) >= Number.EPSILON ) { - return cellsAroundViewport; + return cellsAroundViewport.last >= getItemCount(data) + ? VirtualizedList._constrainToItemCount(cellsAroundViewport, props) + : cellsAroundViewport; } newCellsAroundViewport = computeWindowedRenderLimits( From bf6a24bd4660819354cc0a562813590f2abe0164 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Tue, 6 Sep 2022 03:25:45 -0700 Subject: [PATCH 008/174] Add Matrix tests for Flipper/NoFlipper (#34595) Summary: This PR adds some tests to verify that we can build the template in every Debug configuration using Flipper and without Flipper. ## Changelog [iOS] [Added] - Add CircleCI tests to verify that we can run the Template with and without Flipper Pull Request resolved: https://github.com/facebook/react-native/pull/34595 Test Plan: CircleCI is green Reviewed By: cortinico Differential Revision: D39262137 Pulled By: cipolleschi fbshipit-source-id: dae45b106cd13fb69442ea216005cee114d861f4 --- .circleci/config.yml | 22 ++++++++++++++++++++-- template/ios/Podfile | 4 +++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ee8f1a63da1f5f..514315b4f61ca7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -689,11 +689,24 @@ jobs: jsengine: type: string default: "Hermes" + flipper: + type: string + default: "WithFlipper" environment: - PROJECT_NAME: "iOSTemplateProject" - HERMES_WS_DIR: *hermes_workspace_root - steps: + # Early exit in case of Release and WithFlipper. The two does not make sense together. + # Unfortunately, the `exclude` parameter of `matrix` does not work, so we have to do it manually. + - when: + condition: + and: + - equal: [ << parameters.flavor >>, "Release"] + - equal: [ << parameters.flipper >>, "WithFlipper" ] + steps: + - run: + command: circleci-agent step halt # this interrupts the job successfully. + # Valid configuration, we can continue - checkout_code_with_cache - run_yarn - attach_workspace: @@ -716,7 +729,7 @@ jobs: node ./scripts/set-rn-template-version.js "file:$PATH_TO_PACKAGE" node cli.js init $PROJECT_NAME --directory "/tmp/$PROJECT_NAME" --template $REPO_ROOT --verbose --skip-install - run: - name: Install iOS dependencies - Configuration << parameters.flavor >>; New Architecture << parameters.architecture >>; JS Engine << parameters.jsengine>> + name: Install iOS dependencies - Configuration << parameters.flavor >>; New Architecture << parameters.architecture >>; JS Engine << parameters.jsengine>>; Flipper << parameters.flipper >> command: | cd /tmp/$PROJECT_NAME yarn install @@ -736,6 +749,10 @@ jobs: export USE_HERMES=0 fi + if [[ << parameters.flipper >> == "WithoutFlipper" ]]; then + export NO_FLIPPER=1 + fi + bundle exec pod install - run: name: Build template project @@ -1347,6 +1364,7 @@ workflows: architecture: ["NewArch", "OldArch"] flavor: ["Debug", "Release"] jsengine: ["Hermes", "JSC"] + flipper: ["WithFlipper", "WithoutFlipper"] - test_ios_rntester: requires: - build_hermes_macos diff --git a/template/ios/Podfile b/template/ios/Podfile index d1953783520bd6..006397252e5c65 100644 --- a/template/ios/Podfile +++ b/template/ios/Podfile @@ -4,6 +4,8 @@ require_relative '../node_modules/react-native/scripts/native_modules' platform :ios, '12.4' install! 'cocoapods', :deterministic_uuids => false +flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled + target 'HelloWorld' do config = use_native_modules! @@ -21,7 +23,7 @@ target 'HelloWorld' do # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. - :flipper_configuration => FlipperConfiguration.enabled, + :flipper_configuration => flipper_config, # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) From a789ead5459b772a1ae9b17fce6565d4717554f8 Mon Sep 17 00:00:00 2001 From: cyrus25 Date: Tue, 6 Sep 2022 04:47:32 -0700 Subject: [PATCH 009/174] Make style pointerEvents take priority over pointerEvents prop (#34597) Summary: Make style pointerEvents take priority over pointerEvents prop. Fixes requested changes in https://github.com/facebook/react-native/issues/34586 ## Changelog [General] [Fixed] - Make style pointerEvents take priority over pointerEvents prop. FIxes requested changes in https://github.com/facebook/react-native/issues/34586 Pull Request resolved: https://github.com/facebook/react-native/pull/34597 Test Plan: Will rely on green cli Reviewed By: NickGerleman Differential Revision: D39269306 Pulled By: cipolleschi fbshipit-source-id: 0927bf6ad7e3ac63e82dbd1a873532152f29001d --- Libraries/Components/View/View.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js index 76ec6975c7c150..bc2145e52982e2 100644 --- a/Libraries/Components/View/View.js +++ b/Libraries/Components/View/View.js @@ -108,8 +108,8 @@ const View: React.AbstractComponent< treeitem: undefined, }; - const flattendStyle = flattenStyle(style); - const newPointerEvents = pointerEvents || flattendStyle?.pointerEvents; + const flattenedStyle = flattenStyle(style); + const newPointerEvents = flattenedStyle?.pointerEvents || pointerEvents; return ( From 65db77d8493555fcd071c5296ac30d6241bd29b2 Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Tue, 6 Sep 2022 06:48:30 -0700 Subject: [PATCH 010/174] Add `setPadding` accepting `Dimension` Summary: Changelog: [Internal][Added] - Add `setPadding` accepting `Dimension` in Yoga 2 Reviewed By: Andrey-Mishanin Differential Revision: D39260889 fbshipit-source-id: 413367f193e5f5ae0f065f153a637778cdfb5ac4 --- ReactCommon/flexlayout/flexlayout/FlexBoxStyle.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ReactCommon/flexlayout/flexlayout/FlexBoxStyle.h b/ReactCommon/flexlayout/flexlayout/FlexBoxStyle.h index b1645e897f29e9..452944358e7011 100644 --- a/ReactCommon/flexlayout/flexlayout/FlexBoxStyle.h +++ b/ReactCommon/flexlayout/flexlayout/FlexBoxStyle.h @@ -82,6 +82,10 @@ class FLEX_LAYOUT_EXPORT FlexBoxStyle { return padding[static_cast(edge)]; } + void setPadding(Edge edge, Dimension dimension) { + padding[static_cast(edge)] = dimension; + } + void setPadding(Edge edge, Float value) { padding[static_cast(edge)] = Dimension(value, Unit::Point); } From 010cdcdc19c3fc3ed16c7b63b163b3b62ff0ea38 Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Tue, 6 Sep 2022 06:48:30 -0700 Subject: [PATCH 011/174] Add `setMargin` accepting `Dimension` Summary: Changelog: [Internal][Added] - Add `setMargin` accepting `Dimension` in Yoga 2 Reviewed By: Andrey-Mishanin Differential Revision: D39271039 fbshipit-source-id: ff98b23352377b16d353cd6922ee37e48c80e55b --- ReactCommon/flexlayout/flexlayout/FlexItemStyle.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ReactCommon/flexlayout/flexlayout/FlexItemStyle.h b/ReactCommon/flexlayout/flexlayout/FlexItemStyle.h index 1627b69bdf7bed..1a7068e6025bb4 100644 --- a/ReactCommon/flexlayout/flexlayout/FlexItemStyle.h +++ b/ReactCommon/flexlayout/flexlayout/FlexItemStyle.h @@ -132,6 +132,10 @@ class FLEX_LAYOUT_EXPORT FlexItemStyleBase { return margin[static_cast(edge)]; } + void setMargin(Edge edge, Dimension dimension) { + margin[static_cast(edge)] = dimension; + } + void setMargin(Edge edge, Float value) { margin[static_cast(edge)] = Dimension(value, Unit::Point); } From ce50c43986bae05ad62552be46f4d5bb4a46f097 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 6 Sep 2022 07:01:17 -0700 Subject: [PATCH 012/174] Add more clang tidy rules Summary: changelog: [internal] Add more clang tidy rules to prevent common class of bugs. Reviewed By: javache Differential Revision: D39245194 fbshipit-source-id: 5521c5c4653d7005b96ebba494e810ba5075afbc --- ReactCommon/react/renderer/.clang-tidy | 142 ++++++++++++++++++ .../LayoutAnimationKeyFrameManager.cpp | 4 +- .../animations/tests/LayoutAnimationTest.cpp | 4 +- .../ComponentDescriptorProviderRegistry.cpp | 2 +- .../ComponentDescriptorProviderRegistry.h | 2 +- .../ComponentDescriptorRegistry.cpp | 13 +- .../ComponentDescriptorRegistry.h | 5 +- .../native/NativeComponentRegistryBinding.cpp | 4 +- .../AndroidProgressBarShadowNode.cpp | 2 +- .../renderer/components/root/RootProps.cpp | 4 +- .../components/slider/SliderShadowNode.cpp | 2 +- .../androidswitch/AndroidSwitchShadowNode.cpp | 2 +- .../components/text/BaseTextProps.cpp | 2 +- .../components/text/BaseTextShadowNode.cpp | 4 +- .../AndroidTextInputShadowNode.cpp | 2 +- .../iostextinput/TextInputEventEmitter.h | 4 +- .../textinput/iostextinput/TextInputState.cpp | 4 +- .../components/view/AccessibilityProps.cpp | 4 +- .../renderer/components/view/PointerEvent.cpp | 2 +- .../react/renderer/components/view/Touch.cpp | 2 +- .../react/renderer/components/view/Touch.h | 2 +- .../renderer/components/view/TouchEvent.cpp | 2 +- .../react/renderer/core/EventEmitter.cpp | 2 +- .../react/renderer/core/EventTarget.cpp | 2 +- .../react/renderer/core/LayoutMetrics.cpp | 2 +- .../renderer/core/LayoutableShadowNode.cpp | 2 +- ReactCommon/react/renderer/core/Props.cpp | 2 +- ReactCommon/react/renderer/core/RawProps.cpp | 5 +- ReactCommon/react/renderer/core/RawProps.h | 2 +- .../react/renderer/core/RawPropsKey.cpp | 4 +- ReactCommon/react/renderer/core/Sealable.cpp | 4 +- .../react/renderer/core/ShadowNodeFamily.cpp | 2 +- .../core/tests/EventQueueProcessorTest.cpp | 6 +- .../renderer/core/tests/RawPropsTest.cpp | 4 +- .../renderer/debug/DebugStringConvertible.cpp | 8 +- .../react/renderer/graphics/Transform.cpp | 34 +++-- .../react/renderer/graphics/Transform.h | 10 +- .../cxx/react/renderer/graphics/Color.cpp | 4 +- .../renderer/imagemanager/ImageManager.h | 2 +- .../renderer/imagemanager/ImageManager.cpp | 7 +- .../react/renderer/leakchecker/LeakChecker.h | 2 +- .../leakchecker/WeakFamilyRegistry.cpp | 3 +- .../react/renderer/mapbuffer/MapBuffer.cpp | 2 +- .../mapbuffer/tests/MapBufferTest.cpp | 2 +- .../renderer/mounting/Differentiator.cpp | 89 +---------- .../renderer/mounting/MountingCoordinator.cpp | 4 +- .../renderer/mounting/MountingCoordinator.h | 2 +- .../react/renderer/mounting/ShadowTree.cpp | 8 +- .../react/renderer/mounting/ShadowTree.h | 8 +- .../react/renderer/mounting/ShadowView.cpp | 5 +- .../renderer/mounting/ShadowViewMutation.cpp | 6 +- .../renderer/mounting/ShadowViewMutation.h | 4 +- .../react/renderer/mounting/StubView.cpp | 4 +- .../tests/StateReconciliationTest.cpp | 12 +- .../RuntimeSchedulerBinding.cpp | 4 +- .../tests/RuntimeSchedulerTest.cpp | 80 +++++----- .../scheduler/AsynchronousEventBeat.cpp | 2 +- .../react/renderer/scheduler/Scheduler.cpp | 14 +- .../react/renderer/scheduler/Scheduler.h | 2 +- .../renderer/scheduler/SurfaceHandler.cpp | 13 +- .../react/renderer/scheduler/SurfaceHandler.h | 2 +- .../scheduler/SynchronousEventBeat.cpp | 2 +- .../templateprocessor/UITemplateProcessor.h | 4 +- .../tests/UITemplateProcessorTest.cpp | 11 +- .../textlayoutmanager/TextLayoutManager.cpp | 6 +- .../textlayoutmanager/TextLayoutManager.h | 2 +- .../react/renderer/timeline/Timeline.cpp | 9 +- .../renderer/timeline/TimelineController.cpp | 2 +- .../renderer/timeline/TimelineHandler.cpp | 2 +- .../react/renderer/timeline/TimelineHandler.h | 4 +- .../react/renderer/uimanager/UIManager.cpp | 27 ++-- .../react/renderer/uimanager/UIManager.h | 2 +- .../renderer/uimanager/UIManagerBinding.cpp | 88 +++++------ 73 files changed, 412 insertions(+), 331 deletions(-) diff --git a/ReactCommon/react/renderer/.clang-tidy b/ReactCommon/react/renderer/.clang-tidy index f413d1fc8587d5..244e901f289f7a 100644 --- a/ReactCommon/react/renderer/.clang-tidy +++ b/ReactCommon/react/renderer/.clang-tidy @@ -40,5 +40,147 @@ performance-noexcept-move-constructor, performance-type-promotion-in-math-fn, performance-unnecessary-copy-initialization, performance-unnecessary-value-param, +cppcoreguidelines-macro-usage, +cppcoreguidelines-narrowing-conversions, +cppcoreguidelines-no-malloc, +cppcoreguidelines-pro-bounds-pointer-arithmetic, +cppcoreguidelines-pro-type-const-cast, +cppcoreguidelines-pro-type-cstyle-cast, +cppcoreguidelines-pro-type-member-init, +cppcoreguidelines-pro-type-reinterpret-cast, +cppcoreguidelines-pro-type-union-access, +cppcoreguidelines-pro-type-vararg, +cppcoreguidelines-slicing, +cppcoreguidelines-special-member-functions, +readability-avoid-const-params-in-decls, +readability-braces-around-statements, +readability-const-return-type, +readability-container-size-empty, +readability-deleted-default, +readability-delete-null-pointer, +readability-implicit-bool-conversion, +readability-inconsistent-declaration-parameter-name, +readability-isolate-declaration, +readability-misplaced-array-index, +readability-named-parameter, +readability-non-const-parameter, +readability-redundant-control-flow, +readability-redundant-declaration, +readability-redundant-function-ptr-dereference, +readability-redundant-preprocessor, +readability-redundant-smartptr-get, +readability-redundant-string-cstr, +readability-redundant-string-init, +readability-simplify-boolean-expr, +readability-simplify-subscript-expr, +readability-static-accessed-through-instance, +readability-static-definition-in-anonymous-namespace, +readability-string-compare, +readability-uniqueptr-delete-release, +misc-definitions-in-headers, +misc-new-delete-overloads, +misc-non-copyable-objects, +misc-static-assert, +misc-throw-by-value-catch-by-reference, +misc-unconventional-assign-operator, +misc-uniqueptr-reset-release, +misc-unused-alias-decls, +misc-unused-parameters, +misc-unused-using-decls, +bugprone-argument-comment, +bugprone-assert-side-effect, +bugprone-bool-pointer-implicit-conversion, +bugprone-copy-constructor-init, +bugprone-dangling-handle, +bugprone-exception-escape, +bugprone-fold-init-type, +bugprone-forward-declaration-namespace, +bugprone-forwarding-reference-overload, +bugprone-inaccurate-erase, +bugprone-incorrect-roundings, +bugprone-integer-division, +bugprone-macro-parentheses, +bugprone-macro-repeated-side-effects, +bugprone-misplaced-operator-in-strlen-in-alloc, +bugprone-misplaced-widening-cast, +bugprone-move-forwarding-reference, +bugprone-multiple-statement-macro, +bugprone-parent-virtual-call, +bugprone-sizeof-container, +bugprone-sizeof-expression, +bugprone-string-constructor, +bugprone-string-integer-assignment, +bugprone-string-literal-with-embedded-nul, +bugprone-suspicious-enum-usage, +bugprone-suspicious-memset-usage, +bugprone-suspicious-missing-comma, +bugprone-suspicious-semicolon, +bugprone-suspicious-string-compare, +bugprone-swapped-arguments, +bugprone-terminating-continue, +bugprone-throw-keyword-missing, +bugprone-too-small-loop-variable, +bugprone-undefined-memory-manipulation, +bugprone-undelegated-constructor, +bugprone-unused-return-value, +bugprone-use-after-move, +bugprone-virtual-near-miss, +clang-analyzer-apiModeling.StdCLibraryFunctions, +clang-analyzer-apiModeling.TrustNonnull, +clang-analyzer-apiModeling.google.GTest, +clang-analyzer-core.CallAndMessage, +clang-analyzer-core.DivideZero, +clang-analyzer-core.DynamicTypePropagation, +clang-analyzer-core.NonNullParamChecker, +clang-analyzer-core.NonnilStringConstants, +clang-analyzer-core.NullDereference, +clang-analyzer-core.StackAddressEscape, +clang-analyzer-core.UndefinedBinaryOperatorResult, +clang-analyzer-core.VLASize, +clang-analyzer-core.builtin.BuiltinFunctions, +clang-analyzer-core.builtin.NoReturnFunctions, +clang-analyzer-core.uninitialized.ArraySubscript, +clang-analyzer-core.uninitialized.Assign, +clang-analyzer-core.uninitialized.Branch, +clang-analyzer-core.uninitialized.CapturedBlockVariable, +clang-analyzer-core.uninitialized.UndefReturn, +clang-analyzer-cplusplus.InnerPointer, +clang-analyzer-cplusplus.Move, +clang-analyzer-cplusplus.NewDelete, +clang-analyzer-cplusplus.NewDeleteLeaks, +clang-analyzer-cplusplus.SelfAssignment, +clang-analyzer-deadcode.DeadStores, +clang-analyzer-optin.cplusplus.VirtualCall, +clang-analyzer-optin.mpi.MPI-Checker, +clang-analyzer-optin.performance.GCDAntipattern, +clang-analyzer-optin.performance.Padding, +clang-analyzer-optin.portability.UnixAPI, +clang-analyzer-nullability.NullPassedToNonnull, +clang-analyzer-nullability.NullReturnedFromNonnull, +clang-analyzer-nullability.NullableDereferenced, +clang-analyzer-nullability.NullablePassedToNonnull, +clang-analyzer-nullability.NullableReturnedFromNonnull, +clang-analyzer-security.FloatLoopCounter, +clang-analyzer-security.insecureAPI.UncheckedReturn, +clang-analyzer-security.insecureAPI.bcmp, +clang-analyzer-security.insecureAPI.bcopy, +clang-analyzer-security.insecureAPI.bzero, +clang-analyzer-security.insecureAPI.getpw, +clang-analyzer-security.insecureAPI.gets, +clang-analyzer-security.insecureAPI.mkstemp, +clang-analyzer-security.insecureAPI.mktemp, +clang-analyzer-security.insecureAPI.rand, +clang-analyzer-security.insecureAPI.strcpy, +clang-analyzer-security.insecureAPI.vfork, +clang-analyzer-unix.API, +clang-analyzer-unix.Malloc, +clang-analyzer-unix.MallocSizeof, +clang-analyzer-unix.MismatchedDeallocator, +clang-analyzer-unix.Vfork, +clang-analyzer-unix.cstring.BadSizeArg, +clang-analyzer-unix.cstring.NullArg, +clang-analyzer-valist.CopyToSelf, +clang-analyzer-valist.Uninitialized, +clang-analyzer-valist.Unterminated, ' ... diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 00b8cfa69efc6b..fe321a2f1e5e34 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -1183,11 +1183,11 @@ void LayoutAnimationKeyFrameManager::queueFinalMutationsForCompletedKeyFrame( AnimationKeyFrame const &keyframe, ShadowViewMutation::List &mutationsList, bool interrupted, - const std::string &logPrefix) const { + const std::string & /*logPrefix*/) const { if (skipInvalidatedKeyFrames_ && keyframe.invalidated) { return; } - if (keyframe.finalMutationsForKeyFrame.size() > 0) { + if (!keyframe.finalMutationsForKeyFrame.empty()) { // TODO: modularize this segment, it is repeated 2x in KeyFrameManager // as well. ShadowView prev = keyframe.viewPrev; diff --git a/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp b/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp index ea6a5e600a98f7..da1aa6cdcb04f2 100644 --- a/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp +++ b/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp @@ -64,7 +64,7 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( // Create a RuntimeExecutor RuntimeExecutor runtimeExecutor = - [](std::function const &) {}; + [](std::function const & /*unused*/) {}; // Create component descriptor registry for animation driver auto providerRegistry = @@ -158,7 +158,7 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( // If tree randomization produced no changes in the form of mutations, // don't bother trying to animate because this violates a bunch of our // assumptions in this test - if (originalMutations.size() == 0) { + if (originalMutations.empty()) { continue; } diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp index 965c7d409fae5a..29e144cfc28bf5 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.cpp @@ -11,7 +11,7 @@ namespace facebook { namespace react { void ComponentDescriptorProviderRegistry::add( - ComponentDescriptorProvider provider) const { + const ComponentDescriptorProvider &provider) const { std::unique_lock lock(mutex_); /* diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h index 182d24a7a8c7cb..cba67833518026 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h @@ -33,7 +33,7 @@ class ComponentDescriptorProviderRegistry final { * `ComponentDescriptorRegistry`s accordingly. * The methods can be called on any thread. */ - void add(ComponentDescriptorProvider provider) const; + void add(const ComponentDescriptorProvider &provider) const; /* * ComponenDescriptorRegistry will call the `request` in case if a component diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp index 42fe6e0eff1426..0a29a3346647b9 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp @@ -50,7 +50,7 @@ void ComponentDescriptorRegistry::add( } void ComponentDescriptorRegistry::registerComponentDescriptor( - SharedComponentDescriptor componentDescriptor) const { + const SharedComponentDescriptor &componentDescriptor) const { ComponentHandle componentHandle = componentDescriptor->getComponentHandle(); _registryByHandle[componentHandle] = componentDescriptor; @@ -119,11 +119,7 @@ bool ComponentDescriptorRegistry::hasComponentDescriptorAt( std::shared_lock lock(mutex_); auto iterator = _registryByHandle.find(componentHandle); - if (iterator == _registryByHandle.end()) { - return false; - } - - return true; + return iterator != _registryByHandle.end(); } ShadowNode::Shared ComponentDescriptorRegistry::createNode( @@ -136,8 +132,7 @@ ShadowNode::Shared ComponentDescriptorRegistry::createNode( auto const &componentDescriptor = this->at(unifiedComponentName); auto const fragment = ShadowNodeFamilyFragment{tag, surfaceId, nullptr}; - auto family = - componentDescriptor.createFamily(fragment, std::move(eventTarget)); + auto family = componentDescriptor.createFamily(fragment, eventTarget); auto const props = componentDescriptor.cloneProps( PropsParserContext{surfaceId, *contextContainer_.get()}, nullptr, @@ -155,7 +150,7 @@ ShadowNode::Shared ComponentDescriptorRegistry::createNode( } void ComponentDescriptorRegistry::setFallbackComponentDescriptor( - SharedComponentDescriptor descriptor) { + const SharedComponentDescriptor &descriptor) { _fallbackComponentDescriptor = descriptor; registerComponentDescriptor(descriptor); } diff --git a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.h b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.h index 054af63c032b9d..d2eeceaf60f996 100644 --- a/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.h +++ b/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.h @@ -62,14 +62,15 @@ class ComponentDescriptorRegistry { folly::dynamic const &props, SharedEventTarget const &eventTarget) const; - void setFallbackComponentDescriptor(SharedComponentDescriptor descriptor); + void setFallbackComponentDescriptor( + const SharedComponentDescriptor &descriptor); ComponentDescriptor::Shared getFallbackComponentDescriptor() const; private: friend class ComponentDescriptorProviderRegistry; void registerComponentDescriptor( - SharedComponentDescriptor componentDescriptor) const; + const SharedComponentDescriptor &componentDescriptor) const; /* * Creates a `ComponentDescriptor` using specified diff --git a/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.cpp b/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.cpp index b23525bddc7880..4b7e9c69917028 100644 --- a/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.cpp +++ b/ReactCommon/react/renderer/componentregistry/native/NativeComponentRegistryBinding.cpp @@ -20,7 +20,7 @@ namespace react { */ NativeComponentRegistryBinding::NativeComponentRegistryBinding( const HasComponentProviderFunctionType &&hasComponentProvider) - : hasComponentProvider_(std::move(hasComponentProvider)) {} + : hasComponentProvider_(hasComponentProvider) {} void NativeComponentRegistryBinding::install( jsi::Runtime &runtime, @@ -61,7 +61,7 @@ jsi::Value NativeComponentRegistryBinding::jsProxy( bool result = hasComponent(moduleName); - return jsi::Value(result); + return {result}; } } // namespace react diff --git a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.cpp b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.cpp index 3d7c97a4a03bcd..85d7b8da1395b5 100644 --- a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.cpp +++ b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarShadowNode.cpp @@ -25,7 +25,7 @@ void AndroidProgressBarShadowNode::setAndroidProgressBarMeasurementsManager( #pragma mark - LayoutableShadowNode Size AndroidProgressBarShadowNode::measureContent( - LayoutContext const &layoutContext, + LayoutContext const & /*layoutContext*/, LayoutConstraints const &layoutConstraints) const { return measurementsManager_->measure( getSurfaceId(), getConcreteProps(), layoutConstraints); diff --git a/ReactCommon/react/renderer/components/root/RootProps.cpp b/ReactCommon/react/renderer/components/root/RootProps.cpp index 47013f3c14e4f7..df7e709b9ec6f0 100644 --- a/ReactCommon/react/renderer/components/root/RootProps.cpp +++ b/ReactCommon/react/renderer/components/root/RootProps.cpp @@ -26,8 +26,8 @@ RootProps::RootProps( // If that's a problem and the context is necesary here, refactor RootShadowNode // first. RootProps::RootProps( - const PropsParserContext &context, - RootProps const &sourceProps, + const PropsParserContext & /*context*/, + RootProps const & /*sourceProps*/, LayoutConstraints const &layoutConstraints, LayoutContext const &layoutContext) : ViewProps(), diff --git a/ReactCommon/react/renderer/components/slider/SliderShadowNode.cpp b/ReactCommon/react/renderer/components/slider/SliderShadowNode.cpp index 094389801734b7..b4d24e69febd14 100644 --- a/ReactCommon/react/renderer/components/slider/SliderShadowNode.cpp +++ b/ReactCommon/react/renderer/components/slider/SliderShadowNode.cpp @@ -84,7 +84,7 @@ ImageSource SliderShadowNode::getThumbImageSource() const { #pragma mark - LayoutableShadowNode Size SliderShadowNode::measureContent( - LayoutContext const &layoutContext, + LayoutContext const & /*layoutContext*/, LayoutConstraints const &layoutConstraints) const { if (SliderMeasurementsManager::shouldMeasureSlider()) { return measurementsManager_->measure(getSurfaceId(), layoutConstraints); diff --git a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.cpp b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.cpp index 4dca3fbda46dda..af2d201d0f3599 100644 --- a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.cpp +++ b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchShadowNode.cpp @@ -22,7 +22,7 @@ void AndroidSwitchShadowNode::setAndroidSwitchMeasurementsManager( #pragma mark - LayoutableShadowNode Size AndroidSwitchShadowNode::measureContent( - LayoutContext const &layoutContext, + LayoutContext const & /*layoutContext*/, LayoutConstraints const &layoutConstraints) const { return measurementsManager_->measure(getSurfaceId(), layoutConstraints); } diff --git a/ReactCommon/react/renderer/components/text/BaseTextProps.cpp b/ReactCommon/react/renderer/components/text/BaseTextProps.cpp index 88189288fdfb6c..c1606d0ddae811 100644 --- a/ReactCommon/react/renderer/components/text/BaseTextProps.cpp +++ b/ReactCommon/react/renderer/components/text/BaseTextProps.cpp @@ -219,7 +219,7 @@ BaseTextProps::BaseTextProps( void BaseTextProps::setProp( const PropsParserContext &context, RawPropsPropNameHash hash, - const char *propName, + const char * /*propName*/, RawValue const &value) { static auto defaults = TextAttributes{}; diff --git a/ReactCommon/react/renderer/components/text/BaseTextShadowNode.cpp b/ReactCommon/react/renderer/components/text/BaseTextShadowNode.cpp index 054bdeb14fbe09..88cf821aac08a6 100644 --- a/ReactCommon/react/renderer/components/text/BaseTextShadowNode.cpp +++ b/ReactCommon/react/renderer/components/text/BaseTextShadowNode.cpp @@ -34,7 +34,7 @@ void BaseTextShadowNode::buildAttributedString( // RawShadowNode auto rawTextShadowNode = traitCast(childNode.get()); - if (rawTextShadowNode) { + if (rawTextShadowNode != nullptr) { auto fragment = AttributedString::Fragment{}; fragment.string = rawTextShadowNode->getConcreteProps().text; fragment.textAttributes = baseTextAttributes; @@ -50,7 +50,7 @@ void BaseTextShadowNode::buildAttributedString( // TextShadowNode auto textShadowNode = traitCast(childNode.get()); - if (textShadowNode) { + if (textShadowNode != nullptr) { auto localTextAttributes = baseTextAttributes; localTextAttributes.apply( textShadowNode->getConcreteProps().textAttributes); diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp index 5edf5badde2216..2c98a0e164e973 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputShadowNode.cpp @@ -168,7 +168,7 @@ void AndroidTextInputShadowNode::updateStateIfNeeded() { #pragma mark - LayoutableShadowNode Size AndroidTextInputShadowNode::measureContent( - LayoutContext const &layoutContext, + LayoutContext const & /*layoutContext*/, LayoutConstraints const &layoutConstraints) const { if (getStateData().cachedAttributedStringId != 0) { return textLayoutManager_ diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.h index a872f5f7ba6fea..3dc1cefaff52de 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputEventEmitter.h @@ -45,8 +45,8 @@ class TextInputEventEmitter : public ViewEventEmitter { void onSelectionChange(TextInputMetrics const &textInputMetrics) const; void onEndEditing(TextInputMetrics const &textInputMetrics) const; void onSubmitEditing(TextInputMetrics const &textInputMetrics) const; - void onKeyPress(KeyPressMetrics const &textInputMetrics) const; - void onKeyPressSync(KeyPressMetrics const &textInputMetrics) const; + void onKeyPress(KeyPressMetrics const &keyPressMetrics) const; + void onKeyPressSync(KeyPressMetrics const &keyPressMetrics) const; void onScroll(TextInputMetrics const &textInputMetrics) const; private: diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp index f4930a436e9411..bd3e8c4f4bc6ee 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputState.cpp @@ -12,8 +12,8 @@ namespace react { #ifdef ANDROID TextInputState::TextInputState( - TextInputState const &previousState, - folly::dynamic const &data){}; + TextInputState const & /*previousState*/, + folly::dynamic const & /*data*/){}; /* * Empty implementation for Android because it doesn't use this class. diff --git a/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp b/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp index d3a91fdfa353cb..d5a4dcadf87ea4 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp +++ b/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp @@ -194,7 +194,7 @@ AccessibilityProps::AccessibilityProps( void AccessibilityProps::setProp( const PropsParserContext &context, RawPropsPropNameHash hash, - const char *propName, + const char * /*propName*/, RawValue const &value) { switch (hash) { RAW_SET_PROP_SWITCH_CASE_BASIC(accessible, false); @@ -217,7 +217,7 @@ void AccessibilityProps::setProp( RAW_SET_PROP_SWITCH_CASE(testId, "testID", std::string{""}); case CONSTEXPR_RAW_PROPS_KEY_HASH("accessibilityRole"): { AccessibilityTraits traits = AccessibilityTraits::None; - std::string roleString = ""; + std::string roleString; if (value.hasValue()) { fromRawValue(context, value, traits); fromRawValue(context, value, roleString); diff --git a/ReactCommon/react/renderer/components/view/PointerEvent.cpp b/ReactCommon/react/renderer/components/view/PointerEvent.cpp index 842c8a4408beee..0bf0a7302ded85 100644 --- a/ReactCommon/react/renderer/components/view/PointerEvent.cpp +++ b/ReactCommon/react/renderer/components/view/PointerEvent.cpp @@ -12,7 +12,7 @@ namespace react { #if RN_DEBUG_STRING_CONVERTIBLE -std::string getDebugName(PointerEvent const &pointerEvent) { +std::string getDebugName(PointerEvent const & /*pointerEvent*/) { return "PointerEvent"; } diff --git a/ReactCommon/react/renderer/components/view/Touch.cpp b/ReactCommon/react/renderer/components/view/Touch.cpp index 15e5bfaaee55a9..116b7deefec1b9 100644 --- a/ReactCommon/react/renderer/components/view/Touch.cpp +++ b/ReactCommon/react/renderer/components/view/Touch.cpp @@ -12,7 +12,7 @@ namespace react { #if RN_DEBUG_STRING_CONVERTIBLE -std::string getDebugName(Touch const &touch) { +std::string getDebugName(Touch const & /*touch*/) { return "Touch"; } diff --git a/ReactCommon/react/renderer/components/view/Touch.h b/ReactCommon/react/renderer/components/view/Touch.h index 13383a0e5bbcb5..415fdc499437b9 100644 --- a/ReactCommon/react/renderer/components/view/Touch.h +++ b/ReactCommon/react/renderer/components/view/Touch.h @@ -80,7 +80,7 @@ using Touches = std::unordered_set; std::string getDebugName(Touch const &touch); std::vector getDebugProps( - Touch const &object, + Touch const &touch, DebugStringConvertibleOptions options); #endif diff --git a/ReactCommon/react/renderer/components/view/TouchEvent.cpp b/ReactCommon/react/renderer/components/view/TouchEvent.cpp index 7f8b9fda170cb9..3939345653c152 100644 --- a/ReactCommon/react/renderer/components/view/TouchEvent.cpp +++ b/ReactCommon/react/renderer/components/view/TouchEvent.cpp @@ -12,7 +12,7 @@ namespace react { #if RN_DEBUG_STRING_CONVERTIBLE -std::string getDebugName(TouchEvent const &touchEvent) { +std::string getDebugName(TouchEvent const & /*touchEvent*/) { return "TouchEvent"; } diff --git a/ReactCommon/react/renderer/core/EventEmitter.cpp b/ReactCommon/react/renderer/core/EventEmitter.cpp index 894ddf8eddd2e0..cca4a0eca17bd5 100644 --- a/ReactCommon/react/renderer/core/EventEmitter.cpp +++ b/ReactCommon/react/renderer/core/EventEmitter.cpp @@ -44,7 +44,7 @@ ValueFactory EventEmitter::defaultPayloadFactory() { EventEmitter::EventEmitter( SharedEventTarget eventTarget, - Tag tag, + Tag /*tag*/, EventDispatcher::Weak eventDispatcher) : eventTarget_(std::move(eventTarget)), eventDispatcher_(std::move(eventDispatcher)) {} diff --git a/ReactCommon/react/renderer/core/EventTarget.cpp b/ReactCommon/react/renderer/core/EventTarget.cpp index 9a6d115b272885..02ceab2c1338a3 100644 --- a/ReactCommon/react/renderer/core/EventTarget.cpp +++ b/ReactCommon/react/renderer/core/EventTarget.cpp @@ -46,7 +46,7 @@ void EventTarget::retain(jsi::Runtime &runtime) const { // react_native_assert(!strongInstanceHandle_.isUndefined()); } -void EventTarget::release(jsi::Runtime &runtime) const { +void EventTarget::release(jsi::Runtime & /*runtime*/) const { // The method does not use `jsi::Runtime` reference. // It takes it only to ensure thread-safety (if the caller has the reference, // we are on a proper thread). diff --git a/ReactCommon/react/renderer/core/LayoutMetrics.cpp b/ReactCommon/react/renderer/core/LayoutMetrics.cpp index 8e92f2f07a137c..6c428988658a0c 100644 --- a/ReactCommon/react/renderer/core/LayoutMetrics.cpp +++ b/ReactCommon/react/renderer/core/LayoutMetrics.cpp @@ -15,7 +15,7 @@ namespace react { #if RN_DEBUG_STRING_CONVERTIBLE -std::string getDebugName(LayoutMetrics const &object) { +std::string getDebugName(LayoutMetrics const & /*object*/) { return "LayoutMetrics"; } diff --git a/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp b/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp index 7f3c1f0382aba5..0347783f0ea333 100644 --- a/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp +++ b/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp @@ -256,7 +256,7 @@ LayoutableShadowNode::getLayoutableChildNodes() const { Size LayoutableShadowNode::measureContent( LayoutContext const &layoutContext, LayoutConstraints const &layoutConstraints) const { - return Size(); + return {}; } Size LayoutableShadowNode::measure( diff --git a/ReactCommon/react/renderer/core/Props.cpp b/ReactCommon/react/renderer/core/Props.cpp index ad1c01c5c2855f..0e2af101fd89e8 100644 --- a/ReactCommon/react/renderer/core/Props.cpp +++ b/ReactCommon/react/renderer/core/Props.cpp @@ -41,7 +41,7 @@ Props::Props( void Props::setProp( const PropsParserContext &context, RawPropsPropNameHash hash, - const char *propName, + const char * /*propName*/, RawValue const &value) { switch (hash) { case CONSTEXPR_RAW_PROPS_KEY_HASH("nativeID"): diff --git a/ReactCommon/react/renderer/core/RawProps.cpp b/ReactCommon/react/renderer/core/RawProps.cpp index 454e2bed304262..bd476f6ca03059 100644 --- a/ReactCommon/react/renderer/core/RawProps.cpp +++ b/ReactCommon/react/renderer/core/RawProps.cpp @@ -48,8 +48,9 @@ RawProps::RawProps(folly::dynamic const &dynamic) noexcept { dynamic_ = dynamic; } -void RawProps::parse(RawPropsParser const &parser, const PropsParserContext &) - const noexcept { +void RawProps::parse( + RawPropsParser const &parser, + const PropsParserContext & /*unused*/) const noexcept { react_native_assert(parser_ == nullptr && "A parser was already assigned."); parser_ = &parser; parser.preparse(*this); diff --git a/ReactCommon/react/renderer/core/RawProps.h b/ReactCommon/react/renderer/core/RawProps.h index 4e86e289cc1c5d..08cdcdd5d03429 100644 --- a/ReactCommon/react/renderer/core/RawProps.h +++ b/ReactCommon/react/renderer/core/RawProps.h @@ -118,7 +118,7 @@ class RawProps final { mutable Mode mode_; // Case 1: Source data is represented as `jsi::Object`. - jsi::Runtime *runtime_; + jsi::Runtime *runtime_{}; jsi::Value value_; // Case 2: Source data is represented as `folly::dynamic`. diff --git a/ReactCommon/react/renderer/core/RawPropsKey.cpp b/ReactCommon/react/renderer/core/RawPropsKey.cpp index de7820dc7baa0c..daaefbc5ae1c4b 100644 --- a/ReactCommon/react/renderer/core/RawPropsKey.cpp +++ b/ReactCommon/react/renderer/core/RawPropsKey.cpp @@ -22,7 +22,7 @@ void RawPropsKey::render(char *buffer, RawPropsPropNameLength *length) *length = 0; // Prefix - if (prefix) { + if (prefix != nullptr) { auto prefixLength = static_cast(std::strlen(prefix)); std::memcpy(buffer, prefix, prefixLength); @@ -35,7 +35,7 @@ void RawPropsKey::render(char *buffer, RawPropsPropNameLength *length) *length += nameLength; // Suffix - if (suffix) { + if (suffix != nullptr) { auto suffixLength = static_cast(std::strlen(suffix)); std::memcpy(buffer + *length, suffix, suffixLength); diff --git a/ReactCommon/react/renderer/core/Sealable.cpp b/ReactCommon/react/renderer/core/Sealable.cpp index abb839c8ea65ea..881ac7842d4e17 100644 --- a/ReactCommon/react/renderer/core/Sealable.cpp +++ b/ReactCommon/react/renderer/core/Sealable.cpp @@ -29,7 +29,7 @@ namespace react { Sealable::Sealable() : sealed_(false) {} -Sealable::Sealable(const Sealable &other) : sealed_(false){}; +Sealable::Sealable(const Sealable & /*other*/) : sealed_(false){}; Sealable::Sealable(Sealable &&other) noexcept : sealed_(false) { other.ensureUnsealed(); @@ -37,7 +37,7 @@ Sealable::Sealable(Sealable &&other) noexcept : sealed_(false) { Sealable::~Sealable() noexcept = default; -Sealable &Sealable::operator=(const Sealable &other) { +Sealable &Sealable::operator=(const Sealable & /*other*/) { ensureUnsealed(); return *this; } diff --git a/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp b/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp index 73d022bf2efb94..b5e28cb988b1b5 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp +++ b/ReactCommon/react/renderer/core/ShadowNodeFamily.cpp @@ -63,7 +63,7 @@ AncestorList ShadowNodeFamily::getAncestors( auto ancestorFamily = ancestorShadowNode.family_.get(); auto family = this; - while (family && family != ancestorFamily) { + while ((family != nullptr) && family != ancestorFamily) { families.push_back(family); family = family->parent_.lock().get(); } diff --git a/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp b/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp index feb6c16973a921..28d85cef6d696d 100644 --- a/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp +++ b/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp @@ -22,11 +22,11 @@ class EventQueueProcessorTest : public testing::Test { runtime_ = facebook::hermes::makeHermesRuntime(); auto eventPipe = [this]( - jsi::Runtime &runtime, - const EventTarget *eventTarget, + jsi::Runtime & /*runtime*/, + const EventTarget * /*eventTarget*/, const std::string &type, ReactEventPriority priority, - const ValueFactory &payloadFactory) { + const ValueFactory & /*payloadFactory*/) { eventTypes_.push_back(type); eventPriorities_.push_back(priority); }; diff --git a/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp b/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp index fe90800696579b..a620d3c96dc136 100644 --- a/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp +++ b/ReactCommon/react/renderer/core/tests/RawPropsTest.cpp @@ -188,7 +188,7 @@ TEST(RawPropsTest, handleRawPropsSingleFloat) { parser.prepare(); raw.parse(parser, parserContext); - float value = (float)*raw.at("floatValue", nullptr, nullptr); + auto value = (float)*raw.at("floatValue", nullptr, nullptr); EXPECT_NEAR(value, 42.42, 0.00001); } @@ -203,7 +203,7 @@ TEST(RawPropsTest, handleRawPropsSingleDouble) { parser.prepare(); raw.parse(parser, parserContext); - double value = (double)*raw.at("doubleValue", nullptr, nullptr); + auto value = (double)*raw.at("doubleValue", nullptr, nullptr); EXPECT_NEAR(value, 42.42, 0.00001); } diff --git a/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp b/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp index fde19f4163a29e..8e6f62b4c1a1e0 100644 --- a/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp +++ b/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp @@ -24,7 +24,7 @@ std::string DebugStringConvertible::getDebugChildrenDescription( options.depth++; auto trailing = options.format ? std::string{"\n"} : std::string{""}; - auto childrenString = std::string{""}; + std::string childrenString; for (auto const &child : getDebugChildren()) { if (!child) { @@ -50,7 +50,7 @@ std::string DebugStringConvertible::getDebugPropsDescription( options.depth++; - auto propsString = std::string{""}; + std::string propsString; for (auto const &prop : getDebugProps()) { if (!prop) { @@ -116,11 +116,11 @@ std::string DebugStringConvertible::getDebugValue() const { SharedDebugStringConvertibleList DebugStringConvertible::getDebugChildren() const { - return SharedDebugStringConvertibleList(); + return {}; } SharedDebugStringConvertibleList DebugStringConvertible::getDebugProps() const { - return SharedDebugStringConvertibleList(); + return {}; } /* diff --git a/ReactCommon/react/renderer/graphics/Transform.cpp b/ReactCommon/react/renderer/graphics/Transform.cpp index a8a7f1033b80e0..5639203f0df6c3 100644 --- a/ReactCommon/react/renderer/graphics/Transform.cpp +++ b/ReactCommon/react/renderer/graphics/Transform.cpp @@ -279,28 +279,40 @@ Transform Transform::operator*(Transform const &rhs) const { auto result = Transform{}; for (const auto &op : this->operations) { if (op.type == TransformOperationType::Identity && - result.operations.size() > 0) { + !result.operations.empty()) { continue; } result.operations.push_back(op); } for (const auto &op : rhs.operations) { if (op.type == TransformOperationType::Identity && - result.operations.size() > 0) { + !result.operations.empty()) { continue; } result.operations.push_back(op); } - auto lhs00 = lhs.matrix[0], lhs01 = lhs.matrix[1], lhs02 = lhs.matrix[2], - lhs03 = lhs.matrix[3], lhs10 = lhs.matrix[4], lhs11 = lhs.matrix[5], - lhs12 = lhs.matrix[6], lhs13 = lhs.matrix[7], lhs20 = lhs.matrix[8], - lhs21 = lhs.matrix[9], lhs22 = lhs.matrix[10], lhs23 = lhs.matrix[11], - lhs30 = lhs.matrix[12], lhs31 = lhs.matrix[13], lhs32 = lhs.matrix[14], - lhs33 = lhs.matrix[15]; - - auto rhs0 = rhs.matrix[0], rhs1 = rhs.matrix[1], rhs2 = rhs.matrix[2], - rhs3 = rhs.matrix[3]; + auto lhs00 = lhs.matrix[0]; + auto lhs01 = lhs.matrix[1]; + auto lhs02 = lhs.matrix[2]; + auto lhs03 = lhs.matrix[3]; + auto lhs10 = lhs.matrix[4]; + auto lhs11 = lhs.matrix[5]; + auto lhs12 = lhs.matrix[6]; + auto lhs13 = lhs.matrix[7]; + auto lhs20 = lhs.matrix[8]; + auto lhs21 = lhs.matrix[9]; + auto lhs22 = lhs.matrix[10]; + auto lhs23 = lhs.matrix[11]; + auto lhs30 = lhs.matrix[12]; + auto lhs31 = lhs.matrix[13]; + auto lhs32 = lhs.matrix[14]; + auto lhs33 = lhs.matrix[15]; + + auto rhs0 = rhs.matrix[0]; + auto rhs1 = rhs.matrix[1]; + auto rhs2 = rhs.matrix[2]; + auto rhs3 = rhs.matrix[3]; result.matrix[0] = rhs0 * lhs00 + rhs1 * lhs10 + rhs2 * lhs20 + rhs3 * lhs30; result.matrix[1] = rhs0 * lhs01 + rhs1 * lhs11 + rhs2 * lhs21 + rhs3 * lhs31; result.matrix[2] = rhs0 * lhs02 + rhs1 * lhs12 + rhs2 * lhs22 + rhs3 * lhs32; diff --git a/ReactCommon/react/renderer/graphics/Transform.h b/ReactCommon/react/renderer/graphics/Transform.h index e24f4af028b2aa..50a70161207d18 100644 --- a/ReactCommon/react/renderer/graphics/Transform.h +++ b/ReactCommon/react/renderer/graphics/Transform.h @@ -112,9 +112,9 @@ struct Transform { /* * Returns a transform that rotates by `angle` radians along the given axis. */ - static Transform RotateX(Float angle); - static Transform RotateY(Float angle); - static Transform RotateZ(Float angle); + static Transform RotateX(Float radians); + static Transform RotateY(Float radians); + static Transform RotateZ(Float radians); static Transform Rotate(Float angleX, Float angleY, Float angleZ); /** @@ -145,8 +145,8 @@ struct Transform { /* * Matrix subscript. */ - Float &at(int x, int y); - Float const &at(int x, int y) const; + Float &at(int i, int j); + Float const &at(int i, int j) const; /* * Concatenates (multiplies) transform matrices. diff --git a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp index 02c6bf82d4abbc..7fb59308a08b3e 100644 --- a/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp +++ b/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.cpp @@ -20,11 +20,11 @@ bool isColorMeaningful(SharedColor const &color) noexcept { SharedColor colorFromComponents(ColorComponents components) { float ratio = 255; - return SharedColor( + return { ((int)round(components.alpha * ratio) & 0xff) << 24 | ((int)round(components.red * ratio) & 0xff) << 16 | ((int)round(components.green * ratio) & 0xff) << 8 | - ((int)round(components.blue * ratio) & 0xff)); + ((int)round(components.blue * ratio) & 0xff)}; } ColorComponents colorComponentsFromColor(SharedColor const &sharedColor) { diff --git a/ReactCommon/react/renderer/imagemanager/ImageManager.h b/ReactCommon/react/renderer/imagemanager/ImageManager.h index f76912bf778de7..42117ac7f77cc5 100644 --- a/ReactCommon/react/renderer/imagemanager/ImageManager.h +++ b/ReactCommon/react/renderer/imagemanager/ImageManager.h @@ -33,7 +33,7 @@ class ImageManager { const; private: - void *self_; + void *self_{}; }; } // namespace react diff --git a/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageManager.cpp b/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageManager.cpp index b7f1274e351c34..6baf9a795af674 100644 --- a/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageManager.cpp +++ b/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageManager.cpp @@ -10,7 +10,8 @@ namespace facebook { namespace react { -ImageManager::ImageManager(ContextContainer::Shared const &contextContainer) { +ImageManager::ImageManager( + ContextContainer::Shared const & /*contextContainer*/) { // Silence unused-private-field warning. (void)self_; // Not implemented. @@ -22,9 +23,9 @@ ImageManager::~ImageManager() { ImageRequest ImageManager::requestImage( const ImageSource &imageSource, - SurfaceId surfaceId) const { + SurfaceId /*surfaceId*/) const { // Not implemented. - return ImageRequest(imageSource, nullptr); + return {imageSource, nullptr}; } } // namespace react diff --git a/ReactCommon/react/renderer/leakchecker/LeakChecker.h b/ReactCommon/react/renderer/leakchecker/LeakChecker.h index c88b34a5e1a2d6..c568b190fdd9df 100644 --- a/ReactCommon/react/renderer/leakchecker/LeakChecker.h +++ b/ReactCommon/react/renderer/leakchecker/LeakChecker.h @@ -32,7 +32,7 @@ class LeakChecker final { RuntimeExecutor const runtimeExecutor_{}; WeakFamilyRegistry registry_{}; - SurfaceId previouslyStoppedSurface_; + SurfaceId previouslyStoppedSurface_{}; }; } // namespace react diff --git a/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.cpp b/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.cpp index a2279a5ed626bf..aaf99e18ccb42e 100644 --- a/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.cpp +++ b/ReactCommon/react/renderer/leakchecker/WeakFamilyRegistry.cpp @@ -28,9 +28,8 @@ WeakFamilyRegistry::WeakFamilies WeakFamilyRegistry::weakFamiliesForSurfaceId( std::lock_guard lock(familiesMutex_); if (families_.find(surfaceId) != families_.end()) { return families_[surfaceId]; - } else { - return {}; } + return {}; } } // namespace react diff --git a/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp b/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp index eaffddf401ba2f..f5d5198f70f513 100644 --- a/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp +++ b/ReactCommon/react/renderer/mapbuffer/MapBuffer.cpp @@ -90,7 +90,7 @@ std::string MapBuffer::getString(Key key) const { uint8_t const *stringPtr = bytes_.data() + dynamicDataOffset + offset + sizeof(int); - return std::string(stringPtr, stringPtr + stringLength); + return {stringPtr, stringPtr + stringLength}; } MapBuffer MapBuffer::getMapBuffer(Key key) const { diff --git a/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp b/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp index f6aec1ccf4af62..8f3baaaf59fdcf 100644 --- a/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp +++ b/ReactCommon/react/renderer/mapbuffer/tests/MapBufferTest.cpp @@ -164,7 +164,7 @@ TEST(MapBufferTest, testMapListEntries) { mapBufferList.push_back(builder2.build()); auto builder3 = MapBufferBuilder(); - builder3.putMapBufferList(5, std::move(mapBufferList)); + builder3.putMapBufferList(5, mapBufferList); auto map = builder3.build(); std::vector mapBufferList2 = map.getMapBufferList(5); diff --git a/ReactCommon/react/renderer/mounting/Differentiator.cpp b/ReactCommon/react/renderer/mounting/Differentiator.cpp index 372aa7cb6f0ca3..ffaadd4266ecf9 100644 --- a/ReactCommon/react/renderer/mounting/Differentiator.cpp +++ b/ReactCommon/react/renderer/mounting/Differentiator.cpp @@ -336,7 +336,6 @@ static_assert( "`ShadowViewNodePair::NonOwningList` must be `move assignable`."); static void calculateShadowViewMutationsV2( - BREADCRUMB_TYPE breadcrumb, ViewNodePairScope &scope, ShadowViewMutation::List &mutations, ShadowView const &parentShadowView, @@ -355,18 +354,15 @@ struct OrderedMutationInstructionContainer { }; static void updateMatchedPairSubtrees( - BREADCRUMB_TYPE breadcrumb, ViewNodePairScope &scope, OrderedMutationInstructionContainer &mutationContainer, TinyMap &newRemainingPairs, ShadowViewNodePair::NonOwningList &oldChildPairs, - ShadowViewNodePair::NonOwningList &newChildPairs, ShadowView const &parentShadowView, ShadowViewNodePair const &oldPair, ShadowViewNodePair const &newPair); static void updateMatchedPair( - BREADCRUMB_TYPE breadcrumb, OrderedMutationInstructionContainer &mutationContainer, bool oldNodeFoundInOrder, bool newNodeFoundInOrder, @@ -375,12 +371,11 @@ static void updateMatchedPair( ShadowViewNodePair const &newPair); static void calculateShadowViewMutationsFlattener( - BREADCRUMB_TYPE breadcrumb, ViewNodePairScope &scope, ReparentMode reparentMode, OrderedMutationInstructionContainer &mutationContainer, ShadowView const &parentShadowView, - TinyMap &unvisitedFlattenedNodes, + TinyMap &unvisitedOtherNodes, ShadowViewNodePair const &node, TinyMap *parentSubVisitedOtherNewNodes = nullptr, TinyMap *parentSubVisitedOtherOldNodes = @@ -395,12 +390,10 @@ static void calculateShadowViewMutationsFlattener( * the ViewNodePairScope used within. */ static void updateMatchedPairSubtrees( - BREADCRUMB_TYPE breadcrumb, ViewNodePairScope &scope, OrderedMutationInstructionContainer &mutationContainer, TinyMap &newRemainingPairs, ShadowViewNodePair::NonOwningList &oldChildPairs, - ShadowViewNodePair::NonOwningList &newChildPairs, ShadowView const &parentShadowView, ShadowViewNodePair const &oldPair, ShadowViewNodePair const &newPair) { @@ -427,9 +420,6 @@ static void updateMatchedPairSubtrees( // children are visited, so we reuse the `newRemainingPairs` // map. calculateShadowViewMutationsFlattener( - DIFF_BREADCRUMB( - "Flatten tree " + std::to_string(parentShadowView.tag) + - " into list " + std::to_string(oldPair.shadowView.tag)), scope, ReparentMode::Flatten, mutationContainer, @@ -460,9 +450,6 @@ static void updateMatchedPairSubtrees( // Unflatten old list into new tree calculateShadowViewMutationsFlattener( - DIFF_BREADCRUMB( - "Unflatten old list " + std::to_string(parentShadowView.tag) + - " into new tree " + std::to_string(newPair.shadowView.tag)), scope, ReparentMode::Unflatten, mutationContainer, @@ -502,8 +489,6 @@ static void updateMatchedPairSubtrees( auto newGrandChildPairs = sliceChildShadowNodeViewPairsFromViewNodePair(newPair, innerScope); calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Non-trivial update " + std::to_string(oldPair.shadowView.tag)), innerScope, *(newGrandChildPairs.size() ? &mutationContainer.downwardMutations @@ -523,7 +508,6 @@ static void updateMatchedPairSubtrees( * correct ordering of INSERT and REMOVE mutations. */ static void updateMatchedPair( - BREADCRUMB_TYPE breadcrumb, OrderedMutationInstructionContainer &mutationContainer, bool oldNodeFoundInOrder, bool newNodeFoundInOrder, @@ -618,7 +602,6 @@ static void updateMatchedPair( * **after this function is called**, by the caller. */ static void calculateShadowViewMutationsFlattener( - BREADCRUMB_TYPE breadcrumb, ViewNodePairScope &scope, ReparentMode reparentMode, OrderedMutationInstructionContainer &mutationContainer, @@ -845,9 +828,6 @@ static void calculateShadowViewMutationsFlattener( if (oldTreeNodePair.shadowNode != newTreeNodePair.shadowNode) { ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "(Un)Flattener trivial update of " + - std::to_string(newTreeNodePair.shadowView.tag)), innerScope, mutationContainer.downwardMutations, newTreeNodePair.shadowView, @@ -867,17 +847,6 @@ static void calculateShadowViewMutationsFlattener( // This is a flatten-flatten, or unflatten-unflatten. if (childReparentMode == reparentMode) { calculateShadowViewMutationsFlattener( - DIFF_BREADCRUMB( - std::string( - reparentMode == ReparentMode::Flatten - ? "Flatten-Flatten" - : "Unflatten-Unflatten") + - " new:" + - std::to_string( - reparentMode == ReparentMode::Flatten - ? parentShadowView.tag - : newTreeNodePair.shadowView.tag) + - " old:" + std::to_string(treeChildPair.shadowView.tag)), scope, childReparentMode, mutationContainer, @@ -919,13 +888,6 @@ static void calculateShadowViewMutationsFlattener( // At the end of this loop we still want to know which of these // children are visited, so we reuse the `newRemainingPairs` map. calculateShadowViewMutationsFlattener( - DIFF_BREADCRUMB( - std::string("Flatten old tree into new list; new:") + - std::to_string( - reparentMode == ReparentMode::Flatten - ? parentShadowView.tag - : newTreeNodePair.shadowView.tag) + - " old:" + std::to_string(oldTreeNodePair.shadowView.tag)), scope, ReparentMode::Flatten, mutationContainer, @@ -941,13 +903,6 @@ static void calculateShadowViewMutationsFlattener( else { // Unflatten old list into new tree calculateShadowViewMutationsFlattener( - DIFF_BREADCRUMB( - "Unflatten old list into new tree; old:" + - std::to_string( - reparentMode == ReparentMode::Flatten - ? parentShadowView.tag - : newTreeNodePair.shadowView.tag) + - " new:" + std::to_string(newTreeNodePair.shadowView.tag)), scope, ReparentMode::Unflatten, mutationContainer, @@ -1049,9 +1004,6 @@ static void calculateShadowViewMutationsFlattener( if (!treeChildPair.flattened) { ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Recursively delete tree child pair (flatten case): " + - std::to_string(treeChildPair.shadowView.tag)), innerScope, mutationContainer.destructiveDownwardMutations, treeChildPair.shadowView, @@ -1066,9 +1018,6 @@ static void calculateShadowViewMutationsFlattener( if (!treeChildPair.flattened) { ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Recursively delete tree child pair (unflatten case): " + - std::to_string(treeChildPair.shadowView.tag)), innerScope, mutationContainer.downwardMutations, treeChildPair.shadowView, @@ -1081,7 +1030,6 @@ static void calculateShadowViewMutationsFlattener( } static void calculateShadowViewMutationsV2( - BREADCRUMB_TYPE breadcrumb, ViewNodePairScope &scope, ShadowViewMutation::List &mutations, ShadowView const &parentShadowView, @@ -1177,9 +1125,6 @@ static void calculateShadowViewMutationsV2( auto newGrandChildPairs = sliceChildShadowNodeViewPairsFromViewNodePair( newChildPair, innerScope); calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Stage 1: Recurse on " + - std::to_string(oldChildPair.shadowView.tag)), innerScope, *(newGrandChildPairs.size() ? &mutationContainer.downwardMutations @@ -1246,8 +1191,6 @@ static void calculateShadowViewMutationsV2( // subtree starting from the removed view. ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Trivial delete " + std::to_string(oldChildPair.shadowView.tag)), innerScope, mutationContainer.destructiveDownwardMutations, oldChildPair.shadowView, @@ -1282,8 +1225,6 @@ static void calculateShadowViewMutationsV2( ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Trivial create " + std::to_string(newChildPair.shadowView.tag)), innerScope, mutationContainer.downwardMutations, newChildPair.shadowView, @@ -1304,9 +1245,10 @@ static void calculateShadowViewMutationsV2( // Walk through both lists at the same time // We will perform updates, create+insert, remove+delete, remove+insert // (move) here. - size_t oldIndex = lastIndexAfterFirstStage, - newIndex = lastIndexAfterFirstStage, newSize = newChildPairs.size(), - oldSize = oldChildPairs.size(); + size_t oldIndex = lastIndexAfterFirstStage; + size_t newIndex = lastIndexAfterFirstStage; + size_t newSize = newChildPairs.size(); + size_t oldSize = oldChildPairs.size(); while (newIndex < newSize || oldIndex < oldSize) { bool haveNewPair = newIndex < newSize; bool haveOldPair = oldIndex < oldSize; @@ -1333,9 +1275,6 @@ static void calculateShadowViewMutationsV2( }); updateMatchedPair( - DIFF_BREADCRUMB( - "Update Matched Pairs (1): " + - std::to_string(oldChildPair.shadowView.tag)), mutationContainer, true, true, @@ -1344,14 +1283,10 @@ static void calculateShadowViewMutationsV2( newChildPair); updateMatchedPairSubtrees( - DIFF_BREADCRUMB( - "Update Matched Pair Subtrees (1): " + - std::to_string(oldChildPair.shadowView.tag)), scope, mutationContainer, newRemainingPairs, oldChildPairs, - newChildPairs, parentShadowView, oldChildPair, newChildPair); @@ -1378,9 +1313,6 @@ static void calculateShadowViewMutationsV2( auto const &newChildPair = *insertedIt->second; updateMatchedPair( - DIFF_BREADCRUMB( - "Update Matched Pairs (2): " + - std::to_string(oldChildPair.shadowView.tag)), mutationContainer, true, false, @@ -1389,14 +1321,10 @@ static void calculateShadowViewMutationsV2( newChildPair); updateMatchedPairSubtrees( - DIFF_BREADCRUMB( - "Update Matched Pair Subtrees (2): " + - std::to_string(oldChildPair.shadowView.tag)), scope, mutationContainer, newRemainingPairs, oldChildPairs, - newChildPairs, parentShadowView, oldChildPair, newChildPair); @@ -1534,9 +1462,6 @@ static void calculateShadowViewMutationsV2( // entire subtree starting from the removed view. ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Non-trivial delete " + - std::to_string(oldChildPair.shadowView.tag)), innerScope, mutationContainer.destructiveDownwardMutations, oldChildPair.shadowView, @@ -1581,9 +1506,6 @@ static void calculateShadowViewMutationsV2( ViewNodePairScope innerScope{}; calculateShadowViewMutationsV2( - DIFF_BREADCRUMB( - "Non-trivial create " + - std::to_string(newChildPair.shadowView.tag)), innerScope, mutationContainer.downwardMutations, newChildPair.shadowView, @@ -1707,7 +1629,6 @@ ShadowViewMutation::List calculateShadowViewMutations( } calculateShadowViewMutationsV2( - CREATE_DIFF_BREADCRUMB(oldRootShadowView.tag), innerViewNodePairScope, mutations, ShadowView(oldRootShadowNode), diff --git a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp index 8dc8f97ca6061a..02e9b58fffeb04 100644 --- a/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp +++ b/ReactCommon/react/renderer/mounting/MountingCoordinator.cpp @@ -20,7 +20,7 @@ namespace facebook { namespace react { -MountingCoordinator::MountingCoordinator(ShadowTreeRevision baseRevision) +MountingCoordinator::MountingCoordinator(const ShadowTreeRevision &baseRevision) : surfaceId_(baseRevision.rootShadowNode->getSurfaceId()), baseRevision_(baseRevision), telemetryController_(*this) { @@ -68,7 +68,7 @@ bool MountingCoordinator::waitForTransaction( void MountingCoordinator::updateBaseRevision( ShadowTreeRevision const &baseRevision) const { - baseRevision_ = std::move(baseRevision); + baseRevision_ = baseRevision; } void MountingCoordinator::resetLatestRevision() const { diff --git a/ReactCommon/react/renderer/mounting/MountingCoordinator.h b/ReactCommon/react/renderer/mounting/MountingCoordinator.h index ba66f6a11dc2b1..d2685185660a21 100644 --- a/ReactCommon/react/renderer/mounting/MountingCoordinator.h +++ b/ReactCommon/react/renderer/mounting/MountingCoordinator.h @@ -40,7 +40,7 @@ class MountingCoordinator final { * The constructor is meant to be used only inside `ShadowTree`, and it's * `public` only to enable using with `std::make_shared<>`. */ - MountingCoordinator(ShadowTreeRevision baseRevision); + MountingCoordinator(const ShadowTreeRevision &baseRevision); /* * Returns the id of the surface that the coordinator belongs to. diff --git a/ReactCommon/react/renderer/mounting/ShadowTree.cpp b/ReactCommon/react/renderer/mounting/ShadowTree.cpp index e68b88f8529bf7..ed69d42aa9f9b6 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTree.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowTree.cpp @@ -296,8 +296,8 @@ MountingCoordinator::Shared ShadowTree::getMountingCoordinator() const { } CommitStatus ShadowTree::commit( - ShadowTreeCommitTransaction transaction, - CommitOptions commitOptions) const { + const ShadowTreeCommitTransaction &transaction, + const CommitOptions &commitOptions) const { SystraceSection s("ShadowTree::commit"); int attempts = 0; @@ -317,8 +317,8 @@ CommitStatus ShadowTree::commit( } CommitStatus ShadowTree::tryCommit( - ShadowTreeCommitTransaction transaction, - CommitOptions commitOptions) const { + const ShadowTreeCommitTransaction &transaction, + const CommitOptions &commitOptions) const { SystraceSection s("ShadowTree::tryCommit"); auto telemetry = TransactionTelemetry{}; diff --git a/ReactCommon/react/renderer/mounting/ShadowTree.h b/ReactCommon/react/renderer/mounting/ShadowTree.h index 248ce4daa10f19..5951c20d1a8781 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTree.h +++ b/ReactCommon/react/renderer/mounting/ShadowTree.h @@ -95,15 +95,15 @@ class ShadowTree final { * The `transaction` function can cancel commit returning `nullptr`. */ CommitStatus tryCommit( - ShadowTreeCommitTransaction transaction, - CommitOptions commitOptions = {false}) const; + const ShadowTreeCommitTransaction &transaction, + const CommitOptions &commitOptions = {false}) const; /* * Calls `tryCommit` in a loop until it finishes successfully. */ CommitStatus commit( - ShadowTreeCommitTransaction transaction, - CommitOptions commitOptions = {false}) const; + const ShadowTreeCommitTransaction &transaction, + const CommitOptions &commitOptions = {false}) const; /* * Returns a `ShadowTreeRevision` representing the momentary state of diff --git a/ReactCommon/react/renderer/mounting/ShadowView.cpp b/ReactCommon/react/renderer/mounting/ShadowView.cpp index a521baf785c81d..7e509a7edaf57a 100644 --- a/ReactCommon/react/renderer/mounting/ShadowView.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowView.cpp @@ -16,8 +16,9 @@ namespace react { static LayoutMetrics layoutMetricsFromShadowNode(ShadowNode const &shadowNode) { auto layoutableShadowNode = traitCast(&shadowNode); - return layoutableShadowNode ? layoutableShadowNode->getLayoutMetrics() - : EmptyLayoutMetrics; + return layoutableShadowNode != nullptr + ? layoutableShadowNode->getLayoutMetrics() + : EmptyLayoutMetrics; } ShadowView::ShadowView(const ShadowNode &shadowNode) diff --git a/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp b/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp index 53006ff347b015..2960499258e085 100644 --- a/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowViewMutation.cpp @@ -148,19 +148,19 @@ std::vector getDebugProps( ShadowViewMutation const &mutation, DebugStringConvertibleOptions options) { return { - mutation.oldChildShadowView.componentHandle + mutation.oldChildShadowView.componentHandle != 0 ? DebugStringConvertibleObject{"oldChild", getDebugDescription( mutation.oldChildShadowView, options)} : DebugStringConvertibleObject{}, - mutation.newChildShadowView.componentHandle + mutation.newChildShadowView.componentHandle != 0 ? DebugStringConvertibleObject{"newChild", getDebugDescription( mutation.newChildShadowView, options)} : DebugStringConvertibleObject{}, - mutation.parentShadowView.componentHandle + mutation.parentShadowView.componentHandle != 0 ? DebugStringConvertibleObject{"parent", getDebugDescription( mutation.parentShadowView, diff --git a/ReactCommon/react/renderer/mounting/ShadowViewMutation.h b/ReactCommon/react/renderer/mounting/ShadowViewMutation.h index 4b571bcc7753ea..cc76e261d6413e 100644 --- a/ReactCommon/react/renderer/mounting/ShadowViewMutation.h +++ b/ReactCommon/react/renderer/mounting/ShadowViewMutation.h @@ -125,9 +125,9 @@ using ShadowViewMutationList = std::vector; #if RN_DEBUG_STRING_CONVERTIBLE -std::string getDebugName(ShadowViewMutation const &object); +std::string getDebugName(ShadowViewMutation const &mutation); std::vector getDebugProps( - ShadowViewMutation const &object, + ShadowViewMutation const &mutation, DebugStringConvertibleOptions options); #endif diff --git a/ReactCommon/react/renderer/mounting/StubView.cpp b/ReactCommon/react/renderer/mounting/StubView.cpp index 0d490dc657258d..5d26b18d9b1b47 100644 --- a/ReactCommon/react/renderer/mounting/StubView.cpp +++ b/ReactCommon/react/renderer/mounting/StubView.cpp @@ -67,7 +67,7 @@ bool operator!=(StubView const &lhs, StubView const &rhs) { std::string getDebugName(StubView const &stubView) { return std::string{"Stub"} + std::string{ - stubView.componentHandle ? stubView.componentName : "[invalid]"}; + stubView.componentHandle != 0 ? stubView.componentName : "[invalid]"}; } std::vector getDebugProps( @@ -85,7 +85,7 @@ std::vector getDebugProps( std::vector getDebugChildren( StubView const &stubView, - DebugStringConvertibleOptions options) { + DebugStringConvertibleOptions /*options*/) { std::vector result; for (auto const &child : stubView.children) { result.push_back(*child); diff --git a/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp b/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp index ffa54f0dd97d67..670692558686f5 100644 --- a/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/StateReconciliationTest.cpp @@ -25,8 +25,8 @@ using namespace facebook::react; class DummyShadowTreeDelegate : public ShadowTreeDelegate { public: RootShadowNode::Unshared shadowTreeWillCommit( - ShadowTree const &shadowTree, - RootShadowNode::Shared const &oldRootShadowNode, + ShadowTree const & /*shadowTree*/, + RootShadowNode::Shared const & /*oldRootShadowNode*/, RootShadowNode::Unshared const &newRootShadowNode) const override { return newRootShadowNode; }; @@ -108,7 +108,7 @@ TEST(StateReconciliationTest, testStateReconciliation) { contextContainer}; shadowTree.commit( - [&](RootShadowNode const &oldRootShadowNode) { + [&](RootShadowNode const & /*oldRootShadowNode*/) { return std::static_pointer_cast(rootShadowNodeState1); }, {true}); @@ -133,7 +133,7 @@ TEST(StateReconciliationTest, testStateReconciliation) { findDescendantNode(*rootShadowNodeState2, family)->getState(), state2); shadowTree.commit( - [&](RootShadowNode const &oldRootShadowNode) { + [&](RootShadowNode const & /*oldRootShadowNode*/) { return std::static_pointer_cast(rootShadowNodeState2); }, {true}); @@ -156,7 +156,7 @@ TEST(StateReconciliationTest, testStateReconciliation) { findDescendantNode(*rootShadowNodeState3, family)->getState(), state3); shadowTree.commit( - [&](RootShadowNode const &oldRootShadowNode) { + [&](RootShadowNode const & /*oldRootShadowNode*/) { return std::static_pointer_cast(rootShadowNodeState3); }, {true}); @@ -171,7 +171,7 @@ TEST(StateReconciliationTest, testStateReconciliation) { // Here we commit the old tree but we expect that the state associated with // the node will stay the same (newer that the old tree has). shadowTree.commit( - [&](RootShadowNode const &oldRootShadowNode) { + [&](RootShadowNode const & /*oldRootShadowNode*/) { return std::static_pointer_cast(rootShadowNodeState2); }, {true}); diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp index c04d842f8e6129..f1f09261a6f998 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp @@ -116,7 +116,7 @@ jsi::Value RuntimeSchedulerBinding::get( jsi::Value const *, size_t) noexcept -> jsi::Value { auto shouldYield = runtimeScheduler_->getShouldYield(); - return jsi::Value(shouldYield); + return {shouldYield}; }); } @@ -148,7 +148,7 @@ jsi::Value RuntimeSchedulerBinding::get( auto asDouble = std::chrono::duration(now.time_since_epoch()) .count(); - return jsi::Value(asDouble); + return {asDouble}; }); } diff --git a/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp b/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp index 7c274bcf39358a..934fedff375455 100644 --- a/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp @@ -52,17 +52,17 @@ class RuntimeSchedulerTest : public testing::Test { jsi::PropNameID::forUtf8(*runtime_, ""), 3, [this, callback = std::move(callback)]( - jsi::Runtime &, - jsi::Value const &, + jsi::Runtime & /*unused*/, + jsi::Value const & /*unused*/, jsi::Value const *arguments, - size_t) -> jsi::Value { + size_t /*unused*/) -> jsi::Value { ++hostFunctionCallCount_; auto didUserCallbackTimeout = arguments[0].getBool(); return callback(didUserCallbackTimeout); }); } - uint hostFunctionCallCount_; + uint hostFunctionCallCount_{}; std::unique_ptr runtime_; std::unique_ptr stubClock_; @@ -160,8 +160,8 @@ TEST_F(RuntimeSchedulerTest, taskExpiration) { TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithSamePriority) { uint firstTaskCallOrder = 0; - auto callbackOne = - createHostFunctionFromLambda([this, &firstTaskCallOrder](bool) { + auto callbackOne = createHostFunctionFromLambda( + [this, &firstTaskCallOrder](bool /*unused*/) { firstTaskCallOrder = hostFunctionCallCount_; return jsi::Value::undefined(); }); @@ -170,8 +170,8 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithSamePriority) { SchedulerPriority::NormalPriority, std::move(callbackOne)); uint secondTaskCallOrder; - auto callbackTwo = - createHostFunctionFromLambda([this, &secondTaskCallOrder](bool) { + auto callbackTwo = createHostFunctionFromLambda( + [this, &secondTaskCallOrder](bool /*unused*/) { secondTaskCallOrder = hostFunctionCallCount_; return jsi::Value::undefined(); }); @@ -193,8 +193,8 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithSamePriority) { TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithDifferentPriorities) { uint lowPriorityTaskCallOrder = 0; - auto callbackOne = - createHostFunctionFromLambda([this, &lowPriorityTaskCallOrder](bool) { + auto callbackOne = createHostFunctionFromLambda( + [this, &lowPriorityTaskCallOrder](bool /*unused*/) { lowPriorityTaskCallOrder = hostFunctionCallCount_; return jsi::Value::undefined(); }); @@ -204,7 +204,7 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithDifferentPriorities) { uint userBlockingPriorityTaskCallOrder; auto callbackTwo = createHostFunctionFromLambda( - [this, &userBlockingPriorityTaskCallOrder](bool) { + [this, &userBlockingPriorityTaskCallOrder](bool /*unused*/) { userBlockingPriorityTaskCallOrder = hostFunctionCallCount_; return jsi::Value::undefined(); }); @@ -226,7 +226,7 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithDifferentPriorities) { TEST_F(RuntimeSchedulerTest, cancelTask) { bool didRunTask = false; - auto callback = createHostFunctionFromLambda([&didRunTask](bool) { + auto callback = createHostFunctionFromLambda([&didRunTask](bool /*unused*/) { didRunTask = true; return jsi::Value::undefined(); }); @@ -249,16 +249,16 @@ TEST_F(RuntimeSchedulerTest, continuationTask) { bool didRunTask = false; bool didContinuationTask = false; - auto callback = createHostFunctionFromLambda([&](bool) { + auto callback = createHostFunctionFromLambda([&](bool /*unused*/) { didRunTask = true; return jsi::Function::createFromHostFunction( *runtime_, jsi::PropNameID::forUtf8(*runtime_, ""), 1, - [&](jsi::Runtime &runtime, - jsi::Value const &, - jsi::Value const *arguments, - size_t) noexcept -> jsi::Value { + [&](jsi::Runtime & /*runtime*/, + jsi::Value const & /*unused*/, + jsi::Value const * /*arguments*/, + size_t /*unused*/) noexcept -> jsi::Value { didContinuationTask = true; return jsi::Value::undefined(); }); @@ -279,7 +279,7 @@ TEST_F(RuntimeSchedulerTest, continuationTask) { TEST_F(RuntimeSchedulerTest, getCurrentPriorityLevel) { auto callback = - createHostFunctionFromLambda([this](bool didUserCallbackTimeout) { + createHostFunctionFromLambda([this](bool /*didUserCallbackTimeout*/) { EXPECT_EQ( runtimeScheduler_->getCurrentPriorityLevel(), SchedulerPriority::ImmediatePriority); @@ -299,12 +299,13 @@ TEST_F(RuntimeSchedulerTest, getCurrentPriorityLevel) { runtimeScheduler_->getCurrentPriorityLevel(), SchedulerPriority::NormalPriority); - callback = createHostFunctionFromLambda([this](bool didUserCallbackTimeout) { - EXPECT_EQ( - runtimeScheduler_->getCurrentPriorityLevel(), - SchedulerPriority::IdlePriority); - return jsi::Value::undefined(); - }); + callback = + createHostFunctionFromLambda([this](bool /*didUserCallbackTimeout*/) { + EXPECT_EQ( + runtimeScheduler_->getCurrentPriorityLevel(), + SchedulerPriority::IdlePriority); + return jsi::Value::undefined(); + }); runtimeScheduler_->scheduleTask( SchedulerPriority::IdlePriority, std::move(callback)); @@ -319,7 +320,7 @@ TEST_F(RuntimeSchedulerTest, getCurrentPriorityLevel) { TEST_F(RuntimeSchedulerTest, scheduleWorkWithYielding) { bool wasCalled = false; runtimeScheduler_->scheduleWork( - [&](jsi::Runtime const &) { wasCalled = true; }); + [&](jsi::Runtime const & /*unused*/) { wasCalled = true; }); EXPECT_FALSE(wasCalled); @@ -338,7 +339,7 @@ TEST_F(RuntimeSchedulerTest, normalTaskYieldsToPlatformEvent) { bool didRunJavaScriptTask = false; bool didRunPlatformWork = false; - auto callback = createHostFunctionFromLambda([&](bool) { + auto callback = createHostFunctionFromLambda([&](bool /*unused*/) { didRunJavaScriptTask = true; EXPECT_TRUE(didRunPlatformWork); return jsi::Value::undefined(); @@ -347,7 +348,7 @@ TEST_F(RuntimeSchedulerTest, normalTaskYieldsToPlatformEvent) { runtimeScheduler_->scheduleTask( SchedulerPriority::NormalPriority, std::move(callback)); - runtimeScheduler_->scheduleWork([&](jsi::Runtime const &) { + runtimeScheduler_->scheduleWork([&](jsi::Runtime const & /*unused*/) { didRunPlatformWork = true; EXPECT_FALSE(didRunJavaScriptTask); EXPECT_FALSE(runtimeScheduler_->getShouldYield()); @@ -365,7 +366,7 @@ TEST_F(RuntimeSchedulerTest, expiredTaskDoesntYieldToPlatformEvent) { bool didRunJavaScriptTask = false; bool didRunPlatformWork = false; - auto callback = createHostFunctionFromLambda([&](bool) { + auto callback = createHostFunctionFromLambda([&](bool /*unused*/) { didRunJavaScriptTask = true; EXPECT_FALSE(didRunPlatformWork); return jsi::Value::undefined(); @@ -374,7 +375,7 @@ TEST_F(RuntimeSchedulerTest, expiredTaskDoesntYieldToPlatformEvent) { runtimeScheduler_->scheduleTask( SchedulerPriority::NormalPriority, std::move(callback)); - runtimeScheduler_->scheduleWork([&](jsi::Runtime const &) { + runtimeScheduler_->scheduleWork([&](jsi::Runtime const & /*unused*/) { didRunPlatformWork = true; EXPECT_TRUE(didRunJavaScriptTask); }); @@ -393,7 +394,7 @@ TEST_F(RuntimeSchedulerTest, immediateTaskDoesntYieldToPlatformEvent) { bool didRunJavaScriptTask = false; bool didRunPlatformWork = false; - auto callback = createHostFunctionFromLambda([&](bool) { + auto callback = createHostFunctionFromLambda([&](bool /*unused*/) { didRunJavaScriptTask = true; EXPECT_FALSE(didRunPlatformWork); return jsi::Value::undefined(); @@ -402,7 +403,7 @@ TEST_F(RuntimeSchedulerTest, immediateTaskDoesntYieldToPlatformEvent) { runtimeScheduler_->scheduleTask( SchedulerPriority::ImmediatePriority, std::move(callback)); - runtimeScheduler_->scheduleWork([&](jsi::Runtime const &) { + runtimeScheduler_->scheduleWork([&](jsi::Runtime const & /*unused*/) { didRunPlatformWork = true; EXPECT_TRUE(didRunJavaScriptTask); }); @@ -451,11 +452,12 @@ TEST_F(RuntimeSchedulerTest, scheduleTaskFromTask) { TEST_F(RuntimeSchedulerTest, handlingError) { bool didRunTask = false; - auto firstCallback = createHostFunctionFromLambda([this, &didRunTask](bool) { - didRunTask = true; - throw jsi::JSError(*runtime_, "Test error"); - return jsi::Value::undefined(); - }); + auto firstCallback = + createHostFunctionFromLambda([this, &didRunTask](bool /*unused*/) { + didRunTask = true; + throw jsi::JSError(*runtime_, "Test error"); + return jsi::Value::undefined(); + }); runtimeScheduler_->scheduleTask( SchedulerPriority::NormalPriority, std::move(firstCallback)); @@ -474,7 +476,7 @@ TEST_F(RuntimeSchedulerTest, basicSameThreadExecution) { bool didRunSynchronousTask = false; std::thread t1([this, &didRunSynchronousTask]() { runtimeScheduler_->executeNowOnTheSameThread( - [this, &didRunSynchronousTask](jsi::Runtime &rt) { + [this, &didRunSynchronousTask](jsi::Runtime & /*rt*/) { EXPECT_TRUE(runtimeScheduler_->getIsSynchronous()); didRunSynchronousTask = true; }); @@ -584,11 +586,11 @@ TEST_F(RuntimeSchedulerTest, twoThreadsRequestAccessToTheRuntime) { bool didRunWork = false; runtimeScheduler_->scheduleWork( - [&didRunWork](jsi::Runtime &) { didRunWork = true; }); + [&didRunWork](jsi::Runtime & /*unused*/) { didRunWork = true; }); std::thread t1([this, &didRunSynchronousTask]() { runtimeScheduler_->executeNowOnTheSameThread( - [&didRunSynchronousTask](jsi::Runtime &runtime) { + [&didRunSynchronousTask](jsi::Runtime & /*runtime*/) { didRunSynchronousTask = true; }); }); diff --git a/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp b/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp index 543be6cf5c70db..35ec8cdb17aa81 100644 --- a/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp +++ b/ReactCommon/react/renderer/scheduler/AsynchronousEventBeat.cpp @@ -23,7 +23,7 @@ AsynchronousEventBeat::AsynchronousEventBeat( void AsynchronousEventBeat::activityDidChange( RunLoopObserver::Delegate const *delegate, - RunLoopObserver::Activity) const noexcept { + RunLoopObserver::Activity /*activity*/) const noexcept { react_native_assert(delegate == this); induce(); } diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index dfacbf9c1f302f..a8418c52c6e930 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -68,7 +68,7 @@ Scheduler::Scheduler( runtime, eventTarget, type, priority, payloadFactory); }, runtime); - if (runtimeScheduler) { + if (runtimeScheduler != nullptr) { runtimeScheduler->callExpiredTasks(runtime); } }; @@ -295,14 +295,14 @@ void Scheduler::uiManagerDidFinishTransaction( MountingCoordinator::Shared const &mountingCoordinator) { SystraceSection s("Scheduler::uiManagerDidFinishTransaction"); - if (delegate_) { + if (delegate_ != nullptr) { delegate_->schedulerDidFinishTransaction(mountingCoordinator); } } void Scheduler::uiManagerDidCreateShadowNode(const ShadowNode &shadowNode) { SystraceSection s("Scheduler::uiManagerDidCreateShadowNode"); - if (delegate_) { + if (delegate_ != nullptr) { delegate_->schedulerDidRequestPreliminaryViewAllocation( shadowNode.getSurfaceId(), shadowNode); } @@ -313,7 +313,7 @@ void Scheduler::uiManagerDidCloneShadowNode( const ShadowNode &newShadowNode) { SystraceSection s("Scheduler::uiManagerDidCloneShadowNode"); - if (delegate_) { + if (delegate_ != nullptr) { delegate_->schedulerDidCloneShadowNode( newShadowNode.getSurfaceId(), oldShadowNode, newShadowNode); } @@ -325,7 +325,7 @@ void Scheduler::uiManagerDidDispatchCommand( folly::dynamic const &args) { SystraceSection s("Scheduler::uiManagerDispatchCommand"); - if (delegate_) { + if (delegate_ != nullptr) { auto shadowView = ShadowView(*shadowNode); delegate_->schedulerDidDispatchCommand(shadowView, commandName, args); } @@ -336,7 +336,7 @@ void Scheduler::uiManagerDidSendAccessibilityEvent( std::string const &eventType) { SystraceSection s("Scheduler::uiManagerDidSendAccessibilityEvent"); - if (delegate_) { + if (delegate_ != nullptr) { auto shadowView = ShadowView(*shadowNode); delegate_->schedulerDidSendAccessibilityEvent(shadowView, eventType); } @@ -349,7 +349,7 @@ void Scheduler::uiManagerDidSetIsJSResponder( ShadowNode::Shared const &shadowNode, bool isJSResponder, bool blockNativeResponder) { - if (delegate_) { + if (delegate_ != nullptr) { delegate_->schedulerDidSetIsJSResponder( ShadowView(*shadowNode), isJSResponder, blockNativeResponder); } diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.h b/ReactCommon/react/renderer/scheduler/Scheduler.h index 626572a073f23f..eaba25e16f451c 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.h +++ b/ReactCommon/react/renderer/scheduler/Scheduler.h @@ -101,7 +101,7 @@ class Scheduler final : public UIManagerDelegate { const ShadowNode::Shared &shadowNode, std::string const &eventType) override; void uiManagerDidSetIsJSResponder( - ShadowNode::Shared const &shadowView, + ShadowNode::Shared const &shadowNode, bool isJSResponder, bool blockNativeResponder) override; diff --git a/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp b/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp index b68e2f617a153a..f8753a6ec37a26 100644 --- a/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp +++ b/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp @@ -283,10 +283,12 @@ void SurfaceHandler::applyDisplayMode(DisplayMode displayMode) const noexcept { link_.shadowTree->setCommitMode(ShadowTree::CommitMode::Suspended); // Committing the current revision back. It will be mounted only when // `DisplayMode` is changed back to `Normal`. - link_.shadowTree->commit([&](RootShadowNode const &oldRootShadowNode) { - return std::static_pointer_cast( - revision.rootShadowNode->ShadowNode::clone(ShadowNodeFragment{})); - }); + link_.shadowTree->commit( + [&](RootShadowNode const & /*oldRootShadowNode*/) { + return std::static_pointer_cast( + revision.rootShadowNode->ShadowNode::clone( + ShadowNodeFragment{})); + }); break; } } @@ -302,7 +304,8 @@ void SurfaceHandler::setUIManager(UIManager const *uiManager) const noexcept { } link_.uiManager = uiManager; - link_.status = uiManager ? Status::Registered : Status::Unregistered; + link_.status = + uiManager != nullptr ? Status::Registered : Status::Unregistered; } SurfaceHandler::~SurfaceHandler() noexcept { diff --git a/ReactCommon/react/renderer/scheduler/SurfaceHandler.h b/ReactCommon/react/renderer/scheduler/SurfaceHandler.h index babf534da3a32c..f550e709f59f08 100644 --- a/ReactCommon/react/renderer/scheduler/SurfaceHandler.h +++ b/ReactCommon/react/renderer/scheduler/SurfaceHandler.h @@ -67,7 +67,7 @@ class SurfaceHandler { /* * Movable-only. */ - SurfaceHandler(SurfaceHandler &&SurfaceHandler) noexcept; + SurfaceHandler(SurfaceHandler &&other) noexcept; SurfaceHandler(SurfaceHandler const &SurfaceHandler) noexcept = delete; SurfaceHandler &operator=(SurfaceHandler &&other) noexcept; SurfaceHandler &operator=(SurfaceHandler const &other) noexcept = delete; diff --git a/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp b/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp index fc9a406629c073..f100463329db50 100644 --- a/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp +++ b/ReactCommon/react/renderer/scheduler/SynchronousEventBeat.cpp @@ -28,7 +28,7 @@ SynchronousEventBeat::SynchronousEventBeat( void SynchronousEventBeat::activityDidChange( RunLoopObserver::Delegate const *delegate, - RunLoopObserver::Activity activity) const noexcept { + RunLoopObserver::Activity /*activity*/) const noexcept { react_native_assert(delegate == this); lockExecutorAndBeat(); } diff --git a/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h b/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h index a95339e58b9114..81416defac27f1 100644 --- a/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h +++ b/ReactCommon/react/renderer/templateprocessor/UITemplateProcessor.h @@ -46,7 +46,7 @@ class UITemplateProcessor { public: static ShadowNode::Shared buildShadowTree( const std::string &jsonStr, - int rootTag, + int surfaceId, const folly::dynamic ¶ms, const ComponentDescriptorRegistry &componentDescriptorRegistry, const NativeModuleRegistry &nativeModuleRegistry, @@ -55,7 +55,7 @@ class UITemplateProcessor { private: static ShadowNode::Shared runCommand( const folly::dynamic &command, - Tag rootTag, + Tag surfaceId, std::vector &nodes, std::vector ®isters, const ComponentDescriptorRegistry &componentDescriptorRegistry, diff --git a/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp b/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp index fc672ef606bfb2..70fa3e85e01abb 100644 --- a/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp +++ b/ReactCommon/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp @@ -48,7 +48,8 @@ NativeModuleRegistry buildNativeModuleRegistry(); NativeModuleRegistry buildNativeModuleRegistry() { NativeModuleRegistry nMR; nMR.registerModule( - "MobileConfig", [&](const std::string &, const folly::dynamic &) { + "MobileConfig", + [&](const std::string & /*unused*/, const folly::dynamic & /*unused*/) { return mockSimpleTestValue_; }); return nMR; @@ -57,19 +58,19 @@ NativeModuleRegistry buildNativeModuleRegistry() { class MockReactNativeConfig : public ReactNativeConfig { public: MockReactNativeConfig() = default; - bool getBool(const std::string ¶m) const override { + bool getBool(const std::string & /*param*/) const override { return mockSimpleTestValue_; } - std::string getString(const std::string &) const override { + std::string getString(const std::string & /*param*/) const override { return ""; } - int64_t getInt64(const std::string &) const override { + int64_t getInt64(const std::string & /*param*/) const override { return 0; } - double getDouble(const std::string &) const override { + double getDouble(const std::string & /*param*/) const override { return 0.0; } }; diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp index c4c5bfce9b1e1d..a8ca135e5795ac 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp @@ -166,9 +166,9 @@ TextMeasurement TextLayoutManager::measure( auto measurement = measureCache_.get( {attributedString, paragraphAttributes, layoutConstraints}, - [&](TextMeasureCacheKey const &key) { + [&](TextMeasureCacheKey const & /*key*/) { auto telemetry = TransactionTelemetry::threadLocalTelemetry(); - if (telemetry) { + if (telemetry != nullptr) { telemetry->willMeasureText(); } @@ -178,7 +178,7 @@ TextMeasurement TextLayoutManager::measure( : doMeasure( attributedString, paragraphAttributes, layoutConstraints); - if (telemetry) { + if (telemetry != nullptr) { telemetry->didMeasureText(); } diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h index ad3483b3eb8dd1..711e617fc729f0 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h @@ -88,7 +88,7 @@ class TextLayoutManager { ParagraphAttributes const ¶graphAttributes, Size size) const; - void *self_; + void *self_{}; ContextContainer::Shared contextContainer_; bool mapBufferSerializationEnabled_; TextMeasureCache measureCache_; diff --git a/ReactCommon/react/renderer/timeline/Timeline.cpp b/ReactCommon/react/renderer/timeline/Timeline.cpp index ea569370e8d2aa..e8377f8efb3f3e 100644 --- a/ReactCommon/react/renderer/timeline/Timeline.cpp +++ b/ReactCommon/react/renderer/timeline/Timeline.cpp @@ -31,7 +31,7 @@ void Timeline::pause() const noexcept { void Timeline::resume() const noexcept { std::lock_guard lock(mutex_); - if (snapshots_.size() > 0) { + if (!snapshots_.empty()) { rewind(snapshots_.at(snapshots_.size() - 1)); } @@ -66,8 +66,8 @@ void Timeline::rewind(TimelineFrame const &frame) const noexcept { } RootShadowNode::Unshared Timeline::shadowTreeWillCommit( - ShadowTree const &shadowTree, - RootShadowNode::Shared const &oldRootShadowNode, + ShadowTree const & /*shadowTree*/, + RootShadowNode::Shared const & /*oldRootShadowNode*/, RootShadowNode::Unshared const &newRootShadowNode) const noexcept { std::lock_guard lock(mutex_); @@ -107,7 +107,8 @@ void Timeline::rewind(TimelineSnapshot const &snapshot) const noexcept { auto rootShadowNode = snapshot.getRootShadowNode(); shadowTree_->commit( - [&](RootShadowNode const &oldRootShadowNode) -> RootShadowNode::Unshared { + [&](RootShadowNode const & /*oldRootShadowNode*/) + -> RootShadowNode::Unshared { return std::static_pointer_cast( rootShadowNode->ShadowNode::clone({})); }); diff --git a/ReactCommon/react/renderer/timeline/TimelineController.cpp b/ReactCommon/react/renderer/timeline/TimelineController.cpp index 01e716741f76a9..accbcb7b15e080 100644 --- a/ReactCommon/react/renderer/timeline/TimelineController.cpp +++ b/ReactCommon/react/renderer/timeline/TimelineController.cpp @@ -49,7 +49,7 @@ void TimelineController::commitHookWasRegistered( } void TimelineController::commitHookWasUnregistered( - UIManager const &uiManager) const noexcept { + UIManager const & /*uiManager*/) const noexcept { uiManager_ = nullptr; } diff --git a/ReactCommon/react/renderer/timeline/TimelineHandler.cpp b/ReactCommon/react/renderer/timeline/TimelineHandler.cpp index 3deef099f739be..7b8dcecb38c384 100644 --- a/ReactCommon/react/renderer/timeline/TimelineHandler.cpp +++ b/ReactCommon/react/renderer/timeline/TimelineHandler.cpp @@ -88,7 +88,7 @@ void TimelineHandler::release() noexcept { } void TimelineHandler::ensureNotEmpty() const noexcept { - if (!timeline_) { + if (timeline_ == nullptr) { abort(); } } diff --git a/ReactCommon/react/renderer/timeline/TimelineHandler.h b/ReactCommon/react/renderer/timeline/TimelineHandler.h index 61fa45f3ce8aa1..3615d76eba7613 100644 --- a/ReactCommon/react/renderer/timeline/TimelineHandler.h +++ b/ReactCommon/react/renderer/timeline/TimelineHandler.h @@ -23,7 +23,7 @@ class TimelineHandler final { /* * Movable, not copyable. */ - TimelineHandler(TimelineHandler &&timelineHandler) noexcept; + TimelineHandler(TimelineHandler &&other) noexcept; TimelineHandler(TimelineHandler const &timelineHandler) = delete; TimelineHandler &operator=(TimelineHandler &&other) noexcept; TimelineHandler &operator=(TimelineHandler const &other) = delete; @@ -73,7 +73,7 @@ class TimelineHandler final { void ensureNotEmpty() const noexcept; - Timeline const *timeline_; + Timeline const *timeline_{}; }; } // namespace react diff --git a/ReactCommon/react/renderer/uimanager/UIManager.cpp b/ReactCommon/react/renderer/uimanager/UIManager.cpp index cd2d3267dafae3..3e7b912e7b7eb5 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -90,7 +90,7 @@ ShadowNode::Shared UIManager::createNode( }, family); - if (delegate_) { + if (delegate_ != nullptr) { delegate_->uiManagerDidCreateShadowNode(*shadowNode); } if (leakChecker_) { @@ -114,13 +114,14 @@ ShadowNode::Shared UIManager::cloneNode( shadowNode, { /* .props = */ - rawProps ? componentDescriptor.cloneProps( - propsParserContext, shadowNode.getProps(), *rawProps) - : ShadowNodeFragment::propsPlaceholder(), + rawProps != nullptr + ? componentDescriptor.cloneProps( + propsParserContext, shadowNode.getProps(), *rawProps) + : ShadowNodeFragment::propsPlaceholder(), /* .children = */ children, }); - if (delegate_) { + if (delegate_ != nullptr) { delegate_->uiManagerDidCloneShadowNode(shadowNode, *clonedShadowNode); } @@ -160,7 +161,7 @@ void UIManager::setIsJSResponder( ShadowNode::Shared const &shadowNode, bool isJSResponder, bool blockNativeResponder) const { - if (delegate_) { + if (delegate_ != nullptr) { delegate_->uiManagerDidSetIsJSResponder( shadowNode, isJSResponder, blockNativeResponder); } @@ -260,7 +261,7 @@ LayoutMetrics UIManager::getRelativeLayoutMetrics( // that the node is not deallocated during method execution lifetime. auto owningAncestorShadowNode = ShadowNode::Shared{}; - if (!ancestorShadowNode) { + if (ancestorShadowNode == nullptr) { shadowTreeRegistry_.visit( shadowNode.getSurfaceId(), [&](ShadowTree const &shadowTree) { owningAncestorShadowNode = @@ -278,7 +279,7 @@ LayoutMetrics UIManager::getRelativeLayoutMetrics( auto layoutableAncestorShadowNode = traitCast(ancestorShadowNode); - if (!layoutableAncestorShadowNode) { + if (layoutableAncestorShadowNode == nullptr) { return EmptyLayoutMetrics; } @@ -328,7 +329,7 @@ void UIManager::dispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, folly::dynamic const &args) const { - if (delegate_) { + if (delegate_ != nullptr) { delegate_->uiManagerDidDispatchCommand(shadowNode, commandName, args); } } @@ -336,7 +337,7 @@ void UIManager::dispatchCommand( void UIManager::sendAccessibilityEvent( const ShadowNode::Shared &shadowNode, std::string const &eventType) { - if (delegate_) { + if (delegate_ != nullptr) { delegate_->uiManagerDidSendAccessibilityEvent(shadowNode, eventType); } } @@ -346,7 +347,7 @@ void UIManager::configureNextLayoutAnimation( RawValue const &config, jsi::Value const &successCallback, jsi::Value const &failureCallback) const { - if (animationDelegate_) { + if (animationDelegate_ != nullptr) { animationDelegate_->uiManagerDidConfigureNextLayoutAnimation( runtime, config, @@ -420,11 +421,11 @@ RootShadowNode::Unshared UIManager::shadowTreeWillCommit( } void UIManager::shadowTreeDidFinishTransaction( - ShadowTree const &shadowTree, + ShadowTree const & /*shadowTree*/, MountingCoordinator::Shared const &mountingCoordinator) const { SystraceSection s("UIManager::shadowTreeDidFinishTransaction"); - if (delegate_) { + if (delegate_ != nullptr) { delegate_->uiManagerDidFinishTransaction(mountingCoordinator); } } diff --git a/ReactCommon/react/renderer/uimanager/UIManager.h b/ReactCommon/react/renderer/uimanager/UIManager.h index a30a594becfba9..e0ba886c972502 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.h +++ b/ReactCommon/react/renderer/uimanager/UIManager.h @@ -184,7 +184,7 @@ class UIManager final : public ShadowTreeDelegate { jsi::Value const &failureCallback) const; SharedComponentDescriptorRegistry componentDescriptorRegistry_; - UIManagerDelegate *delegate_; + UIManagerDelegate *delegate_{}; UIManagerAnimationDelegate *animationDelegate_{nullptr}; RuntimeExecutor const runtimeExecutor_{}; ShadowTreeRegistry shadowTreeRegistry_{}; diff --git a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index 9393ba512f6781..e1ac1399850cf8 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -107,7 +107,7 @@ void UIManagerBinding::dispatchEvent( return; } - auto instanceHandle = eventTarget + auto instanceHandle = eventTarget != nullptr ? [&]() { auto instanceHandle = eventTarget->getInstanceHandle(runtime); if (instanceHandle.isUndefined()) { @@ -187,9 +187,9 @@ jsi::Value UIManagerBinding::get( 5, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto eventTarget = eventTargetFromValue(runtime, arguments[4], arguments[0]); if (!eventTarget) { @@ -215,9 +215,9 @@ jsi::Value UIManagerBinding::get( 1, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { return valueFromShadowNode( runtime, uiManager->cloneNode( @@ -232,9 +232,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { uiManager->setIsJSResponder( shadowNodeFromValue(runtime, arguments[0]), arguments[1].getBool(), @@ -251,9 +251,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto node = shadowNodeFromValue(runtime, arguments[0]); auto locationX = (Float)arguments[1].getNumber(); auto locationY = (Float)arguments[2].getNumber(); @@ -282,9 +282,9 @@ jsi::Value UIManagerBinding::get( 1, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { return valueFromShadowNode( runtime, uiManager->cloneNode( @@ -301,9 +301,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto const &rawProps = RawProps(runtime, arguments[1]); return valueFromShadowNode( runtime, @@ -322,9 +322,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto const &rawProps = RawProps(runtime, arguments[1]); return valueFromShadowNode( runtime, @@ -342,9 +342,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { uiManager->appendChild( shadowNodeFromValue(runtime, arguments[0]), shadowNodeFromValue(runtime, arguments[1])); @@ -358,9 +358,9 @@ jsi::Value UIManagerBinding::get( name, 1, [](jsi::Runtime &runtime, - jsi::Value const &thisValue, - jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + jsi::Value const & /*thisValue*/, + jsi::Value const * /*arguments*/, + size_t /*count*/) noexcept -> jsi::Value { auto shadowNodeList = std::make_shared( ShadowNode::ListOfShared({})); return valueFromShadowNodeList(runtime, shadowNodeList); @@ -373,9 +373,9 @@ jsi::Value UIManagerBinding::get( name, 2, [](jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto shadowNodeList = shadowNodeListFromValue(runtime, arguments[0]); auto shadowNode = shadowNodeFromValue(runtime, arguments[1]); shadowNodeList->push_back(shadowNode); @@ -393,9 +393,9 @@ jsi::Value UIManagerBinding::get( 2, [weakUIManager, uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto runtimeSchedulerBinding = RuntimeSchedulerBinding::getBinding(runtime); auto surfaceId = surfaceIdFromValue(runtime, arguments[0]); @@ -449,9 +449,9 @@ jsi::Value UIManagerBinding::get( 1, [this]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto eventHandler = arguments[0].getObject(runtime).getFunction(runtime); eventHandler_ = @@ -467,9 +467,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto layoutMetrics = uiManager->getRelativeLayoutMetrics( *shadowNodeFromValue(runtime, arguments[0]), shadowNodeFromValue(runtime, arguments[1]).get(), @@ -491,9 +491,9 @@ jsi::Value UIManagerBinding::get( 3, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto shadowNode = shadowNodeFromValue(runtime, arguments[0]); if (shadowNode) { uiManager->dispatchCommand( @@ -513,9 +513,9 @@ jsi::Value UIManagerBinding::get( 4, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto layoutMetrics = uiManager->getRelativeLayoutMetrics( *shadowNodeFromValue(runtime, arguments[0]), shadowNodeFromValue(runtime, arguments[1]).get(), @@ -549,9 +549,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto shadowNode = shadowNodeFromValue(runtime, arguments[0]); auto layoutMetrics = uiManager->getRelativeLayoutMetrics( *shadowNode, nullptr, {/* .includeTransform = */ true}); @@ -567,7 +567,7 @@ jsi::Value UIManagerBinding::get( auto layoutableShadowNode = traitCast( newestCloneOfShadowNode.get()); - Point originRelativeToParent = layoutableShadowNode + Point originRelativeToParent = layoutableShadowNode != nullptr ? layoutableShadowNode->getLayoutMetrics().frame.origin : Point(); @@ -591,9 +591,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { auto layoutMetrics = uiManager->getRelativeLayoutMetrics( *shadowNodeFromValue(runtime, arguments[0]), nullptr, @@ -626,9 +626,9 @@ jsi::Value UIManagerBinding::get( 2, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { uiManager->sendAccessibilityEvent( shadowNodeFromValue(runtime, arguments[0]), stringFromValue(runtime, arguments[1])); @@ -644,9 +644,9 @@ jsi::Value UIManagerBinding::get( 3, [uiManager]( jsi::Runtime &runtime, - jsi::Value const &thisValue, + jsi::Value const & /*thisValue*/, jsi::Value const *arguments, - size_t count) noexcept -> jsi::Value { + size_t /*count*/) noexcept -> jsi::Value { uiManager->configureNextLayoutAnimation( runtime, // TODO: pass in JSI value instead of folly::dynamic to RawValue @@ -667,16 +667,16 @@ jsi::Value UIManagerBinding::get( jsi::Value const &, jsi::Value const *, size_t) noexcept -> jsi::Value { - return jsi::Value(serialize(currentEventPriority_)); + return {serialize(currentEventPriority_)}; }); } if (methodName == "unstable_DefaultEventPriority") { - return jsi::Value(serialize(ReactEventPriority::Default)); + return {serialize(ReactEventPriority::Default)}; } if (methodName == "unstable_DiscreteEventPriority") { - return jsi::Value(serialize(ReactEventPriority::Discrete)); + return {serialize(ReactEventPriority::Discrete)}; } return jsi::Value::undefined(); From 00458c94109776251678efbec10052702a41c335 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Tue, 6 Sep 2022 10:24:22 -0700 Subject: [PATCH 013/174] Make react-native-codegen tests run in OSS (#34594) Summary: During the CoreContributor summit, we discovered that the `react-native-codegen` tests cannot be executed in the OSS due to this [issue with Jest](https://github.com/facebook/jest/issues/2567). This PR moves the required variables inside the proper closure so that we can run tests in the OSS. ## Changelog [General] [Fixed] - Enable the `react-native-codegen` tests in the OSS. Pull Request resolved: https://github.com/facebook/react-native/pull/34594 Test Plan: 1. Run `yarn install` in the `react-native-codegen` folder. 2. Run `yarn jest`, see the test fail. 3. Apply the changes in this diff. 4. Run `yarn jest`, see the test pass. Reviewed By: cortinico Differential Revision: D39259164 Pulled By: cipolleschi fbshipit-source-id: 7c4c0a7baa3c9b5e90a7ef75a37a0ec9d1b89db0 --- .gitignore | 2 + .../generators/__tests__/RNCodegen-test.js | 40 ++++++++++--------- .../__tests__/component-parser-test.js | 9 ++++- .../__tests__/module-parser-snapshot-test.js | 11 ++++- .../typescript-component-parser-test.js | 9 ++++- .../typescript-module-parser-snapshot-test.js | 10 ++++- 6 files changed, 58 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index c954afb75a0f3b..98dd6edc4f9481 100644 --- a/.gitignore +++ b/.gitignore @@ -111,9 +111,11 @@ package-lock.json # react-native-codegen /React/FBReactNativeSpec/FBReactNativeSpec /packages/react-native-codegen/lib +/packages/react-native-codegen/tmp/ /ReactCommon/react/renderer/components/rncore/ /packages/rn-tester/NativeModuleExample/ScreenshotManagerSpec* + # Additional SDKs /sdks/download /sdks/hermes diff --git a/packages/react-native-codegen/src/generators/__tests__/RNCodegen-test.js b/packages/react-native-codegen/src/generators/__tests__/RNCodegen-test.js index 4cc51277d1d03d..10d1d2543d4118 100644 --- a/packages/react-native-codegen/src/generators/__tests__/RNCodegen-test.js +++ b/packages/react-native-codegen/src/generators/__tests__/RNCodegen-test.js @@ -13,9 +13,6 @@ const rnCodegen = require('../RNCodegen.js'); const fixture = require('../__test_fixtures__/fixtures.js'); -const path = require('path'); - -const outputDirectory = 'tmp/out/'; const packageName = 'na'; describe('RNCodegen.generate', () => { @@ -23,27 +20,31 @@ describe('RNCodegen.generate', () => { jest.resetModules(); }); it('when type `all`, with default paths', () => { - const componentsOutputDir = 'react/renderer/components/library'; - const modulesOutputDir = 'library'; - - const expectedPaths = { - 'library.h': modulesOutputDir, - 'library-generated.mm': modulesOutputDir, - 'ShadowNodes.h': componentsOutputDir, - 'ShadowNodes.cpp': componentsOutputDir, - 'Props.h': componentsOutputDir, - 'Props.cpp': componentsOutputDir, - 'RCTComponentViewHelpers.h': componentsOutputDir, - 'EventEmitters.h': componentsOutputDir, - 'EventEmitters.cpp': componentsOutputDir, - 'ComponentDescriptors.h': componentsOutputDir, - }; - jest.mock('fs', () => ({ existsSync: location => { return true; }, writeFileSync: (location, content) => { + // Jest in the OSS does not allow to capture variables in closures. + // Therefore, we have to bring the variables inside the closure. + // see: https://github.com/facebook/jest/issues/2567 + const path = require('path'); + const outputDirectory = 'tmp/out/'; + const componentsOutputDir = 'react/renderer/components/library'; + const modulesOutputDir = 'library'; + const expectedPaths = { + 'library.h': modulesOutputDir, + 'library-generated.mm': modulesOutputDir, + 'ShadowNodes.h': componentsOutputDir, + 'ShadowNodes.cpp': componentsOutputDir, + 'Props.h': componentsOutputDir, + 'Props.cpp': componentsOutputDir, + 'RCTComponentViewHelpers.h': componentsOutputDir, + 'EventEmitters.h': componentsOutputDir, + 'EventEmitters.cpp': componentsOutputDir, + 'ComponentDescriptors.h': componentsOutputDir, + }; + let receivedDir = path.dirname(location); let receivedBasename = path.basename(location); @@ -55,6 +56,7 @@ describe('RNCodegen.generate', () => { }, })); + const outputDirectory = 'tmp/out/'; const res = rnCodegen.generate( { libraryName: 'library', diff --git a/packages/react-native-codegen/src/parsers/flow/components/__tests__/component-parser-test.js b/packages/react-native-codegen/src/parsers/flow/components/__tests__/component-parser-test.js index 8c5a3c3457a806..a58743aaaa2aac 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/__tests__/component-parser-test.js +++ b/packages/react-native-codegen/src/parsers/flow/components/__tests__/component-parser-test.js @@ -15,7 +15,14 @@ const FlowParser = require('../../index.js'); const fixtures = require('../__test_fixtures__/fixtures.js'); const failureFixtures = require('../__test_fixtures__/failures.js'); jest.mock('fs', () => ({ - readFileSync: filename => fixtures[filename] || failureFixtures[filename], + readFileSync: filename => { + // Jest in the OSS does not allow to capture variables in closures. + // Therefore, we have to bring the variables inside the closure. + // see: https://github.com/facebook/jest/issues/2567 + const readFileFixtures = require('../__test_fixtures__/fixtures.js'); + const readFileFailureFixtures = require('../__test_fixtures__/failures.js'); + return readFileFixtures[filename] || readFileFailureFixtures[filename]; + }, })); describe('RN Codegen Flow Parser', () => { diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-snapshot-test.js b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-snapshot-test.js index 103c80e8c1e044..22291f12ef599e 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-snapshot-test.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-snapshot-test.js @@ -12,10 +12,19 @@ 'use strict'; const FlowParser = require('../../index.js'); + const fixtures = require('../__test_fixtures__/fixtures.js'); const failureFixtures = require('../__test_fixtures__/failures.js'); + jest.mock('fs', () => ({ - readFileSync: filename => fixtures[filename] || failureFixtures[filename], + readFileSync: filename => { + // Jest in the OSS does not allow to capture variables in closures. + // Therefore, we have to bring the variables inside the closure. + // see: https://github.com/facebook/jest/issues/2567 + const readFileFixtures = require('../__test_fixtures__/fixtures.js'); + const readFileFailureFixtures = require('../__test_fixtures__/failures.js'); + return readFileFixtures[filename] || readFileFailureFixtures[filename]; + }, })); describe('RN Codegen Flow Parser', () => { diff --git a/packages/react-native-codegen/src/parsers/typescript/components/__tests__/typescript-component-parser-test.js b/packages/react-native-codegen/src/parsers/typescript/components/__tests__/typescript-component-parser-test.js index 223c7d558efb18..7538a12ea9621d 100644 --- a/packages/react-native-codegen/src/parsers/typescript/components/__tests__/typescript-component-parser-test.js +++ b/packages/react-native-codegen/src/parsers/typescript/components/__tests__/typescript-component-parser-test.js @@ -15,7 +15,14 @@ const TypeScriptParser = require('../../index.js'); const fixtures = require('../__test_fixtures__/fixtures.js'); const failureFixtures = require('../__test_fixtures__/failures.js'); jest.mock('fs', () => ({ - readFileSync: filename => fixtures[filename] || failureFixtures[filename], + readFileSync: filename => { + // Jest in the OSS does not allow to capture variables in closures. + // Therefore, we have to bring the variables inside the closure. + // see: https://github.com/facebook/jest/issues/2567 + const readFileFixtures = require('../__test_fixtures__/fixtures.js'); + const readFileFailureFixtures = require('../__test_fixtures__/failures.js'); + return readFileFixtures[filename] || readFileFailureFixtures[filename]; + }, })); describe('RN Codegen TypeScript Parser', () => { diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/typescript-module-parser-snapshot-test.js b/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/typescript-module-parser-snapshot-test.js index 371e6f7d9c6b9d..b9935444b98e11 100644 --- a/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/typescript-module-parser-snapshot-test.js +++ b/packages/react-native-codegen/src/parsers/typescript/modules/__tests__/typescript-module-parser-snapshot-test.js @@ -14,8 +14,16 @@ const TypeScriptParser = require('../../index.js'); const fixtures = require('../__test_fixtures__/fixtures.js'); const failureFixtures = require('../__test_fixtures__/failures.js'); + jest.mock('fs', () => ({ - readFileSync: filename => fixtures[filename] || failureFixtures[filename], + readFileSync: filename => { + // Jest in the OSS does not allow to capture variables in closures. + // Therefore, we have to bring the variables inside the closure. + // see: https://github.com/facebook/jest/issues/2567 + const readFileFixtures = require('../__test_fixtures__/fixtures.js'); + const readFileFailureFixtures = require('../__test_fixtures__/failures.js'); + return readFileFixtures[filename] || readFileFailureFixtures[filename]; + }, })); describe('RN Codegen TypeScript Parser', () => { From 37d0a25cb28879449d89056079c94177c7d2c73f Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 6 Sep 2022 10:52:22 -0700 Subject: [PATCH 014/174] React Native sync for revisions 229c86a...c1f5884 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: This sync includes the following changes: - **[c1f5884ff](https://github.com/facebook/react/commit/c1f5884ff )**: Add missing null checks to OffscreenInstance code ([#24846](https://github.com/facebook/react/pull/24846)) //// - **[4cd788aef](https://github.com/facebook/react/commit/4cd788aef )**: Revert "Revert [Transition Tracing] Refactor Transition Tracing Root Code" ([#24830](https://github.com/facebook/react/pull/24830)) //// - **[e61fd91f5](https://github.com/facebook/react/commit/e61fd91f5 )**: Revert "[Transition Tracing] Refactor Transition Tracing Root Code ([#24766](https://github.com/facebook/react/pull/24766))" ([#24829](https://github.com/facebook/react/pull/24829)) //// - **[401296310](https://github.com/facebook/react/commit/401296310 )**: [Transition Tracing] Refactor Transition Tracing Root Code ([#24766](https://github.com/facebook/react/pull/24766)) //// - **[185932902](https://github.com/facebook/react/commit/185932902 )**: Track nearest Suspense handler on stack ([#24585](https://github.com/facebook/react/pull/24585)) //// - **[a7b192e0f](https://github.com/facebook/react/commit/a7b192e0f )**: Add test gate alias for Offscreen ([#24749](https://github.com/facebook/react/pull/24749)) //// - **[6b6cf8311](https://github.com/facebook/react/commit/6b6cf8311 )**: Land forked reconciler changes ([#24817](https://github.com/facebook/react/pull/24817)) //// - **[d1432ba93](https://github.com/facebook/react/commit/d1432ba93 )**: [Transition Tracing] Fix excess calls to the transition start callback ([#24806](https://github.com/facebook/react/pull/24806)) //// - **[88574c1b8](https://github.com/facebook/react/commit/88574c1b8 )**: Fix enableTransitionTracing flag ([#24801](https://github.com/facebook/react/pull/24801)) //// - **[a4bed4696](https://github.com/facebook/react/commit/a4bed4696 )**: [Transition Tracing] Add Tracing Markers ([#24686](https://github.com/facebook/react/pull/24686)) //// - **[167853026](https://github.com/facebook/react/commit/167853026 )**: fix hydration warning suppression in text comparisons ([#24784](https://github.com/facebook/react/pull/24784)) //// - **[9abe745aa](https://github.com/facebook/react/commit/9abe745aa )**: [DevTools][Timeline Profiler] Component Stacks Backend ([#24776](https://github.com/facebook/react/pull/24776)) //// - **[cf665c4b7](https://github.com/facebook/react/commit/cf665c4b7 )**: [DevTools] Refactor incompleteTransitions field from Root Fiber memoized state to FiberRoot ([#24765](https://github.com/facebook/react/pull/24765)) //// - **[56389e81f](https://github.com/facebook/react/commit/56389e81f )**: Abort Flight ([#24754](https://github.com/facebook/react/pull/24754)) //// - **[0f216ae31](https://github.com/facebook/react/commit/0f216ae31 )**: Add entry points for "static" server rendering passes ([#24752](https://github.com/facebook/react/pull/24752)) //// - **[f796fa13a](https://github.com/facebook/react/commit/f796fa13a )**: Rename Segment to Task in Flight ([#24753](https://github.com/facebook/react/pull/24753)) //// - **[0f0aca3ab](https://github.com/facebook/react/commit/0f0aca3ab )**: Aborting early should not infinitely suspend ([#24751](https://github.com/facebook/react/pull/24751)) //// - **[12a738f1a](https://github.com/facebook/react/commit/12a738f1a )**: [Transition Tracing] Add Support for Multiple Transitions on Root ([#24732](https://github.com/facebook/react/pull/24732)) //// - **[72ebc703a](https://github.com/facebook/react/commit/72ebc703a )**: [DevTools] fix useDeferredValue to match reconciler change ([#24742](https://github.com/facebook/react/pull/24742)) //// - **[7cf9f5e03](https://github.com/facebook/react/commit/7cf9f5e03 )**: Extra space ([#24612](https://github.com/facebook/react/pull/24612)) //// Changelog: [General][Changed] - React Native sync for revisions 229c86a...c1f5884 Reviewed By: mdvacca, GijsWeterings Differential Revision: D38904311 fbshipit-source-id: 1e30bc420c30ec7a0c0073fc92a706afef4b3340 --- Libraries/Renderer/REVISION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index e542b33c1c8aee..30c8a05b38c458 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -229c86af07302d40b70c41de18106f80fe89836c \ No newline at end of file +c1f5884ffeceb8be2277e10c81aeaffca2dfe9d8 \ No newline at end of file From 18119422aeb23cef99ae0e6d41797c6bd0aceb6a Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Wed, 7 Sep 2022 02:57:28 -0700 Subject: [PATCH 015/174] Run Codegen Tests in CI (#34596) Summary: This PR runs the Jest test for the Codegen package in CI. ## Changelog [General] [Added] - Run Codegen Tests in CI Pull Request resolved: https://github.com/facebook/react-native/pull/34596 Test Plan: CircleCI should show a new job for the tests. The job should be green. Reviewed By: NickGerleman Differential Revision: D39275645 Pulled By: cipolleschi fbshipit-source-id: 29133c933f134802029406ff255b62d27681c8ff --- .circleci/config.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 514315b4f61ca7..863275c704b510 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -406,6 +406,27 @@ jobs: - store_test_results: path: ./reports/junit + # ----------------------- + # JOBS: Codegen Tests + # ----------------------- + test_codegen: + parameters: + executor: + type: executor + default: nodelts + executor: << parameters.executor >> + steps: + - checkout + - setup_artifacts + - run: + name: Install Yarn in codegen + command: yarn install + working_directory: packages/react-native-codegen + - run: + name: Run Tests + command: yarn jest + working_directory: packages/react-native-codegen + # ------------------------- # JOBS: iOS Unit Tests # ------------------------- @@ -1328,6 +1349,7 @@ workflows: unless: << pipeline.parameters.run_package_release_workflow_only >> jobs: - prepare_hermes_workspace + - test_codegen - build_hermesc_linux: requires: - prepare_hermes_workspace From 4f6929bb3c4b4d8ba53fa250645b5ae4e297a1b3 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Wed, 7 Sep 2022 04:12:38 -0700 Subject: [PATCH 016/174] Bump @react-native/babel-plugin-codegen to v0.71.0 Summary: ## Change This align react-native/babel-plugin-codegen version to RN version: 0.71.0 ## Motivation We just introduced TypeScript support in this babel plugin via D39136171 (https://github.com/facebook/react-native/commit/df0b6900eca873417c867483b719e8e892a4b75d). This version bump will allow us to enable the static ViewConfig codegen in TypeScript React Native libraries, like React Native SVG. See PR: https://github.com/react-native-svg/react-native-svg/pull/1847 Changelog: [General] Bump react-native/babel-plugin-codegen to v0.71.0 Created from CodeHub with https://fburl.com/edit-in-codehub Reviewed By: cortinico Differential Revision: D39172735 fbshipit-source-id: 1d1b2c073dd6d76160979ac3c281e85f6eb4c87a --- packages/babel-plugin-codegen/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-plugin-codegen/package.json b/packages/babel-plugin-codegen/package.json index 56dc4f1d6c7ede..24a348986519b7 100644 --- a/packages/babel-plugin-codegen/package.json +++ b/packages/babel-plugin-codegen/package.json @@ -1,5 +1,5 @@ { - "version": "0.0.6", + "version": "0.71.0", "name": "@react-native/babel-plugin-codegen", "description": "Babel plugin to generate native module and view manager code for React Native.", "repository": { From 1f13811ff3b134f858eabf741d3ce7ad34b01e63 Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Wed, 7 Sep 2022 08:16:10 -0700 Subject: [PATCH 017/174] Add `setPosition` accepting `Dimension` Summary: Changelog: [Internal][Added] - Add `setPosition` accepting `Dimension` in Yoga 2 Reviewed By: Andrey-Mishanin Differential Revision: D39271414 fbshipit-source-id: af860078dec3db986d8357e4cf9ba867ba1e0532 --- ReactCommon/flexlayout/flexlayout/FlexItemStyle.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ReactCommon/flexlayout/flexlayout/FlexItemStyle.h b/ReactCommon/flexlayout/flexlayout/FlexItemStyle.h index 1a7068e6025bb4..11f02d76de6209 100644 --- a/ReactCommon/flexlayout/flexlayout/FlexItemStyle.h +++ b/ReactCommon/flexlayout/flexlayout/FlexItemStyle.h @@ -152,6 +152,10 @@ class FLEX_LAYOUT_EXPORT FlexItemStyleBase { return position[static_cast(edge)]; } + void setPosition(Edge edge, Dimension dimension) { + position[static_cast(edge)] = dimension; + } + void setPosition(Edge edge, Float value) { position[static_cast(edge)] = Dimension(value, Unit::Point); } From ebdb23c6e060897112b060c25172135d50c78cd3 Mon Sep 17 00:00:00 2001 From: Gabriel Donadel Dall'Agnol Date: Wed, 7 Sep 2022 08:38:25 -0700 Subject: [PATCH 018/174] feat: Add aria-hidden prop to Pressable, View and Touchables components (#34552) Summary: This adds the ` aria-hidden` prop to `Pressable`, `TouchableBounce`, `TouchableHighlight`, `TouchableNativeFeedback`, `TouchableOpacity`, `TouchableWithoutFeedback` and `View` components as requested on https://github.com/facebook/react-native/issues/34424, being an alias `importantforAccessibility='no-hide-descendants'` on Android and an alias for `accessibilityElementsHidden` on iOS. This PR also updates RNTester AccessibilityExample in order to facilitate the manual QA. ## Changelog [General] [Added] - Add aria-hidden prop to Pressable, View and Touchables components Pull Request resolved: https://github.com/facebook/react-native/pull/34552 Test Plan: 1. Open the RNTester app and navigate to the Accessibility page 2. Test the `aria-hidden` prop through the `View with hidden children from accessibility tree` section, this can be tested either by enabling Voice Over if you're using a real device or through the Accessibility Inspector if you're using a simulator https://user-images.githubusercontent.com/11707729/187814455-6937e33e-7edd-434e-b7d3-ee6c03f635ca.mov Reviewed By: NickGerleman Differential Revision: D39206245 Pulled By: jacdebug fbshipit-source-id: 551dc671fbcedc824f253e22b8d7753c466838c7 --- Libraries/Components/Pressable/Pressable.js | 5 +++++ .../Components/Touchable/TouchableBounce.js | 10 ++++++++-- .../Components/Touchable/TouchableHighlight.js | 10 ++++++++-- .../Touchable/TouchableNativeFeedback.js | 8 ++++++-- .../Components/Touchable/TouchableOpacity.js | 10 ++++++++-- .../Touchable/TouchableWithoutFeedback.js | 10 ++++++++-- Libraries/Components/View/View.js | 17 ++++++++++++++--- Libraries/Components/View/ViewPropTypes.js | 8 ++++++++ .../Accessibility/AccessibilityExample.js | 8 ++++++++ 9 files changed, 73 insertions(+), 13 deletions(-) diff --git a/Libraries/Components/Pressable/Pressable.js b/Libraries/Components/Pressable/Pressable.js index aab4f21d33ed89..992378df706985 100644 --- a/Libraries/Components/Pressable/Pressable.js +++ b/Libraries/Components/Pressable/Pressable.js @@ -52,6 +52,11 @@ type Props = $ReadOnly<{| accessibilityValue?: ?AccessibilityValue, accessibilityViewIsModal?: ?boolean, accessible?: ?boolean, + /** + * A value indicating whether the accessibility elements contained within + * this accessibility element are hidden. + */ + 'aria-hidden'?: ?boolean, focusable?: ?boolean, importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, diff --git a/Libraries/Components/Touchable/TouchableBounce.js b/Libraries/Components/Touchable/TouchableBounce.js index f77ab0f5738fcf..62a7820d68d7e2 100644 --- a/Libraries/Components/Touchable/TouchableBounce.js +++ b/Libraries/Components/Touchable/TouchableBounce.js @@ -143,10 +143,16 @@ class TouchableBounce extends React.Component { accessibilityActions={this.props.accessibilityActions} onAccessibilityAction={this.props.onAccessibilityAction} accessibilityValue={this.props.accessibilityValue} - importantForAccessibility={this.props.importantForAccessibility} + importantForAccessibility={ + this.props['aria-hidden'] === true + ? 'no-hide-descendants' + : this.props.importantForAccessibility + } accessibilityLiveRegion={this.props.accessibilityLiveRegion} accessibilityViewIsModal={this.props.accessibilityViewIsModal} - accessibilityElementsHidden={this.props.accessibilityElementsHidden} + accessibilityElementsHidden={ + this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden + } nativeID={this.props.nativeID} testID={this.props.testID} hitSlop={this.props.hitSlop} diff --git a/Libraries/Components/Touchable/TouchableHighlight.js b/Libraries/Components/Touchable/TouchableHighlight.js index d41513b189b55d..9bda74f946a4ea 100644 --- a/Libraries/Components/Touchable/TouchableHighlight.js +++ b/Libraries/Components/Touchable/TouchableHighlight.js @@ -302,10 +302,16 @@ class TouchableHighlight extends React.Component { accessibilityValue={this.props.accessibilityValue} accessibilityActions={this.props.accessibilityActions} onAccessibilityAction={this.props.onAccessibilityAction} - importantForAccessibility={this.props.importantForAccessibility} + importantForAccessibility={ + this.props['aria-hidden'] === true + ? 'no-hide-descendants' + : this.props.importantForAccessibility + } accessibilityLiveRegion={this.props.accessibilityLiveRegion} accessibilityViewIsModal={this.props.accessibilityViewIsModal} - accessibilityElementsHidden={this.props.accessibilityElementsHidden} + accessibilityElementsHidden={ + this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden + } style={StyleSheet.compose( this.props.style, this.state.extraStyles?.underlay, diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.js b/Libraries/Components/Touchable/TouchableNativeFeedback.js index 8fff2f302397f2..3b6de69fb9991f 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.js @@ -278,10 +278,14 @@ class TouchableNativeFeedback extends React.Component { accessibilityActions: this.props.accessibilityActions, onAccessibilityAction: this.props.onAccessibilityAction, accessibilityValue: this.props.accessibilityValue, - importantForAccessibility: this.props.importantForAccessibility, + importantForAccessibility: + this.props['aria-hidden'] === true + ? 'no-hide-descendants' + : this.props.importantForAccessibility, accessibilityLiveRegion: this.props.accessibilityLiveRegion, accessibilityViewIsModal: this.props.accessibilityViewIsModal, - accessibilityElementsHidden: this.props.accessibilityElementsHidden, + accessibilityElementsHidden: + this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden, hasTVPreferredFocus: this.props.hasTVPreferredFocus, hitSlop: this.props.hitSlop, focusable: diff --git a/Libraries/Components/Touchable/TouchableOpacity.js b/Libraries/Components/Touchable/TouchableOpacity.js index 67e18c06d54c83..936caceaf16bf7 100644 --- a/Libraries/Components/Touchable/TouchableOpacity.js +++ b/Libraries/Components/Touchable/TouchableOpacity.js @@ -231,10 +231,16 @@ class TouchableOpacity extends React.Component { accessibilityActions={this.props.accessibilityActions} onAccessibilityAction={this.props.onAccessibilityAction} accessibilityValue={this.props.accessibilityValue} - importantForAccessibility={this.props.importantForAccessibility} + importantForAccessibility={ + this.props['aria-hidden'] === true + ? 'no-hide-descendants' + : this.props.importantForAccessibility + } accessibilityLiveRegion={this.props.accessibilityLiveRegion} accessibilityViewIsModal={this.props.accessibilityViewIsModal} - accessibilityElementsHidden={this.props.accessibilityElementsHidden} + accessibilityElementsHidden={ + this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden + } style={[this.props.style, {opacity: this.state.anim}]} nativeID={this.props.nativeID} testID={this.props.testID} diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index 2b3bd4b930e14b..f260f2cc9d7334 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -42,6 +42,7 @@ type Props = $ReadOnly<{| accessibilityValue?: ?AccessibilityValue, accessibilityViewIsModal?: ?boolean, accessible?: ?boolean, + 'aria-hidden'?: ?boolean, children?: ?React.Node, delayLongPress?: ?number, delayPressIn?: ?number, @@ -71,7 +72,6 @@ type State = $ReadOnly<{| const PASSTHROUGH_PROPS = [ 'accessibilityActions', - 'accessibilityElementsHidden', 'accessibilityHint', 'accessibilityLanguage', 'accessibilityIgnoresInvertColors', @@ -81,7 +81,6 @@ const PASSTHROUGH_PROPS = [ 'accessibilityValue', 'accessibilityViewIsModal', 'hitSlop', - 'importantForAccessibility', 'nativeID', 'onAccessibilityAction', 'onBlur', @@ -123,6 +122,13 @@ class TouchableWithoutFeedback extends React.Component { : this.props.accessibilityState, focusable: this.props.focusable !== false && this.props.onPress !== undefined, + + accessibilityElementsHidden: + this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden, + importantForAccessibility: + this.props['aria-hidden'] === true + ? 'no-hide-descendants' + : this.props.importantForAccessibility, }; for (const prop of PASSTHROUGH_PROPS) { if (this.props[prop] !== undefined) { diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js index bc2145e52982e2..1de58236e720e6 100644 --- a/Libraries/Components/View/View.js +++ b/Libraries/Components/View/View.js @@ -30,12 +30,15 @@ const View: React.AbstractComponent< > = React.forwardRef( ( { - tabIndex, - focusable, - role, + accessibilityElementsHidden, accessibilityRole, + 'aria-hidden': ariaHidden, + focusable, + importantForAccessibility, pointerEvents, + role, style, + tabIndex, ...otherProps }: ViewProps, forwardedRef, @@ -118,6 +121,14 @@ const View: React.AbstractComponent< accessibilityRole={ role ? roleToAccessibilityRoleMapping[role] : accessibilityRole } + accessibilityElementsHidden={ + ariaHidden ?? accessibilityElementsHidden + } + importantForAccessibility={ + ariaHidden === true + ? 'no-hide-descendants' + : importantForAccessibility + } {...otherProps} style={style} pointerEvents={newPointerEvents} diff --git a/Libraries/Components/View/ViewPropTypes.js b/Libraries/Components/View/ViewPropTypes.js index 62faf8a0030b9b..bb0859e45e944a 100644 --- a/Libraries/Components/View/ViewPropTypes.js +++ b/Libraries/Components/View/ViewPropTypes.js @@ -491,6 +491,14 @@ export type ViewProps = $ReadOnly<{| */ accessibilityLabelledBy?: ?string | ?Array, + /** + * A value indicating whether the accessibility elements contained within + * this accessibility element are hidden. + * + * See https://reactnative.dev/docs/view#aria-hidden + */ + 'aria-hidden'?: ?boolean, + /** * Views that are only used to layout their children or otherwise don't draw * anything may be automatically removed from the native hierarchy as an diff --git a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js index 1db5bc2249f662..cc227872250c72 100644 --- a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js +++ b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js @@ -126,6 +126,14 @@ class AccessibilityExample extends React.Component<{}> { + + + + This view's children are hidden from the accessibility tree + + + + {/* Android screen readers will say the accessibility hint instead of the text since the view doesn't have a label. */} From 951538c080ef745da304fb308fa91d597e0dd98a Mon Sep 17 00:00:00 2001 From: David <4661784+retyui@users.noreply.github.com> Date: Wed, 7 Sep 2022 12:17:55 -0700 Subject: [PATCH 019/174] Add support `Promise.allSettled` out of box (#34544) Summary: Issue: https://github.com/facebook/react-native/issues/30236 ## Changelog [General] [Added] - Added support `Promise.allSettled` Pull Request resolved: https://github.com/facebook/react-native/pull/34544 Test Plan: Release notes [`promise@8.2.0`](https://github.com/then/promise/releases/tag/8.2.0) ```tsx typeof Promise.allSettled // function ``` Reviewed By: motiz88 Differential Revision: D39170057 Pulled By: jacdebug fbshipit-source-id: 72467285e1ad82510ca8fe3d5f347ec8ae286823 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b3307805f7a3e2..9f5197085a9071 100644 --- a/package.json +++ b/package.json @@ -123,7 +123,7 @@ "mkdirp": "^0.5.1", "nullthrows": "^1.1.1", "pretty-format": "^26.5.2", - "promise": "^8.0.3", + "promise": "^8.2.0", "react-devtools-core": "4.24.0", "react-native-gradle-plugin": "^0.71.0", "react-refresh": "^0.4.0", diff --git a/yarn.lock b/yarn.lock index 3a65b3a581d5ce..e9bf936c6bc360 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5841,10 +5841,10 @@ process-nextick-args@~2.0.0: resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" integrity sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw== -promise@^8.0.3: - version "8.0.3" - resolved "https://registry.yarnpkg.com/promise/-/promise-8.0.3.tgz#f592e099c6cddc000d538ee7283bb190452b0bf6" - integrity sha512-HeRDUL1RJiLhyA0/grn+PTShlBAcLuh/1BJGtrvjwbvRDCTLLMEz9rOGCV+R3vHY4MixIuoMEd9Yq/XvsTPcjw== +promise@^8.2.0: + version "8.2.0" + resolved "https://registry.yarnpkg.com/promise/-/promise-8.2.0.tgz#a1f6280ab67457fbfc8aad2b198c9497e9e5c806" + integrity sha512-+CMAlLHqwRYwBMXKCP+o8ns7DN+xHDUiI+0nArsiJ9y+kJVPLFxEaSw6Ha9s9H0tftxg2Yzl25wqj9G7m5wLZg== dependencies: asap "~2.0.6" From 34e7d48472565ec4502c56d42adc17b66c71c4bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Wed, 7 Sep 2022 12:20:58 -0700 Subject: [PATCH 020/174] Remove unused JSDevSupport module Summary: The `JSDevSupport` module is incompatible with Fabric. Given it's not used internally and it's undocumented in OSS, we decided to remove it altogether. Changelog: [Internal] Reviewed By: javache, nlutsenko Differential Revision: D39305892 fbshipit-source-id: 82455701a0b9ba83e6f971fc774280dceb2b22e0 --- Libraries/Core/setUpBatchedBridge.js | 4 - Libraries/Utilities/JSDevSupportModule.js | 37 ------- Libraries/Utilities/NativeJSDevSupport.js | 23 ---- .../react/devsupport/JSDevSupport.java | 103 ------------------ 4 files changed, 167 deletions(-) delete mode 100644 Libraries/Utilities/JSDevSupportModule.js delete mode 100644 Libraries/Utilities/NativeJSDevSupport.js delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDevSupport.java diff --git a/Libraries/Core/setUpBatchedBridge.js b/Libraries/Core/setUpBatchedBridge.js index 17ba06eb818b92..4ceff36bc50ad9 100644 --- a/Libraries/Core/setUpBatchedBridge.js +++ b/Libraries/Core/setUpBatchedBridge.js @@ -20,7 +20,6 @@ if (global.RN$Bridgeless === true && global.RN$registerCallableModule) { | $TEMPORARY$string<'GlobalPerformanceLogger'> | $TEMPORARY$string<'HMRClient'> | $TEMPORARY$string<'HeapCapture'> - | $TEMPORARY$string<'JSDevSupportModule'> | $TEMPORARY$string<'JSTimers'> | $TEMPORARY$string<'RCTDeviceEventEmitter'> | $TEMPORARY$string<'RCTLog'> @@ -52,9 +51,6 @@ registerModule('RCTNativeAppEventEmitter', () => registerModule('GlobalPerformanceLogger', () => require('../Utilities/GlobalPerformanceLogger'), ); -registerModule('JSDevSupportModule', () => - require('../Utilities/JSDevSupportModule'), -); if (__DEV__ && !global.__RCTProfileIsProfiling) { registerModule('HMRClient', () => require('../Utilities/HMRClient')); diff --git a/Libraries/Utilities/JSDevSupportModule.js b/Libraries/Utilities/JSDevSupportModule.js deleted file mode 100644 index c88df1f1dd3fc4..00000000000000 --- a/Libraries/Utilities/JSDevSupportModule.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict-local - */ - -import NativeJSDevSupport from './NativeJSDevSupport'; -const ReactNative = require('../Renderer/shims/ReactNative'); - -const JSDevSupportModule = { - getJSHierarchy: function (tag: number) { - if (NativeJSDevSupport) { - const constants = NativeJSDevSupport.getConstants(); - try { - const {computeComponentStackForErrorReporting} = - ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - const componentStack = computeComponentStackForErrorReporting(tag); - if (!componentStack) { - NativeJSDevSupport.onFailure( - constants.ERROR_CODE_VIEW_NOT_FOUND, - "Component stack doesn't exist for tag " + tag, - ); - } else { - NativeJSDevSupport.onSuccess(componentStack); - } - } catch (e) { - NativeJSDevSupport.onFailure(constants.ERROR_CODE_EXCEPTION, e.message); - } - } - }, -}; - -module.exports = JSDevSupportModule; diff --git a/Libraries/Utilities/NativeJSDevSupport.js b/Libraries/Utilities/NativeJSDevSupport.js deleted file mode 100644 index 59347258888327..00000000000000 --- a/Libraries/Utilities/NativeJSDevSupport.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict - * @format - */ - -import type {TurboModule} from '../TurboModule/RCTExport'; -import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry'; - -export interface Spec extends TurboModule { - +getConstants: () => {| - ERROR_CODE_EXCEPTION: number, - ERROR_CODE_VIEW_NOT_FOUND: number, - |}; - +onSuccess: (data: string) => void; - +onFailure: (errorCode: number, error: string) => void; -} - -export default (TurboModuleRegistry.get('JSDevSupport'): ?Spec); diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDevSupport.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDevSupport.java deleted file mode 100644 index 4ea6a82c7c9849..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDevSupport.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.devsupport; - -import android.util.Pair; -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.fbreact.specs.NativeJSDevSupportSpec; -import com.facebook.react.bridge.JavaScriptModule; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.module.annotations.ReactModule; -import java.util.HashMap; -import java.util.Map; - -@ReactModule(name = JSDevSupport.MODULE_NAME) -public class JSDevSupport extends NativeJSDevSupportSpec { - public static final String MODULE_NAME = "JSDevSupport"; - - public static final int ERROR_CODE_EXCEPTION = 0; - public static final int ERROR_CODE_VIEW_NOT_FOUND = 1; - - @Nullable private volatile DevSupportCallback mCurrentCallback = null; - - public interface JSDevSupportModule extends JavaScriptModule { - void getJSHierarchy(int reactTag); - } - - public JSDevSupport(ReactApplicationContext reactContext) { - super(reactContext); - } - - public interface DevSupportCallback { - - void onSuccess(String data); - - void onFailure(int errorCode, Exception error); - } - - /** - * Notifies the callback with either the JS hierarchy of the deepest leaf from the given root view - * or with an error. - */ - public synchronized void computeDeepestJSHierarchy(View root, DevSupportCallback callback) { - final Pair deepestPairView = ViewHierarchyUtil.getDeepestLeaf(root); - View deepestView = deepestPairView.first; - Integer tagId = deepestView.getId(); - getJSHierarchy(tagId, callback); - } - - public synchronized void getJSHierarchy(int reactTag, DevSupportCallback callback) { - ReactApplicationContext reactApplicationContext = getReactApplicationContextIfActiveOrWarn(); - - JSDevSupportModule jsDevSupportModule = null; - if (reactApplicationContext != null) { - jsDevSupportModule = reactApplicationContext.getJSModule(JSDevSupportModule.class); - } - - if (jsDevSupportModule == null) { - callback.onFailure( - ERROR_CODE_EXCEPTION, - new JSCHeapCapture.CaptureException(MODULE_NAME + " module not registered.")); - return; - } - mCurrentCallback = callback; - jsDevSupportModule.getJSHierarchy(reactTag); - } - - @SuppressWarnings("unused") - @Override - public synchronized void onSuccess(String data) { - if (mCurrentCallback != null) { - mCurrentCallback.onSuccess(data); - } - } - - @SuppressWarnings("unused") - @Override - public synchronized void onFailure(double errorCodeDouble, String error) { - int errorCode = (int) errorCodeDouble; - - if (mCurrentCallback != null) { - mCurrentCallback.onFailure(errorCode, new RuntimeException(error)); - } - } - - @Override - public Map getTypedExportedConstants() { - HashMap constants = new HashMap<>(); - constants.put("ERROR_CODE_EXCEPTION", ERROR_CODE_EXCEPTION); - constants.put("ERROR_CODE_VIEW_NOT_FOUND", ERROR_CODE_VIEW_NOT_FOUND); - return constants; - } - - @Override - public String getName() { - return MODULE_NAME; - } -} From ac1fe3b7eb8e16f5feddeeac846ff70080dc119e Mon Sep 17 00:00:00 2001 From: Gabriel Donadel Dall'Agnol Date: Wed, 7 Sep 2022 12:41:09 -0700 Subject: [PATCH 021/174] feat: Add expanded support for CSS Colors (#34600) Summary: ## Summary This PR adds expanded support for CSS Colors, as requested on https://github.com/facebook/react-native/issues/34425. It updates the current regex used to match the functional notation for colors, e.g `rgb()` to accept space as a valid separator between values as specified on [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/) definition. This also adds support for the `hwb` notation. ## Changelog [General] [Added] - Add expanded support for CSS Colors Pull Request resolved: https://github.com/facebook/react-native/pull/34600 Test Plan: We can test different color scenarios through the new test cases added to the already existing normalizeColor-test.js Reviewed By: necolas Differential Revision: D39269360 Pulled By: cipolleschi fbshipit-source-id: 449158d17256bbab8bd9fd0da29245660225fb92 --- .../__tests__/normalizeColor-test.js | 25 +++++ packages/normalize-color/index.js | 101 ++++++++++++++++-- 2 files changed, 117 insertions(+), 9 deletions(-) diff --git a/packages/normalize-color/__tests__/normalizeColor-test.js b/packages/normalize-color/__tests__/normalizeColor-test.js index 257ae1db0cbcfd..6f50aa62490fc9 100644 --- a/packages/normalize-color/__tests__/normalizeColor-test.js +++ b/packages/normalize-color/__tests__/normalizeColor-test.js @@ -19,6 +19,7 @@ it('accepts only spec compliant colors', () => { expect(normalizeColor('#abcdef')).not.toBe(null); expect(normalizeColor('#abcdef01')).not.toBe(null); expect(normalizeColor('rgb(1,2,3)')).not.toBe(null); + expect(normalizeColor('rgb(1 2 3)')).not.toBe(null); expect(normalizeColor('rgb(1, 2, 3)')).not.toBe(null); expect(normalizeColor('rgb( 1 , 2 , 3 )')).not.toBe(null); expect(normalizeColor('rgb(-1, -2, -3)')).not.toBe(null); @@ -45,6 +46,7 @@ it('refuses non-spec compliant colors', () => { expect(normalizeColor('rgb 255 0 0')).toBe(null); expect(normalizeColor('RGBA(0, 1, 2)')).toBe(null); expect(normalizeColor('rgb (0, 1, 2)')).toBe(null); + expect(normalizeColor('rgba(0 0 0 0.0)')).toBe(null); expect(normalizeColor('hsv(0, 1, 2)')).toBe(null); // $FlowExpectedError - Intentionally malformed argument. expect(normalizeColor({r: 10, g: 10, b: 10})).toBe(null); @@ -81,6 +83,8 @@ it('handles rgb properly', () => { expect(normalizeColor('rgb(100, 15, 69)')).toBe(0x640f45ff); expect(normalizeColor('rgb(255, 255, 255)')).toBe(0xffffffff); expect(normalizeColor('rgb(256, 256, 256)')).toBe(0xffffffff); + expect(normalizeColor('rgb(0 0 0)')).toBe(0x000000ff); + expect(normalizeColor('rgb(0 0 255)')).toBe(0x0000ffff); }); it('handles rgba properly', () => { @@ -91,6 +95,9 @@ it('handles rgba properly', () => { expect(normalizeColor('rgba(0, 0, 0, 1)')).toBe(0x000000ff); expect(normalizeColor('rgba(0, 0, 0, 1.5)')).toBe(0x000000ff); expect(normalizeColor('rgba(100, 15, 69, 0.5)')).toBe(0x640f4580); + expect(normalizeColor('rgba(0 0 0 / 0.0)')).toBe(0x00000000); + expect(normalizeColor('rgba(0 0 0 / 1)')).toBe(0x000000ff); + expect(normalizeColor('rgba(100 15 69 / 0.5)')).toBe(0x640f4580); }); it('handles hsl properly', () => { @@ -103,6 +110,9 @@ it('handles hsl properly', () => { expect(normalizeColor('hsl(70, 110%, 75%)')).toBe(0xeaff80ff); expect(normalizeColor('hsl(70, 0%, 75%)')).toBe(0xbfbfbfff); expect(normalizeColor('hsl(70, -10%, 75%)')).toBe(0xbfbfbfff); + expect(normalizeColor('hsl(0 0% 0%)')).toBe(0x000000ff); + expect(normalizeColor('hsl(360 100% 100%)')).toBe(0xffffffff); + expect(normalizeColor('hsl(180 50% 50%)')).toBe(0x40bfbfff); }); it('handles hsla properly', () => { @@ -110,6 +120,21 @@ it('handles hsla properly', () => { expect(normalizeColor('hsla(360, 100%, 100%, 1)')).toBe(0xffffffff); expect(normalizeColor('hsla(360, 100%, 100%, 0)')).toBe(0xffffff00); expect(normalizeColor('hsla(180, 50%, 50%, 0.2)')).toBe(0x40bfbf33); + expect(normalizeColor('hsla(0 0% 0% / 0)')).toBe(0x00000000); + expect(normalizeColor('hsla(360 100% 100% / 1)')).toBe(0xffffffff); + expect(normalizeColor('hsla(360 100% 100% / 0)')).toBe(0xffffff00); + expect(normalizeColor('hsla(180 50% 50% / 0.2)')).toBe(0x40bfbf33); +}); + +it('handles hwb properly', () => { + expect(normalizeColor('hwb(0, 0%, 100%)')).toBe(0x000000ff); + expect(normalizeColor('hwb(0, 100%, 0%)')).toBe(0xffffffff); + expect(normalizeColor('hwb(0, 0%, 0%)')).toBe(0xff0000ff); + expect(normalizeColor('hwb(70, 50%, 0%)')).toBe(0xeaff80ff); + expect(normalizeColor('hwb(0, 50%, 50%)')).toBe(0x808080ff); + expect(normalizeColor('hwb(360, 100%, 100%)')).toBe(0x808080ff); + expect(normalizeColor('hwb(0 0% 0%)')).toBe(0xff0000ff); + expect(normalizeColor('hwb(70 50% 0%)')).toBe(0xeaff80ff); }); it('handles named colors properly', () => { diff --git a/packages/normalize-color/index.js b/packages/normalize-color/index.js index a20b1c3486d43f..611baaffc13891 100644 --- a/packages/normalize-color/index.js +++ b/packages/normalize-color/index.js @@ -48,11 +48,23 @@ function normalizeColor(color) { } if ((match = matchers.rgba.exec(color))) { + // rgba(R G B / A) notation + if (match[6] !== undefined) { + return ( + ((parse255(match[6]) << 24) | // r + (parse255(match[7]) << 16) | // g + (parse255(match[8]) << 8) | // b + parse1(match[9])) >>> // a + 0 + ); + } + + // rgba(R, G, B, A) notation return ( - ((parse255(match[1]) << 24) | // r - (parse255(match[2]) << 16) | // g - (parse255(match[3]) << 8) | // b - parse1(match[4])) >>> // a + ((parse255(match[2]) << 24) | // r + (parse255(match[3]) << 16) | // g + (parse255(match[4]) << 8) | // b + parse1(match[5])) >>> // a 0 ); } @@ -106,13 +118,39 @@ function normalizeColor(color) { } if ((match = matchers.hsla.exec(color))) { + // hsla(H S L / A) notation + if (match[6] !== undefined) { + return ( + (hslToRgb( + parse360(match[6]), // h + parsePercentage(match[7]), // s + parsePercentage(match[8]), // l + ) | + parse1(match[9])) >>> // a + 0 + ); + } + + // hsla(H, S, L, A) notation return ( (hslToRgb( + parse360(match[2]), // h + parsePercentage(match[3]), // s + parsePercentage(match[4]), // l + ) | + parse1(match[5])) >>> // a + 0 + ); + } + + if ((match = matchers.hwb.exec(color))) { + return ( + (hwbToRgb( parse360(match[1]), // h - parsePercentage(match[2]), // s - parsePercentage(match[3]), // l + parsePercentage(match[2]), // w + parsePercentage(match[3]), // b ) | - parse1(match[4])) >>> // a + 0x000000ff) >>> // a 0 ); } @@ -153,10 +191,42 @@ function hslToRgb(h, s, l) { ); } +function hwbToRgb(h, w, b) { + if (w + b >= 1) { + const gray = Math.round((w * 255) / (w + b)); + + return (gray << 24) | (gray << 16) | (gray << 8); + } + + const red = hue2rgb(0, 1, h + 1 / 3) * (1 - w - b) + w; + const green = hue2rgb(0, 1, h) * (1 - w - b) + w; + const blue = hue2rgb(0, 1, h - 1 / 3) * (1 - w - b) + w; + + return ( + (Math.round(red * 255) << 24) | + (Math.round(green * 255) << 16) | + (Math.round(blue * 255) << 8) + ); +} + const NUMBER = '[-+]?\\d*\\.?\\d+'; const PERCENTAGE = NUMBER + '%'; function call(...args) { + return '\\(\\s*(' + args.join(')\\s*,?\\s*(') + ')\\s*\\)'; +} + +function callWithSlashSeparator(...args) { + return ( + '\\(\\s*(' + + args.slice(0, args.length - 1).join(')\\s*,?\\s*(') + + ')\\s*/\\s*(' + + args[args.length - 1] + + ')\\s*\\)' + ); +} + +function commaSeparatedCall(...args) { return '\\(\\s*(' + args.join(')\\s*,\\s*(') + ')\\s*\\)'; } @@ -166,9 +236,22 @@ function getMatchers() { if (cachedMatchers === undefined) { cachedMatchers = { rgb: new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER)), - rgba: new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER)), + rgba: new RegExp( + 'rgba(' + + commaSeparatedCall(NUMBER, NUMBER, NUMBER, NUMBER) + + '|' + + callWithSlashSeparator(NUMBER, NUMBER, NUMBER, NUMBER) + + ')', + ), hsl: new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE)), - hsla: new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)), + hsla: new RegExp( + 'hsla(' + + commaSeparatedCall(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER) + + '|' + + callWithSlashSeparator(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER) + + ')', + ), + hwb: new RegExp('hwb' + call(NUMBER, PERCENTAGE, PERCENTAGE)), hex3: /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex4: /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex6: /^#([0-9a-fA-F]{6})$/, From 32d12e89f864a106433c8e54c10691d7876333ee Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Wed, 7 Sep 2022 12:52:37 -0700 Subject: [PATCH 022/174] add debugging settings (#34489) Summary: For brownfield apps, it is possible to have multiple hermes runtimes serving different JS bundles. Hermes inspector currently only supports single JS bundle. The latest loaded JS bundle will overwrite previous JS bundle. This is because we always use the ["Hermes React Native" as the inspector page name](https://github.com/facebook/react-native/blob/de75a7a22eebbe6b7106377bdd697a2d779b91b0/ReactCommon/hermes/executor/HermesExecutorFactory.cpp#L157) and [the latest page name will overwrite previous one](https://github.com/facebook/react-native/blob/de75a7a22eebbe6b7106377bdd697a2d779b91b0/ReactCommon/hermes/inspector/chrome/ConnectionDemux.cpp#L77-L86). This PR adds more customization for HermesExecutorFactory: - `setEnableDebugger`: provide a way to disable debugging features for the hermes runtime - `setDebuggerName`: provide a way to customize inspector page name other than the default "Hermes React Native" ## Changelog [General] [Added] - Add more debugging settings for *HermesExecutorFactory* Pull Request resolved: https://github.com/facebook/react-native/pull/34489 Test Plan: Verify the features by RNTester. 1. `setEnableDebugger` ```diff --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java @@ -10,10 +10,12 @@ package com.facebook.react.uiapp; import android.app.Application; import androidx.annotation.NonNull; import com.facebook.fbreact.specs.SampleTurboModule; +import com.facebook.hermes.reactexecutor.HermesExecutorFactory; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.TurboReactPackage; +import com.facebook.react.bridge.JavaScriptExecutorFactory; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.config.ReactFeatureFlags; @@ -50,6 +52,13 @@ public class RNTesterApplication extends Application implements ReactApplication return BuildConfig.DEBUG; } + Override + protected JavaScriptExecutorFactory getJavaScriptExecutorFactory() { + HermesExecutorFactory factory = new HermesExecutorFactory(); + factory.setEnableDebugger(false); + return factory; + } + Override public List getPackages() { return Arrays.asList( ``` after app launched, the metro inspector should return empty array. Run `curl http://localhost:8081/json` and returns `[]` 2. `setDebuggerName` ```diff --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java @@ -10,10 +10,12 @@ package com.facebook.react.uiapp; import android.app.Application; import androidx.annotation.NonNull; import com.facebook.fbreact.specs.SampleTurboModule; +import com.facebook.hermes.reactexecutor.HermesExecutorFactory; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.TurboReactPackage; +import com.facebook.react.bridge.JavaScriptExecutorFactory; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.config.ReactFeatureFlags; @@ -50,6 +52,13 @@ public class RNTesterApplication extends Application implements ReactApplication return BuildConfig.DEBUG; } + Override + protected JavaScriptExecutorFactory getJavaScriptExecutorFactory() { + HermesExecutorFactory factory = new HermesExecutorFactory(); + factory.setDebuggerName("Custom Hermes Debugger"); + return factory; + } + Override public List getPackages() { return Arrays.asList( ``` after app launched, the metro inspector should return an entry with *Custom Hermes Debugger* Run `curl http://localhost:8081/json` and returns ```json [ { "id": "2-1", "description": "com.facebook.react.uiapp", "title": "Custom Hermes Debugger", "faviconUrl": "https://reactjs.org/favicon.ico", "devtoolsFrontendUrl": "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=%5B%3A%3A1%5D%3A8081%2Finspector%2Fdebug%3Fdevice%3D2 (https://github.com/facebook/react-native/commit/e5c5dcd9e26e9443f59864d9763b049e0bda98e7)%26page%3D1 (https://github.com/facebook/react-native/commit/ea93151f21003df6f65dd173dd5dcb3135b0ae94)", "type": "node", "webSocketDebuggerUrl": "ws://[::1]:8081/inspector/debug?device=2&page=1", "vm": "Hermes" } ] ``` Reviewed By: mdvacca Differential Revision: D38982104 Pulled By: cipolleschi fbshipit-source-id: 78003c173db55448a751145986985b3e1d1c71bb --- .../hermes/reactexecutor/HermesExecutor.java | 13 ++++--- .../reactexecutor/HermesExecutorFactory.java | 12 ++++++- .../jni/react/hermes/reactexecutor/OnLoad.cpp | 23 +++++++++--- .../hermes/executor/HermesExecutorFactory.cpp | 35 +++++++++++++++---- .../hermes/executor/HermesExecutorFactory.h | 6 ++++ 5 files changed, 72 insertions(+), 17 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java index a9a474510fbe16..48eaaa4c0668ba 100644 --- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java +++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java @@ -33,8 +33,11 @@ public static void loadLibrary() throws UnsatisfiedLinkError { } } - HermesExecutor(@Nullable RuntimeConfig config) { - super(config == null ? initHybridDefaultConfig() : initHybrid(config.heapSizeMB)); + HermesExecutor(@Nullable RuntimeConfig config, boolean enableDebugger, String debuggerName) { + super( + config == null + ? initHybridDefaultConfig(enableDebugger, debuggerName) + : initHybrid(enableDebugger, debuggerName, config.heapSizeMB)); } @Override @@ -51,7 +54,9 @@ public String getName() { */ public static native boolean canLoadFile(String path); - private static native HybridData initHybridDefaultConfig(); + private static native HybridData initHybridDefaultConfig( + boolean enableDebugger, String debuggerName); - private static native HybridData initHybrid(long heapSizeMB); + private static native HybridData initHybrid( + boolean enableDebugger, String debuggerName, long heapSizeMB); } diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java index 944afe6b64568d..a51d5825a26880 100644 --- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java +++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java @@ -15,6 +15,8 @@ public class HermesExecutorFactory implements JavaScriptExecutorFactory { private static final String TAG = "Hermes"; private final RuntimeConfig mConfig; + private boolean mEnableDebugger = true; + private String mDebuggerName = ""; public HermesExecutorFactory() { this(null); @@ -24,9 +26,17 @@ public HermesExecutorFactory(RuntimeConfig config) { mConfig = config; } + public void setEnableDebugger(boolean enableDebugger) { + mEnableDebugger = enableDebugger; + } + + public void setDebuggerName(String debuggerName) { + mDebuggerName = debuggerName; + } + @Override public JavaScriptExecutor create() { - return new HermesExecutor(mConfig); + return new HermesExecutor(mConfig, mEnableDebugger, mDebuggerName); } @Override diff --git a/ReactAndroid/src/main/jni/react/hermes/reactexecutor/OnLoad.cpp b/ReactAndroid/src/main/jni/react/hermes/reactexecutor/OnLoad.cpp index 304603fd12e1ba..2a102d5d265542 100644 --- a/ReactAndroid/src/main/jni/react/hermes/reactexecutor/OnLoad.cpp +++ b/ReactAndroid/src/main/jni/react/hermes/reactexecutor/OnLoad.cpp @@ -69,26 +69,39 @@ class HermesExecutorHolder "Lcom/facebook/hermes/reactexecutor/HermesExecutor;"; static jni::local_ref initHybridDefaultConfig( - jni::alias_ref) { + jni::alias_ref, + bool enableDebugger, + std::string debuggerName) { JReactMarker::setLogPerfMarkerIfNeeded(); std::call_once(flag, []() { facebook::hermes::HermesRuntime::setFatalHandler(hermesFatalHandler); }); - return makeCxxInstance( - std::make_unique(installBindings)); + auto factory = std::make_unique(installBindings); + factory->setEnableDebugger(enableDebugger); + if (!debuggerName.empty()) { + factory->setDebuggerName(debuggerName); + } + return makeCxxInstance(std::move(factory)); } static jni::local_ref initHybrid( jni::alias_ref, + bool enableDebugger, + std::string debuggerName, jlong heapSizeMB) { JReactMarker::setLogPerfMarkerIfNeeded(); auto runtimeConfig = makeRuntimeConfig(heapSizeMB); std::call_once(flag, []() { facebook::hermes::HermesRuntime::setFatalHandler(hermesFatalHandler); }); - return makeCxxInstance(std::make_unique( - installBindings, JSIExecutor::defaultTimeoutInvoker, runtimeConfig)); + auto factory = std::make_unique( + installBindings, JSIExecutor::defaultTimeoutInvoker, runtimeConfig); + factory->setEnableDebugger(enableDebugger); + if (!debuggerName.empty()) { + factory->setDebuggerName(debuggerName); + } + return makeCxxInstance(std::move(factory)); } static bool canLoadFile(jni::alias_ref, const std::string &path) { diff --git a/ReactCommon/hermes/executor/HermesExecutorFactory.cpp b/ReactCommon/hermes/executor/HermesExecutorFactory.cpp index e1626d4f20ccc5..500eac9340a6fb 100644 --- a/ReactCommon/hermes/executor/HermesExecutorFactory.cpp +++ b/ReactCommon/hermes/executor/HermesExecutorFactory.cpp @@ -147,20 +147,28 @@ class DecoratedRuntime : public jsi::WithRuntimeDecorator { DecoratedRuntime( std::unique_ptr runtime, HermesRuntime &hermesRuntime, - std::shared_ptr jsQueue) + std::shared_ptr jsQueue, + bool enableDebugger, + const std::string &debuggerName) : jsi::WithRuntimeDecorator(*runtime, reentrancyCheck_), runtime_(std::move(runtime)) { #ifdef HERMES_ENABLE_DEBUGGER - std::shared_ptr rt(runtime_, &hermesRuntime); - auto adapter = std::make_unique(rt, jsQueue); - debugToken_ = facebook::hermes::inspector::chrome::enableDebugging( - std::move(adapter), "Hermes React Native"); + enableDebugger_ = enableDebugger; + if (enableDebugger_) { + std::shared_ptr rt(runtime_, &hermesRuntime); + auto adapter = + std::make_unique(rt, jsQueue); + debugToken_ = facebook::hermes::inspector::chrome::enableDebugging( + std::move(adapter), debuggerName); + } #endif } ~DecoratedRuntime() { #ifdef HERMES_ENABLE_DEBUGGER - facebook::hermes::inspector::chrome::disableDebugging(debugToken_); + if (enableDebugger_) { + facebook::hermes::inspector::chrome::disableDebugging(debugToken_); + } #endif } @@ -175,12 +183,21 @@ class DecoratedRuntime : public jsi::WithRuntimeDecorator { std::shared_ptr runtime_; ReentrancyCheck reentrancyCheck_; #ifdef HERMES_ENABLE_DEBUGGER + bool enableDebugger_; facebook::hermes::inspector::chrome::DebugSessionToken debugToken_; #endif }; } // namespace +void HermesExecutorFactory::setEnableDebugger(bool enableDebugger) { + enableDebugger_ = enableDebugger; +} + +void HermesExecutorFactory::setDebuggerName(const std::string &debuggerName) { + debuggerName_ = debuggerName; +} + std::unique_ptr HermesExecutorFactory::createJSExecutor( std::shared_ptr delegate, std::shared_ptr jsQueue) { @@ -188,7 +205,11 @@ std::unique_ptr HermesExecutorFactory::createJSExecutor( makeHermesRuntimeSystraced(runtimeConfig_); HermesRuntime &hermesRuntimeRef = *hermesRuntime; auto decoratedRuntime = std::make_shared( - std::move(hermesRuntime), hermesRuntimeRef, jsQueue); + std::move(hermesRuntime), + hermesRuntimeRef, + jsQueue, + enableDebugger_, + debuggerName_); // So what do we have now? // DecoratedRuntime -> HermesRuntime diff --git a/ReactCommon/hermes/executor/HermesExecutorFactory.h b/ReactCommon/hermes/executor/HermesExecutorFactory.h index d06323ec7d4ebf..d0d5352ba5450e 100644 --- a/ReactCommon/hermes/executor/HermesExecutorFactory.h +++ b/ReactCommon/hermes/executor/HermesExecutorFactory.h @@ -28,6 +28,10 @@ class HermesExecutorFactory : public JSExecutorFactory { assert(timeoutInvoker_ && "Should not have empty timeoutInvoker"); } + void setEnableDebugger(bool enableDebugger); + + void setDebuggerName(const std::string &debuggerName); + std::unique_ptr createJSExecutor( std::shared_ptr delegate, std::shared_ptr jsQueue) override; @@ -38,6 +42,8 @@ class HermesExecutorFactory : public JSExecutorFactory { JSIExecutor::RuntimeInstaller runtimeInstaller_; JSIScopedTimeoutInvoker timeoutInvoker_; ::hermes::vm::RuntimeConfig runtimeConfig_; + bool enableDebugger_ = true; + std::string debuggerName_ = "Hermes React Native"; }; class HermesExecutor : public JSIExecutor { From 47a05bc26ab76add640183c1d9d8cbba39d7d0d2 Mon Sep 17 00:00:00 2001 From: dhruvtailor7 Date: Wed, 7 Sep 2022 13:13:08 -0700 Subject: [PATCH 023/174] feat: added `crossOrigin`, `referrerPolicy`, `srcSet`, `width`, `height` and `src` props to the Image Component. (#34481) Summary: This PR is for adding the support for `crossOrigin`, `referrerPolicy`, `width`, `height` and `srcSet` props to Image Component and mapping the `src` prop to `source.uri` of Image Component for the issue https://github.com/facebook/react-native/issues/34424. An example is also added in the RNTester ImageExample. ## Changelog [General] [Changed] - Map the `src` prop to `source.uri` prop in Image Component. [General] [Added] - added `crossOrigin`, `referrerPolicy`, `width`, `height` and `srcSet` props to Image Component. Pull Request resolved: https://github.com/facebook/react-native/pull/34481 Test Plan: 1. Navigate to Image Component Example in the RNTester app. 2. Contains an example of the Image component using the `src` and `srcSet` prop. 3. For headers, inspect the Image request using Flipper. Reviewed By: christophpurrer Differential Revision: D38982041 Pulled By: cipolleschi fbshipit-source-id: dd6594e39b8f3b36cfcdafa35695254034f1fb7f --- Libraries/Image/Image.android.js | 30 ++-- Libraries/Image/Image.ios.js | 15 +- Libraries/Image/ImageProps.js | 55 ++++++- Libraries/Image/ImageSourceUtils.js | 80 ++++++++++ .../Image/__tests__/ImageSourceUtils-test.js | 145 ++++++++++++++++++ .../js/examples/Image/ImageExample.js | 28 +++- 6 files changed, 323 insertions(+), 30 deletions(-) create mode 100644 Libraries/Image/ImageSourceUtils.js create mode 100644 Libraries/Image/__tests__/ImageSourceUtils-test.js diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index eac8a56c63eba7..4c9605514eda41 100644 --- a/Libraries/Image/Image.android.js +++ b/Libraries/Image/Image.android.js @@ -23,6 +23,7 @@ import TextInlineImageNativeComponent from './TextInlineImageNativeComponent'; import type {ImageProps as ImagePropsType} from './ImageProps'; import type {RootTag} from '../Types/RootTagTypes'; +import {getImageSourcesFromImageProps} from './ImageSourceUtils'; let _requestId = 1; function generateRequestId() { @@ -126,25 +127,12 @@ export type ImageComponentStatics = $ReadOnly<{| /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's * LTI update could not be added via codemod */ const BaseImage = (props: ImagePropsType, forwardedRef) => { - let source = resolveAssetSource(props.source); + let source = getImageSourcesFromImageProps(props); const defaultSource = resolveAssetSource(props.defaultSource); const loadingIndicatorSource = resolveAssetSource( props.loadingIndicatorSource, ); - if (source) { - const uri = source.uri; - if (uri === '') { - console.warn('source.uri should not be an empty string'); - } - } - - if (props.src) { - console.warn( - 'The component requires a `source` property rather than `src`.', - ); - } - if (props.children) { throw new Error( 'The component cannot contain children. If you want to render content on top of the image, consider using the component or absolute positioning.', @@ -163,24 +151,28 @@ const BaseImage = (props: ImagePropsType, forwardedRef) => { let style; let sources; - if (source?.uri != null) { - const {width, height} = source; + if (!Array.isArray(source) && source?.uri != null) { + const {width = props.width, height = props.height, uri} = source; style = flattenStyle([{width, height}, styles.base, props.style]); - sources = [{uri: source.uri}]; + sources = [{uri: uri, width: width, height: height}]; + if (uri === '') { + console.warn('source.uri should not be an empty string'); + } } else { style = flattenStyle([styles.base, props.style]); sources = source; } + const {height, width, ...restProps} = props; const {onLoadStart, onLoad, onLoadEnd, onError} = props; const nativeProps = { - ...props, + ...restProps, style, shouldNotifyLoadEvents: !!(onLoadStart || onLoad || onLoadEnd || onError), src: sources, /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found * when making Flow check .android.js files. */ - headers: source?.headers, + headers: (source?.[0]?.headers || source?.headers: ?{[string]: string}), defaultSrc: defaultSource ? defaultSource.uri : null, loadingIndicatorSrc: loadingIndicatorSource ? loadingIndicatorSource.uri diff --git a/Libraries/Image/Image.ios.js b/Libraries/Image/Image.ios.js index 98631a33555bc5..2c0119f75b23e0 100644 --- a/Libraries/Image/Image.ios.js +++ b/Libraries/Image/Image.ios.js @@ -23,6 +23,7 @@ import NativeImageLoaderIOS from './NativeImageLoaderIOS'; import ImageViewNativeComponent from './ImageViewNativeComponent'; import type {RootTag} from 'react-native/Libraries/Types/RootTagTypes'; +import {getImageSourcesFromImageProps} from './ImageSourceUtils'; function getSize( uri: string, @@ -105,7 +106,7 @@ export type ImageComponentStatics = $ReadOnly<{| /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's * LTI update could not be added via codemod */ const BaseImage = (props: ImagePropsType, forwardedRef) => { - const source = resolveAssetSource(props.source) || { + const source = getImageSourcesFromImageProps(props) || { uri: undefined, width: undefined, height: undefined, @@ -117,7 +118,7 @@ const BaseImage = (props: ImagePropsType, forwardedRef) => { style = flattenStyle([styles.base, props.style]) || {}; sources = source; } else { - const {width, height, uri} = source; + const {width = props.width, height = props.height, uri} = source; style = flattenStyle([{width, height}, styles.base, props.style]) || {}; sources = [source]; @@ -131,24 +132,20 @@ const BaseImage = (props: ImagePropsType, forwardedRef) => { // $FlowFixMe[prop-missing] const tintColor = props.tintColor || style.tintColor; - if (props.src != null) { - console.warn( - 'The component requires a `source` property rather than `src`.', - ); - } - if (props.children != null) { throw new Error( 'The component cannot contain children. If you want to render content on top of the image, consider using the component or absolute positioning.', ); } + const {src, width, height, ...restProps} = props; + return ( {analyticTag => { return ( { + let source = resolveAssetSource(imageProps.source); + + let sources; + + const {crossOrigin, referrerPolicy, src, srcSet, width, height} = imageProps; + + const headers: {[string]: string} = {}; + if (crossOrigin === 'use-credentials') { + headers['Access-Control-Allow-Credentials'] = 'true'; + } + if (referrerPolicy != null) { + headers['Referrer-Policy'] = referrerPolicy; + } + if (srcSet != null) { + const sourceList = []; + const srcSetList = srcSet.split(', '); + // `src` prop should be used with default scale if `srcSet` does not have 1x scale. + let shouldUseSrcForDefaultScale = true; + srcSetList.forEach(imageSrc => { + const [uri, xScale = '1x'] = imageSrc.split(' '); + if (!xScale.endsWith('x')) { + console.warn( + 'The provided format for scale is not supported yet. Please use scales like 1x, 2x, etc.', + ); + } else { + const scale = parseInt(xScale.split('x')[0], 10); + if (!isNaN(scale)) { + // 1x scale is provided in `srcSet` prop so ignore the `src` prop if provided. + shouldUseSrcForDefaultScale = + scale === 1 ? false : shouldUseSrcForDefaultScale; + sourceList.push({headers: headers, scale, uri, width, height}); + } + } + }); + + if (shouldUseSrcForDefaultScale && src != null) { + sourceList.push({ + headers: headers, + scale: 1, + uri: src, + width, + height, + }); + } + if (sourceList.length === 0) { + console.warn('The provided value for srcSet is not valid.'); + } + + sources = sourceList; + } else if (src != null) { + sources = [{uri: src, headers: headers, width, height}]; + } else { + sources = source; + } + return sources; +} diff --git a/Libraries/Image/__tests__/ImageSourceUtils-test.js b/Libraries/Image/__tests__/ImageSourceUtils-test.js new file mode 100644 index 00000000000000..23ca3bbf58d8b0 --- /dev/null +++ b/Libraries/Image/__tests__/ImageSourceUtils-test.js @@ -0,0 +1,145 @@ +/** + * 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 + * @emails oncall+react_native + */ + +const {getImageSourcesFromImageProps} = require('../ImageSourceUtils'); + +describe('ImageSourceUtils', () => { + afterEach(() => { + jest.clearAllMocks(); + }); + + it('source prop provided', () => { + const imageProps = {source: require('./img/img1.png')}; + const sources = getImageSourcesFromImageProps(imageProps); + + expect(sources).toBeDefined(); + }); + + it('should ignore source when src is provided', () => { + let uri = 'imageURI'; + const imageProps = {source: require('./img/img1.png'), src: uri}; + const sources = getImageSourcesFromImageProps(imageProps); + + expect(sources).toBeDefined(); + expect(sources).toHaveLength(1); + expect(sources[0].uri).toBe(uri); + }); + + it('should ignore source and src when srcSet is provided', () => { + let uri = 'imageURI'; + + let uri1 = 'uri1'; + let scale1 = '1x'; + + let uri2 = 'uri2'; + let scale2 = '2x'; + + const imageProps = { + source: require('./img/img1.png'), + src: uri, + srcSet: `${uri1} ${scale1}, ${uri2} ${scale2}`, + }; + const sources = getImageSourcesFromImageProps(imageProps); + + expect(sources).toBeDefined(); + expect(sources).toHaveLength(2); + expect(sources[0]).toEqual(expect.objectContaining({uri: uri1, scale: 1})); + expect(sources[1]).toEqual(expect.objectContaining({uri: uri2, scale: 2})); + }); + + it('should use src as default when 1x scale is not provided in srcSet', () => { + let uri = 'imageURI'; + + let uri1 = 'uri1'; + let scale1 = '3x'; + + let uri2 = 'uri2'; + let scale2 = '2x'; + + const imageProps = { + src: uri, + srcSet: `${uri1} ${scale1}, ${uri2} ${scale2}`, + }; + const sources = getImageSourcesFromImageProps(imageProps); + + expect(sources).toBeDefined(); + expect(sources).toHaveLength(3); + expect(sources[0]).toEqual(expect.objectContaining({uri: uri1, scale: 3})); + expect(sources[1]).toEqual(expect.objectContaining({uri: uri2, scale: 2})); + expect(sources[2]).toEqual(expect.objectContaining({uri: uri, scale: 1})); + }); + + it('should use 1x as default scale if only url is provided in srcSet', () => { + let uri1 = 'uri1'; + let scale1 = '2x'; + + let uri2 = 'uri2'; + + const imageProps = { + srcSet: `${uri1} ${scale1}, ${uri2}`, + }; + const sources = getImageSourcesFromImageProps(imageProps); + + expect(sources).toBeDefined(); + expect(sources).toHaveLength(2); + expect(sources[0]).toEqual(expect.objectContaining({uri: uri1, scale: 2})); + expect(sources[1]).toEqual(expect.objectContaining({uri: uri2, scale: 1})); + }); + + it('should warn when an unsupported scale is provided in srcSet', () => { + const mockWarn = jest.spyOn(console, 'warn'); + let uri1 = 'uri1'; + let scale1 = '300w'; + + let uri2 = 'uri2'; + + const imageProps = { + srcSet: `${uri1} ${scale1}, ${uri2}`, + }; + const sources = getImageSourcesFromImageProps(imageProps); + + expect(sources).toBeDefined(); + expect(sources).toHaveLength(1); + expect(mockWarn).toHaveBeenCalled(); + }); + + it('should contain crossorigin headers when provided with src', () => { + let uri = 'imageURI'; + + const imageProps = { + src: uri, + crossOrigin: 'use-credentials', + }; + const sources = getImageSourcesFromImageProps(imageProps); + + expect(sources).toBeDefined(); + expect(sources).toHaveLength(1); + expect(sources[0]).toHaveProperty('headers', { + ['Access-Control-Allow-Credentials']: 'true', + }); + }); + + it('should contain referrerPolicy headers when provided with src', () => { + let uri = 'imageURI'; + + let referrerPolicy = 'origin-when-cross-origin'; + const imageProps = { + src: uri, + referrerPolicy: referrerPolicy, + }; + const sources = getImageSourcesFromImageProps(imageProps); + + expect(sources).toBeDefined(); + expect(sources).toHaveLength(1); + expect(sources[0]).toHaveProperty('headers', { + ['Referrer-Policy']: referrerPolicy, + }); + }); +}); diff --git a/packages/rn-tester/js/examples/Image/ImageExample.js b/packages/rn-tester/js/examples/Image/ImageExample.js index 5c257c81f44787..cddfc87a83517d 100644 --- a/packages/rn-tester/js/examples/Image/ImageExample.js +++ b/packages/rn-tester/js/examples/Image/ImageExample.js @@ -635,13 +635,39 @@ exports.description = exports.examples = [ { - title: 'Plain Network Image', + title: 'Plain Network Image with `source` prop.', description: ('If the `source` prop `uri` property is prefixed with ' + '"http", then it will be downloaded from the network.': string), render: function (): React.Node { return ; }, }, + { + title: 'Plain Network Image with `src` prop.', + description: ('If the `src` prop is defined with ' + + '"http", then it will be downloaded from the network.': string), + render: function (): React.Node { + return ; + }, + }, + { + title: 'Multiple Image Source using the `srcSet` prop.', + description: + ('A list of comma seperated uris along with scale are provided in `srcSet`.' + + 'An appropriate value will be used based on the scale of the device.': string), + render: function (): React.Node { + return ( + + ); + }, + }, { title: 'Plain Blob Image', description: ('If the `source` prop `uri` property is an object URL, ' + From b6bf1fd373c7bfe1e96d82458a1e7de6c5897af7 Mon Sep 17 00:00:00 2001 From: Lulu Wu Date: Wed, 7 Sep 2022 14:41:45 -0700 Subject: [PATCH 024/174] Reland D38460203 Summary: D38460203 (https://github.com/facebook/react-native/commit/e6ef0836c132d6b798e2ff1fc1e1a66c7e238e0b) was reverted because it broke OSS, the root cause is that OSS doesn't have MapBuffer module. Fixed the issue in this diff by moving MapBuffer usage to fb internal class (FBReactModule) and will re-land. Changelog: [iOS][Changed] Replace Folly with MapBuffer for passing js error data Reviewed By: sammy-SC Differential Revision: D39210957 fbshipit-source-id: dda0e8c55dbd13bc96310e10a3b09ea53978e8bc --- React/CoreModules/BUCK | 5 ++++- React/CoreModules/RCTExceptionsManager.h | 5 ++++- React/CoreModules/RCTExceptionsManager.mm | 16 ++++------------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/React/CoreModules/BUCK b/React/CoreModules/BUCK index c5f95ab7009ceb..750745304e9090 100644 --- a/React/CoreModules/BUCK +++ b/React/CoreModules/BUCK @@ -1,5 +1,5 @@ load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "get_objc_arc_preprocessor_flags", "get_preprocessor_flags_for_build_mode") -load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "rn_apple_library", "rn_extra_build_flags") +load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "react_native_xplat_target", "rn_apple_library", "rn_extra_build_flags") load( "@fbsource//xplat/configurations/buck/apple/plugins/sad_xplat_hosted_configurations:react_module_registration.bzl", "react_module_plugin_providers", @@ -129,6 +129,9 @@ rn_apple_library( ], reexport_all_header_dependencies = True, visibility = ["PUBLIC"], + deps = [ + react_native_xplat_target("react/renderer/mapbuffer:mapbufferApple"), + ], exported_deps = [ "//xplat/js/react-native-github:FBReactNativeSpecApple", "//xplat/js/react-native-github:RCTLinkingApple", diff --git a/React/CoreModules/RCTExceptionsManager.h b/React/CoreModules/RCTExceptionsManager.h index 76d36423d722aa..f23bb2153b809e 100644 --- a/React/CoreModules/RCTExceptionsManager.h +++ b/React/CoreModules/RCTExceptionsManager.h @@ -38,7 +38,10 @@ NS_ASSUME_NONNULL_BEGIN - (void)reportFatalException:(nullable NSString *)message stack:(nullable NSArray *)stack exceptionId:(double)exceptionId; -- (void)reportJsException:(NSString *)errorMap; +- (void)reportJsException:(nullable NSString *)message + stack:(nullable NSArray *)stack + exceptionId:(double)exceptionId + isFatal:(bool)isFatal; @property (nonatomic, weak) id delegate; diff --git a/React/CoreModules/RCTExceptionsManager.mm b/React/CoreModules/RCTExceptionsManager.mm index 9d6aafc044be4f..439092ecb651ce 100644 --- a/React/CoreModules/RCTExceptionsManager.mm +++ b/React/CoreModules/RCTExceptionsManager.mm @@ -150,19 +150,11 @@ - (void)reportFatal:(NSString *)message } } -- (void)reportJsException:(NSString *)errorStr +- (void)reportJsException:(nullable NSString *)message + stack:(nullable NSArray *)stack + exceptionId:(double)exceptionId + isFatal:(bool)isFatal { - NSData *jsonData = [errorStr dataUsingEncoding:NSUTF8StringEncoding]; - NSError *jsonError; - NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData - options:NSJSONWritingPrettyPrinted - error:&jsonError]; - - NSString *message = [dict objectForKey:@"message"]; - double exceptionId = [[dict objectForKey:@"id"] doubleValue]; - NSArray *stack = [dict objectForKey:@"stack"]; - BOOL isFatal = [[dict objectForKey:@"isFatal"] boolValue]; - if (isFatal) { [self reportFatalException:message stack:stack exceptionId:exceptionId]; } else { From f44dfef923b887308300cee9ae5a55269414c45a Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Wed, 7 Sep 2022 16:52:01 -0700 Subject: [PATCH 025/174] Add proper support for fractional scrollIndex in VirtualizedList Summary: Non-integer `initialScrollIndex` or values to `scrollToIndex` would produce a reasonable result, with the caveat that it always falls back to layout estimation (will only be correct when all items are the same size), and breaks if getItemLayout() is supplied. It has usage though, so this diff adds proper support for non-integer scrollIndex, to offset a given amount into the length of the specific cell. This overlaps a bit with the optional `viewOffset` and `viewPosition` arguments in `scrollToIndex`, but there isn't really the equivalent API for `initialScrollIndex`. Changelog: [General][Added]- Add proper support for fractional scrollIndex in VirtualizedList Reviewed By: yungsters Differential Revision: D39271100 fbshipit-source-id: 4d93887eed4497e9f6abcd1a6117ac7fdaebf2b1 --- .../Lists/VirtualizedList_EXPERIMENTAL.js | 23 +- .../Lists/__tests__/VirtualizedList-test.js | 207 ++++++++++++++++++ 2 files changed, 227 insertions(+), 3 deletions(-) diff --git a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js index ebe059a01bd14f..b54c238d1e8646 100644 --- a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js +++ b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js @@ -235,11 +235,11 @@ class VirtualizedList extends StateSafePureComponent { }); return; } - const frame = this.__getFrameMetricsApprox(index, this.props); + const frame = this.__getFrameMetricsApprox(Math.floor(index), this.props); const offset = Math.max( 0, - frame.offset - + this._getOffsetApprox(index, this.props) - (viewPosition || 0) * (this._scrollMetrics.visibleLength - frame.length), ) - (viewOffset || 0); @@ -564,7 +564,7 @@ class VirtualizedList extends StateSafePureComponent { static _initialRenderRegion(props: Props): {first: number, last: number} { const itemCount = props.getItemCount(props.data); - const scrollIndex = Math.max(0, props.initialScrollIndex ?? 0); + const scrollIndex = Math.floor(Math.max(0, props.initialScrollIndex ?? 0)); return { first: scrollIndex, @@ -1780,6 +1780,23 @@ class VirtualizedList extends StateSafePureComponent { }; }; + /** + * Gets an approximate offset to an item at a given index. Supports + * fractional indices. + */ + _getOffsetApprox = (index: number, props: FrameMetricProps): number => { + if (Number.isInteger(index)) { + return this.__getFrameMetricsApprox(index, props).offset; + } else { + const frameMetrics = this.__getFrameMetricsApprox( + Math.floor(index), + props, + ); + const remainder = index - Math.floor(index); + return frameMetrics.offset + remainder * frameMetrics.length; + } + }; + __getFrameMetricsApprox: ( index: number, props: FrameMetricProps, diff --git a/Libraries/Lists/__tests__/VirtualizedList-test.js b/Libraries/Lists/__tests__/VirtualizedList-test.js index 0928fd57c98c02..08be48906c687f 100644 --- a/Libraries/Lists/__tests__/VirtualizedList-test.js +++ b/Libraries/Lists/__tests__/VirtualizedList-test.js @@ -736,6 +736,213 @@ it('renders offset cells in initial render when initialScrollIndex set', () => { expect(component).toMatchSnapshot(); }); +it('scrolls after content sizing with integer initialScrollIndex', () => { + const items = generateItems(10); + const ITEM_HEIGHT = 10; + + const listRef = React.createRef(null); + + const component = ReactTestRenderer.create( + , + ); + + const {scrollTo} = listRef.current.getScrollRef(); + + ReactTestRenderer.act(() => { + simulateLayout(component, { + viewport: {width: 10, height: 50}, + content: {width: 10, height: 200}, + }); + performAllBatches(); + }); + + expect(scrollTo).toHaveBeenLastCalledWith({y: 10, animated: false}); +}); + +it('scrolls after content sizing with near-zero initialScrollIndex', () => { + const items = generateItems(10); + const ITEM_HEIGHT = 10; + + const listRef = React.createRef(null); + + const component = ReactTestRenderer.create( + , + ); + + const {scrollTo} = listRef.current.getScrollRef(); + + ReactTestRenderer.act(() => { + simulateLayout(component, { + viewport: {width: 10, height: 50}, + content: {width: 10, height: 200}, + }); + performAllBatches(); + }); + + expect(scrollTo).toHaveBeenLastCalledWith({y: 0.001, animated: false}); +}); + +it('scrolls after content sizing with near-end initialScrollIndex', () => { + const items = generateItems(10); + const ITEM_HEIGHT = 10; + + const listRef = React.createRef(null); + + const component = ReactTestRenderer.create( + , + ); + + const {scrollTo} = listRef.current.getScrollRef(); + + ReactTestRenderer.act(() => { + simulateLayout(component, { + viewport: {width: 10, height: 50}, + content: {width: 10, height: 200}, + }); + performAllBatches(); + }); + + expect(scrollTo).toHaveBeenLastCalledWith({y: 99.999, animated: false}); +}); + +it('scrolls after content sizing with fractional initialScrollIndex (getItemLayout())', () => { + const items = generateItems(10); + const itemHeights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + const getItemLayout = (_, index) => ({ + length: itemHeights[index], + offset: itemHeights.slice(0, index).reduce((a, b) => a + b, 0), + index, + }); + + const listRef = React.createRef(null); + + const component = ReactTestRenderer.create( + , + ); + + const {scrollTo} = listRef.current.getScrollRef(); + + ReactTestRenderer.act(() => { + simulateLayout(component, { + viewport: {width: 10, height: 50}, + content: {width: 10, height: 200}, + }); + performAllBatches(); + }); + + if (useExperimentalList) { + expect(scrollTo).toHaveBeenLastCalledWith({y: 2.0, animated: false}); + } else { + // Legacy incorrect results + expect(scrollTo).toHaveBeenLastCalledWith({y: Number.NaN, animated: false}); + } +}); + +it('scrolls after content sizing with fractional initialScrollIndex (cached layout)', () => { + const items = generateItems(10); + const listRef = React.createRef(null); + + const component = ReactTestRenderer.create( + , + ); + + const {scrollTo} = listRef.current.getScrollRef(); + + ReactTestRenderer.act(() => { + let y = 0; + for (let i = 0; i < 10; ++i) { + const height = i + 1; + simulateCellLayout(component, items, i, { + width: 10, + height, + x: 0, + y, + }); + y += height; + } + + simulateLayout(component, { + viewport: {width: 10, height: 50}, + content: {width: 10, height: 200}, + }); + performAllBatches(); + }); + + if (useExperimentalList) { + expect(scrollTo).toHaveBeenLastCalledWith({y: 2.0, animated: false}); + } else { + // Legacy incorrect results + expect(scrollTo).toHaveBeenLastCalledWith({y: 8.25, animated: false}); + } +}); + +it('scrolls after content sizing with fractional initialScrollIndex (layout estimation)', () => { + const items = generateItems(10); + const listRef = React.createRef(null); + + const component = ReactTestRenderer.create( + , + ); + + const {scrollTo} = listRef.current.getScrollRef(); + + ReactTestRenderer.act(() => { + let y = 0; + for (let i = 5; i < 10; ++i) { + const height = i + 1; + simulateCellLayout(component, items, i, { + width: 10, + height, + x: 0, + y, + }); + y += height; + } + + simulateLayout(component, { + viewport: {width: 10, height: 50}, + content: {width: 10, height: 200}, + }); + performAllBatches(); + }); + + expect(scrollTo).toHaveBeenLastCalledWith({y: 12, animated: false}); +}); + it('initially renders nothing when initialNumToRender is 0', () => { const items = generateItems(10); const ITEM_HEIGHT = 10; From 0ef770587f78389ea4c56f5ace4389d07281947c Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Wed, 7 Sep 2022 17:00:28 -0700 Subject: [PATCH 026/174] Attempt fix #2 for `cellsAroundViewport` reaching out of bounds Summary: VirtualizedList would more gracefully handle out of range cells than VirtualizedList_EXPERIMENTAL, which treats it as an invariant violation. D39244112 (https://github.com/facebook/react-native/commit/7aa203beda3cd358703c2fa535ed045771761612) attempted to fix an issue where recalculation of cells around viewport can include out of range cells, but it is still showing up later. This change adds a bounds check to the remaining branch we control, and an assertion that `computeWindowedRenderLimits` is not returing something out of range to discover if that is the cause. Reviewed By: yungsters Differential Revision: D39267445 fbshipit-source-id: 64c99da28b5b01ef61784079b586e355f73764a1 --- Libraries/Lists/VirtualizedList_EXPERIMENTAL.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js index b54c238d1e8646..50b867e6cbfaa1 100644 --- a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js +++ b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js @@ -608,7 +608,9 @@ class VirtualizedList extends StateSafePureComponent { // Wait until the scroll view metrics have been set up. And until then, // we will trust the initialNumToRender suggestion if (visibleLength <= 0 || contentLength <= 0) { - return cellsAroundViewport; + return cellsAroundViewport.last >= getItemCount(data) + ? VirtualizedList._constrainToItemCount(cellsAroundViewport, props) + : cellsAroundViewport; } let newCellsAroundViewport: {first: number, last: number}; @@ -654,6 +656,10 @@ class VirtualizedList extends StateSafePureComponent { this.__getFrameMetricsApprox, this._scrollMetrics, ); + invariant( + newCellsAroundViewport.last < getItemCount(data), + 'computeWindowedRenderLimits() should return range in-bounds', + ); } if (this._nestedChildLists.size > 0) { From 62f83a9fad027ef0ed808f7e34973bb01cdf10e9 Mon Sep 17 00:00:00 2001 From: Anne Pham Date: Wed, 7 Sep 2022 19:10:01 -0700 Subject: [PATCH 027/174] Add a check for scrollEnabled to VirtualizedList error (#34560) Summary: Nested `VirtualizedList` is now an [error](https://github.com/facebook/react-native/commit/646605b90e666c4b0d1c1200a137eacf62b46f87), instead of a warning. Issues [here](https://github.com/facebook/react-native/issues/31697) and [here](https://github.com/facebook/react-native/issues/33024) outline the concern. ## Changelog [General] [Added] - Added a check to if `scrollEnabled` is not false, if so then fire the `VirtualizedList` error Pull Request resolved: https://github.com/facebook/react-native/pull/34560 Test Plan: Passes all provided automatic tests. In a personal app, there is a situation of nested ScrollViews that had triggered the error. After defining `scrollEnabled={false}` and adding the check, the error no longer appears. Reviewed By: yungsters Differential Revision: D39283866 Pulled By: NickGerleman fbshipit-source-id: 16ae6bbe6bb8b01a54ae18f9e6abf75d11c21c29 --- Libraries/Lists/VirtualizedList_EXPERIMENTAL.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js index 50b867e6cbfaa1..dcad121319835a 100644 --- a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js +++ b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js @@ -1101,7 +1101,8 @@ class VirtualizedList extends StateSafePureComponent { !scrollContext.horizontal === !horizontalOrDefault(this.props.horizontal) && !this._hasWarned.nesting && - this.context == null + this.context == null && + this.props.scrollEnabled !== false ) { // TODO (T46547044): use React.warn once 16.9 is sync'd: https://github.com/facebook/react/pull/15170 console.error( From fc42d5bbb9906c37c2f62d26c46f6e3191cccd01 Mon Sep 17 00:00:00 2001 From: Daksh Bhardwaj Date: Thu, 8 Sep 2022 03:09:11 -0700 Subject: [PATCH 028/174] feat: add userSelect style equivalent to selectable (#34575) Summary: This adds support for the `userSelect` style attribute, mapping the already existing selectable attribute as requested on https://github.com/facebook/react-native/issues/34425. This PR also updates the TextExample.android and TestExample.ios on the RNTester in order to facilitate the manual QA of this. ## Changelog [General] [Added] - Add support for `userSelect` style Pull Request resolved: https://github.com/facebook/react-native/pull/34575 Test Plan: - open the RNTester app and navigate to the Text page - Check the `Selectable Text` through the Selectable text section Reviewed By: yungsters Differential Revision: D39252798 Pulled By: jacdebug fbshipit-source-id: f7fabf20ee68778d75461f511c56f94d0d756d9c --- .../View/ReactNativeStyleAttributes.js | 1 + Libraries/StyleSheet/StyleSheetTypes.js | 1 + Libraries/Text/Text.js | 19 ++++++++++++++++++- .../js/examples/Text/TextExample.android.js | 10 ++++++++++ .../js/examples/Text/TextExample.ios.js | 10 ++++++++++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/View/ReactNativeStyleAttributes.js b/Libraries/Components/View/ReactNativeStyleAttributes.js index 620dd8fdad98e8..dbf500a25925fd 100644 --- a/Libraries/Components/View/ReactNativeStyleAttributes.js +++ b/Libraries/Components/View/ReactNativeStyleAttributes.js @@ -134,6 +134,7 @@ const ReactNativeStyleAttributes: {[string]: AnyAttributeType, ...} = { textShadowOffset: true, textShadowRadius: true, textTransform: true, + userSelect: true, writingDirection: true, /** diff --git a/Libraries/StyleSheet/StyleSheetTypes.js b/Libraries/StyleSheet/StyleSheetTypes.js index a78e58061d8be5..ee11fab8aa5d26 100644 --- a/Libraries/StyleSheet/StyleSheetTypes.js +++ b/Libraries/StyleSheet/StyleSheetTypes.js @@ -632,6 +632,7 @@ export type ____TextStyle_InternalCore = $ReadOnly<{ textDecorationStyle?: 'solid' | 'double' | 'dotted' | 'dashed', textDecorationColor?: ____ColorValue_Internal, textTransform?: 'none' | 'capitalize' | 'uppercase' | 'lowercase', + userSelect?: 'auto' | 'text' | 'none' | 'contain' | 'all', writingDirection?: 'auto' | 'ltr' | 'rtl', }>; diff --git a/Libraries/Text/Text.js b/Libraries/Text/Text.js index 57b6a2ea82ca28..2337efee07d3c1 100644 --- a/Libraries/Text/Text.js +++ b/Libraries/Text/Text.js @@ -20,6 +20,7 @@ import {NativeText, NativeVirtualText} from './TextNativeComponent'; import {type TextProps} from './TextProps'; import * as React from 'react'; import {useContext, useMemo, useState} from 'react'; +import flattenStyle from '../StyleSheet/flattenStyle'; /** * Text is the fundamental component for displaying text. @@ -152,7 +153,13 @@ const Text: React.AbstractComponent< ? null : processColor(restProps.selectionColor); - let style = restProps.style; + let style = flattenStyle(restProps.style); + + let _selectable = restProps.selectable; + if (style?.userSelect != null) { + _selectable = userSelectToSelectableMap[style.userSelect]; + } + if (__DEV__) { if (PressabilityDebug.isEnabled() && onPress != null) { style = StyleSheet.compose(restProps.style, { @@ -182,6 +189,7 @@ const Text: React.AbstractComponent< {...eventHandlersForText} isHighlighted={isHighlighted} isPressable={isPressable} + selectable={_selectable} numberOfLines={numberOfLines} selectionColor={selectionColor} style={style} @@ -193,6 +201,7 @@ const Text: React.AbstractComponent< {...restProps} {...eventHandlersForText} disabled={_disabled} + selectable={_selectable} accessible={_accessible} accessibilityState={_accessibilityState} allowFontScaling={allowFontScaling !== false} @@ -222,4 +231,12 @@ function useLazyInitialization(newValue: boolean): boolean { return oldValue; } +const userSelectToSelectableMap = { + auto: true, + text: true, + none: false, + contain: true, + all: true, +}; + module.exports = Text; diff --git a/packages/rn-tester/js/examples/Text/TextExample.android.js b/packages/rn-tester/js/examples/Text/TextExample.android.js index 8980335aba1361..45826991731aca 100644 --- a/packages/rn-tester/js/examples/Text/TextExample.android.js +++ b/packages/rn-tester/js/examples/Text/TextExample.android.js @@ -982,4 +982,14 @@ exports.examples = [ return ; }, }, + { + title: 'Selectable Text', + render: function (): React.Node { + return ( + + Text element is selectable + + ); + }, + }, ]; diff --git a/packages/rn-tester/js/examples/Text/TextExample.ios.js b/packages/rn-tester/js/examples/Text/TextExample.ios.js index 96c19353c25c5c..d24c35ca1638eb 100644 --- a/packages/rn-tester/js/examples/Text/TextExample.ios.js +++ b/packages/rn-tester/js/examples/Text/TextExample.ios.js @@ -1227,4 +1227,14 @@ exports.examples = [ ); }, }, + { + title: 'Selectable Text', + render: function (): React.Node { + return ( + + Text element is selectable + + ); + }, + }, ]; From a5622165c198ac6e7ffff5883d4f269a2c974f2e Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Thu, 8 Sep 2022 03:09:16 -0700 Subject: [PATCH 029/174] feat: support custom library paths in `react-native.config.js` for codegen on iOS (#34580) Summary: Currently for codegen to work for a library on iOS, it needs to be located inside `node_modules`. This patch adds support for libraries defined in `react-native.config.js`. This is useful when developing libraries as well as monorepos where the library may exist outside of the `node_modules`. Example: ```js // react-native.config.js const path = require('path'); module.exports = { dependencies: { 'react-native-library-name': { root: path.join(__dirname, '..'), }, }, }; ``` ## Changelog [Internal] [Added] - Support custom library paths in `react-native.config.js` for codegen on iOS Pull Request resolved: https://github.com/facebook/react-native/pull/34580 Test Plan: Tested on a test application and ensured that codegen finds the library specified in `react-native.config.js` https://user-images.githubusercontent.com/1174278/188141056-bce03730-2a13-4648-8889-9727aaf2c3c4.mp4 I have also added a basic test case for this scenario. Reviewed By: jacdebug, cortinico Differential Revision: D39257919 Pulled By: cipolleschi fbshipit-source-id: 131189f1941128a59b9b1e28af61a9038eb4536b --- repo-config/package.json | 3 + .../generate-artifacts-executor-test.js | 148 +++++++++++++----- .../codegen/generate-artifacts-executor.js | 98 ++++++++++-- yarn.lock | 5 + 4 files changed, 202 insertions(+), 52 deletions(-) diff --git a/repo-config/package.json b/repo-config/package.json index 9bb7ed9a48b5c9..fcf03a774d1f8e 100644 --- a/repo-config/package.json +++ b/repo-config/package.json @@ -48,5 +48,8 @@ "signedsource": "^1.0.0", "ws": "^6.1.4", "yargs": "^15.3.1" + }, + "devDependencies": { + "mock-fs": "^5.1.4" } } diff --git a/scripts/codegen/__tests__/generate-artifacts-executor-test.js b/scripts/codegen/__tests__/generate-artifacts-executor-test.js index c59592201c981e..68faeda9480428 100644 --- a/scripts/codegen/__tests__/generate-artifacts-executor-test.js +++ b/scripts/codegen/__tests__/generate-artifacts-executor-test.js @@ -13,13 +13,20 @@ const underTest = require('../generate-artifacts-executor'); const fixtures = require('../__test_fixtures__/fixtures'); const path = require('path'); +const fs = require('fs'); +const child_process = require('child_process'); const codegenConfigKey = 'codegenConfig'; const reactNativeDependencyName = 'react-native'; const rootPath = path.join(__dirname, '../../..'); describe('generateCode', () => { - it('executeNodes with the right arguents', () => { + afterEach(() => { + jest.resetModules(); + jest.resetAllMocks(); + }); + + it('executeNodes with the right arguments', () => { // Define variables and expected values const iosOutputDir = 'app/ios/build/generated/ios'; const library = {config: {name: 'library', type: 'all'}}; @@ -32,46 +39,32 @@ describe('generateCode', () => { const tmpOutDir = path.join(tmpDir, 'out'); // mock used functions - let mkdirSyncInvocationCount = 0; - jest.mock('fs', () => ({ - mkdirSync: (location, config) => { - if (mkdirSyncInvocationCount === 0) { - expect(location).toEqual(tmpOutDir); - } - if (mkdirSyncInvocationCount === 1) { - expect(location).toEqual(iosOutputDir); - } - - mkdirSyncInvocationCount += 1; - }, - })); - - let execSyncInvocationCount = 0; - jest.mock('child_process', () => ({ - execSync: command => { - if (execSyncInvocationCount === 0) { - const expectedCommand = `${node} ${path.join( - rnRoot, - 'generate-specs-cli.js', - )} \ - --platform ios \ - --schemaPath ${pathToSchema} \ - --outputDir ${tmpOutDir} \ - --libraryName ${library.config.name} \ - --libraryType ${libraryType}`; - expect(command).toEqual(expectedCommand); - } - - if (execSyncInvocationCount === 1) { - expect(command).toEqual(`cp -R ${tmpOutDir}/* ${iosOutputDir}`); - } - - execSyncInvocationCount += 1; - }, - })); + jest.spyOn(fs, 'mkdirSync').mockImplementation(); + jest.spyOn(child_process, 'execSync').mockImplementation(); underTest._generateCode(iosOutputDir, library, tmpDir, node, pathToSchema); - expect(mkdirSyncInvocationCount).toBe(2); + + const expectedCommand = `${node} ${path.join( + rnRoot, + 'generate-specs-cli.js', + )} --platform ios --schemaPath ${pathToSchema} --outputDir ${tmpOutDir} --libraryName ${ + library.config.name + } --libraryType ${libraryType}`; + + expect(child_process.execSync).toHaveBeenCalledTimes(2); + expect(child_process.execSync).toHaveBeenNthCalledWith(1, expectedCommand); + expect(child_process.execSync).toHaveBeenNthCalledWith( + 2, + `cp -R ${tmpOutDir}/* ${iosOutputDir}`, + ); + + expect(fs.mkdirSync).toHaveBeenCalledTimes(2); + expect(fs.mkdirSync).toHaveBeenNthCalledWith(1, tmpOutDir, { + recursive: true, + }); + expect(fs.mkdirSync).toHaveBeenNthCalledWith(2, iosOutputDir, { + recursive: true, + }); }); }); @@ -202,6 +195,83 @@ describe('extractLibrariesFromJSON', () => { }); }); +describe('findCodegenEnabledLibraries', () => { + const mock = require('mock-fs'); + const { + _findCodegenEnabledLibraries: findCodegenEnabledLibraries, + } = require('../generate-artifacts-executor'); + + afterEach(() => { + mock.restore(); + }); + + it('returns libraries defined in react-native.config.js', () => { + const projectDir = path.join(__dirname, '../../../../test-project'); + const baseCodegenConfigFileDir = path.join(__dirname, '../../..'); + const baseCodegenConfigFilePath = path.join( + baseCodegenConfigFileDir, + 'package.json', + ); + + mock({ + [baseCodegenConfigFilePath]: ` + { + "codegenConfig": {} + } + `, + [projectDir]: { + app: { + 'package.json': `{ + "name": "my-app" + }`, + 'react-native.config.js': '', + }, + 'library-foo': { + 'package.json': `{ + "name": "react-native-foo", + "codegenConfig": { + "name": "RNFooSpec", + "type": "modules", + "jsSrcsDir": "src" + } + }`, + }, + }, + }); + + jest.mock(path.join(projectDir, 'app', 'react-native.config.js'), () => ({ + dependencies: { + 'react-native-foo': { + root: path.join(projectDir, 'library-foo'), + }, + 'react-native-bar': { + root: path.join(projectDir, 'library-bar'), + }, + }, + })); + + const libraries = findCodegenEnabledLibraries( + `${projectDir}/app`, + baseCodegenConfigFileDir, + `package.json`, + 'codegenConfig', + ); + + expect(libraries).toEqual([ + { + library: 'react-native', + config: {}, + libraryPath: baseCodegenConfigFileDir, + }, + { + library: 'react-native-foo', + config: {name: 'RNFooSpec', type: 'modules', jsSrcsDir: 'src'}, + libraryPath: path.join(projectDir, 'library-foo'), + }, + ]); + }); +}); + describe('delete empty files and folders', () => { beforeEach(() => { jest.resetModules(); diff --git a/scripts/codegen/generate-artifacts-executor.js b/scripts/codegen/generate-artifacts-executor.js index 458495baba452e..6fc398a8bcb9d6 100644 --- a/scripts/codegen/generate-artifacts-executor.js +++ b/scripts/codegen/generate-artifacts-executor.js @@ -204,6 +204,55 @@ function handleThirdPartyLibraries( }); } +function handleLibrariesFromReactNativeConfig( + libraries, + codegenConfigKey, + codegenConfigFilename, + appRootDir, +) { + const rnConfigFileName = 'react-native.config.js'; + + console.log( + `\n\n[Codegen] >>>>> Searching for codegen-enabled libraries in ${rnConfigFileName}`, + ); + + const rnConfigFilePath = path.join(appRootDir, rnConfigFileName); + + if (fs.existsSync(rnConfigFilePath)) { + const rnConfig = require(rnConfigFilePath); + + if (rnConfig.dependencies != null) { + Object.keys(rnConfig.dependencies).forEach(name => { + const dependencyConfig = rnConfig.dependencies[name]; + + if (dependencyConfig.root) { + const codegenConfigFileDir = path.resolve( + appRootDir, + dependencyConfig.root, + ); + const configFilePath = path.join( + codegenConfigFileDir, + codegenConfigFilename, + ); + const pkgJsonPath = path.join(codegenConfigFileDir, 'package.json'); + + if (fs.existsSync(configFilePath)) { + const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath)); + const configFile = JSON.parse(fs.readFileSync(configFilePath)); + extractLibrariesFromJSON( + configFile, + libraries, + codegenConfigKey, + pkgJson.name, + codegenConfigFileDir, + ); + } + } + }); + } + } +} + function handleInAppLibraries( libraries, pkgJson, @@ -362,6 +411,39 @@ function createComponentProvider( } } +function findCodegenEnabledLibraries( + appRootDir, + baseCodegenConfigFileDir, + codegenConfigFilename, + codegenConfigKey, +) { + const pkgJson = readPackageJSON(appRootDir); + const dependencies = {...pkgJson.dependencies, ...pkgJson.devDependencies}; + const libraries = []; + + handleReactNativeCodeLibraries( + libraries, + codegenConfigFilename, + codegenConfigKey, + ); + handleThirdPartyLibraries( + libraries, + baseCodegenConfigFileDir, + dependencies, + codegenConfigFilename, + codegenConfigKey, + ); + handleLibrariesFromReactNativeConfig( + libraries, + codegenConfigKey, + codegenConfigFilename, + appRootDir, + ); + handleInAppLibraries(libraries, pkgJson, codegenConfigKey, appRootDir); + + return libraries; +} + // It removes all the empty files and empty folders // it finds, starting from `filepath`, recursively. // @@ -429,23 +511,12 @@ function execute( } try { - const pkgJson = readPackageJSON(appRootDir); - const dependencies = {...pkgJson.dependencies, ...pkgJson.devDependencies}; - const libraries = []; - - handleReactNativeCodeLibraries( - libraries, - codegenConfigFilename, - codegenConfigKey, - ); - handleThirdPartyLibraries( - libraries, + const libraries = findCodegenEnabledLibraries( + appRootDir, baseCodegenConfigFileDir, - dependencies, codegenConfigFilename, codegenConfigKey, ); - handleInAppLibraries(libraries, pkgJson, codegenConfigKey, appRootDir); if (libraries.length === 0) { console.log('[Codegen] No codegen-enabled libraries found.'); @@ -482,6 +553,7 @@ module.exports = { execute: execute, // exported for testing purposes only: _extractLibrariesFromJSON: extractLibrariesFromJSON, + _findCodegenEnabledLibraries: findCodegenEnabledLibraries, _executeNodeScript: executeNodeScript, _generateCode: generateCode, _cleanupEmptyFilesAndFolders: cleanupEmptyFilesAndFolders, diff --git a/yarn.lock b/yarn.lock index e9bf936c6bc360..70ec84790934de 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5301,6 +5301,11 @@ mkdirp@^0.5.1: dependencies: minimist "0.0.8" +mock-fs@^5.1.4: + version "5.1.4" + resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-5.1.4.tgz#d64dc37b2793613ca7148b510b1167b5b8afb6b8" + integrity sha512-sudhLjCjX37qWIcAlIv1OnAxB2wI4EmXByVuUjILh1rKGNGpGU8GNnzw+EAbrhdpBe0TL/KONbK1y3RXZk8SxQ== + ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" From 98d84e571df64b00e1ed3484923a1d8169dcfda1 Mon Sep 17 00:00:00 2001 From: ankit-tailor Date: Thu, 8 Sep 2022 03:38:39 -0700 Subject: [PATCH 030/174] Feat/accessibility state alias (#34524) Summary: This adds aliasing for accessibility state, it's used as requested on https://github.com/facebook/react-native/issues/34424. - [aria-disabled](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled) to equivalent [accessibilityState.disabled](https://reactnative.dev/docs/accessibility#accessibilitystate) - [aria-busy](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-busy) to equivalent [accessibilityState.busy](https://reactnative.dev/docs/accessibility#accessibilitystate) - [aria-checked](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked) to equivalent [accessibilityState.checked](https://reactnative.dev/docs/accessibility#accessibilitystate) - [aria-expanded](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-expanded) to equivalent [accessibilityState.expanded](https://reactnative.dev/docs/accessibility#accessibilitystate) - [aria-selected](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-selected) to equivalent [accessibilityState.selected](https://reactnative.dev/docs/accessibility#accessibilitystate) ## Changelog [General] [Added] - Add aria-disabled, aria-busy, aria-checked, aria-expanded and aria-selected prop to core components Pull Request resolved: https://github.com/facebook/react-native/pull/34524 Test Plan: ```js Blue background ``` Reviewed By: cipolleschi Differential Revision: D39137790 Pulled By: jacdebug fbshipit-source-id: 27b5c56e91731ba36bb4754d9862286a7a8191bc --- Libraries/Components/Button.js | 37 ++++++++-- Libraries/Components/Pressable/Pressable.js | 35 ++++++++-- .../__snapshots__/Pressable-test.js.snap | 48 +++++++++++++ Libraries/Components/TextInput/TextInput.js | 10 +++ .../__snapshots__/TextInput-test.js.snap | 18 +++++ .../Components/Touchable/TouchableBounce.js | 14 +++- .../Touchable/TouchableNativeFeedback.js | 24 +++++-- .../Components/Touchable/TouchableOpacity.js | 25 +++++-- .../Touchable/TouchableWithoutFeedback.js | 37 ++++++++-- .../TouchableNativeFeedback-test.js.snap | 67 ++++++++++++++----- .../TouchableOpacity-test.js.snap | 17 +++++ .../TouchableWithoutFeedback-test.js.snap | 28 ++++++++ Libraries/Components/View/View.js | 21 +++++- Libraries/Components/View/ViewPropTypes.js | 11 ++- .../__snapshots__/Button-test.js.snap | 51 ++++++++++++++ Libraries/Image/Image.android.js | 7 ++ Libraries/Image/Image.ios.js | 20 +++++- .../__snapshots__/Image-test.js.snap | 9 +++ Libraries/Text/Text.js | 27 ++++++-- Libraries/Text/TextProps.js | 11 +++ .../Accessibility/AccessibilityExample.js | 11 +++ 21 files changed, 475 insertions(+), 53 deletions(-) diff --git a/Libraries/Components/Button.js b/Libraries/Components/Button.js index d396acebf5e59f..b2bf05b5914c39 100644 --- a/Libraries/Components/Button.js +++ b/Libraries/Components/Button.js @@ -147,6 +147,17 @@ type ButtonProps = $ReadOnly<{| onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, accessibilityState?: ?AccessibilityState, + /** + * alias for accessibilityState + * + * see https://reactnative.dev/docs/accessibility#accessibilitystate + */ + 'aria-busy'?: ?boolean, + 'aria-checked'?: ?boolean, + 'aria-disabled'?: ?boolean, + 'aria-expanded'?: ?boolean, + 'aria-selected'?: ?boolean, + /** * [Android] Controlling if a view fires accessibility events and if it is reported to accessibility services. */ @@ -270,6 +281,12 @@ class Button extends React.Component { render(): React.Node { const { accessibilityLabel, + accessibilityState, + 'aria-busy': ariaBusy, + 'aria-checked': ariaChecked, + 'aria-disabled': ariaDisabled, + 'aria-expanded': ariaExpanded, + 'aria-selected': ariaSelected, importantForAccessibility, color, onPress, @@ -298,15 +315,23 @@ class Button extends React.Component { } } + let _accessibilityState = { + busy: ariaBusy ?? accessibilityState?.busy, + checked: ariaChecked ?? accessibilityState?.checked, + disabled: ariaDisabled ?? accessibilityState?.disabled, + expanded: ariaExpanded ?? accessibilityState?.expanded, + selected: ariaSelected ?? accessibilityState?.selected, + }; + const disabled = this.props.disabled != null ? this.props.disabled - : this.props.accessibilityState?.disabled; + : _accessibilityState?.disabled; - const accessibilityState = - disabled !== this.props.accessibilityState?.disabled - ? {...this.props.accessibilityState, disabled} - : this.props.accessibilityState; + _accessibilityState = + disabled !== _accessibilityState?.disabled + ? {..._accessibilityState, disabled} + : _accessibilityState; if (disabled) { buttonStyles.push(styles.buttonDisabled); @@ -337,7 +362,7 @@ class Button extends React.Component { accessibilityHint={accessibilityHint} accessibilityLanguage={accessibilityLanguage} accessibilityRole="button" - accessibilityState={accessibilityState} + accessibilityState={_accessibilityState} importantForAccessibility={_importantForAccessibility} hasTVPreferredFocus={hasTVPreferredFocus} nextFocusDown={nextFocusDown} diff --git a/Libraries/Components/Pressable/Pressable.js b/Libraries/Components/Pressable/Pressable.js index 992378df706985..081a960e4a4ddb 100644 --- a/Libraries/Components/Pressable/Pressable.js +++ b/Libraries/Components/Pressable/Pressable.js @@ -52,6 +52,17 @@ type Props = $ReadOnly<{| accessibilityValue?: ?AccessibilityValue, accessibilityViewIsModal?: ?boolean, accessible?: ?boolean, + + /** + * alias for accessibilityState + * + * see https://reactnative.dev/docs/accessibility#accessibilitystate + */ + 'aria-busy'?: ?boolean, + 'aria-checked'?: ?boolean, + 'aria-disabled'?: ?boolean, + 'aria-expanded'?: ?boolean, + 'aria-selected'?: ?boolean, /** * A value indicating whether the accessibility elements contained within * this accessibility element are hidden. @@ -179,9 +190,15 @@ type Props = $ReadOnly<{| * LTI update could not be added via codemod */ function Pressable(props: Props, forwardedRef): React.Node { const { - accessible, + accessibilityState, android_disableSound, android_ripple, + accessible, + 'aria-busy': ariaBusy, + 'aria-checked': ariaChecked, + 'aria-disabled': ariaDisabled, + 'aria-expanded': ariaExpanded, + 'aria-selected': ariaSelected, cancelable, children, delayHoverIn, @@ -210,16 +227,22 @@ function Pressable(props: Props, forwardedRef): React.Node { const [pressed, setPressed] = usePressState(testOnly_pressed === true); - const accessibilityState = - disabled != null - ? {...props.accessibilityState, disabled} - : props.accessibilityState; + let _accessibilityState = { + busy: ariaBusy ?? accessibilityState?.busy, + checked: ariaChecked ?? accessibilityState?.checked, + disabled: ariaDisabled ?? accessibilityState?.disabled, + expanded: ariaExpanded ?? accessibilityState?.expanded, + selected: ariaSelected ?? accessibilityState?.selected, + }; + + _accessibilityState = + disabled != null ? {..._accessibilityState, disabled} : _accessibilityState; const restPropsWithDefaults: React.ElementConfig = { ...restProps, ...android_rippleConfig?.viewProps, accessible: accessible !== false, - accessibilityState, + accessibilityState: _accessibilityState, focusable: focusable !== false, hitSlop, }; diff --git a/Libraries/Components/Pressable/__tests__/__snapshots__/Pressable-test.js.snap b/Libraries/Components/Pressable/__tests__/__snapshots__/Pressable-test.js.snap index 821d4f41ea56e5..4e03820efa8ea3 100644 --- a/Libraries/Components/Pressable/__tests__/__snapshots__/Pressable-test.js.snap +++ b/Libraries/Components/Pressable/__tests__/__snapshots__/Pressable-test.js.snap @@ -2,6 +2,15 @@ exports[` should render as expected: should deep render when mocked (please verify output manually) 1`] = ` should render as expected: should deep render when mocked exports[` should render as expected: should deep render when not mocked (please verify output manually) 1`] = ` should be disabled when disabled is true: should be disabled when disabled is true: should be disable should be disable shou shou sh sh { const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} = this.state.pressability.getEventHandlers(); + const _accessibilityState = { + busy: this.props['aria-busy'] ?? this.props.accessibilityState?.busy, + checked: + this.props['aria-checked'] ?? this.props.accessibilityState?.checked, + disabled: + this.props['aria-disabled'] ?? this.props.accessibilityState?.disabled, + expanded: + this.props['aria-expanded'] ?? this.props.accessibilityState?.expanded, + selected: + this.props['aria-selected'] ?? this.props.accessibilityState?.selected, + }; + return ( { accessibilityHint={this.props.accessibilityHint} accessibilityLanguage={this.props.accessibilityLanguage} accessibilityRole={this.props.accessibilityRole} - accessibilityState={this.props.accessibilityState} + accessibilityState={_accessibilityState} accessibilityActions={this.props.accessibilityActions} onAccessibilityAction={this.props.onAccessibilityAction} accessibilityValue={this.props.accessibilityValue} diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.js b/Libraries/Components/Touchable/TouchableNativeFeedback.js index 3b6de69fb9991f..7f305fd70869a9 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.js @@ -162,12 +162,14 @@ class TouchableNativeFeedback extends React.Component { }; _createPressabilityConfig(): PressabilityConfig { + const accessibilityStateDisabled = + this.props['aria-disabled'] ?? this.props.accessibilityState?.disabled; return { cancelable: !this.props.rejectResponderTermination, disabled: this.props.disabled != null ? this.props.disabled - : this.props.accessibilityState?.disabled, + : accessibilityStateDisabled, hitSlop: this.props.hitSlop, delayLongPress: this.props.delayLongPress, delayPressIn: this.props.delayPressIn, @@ -251,13 +253,25 @@ class TouchableNativeFeedback extends React.Component { const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} = this.state.pressability.getEventHandlers(); - const accessibilityState = + let _accessibilityState = { + busy: this.props['aria-busy'] ?? this.props.accessibilityState?.busy, + checked: + this.props['aria-checked'] ?? this.props.accessibilityState?.checked, + disabled: + this.props['aria-disabled'] ?? this.props.accessibilityState?.disabled, + expanded: + this.props['aria-expanded'] ?? this.props.accessibilityState?.expanded, + selected: + this.props['aria-selected'] ?? this.props.accessibilityState?.selected, + }; + + _accessibilityState = this.props.disabled != null ? { - ...this.props.accessibilityState, + ..._accessibilityState, disabled: this.props.disabled, } - : this.props.accessibilityState; + : _accessibilityState; return React.cloneElement( element, @@ -274,7 +288,7 @@ class TouchableNativeFeedback extends React.Component { accessibilityLanguage: this.props.accessibilityLanguage, accessibilityLabel: this.props.accessibilityLabel, accessibilityRole: this.props.accessibilityRole, - accessibilityState: accessibilityState, + accessibilityState: _accessibilityState, accessibilityActions: this.props.accessibilityActions, onAccessibilityAction: this.props.onAccessibilityAction, accessibilityValue: this.props.accessibilityValue, diff --git a/Libraries/Components/Touchable/TouchableOpacity.js b/Libraries/Components/Touchable/TouchableOpacity.js index 936caceaf16bf7..1d4f392cbde3c2 100644 --- a/Libraries/Components/Touchable/TouchableOpacity.js +++ b/Libraries/Components/Touchable/TouchableOpacity.js @@ -137,7 +137,10 @@ class TouchableOpacity extends React.Component { _createPressabilityConfig(): PressabilityConfig { return { cancelable: !this.props.rejectResponderTermination, - disabled: this.props.disabled ?? this.props.accessibilityState?.disabled, + disabled: + this.props.disabled ?? + this.props['aria-disabled'] ?? + this.props.accessibilityState?.disabled, hitSlop: this.props.hitSlop, delayLongPress: this.props.delayLongPress, delayPressIn: this.props.delayPressIn, @@ -212,13 +215,25 @@ class TouchableOpacity extends React.Component { const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} = this.state.pressability.getEventHandlers(); - const accessibilityState = + let _accessibilityState = { + busy: this.props['aria-busy'] ?? this.props.accessibilityState?.busy, + checked: + this.props['aria-checked'] ?? this.props.accessibilityState?.checked, + disabled: + this.props['aria-disabled'] ?? this.props.accessibilityState?.disabled, + expanded: + this.props['aria-expanded'] ?? this.props.accessibilityState?.expanded, + selected: + this.props['aria-selected'] ?? this.props.accessibilityState?.selected, + }; + + _accessibilityState = this.props.disabled != null ? { - ...this.props.accessibilityState, + ..._accessibilityState, disabled: this.props.disabled, } - : this.props.accessibilityState; + : _accessibilityState; return ( { accessibilityHint={this.props.accessibilityHint} accessibilityLanguage={this.props.accessibilityLanguage} accessibilityRole={this.props.accessibilityRole} - accessibilityState={accessibilityState} + accessibilityState={_accessibilityState} accessibilityActions={this.props.accessibilityActions} onAccessibilityAction={this.props.onAccessibilityAction} accessibilityValue={this.props.accessibilityValue} diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index f260f2cc9d7334..bb46921c8c9c75 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -42,6 +42,16 @@ type Props = $ReadOnly<{| accessibilityValue?: ?AccessibilityValue, accessibilityViewIsModal?: ?boolean, accessible?: ?boolean, + /** + * alias for accessibilityState + * + * see https://reactnative.dev/docs/accessibility#accessibilitystate + */ + 'aria-busy'?: ?boolean, + 'aria-checked'?: ?boolean, + 'aria-disabled'?: ?boolean, + 'aria-expanded'?: ?boolean, + 'aria-selected'?: ?boolean, 'aria-hidden'?: ?boolean, children?: ?React.Node, delayLongPress?: ?number, @@ -105,6 +115,18 @@ class TouchableWithoutFeedback extends React.Component { } } + let _accessibilityState = { + busy: this.props['aria-busy'] ?? this.props.accessibilityState?.busy, + checked: + this.props['aria-checked'] ?? this.props.accessibilityState?.checked, + disabled: + this.props['aria-disabled'] ?? this.props.accessibilityState?.disabled, + expanded: + this.props['aria-expanded'] ?? this.props.accessibilityState?.expanded, + selected: + this.props['aria-selected'] ?? this.props.accessibilityState?.selected, + }; + // BACKWARD-COMPATIBILITY: Focus and blur events were never supported before // adopting `Pressability`, so preserve that behavior. const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} = @@ -116,10 +138,10 @@ class TouchableWithoutFeedback extends React.Component { accessibilityState: this.props.disabled != null ? { - ...this.props.accessibilityState, + ..._accessibilityState, disabled: this.props.disabled, } - : this.props.accessibilityState, + : _accessibilityState, focusable: this.props.focusable !== false && this.props.onPress !== undefined, @@ -148,13 +170,16 @@ class TouchableWithoutFeedback extends React.Component { } } -function createPressabilityConfig(props: Props): PressabilityConfig { +function createPressabilityConfig({ + 'aria-disabled': ariaDisabled, + ...props +}: Props): PressabilityConfig { + const accessibilityStateDisabled = + ariaDisabled ?? props.accessibilityState?.disabled; return { cancelable: !props.rejectResponderTermination, disabled: - props.disabled !== null - ? props.disabled - : props.accessibilityState?.disabled, + props.disabled !== null ? props.disabled : accessibilityStateDisabled, hitSlop: props.hitSlop, delayLongPress: props.delayLongPress, delayPressIn: props.delayPressIn, diff --git a/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableNativeFeedback-test.js.snap b/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableNativeFeedback-test.js.snap index 64b098803b11c3..05f56b9147c90f 100644 --- a/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableNativeFeedback-test.js.snap +++ b/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableNativeFeedback-test.js.snap @@ -1,7 +1,16 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`TouchableWithoutFeedback renders correctly 1`] = ` - should render as expected 1`] = ` + - Touchable - +/> `; -exports[` should render as expected 1`] = ` +exports[` should overwrite accessibilityState with value of disabled prop 1`] = ` should render as expected 1`] = ` /> `; -exports[` should be disabled when disabled is true 1`] = ` +exports[` should be disabled when disabled is true and accessibilityState is empty 1`] = ` should be disabled when disab /> `; -exports[` should be disabled when disabled is true and accessibilityState is empty 1`] = ` +exports[` should keep accessibilityState when disabled is true 1`] = ` shoul /> `; -exports[` should keep accessibilityState when disabled is true 1`] = ` +exports[` should overwrite accessibilityState with value of disabled prop 1`] = ` `; -exports[` should overwrite accessibilityState with value of disabled prop 1`] = ` +exports[` should be disabled when disabled is true 1`] = ` `; -exports[` should overwrite accessibilityState with value of disabled prop 1`] = ` - +> + Touchable + `; diff --git a/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableOpacity-test.js.snap b/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableOpacity-test.js.snap index 4d3f11bc92ef35..92d94f7a1630cb 100644 --- a/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableOpacity-test.js.snap +++ b/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableOpacity-test.js.snap @@ -2,6 +2,15 @@ exports[`TouchableOpacity renders correctly 1`] = ` { + const { + accessibilityState, + 'aria-busy': ariaBusy, + 'aria-checked': ariaChecked, + 'aria-disabled': ariaDisabled, + 'aria-expanded': ariaExpanded, + 'aria-selected': ariaSelected, + ...restProps + } = otherProps; + + const _accessibilityState = { + busy: ariaBusy ?? accessibilityState?.busy, + checked: ariaChecked ?? accessibilityState?.checked, + disabled: ariaDisabled ?? accessibilityState?.disabled, + expanded: ariaExpanded ?? accessibilityState?.expanded, + selected: ariaSelected ?? accessibilityState?.selected, + }; + // Map role values to AccessibilityRole values const roleToAccessibilityRoleMapping = { alert: 'alert', @@ -118,6 +136,7 @@ const View: React.AbstractComponent< , /** - * A value indicating whether the accessibility elements contained within + * alias for accessibilityState + * + * see https://reactnative.dev/docs/accessibility#accessibilitystate + */ + 'aria-busy'?: ?boolean, + 'aria-checked'?: ?boolean, + 'aria-disabled'?: ?boolean, + 'aria-expanded'?: ?boolean, + 'aria-selected'?: ?boolean, + /** A value indicating whether the accessibility elements contained within * this accessibility element are hidden. * * See https://reactnative.dev/docs/view#aria-hidden diff --git a/Libraries/Components/__tests__/__snapshots__/Button-test.js.snap b/Libraries/Components/__tests__/__snapshots__/Button-test.js.snap index fb87db9320e845..57c18ada171a0d 100644 --- a/Libraries/Components/__tests__/__snapshots__/Button-test.js.snap +++ b/Libraries/Components/__tests__/__snapshots__/Button-test.js.snap @@ -5,7 +5,11 @@ exports[`