Skip to content

Commit

Permalink
Use the disableLegacyMode where ever we check the ConcurrentMode mode (
Browse files Browse the repository at this point in the history
…#28657)

Saves some bytes and ensures that we're actually disabling it.

Turns out this flag wasn't disabling React Native/Fabric, React Noop and
React ART legacy modes so those are updated too.

Should be rebased on #28681.

DiffTrain build for [5de8703](5de8703)
  • Loading branch information
sebmarkbage committed Apr 3, 2024
1 parent 8d925e2 commit 72e3e57
Show file tree
Hide file tree
Showing 19 changed files with 274 additions and 150 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5998a775194f491afa5d3badd9afe9ceaf12845e
5de8703646cdd3838cb1686f761b10c0692743aa
27 changes: 20 additions & 7 deletions compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (__DEV__) {
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var ReactVersion = "19.0.0-www-classic-c27d3e58";
var ReactVersion = "19.0.0-www-classic-279ec326";

// ATTENTION
// When adding new symbols to this file,
Expand Down Expand Up @@ -404,6 +404,7 @@ if (__DEV__) {
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
enableRefAsProp = dynamicFeatureFlags.enableRefAsProp;
// On WWW, false is used for a new modern build.
var disableLegacyMode = false;

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down Expand Up @@ -3281,7 +3282,10 @@ if (__DEV__) {
// triggered during an async event, because this is how the legacy
// implementation of `act` behaved.

ReactCurrentActQueue.isBatchingLegacy = true;
{
ReactCurrentActQueue.isBatchingLegacy = true;
}

var result; // This tracks whether the `act` call is awaited. In certain cases, not
// awaiting it is a mistake, so we will detect that and warn.

Expand All @@ -3291,10 +3295,14 @@ if (__DEV__) {
// Reset this to `false` right before entering the React work loop. The
// only place we ever read this fields is just below, right after running
// the callback. So we don't need to reset after the callback runs.
ReactCurrentActQueue.didScheduleLegacyUpdate = false;
if (!disableLegacyMode) {
ReactCurrentActQueue.didScheduleLegacyUpdate = false;
}

result = callback();
var didScheduleLegacyUpdate =
ReactCurrentActQueue.didScheduleLegacyUpdate; // Replicate behavior of original `act` implementation in legacy mode,
var didScheduleLegacyUpdate = !disableLegacyMode
? ReactCurrentActQueue.didScheduleLegacyUpdate
: false; // Replicate behavior of original `act` implementation in legacy mode,
// which flushed updates immediately after the scope function exits, even
// if it's an async function.

Expand All @@ -3305,7 +3313,9 @@ if (__DEV__) {
// that's how it worked before version 18. Yes, it's confusing! We should
// delete legacy mode!!

ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
if (!disableLegacyMode) {
ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
}
} catch (error) {
// `isBatchingLegacy` gets reset using the regular stack, not the async
// one used to track `act` scopes. Why, you may be wondering? Because
Expand All @@ -3315,7 +3325,10 @@ if (__DEV__) {
}

if (ReactCurrentActQueue.thrownErrors.length > 0) {
ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
{
ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
}

popActScope(prevActQueue, prevActScopeDepth);
var thrownError = aggregateErrors(ReactCurrentActQueue.thrownErrors);
ReactCurrentActQueue.thrownErrors.length = 0;
Expand Down
27 changes: 20 additions & 7 deletions compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (__DEV__) {
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var ReactVersion = "19.0.0-www-modern-5ccfe516";
var ReactVersion = "19.0.0-www-modern-e4b79a21";

// ATTENTION
// When adding new symbols to this file,
Expand Down Expand Up @@ -404,6 +404,7 @@ if (__DEV__) {
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
enableRefAsProp = dynamicFeatureFlags.enableRefAsProp;
// On WWW, true is used for a new modern build.
var disableLegacyMode = false;

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down Expand Up @@ -3281,7 +3282,10 @@ if (__DEV__) {
// triggered during an async event, because this is how the legacy
// implementation of `act` behaved.

ReactCurrentActQueue.isBatchingLegacy = true;
{
ReactCurrentActQueue.isBatchingLegacy = true;
}

var result; // This tracks whether the `act` call is awaited. In certain cases, not
// awaiting it is a mistake, so we will detect that and warn.

Expand All @@ -3291,10 +3295,14 @@ if (__DEV__) {
// Reset this to `false` right before entering the React work loop. The
// only place we ever read this fields is just below, right after running
// the callback. So we don't need to reset after the callback runs.
ReactCurrentActQueue.didScheduleLegacyUpdate = false;
if (!disableLegacyMode) {
ReactCurrentActQueue.didScheduleLegacyUpdate = false;
}

result = callback();
var didScheduleLegacyUpdate =
ReactCurrentActQueue.didScheduleLegacyUpdate; // Replicate behavior of original `act` implementation in legacy mode,
var didScheduleLegacyUpdate = !disableLegacyMode
? ReactCurrentActQueue.didScheduleLegacyUpdate
: false; // Replicate behavior of original `act` implementation in legacy mode,
// which flushed updates immediately after the scope function exits, even
// if it's an async function.

Expand All @@ -3305,7 +3313,9 @@ if (__DEV__) {
// that's how it worked before version 18. Yes, it's confusing! We should
// delete legacy mode!!

ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
if (!disableLegacyMode) {
ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
}
} catch (error) {
// `isBatchingLegacy` gets reset using the regular stack, not the async
// one used to track `act` scopes. Why, you may be wondering? Because
Expand All @@ -3315,7 +3325,10 @@ if (__DEV__) {
}

if (ReactCurrentActQueue.thrownErrors.length > 0) {
ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
{
ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
}

popActScope(prevActQueue, prevActScopeDepth);
var thrownError = aggregateErrors(ReactCurrentActQueue.thrownErrors);
ReactCurrentActQueue.thrownErrors.length = 0;
Expand Down
38 changes: 25 additions & 13 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (__DEV__) {
return self;
}

var ReactVersion = "19.0.0-www-classic-1a37f8de";
var ReactVersion = "19.0.0-www-classic-e7863b04";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -195,6 +195,7 @@ if (__DEV__) {
var enableAsyncActions = true;

var enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler;
var disableLegacyMode = false;

var FunctionComponent = 0;
var ClassComponent = 1;
Expand Down Expand Up @@ -490,11 +491,15 @@ if (__DEV__) {

case TracingMarkerComponent:
return "TracingMarker";
// The display name for this tags come from the user-provided type:
// The display name for these tags come from the user-provided type:

case IncompleteClassComponent:
case IncompleteFunctionComponent:

// Fallthrough

case ClassComponent:
case FunctionComponent:
case IncompleteClassComponent:
case MemoComponent:
case SimpleMemoComponent:
if (typeof type === "function") {
Expand Down Expand Up @@ -4749,7 +4754,9 @@ if (__DEV__) {
function flushSyncWorkOnLegacyRootsOnly() {
// This is allowed to be called synchronously, but the caller should check
// the execution context first.
flushSyncWorkAcrossRoots_impl(true);
{
flushSyncWorkAcrossRoots_impl(true);
}
}

function flushSyncWorkAcrossRoots_impl(onlyLegacy) {
Expand Down Expand Up @@ -20490,10 +20497,11 @@ if (__DEV__) {
var newProps = workInProgress.pendingProps; // Note: This intentionally doesn't check if we're hydrating because comparing

switch (workInProgress.tag) {
case IncompleteFunctionComponent:

case LazyComponent:
case SimpleMemoComponent:
case FunctionComponent:
case IncompleteFunctionComponent:
case ForwardRef:
case Fragment:
case Mode:
Expand Down Expand Up @@ -20849,8 +20857,8 @@ if (__DEV__) {
return null;

case IncompleteClassComponent: {
// Same as class component case. I put it down here so that the tags are
// sequential to ensure this switch is compiled to a jump table.

var _Component = workInProgress.type;

if (isContextProvider(_Component)) {
Expand Down Expand Up @@ -26221,6 +26229,7 @@ if (__DEV__) {
if (
lane === SyncLane &&
executionContext === NoContext &&
!disableLegacyMode &&
(fiber.mode & ConcurrentMode) === NoMode
) {
if (ReactCurrentActQueue.isBatchingLegacy);
Expand Down Expand Up @@ -26789,6 +26798,7 @@ if (__DEV__) {
// next event, not at the end of the previous one.
if (
rootWithPendingPassiveEffects !== null &&
!disableLegacyMode &&
rootWithPendingPassiveEffects.tag === LegacyRoot &&
(executionContext & (RenderContext | CommitContext)) === NoContext
) {
Expand Down Expand Up @@ -30427,14 +30437,16 @@ if (__DEV__) {
}

{
switch (tag) {
case ConcurrentRoot:
this._debugRootType = hydrate ? "hydrateRoot()" : "createRoot()";
break;
{
switch (tag) {
case ConcurrentRoot:
this._debugRootType = hydrate ? "hydrateRoot()" : "createRoot()";
break;

case LegacyRoot:
this._debugRootType = hydrate ? "hydrate()" : "render()";
break;
case LegacyRoot:
this._debugRootType = hydrate ? "hydrate()" : "render()";
break;
}
}
}
}
Expand Down
36 changes: 24 additions & 12 deletions compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (__DEV__) {
return self;
}

var ReactVersion = "19.0.0-www-modern-d5826a7d";
var ReactVersion = "19.0.0-www-modern-f0fe1a8a";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -195,6 +195,7 @@ if (__DEV__) {
var enableAsyncActions = true;

var enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler;
var disableLegacyMode = false;

var FunctionComponent = 0;
var ClassComponent = 1;
Expand Down Expand Up @@ -490,11 +491,15 @@ if (__DEV__) {

case TracingMarkerComponent:
return "TracingMarker";
// The display name for this tags come from the user-provided type:
// The display name for these tags come from the user-provided type:

case IncompleteClassComponent:
case IncompleteFunctionComponent:

// Fallthrough

case ClassComponent:
case FunctionComponent:
case IncompleteClassComponent:
case MemoComponent:
case SimpleMemoComponent:
if (typeof type === "function") {
Expand Down Expand Up @@ -4514,7 +4519,9 @@ if (__DEV__) {
function flushSyncWorkOnLegacyRootsOnly() {
// This is allowed to be called synchronously, but the caller should check
// the execution context first.
flushSyncWorkAcrossRoots_impl(true);
{
flushSyncWorkAcrossRoots_impl(true);
}
}

function flushSyncWorkAcrossRoots_impl(onlyLegacy) {
Expand Down Expand Up @@ -20185,10 +20192,11 @@ if (__DEV__) {
var newProps = workInProgress.pendingProps; // Note: This intentionally doesn't check if we're hydrating because comparing

switch (workInProgress.tag) {
case IncompleteFunctionComponent:

case LazyComponent:
case SimpleMemoComponent:
case FunctionComponent:
case IncompleteFunctionComponent:
case ForwardRef:
case Fragment:
case Mode:
Expand Down Expand Up @@ -25887,6 +25895,7 @@ if (__DEV__) {
if (
lane === SyncLane &&
executionContext === NoContext &&
!disableLegacyMode &&
(fiber.mode & ConcurrentMode) === NoMode
) {
if (ReactCurrentActQueue.isBatchingLegacy);
Expand Down Expand Up @@ -26455,6 +26464,7 @@ if (__DEV__) {
// next event, not at the end of the previous one.
if (
rootWithPendingPassiveEffects !== null &&
!disableLegacyMode &&
rootWithPendingPassiveEffects.tag === LegacyRoot &&
(executionContext & (RenderContext | CommitContext)) === NoContext
) {
Expand Down Expand Up @@ -30084,14 +30094,16 @@ if (__DEV__) {
}

{
switch (tag) {
case ConcurrentRoot:
this._debugRootType = hydrate ? "hydrateRoot()" : "createRoot()";
break;
{
switch (tag) {
case ConcurrentRoot:
this._debugRootType = hydrate ? "hydrateRoot()" : "createRoot()";
break;

case LegacyRoot:
this._debugRootType = hydrate ? "hydrate()" : "render()";
break;
case LegacyRoot:
this._debugRootType = hydrate ? "hydrate()" : "render()";
break;
}
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions compiled/facebook-www/ReactART-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,10 @@ function getComponentNameFromFiber(fiber) {
return "SuspenseList";
case 25:
return "TracingMarker";
case 17:
case 28:
case 1:
case 0:
case 17:
case 14:
case 15:
if ("function" === typeof type)
Expand Down Expand Up @@ -6537,10 +6538,10 @@ function bubbleProperties(completedWork) {
function completeWork(current, workInProgress, renderLanes) {
var newProps = workInProgress.pendingProps;
switch (workInProgress.tag) {
case 28:
case 16:
case 15:
case 0:
case 28:
case 11:
case 7:
case 8:
Expand Down Expand Up @@ -10649,7 +10650,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "19.0.0-www-classic-da81c41b",
version: "19.0.0-www-classic-d150a248",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1308 = {
Expand Down Expand Up @@ -10680,7 +10681,7 @@ var internals$jscomp$inline_1308 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-classic-da81c41b"
reconcilerVersion: "19.0.0-www-classic-d150a248"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1309 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Loading

0 comments on commit 72e3e57

Please sign in to comment.