mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[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] (<anonymous>:1:26) // <-- note the name here
at <anonymous>: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
`<div onClick={() => ...}` uses "<div>.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 [a9410fb487](https://github.com/facebook/react/commit/a9410fb487776339ec68e57a57a570be952ccad0)
This commit is contained in:
@@ -1 +1 @@
|
||||
19.2.0-native-fb-3f2a42a5-20250908
|
||||
19.2.0-native-fb-a9410fb4-20250909
|
||||
Vendored
+2
-2
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<e7695c0bc1692a27009902d171426576>>
|
||||
* @generated SignedSource<<ab106fb4055a126b611db4d06bc514bd>>
|
||||
*/
|
||||
|
||||
"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";
|
||||
})();
|
||||
|
||||
Vendored
+2
-2
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<1ff7b31d0764d05d0f7a8aa00a1e4f30>>
|
||||
* @generated SignedSource<<ebb8d83293db804dee0e0cb2fad3a188>>
|
||||
*/
|
||||
|
||||
"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";
|
||||
|
||||
Vendored
+2
-2
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<1ff7b31d0764d05d0f7a8aa00a1e4f30>>
|
||||
* @generated SignedSource<<ebb8d83293db804dee0e0cb2fad3a188>>
|
||||
*/
|
||||
|
||||
"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";
|
||||
|
||||
Vendored
+6
-6
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<eeaa77b6ff880bf55d3ec6d4978cea6c>>
|
||||
* @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";
|
||||
})();
|
||||
|
||||
compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js
Vendored
+6
-6
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<92d51389784b006674cd5e30dccfbc4c>>
|
||||
* @generated SignedSource<<cdae6aebbeaffa3bdeda56dbabf0f617>>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -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";
|
||||
|
||||
+6
-6
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<d854ec976f6d3c134c060d52440f4840>>
|
||||
* @generated SignedSource<<edc61f1e9751c6c0c77a45bf0ebcc92b>>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -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";
|
||||
|
||||
+6
-6
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<98c8085f57017a9e88c788e33791d907>>
|
||||
* @generated SignedSource<<f707e6dbd74b68b60826c3d97ee00ab5>>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -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 &&
|
||||
|
||||
+6
-6
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<91cd106513d4931e6663a57dd532be2e>>
|
||||
* @generated SignedSource<<aa2f1fd521880ff87e14cb7631a5764c>>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -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";
|
||||
|
||||
+6
-6
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<60c470cf86324368d60caf7fc692aa50>>
|
||||
* @generated SignedSource<<b40a6e44898c9f9812a5380ea4b800f9>>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -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 &&
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<822309d251aa9f4042bd03d7acf35a53>>
|
||||
* @generated SignedSource<<be1755f3d2ddea7d779085574762eda0>>
|
||||
*/
|
||||
|
||||
"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";
|
||||
})();
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<57f66fc8c747e341a320a04600d9c04d>>
|
||||
* @generated SignedSource<<b0d28d1aeed9e99c89d73e724299bf36>>
|
||||
*/
|
||||
|
||||
"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";
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<d870f9e4ce582b64b52ea2b63dd6f8f5>>
|
||||
* @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";
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<a87cb348aa6311e08fbc193eea7d4763>>
|
||||
* @generated SignedSource<<ee7b958cfe86b82b1927e9c5e5ccd6c5>>
|
||||
*/
|
||||
|
||||
"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 &&
|
||||
|
||||
+2
-2
@@ -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";
|
||||
|
||||
Vendored
+2
-2
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<d820dfe1071697c084647149b32e41ed>>
|
||||
* @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 &&
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
3f2a42a5decc88551d34c96f3d031c316ac34f6a
|
||||
a9410fb487776339ec68e57a57a570be952ccad0
|
||||
|
||||
+3
-3
@@ -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);
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<a6c12c8b01b38f9b717744e8af22a4d0>>
|
||||
* @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);
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<688bd1389d3c99a635c0164205822bfe>>
|
||||
* @generated SignedSource<<fb83b5a64645cc1af9bf29b42177780d>>
|
||||
*/
|
||||
|
||||
"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);
|
||||
|
||||
+5
-5
@@ -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);
|
||||
|
||||
+5
-5
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<0cd7e137f26fb57f7a63342be01cfd46>>
|
||||
* @generated SignedSource<<fc2ece912e3bcd5c724b549671f9f11d>>
|
||||
*/
|
||||
|
||||
"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);
|
||||
|
||||
+5
-5
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<a2c2ab911ec4a6e7f9b6e052aad4a407>>
|
||||
* @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);
|
||||
|
||||
+163
-4
@@ -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 : '<anonymous>'} > `;
|
||||
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',
|
||||
|
||||
+163
-4
@@ -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 : '<anonymous>'} > `;
|
||||
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',
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user