main
js 110 lines 4.77 KB
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @flow
8 */
9
10 // This is a host config that's used for the `react-server` package on npm.
11 // It is only used by third-party renderers.
12 //
13 // Its API lets you pass the host config as an argument.
14 // However, inside the `react-server` we treat host config as a module.
15 // This file is a shim between two worlds.
16 //
17 // It works because the `react-server` bundle is wrapped in something like:
18 //
19 // module.exports = function ($$$config) {
20 // /* renderer code */
21 // }
22 //
23 // So `$$$config` looks like a global variable, but it's
24 // really an argument to a top-level wrapping function.
25
26 import type {Request} from 'react-server/src/ReactFizzServer';
27 import type {TransitionStatus} from 'react-reconciler/src/ReactFiberConfig';
28
29 declare const $$$config: any;
30 export opaque type Destination = mixed;
31 export opaque type RenderState = mixed;
32 export opaque type HoistableState = mixed;
33 export opaque type ResumableState = mixed;
34 export opaque type PreambleState = mixed;
35 export opaque type FormatContext = mixed;
36 export opaque type HeadersDescriptor = mixed;
37 export type {TransitionStatus};
38
39 export const isPrimaryRenderer = false;
40
41 export const supportsClientAPIs = true;
42
43 export const isWorkLoopExternallyDriven =
44 $$$config.isWorkLoopExternallyDriven === true;
45 export const supportsRequestStorage = false;
46 export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
47
48 export const bindToConsole = $$$config.bindToConsole;
49
50 export const resetResumableState = $$$config.resetResumableState;
51 export const completeResumableState = $$$config.completeResumableState;
52 export const getChildFormatContext = $$$config.getChildFormatContext;
53 export const getSuspenseFallbackFormatContext =
54 $$$config.getSuspenseFallbackFormatContext;
55 export const getSuspenseContentFormatContext =
56 $$$config.getSuspenseContentFormatContext;
57 export const getViewTransitionFormatContext =
58 $$$config.getViewTransitionFormatContext;
59 export const makeId = $$$config.makeId;
60 export const pushTextInstance = $$$config.pushTextInstance;
61 export const pushStartInstance = $$$config.pushStartInstance;
62 export const pushEndInstance = $$$config.pushEndInstance;
63 export const pushSegmentFinale = $$$config.pushSegmentFinale;
64 export const pushFormStateMarkerIsMatching =
65 $$$config.pushFormStateMarkerIsMatching;
66 export const pushFormStateMarkerIsNotMatching =
67 $$$config.pushFormStateMarkerIsNotMatching;
68 export const writeCompletedRoot = $$$config.writeCompletedRoot;
69 export const writePlaceholder = $$$config.writePlaceholder;
70 export const pushStartActivityBoundary = $$$config.pushStartActivityBoundary;
71 export const pushEndActivityBoundary = $$$config.pushEndActivityBoundary;
72 export const writeStartCompletedSuspenseBoundary =
73 $$$config.writeStartCompletedSuspenseBoundary;
74 export const writeStartPendingSuspenseBoundary =
75 $$$config.writeStartPendingSuspenseBoundary;
76 export const writeStartClientRenderedSuspenseBoundary =
77 $$$config.writeStartClientRenderedSuspenseBoundary;
78 export const writeEndCompletedSuspenseBoundary =
79 $$$config.writeEndCompletedSuspenseBoundary;
80 export const writeEndPendingSuspenseBoundary =
81 $$$config.writeEndPendingSuspenseBoundary;
82 export const writeEndClientRenderedSuspenseBoundary =
83 $$$config.writeEndClientRenderedSuspenseBoundary;
84 export const writeStartSegment = $$$config.writeStartSegment;
85 export const writeEndSegment = $$$config.writeEndSegment;
86 export const writeCompletedSegmentInstruction =
87 $$$config.writeCompletedSegmentInstruction;
88 export const writeCompletedBoundaryInstruction =
89 $$$config.writeCompletedBoundaryInstruction;
90 export const writeClientRenderBoundaryInstruction =
91 $$$config.writeClientRenderBoundaryInstruction;
92 export const NotPendingTransition = $$$config.NotPendingTransition;
93 export const createPreambleState = $$$config.createPreambleState;
94 export const canHavePreamble = $$$config.canHavePreamble;
95 export const isPreambleContext = $$$config.isPreambleContext;
96 export const isPreambleReady = $$$config.isPreambleReady;
97 export const hoistPreambleState = $$$config.hoistPreambleState;
98
99 // -------------------------
100 // Resources
101 // -------------------------
102 export const writePreambleStart = $$$config.writePreambleStart;
103 export const writePreambleEnd = $$$config.writePreambleEnd;
104 export const writeHoistables = $$$config.writeHoistables;
105 export const writeHoistablesForBoundary = $$$config.writeHoistablesForBoundary;
106 export const writePostamble = $$$config.writePostamble;
107 export const hoistHoistables = $$$config.hoistHoistables;
108 export const createHoistableState = $$$config.createHoistableState;
109 export const hasSuspenseyContent = $$$config.hasSuspenseyContent;
110 export const emitEarlyPreloads = $$$config.emitEarlyPreloads;