Skip to content

Commit a1e1701

Browse files
committed
[Fizz] Various smaller refactors (#27368)
Back ported from a larger PR. DiffTrain build for [e520565](e520565)
1 parent 9130065 commit a1e1701

8 files changed

+165
-117
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
69be472c11231056d297a7b73dd0b121905606d3
1+
e5205658f40ad181279857dbb66e36b8ebcd8c0e

compiled/facebook-www/ReactDOMServer-dev.classic.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

22-
var ReactVersion = "18.3.0-www-classic-82e3d4f9";
22+
var ReactVersion = "18.3.0-www-classic-49aaaaa7";
2323

2424
// This refers to a WWW module.
2525
var warningWWW = require("warning");
@@ -5214,7 +5214,7 @@ function writeEndSegment(destination, formatContext) {
52145214
}
52155215
}
52165216
var completeSegmentScript1Full = stringToPrecomputedChunk(
5217-
completeSegment + ';$RS("'
5217+
completeSegment + '$RS("'
52185218
);
52195219
var completeSegmentScript1Partial = stringToPrecomputedChunk('$RS("');
52205220
var completeSegmentScript2 = stringToPrecomputedChunk('","');
@@ -9703,6 +9703,7 @@ function createRequest(
97039703
request,
97049704
null,
97059705
children,
9706+
-1,
97069707
null,
97079708
rootSegment,
97089709
abortSet,
@@ -9754,6 +9755,7 @@ function createTask(
97549755
request,
97559756
thenableState,
97569757
node,
9758+
childIndex,
97579759
blockedBoundary,
97589760
blockedSegment,
97599761
abortSet,
@@ -9773,6 +9775,7 @@ function createTask(
97739775

97749776
var task = {
97759777
node: node,
9778+
childIndex: childIndex,
97769779
ping: function () {
97779780
return pingTask(request, task);
97789781
},
@@ -9784,8 +9787,7 @@ function createTask(
97849787
legacyContext: legacyContext,
97859788
context: context,
97869789
treeContext: treeContext,
9787-
thenableState: thenableState,
9788-
childIndex: -1
9790+
thenableState: thenableState
97899791
};
97909792

97919793
{
@@ -9933,6 +9935,7 @@ function fatalError(request, error) {
99339935

99349936
function renderSuspenseBoundary(request, task, keyPath, props) {
99359937
pushBuiltInComponentStackInDEV(task, "Suspense");
9938+
var prevKeyPath = task.keyPath;
99369939
var parentBoundary = task.blockedBoundary;
99379940
var parentSegment = task.blockedSegment; // Each time we enter a suspense boundary, we split out into a new segment for
99389941
// the fallback so that we can later replace that segment with the content.
@@ -9985,6 +9988,8 @@ function renderSuspenseBoundary(request, task, keyPath, props) {
99859988
);
99869989
}
99879990

9991+
task.keyPath = keyPath;
9992+
99889993
try {
99899994
// We use the safe form because we don't handle suspending here. Only error handling.
99909995
renderNode(request, task, content, -1);
@@ -10031,13 +10036,15 @@ function renderSuspenseBoundary(request, task, keyPath, props) {
1003110036

1003210037
task.blockedBoundary = parentBoundary;
1003310038
task.blockedSegment = parentSegment;
10039+
task.keyPath = prevKeyPath;
1003410040
} // We create suspended task for the fallback because we don't want to actually work
1003510041
// on it yet in case we finish the main content, so we queue for later.
1003610042

1003710043
var suspendedFallbackTask = createTask(
1003810044
request,
1003910045
null,
1004010046
fallback,
10047+
-1,
1004110048
parentBoundary,
1004210049
boundarySegment,
1004310050
fallbackAbortSet, // TODO: Should distinguish key path of fallback and primary tasks
@@ -11041,6 +11048,7 @@ function spawnNewSuspendedTask(request, task, thenableState, x) {
1104111048
request,
1104211049
thenableState,
1104311050
task.node,
11051+
task.childIndex,
1104411052
task.blockedBoundary,
1104511053
newSegment,
1104611054
task.abortSet,
@@ -11050,7 +11058,6 @@ function spawnNewSuspendedTask(request, task, thenableState, x) {
1105011058
task.context,
1105111059
task.treeContext
1105211060
);
11053-
newTask.childIndex = task.childIndex;
1105411061

1105511062
{
1105611063
if (task.componentStack !== null) {

compiled/facebook-www/ReactDOMServer-dev.modern.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

22-
var ReactVersion = "18.3.0-www-modern-6e4c58de";
22+
var ReactVersion = "18.3.0-www-modern-b00edc72";
2323

2424
// This refers to a WWW module.
2525
var warningWWW = require("warning");
@@ -5214,7 +5214,7 @@ function writeEndSegment(destination, formatContext) {
52145214
}
52155215
}
52165216
var completeSegmentScript1Full = stringToPrecomputedChunk(
5217-
completeSegment + ';$RS("'
5217+
completeSegment + '$RS("'
52185218
);
52195219
var completeSegmentScript1Partial = stringToPrecomputedChunk('$RS("');
52205220
var completeSegmentScript2 = stringToPrecomputedChunk('","');
@@ -9462,6 +9462,7 @@ function createRequest(
94629462
request,
94639463
null,
94649464
children,
9465+
-1,
94659466
null,
94669467
rootSegment,
94679468
abortSet,
@@ -9513,6 +9514,7 @@ function createTask(
95139514
request,
95149515
thenableState,
95159516
node,
9517+
childIndex,
95169518
blockedBoundary,
95179519
blockedSegment,
95189520
abortSet,
@@ -9532,6 +9534,7 @@ function createTask(
95329534

95339535
var task = {
95349536
node: node,
9537+
childIndex: childIndex,
95359538
ping: function () {
95369539
return pingTask(request, task);
95379540
},
@@ -9543,8 +9546,7 @@ function createTask(
95439546
legacyContext: legacyContext,
95449547
context: context,
95459548
treeContext: treeContext,
9546-
thenableState: thenableState,
9547-
childIndex: -1
9549+
thenableState: thenableState
95489550
};
95499551

95509552
{
@@ -9692,6 +9694,7 @@ function fatalError(request, error) {
96929694

96939695
function renderSuspenseBoundary(request, task, keyPath, props) {
96949696
pushBuiltInComponentStackInDEV(task, "Suspense");
9697+
var prevKeyPath = task.keyPath;
96959698
var parentBoundary = task.blockedBoundary;
96969699
var parentSegment = task.blockedSegment; // Each time we enter a suspense boundary, we split out into a new segment for
96979700
// the fallback so that we can later replace that segment with the content.
@@ -9744,6 +9747,8 @@ function renderSuspenseBoundary(request, task, keyPath, props) {
97449747
);
97459748
}
97469749

9750+
task.keyPath = keyPath;
9751+
97479752
try {
97489753
// We use the safe form because we don't handle suspending here. Only error handling.
97499754
renderNode(request, task, content, -1);
@@ -9790,13 +9795,15 @@ function renderSuspenseBoundary(request, task, keyPath, props) {
97909795

97919796
task.blockedBoundary = parentBoundary;
97929797
task.blockedSegment = parentSegment;
9798+
task.keyPath = prevKeyPath;
97939799
} // We create suspended task for the fallback because we don't want to actually work
97949800
// on it yet in case we finish the main content, so we queue for later.
97959801

97969802
var suspendedFallbackTask = createTask(
97979803
request,
97989804
null,
97999805
fallback,
9806+
-1,
98009807
parentBoundary,
98019808
boundarySegment,
98029809
fallbackAbortSet, // TODO: Should distinguish key path of fallback and primary tasks
@@ -10789,6 +10796,7 @@ function spawnNewSuspendedTask(request, task, thenableState, x) {
1078910796
request,
1079010797
thenableState,
1079110798
task.node,
10799+
task.childIndex,
1079210800
task.blockedBoundary,
1079310801
newSegment,
1079410802
task.abortSet,
@@ -10798,7 +10806,6 @@ function spawnNewSuspendedTask(request, task, thenableState, x) {
1079810806
task.context,
1079910807
task.treeContext
1080010808
);
10801-
newTask.childIndex = task.childIndex;
1080210809

1080310810
{
1080410811
if (task.componentStack !== null) {

compiled/facebook-www/ReactDOMServer-prod.classic.js

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2915,6 +2915,7 @@ function createRequest(
29152915
resumableState,
29162916
null,
29172917
children,
2918+
-1,
29182919
null,
29192920
renderState,
29202921
abortSet,
@@ -2932,6 +2933,7 @@ function createTask(
29322933
request,
29332934
thenableState,
29342935
node,
2936+
childIndex,
29352937
blockedBoundary,
29362938
blockedSegment,
29372939
abortSet,
@@ -2947,6 +2949,7 @@ function createTask(
29472949
: blockedBoundary.pendingTasks++;
29482950
var task = {
29492951
node: node,
2952+
childIndex: childIndex,
29502953
ping: function () {
29512954
request.pingedTasks.push(task);
29522955
1 === request.pingedTasks.length &&
@@ -2961,8 +2964,7 @@ function createTask(
29612964
legacyContext: legacyContext,
29622965
context: context,
29632966
treeContext: treeContext,
2964-
thenableState: thenableState,
2965-
childIndex: -1
2967+
thenableState: thenableState
29662968
};
29672969
abortSet.add(task);
29682970
return task;
@@ -3293,79 +3295,83 @@ function renderElement(
32933295
return;
32943296
case REACT_SUSPENSE_TYPE:
32953297
a: {
3296-
type = task.blockedBoundary;
3297-
contextKey = task.blockedSegment;
3298-
prevThenableState = props.fallback;
3298+
type = task.keyPath;
3299+
contextKey = task.blockedBoundary;
3300+
prevThenableState = task.blockedSegment;
3301+
ref = props.fallback;
32993302
props = props.children;
3300-
ref = new Set();
3301-
initialState = {
3303+
initialState = new Set();
3304+
contextType = {
33023305
status: 0,
33033306
id: null,
33043307
rootSegmentID: -1,
33053308
parentFlushed: !1,
33063309
pendingTasks: 0,
33073310
completedSegments: [],
33083311
byteSize: 0,
3309-
fallbackAbortableTasks: ref,
3312+
fallbackAbortableTasks: initialState,
33103313
errorDigest: null,
33113314
resources: new Set(),
33123315
keyPath: keyPath
33133316
};
3314-
contextType = createPendingSegment(
3317+
oldReplace = createPendingSegment(
33153318
request,
3316-
contextKey.chunks.length,
3317-
initialState,
3319+
prevThenableState.chunks.length,
3320+
contextType,
33183321
task.formatContext,
33193322
!1,
33203323
!1
33213324
);
3322-
contextKey.children.push(contextType);
3323-
contextKey.lastPushedText = !1;
3324-
oldReplace = createPendingSegment(
3325+
prevThenableState.children.push(oldReplace);
3326+
prevThenableState.lastPushedText = !1;
3327+
partial = createPendingSegment(
33253328
request,
33263329
0,
33273330
null,
33283331
task.formatContext,
33293332
!1,
33303333
!1
33313334
);
3332-
oldReplace.parentFlushed = !0;
3333-
task.blockedBoundary = initialState;
3334-
task.blockedSegment = oldReplace;
3335-
request.renderState.boundaryResources = initialState.resources;
3335+
partial.parentFlushed = !0;
3336+
task.blockedBoundary = contextType;
3337+
task.blockedSegment = partial;
3338+
request.renderState.boundaryResources = contextType.resources;
3339+
task.keyPath = keyPath;
33363340
try {
33373341
if (
33383342
(renderNode(request, task, props, -1),
33393343
request.renderState.generateStaticMarkup ||
3340-
(oldReplace.lastPushedText &&
3341-
oldReplace.textEmbedded &&
3342-
oldReplace.chunks.push("\x3c!-- --\x3e")),
3343-
(oldReplace.status = 1),
3344-
queueCompletedSegment(initialState, oldReplace),
3345-
0 === initialState.pendingTasks && 0 === initialState.status)
3344+
(partial.lastPushedText &&
3345+
partial.textEmbedded &&
3346+
partial.chunks.push("\x3c!-- --\x3e")),
3347+
(partial.status = 1),
3348+
queueCompletedSegment(contextType, partial),
3349+
0 === contextType.pendingTasks && 0 === contextType.status)
33463350
) {
3347-
initialState.status = 1;
3351+
contextType.status = 1;
33483352
break a;
33493353
}
33503354
} catch (error) {
3351-
(oldReplace.status = 4),
3352-
(initialState.status = 4),
3355+
(partial.status = 4),
3356+
(contextType.status = 4),
33533357
(JSCompiler_inline_result = logRecoverableError(request, error)),
3354-
(initialState.errorDigest = JSCompiler_inline_result);
3358+
(contextType.errorDigest = JSCompiler_inline_result);
33553359
} finally {
3356-
(request.renderState.boundaryResources = type
3357-
? type.resources
3360+
(request.renderState.boundaryResources = contextKey
3361+
? contextKey.resources
33583362
: null),
3359-
(task.blockedBoundary = type),
3360-
(task.blockedSegment = contextKey);
3363+
(task.blockedBoundary = contextKey),
3364+
(task.blockedSegment = prevThenableState),
3365+
(task.keyPath = type);
33613366
}
33623367
task = createTask(
33633368
request,
33643369
null,
3365-
prevThenableState,
3366-
type,
3367-
contextType,
33683370
ref,
3371+
-1,
3372+
contextKey,
3373+
oldReplace,
3374+
initialState,
33693375
keyPath,
33703376
task.formatContext,
33713377
task.legacyContext,
@@ -3635,6 +3641,7 @@ function renderNode(request, task, node, childIndex) {
36353641
request,
36363642
childIndex,
36373643
task.node,
3644+
task.childIndex,
36383645
task.blockedBoundary,
36393646
childrenLength,
36403647
task.abortSet,
@@ -3643,9 +3650,7 @@ function renderNode(request, task, node, childIndex) {
36433650
task.legacyContext,
36443651
task.context,
36453652
task.treeContext
3646-
)),
3647-
(request.childIndex = task.childIndex),
3648-
(request = request.ping),
3653+
).ping),
36493654
node.then(request, request),
36503655
(task.formatContext = previousFormatContext),
36513656
(task.legacyContext = previousLegacyContext),
@@ -4042,7 +4047,7 @@ function flushPartiallyCompletedSegment(
40424047
0 === (boundary.instructions & 1)
40434048
? ((boundary.instructions |= 1),
40444049
destination.push(
4045-
'$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};;$RS("'
4050+
'$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'
40464051
))
40474052
: destination.push('$RS("'))
40484053
: destination.push('<template data-rsi="" data-sid="');
@@ -4500,4 +4505,4 @@ exports.renderToString = function (children, options) {
45004505
'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server'
45014506
);
45024507
};
4503-
exports.version = "18.3.0-www-classic-249420ad";
4508+
exports.version = "18.3.0-www-classic-019477d4";

0 commit comments

Comments
 (0)