Skip to content

Commit

Permalink
[flags] Clean up scheduler flags (facebook#31814)
Browse files Browse the repository at this point in the history
These flags are hardcoded now, we can make them static.

DiffTrain build for [d428725](facebook@d428725)
  • Loading branch information
22388o committed Dec 17, 2024
1 parent 463f1f4 commit b320492
Show file tree
Hide file tree
Showing 54 changed files with 9,795 additions and 11,485 deletions.
93 changes: 79 additions & 14 deletions compiled/facebook-www/JSXDEVRuntime-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ __DEV__ &&
if ("object" === typeof type)
switch (type.$$typeof) {
case REACT_FORWARD_REF_TYPE:
return (type = describeNativeComponentFrame(type.render, !1)), type;
return describeNativeComponentFrame(type.render, !1);
case REACT_MEMO_TYPE:
return describeUnknownElementTypeFrameInDEV(type.type);
case REACT_LAZY_TYPE:
Expand All @@ -373,6 +373,21 @@ __DEV__ &&
}
return "";
}
function getTaskName(type) {
if (type === REACT_FRAGMENT_TYPE) return "<>";
if (
"object" === typeof type &&
null !== type &&
type.$$typeof === REACT_LAZY_TYPE
)
return "<...>";
try {
var name = getComponentNameFromType(type);
return name ? "<" + name + ">" : "<...>";
} catch (x) {
return "<...>";
}
}
function getOwner() {
var dispatcher = ReactSharedInternals.A;
return null === dispatcher ? null : dispatcher.getOwner();
Expand Down Expand Up @@ -409,7 +424,16 @@ __DEV__ &&
componentName = this.props.ref;
return void 0 !== componentName ? componentName : null;
}
function ReactElement(type, key, self, source, owner, props) {
function ReactElement(
type,
key,
self,
source,
owner,
props,
debugStack,
debugTask
) {
self = props.ref;
type = {
$$typeof: REACT_ELEMENT_TYPE,
Expand Down Expand Up @@ -437,6 +461,19 @@ __DEV__ &&
writable: !0,
value: null
});
enableOwnerStacks &&
(Object.defineProperty(type, "_debugStack", {
configurable: !1,
enumerable: !1,
writable: !0,
value: debugStack
}),
Object.defineProperty(type, "_debugTask", {
configurable: !1,
enumerable: !1,
writable: !0,
value: debugTask
}));
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
return type;
}
Expand All @@ -446,14 +483,16 @@ __DEV__ &&
maybeKey,
isStaticChildren,
source,
self
self,
debugStack,
debugTask
) {
if (
enableOwnerStacks ||
"string" === typeof type ||
"function" === typeof type ||
type === REACT_FRAGMENT_TYPE ||
type === REACT_PROFILER_TYPE ||
(enableDebugTracing && type === REACT_DEBUG_TRACING_MODE_TYPE) ||
type === REACT_STRICT_MODE_TYPE ||
type === REACT_SUSPENSE_TYPE ||
type === REACT_SUSPENSE_LIST_TYPE ||
Expand Down Expand Up @@ -562,10 +601,21 @@ __DEV__ &&
? type.displayName || type.name || "Unknown"
: type
);
return ReactElement(type, children, self, source, getOwner(), maybeKey);
return ReactElement(
type,
children,
self,
source,
getOwner(),
maybeKey,
debugStack,
debugTask
);
}
function validateChildKeys(node, parentType) {
if (
if (enableOwnerStacks)
isValidElement(node) && node._store && (node._store.validated = 1);
else if (
"object" === typeof node &&
node &&
node.$$typeof !== REACT_CLIENT_REFERENCE
Expand Down Expand Up @@ -601,6 +651,7 @@ __DEV__ &&
}
function validateExplicitKey(element, parentType) {
if (
!enableOwnerStacks &&
element._store &&
!element._store.validated &&
null == element.key &&
Expand Down Expand Up @@ -649,14 +700,14 @@ __DEV__ &&
dynamicFeatureFlags = require("ReactFeatureFlags"),
disableDefaultPropsExceptForClasses =
dynamicFeatureFlags.disableDefaultPropsExceptForClasses,
enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing;
dynamicFeatureFlags = dynamicFeatureFlags.renameElementSymbol;
var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_ELEMENT_TYPE = dynamicFeatureFlags
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
renameElementSymbol = dynamicFeatureFlags.renameElementSymbol,
enableOwnerStacks = dynamicFeatureFlags.enableOwnerStacks;
dynamicFeatureFlags = Symbol.for("react.element");
var REACT_ELEMENT_TYPE = renameElementSymbol
? Symbol.for("react.transitional.element")
: REACT_LEGACY_ELEMENT_TYPE,
: dynamicFeatureFlags,
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
Expand All @@ -670,7 +721,6 @@ __DEV__ &&
REACT_MEMO_TYPE = Symbol.for("react.memo"),
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
REACT_SCOPE_TYPE = Symbol.for("react.scope"),
REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for("react.debug_trace_mode"),
REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen"),
REACT_LEGACY_HIDDEN_TYPE = Symbol.for("react.legacy_hidden"),
REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker"),
Expand Down Expand Up @@ -699,6 +749,12 @@ __DEV__ &&
"function" === typeof WeakMap ? WeakMap : Map
)();
var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
createTask =
enableOwnerStacks && console.createTask
? console.createTask
: function () {
return null;
},
specialPropKeyWarningShown;
var didWarnAboutElementRef = {};
var didWarnAboutKeySpread = {},
Expand All @@ -712,6 +768,15 @@ __DEV__ &&
source,
self
) {
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
return jsxDEVImpl(
type,
config,
maybeKey,
isStaticChildren,
source,
self,
enableOwnerStacks ? Error("react-stack-top-frame") : void 0,
enableOwnerStacks ? createTask(getTaskName(type)) : void 0
);
};
})();
93 changes: 79 additions & 14 deletions compiled/facebook-www/JSXDEVRuntime-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ __DEV__ &&
if ("object" === typeof type)
switch (type.$$typeof) {
case REACT_FORWARD_REF_TYPE:
return (type = describeNativeComponentFrame(type.render, !1)), type;
return describeNativeComponentFrame(type.render, !1);
case REACT_MEMO_TYPE:
return describeUnknownElementTypeFrameInDEV(type.type);
case REACT_LAZY_TYPE:
Expand All @@ -373,6 +373,21 @@ __DEV__ &&
}
return "";
}
function getTaskName(type) {
if (type === REACT_FRAGMENT_TYPE) return "<>";
if (
"object" === typeof type &&
null !== type &&
type.$$typeof === REACT_LAZY_TYPE
)
return "<...>";
try {
var name = getComponentNameFromType(type);
return name ? "<" + name + ">" : "<...>";
} catch (x) {
return "<...>";
}
}
function getOwner() {
var dispatcher = ReactSharedInternals.A;
return null === dispatcher ? null : dispatcher.getOwner();
Expand Down Expand Up @@ -409,7 +424,16 @@ __DEV__ &&
componentName = this.props.ref;
return void 0 !== componentName ? componentName : null;
}
function ReactElement(type, key, self, source, owner, props) {
function ReactElement(
type,
key,
self,
source,
owner,
props,
debugStack,
debugTask
) {
self = props.ref;
type = {
$$typeof: REACT_ELEMENT_TYPE,
Expand Down Expand Up @@ -437,6 +461,19 @@ __DEV__ &&
writable: !0,
value: null
});
enableOwnerStacks &&
(Object.defineProperty(type, "_debugStack", {
configurable: !1,
enumerable: !1,
writable: !0,
value: debugStack
}),
Object.defineProperty(type, "_debugTask", {
configurable: !1,
enumerable: !1,
writable: !0,
value: debugTask
}));
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
return type;
}
Expand All @@ -446,14 +483,16 @@ __DEV__ &&
maybeKey,
isStaticChildren,
source,
self
self,
debugStack,
debugTask
) {
if (
enableOwnerStacks ||
"string" === typeof type ||
"function" === typeof type ||
type === REACT_FRAGMENT_TYPE ||
type === REACT_PROFILER_TYPE ||
(enableDebugTracing && type === REACT_DEBUG_TRACING_MODE_TYPE) ||
type === REACT_STRICT_MODE_TYPE ||
type === REACT_SUSPENSE_TYPE ||
type === REACT_SUSPENSE_LIST_TYPE ||
Expand Down Expand Up @@ -562,10 +601,21 @@ __DEV__ &&
? type.displayName || type.name || "Unknown"
: type
);
return ReactElement(type, children, self, source, getOwner(), maybeKey);
return ReactElement(
type,
children,
self,
source,
getOwner(),
maybeKey,
debugStack,
debugTask
);
}
function validateChildKeys(node, parentType) {
if (
if (enableOwnerStacks)
isValidElement(node) && node._store && (node._store.validated = 1);
else if (
"object" === typeof node &&
node &&
node.$$typeof !== REACT_CLIENT_REFERENCE
Expand Down Expand Up @@ -601,6 +651,7 @@ __DEV__ &&
}
function validateExplicitKey(element, parentType) {
if (
!enableOwnerStacks &&
element._store &&
!element._store.validated &&
null == element.key &&
Expand Down Expand Up @@ -649,14 +700,14 @@ __DEV__ &&
dynamicFeatureFlags = require("ReactFeatureFlags"),
disableDefaultPropsExceptForClasses =
dynamicFeatureFlags.disableDefaultPropsExceptForClasses,
enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing;
dynamicFeatureFlags = dynamicFeatureFlags.renameElementSymbol;
var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_ELEMENT_TYPE = dynamicFeatureFlags
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
renameElementSymbol = dynamicFeatureFlags.renameElementSymbol,
enableOwnerStacks = dynamicFeatureFlags.enableOwnerStacks;
dynamicFeatureFlags = Symbol.for("react.element");
var REACT_ELEMENT_TYPE = renameElementSymbol
? Symbol.for("react.transitional.element")
: REACT_LEGACY_ELEMENT_TYPE,
: dynamicFeatureFlags,
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
Expand All @@ -670,7 +721,6 @@ __DEV__ &&
REACT_MEMO_TYPE = Symbol.for("react.memo"),
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
REACT_SCOPE_TYPE = Symbol.for("react.scope"),
REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for("react.debug_trace_mode"),
REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen"),
REACT_LEGACY_HIDDEN_TYPE = Symbol.for("react.legacy_hidden"),
REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker"),
Expand Down Expand Up @@ -699,6 +749,12 @@ __DEV__ &&
"function" === typeof WeakMap ? WeakMap : Map
)();
var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
createTask =
enableOwnerStacks && console.createTask
? console.createTask
: function () {
return null;
},
specialPropKeyWarningShown;
var didWarnAboutElementRef = {};
var didWarnAboutKeySpread = {},
Expand All @@ -712,6 +768,15 @@ __DEV__ &&
source,
self
) {
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
return jsxDEVImpl(
type,
config,
maybeKey,
isStaticChildren,
source,
self,
enableOwnerStacks ? Error("react-stack-top-frame") : void 0,
enableOwnerStacks ? createTask(getTaskName(type)) : void 0
);
};
})();
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7283a213dbbc31029e65005276f12202558558fc
d42872588282b9eef56b8fa02441b33d596fd197
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7283a213dbbc31029e65005276f12202558558fc
d42872588282b9eef56b8fa02441b33d596fd197
Loading

0 comments on commit b320492

Please sign in to comment.