feat: Add Expo Config Plugin for CodeScanner MLKit Barcode Model downloader (#1916)

This commit is contained in:
Jakov Glavina 2023-10-05 10:58:31 +02:00 committed by GitHub
parent 59699929f4
commit 6e249d165a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1,17 @@
import { AndroidConfig, ConfigPlugin, withAndroidManifest } from '@expo/config-plugins'
const { addMetaDataItemToMainApplication, getMainApplicationOrThrow } = AndroidConfig.Manifest
export const withAndroidMLKitVisionModel: ConfigPlugin = (config) => {
return withAndroidManifest(config, (conf) => {
const androidManifest = conf.modResults
const mainApplication = getMainApplicationOrThrow(androidManifest)
addMetaDataItemToMainApplication(mainApplication, 'com.google.mlkit.vision.DEPENDENCIES', 'barcode')
conf.modResults = androidManifest
return conf
})
}

View File

@ -1,6 +1,7 @@
import { withPlugins, AndroidConfig, ConfigPlugin, createRunOncePlugin } from '@expo/config-plugins'
import { withDisableFrameProcessorsAndroid } from './withDisableFrameProcessorsAndroid'
import { withDisableFrameProcessorsIOS } from './withDisableFrameProcessorsIOS'
import { withAndroidMLKitVisionModel } from './withAndroidMLKitVisionModel'
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment
const pkg = require('../../../package.json')
@ -31,7 +32,7 @@ const withCamera: ConfigPlugin<Props> = (config, props = {}) => {
config = withDisableFrameProcessorsIOS(config)
}
return withPlugins(config, [[AndroidConfig.Permissions.withPermissions, androidPermissions]])
return withPlugins(config, [[AndroidConfig.Permissions.withPermissions, androidPermissions], withAndroidMLKitVisionModel])
}
export default createRunOncePlugin(withCamera, pkg.name, pkg.version)