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 file uses workerize to load ./importFile.worker as a webworker and instanciates it,
    
  11. // exposing flow typed functions that can be used on other files.
    
  12. 
    
  13. import * as importFileModule from './importFile';
    
  14. import WorkerizedImportFile from './importFile.worker';
    
  15. 
    
  16. import type {TimelineData} from '../types';
    
  17. 
    
  18. type ImportFileModule = typeof importFileModule;
    
  19. 
    
  20. const workerizedImportFile: ImportFileModule = window.Worker
    
  21.   ? WorkerizedImportFile()
    
  22.   : importFileModule;
    
  23. 
    
  24. export type ImportWorkerOutputData =
    
  25.   | {status: 'SUCCESS', processedData: TimelineData}
    
  26.   | {status: 'INVALID_PROFILE_ERROR', error: Error}
    
  27.   | {status: 'UNEXPECTED_ERROR', error: Error};
    
  28. 
    
  29. export type importFileFunction = (file: File) => ImportWorkerOutputData;
    
  30. 
    
  31. export const importFile = (file: File): Promise<ImportWorkerOutputData> =>
    
  32.   workerizedImportFile.importFile(file);