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