1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4  value: true
5});
6exports.createBuildPodfilePropsConfigPlugin = createBuildPodfilePropsConfigPlugin;
7exports.updateIosBuildPropertiesFromConfig = updateIosBuildPropertiesFromConfig;
8exports.updateIosBuildProperty = updateIosBuildProperty;
9exports.withJsEnginePodfileProps = void 0;
10function _iosPlugins() {
11  const data = require("../plugins/ios-plugins");
12  _iosPlugins = function () {
13    return data;
14  };
15  return data;
16}
17/**
18 * Creates a `withPodfileProperties` config-plugin based on given config to property mapping rules.
19 *
20 * The factory supports two modes from generic type inference
21 * ```ts
22 * // config-plugin without `props`, it will implicitly use the expo config as source config.
23 * createBuildPodfilePropsConfigPlugin<ExpoConfig>(): ConfigPlugin<void>;
24 *
25 * // config-plugin with a parameter `props: CustomType`, it will use the `props` as source config.
26 * createBuildPodfilePropsConfigPlugin<CustomType>(): ConfigPlugin<CustomType>;
27 * ```
28 *
29 * @param configToPropertyRules config to property mapping rules
30 * @param name the config plugin name
31 */
32function createBuildPodfilePropsConfigPlugin(configToPropertyRules, name) {
33  const withUnknown = (config, sourceConfig) => (0, _iosPlugins().withPodfileProperties)(config, config => {
34    config.modResults = updateIosBuildPropertiesFromConfig(sourceConfig !== null && sourceConfig !== void 0 ? sourceConfig : config, config.modResults, configToPropertyRules);
35    return config;
36  });
37  if (name) {
38    Object.defineProperty(withUnknown, 'name', {
39      value: name
40    });
41  }
42  return withUnknown;
43}
44
45/**
46 * A config-plugin to update `ios/Podfile.properties.json` from the `jsEngine` in expo config
47 */
48const withJsEnginePodfileProps = createBuildPodfilePropsConfigPlugin([{
49  propName: 'expo.jsEngine',
50  propValueGetter: config => {
51    var _ref, _config$ios$jsEngine, _config$ios;
52    return (_ref = (_config$ios$jsEngine = (_config$ios = config.ios) === null || _config$ios === void 0 ? void 0 : _config$ios.jsEngine) !== null && _config$ios$jsEngine !== void 0 ? _config$ios$jsEngine : config.jsEngine) !== null && _ref !== void 0 ? _ref : 'hermes';
53  }
54}], 'withJsEnginePodfileProps');
55exports.withJsEnginePodfileProps = withJsEnginePodfileProps;
56function updateIosBuildPropertiesFromConfig(config, podfileProperties, configToPropertyRules) {
57  for (const configToProperty of configToPropertyRules) {
58    const value = configToProperty.propValueGetter(config);
59    updateIosBuildProperty(podfileProperties, configToProperty.propName, value);
60  }
61  return podfileProperties;
62}
63function updateIosBuildProperty(podfileProperties, name, value, options) {
64  if (value) {
65    podfileProperties[name] = value;
66  } else if (options !== null && options !== void 0 && options.removePropWhenValueIsNull) {
67    delete podfileProperties[name];
68  }
69  return podfileProperties;
70}
71//# sourceMappingURL=BuildProperties.js.map