1import { 2 getBuildInfoAsync, 3 getCrashReport, 4 installationID, 5 isDevice, 6 updatesConfig, 7} from '../native-modules/DevLauncherInternal'; 8import { getMenuPreferencesAsync } from '../native-modules/DevMenuPreferences'; 9import { AppProvidersProps } from '../providers/AppProviders'; 10import { defaultQueryOptions } from '../providers/QueryProvider'; 11import { prefetchBranchesForApp } from '../queries/useBranchesForApp'; 12import { getDevSessionsAsync } from './getDevSessionsAsync'; 13import { restoreUserAsync } from './restoreUserAsync'; 14 15export async function getInitialData(): Promise<Partial<AppProvidersProps>> { 16 const initialUserData = await restoreUserAsync(); 17 const isAuthenticated = initialUserData != null; 18 19 const initialDevSessions = await getDevSessionsAsync({ 20 isAuthenticated, 21 installationID, 22 isDevice, 23 }); 24 25 const initialBuildInfo = await getBuildInfoAsync(); 26 const initialDevMenuPreferences = await getMenuPreferencesAsync(); 27 const initialCrashReport = await getCrashReport(); 28 29 if (isAuthenticated && updatesConfig.usesEASUpdates) { 30 prefetchBranchesForApp( 31 updatesConfig.appId, 32 updatesConfig.runtimeVersion, 33 defaultQueryOptions.pageSize 34 ).catch((error) => console.log({ error })); 35 } 36 37 return { 38 initialDevSessions, 39 initialUserData, 40 initialBuildInfo, 41 initialDevMenuPreferences, 42 initialCrashReport, 43 }; 44} 45