feat(taildrop): stream files via ReadableStream on send and receive #11
Reference in New Issue
Block a user
Delete Branch "streaming-taildrop"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Removes whole-file buffering on both send and receive paths by wiring up the Web Streams API throughout the WASM/JS Taildrop bridge.
Changes
Send —
sendFilenow accepts aReadableStreamDefaultReaderstream +declaredSize. A newjsStreamReader(io.ReadCloser) pulls chunks from the JS stream by awaitingreader.read()Promises via the channel+js.FuncOfpattern. The full file is never copied into Go memory.Receive —
openWaitingFileresolves with a JSReadableStreaminstead of aUint8Array. A newjsReadableStream(rc io.ReadCloser)helper creates a pull-based stream: eachpullreturns a Promise; a goroutine reads up to 64 KiB and enqueues the chunk. Noio.ReadAll.FileOps —
jsFileOps.OpenReadernow expects JS to return aReadableStream; it wraps it injsStreamReaderfor streaming delivery to Go.JS API changes (breaking)
sendFile(stableNodeID, filename, data: Uint8Array)→sendFile(stableNodeID, filename, stream: ReadableStream<Uint8Array>, declaredSize: number)openWaitingFile(name)resolves withReadableStream<Uint8Array>instead ofUint8ArrayIPNFileOps.openReadercallback now passesReadableStream<Uint8Array>instead ofUint8ArrayCompanion PR in webnet for the JS/TS side: TBD