@@ -86,7 +86,7 @@ export type ReactModel = |
86 | 86 |
|
87 | 87 | type ReactModelObject = {+[key: string]: ReactModel}; |
88 | 88 |
|
89 | | -type Segment = { |
| 89 | +type Task = { |
90 | 90 | id: number, |
91 | 91 | model: ReactModel, |
92 | 92 | ping: () => void, |
@@ -101,7 +101,7 @@ export type Request = { |
101 | 101 | cache: Map<Function, mixed>, |
102 | 102 | nextChunkId: number, |
103 | 103 | pendingChunks: number, |
104 | | - pingedSegments: Array<Segment>, |
| 104 | + pingedTasks: Array<Task>, |
105 | 105 | completedModuleChunks: Array<Chunk>, |
106 | 106 | completedJSONChunks: Array<Chunk>, |
107 | 107 | completedErrorChunks: Array<Chunk>, |
@@ -132,7 +132,7 @@ export function createRequest( |
132 | 132 | context?: Array<[string, ServerContextJSONValue]>, |
133 | 133 | identifierPrefix?: string, |
134 | 134 | ): Request { |
135 | | - const pingedSegments = []; |
| 135 | + const pingedTasks = []; |
136 | 136 | const request = { |
137 | 137 | status: OPEN, |
138 | 138 | fatalError: null, |
@@ -141,7 +141,7 @@ export function createRequest( |
141 | 141 | cache: new Map(), |
142 | 142 | nextChunkId: 0, |
143 | 143 | pendingChunks: 0, |
144 | | - pingedSegments: pingedSegments, |
| 144 | + pingedTasks: pingedTasks, |
145 | 145 | completedModuleChunks: [], |
146 | 146 | completedJSONChunks: [], |
147 | 147 | completedErrorChunks: [], |
@@ -157,8 +157,8 @@ export function createRequest( |
157 | 157 | }; |
158 | 158 | request.pendingChunks++; |
159 | 159 | const rootContext = createRootContext(context); |
160 | | - const rootSegment = createSegment(request, model, rootContext); |
161 | | - pingedSegments.push(rootSegment); |
| 160 | + const rootTask = createTask(request, model, rootContext); |
| 161 | + pingedTasks.push(rootTask); |
162 | 162 | return request; |
163 | 163 | } |
164 | 164 |
|
@@ -251,27 +251,27 @@ function attemptResolveElement( |
251 | 251 | ); |
252 | 252 | } |
253 | 253 |
|
254 | | -function pingSegment(request: Request, segment: Segment): void { |
255 | | - const pingedSegments = request.pingedSegments; |
256 | | - pingedSegments.push(segment); |
257 | | - if (pingedSegments.length === 1) { |
| 254 | +function pingTask(request: Request, task: Task): void { |
| 255 | + const pingedTasks = request.pingedTasks; |
| 256 | + pingedTasks.push(task); |
| 257 | + if (pingedTasks.length === 1) { |
258 | 258 | scheduleWork(() => performWork(request)); |
259 | 259 | } |
260 | 260 | } |
261 | 261 |
|
262 | | -function createSegment( |
| 262 | +function createTask( |
263 | 263 | request: Request, |
264 | 264 | model: ReactModel, |
265 | 265 | context: ContextSnapshot, |
266 | | -): Segment { |
| 266 | +): Task { |
267 | 267 | const id = request.nextChunkId++; |
268 | | - const segment = { |
| 268 | + const task = { |
269 | 269 | id, |
270 | 270 | model, |
271 | 271 | context, |
272 | | - ping: () => pingSegment(request, segment), |
| 272 | + ping: () => pingTask(request, task), |
273 | 273 | }; |
274 | | - return segment; |
| 274 | + return task; |
275 | 275 | } |
276 | 276 |
|
277 | 277 | function serializeByValueID(id: number): string { |
@@ -518,12 +518,12 @@ export function resolveModelToJSON( |
518 | 518 | } |
519 | 519 | } catch (x) { |
520 | 520 | if (typeof x === 'object' && x !== null && typeof x.then === 'function') { |
521 | | - // Something suspended, we'll need to create a new segment and resolve it later. |
| 521 | + // Something suspended, we'll need to create a new task and resolve it later. |
522 | 522 | request.pendingChunks++; |
523 | | - const newSegment = createSegment(request, value, getActiveContext()); |
524 | | - const ping = newSegment.ping; |
| 523 | + const newTask = createTask(request, value, getActiveContext()); |
| 524 | + const ping = newTask.ping; |
525 | 525 | x.then(ping, ping); |
526 | | - return serializeByRefID(newSegment.id); |
| 526 | + return serializeByRefID(newTask.id); |
527 | 527 | } else { |
528 | 528 | logRecoverableError(request, x); |
529 | 529 | // Something errored. We'll still send everything we have up until this point. |
@@ -790,10 +790,10 @@ function emitProviderChunk( |
790 | 790 | request.completedJSONChunks.push(processedChunk); |
791 | 791 | } |
792 | 792 |
|
793 | | -function retrySegment(request: Request, segment: Segment): void { |
794 | | - switchContext(segment.context); |
| 793 | +function retryTask(request: Request, task: Task): void { |
| 794 | + switchContext(task.context); |
795 | 795 | try { |
796 | | - let value = segment.model; |
| 796 | + let value = task.model; |
797 | 797 | while ( |
798 | 798 | typeof value === 'object' && |
799 | 799 | value !== null && |
@@ -802,28 +802,28 @@ function retrySegment(request: Request, segment: Segment): void { |
802 | 802 | // TODO: Concatenate keys of parents onto children. |
803 | 803 | const element: React$Element<any> = (value: any); |
804 | 804 | // Attempt to render the server component. |
805 | | - // Doing this here lets us reuse this same segment if the next component |
| 805 | + // Doing this here lets us reuse this same task if the next component |
806 | 806 | // also suspends. |
807 | | - segment.model = value; |
| 807 | + task.model = value; |
808 | 808 | value = attemptResolveElement( |
809 | 809 | element.type, |
810 | 810 | element.key, |
811 | 811 | element.ref, |
812 | 812 | element.props, |
813 | 813 | ); |
814 | 814 | } |
815 | | - const processedChunk = processModelChunk(request, segment.id, value); |
| 815 | + const processedChunk = processModelChunk(request, task.id, value); |
816 | 816 | request.completedJSONChunks.push(processedChunk); |
817 | 817 | } catch (x) { |
818 | 818 | if (typeof x === 'object' && x !== null && typeof x.then === 'function') { |
819 | 819 | // Something suspended again, let's pick it back up later. |
820 | | - const ping = segment.ping; |
| 820 | + const ping = task.ping; |
821 | 821 | x.then(ping, ping); |
822 | 822 | return; |
823 | 823 | } else { |
824 | 824 | logRecoverableError(request, x); |
825 | 825 | // This errored, we need to serialize this error to the |
826 | | - emitErrorChunk(request, segment.id, x); |
| 826 | + emitErrorChunk(request, task.id, x); |
827 | 827 | } |
828 | 828 | } |
829 | 829 | } |
@@ -836,11 +836,11 @@ function performWork(request: Request): void { |
836 | 836 | prepareToUseHooksForRequest(request); |
837 | 837 |
|
838 | 838 | try { |
839 | | - const pingedSegments = request.pingedSegments; |
840 | | - request.pingedSegments = []; |
841 | | - for (let i = 0; i < pingedSegments.length; i++) { |
842 | | - const segment = pingedSegments[i]; |
843 | | - retrySegment(request, segment); |
| 839 | + const pingedTasks = request.pingedTasks; |
| 840 | + request.pingedTasks = []; |
| 841 | + for (let i = 0; i < pingedTasks.length; i++) { |
| 842 | + const task = pingedTasks[i]; |
| 843 | + retryTask(request, task); |
844 | 844 | } |
845 | 845 | if (request.destination !== null) { |
846 | 846 | flushCompletedChunks(request, request.destination); |
|