From 4c4d28f0e2843628f124bef676ca22eb289a3343 Mon Sep 17 00:00:00 2001 From: lafay <2021211506@stu.hit.edu.cn> Date: Tue, 16 Jun 2026 01:10:20 +0800 Subject: [PATCH] feat(plugins): add LiveKit audio switch patch plugin Introduce withLivekitAudioswitchPatch plugin for handling LiveKit audio routing and switching functionality. --- app.json | 1 + plugins/withLivekitAudioswitchPatch.js | 40 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 plugins/withLivekitAudioswitchPatch.js diff --git a/app.json b/app.json index 5aaca0c..63b7d24 100644 --- a/app.json +++ b/app.json @@ -68,6 +68,7 @@ "plugins": [ "./plugins/withCmakeJobLimit", "./plugins/withJcorePatch", + "./plugins/withLivekitAudioswitchPatch", "./plugins/withSigning", "./plugins/withMainActivityConfigChange", [ diff --git a/plugins/withLivekitAudioswitchPatch.js b/plugins/withLivekitAudioswitchPatch.js new file mode 100644 index 0000000..d83adf1 --- /dev/null +++ b/plugins/withLivekitAudioswitchPatch.js @@ -0,0 +1,40 @@ +const { withDangerousMod } = require('@expo/config-plugins'); +const fs = require('fs'); +const path = require('path'); + +// @livekit/react-native depends on com.github.davidliu:audioswitch via JitPack. +// That JitPack artifact returns 403 Forbidden (repo/commit no longer accessible). +// The original upstream com.twilio:audioswitch is published on Maven Central. +// This plugin patches livekit's build.gradle during prebuild to swap the +// JitPack dependency for the Maven Central one. +const withLivekitAudioswitchPatch = (config) => + withDangerousMod(config, [ + 'android', + async (config) => { + const root = config.modRequest.projectRoot; + const gradlePath = path.join( + root, + 'node_modules', + '@livekit', + 'react-native', + 'android', + 'build.gradle', + ); + + if (!fs.existsSync(gradlePath)) return config; + + let content = fs.readFileSync(gradlePath, 'utf-8'); + const oldDep = /api\s+'com\.github\.davidliu:audioswitch:[a-f0-9]+'/; + const newDep = `api 'com.twilio:audioswitch:1.1.5'`; + + if (oldDep.test(content)) { + content = content.replace(oldDep, newDep); + fs.writeFileSync(gradlePath, content); + console.log('[withLivekitAudioswitchPatch] replaced davidliu JitPack audioswitch with com.twilio:audioswitch:1.1.5'); + } + + return config; + }, + ]); + +module.exports = withLivekitAudioswitchPatch;