silverwolf-x/project / packages /next /src /server /app-render /debug-channel-server.web.ts
silverwolf-x's picture
download
raw
1.49 kB
/**
* Web debug channel implementation.
* Loaded by debug-channel-server.ts.
*/
import type { AnyStream } from './app-render-prerender-utils'
export type DebugChannelPair = {
serverSide: DebugChannelServer
clientSide: DebugChannelClient
}
export type DebugChannelServer = any
type DebugChannelClient = {
readable: AnyStream
}
/**
* Creates a debug channel using web WritableStream/ReadableStream.
* Use with renderToWebFlightStream (React's renderToReadableStream),
* which expects debugChannel = { writable: WritableStream }.
*/
export function createWebDebugChannel(): DebugChannelPair {
let readableController: ReadableStreamDefaultController | undefined
const clientSideReadable = new ReadableStream<Uint8Array>({
start(controller) {
readableController = controller
},
})
return {
serverSide: {
writable: new WritableStream<Uint8Array>({
write(chunk) {
readableController?.enqueue(chunk)
},
close() {
readableController?.close()
},
abort(err) {
readableController?.error(err)
},
}),
},
clientSide: { readable: clientSideReadable },
}
}
/**
* Creates a debug channel using Node.js streams.
* Use with renderToNodeFlightStream (React's renderToPipeableStream),
* which expects debugChannel to be a Node.js stream with a .write() method.
*/
export function createNodeDebugChannel(): DebugChannelPair {
throw new Error('not implemented')
}

Xet Storage Details

Size:
1.49 kB
·
Xet hash:
5d6fcb5a6fe4cc32afe20ca2c66777b46611cd0aa9285bf6406609d492093b9d

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.