node-web-streams-helper.d.ts 2.0 KB

12345678910111213141516171819202122232425262728
  1. /// <reference types="react" />
  2. export declare type ReactReadableStream = ReadableStream<Uint8Array> & {
  3. allReady?: Promise<void> | undefined;
  4. };
  5. export declare function encodeText(input: string): Uint8Array;
  6. export declare function decodeText(input?: Uint8Array, textDecoder?: TextDecoder): string;
  7. export declare function readableStreamTee<T = any>(readable: ReadableStream<T>): [ReadableStream<T>, ReadableStream<T>];
  8. export declare function chainStreams<T>(streams: ReadableStream<T>[]): ReadableStream<T>;
  9. export declare function streamFromArray(strings: string[]): ReadableStream<Uint8Array>;
  10. export declare function streamToString(stream: ReadableStream<Uint8Array>): Promise<string>;
  11. export declare function createBufferedTransformStream(transform?: (v: string) => string | Promise<string>): TransformStream<Uint8Array, Uint8Array>;
  12. export declare function createFlushEffectStream(handleFlushEffect: () => string): TransformStream<Uint8Array, Uint8Array>;
  13. export declare function renderToInitialStream({ ReactDOMServer, element, streamOptions, }: {
  14. ReactDOMServer: any;
  15. element: React.ReactElement;
  16. streamOptions?: any;
  17. }): Promise<ReactReadableStream>;
  18. export declare function createHeadInjectionTransformStream(inject: () => string): TransformStream<Uint8Array, Uint8Array>;
  19. export declare function createDeferredSuffixStream(suffix: string): TransformStream<Uint8Array, Uint8Array>;
  20. export declare function createInlineDataStream(dataStream: ReadableStream<Uint8Array>): TransformStream<Uint8Array, Uint8Array>;
  21. export declare function createSuffixStream(suffix: string): TransformStream<Uint8Array, Uint8Array>;
  22. export declare function continueFromInitialStream(renderStream: ReactReadableStream, { suffix, dataStream, generateStaticHTML, flushEffectHandler, flushEffectsToHead, }: {
  23. suffix?: string;
  24. dataStream?: ReadableStream<Uint8Array>;
  25. generateStaticHTML: boolean;
  26. flushEffectHandler?: () => string;
  27. flushEffectsToHead: boolean;
  28. }): Promise<ReadableStream<Uint8Array>>;