1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.setGradleMaven = void 0;
|
4 | const config_plugins_1 = require("@expo/config-plugins");
|
5 | const pkg = require('expo-camera/package.json');
|
6 | const CAMERA_USAGE = 'Allow $(PRODUCT_NAME) to access your camera';
|
7 | const MICROPHONE_USAGE = 'Allow $(PRODUCT_NAME) to access your microphone';
|
8 |
|
9 |
|
10 |
|
11 | const gradleMaven = 'allprojects { repositories { maven { url "$rootDir/../node_modules/expo-camera/android/maven" } } }';
|
12 | const withAndroidCameraGradle = config => {
|
13 | return config_plugins_1.withProjectBuildGradle(config, config => {
|
14 | if (config.modResults.language === 'groovy') {
|
15 | config.modResults.contents = setGradleMaven(config.modResults.contents);
|
16 | }
|
17 | else {
|
18 | throw new Error('Cannot add camera maven gradle because the build.gradle is not groovy');
|
19 | }
|
20 | return config;
|
21 | });
|
22 | };
|
23 | function setGradleMaven(buildGradle) {
|
24 |
|
25 |
|
26 | if (buildGradle.includes('expo-camera/android/maven')) {
|
27 | return buildGradle;
|
28 | }
|
29 | return buildGradle + `\n${gradleMaven}\n`;
|
30 | }
|
31 | exports.setGradleMaven = setGradleMaven;
|
32 | const withCamera = (config, { cameraPermission, microphonePermission } = {}) => {
|
33 | if (!config.ios)
|
34 | config.ios = {};
|
35 | if (!config.ios.infoPlist)
|
36 | config.ios.infoPlist = {};
|
37 | config.ios.infoPlist.NSCameraUsageDescription =
|
38 | cameraPermission || config.ios.infoPlist.NSCameraUsageDescription || CAMERA_USAGE;
|
39 | config.ios.infoPlist.NSMicrophoneUsageDescription =
|
40 | microphonePermission || config.ios.infoPlist.NSMicrophoneUsageDescription || MICROPHONE_USAGE;
|
41 | return config_plugins_1.withPlugins(config, [
|
42 | [
|
43 | config_plugins_1.AndroidConfig.Permissions.withPermissions,
|
44 | [
|
45 | 'android.permission.CAMERA',
|
46 |
|
47 | 'android.permission.RECORD_AUDIO',
|
48 | ],
|
49 | ],
|
50 | withAndroidCameraGradle,
|
51 | ]);
|
52 | };
|
53 | exports.default = config_plugins_1.createRunOncePlugin(withCamera, pkg.name, pkg.version);
|