Files
streamyfin/plugins/withExcludeMedia3Dash.ts
Gauvino 7054137690 refactor: migrate app.config and Expo config plugins to TypeScript
Migrate the dynamic Expo config and all 12 local config plugins from
CommonJS .js to typed TypeScript:

- app.config.js -> app.config.ts (typed ConfigContext/ExpoConfig,
  behavior-identical port)
- plugins/*.js -> plugins/*.ts with `ConfigPlugin` typings from
  expo/config-plugins; plugin options are now type-checked (withGitPod)
- app.json plugin references updated to the .ts paths
- imports unified on expo/config-plugins (some plugins used the
  @expo/config-plugins alias)

Node evaluates the config at prebuild time and cannot parse TypeScript
plugin modules on its own (verified empirically: Expo transpiles
app.config.ts itself but not its imports), so the documented tsx
approach is used: `import "tsx/cjs"` at the top of app.config.ts plus
tsx as a devDependency.

Validation: resolved prebuild configs (expo config --type prebuild) are
byte-identical to the old JS config for both mobile and TV (modulo
plugin path extensions and the builtAt timestamp); full
`bun run prebuild` and `bun run prebuild:tv` pass and all Android
plugin mods are present in the generated project (media3 exclusions,
gradle properties, cast activity, network security config, alert
colors).
2026-06-11 12:20:31 +02:00

37 lines
1.2 KiB
TypeScript

import { type ConfigPlugin, withAppBuildGradle } from "expo/config-plugins";
const withExcludeMedia3Dash: ConfigPlugin = (config) => {
return withAppBuildGradle(config, (config) => {
const contents = config.modResults.contents;
// Add exclusion for duplicate media3 modules before dependencies block
const exclusionBlock = `
configurations.all {
// Exclude duplicate media3 modules to avoid conflict between react-native-video and react-native-track-player
exclude group: 'androidx.media3', module: 'media3-exoplayer-dash'
exclude group: 'androidx.media3', module: 'media3-exoplayer-smoothstreaming'
exclude group: 'androidx.media3', module: 'media3-exoplayer-rtsp'
}
`;
// Check if exclusion already exists
if (contents.includes("media3-exoplayer-dash")) {
return config;
}
// Insert before the dependencies block
const dependenciesIndex = contents.indexOf("dependencies {");
if (dependenciesIndex !== -1) {
config.modResults.contents =
contents.slice(0, dependenciesIndex) +
exclusionBlock +
"\n" +
contents.slice(dependenciesIndex);
}
return config;
});
};
export default withExcludeMedia3Dash;