This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.

1 line
2.6 KiB
Plaintext
Raw Permalink Normal View History

2021-04-02 02:24:13 +03:00
{"version":3,"file":"Permissions.js","sourceRoot":"","sources":["../../src/ios/Permissions.ts"],"names":[],"mappings":";;AACA,wDAAuD;AAGvD;;;;;;GAMG;AACU,QAAA,eAAe,GAAgD,CAC1E,MAAM,EACN,WAAW,EACX,EAAE;IACF,OAAO,2BAAa,CAAC,MAAM,EAAE,KAAK,EAAC,MAAM,EAAC,EAAE;QAC1C,MAAM,CAAC,UAAU,GAAG,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;QACrE,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,SAAgB,gBAAgB,CAC9B,WAA0C,EAC1C,SAA8B;IAE9B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC5C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,mBAAmB;QACnB,kEAAkE;KACnE;IACD,KAAK,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,OAAO,EAAE;QAC/C,IAAI,WAAW,IAAI,IAAI,EAAE;YACvB,OAAO,SAAS,CAAC,UAAU,CAAC,CAAC;SAC9B;aAAM;YACL,MAAM,kBAAkB,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;YACjD,IAAI,kBAAkB,IAAI,kBAAkB,KAAK,WAAW,EAAE;gBAC5D,mBAAmB;gBACnB,kBAAkB;gBAClB,gJAAgJ;gBAChJ,OAAO;aACR;YACD,SAAS,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC;SACrC;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAxBD,4CAwBC","sourcesContent":["import { ConfigPlugin } from '../Plugin.types';\nimport { withInfoPlist } from '../plugins/ios-plugins';\nimport { InfoPlist } from './IosConfig.types';\n\n/**\n * Apply permissions and their respective descriptions to the iOS Info.plist.\n * Providing a null description will remove the permission from the Info.plist.\n *\n * @param config\n * @param permissions record of strings where the key matches Info.plist permissions and the values are the permission descriptions.\n */\nexport const withPermissions: ConfigPlugin<Record<string, string | null>> = (\n config,\n permissions\n) => {\n return withInfoPlist(config, async config => {\n config.modResults = applyPermissions(permissions, config.modResults);\n return config;\n });\n};\n\nexport function applyPermissions(\n permissions: Record<string, string | null>,\n infoPlist: Record<string, any>\n): InfoPlist {\n const entries = Object.entries(permissions);\n if (entries.length === 0) {\n // TODO: Debug warn\n // console.warn('[withPermissions] no permissions were provided');\n }\n for (const [permission, description] of entries) {\n if (description == null) {\n delete infoPlist[permission];\n } else {\n const existingPermission = infoPlist[permission];\n if (existingPermission && existingPermission !== description) {\n // TODO: Debug warn\n // console.warn(\n // `[withPermissionsIos][conflict] permission \"${permission}\" is already defined in the Info.plist with description \"${existingPermission}\"`\n // );\n }\n infoPlist[permission] = description;\n }\n }\n return infoPlist;\n}\n"]}