@@ -243,11 +243,16 @@ export type ReactClientValue =
243
243
244
244
type ReactClientObject = { + [ key : string ] : ReactClientValue } ;
245
245
246
+ // task status
246
247
const PENDING = 0 ;
247
248
const COMPLETED = 1 ;
248
249
const ABORTED = 3 ;
249
250
const ERRORED = 4 ;
250
251
252
+ // object reference status
253
+ const SEEN_BUT_NOT_YET_OUTLINED = - 1 ;
254
+ const NEVER_OUTLINED = - 2 ;
255
+
251
256
type Task = {
252
257
id : number ,
253
258
status : 0 | 1 | 3 | 4 ,
@@ -280,7 +285,7 @@ export type Request = {
280
285
writtenSymbols : Map < symbol , number> ,
281
286
writtenClientReferences : Map < ClientReferenceKey , number> ,
282
287
writtenServerReferences : Map < ServerReference < any > , number > ,
283
- writtenObjects : WeakMap < Reference , number> , // -1 means "seen" but not outlined.
288
+ writtenObjects : WeakMap < Reference , number> ,
284
289
identifierPrefix : string ,
285
290
identifierCount : number ,
286
291
taintCleanupQueue : Array < string | bigint > ,
@@ -1125,8 +1130,7 @@ function serializeMap(
1125
1130
const writtenObjects = request . writtenObjects ;
1126
1131
const existingId = writtenObjects . get ( key ) ;
1127
1132
if ( existingId === undefined ) {
1128
- // Mark all object keys as seen so that they're always outlined.
1129
- writtenObjects . set ( key , - 1 ) ;
1133
+ writtenObjects . set ( key , SEEN_BUT_NOT_YET_OUTLINED ) ;
1130
1134
}
1131
1135
}
1132
1136
}
@@ -1142,8 +1146,7 @@ function serializeSet(request: Request, set: Set<ReactClientValue>): string {
1142
1146
const writtenObjects = request . writtenObjects ;
1143
1147
const existingId = writtenObjects . get ( key ) ;
1144
1148
if ( existingId === undefined ) {
1145
- // Mark all object keys as seen so that they're always outlined.
1146
- writtenObjects. set ( key , - 1 ) ;
1149
+ writtenObjects . set ( key , SEEN_BUT_NOT_YET_OUTLINED ) ;
1147
1150
}
1148
1151
}
1149
1152
}
@@ -1328,8 +1331,7 @@ function renderModelDestructive(
1328
1331
// This is the ID we're currently emitting so we need to write it
1329
1332
// once but if we discover it again, we refer to it by id.
1330
1333
modelRoot = null ;
1331
- } else if ( existingId === - 1 ) {
1332
- // Seen but not yet outlined.
1334
+ } else if ( existingId === SEEN_BUT_NOT_YET_OUTLINED ) {
1333
1335
// TODO: If we throw here we can treat this as suspending which causes an outline
1334
1336
// but that is able to reuse the same task if we're already in one but then that
1335
1337
// will be a lazy future value rather than guaranteed to exist but maybe that's good.
@@ -1348,7 +1350,10 @@ function renderModelDestructive(
1348
1350
} else {
1349
1351
// This is the first time we've seen this object. We may never see it again
1350
1352
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
1351
- writtenObjects . set ( value , - 1 ) ;
1353
+ writtenObjects . set ( value , SEEN_BUT_NOT_YET_OUTLINED ) ;
1354
+ // The element's props are marked as "never outlined" so that they are inlined into
1355
+ // the same row as the element itself.
1356
+ writtenObjects . set ( value . props , NEVER_OUTLINED ) ;
1352
1357
}
1353
1358
1354
1359
const element : React$Element < any > = ( value : any ) ;
@@ -1477,19 +1482,18 @@ function renderModelDestructive(
1477
1482
// This is the ID we're currently emitting so we need to write it
1478
1483
// once but if we discover it again, we refer to it by id.
1479
1484
modelRoot = null ;
1480
- } else if ( existingId === - 1 ) {
1481
- // Seen but not yet outlined.
1485
+ } else if ( existingId === SEEN_BUT_NOT_YET_OUTLINED ) {
1482
1486
const newId = outlineModel ( request , ( value : any ) ) ;
1483
1487
return serializeByValueID ( newId ) ;
1484
- } else {
1488
+ } else if ( existingId !== NEVER_OUTLINED ) {
1485
1489
// We've already emitted this as an outlined object, so we can
1486
1490
// just refer to that by its existing ID.
1487
1491
return serializeByValueID ( existingId ) ;
1488
1492
}
1489
1493
} else {
1490
1494
// This is the first time we've seen this object. We may never see it again
1491
1495
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
1492
- writtenObjects . set ( value , - 1 ) ;
1496
+ writtenObjects . set ( value , SEEN_BUT_NOT_YET_OUTLINED ) ;
1493
1497
}
1494
1498
1495
1499
if ( isArray ( value ) ) {
@@ -2007,7 +2011,7 @@ function renderConsoleValue(
2007
2011
return serializeInfinitePromise();
2008
2012
}
2009
2013
2010
- if ( existingId !== undefined && existingId !== - 1 ) {
2014
+ if ( existingId !== undefined && existingId >= 0 ) {
2011
2015
// We've already emitted this as a real object, so we can
2012
2016
// just refer to that by its existing ID.
2013
2017
return serializeByValueID ( existingId ) ;
0 commit comments