From 94683ffb3d39d47a6a80f6f2ccd127a8632ab17e Mon Sep 17 00:00:00 2001 From: sebmarkbage Date: Mon, 19 Feb 2024 16:54:24 +0000 Subject: [PATCH] [Flight] Allow a Server Reference to be registered twice (#28343) It's possible for the same function instance to appear more than once in the same graph or even the same file. Currently this errors on trying to reconfigure the property but it really doesn't matter which one wins. First or last. Regardless there will be an entry point generated that can get them. DiffTrain build for [9444c51c7e44936c24e1f44db905cfd45c51cff3](https://github.com/facebook/react/commit/9444c51c7e44936c24e1f44db905cfd45c51cff3) --- compiled/facebook-www/REVISION | 2 +- compiled/facebook-www/React-prod.modern.js | 2 +- .../facebook-www/ReactDOMServer-dev.classic.js | 18 +++++++++++++++++- .../facebook-www/ReactDOMServer-dev.modern.js | 18 +++++++++++++++++- .../ReactDOMServerStreaming-dev.modern.js | 16 ++++++++++++++++ .../ReactDOMTesting-prod.modern.js | 6 +++--- .../ReactFlightDOMServer-dev.modern.js | 16 ++++++++++++++++ .../ReactFlightDOMServer-prod.modern.js | 6 +++++- .../ReactTestRenderer-dev.modern.js | 2 +- 9 files changed, 77 insertions(+), 9 deletions(-) diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index 8c99ae84e2031..c85010c4d934a 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -c1fd2a91b1042c137d750be85e5998f699a54d2a +9444c51c7e44936c24e1f44db905cfd45c51cff3 diff --git a/compiled/facebook-www/React-prod.modern.js b/compiled/facebook-www/React-prod.modern.js index d2f8264226ef7..202eacea293bb 100644 --- a/compiled/facebook-www/React-prod.modern.js +++ b/compiled/facebook-www/React-prod.modern.js @@ -610,4 +610,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "18.3.0-www-modern-a12e20fd"; +exports.version = "18.3.0-www-modern-f4161761"; diff --git a/compiled/facebook-www/ReactDOMServer-dev.classic.js b/compiled/facebook-www/ReactDOMServer-dev.classic.js index 4ed087c76a301..e5efb83c4f354 100644 --- a/compiled/facebook-www/ReactDOMServer-dev.classic.js +++ b/compiled/facebook-www/ReactDOMServer-dev.classic.js @@ -19,7 +19,7 @@ if (__DEV__) { var React = require("react"); var ReactDOM = require("react-dom"); - var ReactVersion = "18.3.0-www-classic-d7b5bc9a"; + var ReactVersion = "18.3.0-www-classic-a730f95d"; // This refers to a WWW module. var warningWWW = require("warning"); @@ -171,6 +171,10 @@ if (__DEV__) { return "[...]"; } + if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); + } + var name = objectName(value); if (name === "Object") { @@ -181,6 +185,10 @@ if (__DEV__) { } case "function": + if (value.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); + } + return "function"; default: @@ -226,6 +234,12 @@ if (__DEV__) { return ""; } + var CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference"); + + function describeClientReference(ref) { + return "client"; + } + function describeObjectForErrorMessage(objectOrArray, expandedName) { var objKind = objectName(objectOrArray); @@ -307,6 +321,8 @@ if (__DEV__) { } else { if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) { str = "<" + describeElementType(objectOrArray.type) + "/>"; + } else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); } else if (jsxPropsParents.has(objectOrArray)) { // Print JSX var _type = jsxPropsParents.get(objectOrArray); diff --git a/compiled/facebook-www/ReactDOMServer-dev.modern.js b/compiled/facebook-www/ReactDOMServer-dev.modern.js index 0a1c935b2b253..f40e1420c80e2 100644 --- a/compiled/facebook-www/ReactDOMServer-dev.modern.js +++ b/compiled/facebook-www/ReactDOMServer-dev.modern.js @@ -19,7 +19,7 @@ if (__DEV__) { var React = require("react"); var ReactDOM = require("react-dom"); - var ReactVersion = "18.3.0-www-modern-4fe256fb"; + var ReactVersion = "18.3.0-www-modern-2b72b29d"; // This refers to a WWW module. var warningWWW = require("warning"); @@ -171,6 +171,10 @@ if (__DEV__) { return "[...]"; } + if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); + } + var name = objectName(value); if (name === "Object") { @@ -181,6 +185,10 @@ if (__DEV__) { } case "function": + if (value.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); + } + return "function"; default: @@ -226,6 +234,12 @@ if (__DEV__) { return ""; } + var CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference"); + + function describeClientReference(ref) { + return "client"; + } + function describeObjectForErrorMessage(objectOrArray, expandedName) { var objKind = objectName(objectOrArray); @@ -307,6 +321,8 @@ if (__DEV__) { } else { if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) { str = "<" + describeElementType(objectOrArray.type) + "/>"; + } else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); } else if (jsxPropsParents.has(objectOrArray)) { // Print JSX var _type = jsxPropsParents.get(objectOrArray); diff --git a/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js b/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js index 34a5c160b4f70..ce6d85f9b6d3f 100644 --- a/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js +++ b/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js @@ -169,6 +169,10 @@ if (__DEV__) { return "[...]"; } + if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); + } + var name = objectName(value); if (name === "Object") { @@ -179,6 +183,10 @@ if (__DEV__) { } case "function": + if (value.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); + } + return "function"; default: @@ -224,6 +232,12 @@ if (__DEV__) { return ""; } + var CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference"); + + function describeClientReference(ref) { + return "client"; + } + function describeObjectForErrorMessage(objectOrArray, expandedName) { var objKind = objectName(objectOrArray); @@ -305,6 +319,8 @@ if (__DEV__) { } else { if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) { str = "<" + describeElementType(objectOrArray.type) + "/>"; + } else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); } else if (jsxPropsParents.has(objectOrArray)) { // Print JSX var _type = jsxPropsParents.get(objectOrArray); diff --git a/compiled/facebook-www/ReactDOMTesting-prod.modern.js b/compiled/facebook-www/ReactDOMTesting-prod.modern.js index d65c4b3c5f129..b0f2f6088ec91 100644 --- a/compiled/facebook-www/ReactDOMTesting-prod.modern.js +++ b/compiled/facebook-www/ReactDOMTesting-prod.modern.js @@ -17085,7 +17085,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1783 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-39d968b9", + version: "18.3.0-www-modern-448aa5e1", rendererPackageName: "react-dom" }; var internals$jscomp$inline_2154 = { @@ -17116,7 +17116,7 @@ var internals$jscomp$inline_2154 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-39d968b9" + reconcilerVersion: "18.3.0-www-modern-448aa5e1" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2155 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -17537,4 +17537,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactCurrentDispatcher$2.current.useHostTransitionStatus(); }; -exports.version = "18.3.0-www-modern-39d968b9"; +exports.version = "18.3.0-www-modern-448aa5e1"; diff --git a/compiled/facebook-www/ReactFlightDOMServer-dev.modern.js b/compiled/facebook-www/ReactFlightDOMServer-dev.modern.js index 95333856072ed..f62d54b8e72a9 100644 --- a/compiled/facebook-www/ReactFlightDOMServer-dev.modern.js +++ b/compiled/facebook-www/ReactFlightDOMServer-dev.modern.js @@ -829,6 +829,10 @@ if (__DEV__) { return "[...]"; } + if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); + } + var name = objectName(value); if (name === "Object") { @@ -839,6 +843,10 @@ if (__DEV__) { } case "function": + if (value.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); + } + return "function"; default: @@ -884,6 +892,12 @@ if (__DEV__) { return ""; } + var CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference"); + + function describeClientReference(ref) { + return "client"; + } + function describeObjectForErrorMessage(objectOrArray, expandedName) { var objKind = objectName(objectOrArray); @@ -965,6 +979,8 @@ if (__DEV__) { } else { if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) { str = "<" + describeElementType(objectOrArray.type) + "/>"; + } else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); } else if (jsxPropsParents.has(objectOrArray)) { // Print JSX var _type = jsxPropsParents.get(objectOrArray); diff --git a/compiled/facebook-www/ReactFlightDOMServer-prod.modern.js b/compiled/facebook-www/ReactFlightDOMServer-prod.modern.js index 037b4a4a64b5b..4d5095fdd2f64 100644 --- a/compiled/facebook-www/ReactFlightDOMServer-prod.modern.js +++ b/compiled/facebook-www/ReactFlightDOMServer-prod.modern.js @@ -346,10 +346,12 @@ function describeValueForErrorMessage(value) { ); case "object": if (isArrayImpl(value)) return "[...]"; + if (null !== value && value.$$typeof === CLIENT_REFERENCE_TAG) + return "client"; value = objectName(value); return "Object" === value ? "{...}" : value; case "function": - return "function"; + return value.$$typeof === CLIENT_REFERENCE_TAG ? "client" : "function"; default: return String(value); } @@ -377,6 +379,7 @@ function describeElementType(type) { } return ""; } +var CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference"); function describeObjectForErrorMessage(objectOrArray, expandedName) { var objKind = objectName(objectOrArray); if ("Object" !== objKind && "Array" !== objKind) return objKind; @@ -402,6 +405,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) { } else if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) str = "<" + describeElementType(objectOrArray.type) + "/>"; else { + if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) return "client"; str = "{"; i = Object.keys(objectOrArray); for (value = 0; value < i.length; value++) { diff --git a/compiled/facebook-www/ReactTestRenderer-dev.modern.js b/compiled/facebook-www/ReactTestRenderer-dev.modern.js index 1d67a13fe309d..4a132341ae787 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.modern.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.modern.js @@ -26067,7 +26067,7 @@ if (__DEV__) { return root; } - var ReactVersion = "18.3.0-www-modern-5300fd2b"; + var ReactVersion = "18.3.0-www-modern-f239ff56"; // Might add PROFILE later.