Skip to content

Commit

Permalink
Rename typed array characters
Browse files Browse the repository at this point in the history
N->M
F->G
d->g
C->O
c->o

These overlap with other tags on references where as previously they were
only used for row tags.
  • Loading branch information
sebmarkbage committed Apr 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 8fe66f6 commit 9531b21
Showing 4 changed files with 70 additions and 78 deletions.
20 changes: 10 additions & 10 deletions packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
@@ -1262,10 +1262,10 @@ function processFullRow(
// 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 67 /* "C" */:
case 79 /* "O" */:
resolveTypedArray(response, id, buffer, chunk, Int8Array, 1);
return;
case 99 /* "c" */:
case 111 /* "o" */:
resolveBuffer(
response,
id,
@@ -1287,13 +1287,13 @@ function processFullRow(
case 108 /* "l" */:
resolveTypedArray(response, id, buffer, chunk, Uint32Array, 4);
return;
case 70 /* "F" */:
case 71 /* "G" */:
resolveTypedArray(response, id, buffer, chunk, Float32Array, 4);
return;
case 100 /* "d" */:
case 103 /* "g" */:
resolveTypedArray(response, id, buffer, chunk, Float64Array, 8);
return;
case 78 /* "N" */:
case 77 /* "M" */:
resolveTypedArray(response, id, buffer, chunk, BigInt64Array, 8);
return;
case 109 /* "m" */:
@@ -1417,16 +1417,16 @@ export function processBinaryChunk(
resolvedRowTag === 84 /* "T" */ ||
(enableBinaryFlight &&
(resolvedRowTag === 65 /* "A" */ ||
resolvedRowTag === 67 /* "C" */ ||
resolvedRowTag === 99 /* "c" */ ||
resolvedRowTag === 79 /* "O" */ ||
resolvedRowTag === 111 /* "o" */ ||
resolvedRowTag === 85 /* "U" */ ||
resolvedRowTag === 83 /* "S" */ ||
resolvedRowTag === 115 /* "s" */ ||
resolvedRowTag === 76 /* "L" */ ||
resolvedRowTag === 108 /* "l" */ ||
resolvedRowTag === 70 /* "F" */ ||
resolvedRowTag === 100 /* "d" */ ||
resolvedRowTag === 78 /* "N" */ ||
resolvedRowTag === 71 /* "G" */ ||
resolvedRowTag === 103 /* "g" */ ||
resolvedRowTag === 77 /* "M" */ ||
resolvedRowTag === 109 /* "m" */ ||
resolvedRowTag === 86)) /* "V" */
) {
12 changes: 6 additions & 6 deletions packages/react-client/src/ReactFlightReplyClient.js
Original file line number Diff line number Diff line change
@@ -188,7 +188,7 @@ export function processReply(
formData = new FormData();
}
formData.append(formFieldPrefix + blobId, blob);
return '$Y' + tag + blobId.toString(16);
return '$' + tag + blobId.toString(16);
}

function resolveToJSON(
@@ -389,11 +389,11 @@ export function processReply(
}
if (value instanceof Int8Array) {
// char
return serializeTypedArray('C', value);
return serializeTypedArray('O', value);
}
if (value instanceof Uint8Array) {
// unsigned char
return serializeTypedArray('c', value);
return serializeTypedArray('o', value);
}
if (value instanceof Uint8ClampedArray) {
// unsigned clamped char
@@ -417,15 +417,15 @@ export function processReply(
}
if (value instanceof Float32Array) {
// float
return serializeTypedArray('F', value);
return serializeTypedArray('G', value);
}
if (value instanceof Float64Array) {
// double
return serializeTypedArray('d', value);
return serializeTypedArray('g', value);
}
if (value instanceof BigInt64Array) {
// number
return serializeTypedArray('N', value);
return serializeTypedArray('M', value);
}
if (value instanceof BigUint64Array) {
// unsigned number
96 changes: 44 additions & 52 deletions packages/react-server/src/ReactFlightReplyServer.js
Original file line number Diff line number Diff line change
@@ -387,7 +387,7 @@ function parseTypedArray(
parentObject: Object,
parentKey: string,
): null {
const id = parseInt(reference.slice(3), 16);
const id = parseInt(reference.slice(2), 16);
const prefix = response._prefix;
const key = prefix + id;
// We should have this backingEntry in the store already because we emitted
@@ -508,58 +508,50 @@ function parseModelString(
}
}
if (enableBinaryFlight) {
if (value[1] === 'Y')
switch (value[2]) {
case 'A':
return parseTypedArray(response, value, ArrayBuffer, 1, obj, key);
case 'C':
return parseTypedArray(response, value, Int8Array, 1, obj, key);
case 'c':
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 'F':
return parseTypedArray(response, value, Float32Array, 4, obj, key);
case 'd':
return parseTypedArray(response, value, Float64Array, 8, obj, key);
case 'N':
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);
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 (value[1] === 'B') {
// Blob
const id = parseInt(value.slice(2), 16);
const prefix = response._prefix;
const key = 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(key): any);
return backingEntry;
}
}

20 changes: 10 additions & 10 deletions packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
@@ -1610,11 +1610,11 @@ function renderModelDestructive(
}
if (value instanceof Int8Array) {
// char
return serializeTypedArray(request, 'C', value);
return serializeTypedArray(request, 'O', value);
}
if (value instanceof Uint8Array) {
// unsigned char
return serializeTypedArray(request, 'c', value);
return serializeTypedArray(request, 'o', value);
}
if (value instanceof Uint8ClampedArray) {
// unsigned clamped char
@@ -1638,15 +1638,15 @@ function renderModelDestructive(
}
if (value instanceof Float32Array) {
// float
return serializeTypedArray(request, 'F', value);
return serializeTypedArray(request, 'G', value);
}
if (value instanceof Float64Array) {
// double
return serializeTypedArray(request, 'd', value);
return serializeTypedArray(request, 'g', value);
}
if (value instanceof BigInt64Array) {
// number
return serializeTypedArray(request, 'N', value);
return serializeTypedArray(request, 'M', value);
}
if (value instanceof BigUint64Array) {
// unsigned number
@@ -2158,11 +2158,11 @@ function renderConsoleValue(
}
if (value instanceof Int8Array) {
// char
return serializeTypedArray(request, 'C', value);
return serializeTypedArray(request, 'O', value);
}
if (value instanceof Uint8Array) {
// unsigned char
return serializeTypedArray(request, 'c', value);
return serializeTypedArray(request, 'o', value);
}
if (value instanceof Uint8ClampedArray) {
// unsigned clamped char
@@ -2186,15 +2186,15 @@ function renderConsoleValue(
}
if (value instanceof Float32Array) {
// float
return serializeTypedArray(request, 'F', value);
return serializeTypedArray(request, 'G', value);
}
if (value instanceof Float64Array) {
// double
return serializeTypedArray(request, 'd', value);
return serializeTypedArray(request, 'g', value);
}
if (value instanceof BigInt64Array) {
// number
return serializeTypedArray(request, 'N', value);
return serializeTypedArray(request, 'M', value);
}
if (value instanceof BigUint64Array) {
// unsigned number

0 comments on commit 9531b21

Please sign in to comment.