exportfunctioncreateBuffer() {letappendable=falseconstbuffer: SSRBuffer=[]return{getBuffer():SSRBuffer{// Return static buffer and await on items during unroll stage
returnbuffer},push(item: SSRBufferItem){constisStringItem=isString(item)if(appendable&&isStringItem){buffer[buffer.length-1]+=itemasstring}else{buffer.push(item)}appendable=isStringItemif(isPromise(item)||(isArray(item)&&item.hasAsync)){// promise, or child buffer with async, mark as async.
// this allows skipping unnecessary await ticks during unroll stage
// 标记为异步 buffer
buffer.hasAsync=true}}}}