1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4  value: true
5});
6exports.createEntitlementsPlugin = createEntitlementsPlugin;
7exports.createInfoPlistPlugin = createInfoPlistPlugin;
8exports.createInfoPlistPluginWithPropertyGuard = createInfoPlistPluginWithPropertyGuard;
9exports.withXcodeProject = exports.withPodfileProperties = exports.withInfoPlist = exports.withExpoPlist = exports.withEntitlementsPlist = exports.withAppDelegate = void 0;
10
11function _obj() {
12  const data = require("../utils/obj");
13
14  _obj = function () {
15    return data;
16  };
17
18  return data;
19}
20
21function _warnings() {
22  const data = require("../utils/warnings");
23
24  _warnings = function () {
25    return data;
26  };
27
28  return data;
29}
30
31function _withMod() {
32  const data = require("./withMod");
33
34  _withMod = function () {
35    return data;
36  };
37
38  return data;
39}
40
41/**
42 * Helper method for creating mods from existing config functions.
43 *
44 * @param action
45 */
46function createInfoPlistPlugin(action, name) {
47  const withUnknown = config => withInfoPlist(config, async config => {
48    config.modResults = await action(config, config.modResults);
49    return config;
50  });
51
52  if (name) {
53    Object.defineProperty(withUnknown, 'name', {
54      value: name
55    });
56  }
57
58  return withUnknown;
59}
60
61function createInfoPlistPluginWithPropertyGuard(action, settings, name) {
62  const withUnknown = config => withInfoPlist(config, async config => {
63    var _config$modRawConfig$, _config$modRawConfig$2;
64
65    const existingProperty = settings.expoPropertyGetter ? settings.expoPropertyGetter(config) : (0, _obj().get)(config, settings.expoConfigProperty); // If the user explicitly sets a value in the infoPlist, we should respect that.
66
67    if (((_config$modRawConfig$ = config.modRawConfig.ios) === null || _config$modRawConfig$ === void 0 ? void 0 : (_config$modRawConfig$2 = _config$modRawConfig$.infoPlist) === null || _config$modRawConfig$2 === void 0 ? void 0 : _config$modRawConfig$2[settings.infoPlistProperty]) === undefined) {
68      config.modResults = await action(config, config.modResults);
69    } else if (existingProperty !== undefined) {
70      // Only warn if there is a conflict.
71      (0, _warnings().addWarningIOS)(settings.expoConfigProperty, `"ios.infoPlist.${settings.infoPlistProperty}" is set in the config. Ignoring abstract property "${settings.expoConfigProperty}": ${existingProperty}`);
72    }
73
74    return config;
75  });
76
77  if (name) {
78    Object.defineProperty(withUnknown, 'name', {
79      value: name
80    });
81  }
82
83  return withUnknown;
84}
85
86/**
87 * Helper method for creating mods from existing config functions.
88 *
89 * @param action
90 */
91function createEntitlementsPlugin(action, name) {
92  const withUnknown = config => withEntitlementsPlist(config, async config => {
93    config.modResults = await action(config, config.modResults);
94    return config;
95  });
96
97  if (name) {
98    Object.defineProperty(withUnknown, 'name', {
99      value: name
100    });
101  }
102
103  return withUnknown;
104}
105/**
106 * Provides the AppDelegate file for modification.
107 *
108 * @param config
109 * @param action
110 */
111
112
113const withAppDelegate = (config, action) => {
114  return (0, _withMod().withMod)(config, {
115    platform: 'ios',
116    mod: 'appDelegate',
117    action
118  });
119};
120/**
121 * Provides the Info.plist file for modification.
122 * Keeps the config's expo.ios.infoPlist object in sync with the data.
123 *
124 * @param config
125 * @param action
126 */
127
128
129exports.withAppDelegate = withAppDelegate;
130
131const withInfoPlist = (config, action) => {
132  return (0, _withMod().withMod)(config, {
133    platform: 'ios',
134    mod: 'infoPlist',
135
136    async action(config) {
137      config = await action(config);
138
139      if (!config.ios) {
140        config.ios = {};
141      }
142
143      config.ios.infoPlist = config.modResults;
144      return config;
145    }
146
147  });
148};
149/**
150 * Provides the main .entitlements file for modification.
151 * Keeps the config's expo.ios.entitlements object in sync with the data.
152 *
153 * @param config
154 * @param action
155 */
156
157
158exports.withInfoPlist = withInfoPlist;
159
160const withEntitlementsPlist = (config, action) => {
161  return (0, _withMod().withMod)(config, {
162    platform: 'ios',
163    mod: 'entitlements',
164
165    async action(config) {
166      config = await action(config);
167
168      if (!config.ios) {
169        config.ios = {};
170      }
171
172      config.ios.entitlements = config.modResults;
173      return config;
174    }
175
176  });
177};
178/**
179 * Provides the Expo.plist for modification.
180 *
181 * @param config
182 * @param action
183 */
184
185
186exports.withEntitlementsPlist = withEntitlementsPlist;
187
188const withExpoPlist = (config, action) => {
189  return (0, _withMod().withMod)(config, {
190    platform: 'ios',
191    mod: 'expoPlist',
192    action
193  });
194};
195/**
196 * Provides the main .xcodeproj for modification.
197 *
198 * @param config
199 * @param action
200 */
201
202
203exports.withExpoPlist = withExpoPlist;
204
205const withXcodeProject = (config, action) => {
206  return (0, _withMod().withMod)(config, {
207    platform: 'ios',
208    mod: 'xcodeproj',
209    action
210  });
211};
212/**
213 * Provides the Podfile.properties.json for modification.
214 *
215 * @param config
216 * @param action
217 */
218
219
220exports.withXcodeProject = withXcodeProject;
221
222const withPodfileProperties = (config, action) => {
223  return (0, _withMod().withMod)(config, {
224    platform: 'ios',
225    mod: 'podfileProperties',
226    action
227  });
228};
229
230exports.withPodfileProperties = withPodfileProperties;
231//# sourceMappingURL=ios-plugins.js.map