@samitouri / QOS-React / commits / 08dfd0b805

Remove enableBinaryflight (#31759)

Based off https://github.com/facebook/react/pull/31757 This has landed everywhere.

Ricky committed Dec 13, 2024 at 14:50 UTC 08dfd0b8053d8d712607d3f37ddbb4da00c351f1
17 files changed +352 -399
packages/react-client/src/ReactFlightClient.js
+73 -81
@@ -43,7 +43,6 @@ import type {Postpone} from 'react/src/ReactPostpone';
43 import type {TemporaryReferenceSet} from './ReactFlightTemporaryReferences';
44
45 import {
46 - enableBinaryFlight,
46 enablePostpone,
47 enableFlightReadableStream,
48 enableOwnerStacks,
@@ -1461,11 +1460,8 @@ function parseModelString(
1460 }
1461 case 'B': {
1462 // Blob
1464 - if (enableBinaryFlight) {
1465 - const ref = value.slice(2);
1466 - return getOutlinedModel(response, ref, parentObject, key, createBlob);
1467 - }
1468 - return undefined;
1463 + const ref = value.slice(2);
1464 + return getOutlinedModel(response, ref, parentObject, key, createBlob);
1465 }
1466 case 'K': {
1467 // FormData
@@ -2821,53 +2817,51 @@ function processFullBinaryRow(
2817 buffer: Array<Uint8Array>,
2818 chunk: Uint8Array,
2819 ): void {
2824 - if (enableBinaryFlight) {
2825 - switch (tag) {
2826 - case 65 /* "A" */:
2827 - // We must always clone to extract it into a separate buffer instead of just a view.
2828 - resolveBuffer(response, id, mergeBuffer(buffer, chunk).buffer);
2829 - return;
2830 - case 79 /* "O" */:
2831 - resolveTypedArray(response, id, buffer, chunk, Int8Array, 1);
2832 - return;
2833 - case 111 /* "o" */:
2834 - resolveBuffer(
2835 - response,
2836 - id,
2837 - buffer.length === 0 ? chunk : mergeBuffer(buffer, chunk),
2838 - );
2839 - return;
2840 - case 85 /* "U" */:
2841 - resolveTypedArray(response, id, buffer, chunk, Uint8ClampedArray, 1);
2842 - return;
2843 - case 83 /* "S" */:
2844 - resolveTypedArray(response, id, buffer, chunk, Int16Array, 2);
2845 - return;
2846 - case 115 /* "s" */:
2847 - resolveTypedArray(response, id, buffer, chunk, Uint16Array, 2);
2848 - return;
2849 - case 76 /* "L" */:
2850 - resolveTypedArray(response, id, buffer, chunk, Int32Array, 4);
2851 - return;
2852 - case 108 /* "l" */:
2853 - resolveTypedArray(response, id, buffer, chunk, Uint32Array, 4);
2854 - return;
2855 - case 71 /* "G" */:
2856 - resolveTypedArray(response, id, buffer, chunk, Float32Array, 4);
2857 - return;
2858 - case 103 /* "g" */:
2859 - resolveTypedArray(response, id, buffer, chunk, Float64Array, 8);
2860 - return;
2861 - case 77 /* "M" */:
2862 - resolveTypedArray(response, id, buffer, chunk, BigInt64Array, 8);
2863 - return;
2864 - case 109 /* "m" */:
2865 - resolveTypedArray(response, id, buffer, chunk, BigUint64Array, 8);
2866 - return;
2867 - case 86 /* "V" */:
2868 - resolveTypedArray(response, id, buffer, chunk, DataView, 1);
2869 - return;
2870 - }
2820 + switch (tag) {
2821 + case 65 /* "A" */:
2822 + // We must always clone to extract it into a separate buffer instead of just a view.
2823 + resolveBuffer(response, id, mergeBuffer(buffer, chunk).buffer);
2824 + return;
2825 + case 79 /* "O" */:
2826 + resolveTypedArray(response, id, buffer, chunk, Int8Array, 1);
2827 + return;
2828 + case 111 /* "o" */:
2829 + resolveBuffer(
2830 + response,
2831 + id,
2832 + buffer.length === 0 ? chunk : mergeBuffer(buffer, chunk),
2833 + );
2834 + return;
2835 + case 85 /* "U" */:
2836 + resolveTypedArray(response, id, buffer, chunk, Uint8ClampedArray, 1);
2837 + return;
2838 + case 83 /* "S" */:
2839 + resolveTypedArray(response, id, buffer, chunk, Int16Array, 2);
2840 + return;
2841 + case 115 /* "s" */:
2842 + resolveTypedArray(response, id, buffer, chunk, Uint16Array, 2);
2843 + return;
2844 + case 76 /* "L" */:
2845 + resolveTypedArray(response, id, buffer, chunk, Int32Array, 4);
2846 + return;
2847 + case 108 /* "l" */:
2848 + resolveTypedArray(response, id, buffer, chunk, Uint32Array, 4);
2849 + return;
2850 + case 71 /* "G" */:
2851 + resolveTypedArray(response, id, buffer, chunk, Float32Array, 4);
2852 + return;
2853 + case 103 /* "g" */:
2854 + resolveTypedArray(response, id, buffer, chunk, Float64Array, 8);
2855 + return;
2856 + case 77 /* "M" */:
2857 + resolveTypedArray(response, id, buffer, chunk, BigInt64Array, 8);
2858 + return;
2859 + case 109 /* "m" */:
2860 + resolveTypedArray(response, id, buffer, chunk, BigUint64Array, 8);
2861 + return;
2862 + case 86 /* "V" */:
2863 + resolveTypedArray(response, id, buffer, chunk, DataView, 1);
2864 + return;
2865 }
2866
2867 const stringDecoder = response._stringDecoder;
@@ -3061,20 +3055,19 @@ export function processBinaryChunk(
3055 const resolvedRowTag = chunk[i];
3056 if (
3057 resolvedRowTag === 84 /* "T" */ ||
3064 - (enableBinaryFlight &&
3065 - (resolvedRowTag === 65 /* "A" */ ||
3066 - resolvedRowTag === 79 /* "O" */ ||
3067 - resolvedRowTag === 111 /* "o" */ ||
3068 - resolvedRowTag === 85 /* "U" */ ||
3069 - resolvedRowTag === 83 /* "S" */ ||
3070 - resolvedRowTag === 115 /* "s" */ ||
3071 - resolvedRowTag === 76 /* "L" */ ||
3072 - resolvedRowTag === 108 /* "l" */ ||
3073 - resolvedRowTag === 71 /* "G" */ ||
3074 - resolvedRowTag === 103 /* "g" */ ||
3075 - resolvedRowTag === 77 /* "M" */ ||
3076 - resolvedRowTag === 109 /* "m" */ ||
3077 - resolvedRowTag === 86)) /* "V" */
3058 + resolvedRowTag === 65 /* "A" */ ||
3059 + resolvedRowTag === 79 /* "O" */ ||
3060 + resolvedRowTag === 111 /* "o" */ ||
3061 + resolvedRowTag === 85 /* "U" */ ||
3062 + resolvedRowTag === 83 /* "S" */ ||
3063 + resolvedRowTag === 115 /* "s" */ ||
3064 + resolvedRowTag === 76 /* "L" */ ||
3065 + resolvedRowTag === 108 /* "l" */ ||
3066 + resolvedRowTag === 71 /* "G" */ ||
3067 + resolvedRowTag === 103 /* "g" */ ||
3068 + resolvedRowTag === 77 /* "M" */ ||
3069 + resolvedRowTag === 109 /* "m" */ ||
3070 + resolvedRowTag === 86 /* "V" */
3071 ) {
3072 rowTag = resolvedRowTag;
3073 rowState = ROW_LENGTH;
@@ -3187,20 +3180,19 @@ export function processStringChunk(response: Response, chunk: string): void {
3180 const resolvedRowTag = chunk.charCodeAt(i);
3181 if (
3182 resolvedRowTag === 84 /* "T" */ ||
3190 - (enableBinaryFlight &&
3191 - (resolvedRowTag === 65 /* "A" */ ||
3192 - resolvedRowTag === 79 /* "O" */ ||
3193 - resolvedRowTag === 111 /* "o" */ ||
3194 - resolvedRowTag === 85 /* "U" */ ||
3195 - resolvedRowTag === 83 /* "S" */ ||
3196 - resolvedRowTag === 115 /* "s" */ ||
3197 - resolvedRowTag === 76 /* "L" */ ||
3198 - resolvedRowTag === 108 /* "l" */ ||
3199 - resolvedRowTag === 71 /* "G" */ ||
3200 - resolvedRowTag === 103 /* "g" */ ||
3201 - resolvedRowTag === 77 /* "M" */ ||
3202 - resolvedRowTag === 109 /* "m" */ ||
3203 - resolvedRowTag === 86)) /* "V" */
3183 + resolvedRowTag === 65 /* "A" */ ||
3184 + resolvedRowTag === 79 /* "O" */ ||
3185 + resolvedRowTag === 111 /* "o" */ ||
3186 + resolvedRowTag === 85 /* "U" */ ||
3187 + resolvedRowTag === 83 /* "S" */ ||
3188 + resolvedRowTag === 115 /* "s" */ ||
3189 + resolvedRowTag === 76 /* "L" */ ||
3190 + resolvedRowTag === 108 /* "l" */ ||
3191 + resolvedRowTag === 71 /* "G" */ ||
3192 + resolvedRowTag === 103 /* "g" */ ||
3193 + resolvedRowTag === 77 /* "M" */ ||
3194 + resolvedRowTag === 109 /* "m" */ ||
3195 + resolvedRowTag === 86 /* "V" */
3196 ) {
3197 rowTag = resolvedRowTag;
3198 rowState = ROW_LENGTH;
packages/react-client/src/ReactFlightReplyClient.js
+63 -66
@@ -20,7 +20,6 @@ import type {TemporaryReferenceSet} from './ReactFlightTemporaryReferences';
20
21 import {
22 enableRenderableContext,
23 - enableBinaryFlight,
23 enableFlightReadableStream,
24 } from 'shared/ReactFeatureFlags';
25
@@ -578,73 +577,71 @@ export function processReply(
577 return serializeSetID(setId);
578 }
579
581 - if (enableBinaryFlight) {
582 - if (value instanceof ArrayBuffer) {
583 - const blob = new Blob([value]);
584 - const blobId = nextPartId++;
585 - if (formData === null) {
586 - formData = new FormData();
587 - }
588 - formData.append(formFieldPrefix + blobId, blob);
589 - return '$' + 'A' + blobId.toString(16);
590 - }
591 - if (value instanceof Int8Array) {
592 - // char
593 - return serializeTypedArray('O', value);
594 - }
595 - if (value instanceof Uint8Array) {
596 - // unsigned char
597 - return serializeTypedArray('o', value);
598 - }
599 - if (value instanceof Uint8ClampedArray) {
600 - // unsigned clamped char
601 - return serializeTypedArray('U', value);
602 - }
603 - if (value instanceof Int16Array) {
604 - // sort
605 - return serializeTypedArray('S', value);
606 - }
607 - if (value instanceof Uint16Array) {
608 - // unsigned short
609 - return serializeTypedArray('s', value);
610 - }
611 - if (value instanceof Int32Array) {
612 - // long
613 - return serializeTypedArray('L', value);
614 - }
615 - if (value instanceof Uint32Array) {
616 - // unsigned long
617 - return serializeTypedArray('l', value);
618 - }
619 - if (value instanceof Float32Array) {
620 - // float
621 - return serializeTypedArray('G', value);
622 - }
623 - if (value instanceof Float64Array) {
624 - // double
625 - return serializeTypedArray('g', value);
626 - }
627 - if (value instanceof BigInt64Array) {
628 - // number
629 - return serializeTypedArray('M', value);
630 - }
631 - if (value instanceof BigUint64Array) {
632 - // unsigned number
633 - // We use "m" instead of "n" since JSON can start with "null"
634 - return serializeTypedArray('m', value);
635 - }
636 - if (value instanceof DataView) {
637 - return serializeTypedArray('V', value);
580 + if (value instanceof ArrayBuffer) {
581 + const blob = new Blob([value]);
582 + const blobId = nextPartId++;
583 + if (formData === null) {
584 + formData = new FormData();
585 }
639 - // TODO: Blob is not available in old Node/browsers. Remove the typeof check later.
640 - if (typeof Blob === 'function' && value instanceof Blob) {
641 - if (formData === null) {
642 - formData = new FormData();
643 - }
644 - const blobId = nextPartId++;
645 - formData.append(formFieldPrefix + blobId, value);
646 - return serializeBlobID(blobId);
586 + formData.append(formFieldPrefix + blobId, blob);
587 + return '$' + 'A' + blobId.toString(16);
588 + }
589 + if (value instanceof Int8Array) {
590 + // char
591 + return serializeTypedArray('O', value);
592 + }
593 + if (value instanceof Uint8Array) {
594 + // unsigned char
595 + return serializeTypedArray('o', value);
596 + }
597 + if (value instanceof Uint8ClampedArray) {
598 + // unsigned clamped char
599 + return serializeTypedArray('U', value);
600 + }
601 + if (value instanceof Int16Array) {
602 + // sort
603 + return serializeTypedArray('S', value);
604 + }
605 + if (value instanceof Uint16Array) {
606 + // unsigned short
607 + return serializeTypedArray('s', value);
608 + }
609 + if (value instanceof Int32Array) {
610 + // long
611 + return serializeTypedArray('L', value);
612 + }
613 + if (value instanceof Uint32Array) {
614 + // unsigned long
615 + return serializeTypedArray('l', value);
616 + }
617 + if (value instanceof Float32Array) {
618 + // float
619 + return serializeTypedArray('G', value);
620 + }
621 + if (value instanceof Float64Array) {
622 + // double
623 + return serializeTypedArray('g', value);
624 + }
625 + if (value instanceof BigInt64Array) {
626 + // number
627 + return serializeTypedArray('M', value);
628 + }
629 + if (value instanceof BigUint64Array) {
630 + // unsigned number
631 + // We use "m" instead of "n" since JSON can start with "null"
632 + return serializeTypedArray('m', value);
633 + }
634 + if (value instanceof DataView) {
635 + return serializeTypedArray('V', value);
636 + }
637 + // TODO: Blob is not available in old Node/browsers. Remove the typeof check later.
638 + if (typeof Blob === 'function' && value instanceof Blob) {
639 + if (formData === null) {
640 + formData = new FormData();
641 }
642 + const blobId = nextPartId++;
643 + formData.append(formFieldPrefix + blobId, value);
644 + return serializeBlobID(blobId);
645 }
646
647 const iteratorFn = getIteratorFn(value);
packages/react-client/src/__tests__/ReactFlight-test.js
+1 -1
@@ -2059,7 +2059,7 @@ describe('ReactFlight', () => {
2059 expect(errors).toEqual(['Cannot pass a secret token to the client']);
2060 });
2061
2062 - // @gate enableTaint && enableBinaryFlight
2062 + // @gate enableTaint
2063 it('errors when a tainted binary value is serialized', async () => {
2064 function UserClient({user}) {
2065 return <span>{user.name}</span>;
packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js
+2 -5
@@ -524,7 +524,6 @@ describe('ReactFlightDOMEdge', () => {
524 expect(serializedContent.length).toBeLessThan(150 + expectedDebugInfoSize);
525 });
526
527 - // @gate enableBinaryFlight
527 it('should be able to serialize any kind of typed array', async () => {
528 const buffer = new Uint8Array([
529 123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
@@ -556,7 +555,6 @@ describe('ReactFlightDOMEdge', () => {
555 expect(result).toEqual(buffers);
556 });
557
559 - // @gate enableBinaryFlight
558 it('should be able to serialize a blob', async () => {
559 const bytes = new Uint8Array([
560 123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
@@ -578,7 +576,6 @@ describe('ReactFlightDOMEdge', () => {
576 expect(await result.arrayBuffer()).toEqual(await blob.arrayBuffer());
577 });
578
581 - // @gate enableBinaryFlight
579 it('can transport FormData (blobs)', async () => {
580 const bytes = new Uint8Array([
581 123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
@@ -823,7 +820,7 @@ describe('ReactFlightDOMEdge', () => {
820 );
821 });
822
826 - // @gate enableFlightReadableStream && enableBinaryFlight
823 + // @gate enableFlightReadableStream
824 it('should supports ReadableStreams with typed arrays', async () => {
825 const buffer = new Uint8Array([
826 123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
@@ -882,7 +879,7 @@ describe('ReactFlightDOMEdge', () => {
879 expect(streamedBuffers).toEqual(buffers);
880 });
881
885 - // @gate enableFlightReadableStream && enableBinaryFlight
882 + // @gate enableFlightReadableStream
883 it('should support BYOB binary ReadableStreams', async () => {
884 const buffer = new Uint8Array([
885 123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js
-1
@@ -972,7 +972,6 @@ describe('ReactFlightDOMForm', () => {
972 expect(form2.firstChild.tagName).toBe('DIV');
973 });
974
975 - // @gate enableBinaryFlight
975 it('useActionState can return binary state during MPA form submission', async () => {
976 const serverAction = serverExports(
977 async function action(prevState, formData) {
packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMNode-test.js
-1
@@ -197,7 +197,6 @@ describe('ReactFlightDOMNode', () => {
197 expect(result.text).toBe(testString);
198 });
199
200 - // @gate enableBinaryFlight
200 it('should be able to serialize any kind of typed array', async () => {
201 const buffer = new Uint8Array([
202 123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReplyEdge-test.js
+2 -5
@@ -53,7 +53,6 @@ describe('ReactFlightDOMReplyEdge', () => {
53 expect(decoded).toEqual({some: 'object'});
54 });
55
56 - // @gate enableBinaryFlight
56 it('should be able to serialize any kind of typed array', async () => {
57 const buffer = new Uint8Array([
58 123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
@@ -85,7 +84,6 @@ describe('ReactFlightDOMReplyEdge', () => {
84 expect(new Uint8Array(result[0])).toEqual(new Uint8Array(buffers[0]));
85 });
86
88 - // @gate enableBinaryFlight
87 it('should be able to serialize a typed array inside a Map', async () => {
88 const array = new Uint8Array([
89 123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
@@ -102,7 +100,6 @@ describe('ReactFlightDOMReplyEdge', () => {
100 expect(result.get('array')).toEqual(array);
101 });
102
105 - // @gate enableBinaryFlight
103 it('should be able to serialize a blob', async () => {
104 const bytes = new Uint8Array([
105 123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
@@ -150,7 +147,7 @@ describe('ReactFlightDOMReplyEdge', () => {
147 expect(await resultBlob.arrayBuffer()).toEqual(await blob.arrayBuffer());
148 });
149
153 - // @gate enableFlightReadableStream && enableBinaryFlight
150 + // @gate enableFlightReadableStream
151 it('should supports ReadableStreams with typed arrays', async () => {
152 const buffer = new Uint8Array([
153 123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
@@ -197,7 +194,7 @@ describe('ReactFlightDOMReplyEdge', () => {
194 expect(streamedBuffers).toEqual(buffers);
195 });
196
200 - // @gate enableFlightReadableStream && enableBinaryFlight
197 + // @gate enableFlightReadableStream
198 it('should support BYOB binary ReadableStreams', async () => {
199 const buffer = new Uint8Array([
200 123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
packages/react-server/src/ReactFlightReplyServer.js
+37 -49
@@ -30,10 +30,7 @@ import {
30 createTemporaryReference,
31 registerTemporaryReference,
32 } from './ReactFlightServerTemporaryReferences';
33 -import {
34 - enableBinaryFlight,
35 - enableFlightReadableStream,
36 -} from 'shared/ReactFeatureFlags';
33 +import {enableFlightReadableStream} from 'shared/ReactFeatureFlags';
34 import {ASYNC_ITERATOR} from 'shared/ReactSymbols';
35
36 import hasOwnProperty from 'shared/hasOwnProperty';
@@ -1019,51 +1016,42 @@ function parseModelString(
1016 return BigInt(value.slice(2));
1017 }
1018 }
1022 - if (enableBinaryFlight) {
1023 - switch (value[1]) {
1024 - case 'A':
1025 - return parseTypedArray(response, value, ArrayBuffer, 1, obj, key);
1026 - case 'O':
1027 - return parseTypedArray(response, value, Int8Array, 1, obj, key);
1028 - case 'o':
1029 - return parseTypedArray(response, value, Uint8Array, 1, obj, key);
1030 - case 'U':
1031 - return parseTypedArray(
1032 - response,
1033 - value,
1034 - Uint8ClampedArray,
1035 - 1,
1036 - obj,
1037 - key,
1038 - );
1039 - case 'S':
1040 - return parseTypedArray(response, value, Int16Array, 2, obj, key);
1041 - case 's':
1042 - return parseTypedArray(response, value, Uint16Array, 2, obj, key);
1043 - case 'L':
1044 - return parseTypedArray(response, value, Int32Array, 4, obj, key);
1045 - case 'l':
1046 - return parseTypedArray(response, value, Uint32Array, 4, obj, key);
1047 - case 'G':
1048 - return parseTypedArray(response, value, Float32Array, 4, obj, key);
1049 - case 'g':
1050 - return parseTypedArray(response, value, Float64Array, 8, obj, key);
1051 - case 'M':
1052 - return parseTypedArray(response, value, BigInt64Array, 8, obj, key);
1053 - case 'm':
1054 - return parseTypedArray(response, value, BigUint64Array, 8, obj, key);
1055 - case 'V':
1056 - return parseTypedArray(response, value, DataView, 1, obj, key);
1057 - case 'B': {
1058 - // Blob
1059 - const id = parseInt(value.slice(2), 16);
1060 - const prefix = response._prefix;
1061 - const blobKey = prefix + id;
1062 - // We should have this backingEntry in the store already because we emitted
1063 - // it before referencing it. It should be a Blob.
1064 - const backingEntry: Blob = (response._formData.get(blobKey): any);
1065 - return backingEntry;
1066 - }
1019 + switch (value[1]) {
1020 + case 'A':
1021 + return parseTypedArray(response, value, ArrayBuffer, 1, obj, key);
1022 + case 'O':
1023 + return parseTypedArray(response, value, Int8Array, 1, obj, key);
1024 + case 'o':
1025 + return parseTypedArray(response, value, Uint8Array, 1, obj, key);
1026 + case 'U':
1027 + return parseTypedArray(response, value, Uint8ClampedArray, 1, obj, key);
1028 + case 'S':
1029 + return parseTypedArray(response, value, Int16Array, 2, obj, key);
1030 + case 's':
1031 + return parseTypedArray(response, value, Uint16Array, 2, obj, key);
1032 + case 'L':
1033 + return parseTypedArray(response, value, Int32Array, 4, obj, key);
1034 + case 'l':
1035 + return parseTypedArray(response, value, Uint32Array, 4, obj, key);
1036 + case 'G':
1037 + return parseTypedArray(response, value, Float32Array, 4, obj, key);
1038 + case 'g':
1039 + return parseTypedArray(response, value, Float64Array, 8, obj, key);
1040 + case 'M':
1041 + return parseTypedArray(response, value, BigInt64Array, 8, obj, key);
1042 + case 'm':
1043 + return parseTypedArray(response, value, BigUint64Array, 8, obj, key);
1044 + case 'V':
1045 + return parseTypedArray(response, value, DataView, 1, obj, key);
1046 + case 'B': {
1047 + // Blob
1048 + const id = parseInt(value.slice(2), 16);
1049 + const prefix = response._prefix;
1050 + const blobKey = prefix + id;
1051 + // We should have this backingEntry in the store already because we emitted
1052 + // it before referencing it. It should be a Blob.
1053 + const backingEntry: Blob = (response._formData.get(blobKey): any);
1054 + return backingEntry;
1055 }
1056 }
1057 if (enableFlightReadableStream) {
packages/react-server/src/ReactFlightServer.js
+171 -180
@@ -14,7 +14,6 @@ import type {Postpone} from 'react/src/ReactPostpone';
14 import type {TemporaryReferenceSet} from './ReactFlightServerTemporaryReferences';
15
16 import {
17 - enableBinaryFlight,
17 enablePostpone,
18 enableHalt,
19 enableTaint,
@@ -2696,63 +2695,60 @@ function renderModelDestructive(
2695 if (value instanceof Error) {
2696 return serializeErrorValue(request, value);
2697 }
2699 -
2700 - if (enableBinaryFlight) {
2701 - if (value instanceof ArrayBuffer) {
2702 - return serializeTypedArray(request, 'A', new Uint8Array(value));
2703 - }
2704 - if (value instanceof Int8Array) {
2705 - // char
2706 - return serializeTypedArray(request, 'O', value);
2707 - }
2708 - if (value instanceof Uint8Array) {
2709 - // unsigned char
2710 - return serializeTypedArray(request, 'o', value);
2711 - }
2712 - if (value instanceof Uint8ClampedArray) {
2713 - // unsigned clamped char
2714 - return serializeTypedArray(request, 'U', value);
2715 - }
2716 - if (value instanceof Int16Array) {
2717 - // sort
2718 - return serializeTypedArray(request, 'S', value);
2719 - }
2720 - if (value instanceof Uint16Array) {
2721 - // unsigned short
2722 - return serializeTypedArray(request, 's', value);
2723 - }
2724 - if (value instanceof Int32Array) {
2725 - // long
2726 - return serializeTypedArray(request, 'L', value);
2727 - }
2728 - if (value instanceof Uint32Array) {
2729 - // unsigned long
2730 - return serializeTypedArray(request, 'l', value);
2731 - }
2732 - if (value instanceof Float32Array) {
2733 - // float
2734 - return serializeTypedArray(request, 'G', value);
2735 - }
2736 - if (value instanceof Float64Array) {
2737 - // double
2738 - return serializeTypedArray(request, 'g', value);
2739 - }
2740 - if (value instanceof BigInt64Array) {
2741 - // number
2742 - return serializeTypedArray(request, 'M', value);
2743 - }
2744 - if (value instanceof BigUint64Array) {
2745 - // unsigned number
2746 - // We use "m" instead of "n" since JSON can start with "null"
2747 - return serializeTypedArray(request, 'm', value);
2748 - }
2749 - if (value instanceof DataView) {
2750 - return serializeTypedArray(request, 'V', value);
2751 - }
2752 - // TODO: Blob is not available in old Node. Remove the typeof check later.
2753 - if (typeof Blob === 'function' && value instanceof Blob) {
2754 - return serializeBlob(request, value);
2755 - }
2698 + if (value instanceof ArrayBuffer) {
2699 + return serializeTypedArray(request, 'A', new Uint8Array(value));
2700 + }
2701 + if (value instanceof Int8Array) {
2702 + // char
2703 + return serializeTypedArray(request, 'O', value);
2704 + }
2705 + if (value instanceof Uint8Array) {
2706 + // unsigned char
2707 + return serializeTypedArray(request, 'o', value);
2708 + }
2709 + if (value instanceof Uint8ClampedArray) {
2710 + // unsigned clamped char
2711 + return serializeTypedArray(request, 'U', value);
2712 + }
2713 + if (value instanceof Int16Array) {
2714 + // sort
2715 + return serializeTypedArray(request, 'S', value);
2716 + }
2717 + if (value instanceof Uint16Array) {
2718 + // unsigned short
2719 + return serializeTypedArray(request, 's', value);
2720 + }
2721 + if (value instanceof Int32Array) {
2722 + // long
2723 + return serializeTypedArray(request, 'L', value);
2724 + }
2725 + if (value instanceof Uint32Array) {
2726 + // unsigned long
2727 + return serializeTypedArray(request, 'l', value);
2728 + }
2729 + if (value instanceof Float32Array) {
2730 + // float
2731 + return serializeTypedArray(request, 'G', value);
2732 + }
2733 + if (value instanceof Float64Array) {
2734 + // double
2735 + return serializeTypedArray(request, 'g', value);
2736 + }
2737 + if (value instanceof BigInt64Array) {
2738 + // number
2739 + return serializeTypedArray(request, 'M', value);
2740 + }
2741 + if (value instanceof BigUint64Array) {
2742 + // unsigned number
2743 + // We use "m" instead of "n" since JSON can start with "null"
2744 + return serializeTypedArray(request, 'm', value);
2745 + }
2746 + if (value instanceof DataView) {
2747 + return serializeTypedArray(request, 'V', value);
2748 + }
2749 + // TODO: Blob is not available in old Node. Remove the typeof check later.
2750 + if (typeof Blob === 'function' && value instanceof Blob) {
2751 + return serializeBlob(request, value);
2752 }
2753
2754 const iteratorFn = getIteratorFn(value);
@@ -3532,63 +3528,60 @@ function renderConsoleValue(
3528 if (value instanceof Error) {
3529 return serializeErrorValue(request, value);
3530 }
3535 -
3536 - if (enableBinaryFlight) {
3537 - if (value instanceof ArrayBuffer) {
3538 - return serializeTypedArray(request, 'A', new Uint8Array(value));
3539 - }
3540 - if (value instanceof Int8Array) {
3541 - // char
3542 - return serializeTypedArray(request, 'O', value);
3543 - }
3544 - if (value instanceof Uint8Array) {
3545 - // unsigned char
3546 - return serializeTypedArray(request, 'o', value);
3547 - }
3548 - if (value instanceof Uint8ClampedArray) {
3549 - // unsigned clamped char
3550 - return serializeTypedArray(request, 'U', value);
3551 - }
3552 - if (value instanceof Int16Array) {
3553 - // sort
3554 - return serializeTypedArray(request, 'S', value);
3555 - }
3556 - if (value instanceof Uint16Array) {
3557 - // unsigned short
3558 - return serializeTypedArray(request, 's', value);
3559 - }
3560 - if (value instanceof Int32Array) {
3561 - // long
3562 - return serializeTypedArray(request, 'L', value);
3563 - }
3564 - if (value instanceof Uint32Array) {
3565 - // unsigned long
3566 - return serializeTypedArray(request, 'l', value);
3567 - }
3568 - if (value instanceof Float32Array) {
3569 - // float
3570 - return serializeTypedArray(request, 'G', value);
3571 - }
3572 - if (value instanceof Float64Array) {
3573 - // double
3574 - return serializeTypedArray(request, 'g', value);
3575 - }
3576 - if (value instanceof BigInt64Array) {
3577 - // number
3578 - return serializeTypedArray(request, 'M', value);
3579 - }
3580 - if (value instanceof BigUint64Array) {
3581 - // unsigned number
3582 - // We use "m" instead of "n" since JSON can start with "null"
3583 - return serializeTypedArray(request, 'm', value);
3584 - }
3585 - if (value instanceof DataView) {
3586 - return serializeTypedArray(request, 'V', value);
3587 - }
3588 - // TODO: Blob is not available in old Node. Remove the typeof check later.
3589 - if (typeof Blob === 'function' && value instanceof Blob) {
3590 - return serializeBlob(request, value);
3591 - }
3531 + if (value instanceof ArrayBuffer) {
3532 + return serializeTypedArray(request, 'A', new Uint8Array(value));
3533 + }
3534 + if (value instanceof Int8Array) {
3535 + // char
3536 + return serializeTypedArray(request, 'O', value);
3537 + }
3538 + if (value instanceof Uint8Array) {
3539 + // unsigned char
3540 + return serializeTypedArray(request, 'o', value);
3541 + }
3542 + if (value instanceof Uint8ClampedArray) {
3543 + // unsigned clamped char
3544 + return serializeTypedArray(request, 'U', value);
3545 + }
3546 + if (value instanceof Int16Array) {
3547 + // sort
3548 + return serializeTypedArray(request, 'S', value);
3549 + }
3550 + if (value instanceof Uint16Array) {
3551 + // unsigned short
3552 + return serializeTypedArray(request, 's', value);
3553 + }
3554 + if (value instanceof Int32Array) {
3555 + // long
3556 + return serializeTypedArray(request, 'L', value);
3557 + }
3558 + if (value instanceof Uint32Array) {
3559 + // unsigned long
3560 + return serializeTypedArray(request, 'l', value);
3561 + }
3562 + if (value instanceof Float32Array) {
3563 + // float
3564 + return serializeTypedArray(request, 'G', value);
3565 + }
3566 + if (value instanceof Float64Array) {
3567 + // double
3568 + return serializeTypedArray(request, 'g', value);
3569 + }
3570 + if (value instanceof BigInt64Array) {
3571 + // number
3572 + return serializeTypedArray(request, 'M', value);
3573 + }
3574 + if (value instanceof BigUint64Array) {
3575 + // unsigned number
3576 + // We use "m" instead of "n" since JSON can start with "null"
3577 + return serializeTypedArray(request, 'm', value);
3578 + }
3579 + if (value instanceof DataView) {
3580 + return serializeTypedArray(request, 'V', value);
3581 + }
3582 + // TODO: Blob is not available in old Node. Remove the typeof check later.
3583 + if (typeof Blob === 'function' && value instanceof Blob) {
3584 + return serializeBlob(request, value);
3585 }
3586
3587 const iteratorFn = getIteratorFn(value);
@@ -3878,71 +3871,69 @@ function emitChunk(
3871 emitTextChunk(request, id, value);
3872 return;
3873 }
3881 - if (enableBinaryFlight) {
3882 - if (value instanceof ArrayBuffer) {
3883 - emitTypedArrayChunk(request, id, 'A', new Uint8Array(value));
3884 - return;
3885 - }
3886 - if (value instanceof Int8Array) {
3887 - // char
3888 - emitTypedArrayChunk(request, id, 'O', value);
3889 - return;
3890 - }
3891 - if (value instanceof Uint8Array) {
3892 - // unsigned char
3893 - emitTypedArrayChunk(request, id, 'o', value);
3894 - return;
3895 - }
3896 - if (value instanceof Uint8ClampedArray) {
3897 - // unsigned clamped char
3898 - emitTypedArrayChunk(request, id, 'U', value);
3899 - return;
3900 - }
3901 - if (value instanceof Int16Array) {
3902 - // sort
3903 - emitTypedArrayChunk(request, id, 'S', value);
3904 - return;
3905 - }
3906 - if (value instanceof Uint16Array) {
3907 - // unsigned short
3908 - emitTypedArrayChunk(request, id, 's', value);
3909 - return;
3910 - }
3911 - if (value instanceof Int32Array) {
3912 - // long
3913 - emitTypedArrayChunk(request, id, 'L', value);
3914 - return;
3915 - }
3916 - if (value instanceof Uint32Array) {
3917 - // unsigned long
3918 - emitTypedArrayChunk(request, id, 'l', value);
3919 - return;
3920 - }
3921 - if (value instanceof Float32Array) {
3922 - // float
3923 - emitTypedArrayChunk(request, id, 'G', value);
3924 - return;
3925 - }
3926 - if (value instanceof Float64Array) {
3927 - // double
3928 - emitTypedArrayChunk(request, id, 'g', value);
3929 - return;
3930 - }
3931 - if (value instanceof BigInt64Array) {
3932 - // number
3933 - emitTypedArrayChunk(request, id, 'M', value);
3934 - return;
3935 - }
3936 - if (value instanceof BigUint64Array) {
3937 - // unsigned number
3938 - // We use "m" instead of "n" since JSON can start with "null"
3939 - emitTypedArrayChunk(request, id, 'm', value);
3940 - return;
3941 - }
3942 - if (value instanceof DataView) {
3943 - emitTypedArrayChunk(request, id, 'V', value);
3944 - return;
3945 - }
3874 + if (value instanceof ArrayBuffer) {
3875 + emitTypedArrayChunk(request, id, 'A', new Uint8Array(value));
3876 + return;
3877 + }
3878 + if (value instanceof Int8Array) {
3879 + // char
3880 + emitTypedArrayChunk(request, id, 'O', value);
3881 + return;
3882 + }
3883 + if (value instanceof Uint8Array) {
3884 + // unsigned char
3885 + emitTypedArrayChunk(request, id, 'o', value);
3886 + return;
3887 + }
3888 + if (value instanceof Uint8ClampedArray) {
3889 + // unsigned clamped char
3890 + emitTypedArrayChunk(request, id, 'U', value);
3891 + return;
3892 + }
3893 + if (value instanceof Int16Array) {
3894 + // sort
3895 + emitTypedArrayChunk(request, id, 'S', value);
3896 + return;
3897 + }
3898 + if (value instanceof Uint16Array) {
3899 + // unsigned short
3900 + emitTypedArrayChunk(request, id, 's', value);
3901 + return;
3902 + }
3903 + if (value instanceof Int32Array) {
3904 + // long
3905 + emitTypedArrayChunk(request, id, 'L', value);
3906 + return;
3907 + }
3908 + if (value instanceof Uint32Array) {
3909 + // unsigned long
3910 + emitTypedArrayChunk(request, id, 'l', value);
3911 + return;
3912 + }
3913 + if (value instanceof Float32Array) {
3914 + // float
3915 + emitTypedArrayChunk(request, id, 'G', value);
3916 + return;
3917 + }
3918 + if (value instanceof Float64Array) {
3919 + // double
3920 + emitTypedArrayChunk(request, id, 'g', value);
3921 + return;
3922 + }
3923 + if (value instanceof BigInt64Array) {
3924 + // number
3925 + emitTypedArrayChunk(request, id, 'M', value);
3926 + return;
3927 + }
3928 + if (value instanceof BigUint64Array) {
3929 + // unsigned number
3930 + // We use "m" instead of "n" since JSON can start with "null"
3931 + emitTypedArrayChunk(request, id, 'm', value);
3932 + return;
3933 + }
3934 + if (value instanceof DataView) {
3935 + emitTypedArrayChunk(request, id, 'V', value);
3936 + return;
3937 }
3938 // For anything else we need to try to serialize it using JSON.
3939 // $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
packages/react/src/ReactTaint.js
+3 -3
@@ -7,7 +7,7 @@
7 * @flow
8 */
9
10 -import {enableTaint, enableBinaryFlight} from 'shared/ReactFeatureFlags';
10 +import {enableTaint} from 'shared/ReactFeatureFlags';
11
12 import getPrototypeOf from 'shared/getPrototypeOf';
13
@@ -76,8 +76,8 @@ export function taintUniqueValue(
76 // Use as is.
77 entryValue = value;
78 } else if (
79 - enableBinaryFlight &&
80 - (value instanceof TypedArrayConstructor || value instanceof DataView)
79 + value instanceof TypedArrayConstructor ||
80 + value instanceof DataView
81 ) {
82 // For now, we just convert binary data to a string so that we can just use the native
83 // hashing in the Map implementation. It doesn't really matter what form the string
packages/shared/ReactFeatureFlags.js
-1
@@ -78,7 +78,6 @@ export const enableLegacyFBSupport = false;
78 export const enableCache = true;
79 export const enableLegacyCache = __EXPERIMENTAL__;
80
81 -export const enableBinaryFlight = true;
81 export const enableFlightReadableStream = true;
82 export const enableAsyncIterableChildren = __EXPERIMENTAL__;
83
packages/shared/forks/ReactFeatureFlags.native-fb.js
-1
@@ -44,7 +44,6 @@ export const disableSchedulerTimeoutInWorkLoop = false;
44 export const disableTextareaChildren = false;
45 export const enableAsyncDebugInfo = false;
46 export const enableAsyncIterableChildren = false;
47 -export const enableBinaryFlight = true;
47 export const enableCache = true;
48 export const enableComponentStackLocations = true;
49 export const enableCPUSuspense = true;
packages/shared/forks/ReactFeatureFlags.native-oss.js
-1
@@ -31,7 +31,6 @@ export const disableSchedulerTimeoutInWorkLoop = false;
31 export const disableTextareaChildren = false;
32 export const enableAsyncDebugInfo = false;
33 export const enableAsyncIterableChildren = false;
34 -export const enableBinaryFlight = true;
34 export const enableCache = true;
35 export const enableComponentStackLocations = true;
36 export const enableCPUSuspense = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.js
-1
@@ -21,7 +21,6 @@ export const enableComponentPerformanceTrack = false;
21 export const enableUpdaterTracking = false;
22 export const enableCache = true;
23 export const enableLegacyCache = __EXPERIMENTAL__;
24 -export const enableBinaryFlight = true;
24 export const enableFlightReadableStream = true;
25 export const enableAsyncIterableChildren = false;
26 export const enableTaint = true;
packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js
-1
@@ -23,7 +23,6 @@ export const disableSchedulerTimeoutInWorkLoop = false;
23 export const disableTextareaChildren = false;
24 export const enableAsyncDebugInfo = false;
25 export const enableAsyncIterableChildren = false;
26 -export const enableBinaryFlight = true;
26 export const enableCache = true;
27 export const enableComponentStackLocations = true;
28 export const enableCPUSuspense = true;
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
-1
@@ -21,7 +21,6 @@ export const enableComponentPerformanceTrack = false;
21 export const enableUpdaterTracking = false;
22 export const enableCache = true;
23 export const enableLegacyCache = true;
24 -export const enableBinaryFlight = true;
24 export const enableFlightReadableStream = true;
25 export const enableAsyncIterableChildren = false;
26 export const enableTaint = true;
packages/shared/forks/ReactFeatureFlags.www.js
-1
@@ -76,7 +76,6 @@ export const enableGetInspectorDataForInstanceInProduction = false;
76 export const enableCache = true;
77 export const enableLegacyCache = true;
78
79 -export const enableBinaryFlight = true;
79 export const enableFlightReadableStream = true;
80 export const enableAsyncIterableChildren = false;
81