From e026437175efc05d78f147b5ff4bb49e72bcf413 Mon Sep 17 00:00:00 2001 From: josephsavona Date: Tue, 9 Sep 2025 10:33:57 -0700 Subject: [PATCH] [compiler] Option to infer names for anonymous functions (#34410) Adds a `@enableNameAnonymousFunctions` feature to infer helpful names for anonymous functions within components and hooks. The logic is inspired by a custom Next.js transform, flagged to us by @eps1lon, that does something similar. Implementing this transform within React Compiler means that all React (Compiler) users can benefit from more helpful names when debugging. The idea builds on the fact that JS engines try to infer helpful names for anonymous functions (in stack traces) when those functions are accessed through an object property lookup: ```js ({'a[xyz]': () => { throw new Error('hello!') } }['a[xyz]'])() // Stack trace: Uncaught Error: hello! at a[xyz] (:1:26) // <-- note the name here at :1:60 ``` The new NameAnonymousFunctions transform is gated by the above flag, which is off by default. It attemps to infer names for functions as follows: First, determine a "local" name: * Assigning a function to a named variable uses the variable name. `const f = () => {}` gets the name "f". * Passing the function as an argument to a function gets the name of the function, ie `foo(() => ...)` get the name "foo()", `foo.bar(() => ...)` gets the name "foo.bar()". Note the parenthesis to help understand that it was part of a call. * Passing the function to a known hook uses the name of the hook, `useEffect(() => ...)` uses "useEffect()". * Passing the function as a JSX prop uses the element and attr name, eg `
...}` uses "
.onClick". Second, the local name is combined with the name of the outer component/hook, so the final names will be strings like `Component[f]` or `useMyHook[useEffect()]`. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34410). * #34434 * __->__ #34410 DiffTrain build for [a9410fb487776339ec68e57a57a570be952ccad0](https://github.com/facebook/react/commit/a9410fb487776339ec68e57a57a570be952ccad0) --- compiled-rn/VERSION_NATIVE_FB | 2 +- .../react/react-dom/cjs/ReactDOM-dev.js | 4 +- .../react/react-dom/cjs/ReactDOM-prod.js | 4 +- .../react/react-dom/cjs/ReactDOM-profiling.js | 4 +- .../react/react-dom/cjs/ReactDOMClient-dev.js | 12 +- .../react-dom/cjs/ReactDOMClient-prod.js | 12 +- .../react-dom/cjs/ReactDOMClient-profiling.js | 12 +- .../react-dom/cjs/ReactDOMProfiling-dev.js | 12 +- .../react-dom/cjs/ReactDOMProfiling-prod.js | 12 +- .../cjs/ReactDOMProfiling-profiling.js | 12 +- .../cjs/ReactTestRenderer-dev.js | 8 +- .../cjs/ReactTestRenderer-prod.js | 8 +- .../cjs/ReactTestRenderer-profiling.js | 8 +- .../vendor/react/react/cjs/React-dev.js | 4 +- .../vendor/react/react/cjs/React-prod.js | 4 +- .../vendor/react/react/cjs/React-profiling.js | 4 +- .../Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 6 +- .../implementations/ReactFabric-prod.fb.js | 6 +- .../ReactFabric-profiling.fb.js | 6 +- .../ReactNativeRenderer-dev.fb.js | 10 +- .../ReactNativeRenderer-prod.fb.js | 10 +- .../ReactNativeRenderer-profiling.fb.js | 10 +- .../eslint-plugin-react-hooks.development.js | 167 +++++++++++++++++- .../eslint-plugin-react-hooks.production.js | 167 +++++++++++++++++- .../eslint-plugin-react-hooks/package.json | 2 +- 26 files changed, 413 insertions(+), 95 deletions(-) diff --git a/compiled-rn/VERSION_NATIVE_FB b/compiled-rn/VERSION_NATIVE_FB index a96cd79be3..1cc8e209df 100644 --- a/compiled-rn/VERSION_NATIVE_FB +++ b/compiled-rn/VERSION_NATIVE_FB @@ -1 +1 @@ -19.2.0-native-fb-3f2a42a5-20250908 \ No newline at end of file +19.2.0-native-fb-a9410fb4-20250909 \ No newline at end of file diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js index 1f324293e2..7324970a6e 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "use strict"; @@ -404,5 +404,5 @@ __DEV__ && exports.useFormStatus = function () { return resolveDispatcher().useHostTransitionStatus(); }; - exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; + exports.version = "19.2.0-native-fb-a9410fb4-20250909"; })(); diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js index 48c318cd4d..6fc62fcb1a 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<1ff7b31d0764d05d0f7a8aa00a1e4f30>> + * @generated SignedSource<> */ "use strict"; @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; +exports.version = "19.2.0-native-fb-a9410fb4-20250909"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js index 48c318cd4d..6fc62fcb1a 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<1ff7b31d0764d05d0f7a8aa00a1e4f30>> + * @generated SignedSource<> */ "use strict"; @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; +exports.version = "19.2.0-native-fb-a9410fb4-20250909"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js index a93247c4c3..6ca7bf0b39 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<9f29f72f6f5795bbd29c31ca0b5cfece>> */ /* @@ -29580,11 +29580,11 @@ __DEV__ && }; (function () { var isomorphicReactPackageVersion = React.version; - if ("19.2.0-native-fb-3f2a42a5-20250908" !== isomorphicReactPackageVersion) + if ("19.2.0-native-fb-a9410fb4-20250909" !== isomorphicReactPackageVersion) throw Error( 'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' + (isomorphicReactPackageVersion + - "\n - react-dom: 19.2.0-native-fb-3f2a42a5-20250908\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-dom: 19.2.0-native-fb-a9410fb4-20250909\nLearn more: https://react.dev/warnings/version-mismatch") ); })(); ("function" === typeof Map && @@ -29621,10 +29621,10 @@ __DEV__ && !(function () { var internals = { bundleType: 1, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908" + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909" }; internals.overrideHookState = overrideHookState; internals.overrideHookStateDeletePath = overrideHookStateDeletePath; @@ -29773,5 +29773,5 @@ __DEV__ && listenToAllSupportedEvents(container); return new ReactDOMHydrationRoot(initialChildren); }; - exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; + exports.version = "19.2.0-native-fb-a9410fb4-20250909"; })(); diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js index 1e41196c57..bf36d65ea8 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<92d51389784b006674cd5e30dccfbc4c>> + * @generated SignedSource<> */ /* @@ -17388,14 +17388,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) { }; var isomorphicReactPackageVersion$jscomp$inline_2057 = React.version; if ( - "19.2.0-native-fb-3f2a42a5-20250908" !== + "19.2.0-native-fb-a9410fb4-20250909" !== isomorphicReactPackageVersion$jscomp$inline_2057 ) throw Error( formatProdErrorMessage( 527, isomorphicReactPackageVersion$jscomp$inline_2057, - "19.2.0-native-fb-3f2a42a5-20250908" + "19.2.0-native-fb-a9410fb4-20250909" ) ); ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { @@ -17417,10 +17417,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { }; var internals$jscomp$inline_2630 = { bundleType: 0, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908" + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2631 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -17527,4 +17527,4 @@ exports.hydrateRoot = function (container, initialChildren, options) { listenToAllSupportedEvents(container); return new ReactDOMHydrationRoot(initialChildren); }; -exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; +exports.version = "19.2.0-native-fb-a9410fb4-20250909"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js index 1aceee40da..edc6dc9fcf 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ /* @@ -19398,14 +19398,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) { }; var isomorphicReactPackageVersion$jscomp$inline_2308 = React.version; if ( - "19.2.0-native-fb-3f2a42a5-20250908" !== + "19.2.0-native-fb-a9410fb4-20250909" !== isomorphicReactPackageVersion$jscomp$inline_2308 ) throw Error( formatProdErrorMessage( 527, isomorphicReactPackageVersion$jscomp$inline_2308, - "19.2.0-native-fb-3f2a42a5-20250908" + "19.2.0-native-fb-a9410fb4-20250909" ) ); ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { @@ -19427,10 +19427,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { }; var internals$jscomp$inline_2315 = { bundleType: 0, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908", + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909", getLaneLabelMap: function () { for ( var map = new Map(), lane = 1, index$324 = 0; @@ -19553,4 +19553,4 @@ exports.hydrateRoot = function (container, initialChildren, options) { listenToAllSupportedEvents(container); return new ReactDOMHydrationRoot(initialChildren); }; -exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; +exports.version = "19.2.0-native-fb-a9410fb4-20250909"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js index 18342c4d7b..ab31a14269 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<98c8085f57017a9e88c788e33791d907>> + * @generated SignedSource<> */ /* @@ -29636,11 +29636,11 @@ __DEV__ && }; (function () { var isomorphicReactPackageVersion = React.version; - if ("19.2.0-native-fb-3f2a42a5-20250908" !== isomorphicReactPackageVersion) + if ("19.2.0-native-fb-a9410fb4-20250909" !== isomorphicReactPackageVersion) throw Error( 'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' + (isomorphicReactPackageVersion + - "\n - react-dom: 19.2.0-native-fb-3f2a42a5-20250908\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-dom: 19.2.0-native-fb-a9410fb4-20250909\nLearn more: https://react.dev/warnings/version-mismatch") ); })(); ("function" === typeof Map && @@ -29677,10 +29677,10 @@ __DEV__ && !(function () { var internals = { bundleType: 1, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908" + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909" }; internals.overrideHookState = overrideHookState; internals.overrideHookStateDeletePath = overrideHookStateDeletePath; @@ -30145,7 +30145,7 @@ __DEV__ && exports.useFormStatus = function () { return resolveDispatcher().useHostTransitionStatus(); }; - exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; + exports.version = "19.2.0-native-fb-a9410fb4-20250909"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js index 997060d372..6d5b2bf179 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<91cd106513d4931e6663a57dd532be2e>> + * @generated SignedSource<> */ /* @@ -17399,14 +17399,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) { }; var isomorphicReactPackageVersion$jscomp$inline_2058 = React.version; if ( - "19.2.0-native-fb-3f2a42a5-20250908" !== + "19.2.0-native-fb-a9410fb4-20250909" !== isomorphicReactPackageVersion$jscomp$inline_2058 ) throw Error( formatProdErrorMessage( 527, isomorphicReactPackageVersion$jscomp$inline_2058, - "19.2.0-native-fb-3f2a42a5-20250908" + "19.2.0-native-fb-a9410fb4-20250909" ) ); ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { @@ -17428,10 +17428,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { }; var internals$jscomp$inline_2633 = { bundleType: 0, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908" + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2634 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -17691,4 +17691,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; +exports.version = "19.2.0-native-fb-a9410fb4-20250909"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js index 00f9b88992..82491ec677 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<60c470cf86324368d60caf7fc692aa50>> + * @generated SignedSource<> */ /* @@ -19413,14 +19413,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) { }; var isomorphicReactPackageVersion$jscomp$inline_2309 = React.version; if ( - "19.2.0-native-fb-3f2a42a5-20250908" !== + "19.2.0-native-fb-a9410fb4-20250909" !== isomorphicReactPackageVersion$jscomp$inline_2309 ) throw Error( formatProdErrorMessage( 527, isomorphicReactPackageVersion$jscomp$inline_2309, - "19.2.0-native-fb-3f2a42a5-20250908" + "19.2.0-native-fb-a9410fb4-20250909" ) ); ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { @@ -19442,10 +19442,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { }; var internals$jscomp$inline_2316 = { bundleType: 0, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908", + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909", getLaneLabelMap: function () { for ( var map = new Map(), lane = 1, index$324 = 0; @@ -19721,7 +19721,7 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; +exports.version = "19.2.0-native-fb-a9410fb4-20250909"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js index 77fdd083ec..5829115ddc 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<822309d251aa9f4042bd03d7acf35a53>> + * @generated SignedSource<> */ "use strict"; @@ -15881,10 +15881,10 @@ __DEV__ && (function () { var internals = { bundleType: 1, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-test-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908" + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909" }; internals.overrideHookState = overrideHookState; internals.overrideHookStateDeletePath = overrideHookStateDeletePath; @@ -16029,5 +16029,5 @@ __DEV__ && flushSyncWorkAcrossRoots_impl(0, !0)); } }; - exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; + exports.version = "19.2.0-native-fb-a9410fb4-20250909"; })(); diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js index fe6b10b310..d3abf51ca4 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<57f66fc8c747e341a320a04600d9c04d>> + * @generated SignedSource<> */ "use strict"; @@ -10045,10 +10045,10 @@ function wrapFiber(fiber) { } var internals$jscomp$inline_1469 = { bundleType: 0, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-test-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908" + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1470 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -10184,4 +10184,4 @@ exports.unstable_batchedUpdates = function (fn, a) { flushSyncWorkAcrossRoots_impl(0, !0)); } }; -exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; +exports.version = "19.2.0-native-fb-a9410fb4-20250909"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js index ee36e428b4..bcf8257826 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<15c16483ae93b695a5a96a7aa39ccd6f>> */ "use strict"; @@ -10666,10 +10666,10 @@ function wrapFiber(fiber) { } var internals$jscomp$inline_1260 = { bundleType: 0, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-test-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908", + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909", getLaneLabelMap: function () { for ( var map = new Map(), lane = 1, index$145 = 0; @@ -10820,4 +10820,4 @@ exports.unstable_batchedUpdates = function (fn, a) { flushSyncWorkAcrossRoots_impl(0, !0)); } }; -exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; +exports.version = "19.2.0-native-fb-a9410fb4-20250909"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js index 420034edc7..e5e32d59ff 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "use strict"; @@ -1397,7 +1397,7 @@ __DEV__ && exports.useTransition = function () { return resolveDispatcher().useTransition(); }; - exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; + exports.version = "19.2.0-native-fb-a9410fb4-20250909"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js index aa17d2d401..0951a75a0a 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<2186a62c20a86789d0bdf74605a67f42>> + * @generated SignedSource<<4f054b7c78c31af5ab89e97b31d7135c>> */ "use strict"; @@ -579,4 +579,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; +exports.version = "19.2.0-native-fb-a9410fb4-20250909"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js index 964c18debe..b89624d119 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<2ad8ce96d061666610acc1d87c61e6b9>> */ "use strict"; @@ -583,7 +583,7 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.2.0-native-fb-3f2a42a5-20250908"; +exports.version = "19.2.0-native-fb-a9410fb4-20250909"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION index 975403a970..c22ece9604 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION @@ -1 +1 @@ -3f2a42a5decc88551d34c96f3d031c316ac34f6a +a9410fb487776339ec68e57a57a570be952ccad0 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 c111ceb17b..45d9b31ce5 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 @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<418a550cc111711cb22827856d148fa9>> + * @generated SignedSource<<25e1e30996fc7cf3d001abe66b383fc9>> */ "use strict"; @@ -19705,10 +19705,10 @@ __DEV__ && (function () { var internals = { bundleType: 1, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908" + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909" }; null !== extraDevToolsConfig && (internals.rendererConfig = extraDevToolsConfig); 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 1fdb3162af..889e8b4724 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 @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<2dacbd6dc5d3a984cbf4f141f9bcfed6>> */ "use strict"; @@ -11211,10 +11211,10 @@ batchedUpdatesImpl = function (fn, a) { var roots = new Map(), internals$jscomp$inline_1281 = { bundleType: 0, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908" + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909" }; null !== extraDevToolsConfig && (internals$jscomp$inline_1281.rendererConfig = extraDevToolsConfig); 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 1872c7ecac..085e433ffb 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 @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<688bd1389d3c99a635c0164205822bfe>> + * @generated SignedSource<> */ "use strict"; @@ -13162,10 +13162,10 @@ batchedUpdatesImpl = function (fn, a) { var roots = new Map(), internals$jscomp$inline_1525 = { bundleType: 0, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908" + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909" }; null !== extraDevToolsConfig && (internals$jscomp$inline_1525.rendererConfig = extraDevToolsConfig); 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 680fbed91e..ff48ea193e 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 @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<06103c7444aed854012b7d119a7f5219>> + * @generated SignedSource<<592d6dcea67edd375ebe297eb4f663ef>> */ "use strict"; @@ -19985,11 +19985,11 @@ __DEV__ && shouldSuspendImpl = newShouldSuspendImpl; }; var isomorphicReactPackageVersion = React.version; - if ("19.2.0-native-fb-3f2a42a5-20250908" !== isomorphicReactPackageVersion) + if ("19.2.0-native-fb-a9410fb4-20250909" !== isomorphicReactPackageVersion) throw Error( 'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' + (isomorphicReactPackageVersion + - "\n - react-native-renderer: 19.2.0-native-fb-3f2a42a5-20250908\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-native-renderer: 19.2.0-native-fb-a9410fb4-20250909\nLearn more: https://react.dev/warnings/version-mismatch") ); if ( "function" !== @@ -20015,10 +20015,10 @@ __DEV__ && (function () { var internals = { bundleType: 1, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908" + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909" }; null !== extraDevToolsConfig && (internals.rendererConfig = extraDevToolsConfig); 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 e5c75efc49..dfba916149 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 @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<0cd7e137f26fb57f7a63342be01cfd46>> + * @generated SignedSource<> */ "use strict"; @@ -11370,11 +11370,11 @@ function updateContainer(element, container, parentComponent, callback) { return lane; } var isomorphicReactPackageVersion = React.version; -if ("19.2.0-native-fb-3f2a42a5-20250908" !== isomorphicReactPackageVersion) +if ("19.2.0-native-fb-a9410fb4-20250909" !== isomorphicReactPackageVersion) throw Error( 'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' + (isomorphicReactPackageVersion + - "\n - react-native-renderer: 19.2.0-native-fb-3f2a42a5-20250908\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-native-renderer: 19.2.0-native-fb-a9410fb4-20250909\nLearn more: https://react.dev/warnings/version-mismatch") ); if ( "function" !== @@ -11424,10 +11424,10 @@ batchedUpdatesImpl = function (fn, a) { var roots = new Map(), internals$jscomp$inline_1312 = { bundleType: 0, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908" + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909" }; null !== extraDevToolsConfig && (internals$jscomp$inline_1312.rendererConfig = extraDevToolsConfig); 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 5cfc369d7e..edbc53e886 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 @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<879b916e474685d0576d92b42ed284f8>> */ "use strict"; @@ -13311,11 +13311,11 @@ function updateContainer(element, container, parentComponent, callback) { return lane; } var isomorphicReactPackageVersion = React.version; -if ("19.2.0-native-fb-3f2a42a5-20250908" !== isomorphicReactPackageVersion) +if ("19.2.0-native-fb-a9410fb4-20250909" !== isomorphicReactPackageVersion) throw Error( 'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' + (isomorphicReactPackageVersion + - "\n - react-native-renderer: 19.2.0-native-fb-3f2a42a5-20250908\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-native-renderer: 19.2.0-native-fb-a9410fb4-20250909\nLearn more: https://react.dev/warnings/version-mismatch") ); if ( "function" !== @@ -13365,10 +13365,10 @@ batchedUpdatesImpl = function (fn, a) { var roots = new Map(), internals$jscomp$inline_1556 = { bundleType: 0, - version: "19.2.0-native-fb-3f2a42a5-20250908", + version: "19.2.0-native-fb-a9410fb4-20250909", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-3f2a42a5-20250908" + reconcilerVersion: "19.2.0-native-fb-a9410fb4-20250909" }; null !== extraDevToolsConfig && (internals$jscomp$inline_1556.rendererConfig = extraDevToolsConfig); diff --git a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js index 6d54c2983a..88db6fd319 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +++ b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js @@ -12,7 +12,7 @@ * @lightSyntaxTransform * @preventMunge * @oncall react_core - * @generated SignedSource<<22db850d8b8aa832a28e53bf1000c0d3>> + * @generated SignedSource<<66030ddb5d3cb21b345936dc0ae8900b>> */ 'use strict'; @@ -18615,6 +18615,12 @@ function makeTemporaryIdentifier(id, loc) { function forkTemporaryIdentifier(id, source) { return Object.assign(Object.assign({}, source), { mutableRange: { start: makeInstructionId(0), end: makeInstructionId(0) }, id }); } +function validateIdentifierName(name) { + if (isReservedWord(name) || !libExports$1.isValidIdentifier(name)) { + return Err(null); + } + return Ok(makeIdentifierName(name).value); +} function makeIdentifierName(name) { if (isReservedWord(name)) { CompilerError.throwInvalidJS({ @@ -25843,13 +25849,16 @@ function trimJsxText(original) { } } function lowerFunctionToValue(builder, expr) { - var _a, _b, _c, _d; + var _a, _b, _c, _d, _e, _f, _g; const exprNode = expr.node; const exprLoc = (_a = exprNode.loc) !== null && _a !== void 0 ? _a : GeneratedSource; let name = null; if (expr.isFunctionExpression()) { name = (_d = (_c = (_b = expr.get('id')) === null || _b === void 0 ? void 0 : _b.node) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : null; } + else if (expr.isFunctionDeclaration()) { + name = (_g = (_f = (_e = expr.get('id')) === null || _e === void 0 ? void 0 : _e.node) === null || _f === void 0 ? void 0 : _f.name) !== null && _g !== void 0 ? _g : null; + } const loweredFunc = lowerFunction(builder, expr); if (!loweredFunc) { return { kind: 'UnsupportedNode', node: exprNode, loc: exprLoc }; @@ -32085,6 +32094,7 @@ const EnvironmentConfigSchema = zod.z.object({ flowTypeProvider: zod.z.nullable(zod.z.function().args(zod.z.string())).default(null), enableOptionalDependencies: zod.z.boolean().default(true), enableFire: zod.z.boolean().default(false), + enableNameAnonymousFunctions: zod.z.boolean().default(false), inferEffectDependencies: zod.z .nullable(zod.z.array(zod.z.object({ function: ExternalFunctionSchema, @@ -38458,7 +38468,7 @@ function codegenInstructionValueToExpression(cx, instrValue) { return convertValueToExpression(value); } function codegenInstructionValue(cx, instrValue) { - var _a, _b, _c, _d, _e, _f, _g, _h; + var _a, _b, _c, _d, _e, _f, _g; let value; switch (instrValue.kind) { case 'ArrayExpression': { @@ -38776,6 +38786,9 @@ function codegenInstructionValue(cx, instrValue) { pruneUnusedLValues(reactiveFunction); pruneHoistedContexts(reactiveFunction); const fn = codegenReactiveFunction(new Context$2(cx.env, (_g = reactiveFunction.id) !== null && _g !== void 0 ? _g : '[[ anonymous ]]', cx.uniqueIdentifiers, cx.fbtOperands, cx.temp), reactiveFunction).unwrap(); + const validatedName = instrValue.name != null + ? validateIdentifierName(instrValue.name) + : Err(null); if (instrValue.type === 'ArrowFunctionExpression') { let body = fn.body; if (body.body.length === 1 && loweredFunc.directives.length == 0) { @@ -38787,7 +38800,15 @@ function codegenInstructionValue(cx, instrValue) { value = libExports$1.arrowFunctionExpression(fn.params, body, fn.async); } else { - value = libExports$1.functionExpression((_h = fn.id) !== null && _h !== void 0 ? _h : (instrValue.name != null ? libExports$1.identifier(instrValue.name) : null), fn.params, fn.body, fn.generator, fn.async); + value = libExports$1.functionExpression(validatedName + .map(name => libExports$1.identifier(name)) + .unwrapOr(null), fn.params, fn.body, fn.generator, fn.async); + } + if (cx.env.config.enableNameAnonymousFunctions && + validatedName.isErr() && + instrValue.name != null) { + const name = instrValue.name; + value = libExports$1.memberExpression(libExports$1.objectExpression([libExports$1.objectProperty(libExports$1.stringLiteral(name), value)]), libExports$1.stringLiteral(name), true, false); } break; } @@ -51842,6 +51863,136 @@ function validateEffect(effectFunction, effectDeps, errors) { } } +function nameAnonymousFunctions(fn) { + if (fn.id == null) { + return; + } + const parentName = fn.id; + const functions = nameAnonymousFunctionsImpl(fn); + function visit(node, prefix) { + var _a, _b; + if (node.generatedName != null) { + const name = `${prefix}${node.generatedName}]`; + node.fn.name = name; + } + const nextPrefix = `${prefix}${(_b = (_a = node.generatedName) !== null && _a !== void 0 ? _a : node.fn.name) !== null && _b !== void 0 ? _b : ''} > `; + for (const inner of node.inner) { + visit(inner, nextPrefix); + } + } + for (const node of functions) { + visit(node, `${parentName}[`); + } +} +function nameAnonymousFunctionsImpl(fn) { + var _a, _b; + const functions = new Map(); + const names = new Map(); + const nodes = []; + for (const block of fn.body.blocks.values()) { + for (const instr of block.instructions) { + const { lvalue, value } = instr; + switch (value.kind) { + case 'LoadGlobal': { + names.set(lvalue.identifier.id, value.binding.name); + break; + } + case 'LoadContext': + case 'LoadLocal': { + const name = value.place.identifier.name; + if (name != null && name.kind === 'named') { + names.set(lvalue.identifier.id, name.value); + } + break; + } + case 'PropertyLoad': { + const objectName = names.get(value.object.identifier.id); + if (objectName != null) { + names.set(lvalue.identifier.id, `${objectName}.${String(value.property)}`); + } + break; + } + case 'FunctionExpression': { + const inner = nameAnonymousFunctionsImpl(value.loweredFunc.func); + const node = { + fn: value, + generatedName: null, + inner, + }; + nodes.push(node); + if (value.name == null) { + functions.set(lvalue.identifier.id, node); + } + break; + } + case 'StoreContext': + case 'StoreLocal': { + const node = functions.get(value.value.identifier.id); + const variableName = value.lvalue.place.identifier.name; + if (node != null && + variableName != null && + variableName.kind === 'named') { + node.generatedName = variableName.value; + functions.delete(value.value.identifier.id); + } + break; + } + case 'CallExpression': + case 'MethodCall': { + const callee = value.kind === 'MethodCall' ? value.property : value.callee; + const hookKind = getHookKind(fn.env, callee.identifier); + let calleeName = null; + if (hookKind != null && hookKind !== 'Custom') { + calleeName = hookKind; + } + else { + calleeName = (_a = names.get(callee.identifier.id)) !== null && _a !== void 0 ? _a : '(anonymous)'; + } + let fnArgCount = 0; + for (const arg of value.args) { + if (arg.kind === 'Identifier' && functions.has(arg.identifier.id)) { + fnArgCount++; + } + } + for (let i = 0; i < value.args.length; i++) { + const arg = value.args[i]; + if (arg.kind === 'Spread') { + continue; + } + const node = functions.get(arg.identifier.id); + if (node != null) { + const generatedName = fnArgCount > 1 ? `${calleeName}(arg${i})` : `${calleeName}()`; + node.generatedName = generatedName; + functions.delete(arg.identifier.id); + } + } + break; + } + case 'JsxExpression': { + for (const attr of value.props) { + if (attr.kind === 'JsxSpreadAttribute') { + continue; + } + const node = functions.get(attr.place.identifier.id); + if (node != null) { + const elementName = value.tag.kind === 'BuiltinTag' + ? value.tag.name + : ((_b = names.get(value.tag.identifier.id)) !== null && _b !== void 0 ? _b : null); + const propName = elementName == null + ? attr.name + : `<${elementName}>.${attr.name}`; + node.generatedName = `${propName}`; + functions.delete(attr.place.identifier.id); + } + } + break; + } + } + } + } + return nodes; +} + function run(func, config, fnType, mode, programContext, logger, filename, code) { var _a, _b; const contextIdentifiers = findContextIdentifiers(func); @@ -52060,6 +52211,14 @@ function runWithEnvironment(func, env) { value: hir, }); } + if (env.config.enableNameAnonymousFunctions) { + nameAnonymousFunctions(hir); + log({ + kind: 'hir', + name: 'NameAnonymougFunctions', + value: hir, + }); + } const reactiveFunction = buildReactiveFunction(hir); log({ kind: 'reactive', diff --git a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js index dd624abfec..e087acde49 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js +++ b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - * @generated SignedSource<<6fbbfa4285eac925cc05ad72d2866f14>> + * @generated SignedSource<<1874e12d1b4a76095476774ae81e9eea>> */ 'use strict'; @@ -18600,6 +18600,12 @@ function makeTemporaryIdentifier(id, loc) { function forkTemporaryIdentifier(id, source) { return Object.assign(Object.assign({}, source), { mutableRange: { start: makeInstructionId(0), end: makeInstructionId(0) }, id }); } +function validateIdentifierName(name) { + if (isReservedWord(name) || !libExports$1.isValidIdentifier(name)) { + return Err(null); + } + return Ok(makeIdentifierName(name).value); +} function makeIdentifierName(name) { if (isReservedWord(name)) { CompilerError.throwInvalidJS({ @@ -25828,13 +25834,16 @@ function trimJsxText(original) { } } function lowerFunctionToValue(builder, expr) { - var _a, _b, _c, _d; + var _a, _b, _c, _d, _e, _f, _g; const exprNode = expr.node; const exprLoc = (_a = exprNode.loc) !== null && _a !== void 0 ? _a : GeneratedSource; let name = null; if (expr.isFunctionExpression()) { name = (_d = (_c = (_b = expr.get('id')) === null || _b === void 0 ? void 0 : _b.node) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : null; } + else if (expr.isFunctionDeclaration()) { + name = (_g = (_f = (_e = expr.get('id')) === null || _e === void 0 ? void 0 : _e.node) === null || _f === void 0 ? void 0 : _f.name) !== null && _g !== void 0 ? _g : null; + } const loweredFunc = lowerFunction(builder, expr); if (!loweredFunc) { return { kind: 'UnsupportedNode', node: exprNode, loc: exprLoc }; @@ -31864,6 +31873,7 @@ const EnvironmentConfigSchema = zod.z.object({ flowTypeProvider: zod.z.nullable(zod.z.function().args(zod.z.string())).default(null), enableOptionalDependencies: zod.z.boolean().default(true), enableFire: zod.z.boolean().default(false), + enableNameAnonymousFunctions: zod.z.boolean().default(false), inferEffectDependencies: zod.z .nullable(zod.z.array(zod.z.object({ function: ExternalFunctionSchema, @@ -38237,7 +38247,7 @@ function codegenInstructionValueToExpression(cx, instrValue) { return convertValueToExpression(value); } function codegenInstructionValue(cx, instrValue) { - var _a, _b, _c, _d, _e, _f, _g, _h; + var _a, _b, _c, _d, _e, _f, _g; let value; switch (instrValue.kind) { case 'ArrayExpression': { @@ -38555,6 +38565,9 @@ function codegenInstructionValue(cx, instrValue) { pruneUnusedLValues(reactiveFunction); pruneHoistedContexts(reactiveFunction); const fn = codegenReactiveFunction(new Context$2(cx.env, (_g = reactiveFunction.id) !== null && _g !== void 0 ? _g : '[[ anonymous ]]', cx.uniqueIdentifiers, cx.fbtOperands, cx.temp), reactiveFunction).unwrap(); + const validatedName = instrValue.name != null + ? validateIdentifierName(instrValue.name) + : Err(null); if (instrValue.type === 'ArrowFunctionExpression') { let body = fn.body; if (body.body.length === 1 && loweredFunc.directives.length == 0) { @@ -38566,7 +38579,15 @@ function codegenInstructionValue(cx, instrValue) { value = libExports$1.arrowFunctionExpression(fn.params, body, fn.async); } else { - value = libExports$1.functionExpression((_h = fn.id) !== null && _h !== void 0 ? _h : (instrValue.name != null ? libExports$1.identifier(instrValue.name) : null), fn.params, fn.body, fn.generator, fn.async); + value = libExports$1.functionExpression(validatedName + .map(name => libExports$1.identifier(name)) + .unwrapOr(null), fn.params, fn.body, fn.generator, fn.async); + } + if (cx.env.config.enableNameAnonymousFunctions && + validatedName.isErr() && + instrValue.name != null) { + const name = instrValue.name; + value = libExports$1.memberExpression(libExports$1.objectExpression([libExports$1.objectProperty(libExports$1.stringLiteral(name), value)]), libExports$1.stringLiteral(name), true, false); } break; } @@ -51621,6 +51642,136 @@ function validateEffect(effectFunction, effectDeps, errors) { } } +function nameAnonymousFunctions(fn) { + if (fn.id == null) { + return; + } + const parentName = fn.id; + const functions = nameAnonymousFunctionsImpl(fn); + function visit(node, prefix) { + var _a, _b; + if (node.generatedName != null) { + const name = `${prefix}${node.generatedName}]`; + node.fn.name = name; + } + const nextPrefix = `${prefix}${(_b = (_a = node.generatedName) !== null && _a !== void 0 ? _a : node.fn.name) !== null && _b !== void 0 ? _b : ''} > `; + for (const inner of node.inner) { + visit(inner, nextPrefix); + } + } + for (const node of functions) { + visit(node, `${parentName}[`); + } +} +function nameAnonymousFunctionsImpl(fn) { + var _a, _b; + const functions = new Map(); + const names = new Map(); + const nodes = []; + for (const block of fn.body.blocks.values()) { + for (const instr of block.instructions) { + const { lvalue, value } = instr; + switch (value.kind) { + case 'LoadGlobal': { + names.set(lvalue.identifier.id, value.binding.name); + break; + } + case 'LoadContext': + case 'LoadLocal': { + const name = value.place.identifier.name; + if (name != null && name.kind === 'named') { + names.set(lvalue.identifier.id, name.value); + } + break; + } + case 'PropertyLoad': { + const objectName = names.get(value.object.identifier.id); + if (objectName != null) { + names.set(lvalue.identifier.id, `${objectName}.${String(value.property)}`); + } + break; + } + case 'FunctionExpression': { + const inner = nameAnonymousFunctionsImpl(value.loweredFunc.func); + const node = { + fn: value, + generatedName: null, + inner, + }; + nodes.push(node); + if (value.name == null) { + functions.set(lvalue.identifier.id, node); + } + break; + } + case 'StoreContext': + case 'StoreLocal': { + const node = functions.get(value.value.identifier.id); + const variableName = value.lvalue.place.identifier.name; + if (node != null && + variableName != null && + variableName.kind === 'named') { + node.generatedName = variableName.value; + functions.delete(value.value.identifier.id); + } + break; + } + case 'CallExpression': + case 'MethodCall': { + const callee = value.kind === 'MethodCall' ? value.property : value.callee; + const hookKind = getHookKind(fn.env, callee.identifier); + let calleeName = null; + if (hookKind != null && hookKind !== 'Custom') { + calleeName = hookKind; + } + else { + calleeName = (_a = names.get(callee.identifier.id)) !== null && _a !== void 0 ? _a : '(anonymous)'; + } + let fnArgCount = 0; + for (const arg of value.args) { + if (arg.kind === 'Identifier' && functions.has(arg.identifier.id)) { + fnArgCount++; + } + } + for (let i = 0; i < value.args.length; i++) { + const arg = value.args[i]; + if (arg.kind === 'Spread') { + continue; + } + const node = functions.get(arg.identifier.id); + if (node != null) { + const generatedName = fnArgCount > 1 ? `${calleeName}(arg${i})` : `${calleeName}()`; + node.generatedName = generatedName; + functions.delete(arg.identifier.id); + } + } + break; + } + case 'JsxExpression': { + for (const attr of value.props) { + if (attr.kind === 'JsxSpreadAttribute') { + continue; + } + const node = functions.get(attr.place.identifier.id); + if (node != null) { + const elementName = value.tag.kind === 'BuiltinTag' + ? value.tag.name + : ((_b = names.get(value.tag.identifier.id)) !== null && _b !== void 0 ? _b : null); + const propName = elementName == null + ? attr.name + : `<${elementName}>.${attr.name}`; + node.generatedName = `${propName}`; + functions.delete(attr.place.identifier.id); + } + } + break; + } + } + } + } + return nodes; +} + function run(func, config, fnType, mode, programContext, logger, filename, code) { var _a, _b; const contextIdentifiers = findContextIdentifiers(func); @@ -51839,6 +51990,14 @@ function runWithEnvironment(func, env) { value: hir, }); } + if (env.config.enableNameAnonymousFunctions) { + nameAnonymousFunctions(hir); + log({ + kind: 'hir', + name: 'NameAnonymougFunctions', + value: hir, + }); + } const reactiveFunction = buildReactiveFunction(hir); log({ kind: 'reactive', diff --git a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json index 9f4941b4cc..320786a1c1 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json +++ b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json @@ -1,7 +1,7 @@ { "name": "eslint-plugin-react-hooks", "description": "ESLint rules for React Hooks", - "version": "0.0.0-experimental-3f2a42a5-20250908", + "version": "0.0.0-experimental-a9410fb4-20250909", "repository": { "type": "git", "url": "https://github.com/facebook/react.git",