Skip to content

Commit

Permalink
When Float was first developed the internal implementation and extern…
Browse files Browse the repository at this point in the history
…al interface were the same. This is problematic for a few reasons. One, the public interface is typed but it is also untrusted and we should not assume that it is actually respected. Two, the internal implementations can get called from places other than the the public interface and having to construct an options argument that ends up being destructured to process the request is computationally wasteful and may limit JIT optimizations to some degree. Lastly, the wire format was not as compressed as it could be and it was untyped.

This refactor aims to address that by separating the public interface from the internal implementations so we can solve these challenges and also make it easier to change Float in the future

The internal dispatcher method preinit is now preinitStyle and preinitScript.
The internal dispatcher method preinitModule is now preinitModuleScript in anticipation of different implementations for other module types in the future
The wire format is explicitly typed and only includes options if they are actually used omitting undefined and nulls.
Some function arguments are not options even if they are optional. For instance precedence can be null/undefined because we deafult it to 'default' however we don't cosnider this an option because it is not something we transparently apply as props to the underlying instance.
Fixes a problem with keying images in flight wehre srcset and sizes were not being taken into account.
Moves argument validation into the ReactDOMFloat file where it is shared with all runtimes that expose these methods
  • Loading branch information
gnoff committed Sep 12, 2023
1 parent 41f0e9d commit 91d987c
Show file tree
Hide file tree
Showing 14 changed files with 977 additions and 975 deletions.
13 changes: 8 additions & 5 deletions packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import type {
StringDecoder,
} from './ReactFlightClientConfig';

import type {HintModel} from 'react-server/src/ReactFlightServerConfig';
import type {
HintCode,
HintModel,
} from 'react-server/src/ReactFlightServerConfig';

import type {CallServerCallback} from './ReactFlightReplyClient';

Expand Down Expand Up @@ -915,12 +918,12 @@ function resolvePostponeDev(
}
}

function resolveHint(
function resolveHint<Code: HintCode>(
response: Response,
code: string,
code: Code,
model: UninitializedModel,
): void {
const hintModel: HintModel = parseModel(response, model);
const hintModel: HintModel<Code> = parseModel(response, model);
dispatchHint(code, hintModel);
}

Expand Down Expand Up @@ -1044,7 +1047,7 @@ function processFullRow(
return;
}
case 72 /* "H" */: {
const code = row[0];
const code: HintCode = (row[0]: any);
resolveHint(response, code, row.slice(1));
return;
}
Expand Down
Loading

0 comments on commit 91d987c

Please sign in to comment.