From 2d7c94bda2a187a0eadbb2f564eb3129cdbd192d Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 17 Oct 2022 09:52:15 -0700 Subject: [PATCH] React Native sync for revisions 0cac4d5...fd31724 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: - **[9fb581c7c](https://github.com/facebook/react/commit/9fb581c7c )**: Refactor: merge duplicate imports ([#25489](https://github.com/facebook/react/pull/25489)) //// - **[bc358362a](https://github.com/facebook/react/commit/bc358362a )**: [Flight] Improve Error Messages when Invalid Object is Passed to Client/Host Components ([#25492](https://github.com/facebook/react/pull/25492)) //// - **[780eacd40](https://github.com/facebook/react/commit/780eacd40 )**: Flow upgrade to 0.190 ([#25483](https://github.com/facebook/react/pull/25483)) //// - **[54f0e0f73](https://github.com/facebook/react/commit/54f0e0f73 )**: Scaffolding for react-dom/unstable_external-server-runtime ([#25482](https://github.com/facebook/react/pull/25482)) //// - **[0eaca3756](https://github.com/facebook/react/commit/0eaca3756 )**: Add script to generate inline Fizz runtime ([#25481](https://github.com/facebook/react/pull/25481)) //// - **[69c7246d9](https://github.com/facebook/react/commit/69c7246d9 )**: Initialize useMemoCache with sentinel values ([#25465](https://github.com/facebook/react/pull/25465)) //// - **[3b814327e](https://github.com/facebook/react/commit/3b814327e )**: Allow Async Functions to be used in Server Components ([#25479](https://github.com/facebook/react/pull/25479)) //// - **[a6bf46689](https://github.com/facebook/react/commit/a6bf46689 )**: Extract Fizz instruction set to build macro ([#25457](https://github.com/facebook/react/pull/25457)) //// - **[ea5bc6bac](https://github.com/facebook/react/commit/ea5bc6bac )**: [React Native FB] dynamic feature flag for ref access warning ([#25471](https://github.com/facebook/react/pull/25471)) //// - **[08d035bc8](https://github.com/facebook/react/commit/08d035bc8 )**: Remove Shallow Renderer Tests ([#25475](https://github.com/facebook/react/pull/25475)) //// - **[a8c16a004](https://github.com/facebook/react/commit/a8c16a004 )**: Split Cache into its own Dispatcher ([#25474](https://github.com/facebook/react/pull/25474)) //// - **[2cf4352e1](https://github.com/facebook/react/commit/2cf4352e1 )**: Implement HostSingleton Fiber type ([#25426](https://github.com/facebook/react/pull/25426)) //// - **[aa9988e5e](https://github.com/facebook/react/commit/aa9988e5e )**: Server render fork for react-dom ([#25436](https://github.com/facebook/react/pull/25436)) //// - **[513417d69](https://github.com/facebook/react/commit/513417d69 )**: Return lastNonHostInstance in getInspectorDataForInstance for devtools ([#25441](https://github.com/facebook/react/pull/25441)) //// - **[5d60a0b84](https://github.com/facebook/react/commit/5d60a0b84 )**: Bugfix: LegacyHidden shouldn't defer effects ([#25442](https://github.com/facebook/react/pull/25442)) //// - **[618388bc3](https://github.com/facebook/react/commit/618388bc3 )**: [Float] Support script preloads ([#25432](https://github.com/facebook/react/pull/25432)) //// - **[2872a26e1](https://github.com/facebook/react/commit/2872a26e1 )**: track resources in different roots separately ([#25388](https://github.com/facebook/react/pull/25388)) //// - **[ea04a486a](https://github.com/facebook/react/commit/ea04a486a )**: Flow: remove unused suppressions ([#25424](https://github.com/facebook/react/pull/25424)) //// - **[9813edef2](https://github.com/facebook/react/commit/9813edef2 )**: Flow upgrade to 0.188 //// - **[3b6826ed9](https://github.com/facebook/react/commit/3b6826ed9 )**: Flow: inference_mode=constrain_writes //// - **[aed33a49c](https://github.com/facebook/react/commit/aed33a49c )**: Flow upgrade to 0.185 //// - **[f02a5f5c7](https://github.com/facebook/react/commit/f02a5f5c7 )**: Flow upgrade to 0.182 //// - **[72593f008](https://github.com/facebook/react/commit/72593f008 )**: Flow upgrade to 0.176 //// - **[46d40f306](https://github.com/facebook/react/commit/46d40f306 )**: Flow upgrade to 0.175 //// - **[1089faf0d](https://github.com/facebook/react/commit/1089faf0d )**: Flow: run codemod to remove existential type //// - **[3fd9bd8e7](https://github.com/facebook/react/commit/3fd9bd8e7 )**: Add RulesOfHooks support for `use` //// - **[338e6a967](https://github.com/facebook/react/commit/338e6a967 )**: Flow upgrade to 0.155 //// - **[8bc95bb3c](https://github.com/facebook/react/commit/8bc95bb3c )**: Flow upgrade to 0.154 //// - **[9f8a98a39](https://github.com/facebook/react/commit/9f8a98a39 )**: Flow upgrade to 0.153 //// - **[64fe791be](https://github.com/facebook/react/commit/64fe791be )**: Flow upgrade to 0.146 //// - **[d3c6c16a0](https://github.com/facebook/react/commit/d3c6c16a0 )**: Flow upgrade to 0.145 //// - **[00a2f8150](https://github.com/facebook/react/commit/00a2f8150 )**: Flow upgrade to 0.143 //// - **[0a3072278](https://github.com/facebook/react/commit/0a3072278 )**: Flow: complete types first migration ([#25389](https://github.com/facebook/react/pull/25389)) //// - **[bcc05671f](https://github.com/facebook/react/commit/bcc05671f )**: Flow: types first in shared ([#25343](https://github.com/facebook/react/pull/25343)) //// - **[b1f34aa30](https://github.com/facebook/react/commit/b1f34aa30 )**: Flow: types first in react-native-renderer ([#25363](https://github.com/facebook/react/pull/25363)) //// - **[9143864ae](https://github.com/facebook/react/commit/9143864ae )**: Flow: well formed exports for smaller packages ([#25361](https://github.com/facebook/react/pull/25361)) //// - **[21a851e03](https://github.com/facebook/react/commit/21a851e03 )**: Fix devtools typos and grammar ([#24587](https://github.com/facebook/react/pull/24587)) //// - **[cfafeb685](https://github.com/facebook/react/commit/cfafeb685 )**: Remove extra space in Wedge.js ([#24611](https://github.com/facebook/react/pull/24611)) //// - **[9c3de25e1](https://github.com/facebook/react/commit/9c3de25e1 )**: Flow: types first in reconciler ([#25362](https://github.com/facebook/react/pull/25362)) //// - **[7b25b961d](https://github.com/facebook/react/commit/7b25b961d )**: [Fizz/Float] Float for stylesheet resources ([#25243](https://github.com/facebook/react/pull/25243)) //// - **[4c016e7aa](https://github.com/facebook/react/commit/4c016e7aa )**: Refactor: use property shorthand ([#25366](https://github.com/facebook/react/pull/25366)) //// - **[06066c1a5](https://github.com/facebook/react/commit/06066c1a5 )**: Make RulesOfHooks-test more consistent with ExhaustiveDeps-test //// - **[49ae0fad8](https://github.com/facebook/react/commit/49ae0fad8 )**: Fix RulesOfHooks test case indentation //// - **[abbbdf4ce](https://github.com/facebook/react/commit/abbbdf4ce )**: Put modern StrictMode behind a feature flag ([#25365](https://github.com/facebook/react/pull/25365)) //// - **[434110390](https://github.com/facebook/react/commit/434110390 )**: ReactHooks.js - delete emptyObject ([#25031](https://github.com/facebook/react/pull/25031)) //// - **[31400ce29](https://github.com/facebook/react/commit/31400ce29 )**: Refactor: merge duplicate imports ([#25364](https://github.com/facebook/react/pull/25364)) //// - **[3517bd9f7](https://github.com/facebook/react/commit/3517bd9f7 )**: Refactor useEvent ([#25336](https://github.com/facebook/react/pull/25336)) //// - **[6cf06a929](https://github.com/facebook/react/commit/6cf06a929 )**: Remove outdated comments. ([#24464](https://github.com/facebook/react/pull/24464)) //// - **[20a257c25](https://github.com/facebook/react/commit/20a257c25 )**: Refactor: more word doubles removed ([#25352](https://github.com/facebook/react/pull/25352)) //// - **[8cadcffd5](https://github.com/facebook/react/commit/8cadcffd5 )**: Fix typo: reconcilation -> reconciliation ([#25355](https://github.com/facebook/react/pull/25355)) //// - **[ebbe599a2](https://github.com/facebook/react/commit/ebbe599a2 )**: Fix EventListener fork ([#25347](https://github.com/facebook/react/pull/25347)) //// - **[97d75c9c8](https://github.com/facebook/react/commit/97d75c9c8 )**: Move react-dom implementation files to react-dom-bindings ([#25345](https://github.com/facebook/react/pull/25345)) //// - **[3de926449](https://github.com/facebook/react/commit/3de926449 )**: [Fizz] experimental_useEvent ([#25325](https://github.com/facebook/react/pull/25325)) //// - **[5b59dd640](https://github.com/facebook/react/commit/5b59dd640 )**: Fix duplicate words tests ([#25333](https://github.com/facebook/react/pull/25333)) //// - **[cb5084d1c](https://github.com/facebook/react/commit/cb5084d1c )**: [ESLint] Check useEvent references instead ([#25319](https://github.com/facebook/react/pull/25319)) //// - **[c89a83695](https://github.com/facebook/react/commit/c89a83695 )**: Update RulesOfHooks with useEvent rules ([#25285](https://github.com/facebook/react/pull/25285)) //// - **[efc6a08e9](https://github.com/facebook/react/commit/efc6a08e9 )**: [Flight] Implement error digests for Flight runtime and expose errorInfo in getDerivedStateFromError ([#25302](https://github.com/facebook/react/pull/25302)) //// - **[c1d414d75](https://github.com/facebook/react/commit/c1d414d75 )**: Add ref to Offscreen component ([#25254](https://github.com/facebook/react/pull/25254)) //// - **[135e33c95](https://github.com/facebook/react/commit/135e33c95 )**: Flow: typing of Scheduler ([#25317](https://github.com/facebook/react/pull/25317)) //// - **[cc8cb145f](https://github.com/facebook/react/commit/cc8cb145f )**: Flow: add some missing types in react-reconciler ([#25316](https://github.com/facebook/react/pull/25316)) //// - **[112d0498c](https://github.com/facebook/react/commit/112d0498c )**: [Fizz] Move digest from errorInfo to Error instance ([#25313](https://github.com/facebook/react/pull/25313)) //// - **[d1bb1c586](https://github.com/facebook/react/commit/d1bb1c586 )**: Fix memory leak after repeated setState bailouts ([#25309](https://github.com/facebook/react/pull/25309)) //// Changelog: [General][Changed] - React Native sync for revisions 0cac4d5...9fb581c jest_e2e[run_all_tests] Reviewed By: yungsters Differential Revision: D40383219 fbshipit-source-id: dc2a44bd05df041e0c7f2e1060640b1d2c372187 --- BUCK | 1 + Libraries/Renderer/REVISION | 2 +- .../implementations/ReactNativeRenderer.d.ts | 149 ------------------ .../Renderer/shims/ReactNativeTypes.d.ts | 141 ----------------- Libraries/Renderer/shims/ReactNativeTypes.js | 4 +- 5 files changed, 4 insertions(+), 293 deletions(-) delete mode 100644 Libraries/Renderer/implementations/ReactNativeRenderer.d.ts delete mode 100644 Libraries/Renderer/shims/ReactNativeTypes.d.ts diff --git a/BUCK b/BUCK index e3735e5e55b5c0..24538162ef03f9 100644 --- a/BUCK +++ b/BUCK @@ -765,6 +765,7 @@ rn_library( "//xplat/js:node_modules__use_19sync_19external_19store", "//xplat/js:node_modules__whatwg_19fetch", "//xplat/js/RKJSModules/Libraries/Polyfills:Polyfills", + "//xplat/js/RKJSModules/Libraries/React:React", "//xplat/js/RKJSModules/vendor/react:react", "//xplat/js/RKJSModules/vendor/react-test-renderer:react-test-renderer", "//xplat/js/RKJSModules/vendor/scheduler:scheduler", diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index f553c513df4d21..0223d5031256c4 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -0cac4d54c3eb144b72b7bf0ccf05b3740c6b747f \ No newline at end of file +9fb581c7cc9b08a776d440254048734c3ffec78c \ No newline at end of file diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer.d.ts b/Libraries/Renderer/implementations/ReactNativeRenderer.d.ts deleted file mode 100644 index 2624d4a78ce01d..00000000000000 --- a/Libraries/Renderer/implementations/ReactNativeRenderer.d.ts +++ /dev/null @@ -1,149 +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 - */ - -import {GestureResponderEvent} from '../../Types/CoreEventTypes'; - -/** - * Gesture recognition on mobile devices is much more complicated than web. - * A touch can go through several phases as the app determines what the user's intention is. - * For example, the app needs to determine if the touch is scrolling, sliding on a widget, or tapping. - * This can even change during the duration of a touch. There can also be multiple simultaneous touches. - * - * The touch responder system is needed to allow components to negotiate these touch interactions - * without any additional knowledge about their parent or child components. - * This system is implemented in ResponderEventPlugin.js, which contains further details and documentation. - * - * Best Practices - * Users can feel huge differences in the usability of web apps vs. native, and this is one of the big causes. - * Every action should have the following attributes: - * Feedback/highlighting- show the user what is handling their touch, and what will happen when they release the gesture - * Cancel-ability- when making an action, the user should be able to abort it mid-touch by dragging their finger away - * - * These features make users more comfortable while using an app, - * because it allows people to experiment and interact without fear of making mistakes. - * - * TouchableHighlight and Touchable* - * The responder system can be complicated to use. - * So we have provided an abstract Touchable implementation for things that should be "tappable". - * This uses the responder system and allows you to easily configure tap interactions declaratively. - * Use TouchableHighlight anywhere where you would use a button or link on web. - */ -export interface GestureResponderHandlers { - /** - * A view can become the touch responder by implementing the correct negotiation methods. - * There are two methods to ask the view if it wants to become responder: - */ - - /** - * Does this view want to become responder on the start of a touch? - */ - onStartShouldSetResponder?: - | ((event: GestureResponderEvent) => boolean) - | undefined; - - /** - * Called for every touch move on the View when it is not the responder: does this view want to "claim" touch responsiveness? - */ - onMoveShouldSetResponder?: - | ((event: GestureResponderEvent) => boolean) - | undefined; - - /** - * If the View returns true and attempts to become the responder, one of the following will happen: - */ - - onResponderEnd?: ((event: GestureResponderEvent) => void) | undefined; - - /** - * The View is now responding for touch events. - * This is the time to highlight and show the user what is happening - */ - onResponderGrant?: ((event: GestureResponderEvent) => void) | undefined; - - /** - * Something else is the responder right now and will not release it - */ - onResponderReject?: ((event: GestureResponderEvent) => void) | undefined; - - /** - * If the view is responding, the following handlers can be called: - */ - - /** - * The user is moving their finger - */ - onResponderMove?: ((event: GestureResponderEvent) => void) | undefined; - - /** - * Fired at the end of the touch, ie "touchUp" - */ - onResponderRelease?: ((event: GestureResponderEvent) => void) | undefined; - - onResponderStart?: ((event: GestureResponderEvent) => void) | undefined; - - /** - * Something else wants to become responder. - * Should this view release the responder? Returning true allows release - */ - onResponderTerminationRequest?: - | ((event: GestureResponderEvent) => boolean) - | undefined; - - /** - * The responder has been taken from the View. - * Might be taken by other views after a call to onResponderTerminationRequest, - * or might be taken by the OS without asking (happens with control center/ notification center on iOS) - */ - onResponderTerminate?: ((event: GestureResponderEvent) => void) | undefined; - - /** - * onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, - * where the deepest node is called first. - * That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers. - * This is desirable in most cases, because it makes sure all controls and buttons are usable. - * - * However, sometimes a parent will want to make sure that it becomes responder. - * This can be handled by using the capture phase. - * Before the responder system bubbles up from the deepest component, - * it will do a capture phase, firing on*ShouldSetResponderCapture. - * So if a parent View wants to prevent the child from becoming responder on a touch start, - * it should have a onStartShouldSetResponderCapture handler which returns true. - */ - onStartShouldSetResponderCapture?: - | ((event: GestureResponderEvent) => boolean) - | undefined; - - /** - * onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, - * where the deepest node is called first. - * That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers. - * This is desirable in most cases, because it makes sure all controls and buttons are usable. - * - * However, sometimes a parent will want to make sure that it becomes responder. - * This can be handled by using the capture phase. - * Before the responder system bubbles up from the deepest component, - * it will do a capture phase, firing on*ShouldSetResponderCapture. - * So if a parent View wants to prevent the child from becoming responder on a touch start, - * it should have a onStartShouldSetResponderCapture handler which returns true. - */ - onMoveShouldSetResponderCapture?: - | ((event: GestureResponderEvent) => boolean) - | undefined; -} - -/** - * React Native also implements unstable_batchedUpdates - */ -export function unstable_batchedUpdates( - callback: (a: A, b: B) => any, - a: A, - b: B, -): void; -export function unstable_batchedUpdates(callback: (a: A) => any, a: A): void; -export function unstable_batchedUpdates(callback: () => any): void; diff --git a/Libraries/Renderer/shims/ReactNativeTypes.d.ts b/Libraries/Renderer/shims/ReactNativeTypes.d.ts deleted file mode 100644 index 38e00e1cc933ca..00000000000000 --- a/Libraries/Renderer/shims/ReactNativeTypes.d.ts +++ /dev/null @@ -1,141 +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 - */ - -import type * as React from 'react'; - -export type MeasureOnSuccessCallback = ( - x: number, - y: number, - width: number, - height: number, - pageX: number, - pageY: number, -) => void; - -export type MeasureInWindowOnSuccessCallback = ( - x: number, - y: number, - width: number, - height: number, -) => void; - -export type MeasureLayoutOnSuccessCallback = ( - left: number, - top: number, - width: number, - height: number, -) => void; - -/** - * NativeMethods provides methods to access the underlying native component directly. - * This can be useful in cases when you want to focus a view or measure its on-screen dimensions, - * for example. - * The methods described here are available on most of the default components provided by React Native. - * Note, however, that they are not available on composite components that aren't directly backed by a - * native view. This will generally include most components that you define in your own app. - * For more information, see [Direct Manipulation](https://reactnative.dev/docs/direct-manipulation). - * @see https://github.com/facebook/react-native/blob/master/Libraries/Renderer/shims/ReactNativeTypes.js#L87 - */ -export interface NativeMethods { - /** - * Determines the location on screen, width, and height of the given view and - * returns the values via an async callback. If successful, the callback will - * be called with the following arguments: - * - * - x - * - y - * - width - * - height - * - pageX - * - pageY - * - * Note that these measurements are not available until after the rendering - * has been completed in native. If you need the measurements as soon as - * possible, consider using the [`onLayout` - * prop](docs/view.html#onlayout) instead. - */ - measure(callback: MeasureOnSuccessCallback): void; - - /** - * Determines the location of the given view in the window and returns the - * values via an async callback. If the React root view is embedded in - * another native view, this will give you the absolute coordinates. If - * successful, the callback will be called with the following - * arguments: - * - * - x - * - y - * - width - * - height - * - * Note that these measurements are not available until after the rendering - * has been completed in native. - */ - measureInWindow(callback: MeasureInWindowOnSuccessCallback): void; - - /** - * Like [`measure()`](#measure), but measures the view relative an ancestor, - * specified as `relativeToNativeComponentRef`. This means that the returned x, y - * are relative to the origin x, y of the ancestor view. - * _Can also be called with a relativeNativeNodeHandle but is deprecated._ - */ - measureLayout( - relativeToNativeComponentRef: HostComponent | number, - onSuccess: MeasureLayoutOnSuccessCallback, - onFail: () => void /* currently unused */, - ): void; - - /** - * This function sends props straight to native. They will not participate in - * future diff process - this means that if you do not include them in the - * next render, they will remain active (see [Direct - * Manipulation](https://reactnative.dev/docs/direct-manipulation)). - */ - setNativeProps(nativeProps: object): void; - - /** - * Requests focus for the given input or view. The exact behavior triggered - * will depend on the platform and type of view. - */ - focus(): void; - - /** - * Removes focus from an input or view. This is the opposite of `focus()`. - */ - blur(): void; - - refs: { - [key: string]: React.Component; - }; -} - -/** - * @deprecated Use NativeMethods instead. - */ -export type NativeMethodsMixin = NativeMethods; -/** - * @deprecated Use NativeMethods instead. - */ -export type NativeMethodsMixinType = NativeMethods; - -/** - * Represents a native component, such as those returned from `requireNativeComponent`. - * - * @see https://github.com/facebook/react-native/blob/v0.62.0-rc.5/Libraries/Renderer/shims/ReactNativeTypes.js - * - * @todo This should eventually be defined as an AbstractComponent, but that - * should first be introduced in the React typings. - */ -export interface HostComponent

- extends Pick< - React.ComponentClass

, - Exclude, 'new'> - > { - new (props: P, context?: any): React.Component

& Readonly; -} diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index c69fed7ff44fe7..e1e8dfaff3b060 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -6,7 +6,7 @@ * * @noformat * @flow strict - * @generated SignedSource<> + * @generated SignedSource<<81b3507b34f3a91f9bf71beb0f487340>> * * This file was sync'd from the facebook/react repository. */ @@ -141,6 +141,7 @@ type InspectorDataGetter = ( }>; export type InspectorData = $ReadOnly<{ + closestInstance?: mixed, hierarchy: Array<{ name: ?string, getInspectorData: InspectorDataGetter, @@ -153,7 +154,6 @@ export type InspectorData = $ReadOnly<{ export type TouchedViewDataAtPoint = $ReadOnly<{ pointerY: number, touchedViewTag?: number, - closestInstance?: mixed, frame: $ReadOnly<{ top: number, left: number,