|
| 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 type Destination = { |
| 11 | + buffer: string, |
| 12 | + done: boolean, |
| 13 | + fatal: boolean, |
| 14 | + error: mixed, |
| 15 | +}; |
| 16 | + |
| 17 | +export opaque type PrecomputedChunk = string; |
| 18 | +export opaque type Chunk = string; |
| 19 | +export opaque type BinaryChunk = string; |
| 20 | + |
| 21 | +export function scheduleWork(callback: () => void) { |
| 22 | + // We don't schedule work in this model, and instead expect performWork to always be called repeatedly. |
| 23 | +} |
| 24 | + |
| 25 | +export function flushBuffered(destination: Destination) {} |
| 26 | + |
| 27 | +export const supportsRequestStorage = false; |
| 28 | +export const requestStorage: AsyncLocalStorage<Request> = (null: any); |
| 29 | + |
| 30 | +export function beginWriting(destination: Destination) {} |
| 31 | + |
| 32 | +export function writeChunk( |
| 33 | + destination: Destination, |
| 34 | + chunk: Chunk | PrecomputedChunk | BinaryChunk, |
| 35 | +): void { |
| 36 | + destination.buffer += chunk; |
| 37 | +} |
| 38 | + |
| 39 | +export function writeChunkAndReturn( |
| 40 | + destination: Destination, |
| 41 | + chunk: Chunk | PrecomputedChunk | BinaryChunk, |
| 42 | +): boolean { |
| 43 | + destination.buffer += chunk; |
| 44 | + return true; |
| 45 | +} |
| 46 | + |
| 47 | +export function completeWriting(destination: Destination) {} |
| 48 | + |
| 49 | +export function close(destination: Destination) { |
| 50 | + destination.done = true; |
| 51 | +} |
| 52 | + |
| 53 | +export function stringToChunk(content: string): Chunk { |
| 54 | + return content; |
| 55 | +} |
| 56 | + |
| 57 | +export function stringToPrecomputedChunk(content: string): PrecomputedChunk { |
| 58 | + return content; |
| 59 | +} |
| 60 | + |
| 61 | +export function typedArrayToBinaryChunk( |
| 62 | + content: $ArrayBufferView, |
| 63 | +): BinaryChunk { |
| 64 | + throw new Error('Not implemented.'); |
| 65 | +} |
| 66 | + |
| 67 | +export function clonePrecomputedChunk( |
| 68 | + chunk: PrecomputedChunk, |
| 69 | +): PrecomputedChunk { |
| 70 | + return chunk; |
| 71 | +} |
| 72 | + |
| 73 | +export function byteLengthOfChunk(chunk: Chunk | PrecomputedChunk): number { |
| 74 | + throw new Error('Not implemented.'); |
| 75 | +} |
| 76 | + |
| 77 | +export function byteLengthOfBinaryChunk(chunk: BinaryChunk): number { |
| 78 | + throw new Error('Not implemented.'); |
| 79 | +} |
| 80 | + |
| 81 | +export function closeWithError(destination: Destination, error: mixed): void { |
| 82 | + destination.done = true; |
| 83 | + destination.fatal = true; |
| 84 | + destination.error = error; |
| 85 | +} |
| 86 | + |
| 87 | +export {createFastHashJS as createFastHash} from './createFastHashJS'; |
0 commit comments