diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js index 18373b8ce688c..5dd228795ca87 100644 --- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js +++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js @@ -52,6 +52,7 @@ import { import { resolveRequest, getResumableState, + getRenderState, flushResources, } from 'react-server/src/ReactFizzServer'; @@ -135,6 +136,10 @@ export type RenderState = { htmlChunks: null | Array, headChunks: null | Array, + // external runtime script chunks + externalRuntimeScript: null | ExternalRuntimeScript, + bootstrapChunks: Array, + // Hoistable chunks charsetChunks: Array, preconnectChunks: Array, @@ -142,6 +147,20 @@ export type RenderState = { preloadChunks: Array, hoistableChunks: Array, + // Flushing queues for Resource dependencies + preconnects: Set, + fontPreloads: Set, + highImagePreloads: Set, + // usedImagePreloads: Set, + precedences: Map>, + stylePrecedences: Map, + bootstrapScripts: Set, + scripts: Set, + bulkPreloads: Set, + + // Temporarily keeps track of key to preload resources before shell flushes. + preloadsMap: Map, + // Module-global-like reference for current boundary resources boundaryResources: ?BoundaryResources, @@ -158,9 +177,6 @@ export type RenderState = { // Per response, global state that is not contextual to the rendering subtree. // This is resumable and therefore should be serializable. export type ResumableState = { - // external runtime script chunks - externalRuntimeScript: null | ExternalRuntimeScript, // TODO: Move to a serializable format - bootstrapChunks: Array, // TODO: Move to a serializable format. idPrefix: string, nextFormID: number, streamingFormat: StreamingFormat, @@ -172,24 +188,11 @@ export type ResumableState = { hasBody: boolean, hasHtml: boolean, - // Resources - - // Request local cache - preloadsMap: Map, - preconnectsMap: Map, - stylesMap: Map, - scriptsMap: Map, - - // Flushing queues for Resource dependencies - preconnects: Set, - fontPreloads: Set, - highImagePreloads: Set, - // usedImagePreloads: Set, - precedences: Map>, - stylePrecedences: Map, - bootstrapScripts: Set, - scripts: Set, - bulkPreloads: Set, + // Resources - Request local cache + preloadsMap: {[key: string]: PreloadProps}, + preconnectsMap: {[key: string]: null}, + stylesMap: {[key: string]: null}, + scriptsMap: {[key: string]: null}, }; const dataElementQuotedEnd = stringToPrecomputedChunk('">'); @@ -249,6 +252,10 @@ const importMapScriptEnd = stringToPrecomputedChunk(''); export function createRenderState( resumableState: ResumableState, nonce: string | void, + bootstrapScriptContent: string | void, + bootstrapScripts: $ReadOnlyArray | void, + bootstrapModules: $ReadOnlyArray | void, + externalRuntimeConfig: string | BootstrapScriptDescriptor | void, importMap: ImportMap | void, ): RenderState { const inlineScriptWithNonce = @@ -258,55 +265,10 @@ export function createRenderState( '