49
Hints,
50
HintCode,
51
HintModel,
52
+ FormatContext,
53
} from './ReactFlightServerConfig';
54
import type {ThenableState} from './ReactFlightThenable';
55
import type {
89
supportsRequestStorage,
90
requestStorage,
91
createHints,
92
+ createRootFormatContext,
93
+ getChildFormatContext,
94
initAsyncDebugInfo,
95
markAsyncSequenceRootTask,
96
getCurrentAsyncSequence,
528
toJSON: (key: string, value: ReactClientValue) => ReactJSONValue,
529
keyPath: null | string, // parent server component keys
530
implicitSlot: boolean, // true if the root server component of this sequence had a null key
531
+ formatContext: FormatContext, // an approximate parent context from host components
532
thenableState: ThenableState | null,
533
timed: boolean, // Profiling-only. Whether we need to track the completion time of this task.
534
time: number, // Profiling-only. The last time stamp emitted for this task.
762
model,
763
null,
764
false,
765
+ createRootFormatContext(),
766
abortSet,
767
timeOrigin,
768
null,
985
(thenable: any), // will be replaced by the value before we retry. used for debug info.
986
task.keyPath, // the server component sequence continues through Promise-as-a-child.
987
task.implicitSlot,
988
+ task.formatContext,
989
request.abortableTasks,
990
enableProfilerTimer &&
991
(enableComponentPerformanceTrack || enableAsyncDebugInfo)
1108
task.model,
1109
task.keyPath,
1110
task.implicitSlot,
1111
+ task.formatContext,
1112
request.abortableTasks,
1113
enableProfilerTimer &&
1114
(enableComponentPerformanceTrack || enableAsyncDebugInfo)
1204
task.model,
1205
task.keyPath,
1206
task.implicitSlot,
1207
+ task.formatContext,
1208
request.abortableTasks,
1209
enableProfilerTimer &&
1210
(enableComponentPerformanceTrack || enableAsyncDebugInfo)
2036
task.model, // the currently rendering element
2037
task.keyPath, // unlike outlineModel this one carries along context
2038
task.implicitSlot,
2039
+ task.formatContext,
2040
request.abortableTasks,
2041
enableProfilerTimer &&
2042
(enableComponentPerformanceTrack || enableAsyncDebugInfo)
2057
task.model, // the currently rendering element
2058
task.keyPath, // unlike outlineModel this one carries along context
2059
task.implicitSlot,
2060
+ task.formatContext,
2061
request.abortableTasks,
2062
enableProfilerTimer &&
2063
(enableComponentPerformanceTrack || enableAsyncDebugInfo)
2224
}
2225
}
2226
}
2227
+ } else if (typeof type === 'string') {
2228
+ const parentFormatContext = task.formatContext;
2229
+ const newFormatContext = getChildFormatContext(
2230
+ parentFormatContext,
2231
+ type,
2232
+ props,
2233
+ );
2234
+ if (parentFormatContext !== newFormatContext && props.children != null) {
2235
+ // We've entered a new context. We need to create another Task which has
2236
+ // the new context set up since it's not safe to push/pop in the middle of
2237
+ // a tree. Additionally this means that any deduping within this tree now
2238
+ // assumes the new context even if it's reused outside in a different context.
2239
+ // We'll rely on this to dedupe the value later as we discover it again
2240
+ // inside the returned element's tree.
2241
+ outlineModelWithFormatContext(request, props.children, newFormatContext);
2242
+ }
2243
}
2244
// For anything else, try it on the client instead.
2245
// We don't know if the client will support it or not. This might error on the
2556
model: ReactClientValue,
2557
keyPath: null | string,
2558
implicitSlot: boolean,
2559
+ formatContext: FormatContext,
2560
abortSet: Set<Task>,
2561
lastTimestamp: number, // Profiling-only
2562
debugOwner: null | ReactComponentInfo, // DEV-only
2581
model,
2582
keyPath,
2583
implicitSlot,
2584
+ formatContext: formatContext,
2585
ping: () => pingTask(request, task),
2586
toJSON: function (
2587
this:
2847
}
2848
2849
function outlineModel(request: Request, value: ReactClientValue): number {
2850
+ return outlineModelWithFormatContext(
2851
+ request,
2852
+ value,
2853
+ // For deduped values we don't know which context it will be reused in
2854
+ // so we have to assume that it's the root context.
2855
+ createRootFormatContext(),
2856
+ );
2857
+}
2858
+
2859
+function outlineModelWithFormatContext(
2860
+ request: Request,
2861
+ value: ReactClientValue,
2862
+ formatContext: FormatContext,
2863
+): number {
2864
const newTask = createTask(
2865
request,
2866
value,
2867
null, // The way we use outlining is for reusing an object.
2868
false, // It makes no sense for that use case to be contextual.
2869
+ formatContext, // Except for FormatContext we optimistically use it.
2870
request.abortableTasks,
2871
enableProfilerTimer &&
2872
(enableComponentPerformanceTrack || enableAsyncDebugInfo)
3114
model,
3115
null,
3116
false,
3117
+ createRootFormatContext(),
3118
request.abortableTasks,
3119
enableProfilerTimer &&
3120
(enableComponentPerformanceTrack || enableAsyncDebugInfo)
3252
task.model,
3253
task.keyPath,
3254
task.implicitSlot,
3255
+ task.formatContext,
3256
request.abortableTasks,
3257
enableProfilerTimer &&
3258
(enableComponentPerformanceTrack || enableAsyncDebugInfo)