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. import type {
    
  11.   CrossOriginEnum,
    
  12.   PreloadImplOptions,
    
  13.   PreloadModuleImplOptions,
    
  14.   PreinitStyleOptions,
    
  15.   PreinitScriptOptions,
    
  16.   PreinitModuleScriptOptions,
    
  17. } from 'react-dom/src/shared/ReactDOMTypes';
    
  18. 
    
  19. import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals';
    
  20. const ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
    
  21. 
    
  22. import {ReactDOMFlightServerDispatcher} from './ReactDOMFlightServerHostDispatcher';
    
  23. 
    
  24. export function prepareHostDispatcher(): void {
    
  25.   ReactDOMCurrentDispatcher.current = ReactDOMFlightServerDispatcher;
    
  26. }
    
  27. 
    
  28. // Used to distinguish these contexts from ones used in other renderers.
    
  29. // E.g. this can be used to distinguish legacy renderers from this modern one.
    
  30. export const isPrimaryRenderer = true;
    
  31. 
    
  32. // We use zero to represent the absence of an explicit precedence because it is
    
  33. // small, smaller than how we encode undefined, and is unambiguous. We could use
    
  34. // a different tuple structure to encode this instead but this makes the runtime
    
  35. // cost cheaper by eliminating a type checks in more positions.
    
  36. type UnspecifiedPrecedence = 0;
    
  37. 
    
  38. // prettier-ignore
    
  39. type TypeMap = {
    
  40.   // prefetchDNS(href)
    
  41.   'D': /* href */ string,
    
  42.   // preconnect(href, options)
    
  43.   'C':
    
  44.     | /* href */ string
    
  45.     | [/* href */ string, CrossOriginEnum],
    
  46.   // preconnect(href, options)
    
  47.   'L':
    
  48.     | [/* href */ string, /* as */ string]
    
  49.     | [/* href */ string, /* as */ string, PreloadImplOptions],
    
  50.   'm':
    
  51.     | /* href */ string
    
  52.     | [/* href */ string, PreloadModuleImplOptions],
    
  53.   'S':
    
  54.     | /* href */ string
    
  55.     | [/* href */ string, /* precedence */ string]
    
  56.     | [/* href */ string, /* precedence */ string | UnspecifiedPrecedence, PreinitStyleOptions],
    
  57.   'X':
    
  58.     | /* href */ string
    
  59.     | [/* href */ string, PreinitScriptOptions],
    
  60.   'M':
    
  61.     | /* href */ string
    
  62.     | [/* href */ string, PreinitModuleScriptOptions],
    
  63. }
    
  64. 
    
  65. export type HintCode = $Keys<TypeMap>;
    
  66. export type HintModel<T: HintCode> = TypeMap[T];
    
  67. 
    
  68. export type Hints = Set<string>;
    
  69. 
    
  70. export function createHints(): Hints {
    
  71.   return new Set();
    
  72. }