1{"version":3,"file":"ios-plugins.js","names":["createInfoPlistPlugin","action","name","withUnknown","config","withInfoPlist","modResults","Object","defineProperty","value","createInfoPlistPluginWithPropertyGuard","settings","existingProperty","expoPropertyGetter","get","expoConfigProperty","modRawConfig","ios","infoPlist","infoPlistProperty","undefined","addWarningIOS","createEntitlementsPlugin","withEntitlementsPlist","withAppDelegate","withMod","platform","mod","entitlements","withExpoPlist","withXcodeProject","withPodfileProperties"],"sources":["../../src/plugins/ios-plugins.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\nimport type { JSONObject } from '@expo/json-file';\nimport type { XcodeProject } from 'xcode';\n\nimport type { ConfigPlugin, Mod } from '../Plugin.types';\nimport type { ExpoPlist, InfoPlist } from '../ios/IosConfig.types';\nimport type { AppDelegateProjectFile } from '../ios/Paths';\nimport { get } from '../utils/obj';\nimport { addWarningIOS } from '../utils/warnings';\nimport { withMod } from './withMod';\n\ntype MutateInfoPlistAction = (\n  expo: ExpoConfig,\n  infoPlist: InfoPlist\n) => Promise<InfoPlist> | InfoPlist;\n\n/**\n * Helper method for creating mods from existing config functions.\n *\n * @param action\n */\nexport function createInfoPlistPlugin(action: MutateInfoPlistAction, name?: string): ConfigPlugin {\n  const withUnknown: ConfigPlugin = (config) =>\n    withInfoPlist(config, async (config) => {\n      config.modResults = await action(config, config.modResults);\n      return config;\n    });\n  if (name) {\n    Object.defineProperty(withUnknown, 'name', {\n      value: name,\n    });\n  }\n  return withUnknown;\n}\n\nexport function createInfoPlistPluginWithPropertyGuard(\n  action: MutateInfoPlistAction,\n  settings: {\n    infoPlistProperty: string;\n    expoConfigProperty: string;\n    expoPropertyGetter?: (config: ExpoConfig) => string;\n  },\n  name?: string\n): ConfigPlugin {\n  const withUnknown: ConfigPlugin = (config) =>\n    withInfoPlist(config, async (config) => {\n      const existingProperty = settings.expoPropertyGetter\n        ? settings.expoPropertyGetter(config)\n        : get(config, settings.expoConfigProperty);\n      // If the user explicitly sets a value in the infoPlist, we should respect that.\n      if (config.modRawConfig.ios?.infoPlist?.[settings.infoPlistProperty] === undefined) {\n        config.modResults = await action(config, config.modResults);\n      } else if (existingProperty !== undefined) {\n        // Only warn if there is a conflict.\n        addWarningIOS(\n          settings.expoConfigProperty,\n          `\"ios.infoPlist.${settings.infoPlistProperty}\" is set in the config. Ignoring abstract property \"${settings.expoConfigProperty}\": ${existingProperty}`\n        );\n      }\n\n      return config;\n    });\n  if (name) {\n    Object.defineProperty(withUnknown, 'name', {\n      value: name,\n    });\n  }\n  return withUnknown;\n}\n\ntype MutateEntitlementsPlistAction = (expo: ExpoConfig, entitlements: JSONObject) => JSONObject;\n\n/**\n * Helper method for creating mods from existing config functions.\n *\n * @param action\n */\nexport function createEntitlementsPlugin(\n  action: MutateEntitlementsPlistAction,\n  name: string\n): ConfigPlugin {\n  const withUnknown: ConfigPlugin = (config) =>\n    withEntitlementsPlist(config, async (config) => {\n      config.modResults = await action(config, config.modResults);\n      return config;\n    });\n  if (name) {\n    Object.defineProperty(withUnknown, 'name', {\n      value: name,\n    });\n  }\n  return withUnknown;\n}\n\n/**\n * Provides the AppDelegate file for modification.\n *\n * @param config\n * @param action\n */\nexport const withAppDelegate: ConfigPlugin<Mod<AppDelegateProjectFile>> = (config, action) => {\n  return withMod(config, {\n    platform: 'ios',\n    mod: 'appDelegate',\n    action,\n  });\n};\n\n/**\n * Provides the Info.plist file for modification.\n * Keeps the config's expo.ios.infoPlist object in sync with the data.\n *\n * @param config\n * @param action\n */\nexport const withInfoPlist: ConfigPlugin<Mod<InfoPlist>> = (config, action) => {\n  return withMod<InfoPlist>(config, {\n    platform: 'ios',\n    mod: 'infoPlist',\n    async action(config) {\n      config = await action(config);\n      if (!config.ios) {\n        config.ios = {};\n      }\n      config.ios.infoPlist = config.modResults;\n      return config;\n    },\n  });\n};\n\n/**\n * Provides the main .entitlements file for modification.\n * Keeps the config's expo.ios.entitlements object in sync with the data.\n *\n * @param config\n * @param action\n */\nexport const withEntitlementsPlist: ConfigPlugin<Mod<JSONObject>> = (config, action) => {\n  return withMod<JSONObject>(config, {\n    platform: 'ios',\n    mod: 'entitlements',\n    async action(config) {\n      config = await action(config);\n      if (!config.ios) {\n        config.ios = {};\n      }\n      config.ios.entitlements = config.modResults;\n      return config;\n    },\n  });\n};\n\n/**\n * Provides the Expo.plist for modification.\n *\n * @param config\n * @param action\n */\nexport const withExpoPlist: ConfigPlugin<Mod<ExpoPlist>> = (config, action) => {\n  return withMod(config, {\n    platform: 'ios',\n    mod: 'expoPlist',\n    action,\n  });\n};\n\n/**\n * Provides the main .xcodeproj for modification.\n *\n * @param config\n * @param action\n */\nexport const withXcodeProject: ConfigPlugin<Mod<XcodeProject>> = (config, action) => {\n  return withMod(config, {\n    platform: 'ios',\n    mod: 'xcodeproj',\n    action,\n  });\n};\n\n/**\n * Provides the Podfile.properties.json for modification.\n *\n * @param config\n * @param action\n */\nexport const withPodfileProperties: ConfigPlugin<Mod<Record<string, string>>> = (\n  config,\n  action\n) => {\n  return withMod(config, {\n    platform: 'ios',\n    mod: 'podfileProperties',\n    action,\n  });\n};\n"],"mappings":";;;;;;;;;AAOA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAOA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAqB,CAACC,MAA6B,EAAEC,IAAa,EAAgB;EAChG,MAAMC,WAAyB,GAAIC,MAAM,IACvCC,aAAa,CAACD,MAAM,EAAE,MAAOA,MAAM,IAAK;IACtCA,MAAM,CAACE,UAAU,GAAG,MAAML,MAAM,CAACG,MAAM,EAAEA,MAAM,CAACE,UAAU,CAAC;IAC3D,OAAOF,MAAM;EACf,CAAC,CAAC;EACJ,IAAIF,IAAI,EAAE;IACRK,MAAM,CAACC,cAAc,CAACL,WAAW,EAAE,MAAM,EAAE;MACzCM,KAAK,EAAEP;IACT,CAAC,CAAC;EACJ;EACA,OAAOC,WAA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