@@ -13,7 +13,7 @@ import type {LazyComponent} from 'react/src/ReactLazy';
13
13
import type {
14
14
ClientReference ,
15
15
ClientReferenceMetadata ,
16
- UninitializedModel ,
16
+ UninitializedValue ,
17
17
Response ,
18
18
SSRManifest ,
19
19
} from './ReactFlightClientHostConfig' ;
@@ -22,7 +22,7 @@ import {
22
22
resolveClientReference ,
23
23
preloadModule ,
24
24
requireModule ,
25
- parseModel ,
25
+ parseValue ,
26
26
} from './ReactFlightClientHostConfig' ;
27
27
28
28
import { knownServerReferences } from './ReactFlightServerReferenceRegistry' ;
@@ -43,7 +43,7 @@ export type JSONValue =
43
43
44
44
const PENDING = 'pending';
45
45
const BLOCKED = 'blocked';
46
- const RESOLVED_MODEL = 'resolved_model ';
46
+ const RESOLVED_VALUE = 'resolved_value ';
47
47
const RESOLVED_MODULE = 'resolved_module';
48
48
const INITIALIZED = 'fulfilled';
49
49
const ERRORED = 'rejected';
@@ -62,9 +62,9 @@ type BlockedChunk<T> = {
62
62
_response : Response ,
63
63
then ( resolve : ( T ) = > mixed , reject : ( mixed ) = > mixed ) : void ,
64
64
} ;
65
- type ResolvedModelChunk < T > = {
66
- status : 'resolved_model ' ,
67
- value : UninitializedModel ,
65
+ type ResolvedValueChunk < T > = {
66
+ status : 'resolved_value ' ,
67
+ value : UninitializedValue ,
68
68
reason : null ,
69
69
_response : Response ,
70
70
then ( resolve : ( T ) = > mixed , reject : ( mixed ) = > mixed ) : void ,
@@ -93,7 +93,7 @@ type ErroredChunk<T> = {
93
93
type SomeChunk< T > =
94
94
| PendingChunk< T >
95
95
| BlockedChunk< T >
96
- | ResolvedModelChunk < T >
96
+ | ResolvedValueChunk < T >
97
97
| ResolvedModuleChunk< T >
98
98
| InitializedChunk< T >
99
99
| ErroredChunk< T > ;
@@ -117,8 +117,8 @@ Chunk.prototype.then = function <T>(
117
117
// If we have resolved content, we try to initialize it first which
118
118
// might put us back into one of the other states.
119
119
switch ( chunk . status ) {
120
- case RESOLVED_MODEL :
121
- initializeModelChunk ( chunk ) ;
120
+ case RESOLVED_VALUE :
121
+ initializeValueChunk ( chunk ) ;
122
122
break ;
123
123
case RESOLVED_MODULE :
124
124
initializeModuleChunk ( chunk ) ;
@@ -163,8 +163,8 @@ function readChunk<T>(chunk: SomeChunk<T>): T {
163
163
// If we have resolved content, we try to initialize it first which
164
164
// might put us back into one of the other states.
165
165
switch ( chunk . status ) {
166
- case RESOLVED_MODEL :
167
- initializeModelChunk ( chunk ) ;
166
+ case RESOLVED_VALUE :
167
+ initializeValueChunk ( chunk ) ;
168
168
break ;
169
169
case RESOLVED_MODULE :
170
170
initializeModuleChunk ( chunk ) ;
@@ -249,12 +249,12 @@ function triggerErrorOnChunk<T>(chunk: SomeChunk<T>, error: mixed): void {
249
249
}
250
250
}
251
251
252
- function createResolvedModelChunk < T > (
252
+ function createResolvedValueChunk < T > (
253
253
response: Response,
254
- value: UninitializedModel ,
255
- ): ResolvedModelChunk < T > {
254
+ value: UninitializedValue ,
255
+ ): ResolvedValueChunk < T > {
256
256
// $FlowFixMe Flow doesn't support functions as constructors
257
- return new Chunk ( RESOLVED_MODEL , value , null , response ) ;
257
+ return new Chunk ( RESOLVED_VALUE , value , null , response ) ;
258
258
}
259
259
260
260
function createResolvedModuleChunk< T > (
@@ -265,24 +265,24 @@ function createResolvedModuleChunk<T>(
265
265
return new Chunk ( RESOLVED_MODULE , value , null , response ) ;
266
266
}
267
267
268
- function resolveModelChunk < T > (
268
+ function resolveValueChunk < T > (
269
269
chunk: SomeChunk< T > ,
270
- value: UninitializedModel ,
270
+ value: UninitializedValue ,
271
271
): void {
272
272
if ( chunk . status !== PENDING ) {
273
273
// We already resolved. We didn't expect to see this.
274
274
return ;
275
275
}
276
276
const resolveListeners = chunk.value;
277
277
const rejectListeners = chunk.reason;
278
- const resolvedChunk: ResolvedModelChunk < T > = (chunk: any);
279
- resolvedChunk.status = RESOLVED_MODEL ;
278
+ const resolvedChunk: ResolvedValueChunk < T > = (chunk: any);
279
+ resolvedChunk.status = RESOLVED_VALUE ;
280
280
resolvedChunk.value = value;
281
281
if (resolveListeners !== null) {
282
282
// This is unfortunate that we're reading this eagerly if
283
283
// we already have listeners attached since they might no
284
284
// longer be rendered or might not be the highest pri.
285
- initializeModelChunk ( resolvedChunk ) ;
285
+ initializeValueChunk ( resolvedChunk ) ;
286
286
// The status might have changed after initialization.
287
287
wakeChunkIfInitialized ( chunk , resolveListeners , rejectListeners ) ;
288
288
}
@@ -307,20 +307,20 @@ function resolveModuleChunk<T>(
307
307
}
308
308
}
309
309
310
- let initializingChunk : ResolvedModelChunk < any > = (null: any);
311
- let initializingChunkBlockedModel : null | { deps : number , value : any } = null;
312
- function initializeModelChunk < T > (chunk: ResolvedModelChunk < T > ): void {
310
+ let initializingChunk : ResolvedValueChunk < any > = (null: any);
311
+ let initializingChunkBlockedValue : null | { deps : number , value : any } = null;
312
+ function initializeValueChunk < T > (chunk: ResolvedValueChunk < T > ): void {
313
313
const prevChunk = initializingChunk ;
314
- const prevBlocked = initializingChunkBlockedModel ;
314
+ const prevBlocked = initializingChunkBlockedValue ;
315
315
initializingChunk = chunk ;
316
- initializingChunkBlockedModel = null ;
316
+ initializingChunkBlockedValue = null ;
317
317
try {
318
- const value : T = parseModel ( chunk . _response , chunk . value ) ;
318
+ const value : T = parseValue ( chunk . _response , chunk . value ) ;
319
319
if (
320
- initializingChunkBlockedModel !== null &&
321
- initializingChunkBlockedModel . deps > 0
320
+ initializingChunkBlockedValue !== null &&
321
+ initializingChunkBlockedValue . deps > 0
322
322
) {
323
- initializingChunkBlockedModel . value = value ;
323
+ initializingChunkBlockedValue . value = value ;
324
324
// We discovered new dependencies on modules that are not yet resolved.
325
325
// We have to go the BLOCKED state until they're resolved.
326
326
const blockedChunk : BlockedChunk < T > = ( chunk : any ) ;
@@ -338,7 +338,7 @@ function initializeModelChunk<T>(chunk: ResolvedModelChunk<T>): void {
338
338
erroredChunk . reason = error ;
339
339
} finally {
340
340
initializingChunk = prevChunk ;
341
- initializingChunkBlockedModel = prevBlocked ;
341
+ initializingChunkBlockedValue = prevBlocked ;
342
342
}
343
343
}
344
344
@@ -436,17 +436,17 @@ function getChunk(response: Response, id: number): SomeChunk<any> {
436
436
return chunk ;
437
437
}
438
438
439
- function createModelResolver < T > (
439
+ function createValueResolver < T > (
440
440
chunk: SomeChunk< T > ,
441
441
parentObject: Object,
442
442
key: string,
443
443
): (value: any) => void {
444
444
let blocked ;
445
- if ( initializingChunkBlockedModel ) {
446
- blocked = initializingChunkBlockedModel ;
445
+ if ( initializingChunkBlockedValue ) {
446
+ blocked = initializingChunkBlockedValue ;
447
447
blocked . deps ++ ;
448
448
} else {
449
- blocked = initializingChunkBlockedModel = {
449
+ blocked = initializingChunkBlockedValue = {
450
450
deps : 1 ,
451
451
value : null ,
452
452
} ;
@@ -469,7 +469,7 @@ function createModelResolver<T>(
469
469
} ;
470
470
}
471
471
472
- function createModelReject < T > (chunk: SomeChunk< T > ): (error: mixed) => void {
472
+ function createValueReject < T > (chunk: SomeChunk< T > ): (error: mixed) => void {
473
473
return ( error : mixed ) = > triggerErrorOnChunk ( chunk , error ) ;
474
474
}
475
475
@@ -501,7 +501,7 @@ function createServerReferenceProxy<A: Iterable<any>, T>(
501
501
return proxy;
502
502
}
503
503
504
- export function parseModelString (
504
+ export function parseValueString (
505
505
response: Response,
506
506
parentObject: Object,
507
507
key: string,
@@ -544,8 +544,8 @@ export function parseModelString(
544
544
const id = parseInt ( value . substring ( 2 ) , 16 ) ;
545
545
const chunk = getChunk ( response , id ) ;
546
546
switch ( chunk . status ) {
547
- case RESOLVED_MODEL :
548
- initializeModelChunk ( chunk ) ;
547
+ case RESOLVED_VALUE :
548
+ initializeValueChunk ( chunk ) ;
549
549
break ;
550
550
}
551
551
// The status might have changed after initialization.
@@ -569,8 +569,8 @@ export function parseModelString(
569
569
const id = parseInt ( value . substring ( 1 ) , 16 ) ;
570
570
const chunk = getChunk ( response , id ) ;
571
571
switch ( chunk . status ) {
572
- case RESOLVED_MODEL :
573
- initializeModelChunk ( chunk ) ;
572
+ case RESOLVED_VALUE :
573
+ initializeValueChunk ( chunk ) ;
574
574
break ;
575
575
case RESOLVED_MODULE :
576
576
initializeModuleChunk ( chunk ) ;
@@ -584,8 +584,8 @@ export function parseModelString(
584
584
case BLOCKED :
585
585
const parentChunk = initializingChunk ;
586
586
chunk . then (
587
- createModelResolver ( parentChunk , parentObject , key ) ,
588
- createModelReject ( parentChunk ) ,
587
+ createValueResolver ( parentChunk , parentObject , key ) ,
588
+ createValueReject ( parentChunk ) ,
589
589
) ;
590
590
return null ;
591
591
default :
@@ -597,7 +597,7 @@ export function parseModelString(
597
597
return value ;
598
598
}
599
599
600
- export function parseModelTuple (
600
+ export function parseValueTuple (
601
601
response : Response ,
602
602
value : { + [ key : string ] : JSONValue } | $ReadOnlyArray < JSONValue > ,
603
603
) : any {
@@ -631,30 +631,30 @@ export function createResponse(
631
631
return response ;
632
632
}
633
633
634
- export function resolveModel (
634
+ export function resolveValue (
635
635
response : Response ,
636
636
id : number ,
637
- model : UninitializedModel ,
637
+ value : UninitializedValue ,
638
638
) : void {
639
639
const chunks = response . _chunks ;
640
640
const chunk = chunks . get ( id ) ;
641
641
if ( ! chunk ) {
642
- chunks . set ( id , createResolvedModelChunk ( response , model ) ) ;
642
+ chunks . set ( id , createResolvedValueChunk ( response , value ) ) ;
643
643
} else {
644
- resolveModelChunk ( chunk , model ) ;
644
+ resolveValueChunk ( chunk , value ) ;
645
645
}
646
646
}
647
647
648
648
export function resolveModule (
649
649
response : Response ,
650
650
id : number ,
651
- model : UninitializedModel ,
651
+ value : UninitializedValue ,
652
652
) : void {
653
653
const chunks = response . _chunks ;
654
654
const chunk = chunks . get ( id ) ;
655
- const clientReferenceMetadata : ClientReferenceMetadata = parseModel (
655
+ const clientReferenceMetadata : ClientReferenceMetadata = parseValue (
656
656
response ,
657
- model ,
657
+ value ,
658
658
) ;
659
659
const clientReference = resolveClientReference < $FlowFixMe > (
660
660
response . _ssrManifest ,
0 commit comments