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 {preinitModuleForSSR} from 'react-client/src/ReactFlightClientConfig';
    
  11. 
    
  12. export type ModuleLoading =
    
  13.   | null
    
  14.   | string
    
  15.   | {
    
  16.       prefix: string,
    
  17.       crossOrigin?: string,
    
  18.     };
    
  19. 
    
  20. export function prepareDestinationForModuleImpl(
    
  21.   moduleLoading: ModuleLoading,
    
  22.   // Chunks are double-indexed [..., idx, filenamex, idy, filenamey, ...]
    
  23.   mod: string,
    
  24.   nonce: ?string,
    
  25. ) {
    
  26.   if (typeof moduleLoading === 'string') {
    
  27.     preinitModuleForSSR(moduleLoading + mod, nonce, undefined);
    
  28.   } else if (moduleLoading !== null) {
    
  29.     preinitModuleForSSR(
    
  30.       moduleLoading.prefix + mod,
    
  31.       nonce,
    
  32.       moduleLoading.crossOrigin,
    
  33.     );
    
  34.   }
    
  35. }