Skip to content

Commit

Permalink
Enable Wave 1 of Feature Flags for React Native (#28977)
Browse files Browse the repository at this point in the history
DiffTrain build for commit 1d618a9.
  • Loading branch information
yungsters committed May 3, 2024
1 parent 0cb0be9 commit 5326299
Show file tree
Hide file tree
Showing 18 changed files with 2,065 additions and 2,194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<67ecfa6f3ffb08a7102950c78e1002d4>>
* @generated SignedSource<<cc5ff8fe75f7cb7812ce459378d61959>>
*/

'use strict';
Expand All @@ -16,15 +16,9 @@ if (__DEV__) {
(function() {
'use strict';

var dynamicFlagsUntyped = require('ReactNativeInternalFeatureFlags');

// Re-export dynamic flags from the internal module.
var dynamicFlags = dynamicFlagsUntyped; // We destructure each value before re-exporting to avoid a dynamic look-up on
// the exports object every time a flag is read.

var enableRenderableContext = dynamicFlags.enableRenderableContext;
// The rest of the flags are static for better dead code elimination.
var enableDebugTracing = false;
var enableRenderableContext = true;
var enableScopeAPI = false;
var enableLegacyHidden = false;
var enableTransitionTracing = false;
Expand Down Expand Up @@ -62,7 +56,7 @@ function isValidElementType(type) {
}

if (typeof type === 'object' && type !== null) {
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || !enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE || enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || !enableRenderableContext || type.$$typeof === REACT_CONSUMER_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
// types supported by any Flight configuration anywhere since
// we don't know which Flight build this will end up being used
// with.
Expand Down Expand Up @@ -101,16 +95,13 @@ function typeOf(object) {
return $$typeofType;

case REACT_CONSUMER_TYPE:
if (enableRenderableContext) {
{
return $$typeofType;
}

// Fall through

case REACT_PROVIDER_TYPE:
if (!enableRenderableContext) {
return $$typeofType;
}

// Fall through

Expand All @@ -127,8 +118,8 @@ function typeOf(object) {

return undefined;
}
var ContextConsumer = enableRenderableContext ? REACT_CONSUMER_TYPE : REACT_CONTEXT_TYPE;
var ContextProvider = enableRenderableContext ? REACT_CONTEXT_TYPE : REACT_PROVIDER_TYPE;
var ContextConsumer = REACT_CONSUMER_TYPE ;
var ContextProvider = REACT_CONTEXT_TYPE ;
var Element = REACT_ELEMENT_TYPE;
var ForwardRef = REACT_FORWARD_REF_TYPE;
var Fragment = REACT_FRAGMENT_TYPE;
Expand All @@ -140,17 +131,13 @@ var StrictMode = REACT_STRICT_MODE_TYPE;
var Suspense = REACT_SUSPENSE_TYPE;
var SuspenseList = REACT_SUSPENSE_LIST_TYPE;
function isContextConsumer(object) {
if (enableRenderableContext) {
{
return typeOf(object) === REACT_CONSUMER_TYPE;
} else {
return typeOf(object) === REACT_CONTEXT_TYPE;
}
}
function isContextProvider(object) {
if (enableRenderableContext) {
{
return typeOf(object) === REACT_CONTEXT_TYPE;
} else {
return typeOf(object) === REACT_PROVIDER_TYPE;
}
}
function isElement(object) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<a2ec93969192b62fe71f0ed10a25ef77>>
* @generated SignedSource<<b5f0f82fdd9d6e3043c1259e7ffcf255>>
*/

"use strict";
var enableRenderableContext =
require("ReactNativeInternalFeatureFlags").enableRenderableContext,
REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
REACT_PROVIDER_TYPE = Symbol.for("react.provider"),
REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
REACT_PROFILER_TYPE = Symbol.for("react.profiler");
Symbol.for("react.provider");
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
Expand Down Expand Up @@ -48,9 +46,7 @@ function typeOf(object) {
case REACT_MEMO_TYPE:
return object;
case REACT_CONSUMER_TYPE:
if (enableRenderableContext) return object;
case REACT_PROVIDER_TYPE:
if (!enableRenderableContext) return object;
return object;
default:
return $$typeof;
}
Expand All @@ -60,13 +56,8 @@ function typeOf(object) {
}
}
}
var ContextProvider = enableRenderableContext
? REACT_CONTEXT_TYPE
: REACT_PROVIDER_TYPE;
exports.ContextConsumer = enableRenderableContext
? REACT_CONSUMER_TYPE
: REACT_CONTEXT_TYPE;
exports.ContextProvider = ContextProvider;
exports.ContextConsumer = REACT_CONSUMER_TYPE;
exports.ContextProvider = REACT_CONTEXT_TYPE;
exports.Element = REACT_LEGACY_ELEMENT_TYPE;
exports.ForwardRef = REACT_FORWARD_REF_TYPE;
exports.Fragment = REACT_FRAGMENT_TYPE;
Expand All @@ -78,14 +69,10 @@ exports.StrictMode = REACT_STRICT_MODE_TYPE;
exports.Suspense = REACT_SUSPENSE_TYPE;
exports.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
exports.isContextConsumer = function (object) {
return enableRenderableContext
? typeOf(object) === REACT_CONSUMER_TYPE
: typeOf(object) === REACT_CONTEXT_TYPE;
return typeOf(object) === REACT_CONSUMER_TYPE;
};
exports.isContextProvider = function (object) {
return enableRenderableContext
? typeOf(object) === REACT_CONTEXT_TYPE
: typeOf(object) === REACT_PROVIDER_TYPE;
return typeOf(object) === REACT_CONTEXT_TYPE;
};
exports.isElement = function (object) {
return (
Expand Down Expand Up @@ -135,8 +122,7 @@ exports.isValidElementType = function (type) {
(type.$$typeof === REACT_LAZY_TYPE ||
type.$$typeof === REACT_MEMO_TYPE ||
type.$$typeof === REACT_CONTEXT_TYPE ||
(!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) ||
(enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) ||
type.$$typeof === REACT_CONSUMER_TYPE ||
type.$$typeof === REACT_FORWARD_REF_TYPE ||
type.$$typeof === REACT_CLIENT_REFERENCE ||
void 0 !== type.getModuleId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<a2ec93969192b62fe71f0ed10a25ef77>>
* @generated SignedSource<<b5f0f82fdd9d6e3043c1259e7ffcf255>>
*/

"use strict";
var enableRenderableContext =
require("ReactNativeInternalFeatureFlags").enableRenderableContext,
REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
REACT_PROVIDER_TYPE = Symbol.for("react.provider"),
REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
REACT_PROFILER_TYPE = Symbol.for("react.profiler");
Symbol.for("react.provider");
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
Expand Down Expand Up @@ -48,9 +46,7 @@ function typeOf(object) {
case REACT_MEMO_TYPE:
return object;
case REACT_CONSUMER_TYPE:
if (enableRenderableContext) return object;
case REACT_PROVIDER_TYPE:
if (!enableRenderableContext) return object;
return object;
default:
return $$typeof;
}
Expand All @@ -60,13 +56,8 @@ function typeOf(object) {
}
}
}
var ContextProvider = enableRenderableContext
? REACT_CONTEXT_TYPE
: REACT_PROVIDER_TYPE;
exports.ContextConsumer = enableRenderableContext
? REACT_CONSUMER_TYPE
: REACT_CONTEXT_TYPE;
exports.ContextProvider = ContextProvider;
exports.ContextConsumer = REACT_CONSUMER_TYPE;
exports.ContextProvider = REACT_CONTEXT_TYPE;
exports.Element = REACT_LEGACY_ELEMENT_TYPE;
exports.ForwardRef = REACT_FORWARD_REF_TYPE;
exports.Fragment = REACT_FRAGMENT_TYPE;
Expand All @@ -78,14 +69,10 @@ exports.StrictMode = REACT_STRICT_MODE_TYPE;
exports.Suspense = REACT_SUSPENSE_TYPE;
exports.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
exports.isContextConsumer = function (object) {
return enableRenderableContext
? typeOf(object) === REACT_CONSUMER_TYPE
: typeOf(object) === REACT_CONTEXT_TYPE;
return typeOf(object) === REACT_CONSUMER_TYPE;
};
exports.isContextProvider = function (object) {
return enableRenderableContext
? typeOf(object) === REACT_CONTEXT_TYPE
: typeOf(object) === REACT_PROVIDER_TYPE;
return typeOf(object) === REACT_CONTEXT_TYPE;
};
exports.isElement = function (object) {
return (
Expand Down Expand Up @@ -135,8 +122,7 @@ exports.isValidElementType = function (type) {
(type.$$typeof === REACT_LAZY_TYPE ||
type.$$typeof === REACT_MEMO_TYPE ||
type.$$typeof === REACT_CONTEXT_TYPE ||
(!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) ||
(enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) ||
type.$$typeof === REACT_CONSUMER_TYPE ||
type.$$typeof === REACT_FORWARD_REF_TYPE ||
type.$$typeof === REACT_CLIENT_REFERENCE ||
void 0 !== type.getModuleId))
Expand Down
Loading

0 comments on commit 5326299

Please sign in to comment.