Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ServerContext] Flight support for ServerContext #23244

Merged
merged 87 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
f75b5d3
Flight side of server context
salazarm Feb 7, 2022
29e80db
1 more test
salazarm Feb 7, 2022
54e8812
rm unused function
salazarm Feb 7, 2022
e148a0a
flow+prettier
salazarm Feb 14, 2022
532dfa2
flow again =)
salazarm Feb 14, 2022
f2868c2
duplicate ReactServerContext across packages
salazarm Feb 15, 2022
a861492
store default value when lazily initializing server context
salazarm Feb 17, 2022
fb521be
.
salazarm Feb 17, 2022
a7051aa
better comment
salazarm Feb 17, 2022
066b206
derp... missing import
salazarm Feb 17, 2022
7706ed7
rm optional chaining
salazarm Feb 17, 2022
8bb4359
missed feature flag
salazarm Feb 17, 2022
03f08ba
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ??
salazarm Feb 17, 2022
9948c43
add warning if non ServerContext passed into useServerContext
salazarm Feb 17, 2022
0bb2d55
pass context in as array of arrays
salazarm Feb 17, 2022
0dc363f
make importServerContext nott pollute the global context state
salazarm Feb 23, 2022
637ad8b
Merge branch 'main' into flightServerContext
salazarm Feb 23, 2022
be811ec
merge main
salazarm Feb 23, 2022
3c8ec09
remove useServerContext
salazarm Feb 23, 2022
9c7e061
dont rely on object getters in ReactServerContext and disallow JSX
salazarm Feb 24, 2022
6f71944
add symbols to devtools + rename globalServerContextRegistry to just …
salazarm Feb 24, 2022
d74b7bd
gate test case as experimental
salazarm Feb 24, 2022
4d9d014
feedback
salazarm Mar 2, 2022
de7f685
remove unions
salazarm Mar 2, 2022
079691e
Lint
salazarm Mar 2, 2022
cb66687
fix oopsies (tests/lint/mismatching arguments/signatures
salazarm Mar 2, 2022
0946c5d
lint again
salazarm Mar 2, 2022
64c6477
replace-fork
salazarm Mar 2, 2022
1f5e888
remove extraneous change
salazarm Mar 2, 2022
8323eb8
rebase
salazarm Feb 7, 2022
640c4a8
1 more test
salazarm Feb 7, 2022
c83c3cc
rm unused function
salazarm Feb 7, 2022
64621f0
flow+prettier
salazarm Feb 14, 2022
905d184
flow again =)
salazarm Feb 14, 2022
42ca798
duplicate ReactServerContext across packages
salazarm Feb 15, 2022
4457295
store default value when lazily initializing server context
salazarm Feb 17, 2022
a69065b
.
salazarm Feb 17, 2022
ef20b40
better comment
salazarm Feb 17, 2022
c5a58d3
derp... missing import
salazarm Feb 17, 2022
6124a34
rm optional chaining
salazarm Feb 17, 2022
fd1465e
missed feature flag
salazarm Feb 17, 2022
ebe8a1e
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ??
salazarm Feb 17, 2022
4e8a2d2
add warning if non ServerContext passed into useServerContext
salazarm Feb 17, 2022
72dbc55
pass context in as array of arrays
salazarm Feb 17, 2022
6e4ed97
make importServerContext nott pollute the global context state
salazarm Feb 23, 2022
c5988f2
merge main
salazarm Feb 23, 2022
5397db6
remove useServerContext
salazarm Feb 23, 2022
9d30d7b
dont rely on object getters in ReactServerContext and disallow JSX
salazarm Feb 24, 2022
50594a2
add symbols to devtools + rename globalServerContextRegistry to just …
salazarm Feb 24, 2022
43a71b2
gate test case as experimental
salazarm Feb 24, 2022
69a9ccd
feedback
salazarm Mar 2, 2022
bc03997
remove unions
salazarm Mar 2, 2022
499f20b
Lint
salazarm Mar 2, 2022
b5e5e47
fix oopsies (tests/lint/mismatching arguments/signatures
salazarm Mar 2, 2022
90f6f08
lint again
salazarm Mar 2, 2022
672712e
replace-fork
salazarm Mar 2, 2022
03fb89b
remove extraneous change
salazarm Mar 2, 2022
db992af
rebase
salazarm Mar 3, 2022
9ceb955
reinline
salazarm Mar 3, 2022
d0d8f5d
Merge branch 'flightServerContext' of github.com:salazarm/react into …
salazarm Mar 3, 2022
eafb265
rebase
salazarm Mar 3, 2022
5b937ad
add back changes lost due to rebase being hard
salazarm Mar 3, 2022
06b6008
emit chunk for provider
salazarm Mar 3, 2022
c83bc66
remove case for React provider type
salazarm Mar 3, 2022
534d370
update type for SomeChunk
salazarm Mar 3, 2022
8283b4b
enable flag with experimental
salazarm Mar 3, 2022
c596825
add missing types
salazarm Mar 3, 2022
04293a0
fix flow type
salazarm Mar 3, 2022
4b780b5
missing type
salazarm Mar 4, 2022
dc4081d
t: any
salazarm Mar 4, 2022
ff6269f
revert extraneous type change
salazarm Mar 4, 2022
f5a8b25
better type
salazarm Mar 4, 2022
a714680
better type
salazarm Mar 4, 2022
81f798f
feedback
salazarm Mar 7, 2022
72ed1cc
Merge branch 'main' of github.com:salazarm/react into flightServerCon…
salazarm Mar 7, 2022
4b808b1
change import to type import
salazarm Mar 7, 2022
463047c
test?
salazarm Mar 7, 2022
3d16208
test?
salazarm Mar 7, 2022
1c4eaf9
remove react-dom
salazarm Mar 7, 2022
af300fc
remove react-native-renderer from react-server-native-relay/package.json
salazarm Mar 7, 2022
9333935
gate change in FiberNewContext, getComponentNameFromType, use switch …
salazarm Mar 8, 2022
2d5129c
getComponentNameFromTpe: server context type gated and use displayNam…
salazarm Mar 8, 2022
573d394
fallthrough
salazarm Mar 8, 2022
26c5667
lint....
salazarm Mar 8, 2022
83fcb8b
Merge branch 'main' into flightServerContext
salazarm Mar 8, 2022
278499d
POP
salazarm Mar 8, 2022
b6bbe30
lint
salazarm Mar 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {

import {REACT_LAZY_TYPE, REACT_ELEMENT_TYPE} from 'shared/ReactSymbols';

import {getOrCreateServerContext} from 'shared/ReactServerContextRegistry';

export type JSONValue =
| number
| null
Expand Down Expand Up @@ -327,6 +329,7 @@ export function parseModelTuple(
value: {+[key: string]: JSONValue} | $ReadOnlyArray<JSONValue>,
): any {
const tuple: [mixed, mixed, mixed, mixed] = (value: any);

if (tuple[0] === REACT_ELEMENT_TYPE) {
// TODO: Consider having React just directly accept these arrays as elements.
// Or even change the ReactElement type to be an array.
Expand Down Expand Up @@ -358,6 +361,21 @@ export function resolveModel(
}
}

export function resolveProvider(
response: Response,
id: number,
contextName: string,
): void {
const chunks = response._chunks;
chunks.set(
id,
createInitializedChunk(
response,
getOrCreateServerContext(contextName).Provider,
),
);
}

export function resolveModule(
response: Response,
id: number,
Expand Down
5 changes: 5 additions & 0 deletions packages/react-client/src/ReactFlightClientStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {Response} from './ReactFlightClientHostConfigStream';
import {
resolveModule,
resolveModel,
resolveProvider,
resolveSymbol,
resolveError,
createResponse as createResponseBase,
Expand Down Expand Up @@ -49,6 +50,10 @@ function processFullRow(response: Response, row: string): void {
resolveModule(response, id, text);
return;
}
case 'P': {
resolveProvider(response, id, text);
return;
}
case 'S': {
resolveSymbol(response, id, JSON.parse(text));
return;
Expand Down
Loading