Skip to content

Commit

Permalink
[Fizz] Split ResponseState/Resources into RenderState/ResumableState (#…
Browse files Browse the repository at this point in the history
…27268)

This exposes a `resume()` API to go with the `prerender()` (only in
experimental). It doesn't work yet since we don't yet emit the postponed
state so not yet tested.

The main thing this does is rename ResponseState->RenderState and
Resources->ResumableState. We separated out resources into a separate
concept preemptively since it seemed like separate enough but probably
doesn't warrant being a separate concept. The result is that we have a
per RenderState in the Config which is really just temporary state and
things that must be flushed completely in the prerender. Most things
should be ResumableState.

Most options are specified in the `prerender()` and transferred into the
`resume()` but certain options that are unique per request can't be.
Notably `nonce` is special. This means that bootstrap scripts and
external runtime can't use `nonce` in this mode. They need to have a CSP
configured to deal with external scripts, but not inline.

We need to be able to restore state of things that we've already emitted
in the prerender. We could have separate snapshot/restore methods that
does this work when it happens but that means we have to explicitly do
that work. This design is trying to keep to the principle that we just
work with resumable data structures instead so that we're designing for
it with every feature. It also makes restoring faster since it's just
straight into the data structure.

This is not yet a serializable format. That can be done in a follow up.

We also need to vet that each step makes sense. Notably stylesToHoist is
a bit unclear how it'll work.

DiffTrain build for commit 31034b6.
  • Loading branch information
sebmarkbage committed Aug 22, 2023
1 parent 19036c8 commit 5dbb6a2
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23977,7 +23977,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-canary-86198b923-20230822";
var ReactVersion = "18.3.0-canary-31034b6de-20230822";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8612,7 +8612,7 @@ var devToolsConfig$jscomp$inline_1029 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-86198b923-20230822",
version: "18.3.0-canary-31034b6de-20230822",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1228 = {
Expand Down Expand Up @@ -8643,7 +8643,7 @@ var internals$jscomp$inline_1228 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-86198b923-20230822"
reconcilerVersion: "18.3.0-canary-31034b6de-20230822"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1229 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9038,7 +9038,7 @@ var devToolsConfig$jscomp$inline_1071 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-86198b923-20230822",
version: "18.3.0-canary-31034b6de-20230822",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1269 = {
Expand Down Expand Up @@ -9069,7 +9069,7 @@ var internals$jscomp$inline_1269 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-86198b923-20230822"
reconcilerVersion: "18.3.0-canary-31034b6de-20230822"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1270 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-canary-86198b923-20230822";
var ReactVersion = "18.3.0-canary-31034b6de-20230822";

// ATTENTION
// When adding new symbols to this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,4 +616,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-86198b923-20230822";
exports.version = "18.3.0-canary-31034b6de-20230822";
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-86198b923-20230822";
exports.version = "18.3.0-canary-31034b6de-20230822";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
86198b923199224b60533952b636348bb0484a6d
31034b6de73c7cd9093e92a34e384d84c082aa4e

0 comments on commit 5dbb6a2

Please sign in to comment.