import type { ConfigContext, ExpoConfig } from 'expo/config'; /** * app.json holds the real config; this only adds build-time switches. * * Local test builds point at a dev server over plain http://, which Android * blocks by default in release builds. Allow cleartext only when the API URL * itself is http://, so store builds (https) stay locked down. */ export default ({ config }: ConfigContext): ExpoConfig => { const apiUrl = process.env.EXPO_PUBLIC_API_URL ?? ''; const localHttp = apiUrl.startsWith('http://'); // F-Droid (MUSICSHARE_FOSS=1): no closed-source libraries. The only one is the Google ML Kit / // Play Services barcode scanner expo-camera bundles; the scan screen decodes QR codes in JS instead. const foss = process.env.MUSICSHARE_FOSS === '1'; type Plugin = NonNullable[number]; const plugins = (config.plugins ?? []).map( (plugin): Plugin => foss && Array.isArray(plugin) && plugin[0] === 'expo-camera' ? ['expo-camera', { ...plugin[1], barcodeScannerEnabled: false }] : plugin, ); return { ...(config as ExpoConfig), extra: { ...config.extra, foss }, plugins: [ ...plugins, ['expo-build-properties', { android: { usesCleartextTraffic: localHttp } }] satisfies Plugin, // F-Droid delivers updates itself; only our own builds install them (modules/updater). ...(foss ? ['./plugins/withoutSelfUpdate'] : []), ], }; };