From eee3aa614c0ee646089b3210b19a40b433fb3e57 Mon Sep 17 00:00:00 2001 From: sammy-SC Date: Mon, 20 Mar 2023 13:40:40 +0000 Subject: [PATCH] Clean interface for public instances between React and React Native (#26416) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary We are going to move the definition of public instances from React to React Native to have them together with the native methods in Fabric that they invoke. This will allow us to have a better type safety between them and iterate faster on the implementation of this proposal: https://github.com/react-native-community/discussions-and-proposals/pull/607 The interface between React and React Native would look like this after this change and a following PR (#26418): React → React Native: ```javascript ReactNativePrivateInterface.createPublicInstance // to provide via refs ReactNativePrivateInterface.getNodeFromPublicInstance // for DevTools, commands, etc. ReactNativePrivateInterface.getNativeTagFromPublicInstance // to implement `findNodeHandle` ``` React Native → React (ReactFabric): ```javascript ReactFabric.getNodeFromInternalInstanceHandle // to get most recent node to call into native ReactFabric.getPublicInstanceFromInternalInstanceHandle // to get public instances from results from native ``` ## How did you test this change? Flow Existing unit tests DiffTrain build for commit https://github.com/facebook/react/commit/3554c8852fe209ad02380ebd24d32f56d6399906. --- .../cjs/ReactTestRenderer-dev.js | 2 +- .../cjs/ReactTestRenderer-prod.js | 4 +- .../cjs/ReactTestRenderer-profiling.js | 4 +- .../RKJSModules/vendor/react/cjs/React-dev.js | 2 +- .../vendor/react/cjs/React-prod.js | 2 +- .../vendor/react/cjs/React-profiling.js | 2 +- .../implementations/ReactFabric-dev.fb.js | 48 +++++------ .../implementations/ReactFabric-prod.fb.js | 27 +++--- .../ReactFabric-profiling.fb.js | 27 +++--- .../ReactNativeRenderer-dev.fb.js | 64 +++++++------- .../ReactNativeRenderer-prod.fb.js | 83 ++++++++++--------- .../ReactNativeRenderer-profiling.fb.js | 69 +++++++-------- .../Renderer/shims/ReactNativeTypes.js | 9 +- 13 files changed, 180 insertions(+), 163 deletions(-) diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js index 49bc461dc4bd9..5dceaa884cbae 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js @@ -23499,7 +23499,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-next-c57b90f50-20230320"; +var ReactVersion = "18.3.0-next-3554c8852-20230320"; // Might add PROFILE later. diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js index d0cc69e86d8fc..6be91b5ff8cfb 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js @@ -8526,7 +8526,7 @@ var devToolsConfig$jscomp$inline_1010 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-next-c57b90f50-20230320", + version: "18.3.0-next-3554c8852-20230320", rendererPackageName: "react-test-renderer" }; var internals$jscomp$inline_1202 = { @@ -8557,7 +8557,7 @@ var internals$jscomp$inline_1202 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-c57b90f50-20230320" + reconcilerVersion: "18.3.0-next-3554c8852-20230320" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1203 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js index 6854d07647044..6943060479a7e 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js @@ -8953,7 +8953,7 @@ var devToolsConfig$jscomp$inline_1051 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-next-c57b90f50-20230320", + version: "18.3.0-next-3554c8852-20230320", rendererPackageName: "react-test-renderer" }; var internals$jscomp$inline_1241 = { @@ -8984,7 +8984,7 @@ var internals$jscomp$inline_1241 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-c57b90f50-20230320" + reconcilerVersion: "18.3.0-next-3554c8852-20230320" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1242 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js index 6c8bf4df54366..e8c202330b5b9 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js @@ -27,7 +27,7 @@ if ( } "use strict"; -var ReactVersion = "18.3.0-next-c57b90f50-20230320"; +var ReactVersion = "18.3.0-next-3554c8852-20230320"; // ATTENTION // When adding new symbols to this file, diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js index 1fbc378400010..9c50237280674 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js @@ -639,4 +639,4 @@ exports.useSyncExternalStore = function ( ); }; exports.useTransition = useTransition; -exports.version = "18.3.0-next-c57b90f50-20230320"; +exports.version = "18.3.0-next-3554c8852-20230320"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js index 34f021a70147b..3f67f70518e56 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js @@ -642,7 +642,7 @@ exports.useSyncExternalStore = function ( ); }; exports.useTransition = useTransition; -exports.version = "18.3.0-next-c57b90f50-20230320"; +exports.version = "18.3.0-next-3554c8852-20230320"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index e672463d2347e..3d5904f91888c 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -26257,7 +26257,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-next-c57b90f50-20230320"; +var ReactVersion = "18.3.0-next-3554c8852-20230320"; function createPortal$1( children, @@ -26792,11 +26792,18 @@ function injectIntoDevTools(devToolsConfig) { * `nativeFabricUIManager` to be defined in the global scope (which does not * happen in Paper). */ + function getNativeTagFromPublicInstance(publicInstance) { return publicInstance.__nativeTag; } -function getInternalInstanceHandleFromPublicInstance(publicInstance) { - return publicInstance.__internalInstanceHandle; +function getNodeFromPublicInstance(publicInstance) { + if (publicInstance.__internalInstanceHandle == null) { + return null; + } + + return getNodeFromInternalInstanceHandle( + publicInstance.__internalInstanceHandle + ); } var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; @@ -26933,15 +26940,10 @@ function dispatchCommand(handle, command, args) { return; } - var internalInstanceHandle = - getInternalInstanceHandleFromPublicInstance(handle); - - if (internalInstanceHandle != null) { - var node = getNodeFromInternalInstanceHandle(internalInstanceHandle); + var node = getNodeFromPublicInstance(handle); - if (node != null) { - nativeFabricUIManager.dispatchCommand(node, command, args); - } + if (node != null) { + nativeFabricUIManager.dispatchCommand(node, command, args); } else { ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( nativeTag, @@ -26967,15 +26969,10 @@ function sendAccessibilityEvent(handle, eventType) { return; } - var internalInstanceHandle = - getInternalInstanceHandleFromPublicInstance(handle); - - if (internalInstanceHandle != null) { - var node = getNodeFromInternalInstanceHandle(internalInstanceHandle); + var node = getNodeFromPublicInstance(handle); - if (node != null) { - nativeFabricUIManager.sendAccessibilityEvent(node, eventType); - } + if (node != null) { + nativeFabricUIManager.sendAccessibilityEvent(node, eventType); } else { ReactNativePrivateInterface.legacySendAccessibilityEvent( nativeTag, @@ -27466,6 +27463,10 @@ function getPublicInstance(instance) { return null; } +function getPublicInstanceFromInternalInstanceHandle(internalInstanceHandle) { + var instance = internalInstanceHandle.stateNode; + return getPublicInstance(instance); +} function prepareUpdate(instance, type, oldProps, newProps, hostContext) { var viewConfig = instance.canonical.viewConfig; var updatePayload = diff(oldProps, newProps, viewConfig.validAttributes); // TODO: If the event handlers have changed, we need to update the current props @@ -27803,12 +27804,7 @@ function getInspectorDataForViewAtPoint( ) { { var closestInstance = null; - var fabricInstanceHandle = - getInternalInstanceHandleFromPublicInstance(inspectedView); - var fabricNode = - fabricInstanceHandle != null - ? getNodeFromInternalInstanceHandle(fabricInstanceHandle) - : null; + var fabricNode = getNodeFromPublicInstance(inspectedView); if (fabricNode) { // For Fabric we can look up the instance handle directly and measure it. @@ -27971,6 +27967,8 @@ exports.findHostInstance_DEPRECATED = findHostInstance_DEPRECATED; exports.findNodeHandle = findNodeHandle; exports.getInspectorDataForInstance = getInspectorDataForInstance; exports.getNodeFromInternalInstanceHandle = getNodeFromInternalInstanceHandle; +exports.getPublicInstanceFromInternalInstanceHandle = + getPublicInstanceFromInternalInstanceHandle; exports.render = render; exports.sendAccessibilityEvent = sendAccessibilityEvent; exports.stopSurface = stopSurface; diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index 2990116972409..1f7e3785f68c1 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -9461,7 +9461,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1030 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-next-c57b90f50-20230320", + version: "18.3.0-next-3554c8852-20230320", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -9503,7 +9503,7 @@ var internals$jscomp$inline_1277 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-c57b90f50-20230320" + reconcilerVersion: "18.3.0-next-3554c8852-20230320" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1278 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -9530,11 +9530,12 @@ exports.dispatchCommand = function (handle, command, args) { var nativeTag = null != handle._nativeTag ? handle._nativeTag : handle.__nativeTag; null != nativeTag && - ((handle = handle.__internalInstanceHandle), + ((handle = + null == handle.__internalInstanceHandle + ? null + : getNodeFromInternalInstanceHandle(handle.__internalInstanceHandle)), null != handle - ? ((nativeTag = getNodeFromInternalInstanceHandle(handle)), - null != nativeTag && - nativeFabricUIManager.dispatchCommand(nativeTag, command, args)) + ? nativeFabricUIManager.dispatchCommand(handle, command, args) : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( nativeTag, command, @@ -9585,6 +9586,11 @@ exports.getInspectorDataForInstance = function (closestInstance) { }; }; exports.getNodeFromInternalInstanceHandle = getNodeFromInternalInstanceHandle; +exports.getPublicInstanceFromInternalInstanceHandle = function ( + internalInstanceHandle +) { + return getPublicInstance(internalInstanceHandle.stateNode); +}; exports.render = function (element, containerTag, callback, concurrentRoot) { var root = roots.get(containerTag); root || @@ -9620,11 +9626,12 @@ exports.sendAccessibilityEvent = function (handle, eventType) { var nativeTag = null != handle._nativeTag ? handle._nativeTag : handle.__nativeTag; null != nativeTag && - ((handle = handle.__internalInstanceHandle), + ((handle = + null == handle.__internalInstanceHandle + ? null + : getNodeFromInternalInstanceHandle(handle.__internalInstanceHandle)), null != handle - ? ((nativeTag = getNodeFromInternalInstanceHandle(handle)), - null != nativeTag && - nativeFabricUIManager.sendAccessibilityEvent(nativeTag, eventType)) + ? nativeFabricUIManager.sendAccessibilityEvent(handle, eventType) : ReactNativePrivateInterface.legacySendAccessibilityEvent( nativeTag, eventType diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 7dd91873fdb18..07beab4f702b0 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -10171,7 +10171,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1107 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-next-c57b90f50-20230320", + version: "18.3.0-next-3554c8852-20230320", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -10226,7 +10226,7 @@ var roots = new Map(), scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-c57b90f50-20230320" + reconcilerVersion: "18.3.0-next-3554c8852-20230320" }); exports.createPortal = function (children, containerTag) { return createPortal$1( @@ -10240,11 +10240,12 @@ exports.dispatchCommand = function (handle, command, args) { var nativeTag = null != handle._nativeTag ? handle._nativeTag : handle.__nativeTag; null != nativeTag && - ((handle = handle.__internalInstanceHandle), + ((handle = + null == handle.__internalInstanceHandle + ? null + : getNodeFromInternalInstanceHandle(handle.__internalInstanceHandle)), null != handle - ? ((nativeTag = getNodeFromInternalInstanceHandle(handle)), - null != nativeTag && - nativeFabricUIManager.dispatchCommand(nativeTag, command, args)) + ? nativeFabricUIManager.dispatchCommand(handle, command, args) : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( nativeTag, command, @@ -10295,6 +10296,11 @@ exports.getInspectorDataForInstance = function (closestInstance) { }; }; exports.getNodeFromInternalInstanceHandle = getNodeFromInternalInstanceHandle; +exports.getPublicInstanceFromInternalInstanceHandle = function ( + internalInstanceHandle +) { + return getPublicInstance(internalInstanceHandle.stateNode); +}; exports.render = function (element, containerTag, callback, concurrentRoot) { var root = roots.get(containerTag); root || @@ -10332,11 +10338,12 @@ exports.sendAccessibilityEvent = function (handle, eventType) { var nativeTag = null != handle._nativeTag ? handle._nativeTag : handle.__nativeTag; null != nativeTag && - ((handle = handle.__internalInstanceHandle), + ((handle = + null == handle.__internalInstanceHandle + ? null + : getNodeFromInternalInstanceHandle(handle.__internalInstanceHandle)), null != handle - ? ((nativeTag = getNodeFromInternalInstanceHandle(handle)), - null != nativeTag && - nativeFabricUIManager.sendAccessibilityEvent(nativeTag, eventType)) + ? nativeFabricUIManager.sendAccessibilityEvent(handle, eventType) : ReactNativePrivateInterface.legacySendAccessibilityEvent( nativeTag, eventType diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 6d2f812f644e8..c9462084b255b 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -27304,7 +27304,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-next-c57b90f50-20230320"; +var ReactVersion = "18.3.0-next-3554c8852-20230320"; function createPortal$1( children, @@ -27833,19 +27833,6 @@ function injectIntoDevTools(devToolsConfig) { }); } -/** - * IMPORTANT: This module is used in Paper and Fabric. It needs to be defined - * outside of `ReactFabricPublicInstance` because that module requires - * `nativeFabricUIManager` to be defined in the global scope (which does not - * happen in Paper). - */ -function getNativeTagFromPublicInstance(publicInstance) { - return publicInstance.__nativeTag; -} -function getInternalInstanceHandleFromPublicInstance(publicInstance) { - return publicInstance.__internalInstanceHandle; -} - var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function findHostInstance_DEPRECATED(componentOrHandle) { { @@ -27980,15 +27967,10 @@ function dispatchCommand(handle, command, args) { return; } - var internalInstanceHandle = - getInternalInstanceHandleFromPublicInstance(handle); - - if (internalInstanceHandle != null) { - var node = getNodeFromInternalInstanceHandle(internalInstanceHandle); + var node = getNodeFromPublicInstance(handle); - if (node != null) { - nativeFabricUIManager.dispatchCommand(node, command, args); - } + if (node != null) { + nativeFabricUIManager.dispatchCommand(node, command, args); } else { ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( nativeTag, @@ -28014,15 +27996,10 @@ function sendAccessibilityEvent(handle, eventType) { return; } - var internalInstanceHandle = - getInternalInstanceHandleFromPublicInstance(handle); - - if (internalInstanceHandle != null) { - var node = getNodeFromInternalInstanceHandle(internalInstanceHandle); + var node = getNodeFromPublicInstance(handle); - if (node != null) { - nativeFabricUIManager.sendAccessibilityEvent(node, eventType); - } + if (node != null) { + nativeFabricUIManager.sendAccessibilityEvent(node, eventType); } else { ReactNativePrivateInterface.legacySendAccessibilityEvent( nativeTag, @@ -28039,6 +28016,26 @@ function getNodeFromInternalInstanceHandle(internalInstanceHandle) { ); } +/** + * IMPORTANT: This module is used in Paper and Fabric. It needs to be defined + * outside of `ReactFabricPublicInstance` because that module requires + * `nativeFabricUIManager` to be defined in the global scope (which does not + * happen in Paper). + */ + +function getNativeTagFromPublicInstance(publicInstance) { + return publicInstance.__nativeTag; +} +function getNodeFromPublicInstance(publicInstance) { + if (publicInstance.__internalInstanceHandle == null) { + return null; + } + + return getNodeFromInternalInstanceHandle( + publicInstance.__internalInstanceHandle + ); +} + var emptyObject = {}; { @@ -28201,12 +28198,7 @@ function getInspectorDataForViewAtPoint( ) { { var closestInstance = null; - var fabricInstanceHandle = - getInternalInstanceHandleFromPublicInstance(inspectedView); - var fabricNode = - fabricInstanceHandle != null - ? getNodeFromInternalInstanceHandle(fabricInstanceHandle) - : null; + var fabricNode = getNodeFromPublicInstance(inspectedView); if (fabricNode) { // For Fabric we can look up the instance handle directly and measure it. diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 5e56905936467..f6c83b45ade44 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -940,7 +940,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_248 = { +var injectedNamesToPlugins$jscomp$inline_249 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -986,32 +986,32 @@ var injectedNamesToPlugins$jscomp$inline_248 = { } } }, - isOrderingDirty$jscomp$inline_249 = !1, - pluginName$jscomp$inline_250; -for (pluginName$jscomp$inline_250 in injectedNamesToPlugins$jscomp$inline_248) + isOrderingDirty$jscomp$inline_250 = !1, + pluginName$jscomp$inline_251; +for (pluginName$jscomp$inline_251 in injectedNamesToPlugins$jscomp$inline_249) if ( - injectedNamesToPlugins$jscomp$inline_248.hasOwnProperty( - pluginName$jscomp$inline_250 + injectedNamesToPlugins$jscomp$inline_249.hasOwnProperty( + pluginName$jscomp$inline_251 ) ) { - var pluginModule$jscomp$inline_251 = - injectedNamesToPlugins$jscomp$inline_248[pluginName$jscomp$inline_250]; + var pluginModule$jscomp$inline_252 = + injectedNamesToPlugins$jscomp$inline_249[pluginName$jscomp$inline_251]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_250) || - namesToPlugins[pluginName$jscomp$inline_250] !== - pluginModule$jscomp$inline_251 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_251) || + namesToPlugins[pluginName$jscomp$inline_251] !== + pluginModule$jscomp$inline_252 ) { - if (namesToPlugins[pluginName$jscomp$inline_250]) + if (namesToPlugins[pluginName$jscomp$inline_251]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_250 + "`.") + (pluginName$jscomp$inline_251 + "`.") ); - namesToPlugins[pluginName$jscomp$inline_250] = - pluginModule$jscomp$inline_251; - isOrderingDirty$jscomp$inline_249 = !0; + namesToPlugins[pluginName$jscomp$inline_251] = + pluginModule$jscomp$inline_252; + isOrderingDirty$jscomp$inline_250 = !0; } } -isOrderingDirty$jscomp$inline_249 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_250 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -9561,6 +9561,13 @@ function findNodeHandle(componentOrHandle) { ? componentOrHandle._nativeTag : componentOrHandle.__nativeTag; } +function getNodeFromPublicInstance(publicInstance) { + return null == publicInstance.__internalInstanceHandle + ? null + : (publicInstance = publicInstance.__internalInstanceHandle) && + publicInstance.stateNode && + publicInstance.stateNode.node; +} var emptyObject = {}; function createHierarchy(fiberHierarchy) { return fiberHierarchy.map(function (fiber$jscomp$0) { @@ -9640,10 +9647,10 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1089 = { + devToolsConfig$jscomp$inline_1092 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.3.0-next-c57b90f50-20230320", + version: "18.3.0-next-3554c8852-20230320", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -9658,11 +9665,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1343 = { - bundleType: devToolsConfig$jscomp$inline_1089.bundleType, - version: devToolsConfig$jscomp$inline_1089.version, - rendererPackageName: devToolsConfig$jscomp$inline_1089.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1089.rendererConfig, +var internals$jscomp$inline_1346 = { + bundleType: devToolsConfig$jscomp$inline_1092.bundleType, + version: devToolsConfig$jscomp$inline_1092.version, + rendererPackageName: devToolsConfig$jscomp$inline_1092.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1092.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -9678,26 +9685,26 @@ var internals$jscomp$inline_1343 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1089.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1092.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-c57b90f50-20230320" + reconcilerVersion: "18.3.0-next-3554c8852-20230320" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1344 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1347 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1344.isDisabled && - hook$jscomp$inline_1344.supportsFiber + !hook$jscomp$inline_1347.isDisabled && + hook$jscomp$inline_1347.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1344.inject( - internals$jscomp$inline_1343 + (rendererID = hook$jscomp$inline_1347.inject( + internals$jscomp$inline_1346 )), - (injectedHook = hook$jscomp$inline_1344); + (injectedHook = hook$jscomp$inline_1347); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { @@ -9719,11 +9726,9 @@ exports.dispatchCommand = function (handle, command, args) { var nativeTag = null != handle._nativeTag ? handle._nativeTag : handle.__nativeTag; null != nativeTag && - ((handle = handle.__internalInstanceHandle), + ((handle = getNodeFromPublicInstance(handle)), null != handle - ? ((nativeTag = handle && handle.stateNode && handle.stateNode.node), - null != nativeTag && - nativeFabricUIManager.dispatchCommand(nativeTag, command, args)) + ? nativeFabricUIManager.dispatchCommand(handle, command, args) : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( nativeTag, command, @@ -9805,11 +9810,9 @@ exports.sendAccessibilityEvent = function (handle, eventType) { var nativeTag = null != handle._nativeTag ? handle._nativeTag : handle.__nativeTag; null != nativeTag && - ((handle = handle.__internalInstanceHandle), + ((handle = getNodeFromPublicInstance(handle)), null != handle - ? ((nativeTag = handle && handle.stateNode && handle.stateNode.node), - null != nativeTag && - nativeFabricUIManager.sendAccessibilityEvent(nativeTag, eventType)) + ? nativeFabricUIManager.sendAccessibilityEvent(handle, eventType) : ReactNativePrivateInterface.legacySendAccessibilityEvent( nativeTag, eventType diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index fd7c3e6628655..ac39494425ff6 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -951,7 +951,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_264 = { +var injectedNamesToPlugins$jscomp$inline_265 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -997,32 +997,32 @@ var injectedNamesToPlugins$jscomp$inline_264 = { } } }, - isOrderingDirty$jscomp$inline_265 = !1, - pluginName$jscomp$inline_266; -for (pluginName$jscomp$inline_266 in injectedNamesToPlugins$jscomp$inline_264) + isOrderingDirty$jscomp$inline_266 = !1, + pluginName$jscomp$inline_267; +for (pluginName$jscomp$inline_267 in injectedNamesToPlugins$jscomp$inline_265) if ( - injectedNamesToPlugins$jscomp$inline_264.hasOwnProperty( - pluginName$jscomp$inline_266 + injectedNamesToPlugins$jscomp$inline_265.hasOwnProperty( + pluginName$jscomp$inline_267 ) ) { - var pluginModule$jscomp$inline_267 = - injectedNamesToPlugins$jscomp$inline_264[pluginName$jscomp$inline_266]; + var pluginModule$jscomp$inline_268 = + injectedNamesToPlugins$jscomp$inline_265[pluginName$jscomp$inline_267]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_266) || - namesToPlugins[pluginName$jscomp$inline_266] !== - pluginModule$jscomp$inline_267 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_267) || + namesToPlugins[pluginName$jscomp$inline_267] !== + pluginModule$jscomp$inline_268 ) { - if (namesToPlugins[pluginName$jscomp$inline_266]) + if (namesToPlugins[pluginName$jscomp$inline_267]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_266 + "`.") + (pluginName$jscomp$inline_267 + "`.") ); - namesToPlugins[pluginName$jscomp$inline_266] = - pluginModule$jscomp$inline_267; - isOrderingDirty$jscomp$inline_265 = !0; + namesToPlugins[pluginName$jscomp$inline_267] = + pluginModule$jscomp$inline_268; + isOrderingDirty$jscomp$inline_266 = !0; } } -isOrderingDirty$jscomp$inline_265 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_266 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -10271,6 +10271,13 @@ function findNodeHandle(componentOrHandle) { ? componentOrHandle._nativeTag : componentOrHandle.__nativeTag; } +function getNodeFromPublicInstance(publicInstance) { + return null == publicInstance.__internalInstanceHandle + ? null + : (publicInstance = publicInstance.__internalInstanceHandle) && + publicInstance.stateNode && + publicInstance.stateNode.node; +} var emptyObject = {}; function createHierarchy(fiberHierarchy) { return fiberHierarchy.map(function (fiber$jscomp$0) { @@ -10350,10 +10357,10 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1166 = { + devToolsConfig$jscomp$inline_1169 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.3.0-next-c57b90f50-20230320", + version: "18.3.0-next-3554c8852-20230320", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -10382,10 +10389,10 @@ var roots = new Map(), } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1166.bundleType, - version: devToolsConfig$jscomp$inline_1166.version, - rendererPackageName: devToolsConfig$jscomp$inline_1166.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1166.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1169.bundleType, + version: devToolsConfig$jscomp$inline_1169.version, + rendererPackageName: devToolsConfig$jscomp$inline_1169.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1169.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10401,14 +10408,14 @@ var roots = new Map(), return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1166.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1169.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-c57b90f50-20230320" + reconcilerVersion: "18.3.0-next-3554c8852-20230320" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function (reactTag) { @@ -10429,11 +10436,9 @@ exports.dispatchCommand = function (handle, command, args) { var nativeTag = null != handle._nativeTag ? handle._nativeTag : handle.__nativeTag; null != nativeTag && - ((handle = handle.__internalInstanceHandle), + ((handle = getNodeFromPublicInstance(handle)), null != handle - ? ((nativeTag = handle && handle.stateNode && handle.stateNode.node), - null != nativeTag && - nativeFabricUIManager.dispatchCommand(nativeTag, command, args)) + ? nativeFabricUIManager.dispatchCommand(handle, command, args) : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( nativeTag, command, @@ -10522,11 +10527,9 @@ exports.sendAccessibilityEvent = function (handle, eventType) { var nativeTag = null != handle._nativeTag ? handle._nativeTag : handle.__nativeTag; null != nativeTag && - ((handle = handle.__internalInstanceHandle), + ((handle = getNodeFromPublicInstance(handle)), null != handle - ? ((nativeTag = handle && handle.stateNode && handle.stateNode.node), - null != nativeTag && - nativeFabricUIManager.sendAccessibilityEvent(nativeTag, eventType)) + ? nativeFabricUIManager.sendAccessibilityEvent(handle, eventType) : ReactNativePrivateInterface.legacySendAccessibilityEvent( nativeTag, eventType diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/shims/ReactNativeTypes.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/shims/ReactNativeTypes.js index ca9a9dfc04d03..25436085debdb 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/shims/ReactNativeTypes.js @@ -213,6 +213,8 @@ export type ReactNativeType = { }; export opaque type Node = mixed; +type InternalInstanceHandle = mixed; +type PublicInstance = mixed; export type ReactFabricType = { findHostInstance_DEPRECATED( @@ -237,7 +239,12 @@ export type ReactFabricType = { concurrentRoot: ?boolean, ): ?ElementRef, unmountComponentAtNode(containerTag: number): void, - getNodeFromInternalInstanceHandle(internalInstanceHandle: mixed): ?Node, + getNodeFromInternalInstanceHandle( + internalInstanceHandle: InternalInstanceHandle, + ): ?Node, + getPublicInstanceFromInternalInstanceHandle( + internalInstanceHandle: InternalInstanceHandle, + ): PublicInstance, ... };