@@ -342,11 +342,6 @@ type Response = {
342342 _chunks : Map < number , SomeChunk< any >> ,
343343 _fromJSON : ( key : string , value : JSONValue ) => any ,
344344 _stringDecoder : StringDecoder ,
345- _rowState : RowParserState ,
346- _rowID : number , // parts of a row ID parsed so far
347- _rowTag : number , // 0 indicates that we're currently parsing the row ID
348- _rowLength : number , // remaining bytes in the row. 0 indicates that we're looking for a newline.
349- _buffer : Array < Uint8Array > , // chunks received so far as part of this row
350345 _closed : boolean ,
351346 _closedReason : mixed ,
352347 _tempRefs : void | TemporaryReferenceSet , // the set temporary references can be resolved from
@@ -2154,11 +2149,6 @@ function ResponseInstance(
21542149 this . _chunks = chunks ;
21552150 this . _stringDecoder = createStringDecoder ( ) ;
21562151 this . _fromJSON = ( null : any ) ;
2157- this . _rowState = 0 ;
2158- this . _rowID = 0 ;
2159- this . _rowTag = 0 ;
2160- this . _rowLength = 0 ;
2161- this . _buffer = [ ] ;
21622152 this . _closed = false ;
21632153 this . _closedReason = null ;
21642154 this . _tempRefs = temporaryReferences ;
@@ -2259,6 +2249,24 @@ export function createResponse(
22592249 ) ;
22602250}
22612251
2252+ export type StreamState = {
2253+ _rowState : RowParserState ,
2254+ _rowID : number , // parts of a row ID parsed so far
2255+ _rowTag : number , // 0 indicates that we're currently parsing the row ID
2256+ _rowLength : number , // remaining bytes in the row. 0 indicates that we're looking for a newline.
2257+ _buffer : Array < Uint8Array > , // chunks received so far as part of this row
2258+ } ;
2259+
2260+ export function createStreamState ( ) : StreamState {
2261+ return {
2262+ _rowState : 0 ,
2263+ _rowID : 0 ,
2264+ _rowTag : 0 ,
2265+ _rowLength : 0 ,
2266+ _buffer : [ ] ,
2267+ } ;
2268+ }
2269+
22622270function resolveDebugHalt ( response : Response , id : number ) : void {
22632271 const chunks = response . _chunks ;
22642272 let chunk = chunks . get ( id ) ;
@@ -3995,6 +4003,7 @@ function processFullStringRow(
39954003
39964004export function processBinaryChunk (
39974005 weakResponse : WeakResponse ,
4006+ streamState : StreamState ,
39984007 chunk : Uint8Array ,
39994008) : void {
40004009 if ( hasGCedResponse ( weakResponse ) ) {
@@ -4003,11 +4012,11 @@ export function processBinaryChunk(
40034012 }
40044013 const response = unwrapWeakResponse ( weakResponse ) ;
40054014 let i = 0 ;
4006- let rowState = response . _rowState ;
4007- let rowID = response . _rowID ;
4008- let rowTag = response . _rowTag ;
4009- let rowLength = response . _rowLength ;
4010- const buffer = response . _buffer ;
4015+ let rowState = streamState . _rowState ;
4016+ let rowID = streamState . _rowID ;
4017+ let rowTag = streamState . _rowTag ;
4018+ let rowLength = streamState . _rowLength ;
4019+ const buffer = streamState . _buffer ;
40114020 const chunkLength = chunk . length ;
40124021 while ( i < chunkLength ) {
40134022 let lastIdx = - 1 ;
@@ -4112,14 +4121,15 @@ export function processBinaryChunk(
41124121 break ;
41134122 }
41144123 }
4115- response . _rowState = rowState ;
4116- response . _rowID = rowID ;
4117- response . _rowTag = rowTag ;
4118- response . _rowLength = rowLength ;
4124+ streamState . _rowState = rowState ;
4125+ streamState . _rowID = rowID ;
4126+ streamState . _rowTag = rowTag ;
4127+ streamState . _rowLength = rowLength ;
41194128}
41204129
41214130export function processStringChunk (
41224131 weakResponse : WeakResponse ,
4132+ streamState : StreamState ,
41234133 chunk : string ,
41244134) : void {
41254135 if ( hasGCedResponse ( weakResponse ) ) {
@@ -4136,11 +4146,11 @@ export function processStringChunk(
41364146 // here. Basically, only if Flight Server gave you this string as a chunk,
41374147 // you can use it here.
41384148 let i = 0 ;
4139- let rowState = response . _rowState ;
4140- let rowID = response . _rowID ;
4141- let rowTag = response . _rowTag ;
4142- let rowLength = response . _rowLength ;
4143- const buffer = response . _buffer ;
4149+ let rowState = streamState . _rowState ;
4150+ let rowID = streamState . _rowID ;
4151+ let rowTag = streamState . _rowTag ;
4152+ let rowLength = streamState . _rowLength ;
4153+ const buffer = streamState . _buffer ;
41444154 const chunkLength = chunk . length ;
41454155 while ( i < chunkLength ) {
41464156 let lastIdx = - 1 ;
@@ -4264,10 +4274,10 @@ export function processStringChunk(
42644274 ) ;
42654275 }
42664276 }
4267- response . _rowState = rowState ;
4268- response . _rowID = rowID ;
4269- response . _rowTag = rowTag ;
4270- response . _rowLength = rowLength ;
4277+ streamState . _rowState = rowState ;
4278+ streamState . _rowID = rowID ;
4279+ streamState . _rowTag = rowTag ;
4280+ streamState . _rowLength = rowLength ;
42714281}
42724282
42734283function parseModel < T > ( response : Response , json : UninitializedModel ) : T {
0 commit comments