delete ReactServerStreamConfig.dom-fb-experimental.js (#29836)
delete ReactServerStreamConfig.dom-fb-experimental.js This config is no longer used since 1cd77a4ff7a2189003965246a3cfc475d2d9857d
Jan Kassens committed
Jun 12, 2024 at 11:12 UTC
62af6b22803d743ff5101f89be6f088ecfd46b00
1 file changed
-99
packages/react-server/src/forks/ReactServerStreamConfig.dom-fb-experimental.js
deleted
-99
@@ -1,99 +0,0 @@
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 * from '../ReactServerStreamConfigFB';
11
-
12
-import type {
13
- PrecomputedChunk,
14
- Chunk,
15
- BinaryChunk,
16
-} from '../ReactServerStreamConfigFB';
17
-
18
-let byteLengthImpl: null | ((chunk: Chunk | PrecomputedChunk) => number) = null;
19
-
20
-export function setByteLengthOfChunkImplementation(
21
- impl: (chunk: Chunk | PrecomputedChunk) => number,
22
-): void {
23
- byteLengthImpl = impl;
24
-}
25
-
26
-export function byteLengthOfChunk(chunk: Chunk | PrecomputedChunk): number {
27
- if (byteLengthImpl == null) {
28
- // eslint-disable-next-line react-internal/prod-error-codes
29
- throw new Error(
30
- 'byteLengthOfChunk implementation is not configured. Please, provide the implementation via ReactFlightDOMServer.setConfig(...);',
31
- );
32
- }
33
- return byteLengthImpl(chunk);
34
-}
35
-
36
-export interface Destination {
37
- beginWriting(): void;
38
- write(chunk: Chunk | PrecomputedChunk | BinaryChunk): void;
39
- completeWriting(): void;
40
- flushBuffered(): void;
41
- close(): void;
42
- onError(error: mixed): void;
43
-}
44
-
45
-function handleErrorInNextTick(error: any) {
46
- setTimeout(() => {
47
- throw error;
48
- });
49
-}
50
-
51
-const LocalPromise = Promise;
52
-
53
-/**
54
- * Since this environment doesn't have a way to schedule tasks from JS we schedule
55
- * using a microtask instead. This isn't necessarily ideal since we would like to give
56
- * other IO a chance to run before performing work typically but it's the best we can
57
- * do in this environment
58
- */
59
-export function scheduleWork(callback: () => void) {
60
- LocalPromise.resolve().then(callback).catch(handleErrorInNextTick);
61
-}
62
-
63
-export const scheduleMicrotask: (callback: () => void) => void = scheduleWork;
64
-
65
-export function beginWriting(destination: Destination) {
66
- destination.beginWriting();
67
-}
68
-
69
-export function writeChunk(
70
- destination: Destination,
71
- chunk: Chunk | PrecomputedChunk | BinaryChunk,
72
-): void {
73
- destination.write(chunk);
74
-}
75
-
76
-export function writeChunkAndReturn(
77
- destination: Destination,
78
- chunk: Chunk | PrecomputedChunk | BinaryChunk,
79
-): boolean {
80
- destination.write(chunk);
81
- return true;
82
-}
83
-
84
-export function completeWriting(destination: Destination) {
85
- destination.completeWriting();
86
-}
87
-
88
-export function flushBuffered(destination: Destination) {
89
- destination.flushBuffered();
90
-}
91
-
92
-export function close(destination: Destination) {
93
- destination.close();
94
-}
95
-
96
-export function closeWithError(destination: Destination, error: mixed): void {
97
- destination.onError(error);
98
- destination.close();
99
-}