mirror of
https://github.com/facebook/react.git
synced 2026-02-23 20:23:02 +00:00
Remove enableBinaryflight (#31759)
Based off https://github.com/facebook/react/pull/31757 This has landed everywhere.
This commit is contained in:
154
packages/react-client/src/ReactFlightClient.js
vendored
154
packages/react-client/src/ReactFlightClient.js
vendored
@@ -43,7 +43,6 @@ import type {Postpone} from 'react/src/ReactPostpone';
|
||||
import type {TemporaryReferenceSet} from './ReactFlightTemporaryReferences';
|
||||
|
||||
import {
|
||||
enableBinaryFlight,
|
||||
enablePostpone,
|
||||
enableFlightReadableStream,
|
||||
enableOwnerStacks,
|
||||
@@ -1461,11 +1460,8 @@ function parseModelString(
|
||||
}
|
||||
case 'B': {
|
||||
// Blob
|
||||
if (enableBinaryFlight) {
|
||||
const ref = value.slice(2);
|
||||
return getOutlinedModel(response, ref, parentObject, key, createBlob);
|
||||
}
|
||||
return undefined;
|
||||
const ref = value.slice(2);
|
||||
return getOutlinedModel(response, ref, parentObject, key, createBlob);
|
||||
}
|
||||
case 'K': {
|
||||
// FormData
|
||||
@@ -2821,53 +2817,51 @@ function processFullBinaryRow(
|
||||
buffer: Array<Uint8Array>,
|
||||
chunk: Uint8Array,
|
||||
): void {
|
||||
if (enableBinaryFlight) {
|
||||
switch (tag) {
|
||||
case 65 /* "A" */:
|
||||
// We must always clone to extract it into a separate buffer instead of just a view.
|
||||
resolveBuffer(response, id, mergeBuffer(buffer, chunk).buffer);
|
||||
return;
|
||||
case 79 /* "O" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Int8Array, 1);
|
||||
return;
|
||||
case 111 /* "o" */:
|
||||
resolveBuffer(
|
||||
response,
|
||||
id,
|
||||
buffer.length === 0 ? chunk : mergeBuffer(buffer, chunk),
|
||||
);
|
||||
return;
|
||||
case 85 /* "U" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Uint8ClampedArray, 1);
|
||||
return;
|
||||
case 83 /* "S" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Int16Array, 2);
|
||||
return;
|
||||
case 115 /* "s" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Uint16Array, 2);
|
||||
return;
|
||||
case 76 /* "L" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Int32Array, 4);
|
||||
return;
|
||||
case 108 /* "l" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Uint32Array, 4);
|
||||
return;
|
||||
case 71 /* "G" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Float32Array, 4);
|
||||
return;
|
||||
case 103 /* "g" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Float64Array, 8);
|
||||
return;
|
||||
case 77 /* "M" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, BigInt64Array, 8);
|
||||
return;
|
||||
case 109 /* "m" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, BigUint64Array, 8);
|
||||
return;
|
||||
case 86 /* "V" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, DataView, 1);
|
||||
return;
|
||||
}
|
||||
switch (tag) {
|
||||
case 65 /* "A" */:
|
||||
// We must always clone to extract it into a separate buffer instead of just a view.
|
||||
resolveBuffer(response, id, mergeBuffer(buffer, chunk).buffer);
|
||||
return;
|
||||
case 79 /* "O" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Int8Array, 1);
|
||||
return;
|
||||
case 111 /* "o" */:
|
||||
resolveBuffer(
|
||||
response,
|
||||
id,
|
||||
buffer.length === 0 ? chunk : mergeBuffer(buffer, chunk),
|
||||
);
|
||||
return;
|
||||
case 85 /* "U" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Uint8ClampedArray, 1);
|
||||
return;
|
||||
case 83 /* "S" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Int16Array, 2);
|
||||
return;
|
||||
case 115 /* "s" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Uint16Array, 2);
|
||||
return;
|
||||
case 76 /* "L" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Int32Array, 4);
|
||||
return;
|
||||
case 108 /* "l" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Uint32Array, 4);
|
||||
return;
|
||||
case 71 /* "G" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Float32Array, 4);
|
||||
return;
|
||||
case 103 /* "g" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, Float64Array, 8);
|
||||
return;
|
||||
case 77 /* "M" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, BigInt64Array, 8);
|
||||
return;
|
||||
case 109 /* "m" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, BigUint64Array, 8);
|
||||
return;
|
||||
case 86 /* "V" */:
|
||||
resolveTypedArray(response, id, buffer, chunk, DataView, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
const stringDecoder = response._stringDecoder;
|
||||
@@ -3061,20 +3055,19 @@ export function processBinaryChunk(
|
||||
const resolvedRowTag = chunk[i];
|
||||
if (
|
||||
resolvedRowTag === 84 /* "T" */ ||
|
||||
(enableBinaryFlight &&
|
||||
(resolvedRowTag === 65 /* "A" */ ||
|
||||
resolvedRowTag === 79 /* "O" */ ||
|
||||
resolvedRowTag === 111 /* "o" */ ||
|
||||
resolvedRowTag === 85 /* "U" */ ||
|
||||
resolvedRowTag === 83 /* "S" */ ||
|
||||
resolvedRowTag === 115 /* "s" */ ||
|
||||
resolvedRowTag === 76 /* "L" */ ||
|
||||
resolvedRowTag === 108 /* "l" */ ||
|
||||
resolvedRowTag === 71 /* "G" */ ||
|
||||
resolvedRowTag === 103 /* "g" */ ||
|
||||
resolvedRowTag === 77 /* "M" */ ||
|
||||
resolvedRowTag === 109 /* "m" */ ||
|
||||
resolvedRowTag === 86)) /* "V" */
|
||||
resolvedRowTag === 65 /* "A" */ ||
|
||||
resolvedRowTag === 79 /* "O" */ ||
|
||||
resolvedRowTag === 111 /* "o" */ ||
|
||||
resolvedRowTag === 85 /* "U" */ ||
|
||||
resolvedRowTag === 83 /* "S" */ ||
|
||||
resolvedRowTag === 115 /* "s" */ ||
|
||||
resolvedRowTag === 76 /* "L" */ ||
|
||||
resolvedRowTag === 108 /* "l" */ ||
|
||||
resolvedRowTag === 71 /* "G" */ ||
|
||||
resolvedRowTag === 103 /* "g" */ ||
|
||||
resolvedRowTag === 77 /* "M" */ ||
|
||||
resolvedRowTag === 109 /* "m" */ ||
|
||||
resolvedRowTag === 86 /* "V" */
|
||||
) {
|
||||
rowTag = resolvedRowTag;
|
||||
rowState = ROW_LENGTH;
|
||||
@@ -3187,20 +3180,19 @@ export function processStringChunk(response: Response, chunk: string): void {
|
||||
const resolvedRowTag = chunk.charCodeAt(i);
|
||||
if (
|
||||
resolvedRowTag === 84 /* "T" */ ||
|
||||
(enableBinaryFlight &&
|
||||
(resolvedRowTag === 65 /* "A" */ ||
|
||||
resolvedRowTag === 79 /* "O" */ ||
|
||||
resolvedRowTag === 111 /* "o" */ ||
|
||||
resolvedRowTag === 85 /* "U" */ ||
|
||||
resolvedRowTag === 83 /* "S" */ ||
|
||||
resolvedRowTag === 115 /* "s" */ ||
|
||||
resolvedRowTag === 76 /* "L" */ ||
|
||||
resolvedRowTag === 108 /* "l" */ ||
|
||||
resolvedRowTag === 71 /* "G" */ ||
|
||||
resolvedRowTag === 103 /* "g" */ ||
|
||||
resolvedRowTag === 77 /* "M" */ ||
|
||||
resolvedRowTag === 109 /* "m" */ ||
|
||||
resolvedRowTag === 86)) /* "V" */
|
||||
resolvedRowTag === 65 /* "A" */ ||
|
||||
resolvedRowTag === 79 /* "O" */ ||
|
||||
resolvedRowTag === 111 /* "o" */ ||
|
||||
resolvedRowTag === 85 /* "U" */ ||
|
||||
resolvedRowTag === 83 /* "S" */ ||
|
||||
resolvedRowTag === 115 /* "s" */ ||
|
||||
resolvedRowTag === 76 /* "L" */ ||
|
||||
resolvedRowTag === 108 /* "l" */ ||
|
||||
resolvedRowTag === 71 /* "G" */ ||
|
||||
resolvedRowTag === 103 /* "g" */ ||
|
||||
resolvedRowTag === 77 /* "M" */ ||
|
||||
resolvedRowTag === 109 /* "m" */ ||
|
||||
resolvedRowTag === 86 /* "V" */
|
||||
) {
|
||||
rowTag = resolvedRowTag;
|
||||
rowState = ROW_LENGTH;
|
||||
|
||||
129
packages/react-client/src/ReactFlightReplyClient.js
vendored
129
packages/react-client/src/ReactFlightReplyClient.js
vendored
@@ -20,7 +20,6 @@ import type {TemporaryReferenceSet} from './ReactFlightTemporaryReferences';
|
||||
|
||||
import {
|
||||
enableRenderableContext,
|
||||
enableBinaryFlight,
|
||||
enableFlightReadableStream,
|
||||
} from 'shared/ReactFeatureFlags';
|
||||
|
||||
@@ -578,73 +577,71 @@ export function processReply(
|
||||
return serializeSetID(setId);
|
||||
}
|
||||
|
||||
if (enableBinaryFlight) {
|
||||
if (value instanceof ArrayBuffer) {
|
||||
const blob = new Blob([value]);
|
||||
const blobId = nextPartId++;
|
||||
if (formData === null) {
|
||||
formData = new FormData();
|
||||
}
|
||||
formData.append(formFieldPrefix + blobId, blob);
|
||||
return '$' + 'A' + blobId.toString(16);
|
||||
if (value instanceof ArrayBuffer) {
|
||||
const blob = new Blob([value]);
|
||||
const blobId = nextPartId++;
|
||||
if (formData === null) {
|
||||
formData = new FormData();
|
||||
}
|
||||
if (value instanceof Int8Array) {
|
||||
// char
|
||||
return serializeTypedArray('O', value);
|
||||
}
|
||||
if (value instanceof Uint8Array) {
|
||||
// unsigned char
|
||||
return serializeTypedArray('o', value);
|
||||
}
|
||||
if (value instanceof Uint8ClampedArray) {
|
||||
// unsigned clamped char
|
||||
return serializeTypedArray('U', value);
|
||||
}
|
||||
if (value instanceof Int16Array) {
|
||||
// sort
|
||||
return serializeTypedArray('S', value);
|
||||
}
|
||||
if (value instanceof Uint16Array) {
|
||||
// unsigned short
|
||||
return serializeTypedArray('s', value);
|
||||
}
|
||||
if (value instanceof Int32Array) {
|
||||
// long
|
||||
return serializeTypedArray('L', value);
|
||||
}
|
||||
if (value instanceof Uint32Array) {
|
||||
// unsigned long
|
||||
return serializeTypedArray('l', value);
|
||||
}
|
||||
if (value instanceof Float32Array) {
|
||||
// float
|
||||
return serializeTypedArray('G', value);
|
||||
}
|
||||
if (value instanceof Float64Array) {
|
||||
// double
|
||||
return serializeTypedArray('g', value);
|
||||
}
|
||||
if (value instanceof BigInt64Array) {
|
||||
// number
|
||||
return serializeTypedArray('M', value);
|
||||
}
|
||||
if (value instanceof BigUint64Array) {
|
||||
// unsigned number
|
||||
// We use "m" instead of "n" since JSON can start with "null"
|
||||
return serializeTypedArray('m', value);
|
||||
}
|
||||
if (value instanceof DataView) {
|
||||
return serializeTypedArray('V', value);
|
||||
}
|
||||
// TODO: Blob is not available in old Node/browsers. Remove the typeof check later.
|
||||
if (typeof Blob === 'function' && value instanceof Blob) {
|
||||
if (formData === null) {
|
||||
formData = new FormData();
|
||||
}
|
||||
const blobId = nextPartId++;
|
||||
formData.append(formFieldPrefix + blobId, value);
|
||||
return serializeBlobID(blobId);
|
||||
formData.append(formFieldPrefix + blobId, blob);
|
||||
return '$' + 'A' + blobId.toString(16);
|
||||
}
|
||||
if (value instanceof Int8Array) {
|
||||
// char
|
||||
return serializeTypedArray('O', value);
|
||||
}
|
||||
if (value instanceof Uint8Array) {
|
||||
// unsigned char
|
||||
return serializeTypedArray('o', value);
|
||||
}
|
||||
if (value instanceof Uint8ClampedArray) {
|
||||
// unsigned clamped char
|
||||
return serializeTypedArray('U', value);
|
||||
}
|
||||
if (value instanceof Int16Array) {
|
||||
// sort
|
||||
return serializeTypedArray('S', value);
|
||||
}
|
||||
if (value instanceof Uint16Array) {
|
||||
// unsigned short
|
||||
return serializeTypedArray('s', value);
|
||||
}
|
||||
if (value instanceof Int32Array) {
|
||||
// long
|
||||
return serializeTypedArray('L', value);
|
||||
}
|
||||
if (value instanceof Uint32Array) {
|
||||
// unsigned long
|
||||
return serializeTypedArray('l', value);
|
||||
}
|
||||
if (value instanceof Float32Array) {
|
||||
// float
|
||||
return serializeTypedArray('G', value);
|
||||
}
|
||||
if (value instanceof Float64Array) {
|
||||
// double
|
||||
return serializeTypedArray('g', value);
|
||||
}
|
||||
if (value instanceof BigInt64Array) {
|
||||
// number
|
||||
return serializeTypedArray('M', value);
|
||||
}
|
||||
if (value instanceof BigUint64Array) {
|
||||
// unsigned number
|
||||
// We use "m" instead of "n" since JSON can start with "null"
|
||||
return serializeTypedArray('m', value);
|
||||
}
|
||||
if (value instanceof DataView) {
|
||||
return serializeTypedArray('V', value);
|
||||
}
|
||||
// TODO: Blob is not available in old Node/browsers. Remove the typeof check later.
|
||||
if (typeof Blob === 'function' && value instanceof Blob) {
|
||||
if (formData === null) {
|
||||
formData = new FormData();
|
||||
}
|
||||
const blobId = nextPartId++;
|
||||
formData.append(formFieldPrefix + blobId, value);
|
||||
return serializeBlobID(blobId);
|
||||
}
|
||||
|
||||
const iteratorFn = getIteratorFn(value);
|
||||
|
||||
@@ -2059,7 +2059,7 @@ describe('ReactFlight', () => {
|
||||
expect(errors).toEqual(['Cannot pass a secret token to the client']);
|
||||
});
|
||||
|
||||
// @gate enableTaint && enableBinaryFlight
|
||||
// @gate enableTaint
|
||||
it('errors when a tainted binary value is serialized', async () => {
|
||||
function UserClient({user}) {
|
||||
return <span>{user.name}</span>;
|
||||
|
||||
@@ -524,7 +524,6 @@ describe('ReactFlightDOMEdge', () => {
|
||||
expect(serializedContent.length).toBeLessThan(150 + expectedDebugInfoSize);
|
||||
});
|
||||
|
||||
// @gate enableBinaryFlight
|
||||
it('should be able to serialize any kind of typed array', async () => {
|
||||
const buffer = new Uint8Array([
|
||||
123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
|
||||
@@ -556,7 +555,6 @@ describe('ReactFlightDOMEdge', () => {
|
||||
expect(result).toEqual(buffers);
|
||||
});
|
||||
|
||||
// @gate enableBinaryFlight
|
||||
it('should be able to serialize a blob', async () => {
|
||||
const bytes = new Uint8Array([
|
||||
123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
|
||||
@@ -578,7 +576,6 @@ describe('ReactFlightDOMEdge', () => {
|
||||
expect(await result.arrayBuffer()).toEqual(await blob.arrayBuffer());
|
||||
});
|
||||
|
||||
// @gate enableBinaryFlight
|
||||
it('can transport FormData (blobs)', async () => {
|
||||
const bytes = new Uint8Array([
|
||||
123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
|
||||
@@ -823,7 +820,7 @@ describe('ReactFlightDOMEdge', () => {
|
||||
);
|
||||
});
|
||||
|
||||
// @gate enableFlightReadableStream && enableBinaryFlight
|
||||
// @gate enableFlightReadableStream
|
||||
it('should supports ReadableStreams with typed arrays', async () => {
|
||||
const buffer = new Uint8Array([
|
||||
123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
|
||||
@@ -882,7 +879,7 @@ describe('ReactFlightDOMEdge', () => {
|
||||
expect(streamedBuffers).toEqual(buffers);
|
||||
});
|
||||
|
||||
// @gate enableFlightReadableStream && enableBinaryFlight
|
||||
// @gate enableFlightReadableStream
|
||||
it('should support BYOB binary ReadableStreams', async () => {
|
||||
const buffer = new Uint8Array([
|
||||
123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
|
||||
|
||||
@@ -972,7 +972,6 @@ describe('ReactFlightDOMForm', () => {
|
||||
expect(form2.firstChild.tagName).toBe('DIV');
|
||||
});
|
||||
|
||||
// @gate enableBinaryFlight
|
||||
it('useActionState can return binary state during MPA form submission', async () => {
|
||||
const serverAction = serverExports(
|
||||
async function action(prevState, formData) {
|
||||
|
||||
@@ -197,7 +197,6 @@ describe('ReactFlightDOMNode', () => {
|
||||
expect(result.text).toBe(testString);
|
||||
});
|
||||
|
||||
// @gate enableBinaryFlight
|
||||
it('should be able to serialize any kind of typed array', async () => {
|
||||
const buffer = new Uint8Array([
|
||||
123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
|
||||
|
||||
@@ -53,7 +53,6 @@ describe('ReactFlightDOMReplyEdge', () => {
|
||||
expect(decoded).toEqual({some: 'object'});
|
||||
});
|
||||
|
||||
// @gate enableBinaryFlight
|
||||
it('should be able to serialize any kind of typed array', async () => {
|
||||
const buffer = new Uint8Array([
|
||||
123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
|
||||
@@ -85,7 +84,6 @@ describe('ReactFlightDOMReplyEdge', () => {
|
||||
expect(new Uint8Array(result[0])).toEqual(new Uint8Array(buffers[0]));
|
||||
});
|
||||
|
||||
// @gate enableBinaryFlight
|
||||
it('should be able to serialize a typed array inside a Map', async () => {
|
||||
const array = new Uint8Array([
|
||||
123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
|
||||
@@ -102,7 +100,6 @@ describe('ReactFlightDOMReplyEdge', () => {
|
||||
expect(result.get('array')).toEqual(array);
|
||||
});
|
||||
|
||||
// @gate enableBinaryFlight
|
||||
it('should be able to serialize a blob', async () => {
|
||||
const bytes = new Uint8Array([
|
||||
123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
|
||||
@@ -150,7 +147,7 @@ describe('ReactFlightDOMReplyEdge', () => {
|
||||
expect(await resultBlob.arrayBuffer()).toEqual(await blob.arrayBuffer());
|
||||
});
|
||||
|
||||
// @gate enableFlightReadableStream && enableBinaryFlight
|
||||
// @gate enableFlightReadableStream
|
||||
it('should supports ReadableStreams with typed arrays', async () => {
|
||||
const buffer = new Uint8Array([
|
||||
123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
|
||||
@@ -197,7 +194,7 @@ describe('ReactFlightDOMReplyEdge', () => {
|
||||
expect(streamedBuffers).toEqual(buffers);
|
||||
});
|
||||
|
||||
// @gate enableFlightReadableStream && enableBinaryFlight
|
||||
// @gate enableFlightReadableStream
|
||||
it('should support BYOB binary ReadableStreams', async () => {
|
||||
const buffer = new Uint8Array([
|
||||
123, 4, 10, 5, 100, 255, 244, 45, 56, 67, 43, 124, 67, 89, 100, 20,
|
||||
|
||||
@@ -30,10 +30,7 @@ import {
|
||||
createTemporaryReference,
|
||||
registerTemporaryReference,
|
||||
} from './ReactFlightServerTemporaryReferences';
|
||||
import {
|
||||
enableBinaryFlight,
|
||||
enableFlightReadableStream,
|
||||
} from 'shared/ReactFeatureFlags';
|
||||
import {enableFlightReadableStream} from 'shared/ReactFeatureFlags';
|
||||
import {ASYNC_ITERATOR} from 'shared/ReactSymbols';
|
||||
|
||||
import hasOwnProperty from 'shared/hasOwnProperty';
|
||||
@@ -1019,51 +1016,42 @@ function parseModelString(
|
||||
return BigInt(value.slice(2));
|
||||
}
|
||||
}
|
||||
if (enableBinaryFlight) {
|
||||
switch (value[1]) {
|
||||
case 'A':
|
||||
return parseTypedArray(response, value, ArrayBuffer, 1, obj, key);
|
||||
case 'O':
|
||||
return parseTypedArray(response, value, Int8Array, 1, obj, key);
|
||||
case 'o':
|
||||
return parseTypedArray(response, value, Uint8Array, 1, obj, key);
|
||||
case 'U':
|
||||
return parseTypedArray(
|
||||
response,
|
||||
value,
|
||||
Uint8ClampedArray,
|
||||
1,
|
||||
obj,
|
||||
key,
|
||||
);
|
||||
case 'S':
|
||||
return parseTypedArray(response, value, Int16Array, 2, obj, key);
|
||||
case 's':
|
||||
return parseTypedArray(response, value, Uint16Array, 2, obj, key);
|
||||
case 'L':
|
||||
return parseTypedArray(response, value, Int32Array, 4, obj, key);
|
||||
case 'l':
|
||||
return parseTypedArray(response, value, Uint32Array, 4, obj, key);
|
||||
case 'G':
|
||||
return parseTypedArray(response, value, Float32Array, 4, obj, key);
|
||||
case 'g':
|
||||
return parseTypedArray(response, value, Float64Array, 8, obj, key);
|
||||
case 'M':
|
||||
return parseTypedArray(response, value, BigInt64Array, 8, obj, key);
|
||||
case 'm':
|
||||
return parseTypedArray(response, value, BigUint64Array, 8, obj, key);
|
||||
case 'V':
|
||||
return parseTypedArray(response, value, DataView, 1, obj, key);
|
||||
case 'B': {
|
||||
// Blob
|
||||
const id = parseInt(value.slice(2), 16);
|
||||
const prefix = response._prefix;
|
||||
const blobKey = prefix + id;
|
||||
// We should have this backingEntry in the store already because we emitted
|
||||
// it before referencing it. It should be a Blob.
|
||||
const backingEntry: Blob = (response._formData.get(blobKey): any);
|
||||
return backingEntry;
|
||||
}
|
||||
switch (value[1]) {
|
||||
case 'A':
|
||||
return parseTypedArray(response, value, ArrayBuffer, 1, obj, key);
|
||||
case 'O':
|
||||
return parseTypedArray(response, value, Int8Array, 1, obj, key);
|
||||
case 'o':
|
||||
return parseTypedArray(response, value, Uint8Array, 1, obj, key);
|
||||
case 'U':
|
||||
return parseTypedArray(response, value, Uint8ClampedArray, 1, obj, key);
|
||||
case 'S':
|
||||
return parseTypedArray(response, value, Int16Array, 2, obj, key);
|
||||
case 's':
|
||||
return parseTypedArray(response, value, Uint16Array, 2, obj, key);
|
||||
case 'L':
|
||||
return parseTypedArray(response, value, Int32Array, 4, obj, key);
|
||||
case 'l':
|
||||
return parseTypedArray(response, value, Uint32Array, 4, obj, key);
|
||||
case 'G':
|
||||
return parseTypedArray(response, value, Float32Array, 4, obj, key);
|
||||
case 'g':
|
||||
return parseTypedArray(response, value, Float64Array, 8, obj, key);
|
||||
case 'M':
|
||||
return parseTypedArray(response, value, BigInt64Array, 8, obj, key);
|
||||
case 'm':
|
||||
return parseTypedArray(response, value, BigUint64Array, 8, obj, key);
|
||||
case 'V':
|
||||
return parseTypedArray(response, value, DataView, 1, obj, key);
|
||||
case 'B': {
|
||||
// Blob
|
||||
const id = parseInt(value.slice(2), 16);
|
||||
const prefix = response._prefix;
|
||||
const blobKey = prefix + id;
|
||||
// We should have this backingEntry in the store already because we emitted
|
||||
// it before referencing it. It should be a Blob.
|
||||
const backingEntry: Blob = (response._formData.get(blobKey): any);
|
||||
return backingEntry;
|
||||
}
|
||||
}
|
||||
if (enableFlightReadableStream) {
|
||||
|
||||
351
packages/react-server/src/ReactFlightServer.js
vendored
351
packages/react-server/src/ReactFlightServer.js
vendored
@@ -14,7 +14,6 @@ import type {Postpone} from 'react/src/ReactPostpone';
|
||||
import type {TemporaryReferenceSet} from './ReactFlightServerTemporaryReferences';
|
||||
|
||||
import {
|
||||
enableBinaryFlight,
|
||||
enablePostpone,
|
||||
enableHalt,
|
||||
enableTaint,
|
||||
@@ -2696,63 +2695,60 @@ function renderModelDestructive(
|
||||
if (value instanceof Error) {
|
||||
return serializeErrorValue(request, value);
|
||||
}
|
||||
|
||||
if (enableBinaryFlight) {
|
||||
if (value instanceof ArrayBuffer) {
|
||||
return serializeTypedArray(request, 'A', new Uint8Array(value));
|
||||
}
|
||||
if (value instanceof Int8Array) {
|
||||
// char
|
||||
return serializeTypedArray(request, 'O', value);
|
||||
}
|
||||
if (value instanceof Uint8Array) {
|
||||
// unsigned char
|
||||
return serializeTypedArray(request, 'o', value);
|
||||
}
|
||||
if (value instanceof Uint8ClampedArray) {
|
||||
// unsigned clamped char
|
||||
return serializeTypedArray(request, 'U', value);
|
||||
}
|
||||
if (value instanceof Int16Array) {
|
||||
// sort
|
||||
return serializeTypedArray(request, 'S', value);
|
||||
}
|
||||
if (value instanceof Uint16Array) {
|
||||
// unsigned short
|
||||
return serializeTypedArray(request, 's', value);
|
||||
}
|
||||
if (value instanceof Int32Array) {
|
||||
// long
|
||||
return serializeTypedArray(request, 'L', value);
|
||||
}
|
||||
if (value instanceof Uint32Array) {
|
||||
// unsigned long
|
||||
return serializeTypedArray(request, 'l', value);
|
||||
}
|
||||
if (value instanceof Float32Array) {
|
||||
// float
|
||||
return serializeTypedArray(request, 'G', value);
|
||||
}
|
||||
if (value instanceof Float64Array) {
|
||||
// double
|
||||
return serializeTypedArray(request, 'g', value);
|
||||
}
|
||||
if (value instanceof BigInt64Array) {
|
||||
// number
|
||||
return serializeTypedArray(request, 'M', value);
|
||||
}
|
||||
if (value instanceof BigUint64Array) {
|
||||
// unsigned number
|
||||
// We use "m" instead of "n" since JSON can start with "null"
|
||||
return serializeTypedArray(request, 'm', value);
|
||||
}
|
||||
if (value instanceof DataView) {
|
||||
return serializeTypedArray(request, 'V', value);
|
||||
}
|
||||
// TODO: Blob is not available in old Node. Remove the typeof check later.
|
||||
if (typeof Blob === 'function' && value instanceof Blob) {
|
||||
return serializeBlob(request, value);
|
||||
}
|
||||
if (value instanceof ArrayBuffer) {
|
||||
return serializeTypedArray(request, 'A', new Uint8Array(value));
|
||||
}
|
||||
if (value instanceof Int8Array) {
|
||||
// char
|
||||
return serializeTypedArray(request, 'O', value);
|
||||
}
|
||||
if (value instanceof Uint8Array) {
|
||||
// unsigned char
|
||||
return serializeTypedArray(request, 'o', value);
|
||||
}
|
||||
if (value instanceof Uint8ClampedArray) {
|
||||
// unsigned clamped char
|
||||
return serializeTypedArray(request, 'U', value);
|
||||
}
|
||||
if (value instanceof Int16Array) {
|
||||
// sort
|
||||
return serializeTypedArray(request, 'S', value);
|
||||
}
|
||||
if (value instanceof Uint16Array) {
|
||||
// unsigned short
|
||||
return serializeTypedArray(request, 's', value);
|
||||
}
|
||||
if (value instanceof Int32Array) {
|
||||
// long
|
||||
return serializeTypedArray(request, 'L', value);
|
||||
}
|
||||
if (value instanceof Uint32Array) {
|
||||
// unsigned long
|
||||
return serializeTypedArray(request, 'l', value);
|
||||
}
|
||||
if (value instanceof Float32Array) {
|
||||
// float
|
||||
return serializeTypedArray(request, 'G', value);
|
||||
}
|
||||
if (value instanceof Float64Array) {
|
||||
// double
|
||||
return serializeTypedArray(request, 'g', value);
|
||||
}
|
||||
if (value instanceof BigInt64Array) {
|
||||
// number
|
||||
return serializeTypedArray(request, 'M', value);
|
||||
}
|
||||
if (value instanceof BigUint64Array) {
|
||||
// unsigned number
|
||||
// We use "m" instead of "n" since JSON can start with "null"
|
||||
return serializeTypedArray(request, 'm', value);
|
||||
}
|
||||
if (value instanceof DataView) {
|
||||
return serializeTypedArray(request, 'V', value);
|
||||
}
|
||||
// TODO: Blob is not available in old Node. Remove the typeof check later.
|
||||
if (typeof Blob === 'function' && value instanceof Blob) {
|
||||
return serializeBlob(request, value);
|
||||
}
|
||||
|
||||
const iteratorFn = getIteratorFn(value);
|
||||
@@ -3532,63 +3528,60 @@ function renderConsoleValue(
|
||||
if (value instanceof Error) {
|
||||
return serializeErrorValue(request, value);
|
||||
}
|
||||
|
||||
if (enableBinaryFlight) {
|
||||
if (value instanceof ArrayBuffer) {
|
||||
return serializeTypedArray(request, 'A', new Uint8Array(value));
|
||||
}
|
||||
if (value instanceof Int8Array) {
|
||||
// char
|
||||
return serializeTypedArray(request, 'O', value);
|
||||
}
|
||||
if (value instanceof Uint8Array) {
|
||||
// unsigned char
|
||||
return serializeTypedArray(request, 'o', value);
|
||||
}
|
||||
if (value instanceof Uint8ClampedArray) {
|
||||
// unsigned clamped char
|
||||
return serializeTypedArray(request, 'U', value);
|
||||
}
|
||||
if (value instanceof Int16Array) {
|
||||
// sort
|
||||
return serializeTypedArray(request, 'S', value);
|
||||
}
|
||||
if (value instanceof Uint16Array) {
|
||||
// unsigned short
|
||||
return serializeTypedArray(request, 's', value);
|
||||
}
|
||||
if (value instanceof Int32Array) {
|
||||
// long
|
||||
return serializeTypedArray(request, 'L', value);
|
||||
}
|
||||
if (value instanceof Uint32Array) {
|
||||
// unsigned long
|
||||
return serializeTypedArray(request, 'l', value);
|
||||
}
|
||||
if (value instanceof Float32Array) {
|
||||
// float
|
||||
return serializeTypedArray(request, 'G', value);
|
||||
}
|
||||
if (value instanceof Float64Array) {
|
||||
// double
|
||||
return serializeTypedArray(request, 'g', value);
|
||||
}
|
||||
if (value instanceof BigInt64Array) {
|
||||
// number
|
||||
return serializeTypedArray(request, 'M', value);
|
||||
}
|
||||
if (value instanceof BigUint64Array) {
|
||||
// unsigned number
|
||||
// We use "m" instead of "n" since JSON can start with "null"
|
||||
return serializeTypedArray(request, 'm', value);
|
||||
}
|
||||
if (value instanceof DataView) {
|
||||
return serializeTypedArray(request, 'V', value);
|
||||
}
|
||||
// TODO: Blob is not available in old Node. Remove the typeof check later.
|
||||
if (typeof Blob === 'function' && value instanceof Blob) {
|
||||
return serializeBlob(request, value);
|
||||
}
|
||||
if (value instanceof ArrayBuffer) {
|
||||
return serializeTypedArray(request, 'A', new Uint8Array(value));
|
||||
}
|
||||
if (value instanceof Int8Array) {
|
||||
// char
|
||||
return serializeTypedArray(request, 'O', value);
|
||||
}
|
||||
if (value instanceof Uint8Array) {
|
||||
// unsigned char
|
||||
return serializeTypedArray(request, 'o', value);
|
||||
}
|
||||
if (value instanceof Uint8ClampedArray) {
|
||||
// unsigned clamped char
|
||||
return serializeTypedArray(request, 'U', value);
|
||||
}
|
||||
if (value instanceof Int16Array) {
|
||||
// sort
|
||||
return serializeTypedArray(request, 'S', value);
|
||||
}
|
||||
if (value instanceof Uint16Array) {
|
||||
// unsigned short
|
||||
return serializeTypedArray(request, 's', value);
|
||||
}
|
||||
if (value instanceof Int32Array) {
|
||||
// long
|
||||
return serializeTypedArray(request, 'L', value);
|
||||
}
|
||||
if (value instanceof Uint32Array) {
|
||||
// unsigned long
|
||||
return serializeTypedArray(request, 'l', value);
|
||||
}
|
||||
if (value instanceof Float32Array) {
|
||||
// float
|
||||
return serializeTypedArray(request, 'G', value);
|
||||
}
|
||||
if (value instanceof Float64Array) {
|
||||
// double
|
||||
return serializeTypedArray(request, 'g', value);
|
||||
}
|
||||
if (value instanceof BigInt64Array) {
|
||||
// number
|
||||
return serializeTypedArray(request, 'M', value);
|
||||
}
|
||||
if (value instanceof BigUint64Array) {
|
||||
// unsigned number
|
||||
// We use "m" instead of "n" since JSON can start with "null"
|
||||
return serializeTypedArray(request, 'm', value);
|
||||
}
|
||||
if (value instanceof DataView) {
|
||||
return serializeTypedArray(request, 'V', value);
|
||||
}
|
||||
// TODO: Blob is not available in old Node. Remove the typeof check later.
|
||||
if (typeof Blob === 'function' && value instanceof Blob) {
|
||||
return serializeBlob(request, value);
|
||||
}
|
||||
|
||||
const iteratorFn = getIteratorFn(value);
|
||||
@@ -3878,71 +3871,69 @@ function emitChunk(
|
||||
emitTextChunk(request, id, value);
|
||||
return;
|
||||
}
|
||||
if (enableBinaryFlight) {
|
||||
if (value instanceof ArrayBuffer) {
|
||||
emitTypedArrayChunk(request, id, 'A', new Uint8Array(value));
|
||||
return;
|
||||
}
|
||||
if (value instanceof Int8Array) {
|
||||
// char
|
||||
emitTypedArrayChunk(request, id, 'O', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Uint8Array) {
|
||||
// unsigned char
|
||||
emitTypedArrayChunk(request, id, 'o', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Uint8ClampedArray) {
|
||||
// unsigned clamped char
|
||||
emitTypedArrayChunk(request, id, 'U', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Int16Array) {
|
||||
// sort
|
||||
emitTypedArrayChunk(request, id, 'S', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Uint16Array) {
|
||||
// unsigned short
|
||||
emitTypedArrayChunk(request, id, 's', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Int32Array) {
|
||||
// long
|
||||
emitTypedArrayChunk(request, id, 'L', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Uint32Array) {
|
||||
// unsigned long
|
||||
emitTypedArrayChunk(request, id, 'l', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Float32Array) {
|
||||
// float
|
||||
emitTypedArrayChunk(request, id, 'G', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Float64Array) {
|
||||
// double
|
||||
emitTypedArrayChunk(request, id, 'g', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof BigInt64Array) {
|
||||
// number
|
||||
emitTypedArrayChunk(request, id, 'M', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof BigUint64Array) {
|
||||
// unsigned number
|
||||
// We use "m" instead of "n" since JSON can start with "null"
|
||||
emitTypedArrayChunk(request, id, 'm', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof DataView) {
|
||||
emitTypedArrayChunk(request, id, 'V', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof ArrayBuffer) {
|
||||
emitTypedArrayChunk(request, id, 'A', new Uint8Array(value));
|
||||
return;
|
||||
}
|
||||
if (value instanceof Int8Array) {
|
||||
// char
|
||||
emitTypedArrayChunk(request, id, 'O', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Uint8Array) {
|
||||
// unsigned char
|
||||
emitTypedArrayChunk(request, id, 'o', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Uint8ClampedArray) {
|
||||
// unsigned clamped char
|
||||
emitTypedArrayChunk(request, id, 'U', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Int16Array) {
|
||||
// sort
|
||||
emitTypedArrayChunk(request, id, 'S', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Uint16Array) {
|
||||
// unsigned short
|
||||
emitTypedArrayChunk(request, id, 's', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Int32Array) {
|
||||
// long
|
||||
emitTypedArrayChunk(request, id, 'L', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Uint32Array) {
|
||||
// unsigned long
|
||||
emitTypedArrayChunk(request, id, 'l', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Float32Array) {
|
||||
// float
|
||||
emitTypedArrayChunk(request, id, 'G', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof Float64Array) {
|
||||
// double
|
||||
emitTypedArrayChunk(request, id, 'g', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof BigInt64Array) {
|
||||
// number
|
||||
emitTypedArrayChunk(request, id, 'M', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof BigUint64Array) {
|
||||
// unsigned number
|
||||
// We use "m" instead of "n" since JSON can start with "null"
|
||||
emitTypedArrayChunk(request, id, 'm', value);
|
||||
return;
|
||||
}
|
||||
if (value instanceof DataView) {
|
||||
emitTypedArrayChunk(request, id, 'V', value);
|
||||
return;
|
||||
}
|
||||
// For anything else we need to try to serialize it using JSON.
|
||||
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import {enableTaint, enableBinaryFlight} from 'shared/ReactFeatureFlags';
|
||||
import {enableTaint} from 'shared/ReactFeatureFlags';
|
||||
|
||||
import getPrototypeOf from 'shared/getPrototypeOf';
|
||||
|
||||
@@ -76,8 +76,8 @@ export function taintUniqueValue(
|
||||
// Use as is.
|
||||
entryValue = value;
|
||||
} else if (
|
||||
enableBinaryFlight &&
|
||||
(value instanceof TypedArrayConstructor || value instanceof DataView)
|
||||
value instanceof TypedArrayConstructor ||
|
||||
value instanceof DataView
|
||||
) {
|
||||
// For now, we just convert binary data to a string so that we can just use the native
|
||||
// hashing in the Map implementation. It doesn't really matter what form the string
|
||||
|
||||
@@ -78,7 +78,6 @@ export const enableLegacyFBSupport = false;
|
||||
export const enableCache = true;
|
||||
export const enableLegacyCache = __EXPERIMENTAL__;
|
||||
|
||||
export const enableBinaryFlight = true;
|
||||
export const enableFlightReadableStream = true;
|
||||
export const enableAsyncIterableChildren = __EXPERIMENTAL__;
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ export const disableSchedulerTimeoutInWorkLoop = false;
|
||||
export const disableTextareaChildren = false;
|
||||
export const enableAsyncDebugInfo = false;
|
||||
export const enableAsyncIterableChildren = false;
|
||||
export const enableBinaryFlight = true;
|
||||
export const enableCache = true;
|
||||
export const enableComponentStackLocations = true;
|
||||
export const enableCPUSuspense = true;
|
||||
|
||||
@@ -31,7 +31,6 @@ export const disableSchedulerTimeoutInWorkLoop = false;
|
||||
export const disableTextareaChildren = false;
|
||||
export const enableAsyncDebugInfo = false;
|
||||
export const enableAsyncIterableChildren = false;
|
||||
export const enableBinaryFlight = true;
|
||||
export const enableCache = true;
|
||||
export const enableComponentStackLocations = true;
|
||||
export const enableCPUSuspense = false;
|
||||
|
||||
@@ -21,7 +21,6 @@ export const enableComponentPerformanceTrack = false;
|
||||
export const enableUpdaterTracking = false;
|
||||
export const enableCache = true;
|
||||
export const enableLegacyCache = __EXPERIMENTAL__;
|
||||
export const enableBinaryFlight = true;
|
||||
export const enableFlightReadableStream = true;
|
||||
export const enableAsyncIterableChildren = false;
|
||||
export const enableTaint = true;
|
||||
|
||||
@@ -23,7 +23,6 @@ export const disableSchedulerTimeoutInWorkLoop = false;
|
||||
export const disableTextareaChildren = false;
|
||||
export const enableAsyncDebugInfo = false;
|
||||
export const enableAsyncIterableChildren = false;
|
||||
export const enableBinaryFlight = true;
|
||||
export const enableCache = true;
|
||||
export const enableComponentStackLocations = true;
|
||||
export const enableCPUSuspense = true;
|
||||
|
||||
@@ -21,7 +21,6 @@ export const enableComponentPerformanceTrack = false;
|
||||
export const enableUpdaterTracking = false;
|
||||
export const enableCache = true;
|
||||
export const enableLegacyCache = true;
|
||||
export const enableBinaryFlight = true;
|
||||
export const enableFlightReadableStream = true;
|
||||
export const enableAsyncIterableChildren = false;
|
||||
export const enableTaint = true;
|
||||
|
||||
@@ -76,7 +76,6 @@ export const enableGetInspectorDataForInstanceInProduction = false;
|
||||
export const enableCache = true;
|
||||
export const enableLegacyCache = true;
|
||||
|
||||
export const enableBinaryFlight = true;
|
||||
export const enableFlightReadableStream = true;
|
||||
export const enableAsyncIterableChildren = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user