From 86183388b83a3ac705c3230a166158ea3975049d Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Thu, 31 Aug 2023 16:14:47 -0400 Subject: [PATCH] Add the rest of the Streams API to installGlobals (#7321) --- .changeset/five-mugs-leave.md | 5 +++++ packages/remix-node/globals.ts | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 .changeset/five-mugs-leave.md diff --git a/.changeset/five-mugs-leave.md b/.changeset/five-mugs-leave.md new file mode 100644 index 00000000000..cb402b7dec8 --- /dev/null +++ b/.changeset/five-mugs-leave.md @@ -0,0 +1,5 @@ +--- +"@remix-run/node": patch +--- + +Add the rest of the Web Streams API to `installGlobals` diff --git a/packages/remix-node/globals.ts b/packages/remix-node/globals.ts index 2732cbe17c4..aadae3533ce 100644 --- a/packages/remix-node/globals.ts +++ b/packages/remix-node/globals.ts @@ -1,6 +1,17 @@ import { + ByteLengthQueuingStrategy as NodeByteLengthQueuingStrategy, + CountQueuingStrategy as NodeCountQueuingStrategy, + ReadableByteStreamController as NodeReadableByteStreamController, ReadableStream as NodeReadableStream, + ReadableStreamBYOBReader as NodeReadableStreamBYOBReader, + ReadableStreamBYOBRequest as NodeReadableStreamBYOBRequest, + ReadableStreamDefaultController as NodeReadableStreamDefaultController, + ReadableStreamDefaultReader as NodeReadableStreamDefaultReader, + TransformStream as NodeTransformStream, + TransformStreamDefaultController as NodeTransformStreamDefaultController, WritableStream as NodeWritableStream, + WritableStreamDefaultController as NodeWritableStreamDefaultController, + WritableStreamDefaultWriter as NodeWritableStreamDefaultWriter, } from "@remix-run/web-stream"; import { atob, btoa } from "./base64"; @@ -52,6 +63,19 @@ export function installGlobals() { global.fetch = nodeFetch as typeof fetch; global.FormData = NodeFormData; + // Export everything from https://developer.mozilla.org/en-US/docs/Web/API/Streams_API + global.ByteLengthQueuingStrategy = NodeByteLengthQueuingStrategy; + global.CountQueuingStrategy = NodeCountQueuingStrategy; + global.ReadableByteStreamController = NodeReadableByteStreamController; global.ReadableStream = NodeReadableStream; + global.ReadableStreamBYOBReader = NodeReadableStreamBYOBReader; + global.ReadableStreamBYOBRequest = NodeReadableStreamBYOBRequest; + global.ReadableStreamDefaultController = NodeReadableStreamDefaultController; + global.ReadableStreamDefaultReader = NodeReadableStreamDefaultReader; + global.TransformStream = NodeTransformStream; + global.TransformStreamDefaultController = + NodeTransformStreamDefaultController; global.WritableStream = NodeWritableStream; + global.WritableStreamDefaultController = NodeWritableStreamDefaultController; + global.WritableStreamDefaultWriter = NodeWritableStreamDefaultWriter; }