Skip to content

Commit deede8d

Browse files
committed
Flatten ReactSharedInternals (#28783)
This is similar to #28771 but for isomorphic. We need a make over for these dispatchers anyway so this is the first step. Also helps flush out some internals usage that will break anyway. It flattens the inner mutable objects onto the ReactSharedInternals. DiffTrain build for commit d50323e.
1 parent d629d07 commit deede8d

17 files changed

+951
-1186
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 149 additions & 180 deletions
Large diffs are not rendered by default.

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js

Lines changed: 51 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<493cdb9fbf258eb499287015c0434886>>
10+
* @generated SignedSource<<87f2bb9cd01d048068daf2853de59b90>>
1111
*/
1212

1313
"use strict";
@@ -2133,9 +2133,7 @@ function findFirstSuspended(row) {
21332133
}
21342134
return null;
21352135
}
2136-
var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
2137-
ReactCurrentBatchConfig$2 = ReactSharedInternals.ReactCurrentBatchConfig,
2138-
renderLanes = 0,
2136+
var renderLanes = 0,
21392137
currentlyRenderingFiber$1 = null,
21402138
currentHook = null,
21412139
workInProgressHook = null,
@@ -2169,7 +2167,7 @@ function renderWithHooks(
21692167
workInProgress.memoizedState = null;
21702168
workInProgress.updateQueue = null;
21712169
workInProgress.lanes = 0;
2172-
ReactCurrentDispatcher$1.current =
2170+
ReactSharedInternals.H =
21732171
null === current || null === current.memoizedState
21742172
? HooksDispatcherOnMount
21752173
: HooksDispatcherOnUpdate;
@@ -2187,7 +2185,7 @@ function renderWithHooks(
21872185
return current;
21882186
}
21892187
function finishRenderingHooks() {
2190-
ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
2188+
ReactSharedInternals.H = ContextOnlyDispatcher;
21912189
var didRenderTooFewHooks = null !== currentHook && null !== currentHook.next;
21922190
renderLanes = 0;
21932191
workInProgressHook = currentHook = currentlyRenderingFiber$1 = null;
@@ -2213,13 +2211,13 @@ function renderWithHooksAgain(workInProgress, Component, props, secondArg) {
22132211
numberOfReRenders += 1;
22142212
workInProgressHook = currentHook = null;
22152213
workInProgress.updateQueue = null;
2216-
ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender;
2214+
ReactSharedInternals.H = HooksDispatcherOnRerender;
22172215
var children = Component(props, secondArg);
22182216
} while (didScheduleRenderPhaseUpdateDuringThisPass);
22192217
return children;
22202218
}
22212219
function TransitionAwareHostComponent() {
2222-
var maybeThenable = ReactCurrentDispatcher$1.current.useState()[0];
2220+
var maybeThenable = ReactSharedInternals.H.useState()[0];
22232221
return "function" === typeof maybeThenable.then
22242222
? useThenable(maybeThenable)
22252223
: maybeThenable;
@@ -2310,7 +2308,7 @@ function useThenable(thenable) {
23102308
(null === workInProgressHook
23112309
? null === currentlyRenderingFiber$1.memoizedState
23122310
: null === workInProgressHook.next) &&
2313-
(ReactCurrentDispatcher$1.current = HooksDispatcherOnMount);
2311+
(ReactSharedInternals.H = HooksDispatcherOnMount);
23142312
return thenable;
23152313
}
23162314
function use(usable) {
@@ -2610,9 +2608,9 @@ function dispatchActionState(
26102608
function runActionStateAction(actionQueue, setPendingState, setState, payload) {
26112609
var action = actionQueue.action,
26122610
prevState = actionQueue.state,
2613-
prevTransition = ReactCurrentBatchConfig$2.transition,
2611+
prevTransition = ReactSharedInternals.T,
26142612
currentTransition = { _callbacks: new Set() };
2615-
ReactCurrentBatchConfig$2.transition = currentTransition;
2613+
ReactSharedInternals.T = currentTransition;
26162614
setPendingState(!0);
26172615
try {
26182616
var returnValue = action(prevState, payload);
@@ -2645,7 +2643,7 @@ function runActionStateAction(actionQueue, setPendingState, setState, payload) {
26452643
setState({ then: function () {}, status: "rejected", reason: error }),
26462644
finishRunningActionStateAction(actionQueue, setPendingState, setState);
26472645
} finally {
2648-
ReactCurrentBatchConfig$2.transition = prevTransition;
2646+
ReactSharedInternals.T = prevTransition;
26492647
}
26502648
}
26512649
function finishRunningActionStateAction(
@@ -2882,9 +2880,9 @@ function startTransition(fiber, queue, pendingState, finishedState, callback) {
28822880
var previousPriority = currentUpdatePriority;
28832881
currentUpdatePriority =
28842882
0 !== previousPriority && 8 > previousPriority ? previousPriority : 8;
2885-
var prevTransition = ReactCurrentBatchConfig$2.transition,
2883+
var prevTransition = ReactSharedInternals.T,
28862884
currentTransition = { _callbacks: new Set() };
2887-
ReactCurrentBatchConfig$2.transition = currentTransition;
2885+
ReactSharedInternals.T = currentTransition;
28882886
dispatchOptimisticSetState(fiber, !1, queue, pendingState);
28892887
try {
28902888
var returnValue = callback();
@@ -2908,7 +2906,7 @@ function startTransition(fiber, queue, pendingState, finishedState, callback) {
29082906
});
29092907
} finally {
29102908
(currentUpdatePriority = previousPriority),
2911-
(ReactCurrentBatchConfig$2.transition = prevTransition);
2909+
(ReactSharedInternals.T = prevTransition);
29122910
}
29132911
}
29142912
function useHostTransitionStatus() {
@@ -3744,8 +3742,7 @@ function throwException(
37443742
} while (null !== returnFiber);
37453743
return !1;
37463744
}
3747-
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner,
3748-
SelectiveHydrationException = Error(
3745+
var SelectiveHydrationException = Error(
37493746
"This is not a real error. It's an implementation detail of React's selective hydration feature. If this leaks into userspace, it's a bug in React. Please file an issue."
37503747
),
37513748
didReceiveUpdate = !1;
@@ -4242,7 +4239,7 @@ function finishClassComponent(
42424239
bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes)
42434240
);
42444241
shouldUpdate = workInProgress.stateNode;
4245-
ReactCurrentOwner$1.current = workInProgress;
4242+
ReactSharedInternals.owner = workInProgress;
42464243
var nextChildren =
42474244
didCaptureError && "function" !== typeof Component.getDerivedStateFromError
42484245
? null
@@ -5438,9 +5435,8 @@ function releaseCache(cache) {
54385435
cache.controller.abort();
54395436
});
54405437
}
5441-
var ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
54425438
function requestCurrentTransition() {
5443-
var transition = ReactCurrentBatchConfig$1.transition;
5439+
var transition = ReactSharedInternals.T;
54445440
null !== transition && transition._callbacks.add(handleAsyncAction);
54455441
return transition;
54465442
}
@@ -7383,10 +7379,6 @@ var DefaultCacheDispatcher = {
73837379
}
73847380
},
73857381
PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map,
7386-
ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher,
7387-
ReactCurrentCache = ReactSharedInternals.ReactCurrentCache,
7388-
ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner,
7389-
ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig,
73907382
executionContext = 0,
73917383
workInProgressRoot = null,
73927384
workInProgress = null,
@@ -7740,18 +7732,14 @@ function flushSyncFromReconciler(fn) {
77407732
flushPassiveEffects();
77417733
var prevExecutionContext = executionContext;
77427734
executionContext |= 1;
7743-
var prevTransition = ReactCurrentBatchConfig.transition,
7735+
var prevTransition = ReactSharedInternals.T,
77447736
previousPriority = currentUpdatePriority;
77457737
try {
7746-
if (
7747-
((currentUpdatePriority = 2),
7748-
(ReactCurrentBatchConfig.transition = null),
7749-
fn)
7750-
)
7738+
if (((currentUpdatePriority = 2), (ReactSharedInternals.T = null), fn))
77517739
return fn();
77527740
} finally {
77537741
(currentUpdatePriority = previousPriority),
7754-
(ReactCurrentBatchConfig.transition = prevTransition),
7742+
(ReactSharedInternals.T = prevTransition),
77557743
(executionContext = prevExecutionContext),
77567744
0 === (executionContext & 6) && flushSyncWorkAcrossRoots_impl(!1);
77577745
}
@@ -7817,8 +7805,8 @@ function prepareFreshStack(root, lanes) {
78177805
}
78187806
function handleThrow(root, thrownValue) {
78197807
currentlyRenderingFiber$1 = null;
7820-
ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
7821-
ReactCurrentOwner.current = null;
7808+
ReactSharedInternals.H = ContextOnlyDispatcher;
7809+
ReactSharedInternals.owner = null;
78227810
if (thrownValue === SuspenseException) {
78237811
thrownValue = getSuspendedThenable();
78247812
var handler = suspenseHandlerStackCursor.current;
@@ -7856,13 +7844,13 @@ function handleThrow(root, thrownValue) {
78567844
));
78577845
}
78587846
function pushDispatcher() {
7859-
var prevDispatcher = ReactCurrentDispatcher.current;
7860-
ReactCurrentDispatcher.current = ContextOnlyDispatcher;
7847+
var prevDispatcher = ReactSharedInternals.H;
7848+
ReactSharedInternals.H = ContextOnlyDispatcher;
78617849
return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher;
78627850
}
78637851
function pushCacheDispatcher() {
7864-
var prevCacheDispatcher = ReactCurrentCache.current;
7865-
ReactCurrentCache.current = DefaultCacheDispatcher;
7852+
var prevCacheDispatcher = ReactSharedInternals.C;
7853+
ReactSharedInternals.C = DefaultCacheDispatcher;
78667854
return prevCacheDispatcher;
78677855
}
78687856
function renderDidSuspendDelayIfPossible() {
@@ -7914,8 +7902,8 @@ function renderRootSync(root, lanes) {
79147902
lanes && root.shellSuspendCounter++;
79157903
resetContextDependencies();
79167904
executionContext = prevExecutionContext;
7917-
ReactCurrentDispatcher.current = prevDispatcher;
7918-
ReactCurrentCache.current = prevCacheDispatcher;
7905+
ReactSharedInternals.H = prevDispatcher;
7906+
ReactSharedInternals.C = prevCacheDispatcher;
79197907
if (null !== workInProgress)
79207908
throw Error(
79217909
"Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue."
@@ -8021,8 +8009,8 @@ function renderRootConcurrent(root, lanes) {
80218009
}
80228010
while (1);
80238011
resetContextDependencies();
8024-
ReactCurrentDispatcher.current = prevDispatcher;
8025-
ReactCurrentCache.current = prevCacheDispatcher;
8012+
ReactSharedInternals.H = prevDispatcher;
8013+
ReactSharedInternals.C = prevCacheDispatcher;
80268014
executionContext = prevExecutionContext;
80278015
if (null !== workInProgress) return 0;
80288016
workInProgressRoot = null;
@@ -8038,7 +8026,7 @@ function performUnitOfWork(unitOfWork) {
80388026
var next = beginWork(unitOfWork.alternate, unitOfWork, entangledRenderLanes);
80398027
unitOfWork.memoizedProps = unitOfWork.pendingProps;
80408028
null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next);
8041-
ReactCurrentOwner.current = null;
8029+
ReactSharedInternals.owner = null;
80428030
}
80438031
function replaySuspendedUnitOfWork(unitOfWork) {
80448032
var current = unitOfWork.alternate;
@@ -8092,7 +8080,7 @@ function replaySuspendedUnitOfWork(unitOfWork) {
80928080
null === current
80938081
? completeUnitOfWork(unitOfWork)
80948082
: (workInProgress = current);
8095-
ReactCurrentOwner.current = null;
8083+
ReactSharedInternals.owner = null;
80968084
}
80978085
function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) {
80988086
resetContextDependencies();
@@ -8179,11 +8167,11 @@ function commitRoot(
81798167
didIncludeRenderPhaseUpdate,
81808168
spawnedLane
81818169
) {
8182-
var prevTransition = ReactCurrentBatchConfig.transition,
8170+
var prevTransition = ReactSharedInternals.T,
81838171
previousUpdateLanePriority = currentUpdatePriority;
81848172
try {
81858173
(currentUpdatePriority = 2),
8186-
(ReactCurrentBatchConfig.transition = null),
8174+
(ReactSharedInternals.T = null),
81878175
commitRootImpl(
81888176
root,
81898177
recoverableErrors,
@@ -8193,7 +8181,7 @@ function commitRoot(
81938181
spawnedLane
81948182
);
81958183
} finally {
8196-
(ReactCurrentBatchConfig.transition = prevTransition),
8184+
(ReactSharedInternals.T = prevTransition),
81978185
(currentUpdatePriority = previousUpdateLanePriority);
81988186
}
81998187
return null;
@@ -8240,21 +8228,21 @@ function commitRootImpl(
82408228
}));
82418229
transitions = 0 !== (finishedWork.flags & 15990);
82428230
if (0 !== (finishedWork.subtreeFlags & 15990) || transitions) {
8243-
transitions = ReactCurrentBatchConfig.transition;
8244-
ReactCurrentBatchConfig.transition = null;
8231+
transitions = ReactSharedInternals.T;
8232+
ReactSharedInternals.T = null;
82458233
spawnedLane = currentUpdatePriority;
82468234
currentUpdatePriority = 2;
82478235
var prevExecutionContext = executionContext;
82488236
executionContext |= 4;
8249-
ReactCurrentOwner.current = null;
8237+
ReactSharedInternals.owner = null;
82508238
commitBeforeMutationEffects(root, finishedWork);
82518239
commitMutationEffectsOnFiber(finishedWork, root);
82528240
root.current = finishedWork;
82538241
commitLayoutEffectOnFiber(root, finishedWork.alternate, finishedWork);
82548242
requestPaint();
82558243
executionContext = prevExecutionContext;
82568244
currentUpdatePriority = spawnedLane;
8257-
ReactCurrentBatchConfig.transition = transitions;
8245+
ReactSharedInternals.T = transitions;
82588246
} else root.current = finishedWork;
82598247
rootDoesHavePassiveEffects
82608248
? ((rootDoesHavePassiveEffects = !1),
@@ -8299,11 +8287,11 @@ function flushPassiveEffects() {
82998287
remainingLanes = pendingPassiveEffectsRemainingLanes;
83008288
pendingPassiveEffectsRemainingLanes = 0;
83018289
var renderPriority = lanesToEventPriority(pendingPassiveEffectsLanes),
8302-
prevTransition = ReactCurrentBatchConfig.transition,
8290+
prevTransition = ReactSharedInternals.T,
83038291
previousPriority = currentUpdatePriority;
83048292
try {
83058293
currentUpdatePriority = 32 > renderPriority ? 32 : renderPriority;
8306-
ReactCurrentBatchConfig.transition = null;
8294+
ReactSharedInternals.T = null;
83078295
if (null === rootWithPendingPassiveEffects)
83088296
var JSCompiler_inline_result = !1;
83098297
else {
@@ -8338,7 +8326,7 @@ function flushPassiveEffects() {
83388326
return JSCompiler_inline_result;
83398327
} finally {
83408328
(currentUpdatePriority = previousPriority),
8341-
(ReactCurrentBatchConfig.transition = prevTransition),
8329+
(ReactSharedInternals.T = prevTransition),
83428330
releaseRootPooledCache(root, remainingLanes);
83438331
}
83448332
}
@@ -9153,10 +9141,10 @@ var devToolsConfig$jscomp$inline_1000 = {
91539141
throw Error("TestRenderer does not support findFiberByHostInstance()");
91549142
},
91559143
bundleType: 0,
9156-
version: "19.0.0-canary-0c75b31c",
9144+
version: "19.0.0-canary-3a10429d",
91579145
rendererPackageName: "react-test-renderer"
91589146
};
9159-
var internals$jscomp$inline_1222 = {
9147+
var internals$jscomp$inline_1221 = {
91609148
bundleType: devToolsConfig$jscomp$inline_1000.bundleType,
91619149
version: devToolsConfig$jscomp$inline_1000.version,
91629150
rendererPackageName: devToolsConfig$jscomp$inline_1000.rendererPackageName,
@@ -9170,7 +9158,7 @@ var internals$jscomp$inline_1222 = {
91709158
setErrorHandler: null,
91719159
setSuspenseHandler: null,
91729160
scheduleUpdate: null,
9173-
currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher,
9161+
currentDispatcherRef: ReactSharedInternals,
91749162
findHostInstanceByFiber: function (fiber) {
91759163
fiber = findCurrentFiberUsingSlowPath(fiber);
91769164
fiber = null !== fiber ? findCurrentHostFiberImpl(fiber) : null;
@@ -9184,19 +9172,19 @@ var internals$jscomp$inline_1222 = {
91849172
scheduleRoot: null,
91859173
setRefreshHandler: null,
91869174
getCurrentFiber: null,
9187-
reconcilerVersion: "19.0.0-canary-0c75b31c"
9175+
reconcilerVersion: "19.0.0-canary-3a10429d"
91889176
};
91899177
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
9190-
var hook$jscomp$inline_1223 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
9178+
var hook$jscomp$inline_1222 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
91919179
if (
9192-
!hook$jscomp$inline_1223.isDisabled &&
9193-
hook$jscomp$inline_1223.supportsFiber
9180+
!hook$jscomp$inline_1222.isDisabled &&
9181+
hook$jscomp$inline_1222.supportsFiber
91949182
)
91959183
try {
9196-
(rendererID = hook$jscomp$inline_1223.inject(
9197-
internals$jscomp$inline_1222
9184+
(rendererID = hook$jscomp$inline_1222.inject(
9185+
internals$jscomp$inline_1221
91989186
)),
9199-
(injectedHook = hook$jscomp$inline_1223);
9187+
(injectedHook = hook$jscomp$inline_1222);
92009188
} catch (err) {}
92019189
}
92029190
exports._Scheduler = Scheduler;

0 commit comments

Comments
 (0)