( request: Request, destination: Destination, segment: Segment, hoistableState: null | HoistableState, )
| 5610 | } |
| 5611 | |
| 5612 | function flushSubtree( |
| 5613 | request: Request, |
| 5614 | destination: Destination, |
| 5615 | segment: Segment, |
| 5616 | hoistableState: null | HoistableState, |
| 5617 | ): boolean { |
| 5618 | segment.parentFlushed = true; |
| 5619 | switch (segment.status) { |
| 5620 | case PENDING: { |
| 5621 | // We're emitting a placeholder for this segment to be filled in later. |
| 5622 | // Therefore we'll need to assign it an ID - to refer to it by. |
| 5623 | segment.id = request.nextSegmentId++; |
| 5624 | // Fallthrough |
| 5625 | } |
| 5626 | case POSTPONED: { |
| 5627 | const segmentID = segment.id; |
| 5628 | // When this segment finally completes it won't be embedded in text since it will flush separately |
| 5629 | segment.lastPushedText = false; |
| 5630 | segment.textEmbedded = false; |
| 5631 | return writePlaceholder(destination, request.renderState, segmentID); |
| 5632 | } |
| 5633 | case COMPLETED: { |
| 5634 | segment.status = FLUSHED; |
| 5635 | let r = true; |
| 5636 | const chunks = segment.chunks; |
| 5637 | let chunkIdx = 0; |
| 5638 | const children = segment.children; |
| 5639 | |
| 5640 | for (let childIdx = 0; childIdx < children.length; childIdx++) { |
| 5641 | const nextChild = children[childIdx]; |
| 5642 | // Write all the chunks up until the next child. |
| 5643 | for (; chunkIdx < nextChild.index; chunkIdx++) { |
| 5644 | writeChunk(destination, chunks[chunkIdx]); |
| 5645 | } |
| 5646 | r = flushSegment(request, destination, nextChild, hoistableState); |
| 5647 | } |
| 5648 | // Finally just write all the remaining chunks |
| 5649 | for (; chunkIdx < chunks.length - 1; chunkIdx++) { |
| 5650 | writeChunk(destination, chunks[chunkIdx]); |
| 5651 | } |
| 5652 | if (chunkIdx < chunks.length) { |
| 5653 | r = writeChunkAndReturn(destination, chunks[chunkIdx]); |
| 5654 | } |
| 5655 | return r; |
| 5656 | } |
| 5657 | case ABORTED: { |
| 5658 | return true; |
| 5659 | } |
| 5660 | default: { |
| 5661 | throw new Error( |
| 5662 | 'Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React.', |
| 5663 | ); |
| 5664 | } |
| 5665 | } |
| 5666 | } |
| 5667 | |
| 5668 | // Running count for how much bytes of boundaries have flushed inlined into the currently |
| 5669 | // flushing root or completed boundary. |
no test coverage detected