1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @flow
    
  8.  */
    
  9. 
    
  10. export interface Destination {
    
  11.   push(chunk: string | null): boolean;
    
  12.   destroy(error: Error): mixed;
    
  13. }
    
  14. 
    
  15. export opaque type PrecomputedChunk = string;
    
  16. export opaque type Chunk = string;
    
  17. export opaque type BinaryChunk = string;
    
  18. 
    
  19. export function scheduleWork(callback: () => void) {
    
  20.   callback();
    
  21. }
    
  22. 
    
  23. export function flushBuffered(destination: Destination) {}
    
  24. 
    
  25. export function beginWriting(destination: Destination) {}
    
  26. 
    
  27. export function writeChunk(
    
  28.   destination: Destination,
    
  29.   chunk: Chunk | PrecomputedChunk | BinaryChunk,
    
  30. ): void {
    
  31.   writeChunkAndReturn(destination, chunk);
    
  32. }
    
  33. 
    
  34. export function writeChunkAndReturn(
    
  35.   destination: Destination,
    
  36.   chunk: Chunk | PrecomputedChunk | BinaryChunk,
    
  37. ): boolean {
    
  38.   return destination.push(chunk);
    
  39. }
    
  40. 
    
  41. export function completeWriting(destination: Destination) {}
    
  42. 
    
  43. export function close(destination: Destination) {
    
  44.   destination.push(null);
    
  45. }
    
  46. 
    
  47. export function stringToChunk(content: string): Chunk {
    
  48.   return content;
    
  49. }
    
  50. 
    
  51. export function stringToPrecomputedChunk(content: string): PrecomputedChunk {
    
  52.   return content;
    
  53. }
    
  54. 
    
  55. export function typedArrayToBinaryChunk(
    
  56.   content: $ArrayBufferView,
    
  57. ): BinaryChunk {
    
  58.   throw new Error('Not implemented.');
    
  59. }
    
  60. 
    
  61. export function clonePrecomputedChunk(
    
  62.   chunk: PrecomputedChunk,
    
  63. ): PrecomputedChunk {
    
  64.   return chunk;
    
  65. }
    
  66. 
    
  67. export function byteLengthOfChunk(chunk: Chunk | PrecomputedChunk): number {
    
  68.   throw new Error('Not implemented.');
    
  69. }
    
  70. 
    
  71. export function byteLengthOfBinaryChunk(chunk: BinaryChunk): number {
    
  72.   throw new Error('Not implemented.');
    
  73. }
    
  74. 
    
  75. export function closeWithError(destination: Destination, error: mixed): void {
    
  76.   // $FlowFixMe[incompatible-call]: This is an Error object or the destination accepts other types.
    
  77.   destination.destroy(error);
    
  78. }
    
  79. 
    
  80. export {createFastHashJS as createFastHash} from 'react-server/src/createFastHashJS';