-
Notifications
You must be signed in to change notification settings - Fork 47.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wrapper around the ServerFormatConfig for legacy mode
This ensures that we can inject custom overrides without negatively affecting the new implementation. This adds another field for static mark up for example.
- Loading branch information
1 parent
3a6ec70
commit 14a6de4
Showing
9 changed files
with
91 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
packages/react-dom/src/server/ReactDOMServerLegacyFormatConfig.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
import {createResponseState as createResponseStateImpl} from './ReactDOMServerFormatConfig'; | ||
|
||
import type {PrecomputedChunk} from 'react-server/src/ReactServerStreamConfig'; | ||
|
||
export const isPrimaryRenderer = false; | ||
|
||
export type ResponseState = { | ||
// Keep this in sync with ReactDOMServerFormatConfig | ||
placeholderPrefix: PrecomputedChunk, | ||
segmentPrefix: PrecomputedChunk, | ||
boundaryPrefix: string, | ||
opaqueIdentifierPrefix: string, | ||
nextSuspenseID: number, | ||
nextOpaqueID: number, | ||
sentCompleteSegmentFunction: boolean, | ||
sentCompleteBoundaryFunction: boolean, | ||
sentClientRenderFunction: boolean, | ||
// This is an extra field for the legacy renderer | ||
generateStaticMarkup: boolean, | ||
}; | ||
|
||
export function createResponseState( | ||
generateStaticMarkup: boolean, | ||
identifierPrefix: string | void, | ||
): ResponseState { | ||
const responseState = createResponseStateImpl(identifierPrefix); | ||
return { | ||
// Keep this in sync with ReactDOMServerFormatConfig | ||
placeholderPrefix: responseState.placeholderPrefix, | ||
segmentPrefix: responseState.segmentPrefix, | ||
boundaryPrefix: responseState.boundaryPrefix, | ||
opaqueIdentifierPrefix: responseState.opaqueIdentifierPrefix, | ||
nextSuspenseID: responseState.nextSuspenseID, | ||
nextOpaqueID: responseState.nextOpaqueID, | ||
sentCompleteSegmentFunction: responseState.sentCompleteSegmentFunction, | ||
sentCompleteBoundaryFunction: responseState.sentCompleteBoundaryFunction, | ||
sentClientRenderFunction: responseState.sentClientRenderFunction, | ||
// This is an extra field for the legacy renderer | ||
generateStaticMarkup, | ||
}; | ||
} | ||
|
||
export type { | ||
FormatContext, | ||
SuspenseBoundaryID, | ||
OpaqueIDType, | ||
} from './ReactDOMServerFormatConfig'; | ||
|
||
export { | ||
createRootFormatContext, | ||
getChildFormatContext, | ||
createSuspenseBoundaryID, | ||
makeServerID, | ||
pushEmpty, | ||
pushTextInstance, | ||
pushStartInstance, | ||
pushEndInstance, | ||
writePlaceholder, | ||
writeStartCompletedSuspenseBoundary, | ||
writeStartPendingSuspenseBoundary, | ||
writeStartClientRenderedSuspenseBoundary, | ||
writeEndSuspenseBoundary, | ||
writeStartSegment, | ||
writeEndSegment, | ||
writeCompletedSegmentInstruction, | ||
writeCompletedBoundaryInstruction, | ||
writeClientRenderBoundaryInstruction, | ||
} from './ReactDOMServerFormatConfig'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters