feat: Add Expo Config Plugin for CodeScanner MLKit Barcode Model downloader (#1916)
This commit is contained in:
parent
59699929f4
commit
6e249d165a
17
package/src/expo-plugin/withAndroidMLKitVisionModel.ts
Normal file
17
package/src/expo-plugin/withAndroidMLKitVisionModel.ts
Normal 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
|
||||
})
|
||||
}
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user