Skip to content

Commit

Permalink
Add the rest of the Streams API to installGlobals (#7321)
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 authored Aug 31, 2023
1 parent 2c5e018 commit 8618338
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-mugs-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/node": patch
---

Add the rest of the Web Streams API to `installGlobals`
24 changes: 24 additions & 0 deletions packages/remix-node/globals.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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;
}

0 comments on commit 8618338

Please sign in to comment.