customerio-expo-plugin 3.4.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/package.json +2 -1
  2. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +64 -59
  3. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
  4. package/plugin/lib/commonjs/android/withAppGoogleServices.js +10 -7
  5. package/plugin/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
  6. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +18 -21
  7. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  8. package/plugin/lib/commonjs/android/withLocationGradleProperties.js +16 -12
  9. package/plugin/lib/commonjs/android/withLocationGradleProperties.js.map +1 -1
  10. package/plugin/lib/commonjs/android/withMainApplicationModifications.js +19 -12
  11. package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -1
  12. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js +2 -1
  13. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js.map +1 -1
  14. package/plugin/lib/commonjs/android/withProjectBuildGradle.js +29 -25
  15. package/plugin/lib/commonjs/android/withProjectBuildGradle.js.map +1 -1
  16. package/plugin/lib/commonjs/android/withProjectGoogleServices.js +9 -5
  17. package/plugin/lib/commonjs/android/withProjectGoogleServices.js.map +1 -1
  18. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +63 -31
  19. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  20. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +47 -33
  21. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
  22. package/plugin/lib/commonjs/ios/withCIOIosSwift.js +26 -42
  23. package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
  24. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +46 -30
  25. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
  26. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +192 -122
  27. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  28. package/plugin/lib/module/android/withAndroidManifestUpdates.js +61 -58
  29. package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
  30. package/plugin/lib/module/android/withAppGoogleServices.js +9 -7
  31. package/plugin/lib/module/android/withAppGoogleServices.js.map +1 -1
  32. package/plugin/lib/module/android/withGoogleServicesJSON.js +17 -21
  33. package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  34. package/plugin/lib/module/android/withLocationGradleProperties.js +15 -12
  35. package/plugin/lib/module/android/withLocationGradleProperties.js.map +1 -1
  36. package/plugin/lib/module/android/withMainApplicationModifications.js +18 -12
  37. package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -1
  38. package/plugin/lib/module/android/withNotificationChannelMetadata.js +1 -1
  39. package/plugin/lib/module/android/withNotificationChannelMetadata.js.map +1 -1
  40. package/plugin/lib/module/android/withProjectBuildGradle.js +28 -25
  41. package/plugin/lib/module/android/withProjectBuildGradle.js.map +1 -1
  42. package/plugin/lib/module/android/withProjectGoogleServices.js +8 -5
  43. package/plugin/lib/module/android/withProjectGoogleServices.js.map +1 -1
  44. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +61 -31
  45. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  46. package/plugin/lib/module/ios/withAppDelegateModifications.js +45 -33
  47. package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
  48. package/plugin/lib/module/ios/withCIOIosSwift.js +24 -42
  49. package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
  50. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +45 -30
  51. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
  52. package/plugin/lib/module/ios/withNotificationsXcodeProject.js +187 -122
  53. package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  54. package/plugin/lib/typescript/android/withAndroidManifestUpdates.d.ts +2 -0
  55. package/plugin/lib/typescript/android/withAppGoogleServices.d.ts +1 -0
  56. package/plugin/lib/typescript/android/withGoogleServicesJSON.d.ts +1 -0
  57. package/plugin/lib/typescript/android/withLocationGradleProperties.d.ts +2 -0
  58. package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +6 -0
  59. package/plugin/lib/typescript/android/withNotificationChannelMetadata.d.ts +5 -0
  60. package/plugin/lib/typescript/android/withProjectBuildGradle.d.ts +9 -0
  61. package/plugin/lib/typescript/android/withProjectGoogleServices.d.ts +1 -0
  62. package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +14 -0
  63. package/plugin/lib/typescript/ios/withAppDelegateModifications.d.ts +13 -0
  64. package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +11 -0
  65. package/plugin/lib/typescript/ios/withGoogleServicesJsonFile.d.ts +14 -1
  66. package/plugin/lib/typescript/ios/withNotificationsXcodeProject.d.ts +53 -2
  67. package/plugin/src/android/withAndroidManifestUpdates.ts +83 -73
  68. package/plugin/src/android/withAppGoogleServices.ts +13 -11
  69. package/plugin/src/android/withGoogleServicesJSON.ts +30 -28
  70. package/plugin/src/android/withLocationGradleProperties.ts +23 -17
  71. package/plugin/src/android/withMainApplicationModifications.ts +25 -15
  72. package/plugin/src/android/withNotificationChannelMetadata.ts +1 -1
  73. package/plugin/src/android/withProjectBuildGradle.ts +37 -27
  74. package/plugin/src/android/withProjectGoogleServices.ts +14 -9
  75. package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +83 -48
  76. package/plugin/src/ios/withAppDelegateModifications.ts +61 -48
  77. package/plugin/src/ios/withCIOIosSwift.ts +33 -50
  78. package/plugin/src/ios/withGoogleServicesJsonFile.ts +66 -48
  79. package/plugin/src/ios/withNotificationsXcodeProject.ts +257 -207
@@ -3,70 +3,73 @@ import { logger } from '../utils/logger';
3
3
 
4
4
  // Default low priority for Firebase messaging service when setHighPriorityPushHandler is false
5
5
  export const DEFAULT_LOW_PRIORITY = -10;
6
- export const withAndroidManifestUpdates = (configOuter, options) => {
7
- return withAndroidManifest(configOuter, props => {
8
- const application = props.modResults.manifest.application;
9
- const customerIOMessagingpush = 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';
10
- if (!application[0].service) {
11
- application[0].service = [];
6
+ export function modifyAndroidManifestApplication(application, options) {
7
+ const customerIOMessagingpush = 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';
8
+ if (!application[0].service) {
9
+ application[0].service = [];
10
+ }
11
+ const existingServiceIndex = application[0].service.findIndex(service => service.$['android:name'] === customerIOMessagingpush);
12
+ if (existingServiceIndex === -1) {
13
+ // Intent filter structure for Firebase messaging service
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ const intentFilter = {
16
+ action: [{
17
+ $: {
18
+ 'android:name': 'com.google.firebase.MESSAGING_EVENT'
19
+ }
20
+ }]
21
+ };
22
+
23
+ // Handle priority based on setHighPriorityPushHandler value
24
+ if (options.setHighPriorityPushHandler === true) {
25
+ // High priority - no priority attribute means default high priority
26
+ logger.info('Successfully set CustomerIO push handler as high priority in AndroidManifest.xml');
27
+ } else if (options.setHighPriorityPushHandler === false) {
28
+ // Low priority - set fixed priority
29
+ intentFilter.$ = {
30
+ 'android:priority': DEFAULT_LOW_PRIORITY.toString()
31
+ };
32
+ logger.info(`Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
12
33
  }
13
- const existingServiceIndex = application[0].service.findIndex(service => service.$['android:name'] === customerIOMessagingpush);
14
- if (existingServiceIndex === -1) {
15
- // Intent filter structure for Firebase messaging service
34
+ application[0].service.push({
35
+ '$': {
36
+ 'android:name': customerIOMessagingpush,
37
+ 'android:exported': 'false'
38
+ },
39
+ 'intent-filter': [intentFilter]
40
+ });
41
+ } else if (options.setHighPriorityPushHandler === true) {
42
+ // Service exists, need to ensure it becomes high priority (remove priority attribute)
43
+ const existingService = application[0].service[existingServiceIndex];
44
+ if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
16
45
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- const intentFilter = {
18
- action: [{
19
- $: {
20
- 'android:name': 'com.google.firebase.MESSAGING_EVENT'
21
- }
22
- }]
23
- };
24
-
25
- // Handle priority based on setHighPriorityPushHandler value
26
- if (options.setHighPriorityPushHandler === true) {
27
- // High priority - no priority attribute means default high priority
28
- logger.info('Successfully set CustomerIO push handler as high priority in AndroidManifest.xml');
29
- } else if (options.setHighPriorityPushHandler === false) {
30
- // Low priority - set fixed priority
31
- intentFilter.$ = {
32
- 'android:priority': DEFAULT_LOW_PRIORITY.toString()
33
- };
34
- logger.info(`Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
46
+ const intentFilter = existingService['intent-filter'][0];
47
+ if (intentFilter.$ && intentFilter.$['android:priority']) {
48
+ delete intentFilter.$['android:priority'];
49
+ logger.info('Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml');
35
50
  }
36
- application[0].service.push({
37
- '$': {
38
- 'android:name': customerIOMessagingpush,
39
- 'android:exported': 'false'
40
- },
41
- 'intent-filter': [intentFilter]
42
- });
43
- } else if (options.setHighPriorityPushHandler === true) {
44
- // Service exists, need to ensure it becomes high priority (remove priority attribute)
45
- const existingService = application[0].service[existingServiceIndex];
46
- if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
47
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
- const intentFilter = existingService['intent-filter'][0];
49
- if (intentFilter.$ && intentFilter.$['android:priority']) {
50
- delete intentFilter.$['android:priority'];
51
- logger.info('Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml');
52
- }
53
- }
54
- } else if (options.setHighPriorityPushHandler === false) {
55
- // Service exists, update to low priority
56
- const existingService = application[0].service[existingServiceIndex];
51
+ }
52
+ } else if (options.setHighPriorityPushHandler === false) {
53
+ // Service exists, update to low priority
54
+ const existingService = application[0].service[existingServiceIndex];
57
55
 
58
- // Update existing service intent-filter with fixed priority
59
- if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
- const intentFilter = existingService['intent-filter'][0];
62
- if (!intentFilter.$) {
63
- intentFilter.$ = {};
64
- }
65
- intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();
66
- logger.info(`Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
56
+ // Update existing service intent-filter with fixed priority
57
+ if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
58
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
+ const intentFilter = existingService['intent-filter'][0];
60
+ if (!intentFilter.$) {
61
+ intentFilter.$ = {};
67
62
  }
63
+ intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();
64
+ logger.info(`Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
68
65
  }
69
- props.modResults.manifest.application = application;
66
+ }
67
+ return application;
68
+ }
69
+ export const withAndroidManifestUpdates = (configOuter, options) => {
70
+ return withAndroidManifest(configOuter, props => {
71
+ const application = props.modResults.manifest.application;
72
+ props.modResults.manifest.application = modifyAndroidManifestApplication(application, options);
70
73
  return props;
71
74
  });
72
75
  };
@@ -1 +1 @@
1
- {"version":3,"names":["withAndroidManifest","logger","DEFAULT_LOW_PRIORITY","withAndroidManifestUpdates","configOuter","options","props","application","modResults","manifest","customerIOMessagingpush","service","existingServiceIndex","findIndex","$","intentFilter","action","setHighPriorityPushHandler","info","toString","push","existingService","length"],"sources":["withAndroidManifestUpdates.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { logger } from '../utils/logger';\n\n// Default low priority for Firebase messaging service when setHighPriorityPushHandler is false\nexport const DEFAULT_LOW_PRIORITY = -10;\n\n\nexport const withAndroidManifestUpdates: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, options) => {\n return withAndroidManifest(configOuter, (props) => {\n const application = props.modResults.manifest\n .application as ManifestApplication[];\n const customerIOMessagingpush =\n 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';\n\n if (!application[0].service) {\n application[0].service = [];\n }\n\n const existingServiceIndex = application[0].service.findIndex(\n (service) => service.$['android:name'] === customerIOMessagingpush\n );\n\n if (existingServiceIndex === -1) {\n // Intent filter structure for Firebase messaging service\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter: any = {\n action: [\n {\n $: {\n 'android:name': 'com.google.firebase.MESSAGING_EVENT',\n },\n },\n ],\n };\n\n // Handle priority based on setHighPriorityPushHandler value\n if (options.setHighPriorityPushHandler === true) {\n // High priority - no priority attribute means default high priority\n logger.info(\n 'Successfully set CustomerIO push handler as high priority in AndroidManifest.xml'\n );\n } else if (options.setHighPriorityPushHandler === false) {\n // Low priority - set fixed priority\n intentFilter.$ = {\n 'android:priority': DEFAULT_LOW_PRIORITY.toString(),\n };\n logger.info(\n `Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n\n application[0].service.push({\n '$': {\n 'android:name': customerIOMessagingpush,\n 'android:exported': 'false',\n },\n 'intent-filter': [intentFilter],\n });\n } else if (options.setHighPriorityPushHandler === true) {\n // Service exists, need to ensure it becomes high priority (remove priority attribute)\n const existingService = application[0].service[existingServiceIndex];\n\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (intentFilter.$ && intentFilter.$['android:priority']) {\n delete intentFilter.$['android:priority'];\n logger.info(\n 'Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml'\n );\n }\n }\n } else if (options.setHighPriorityPushHandler === false) {\n // Service exists, update to low priority\n const existingService = application[0].service[existingServiceIndex];\n\n // Update existing service intent-filter with fixed priority\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (!intentFilter.$) {\n intentFilter.$ = {};\n }\n intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();\n logger.info(\n `Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n }\n\n props.modResults.manifest.application = application;\n return props;\n });\n};\n"],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"names":["withAndroidManifest","logger","DEFAULT_LOW_PRIORITY","modifyAndroidManifestApplication","application","options","customerIOMessagingpush","service","existingServiceIndex","findIndex","$","intentFilter","action","setHighPriorityPushHandler","info","toString","push","existingService","length","withAndroidManifestUpdates","configOuter","props","modResults","manifest"],"sources":["withAndroidManifestUpdates.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { logger } from '../utils/logger';\n\n// Default low priority for Firebase messaging service when setHighPriorityPushHandler is false\nexport const DEFAULT_LOW_PRIORITY = -10;\n\n\nexport function modifyAndroidManifestApplication(\n application: ManifestApplication[],\n options: CustomerIOPluginOptionsAndroid\n): ManifestApplication[] {\n const customerIOMessagingpush =\n 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';\n\n if (!application[0].service) {\n application[0].service = [];\n }\n\n const existingServiceIndex = application[0].service.findIndex(\n (service) => service.$['android:name'] === customerIOMessagingpush\n );\n\n if (existingServiceIndex === -1) {\n // Intent filter structure for Firebase messaging service\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter: any = {\n action: [\n {\n $: {\n 'android:name': 'com.google.firebase.MESSAGING_EVENT',\n },\n },\n ],\n };\n\n // Handle priority based on setHighPriorityPushHandler value\n if (options.setHighPriorityPushHandler === true) {\n // High priority - no priority attribute means default high priority\n logger.info(\n 'Successfully set CustomerIO push handler as high priority in AndroidManifest.xml'\n );\n } else if (options.setHighPriorityPushHandler === false) {\n // Low priority - set fixed priority\n intentFilter.$ = {\n 'android:priority': DEFAULT_LOW_PRIORITY.toString(),\n };\n logger.info(\n `Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n\n application[0].service.push({\n '$': {\n 'android:name': customerIOMessagingpush,\n 'android:exported': 'false',\n },\n 'intent-filter': [intentFilter],\n });\n } else if (options.setHighPriorityPushHandler === true) {\n // Service exists, need to ensure it becomes high priority (remove priority attribute)\n const existingService = application[0].service[existingServiceIndex];\n\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (intentFilter.$ && intentFilter.$['android:priority']) {\n delete intentFilter.$['android:priority'];\n logger.info(\n 'Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml'\n );\n }\n }\n } else if (options.setHighPriorityPushHandler === false) {\n // Service exists, update to low priority\n const existingService = application[0].service[existingServiceIndex];\n\n // Update existing service intent-filter with fixed priority\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (!intentFilter.$) {\n intentFilter.$ = {};\n }\n intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();\n logger.info(\n `Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n }\n\n return application;\n}\n\nexport const withAndroidManifestUpdates: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, options) => {\n return withAndroidManifest(configOuter, (props) => {\n const application = props.modResults.manifest\n .application as ManifestApplication[];\n props.modResults.manifest.application = modifyAndroidManifestApplication(\n application,\n options\n );\n return props;\n });\n};\n"],"mappings":"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","ignoreList":[]}
@@ -1,15 +1,17 @@
1
1
  import { withAppBuildGradle } from '@expo/config-plugins';
2
2
  import { CIO_APP_APPLY_REGEX, CIO_APP_GOOGLE_SNIPPET } from '../helpers/constants/android';
3
3
  import { logger } from '../utils/logger';
4
+ export function modifyAppBuildGradle(contents) {
5
+ const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);
6
+ if (regex.test(contents)) {
7
+ logger.info('app/build.gradle snippet already exists. Skipping...');
8
+ return contents;
9
+ }
10
+ return contents.replace(CIO_APP_APPLY_REGEX, `$1\n${CIO_APP_GOOGLE_SNIPPET}`);
11
+ }
4
12
  export const withAppGoogleServices = configOuter => {
5
13
  return withAppBuildGradle(configOuter, props => {
6
- const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);
7
- const match = props.modResults.contents.match(regex);
8
- if (!match) {
9
- props.modResults.contents = props.modResults.contents.replace(CIO_APP_APPLY_REGEX, `$1\n${CIO_APP_GOOGLE_SNIPPET}`);
10
- } else {
11
- logger.info('app/build.gradle snippet already exists. Skipping...');
12
- }
14
+ props.modResults.contents = modifyAppBuildGradle(props.modResults.contents);
13
15
  return props;
14
16
  });
15
17
  };
@@ -1 +1 @@
1
- {"version":3,"names":["withAppBuildGradle","CIO_APP_APPLY_REGEX","CIO_APP_GOOGLE_SNIPPET","logger","withAppGoogleServices","configOuter","props","regex","RegExp","match","modResults","contents","replace","info"],"sources":["withAppGoogleServices.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAppBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_APP_APPLY_REGEX,\n CIO_APP_GOOGLE_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { logger } from '../utils/logger';\n\nexport const withAppGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withAppBuildGradle(configOuter, (props) => {\n const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);\n const match = props.modResults.contents.match(regex);\n if (!match) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_APP_APPLY_REGEX,\n `$1\\n${CIO_APP_GOOGLE_SNIPPET}`\n );\n } else {\n logger.info('app/build.gradle snippet already exists. Skipping...');\n }\n\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,kBAAkB,QAAQ,sBAAsB;AAEzD,SACEC,mBAAmB,EACnBC,sBAAsB,QACjB,8BAA8B;AAErC,SAASC,MAAM,QAAQ,iBAAiB;AAExC,OAAO,MAAMC,qBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOL,kBAAkB,CAACK,WAAW,EAAGC,KAAK,IAAK;IAChD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACN,sBAAsB,CAAC;IAChD,MAAMO,KAAK,GAAGH,KAAK,CAACI,UAAU,CAACC,QAAQ,CAACF,KAAK,CAACF,KAAK,CAAC;IACpD,IAAI,CAACE,KAAK,EAAE;MACVH,KAAK,CAACI,UAAU,CAACC,QAAQ,GAAGL,KAAK,CAACI,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DX,mBAAmB,EACnB,OAAOC,sBAAsB,EAC/B,CAAC;IACH,CAAC,MAAM;MACLC,MAAM,CAACU,IAAI,CAAC,sDAAsD,CAAC;IACrE;IAEA,OAAOP,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withAppBuildGradle","CIO_APP_APPLY_REGEX","CIO_APP_GOOGLE_SNIPPET","logger","modifyAppBuildGradle","contents","regex","RegExp","test","info","replace","withAppGoogleServices","configOuter","props","modResults"],"sources":["withAppGoogleServices.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAppBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_APP_APPLY_REGEX,\n CIO_APP_GOOGLE_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { logger } from '../utils/logger';\n\nexport function modifyAppBuildGradle(contents: string): string {\n const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);\n if (regex.test(contents)) {\n logger.info('app/build.gradle snippet already exists. Skipping...');\n return contents;\n }\n return contents.replace(\n CIO_APP_APPLY_REGEX,\n `$1\\n${CIO_APP_GOOGLE_SNIPPET}`\n );\n}\n\nexport const withAppGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withAppBuildGradle(configOuter, (props) => {\n props.modResults.contents = modifyAppBuildGradle(props.modResults.contents);\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,kBAAkB,QAAQ,sBAAsB;AAEzD,SACEC,mBAAmB,EACnBC,sBAAsB,QACjB,8BAA8B;AAErC,SAASC,MAAM,QAAQ,iBAAiB;AAExC,OAAO,SAASC,oBAAoBA,CAACC,QAAgB,EAAU;EAC7D,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACL,sBAAsB,CAAC;EAChD,IAAII,KAAK,CAACE,IAAI,CAACH,QAAQ,CAAC,EAAE;IACxBF,MAAM,CAACM,IAAI,CAAC,sDAAsD,CAAC;IACnE,OAAOJ,QAAQ;EACjB;EACA,OAAOA,QAAQ,CAACK,OAAO,CACrBT,mBAAmB,EACnB,OAAOC,sBAAsB,EAC/B,CAAC;AACH;AAEA,OAAO,MAAMS,qBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOZ,kBAAkB,CAACY,WAAW,EAAGC,KAAK,IAAK;IAChDA,KAAK,CAACC,UAAU,CAACT,QAAQ,GAAGD,oBAAoB,CAACS,KAAK,CAACC,UAAU,CAACT,QAAQ,CAAC;IAC3E,OAAOQ,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -1,29 +1,25 @@
1
1
  import { withProjectBuildGradle } from '@expo/config-plugins';
2
2
  import { logger } from '../utils/logger';
3
3
  import { FileManagement } from './../helpers/utils/fileManagement';
4
+ export function copyGoogleServicesFile(androidPath, googleServicesFile) {
5
+ const destination = `${androidPath}/app/google-services.json`;
6
+ if (FileManagement.exists(destination)) {
7
+ logger.info(`File already exists: ${destination}. Skipping...`);
8
+ return;
9
+ }
10
+ if (googleServicesFile && FileManagement.exists(googleServicesFile)) {
11
+ try {
12
+ FileManagement.copyFile(googleServicesFile, destination);
13
+ } catch {
14
+ logger.info(`There was an error copying your google-services.json file. You can copy it manually into ${destination}`);
15
+ }
16
+ } else {
17
+ logger.info(`The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${destination}`);
18
+ }
19
+ }
4
20
  export const withGoogleServicesJSON = (configOuter, cioProps) => {
5
21
  return withProjectBuildGradle(configOuter, props => {
6
- const options = {
7
- androidPath: props.modRequest.platformProjectRoot,
8
- googleServicesFile: cioProps === null || cioProps === void 0 ? void 0 : cioProps.googleServicesFile
9
- };
10
- const {
11
- androidPath,
12
- googleServicesFile
13
- } = options;
14
- if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {
15
- if (googleServicesFile && FileManagement.exists(googleServicesFile)) {
16
- try {
17
- FileManagement.copyFile(googleServicesFile, `${androidPath}/app/google-services.json`);
18
- } catch {
19
- logger.info(`There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`);
20
- }
21
- } else {
22
- logger.info(`The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${androidPath}/app/google-services.json`);
23
- }
24
- } else {
25
- logger.info(`File already exists: ${androidPath}/app/google-services.json. Skipping...`);
26
- }
22
+ copyGoogleServicesFile(props.modRequest.platformProjectRoot, cioProps === null || cioProps === void 0 ? void 0 : cioProps.googleServicesFile);
27
23
  return props;
28
24
  });
29
25
  };
@@ -1 +1 @@
1
- {"version":3,"names":["withProjectBuildGradle","logger","FileManagement","withGoogleServicesJSON","configOuter","cioProps","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFile","exists","copyFile","info"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withProjectBuildGradle } from '@expo/config-plugins';\n\nimport { logger } from '../utils/logger';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGoogleServicesJSON: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, cioProps) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const options: CustomerIOPluginOptionsAndroid = {\n androidPath: props.modRequest.platformProjectRoot,\n googleServicesFile: cioProps?.googleServicesFile,\n };\n const { androidPath, googleServicesFile } = options;\n if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${androidPath}/app/google-services.json`\n );\n } catch {\n logger.info(\n `There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n logger.info(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n logger.info(\n `File already exists: ${androidPath}/app/google-services.json. Skipping...`\n );\n }\n\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,sBAAsB;AAE7D,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,cAAc,QAAQ,mCAAmC;AAGlE,OAAO,MAAMC,sBAEZ,GAAGA,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAOL,sBAAsB,CAACI,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,kBAAkB,EAAEN,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEM;IAChC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAmB,CAAC,GAAGJ,OAAO;IACnD,IAAI,CAACL,cAAc,CAACU,MAAM,CAAC,GAAGJ,WAAW,2BAA2B,CAAC,EAAE;MACrE,IAAIG,kBAAkB,IAAIT,cAAc,CAACU,MAAM,CAACD,kBAAkB,CAAC,EAAE;QACnE,IAAI;UACFT,cAAc,CAACW,QAAQ,CACrBF,kBAAkB,EAClB,GAAGH,WAAW,2BAChB,CAAC;QACH,CAAC,CAAC,MAAM;UACNP,MAAM,CAACa,IAAI,CACT,4FAA4FN,WAAW,2BACzG,CAAC;QACH;MACF,CAAC,MAAM;QACLP,MAAM,CAACa,IAAI,CACT,wCAAwCH,kBAAkB,yDAAyDH,WAAW,2BAChI,CAAC;MACH;IACF,CAAC,MAAM;MACLP,MAAM,CAACa,IAAI,CACT,wBAAwBN,WAAW,wCACrC,CAAC;IACH;IAEA,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withProjectBuildGradle","logger","FileManagement","copyGoogleServicesFile","androidPath","googleServicesFile","destination","exists","info","copyFile","withGoogleServicesJSON","configOuter","cioProps","props","modRequest","platformProjectRoot"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withProjectBuildGradle } from '@expo/config-plugins';\n\nimport { logger } from '../utils/logger';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport function copyGoogleServicesFile(\n androidPath: string,\n googleServicesFile: string | undefined\n): void {\n const destination = `${androidPath}/app/google-services.json`;\n\n if (FileManagement.exists(destination)) {\n logger.info(`File already exists: ${destination}. Skipping...`);\n return;\n }\n\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n try {\n FileManagement.copyFile(googleServicesFile, destination);\n } catch {\n logger.info(\n `There was an error copying your google-services.json file. You can copy it manually into ${destination}`\n );\n }\n } else {\n logger.info(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${destination}`\n );\n }\n}\n\nexport const withGoogleServicesJSON: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, cioProps) => {\n return withProjectBuildGradle(configOuter, (props) => {\n copyGoogleServicesFile(\n props.modRequest.platformProjectRoot,\n cioProps?.googleServicesFile\n );\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,sBAAsB;AAE7D,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,cAAc,QAAQ,mCAAmC;AAGlE,OAAO,SAASC,sBAAsBA,CACpCC,WAAmB,EACnBC,kBAAsC,EAChC;EACN,MAAMC,WAAW,GAAG,GAAGF,WAAW,2BAA2B;EAE7D,IAAIF,cAAc,CAACK,MAAM,CAACD,WAAW,CAAC,EAAE;IACtCL,MAAM,CAACO,IAAI,CAAC,wBAAwBF,WAAW,eAAe,CAAC;IAC/D;EACF;EAEA,IAAID,kBAAkB,IAAIH,cAAc,CAACK,MAAM,CAACF,kBAAkB,CAAC,EAAE;IACnE,IAAI;MACFH,cAAc,CAACO,QAAQ,CAACJ,kBAAkB,EAAEC,WAAW,CAAC;IAC1D,CAAC,CAAC,MAAM;MACNL,MAAM,CAACO,IAAI,CACT,4FAA4FF,WAAW,EACzG,CAAC;IACH;EACF,CAAC,MAAM;IACLL,MAAM,CAACO,IAAI,CACT,wCAAwCH,kBAAkB,yDAAyDC,WAAW,EAChI,CAAC;EACH;AACF;AAEA,OAAO,MAAMI,sBAEZ,GAAGA,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAOZ,sBAAsB,CAACW,WAAW,EAAGE,KAAK,IAAK;IACpDV,sBAAsB,CACpBU,KAAK,CAACC,UAAU,CAACC,mBAAmB,EACpCH,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEP,kBACZ,CAAC;IACD,OAAOQ,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -1,5 +1,19 @@
1
1
  import { withGradleProperties } from '@expo/config-plugins';
2
2
  const CUSTOMERIO_LOCATION_ENABLED_KEY = 'customerio_location_enabled';
3
+ export function modifyGradleProperties(items) {
4
+ const existingIndex = items.findIndex(item => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY);
5
+ const newItem = {
6
+ type: 'property',
7
+ key: CUSTOMERIO_LOCATION_ENABLED_KEY,
8
+ value: 'true'
9
+ };
10
+ if (existingIndex >= 0) {
11
+ items[existingIndex] = newItem;
12
+ } else {
13
+ items.push(newItem);
14
+ }
15
+ return items;
16
+ }
3
17
 
4
18
  /**
5
19
  * Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.
@@ -12,18 +26,7 @@ export const withLocationGradleProperties = (config, props) => {
12
26
  }
13
27
  return withGradleProperties(config, config => {
14
28
  const items = config.modResults;
15
- const existingIndex = items.findIndex(item => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY);
16
- const newItem = {
17
- type: 'property',
18
- key: CUSTOMERIO_LOCATION_ENABLED_KEY,
19
- value: 'true'
20
- };
21
- if (existingIndex >= 0) {
22
- items[existingIndex] = newItem;
23
- } else {
24
- items.push(newItem);
25
- }
26
- config.modResults = items;
29
+ config.modResults = modifyGradleProperties(items);
27
30
  return config;
28
31
  });
29
32
  };
@@ -1 +1 @@
1
- {"version":3,"names":["withGradleProperties","CUSTOMERIO_LOCATION_ENABLED_KEY","withLocationGradleProperties","config","props","_props$location","location","enabled","items","modResults","existingIndex","findIndex","item","type","key","newItem","value","push"],"sources":["withLocationGradleProperties.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withGradleProperties } from '@expo/config-plugins';\nimport type { PropertiesItem } from '@expo/config-plugins/build/android/Properties';\n\nimport type { CustomerIOPluginLocationOptions } from '../types/cio-types';\n\nconst CUSTOMERIO_LOCATION_ENABLED_KEY = 'customerio_location_enabled';\n\n/**\n * Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.\n * The Customer.io React Native SDK reads this to enable the location native module.\n */\nexport const withLocationGradleProperties: ConfigPlugin<{\n location?: CustomerIOPluginLocationOptions;\n}> = (config, props) => {\n if (props?.location?.enabled !== true) {\n return config;\n }\n\n return withGradleProperties(config, (config) => {\n const items = config.modResults as PropertiesItem[];\n const existingIndex = items.findIndex(\n (item) => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY\n );\n\n const newItem: PropertiesItem = {\n type: 'property',\n key: CUSTOMERIO_LOCATION_ENABLED_KEY,\n value: 'true',\n };\n\n if (existingIndex >= 0) {\n items[existingIndex] = newItem;\n } else {\n items.push(newItem);\n }\n\n config.modResults = items;\n return config;\n });\n};\n"],"mappings":"AACA,SAASA,oBAAoB,QAAQ,sBAAsB;AAK3D,MAAMC,+BAA+B,GAAG,6BAA6B;;AAErE;AACA;AACA;AACA;AACA,OAAO,MAAMC,4BAEX,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EAAA,IAAAC,eAAA;EACtB,IAAI,CAAAD,KAAK,aAALA,KAAK,gBAAAC,eAAA,GAALD,KAAK,CAAEE,QAAQ,cAAAD,eAAA,uBAAfA,eAAA,CAAiBE,OAAO,MAAK,IAAI,EAAE;IACrC,OAAOJ,MAAM;EACf;EAEA,OAAOH,oBAAoB,CAACG,MAAM,EAAGA,MAAM,IAAK;IAC9C,MAAMK,KAAK,GAAGL,MAAM,CAACM,UAA8B;IACnD,MAAMC,aAAa,GAAGF,KAAK,CAACG,SAAS,CAClCC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,UAAU,IAAID,IAAI,CAACE,GAAG,KAAKb,+BACrD,CAAC;IAED,MAAMc,OAAuB,GAAG;MAC9BF,IAAI,EAAE,UAAU;MAChBC,GAAG,EAAEb,+BAA+B;MACpCe,KAAK,EAAE;IACT,CAAC;IAED,IAAIN,aAAa,IAAI,CAAC,EAAE;MACtBF,KAAK,CAACE,aAAa,CAAC,GAAGK,OAAO;IAChC,CAAC,MAAM;MACLP,KAAK,CAACS,IAAI,CAACF,OAAO,CAAC;IACrB;IAEAZ,MAAM,CAACM,UAAU,GAAGD,KAAK;IACzB,OAAOL,MAAM;EACf,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withGradleProperties","CUSTOMERIO_LOCATION_ENABLED_KEY","modifyGradleProperties","items","existingIndex","findIndex","item","type","key","newItem","value","push","withLocationGradleProperties","config","props","_props$location","location","enabled","modResults"],"sources":["withLocationGradleProperties.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withGradleProperties } from '@expo/config-plugins';\nimport type { PropertiesItem } from '@expo/config-plugins/build/android/Properties';\n\nimport type { CustomerIOPluginLocationOptions } from '../types/cio-types';\n\nconst CUSTOMERIO_LOCATION_ENABLED_KEY = 'customerio_location_enabled';\n\nexport function modifyGradleProperties(\n items: PropertiesItem[]\n): PropertiesItem[] {\n const existingIndex = items.findIndex(\n (item) => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY\n );\n\n const newItem: PropertiesItem = {\n type: 'property',\n key: CUSTOMERIO_LOCATION_ENABLED_KEY,\n value: 'true',\n };\n\n if (existingIndex >= 0) {\n items[existingIndex] = newItem;\n } else {\n items.push(newItem);\n }\n\n return items;\n}\n\n/**\n * Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.\n * The Customer.io React Native SDK reads this to enable the location native module.\n */\nexport const withLocationGradleProperties: ConfigPlugin<{\n location?: CustomerIOPluginLocationOptions;\n}> = (config, props) => {\n if (props?.location?.enabled !== true) {\n return config;\n }\n\n return withGradleProperties(config, (config) => {\n const items = config.modResults as PropertiesItem[];\n config.modResults = modifyGradleProperties(items);\n return config;\n });\n};\n"],"mappings":"AACA,SAASA,oBAAoB,QAAQ,sBAAsB;AAK3D,MAAMC,+BAA+B,GAAG,6BAA6B;AAErE,OAAO,SAASC,sBAAsBA,CACpCC,KAAuB,EACL;EAClB,MAAMC,aAAa,GAAGD,KAAK,CAACE,SAAS,CAClCC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,UAAU,IAAID,IAAI,CAACE,GAAG,KAAKP,+BACrD,CAAC;EAED,MAAMQ,OAAuB,GAAG;IAC9BF,IAAI,EAAE,UAAU;IAChBC,GAAG,EAAEP,+BAA+B;IACpCS,KAAK,EAAE;EACT,CAAC;EAED,IAAIN,aAAa,IAAI,CAAC,EAAE;IACtBD,KAAK,CAACC,aAAa,CAAC,GAAGK,OAAO;EAChC,CAAC,MAAM;IACLN,KAAK,CAACQ,IAAI,CAACF,OAAO,CAAC;EACrB;EAEA,OAAON,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMS,4BAEX,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EAAA,IAAAC,eAAA;EACtB,IAAI,CAAAD,KAAK,aAALA,KAAK,gBAAAC,eAAA,GAALD,KAAK,CAAEE,QAAQ,cAAAD,eAAA,uBAAfA,eAAA,CAAiBE,OAAO,MAAK,IAAI,EAAE;IACrC,OAAOJ,MAAM;EACf;EAEA,OAAOb,oBAAoB,CAACa,MAAM,EAAGA,MAAM,IAAK;IAC9C,MAAMV,KAAK,GAAGU,MAAM,CAACK,UAA8B;IACnDL,MAAM,CAACK,UAAU,GAAGhB,sBAAsB,CAACC,KAAK,CAAC;IACjD,OAAOU,MAAM;EACf,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -26,30 +26,36 @@ const getLocationInitOptions = (location, sdkConfig) => {
26
26
  trackingMode: sdkConfig === null || sdkConfig === void 0 || (_sdkConfig$location = sdkConfig.location) === null || _sdkConfig$location === void 0 ? void 0 : _sdkConfig$location.trackingMode
27
27
  };
28
28
  };
29
+ const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';
30
+ const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';
31
+ const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;
32
+ const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;
33
+
34
+ /**
35
+ * Pure string transform: given the existing MainApplication contents, returns the contents
36
+ * with the CustomerIOSDKInitializer import and onCreate call injected (idempotent — if the
37
+ * initialize call is already present, the call-injection step is skipped).
38
+ */
39
+ export function injectCustomerIOInitializerIntoMainApplication(contents) {
40
+ let next = addImportToFile(contents, SDK_INITIALIZER_IMPORT);
41
+ if (!next.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {
42
+ next = addCodeToMethod(next, CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);
43
+ }
44
+ return next;
45
+ }
29
46
 
30
47
  /**
31
48
  * Setup CustomerIOSDKInitializer for Android auto initialization
32
49
  */
33
50
  const setupCustomerIOSDKInitializer = (config, sdkConfig, location) => {
34
- const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';
35
- const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';
36
- const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;
37
- const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;
38
51
  const locationOptions = getLocationInitOptions(location, sdkConfig);
39
- let content = config.modResults.contents;
40
52
  try {
41
53
  // Always regenerate the CustomerIOSDKInitializer file to reflect config changes
42
54
  copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, content => patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig, locationOptions));
43
- // Add import if not already present
44
- content = addImportToFile(content, SDK_INITIALIZER_IMPORT);
45
- // Add initialization code to onCreate if not already present
46
- if (!content.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {
47
- content = addCodeToMethod(content, CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);
48
- }
55
+ return injectCustomerIOInitializerIntoMainApplication(config.modResults.contents);
49
56
  } catch (error) {
50
57
  logger.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);
51
58
  return config.modResults.contents;
52
59
  }
53
- return content;
54
60
  };
55
61
  //# sourceMappingURL=withMainApplicationModifications.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["withMainApplication","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","PLATFORM","patchNativeSDKInitializer","addCodeToMethod","addImportToFile","copyTemplateFile","logger","withMainApplicationModifications","configOuter","sdkConfig","location","config","content","setupCustomerIOSDKInitializer","modResults","contents","getLocationInitOptions","_sdkConfig$location","enabled","trackingMode","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","locationOptions","ANDROID","includes","error","warn"],"sources":["withMainApplicationModifications.ts"],"sourcesContent":["import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins';\nimport { withMainApplication } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';\nimport { PLATFORM } from '../helpers/constants/common';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type {\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';\nimport { logger } from '../utils/logger';\n\ntype MainApplicationModParams = {\n sdkConfig: NativeSDKConfig;\n location?: CustomerIOPluginLocationOptions;\n};\n\nexport const withMainApplicationModifications: ConfigPlugin<MainApplicationModParams> = (configOuter, { sdkConfig, location }) => {\n return withMainApplication(configOuter, async (config) => {\n const content = setupCustomerIOSDKInitializer(config, sdkConfig, location);\n config.modResults.contents = content;\n return config;\n });\n};\n\n/**\n * Build location options for native initializer from plugin config.\n * trackingMode comes from config.location.trackingMode (only used when location.enabled is true).\n */\nconst getLocationInitOptions = (\n location?: CustomerIOPluginLocationOptions,\n sdkConfig?: NativeSDKConfig\n) => ({\n enabled: location?.enabled === true,\n trackingMode: sdkConfig?.location?.trackingMode,\n});\n\n/**\n * Setup CustomerIOSDKInitializer for Android auto initialization\n */\nconst setupCustomerIOSDKInitializer = (\n config: ExportedConfigWithProps<ApplicationProjectFile>,\n sdkConfig: NativeSDKConfig,\n location?: CustomerIOPluginLocationOptions,\n): string => {\n const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';\n const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';\n\n const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;\n const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;\n\n const locationOptions = getLocationInitOptions(location, sdkConfig);\n let content = config.modResults.contents;\n\n try {\n // Always regenerate the CustomerIOSDKInitializer file to reflect config changes\n copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, (content) =>\n patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig, locationOptions)\n );\n // Add import if not already present\n content = addImportToFile(content, SDK_INITIALIZER_IMPORT);\n // Add initialization code to onCreate if not already present\n if (!content.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n content = addCodeToMethod(content, CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);\n }\n } catch (error) {\n logger.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);\n return config.modResults.contents;\n }\n\n return content;\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAE1D,SAASC,kCAAkC,EAAEC,8BAA8B,EAAEC,iCAAiC,QAAQ,8BAA8B;AACpJ,SAASC,QAAQ,QAAQ,6BAA6B;AACtD,SAASC,yBAAyB,QAAQ,wCAAwC;AAKlF,SAASC,eAAe,EAAEC,eAAe,EAAEC,gBAAgB,QAAQ,kBAAkB;AACrF,SAASC,MAAM,QAAQ,iBAAiB;AAOxC,OAAO,MAAMC,gCAAwE,GAAGA,CAACC,WAAW,EAAE;EAAEC,SAAS;EAAEC;AAAS,CAAC,KAAK;EAChI,OAAOb,mBAAmB,CAACW,WAAW,EAAE,MAAOG,MAAM,IAAK;IACxD,MAAMC,OAAO,GAAGC,6BAA6B,CAACF,MAAM,EAAEF,SAAS,EAAEC,QAAQ,CAAC;IAC1EC,MAAM,CAACG,UAAU,CAACC,QAAQ,GAAGH,OAAO;IACpC,OAAOD,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMK,sBAAsB,GAAGA,CAC7BN,QAA0C,EAC1CD,SAA2B;EAAA,IAAAQ,mBAAA;EAAA,OACvB;IACJC,OAAO,EAAE,CAAAR,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEQ,OAAO,MAAK,IAAI;IACnCC,YAAY,EAAEV,SAAS,aAATA,SAAS,gBAAAQ,mBAAA,GAATR,SAAS,CAAEC,QAAQ,cAAAO,mBAAA,uBAAnBA,mBAAA,CAAqBE;EACrC,CAAC;AAAA,CAAC;;AAEF;AACA;AACA;AACA,MAAMN,6BAA6B,GAAGA,CACpCF,MAAuD,EACvDF,SAA0B,EAC1BC,QAA0C,KAC/B;EACX,MAAMU,qBAAqB,GAAG,0BAA0B;EACxD,MAAMC,uBAAuB,GAAG,sBAAsB;EAEtD,MAAMC,oBAAoB,GAAG,GAAGF,qBAAqB,KAAK;EAC1D,MAAMG,sBAAsB,GAAG,UAAUF,uBAAuB,IAAID,qBAAqB,EAAE;EAE3F,MAAMI,eAAe,GAAGR,sBAAsB,CAACN,QAAQ,EAAED,SAAS,CAAC;EACnE,IAAIG,OAAO,GAAGD,MAAM,CAACG,UAAU,CAACC,QAAQ;EAExC,IAAI;IACF;IACAV,gBAAgB,CAACM,MAAM,EAAEW,oBAAoB,EAAED,uBAAuB,EAAGT,OAAO,IAC9EV,yBAAyB,CAACU,OAAO,EAAEX,QAAQ,CAACwB,OAAO,EAAEhB,SAAS,EAAEe,eAAe,CACjF,CAAC;IACD;IACAZ,OAAO,GAAGR,eAAe,CAACQ,OAAO,EAAEW,sBAAsB,CAAC;IAC1D;IACA,IAAI,CAACX,OAAO,CAACc,QAAQ,CAAC3B,8BAA8B,CAAC,EAAE;MACrDa,OAAO,GAAGT,eAAe,CAACS,OAAO,EAAEd,kCAAkC,EAAEE,iCAAiC,CAAC;IAC3G;EACF,CAAC,CAAC,OAAO2B,KAAK,EAAE;IACdrB,MAAM,CAACsB,IAAI,CAAC,mBAAmBR,qBAAqB,GAAG,EAAEO,KAAK,CAAC;IAC/D,OAAOhB,MAAM,CAACG,UAAU,CAACC,QAAQ;EACnC;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withMainApplication","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","PLATFORM","patchNativeSDKInitializer","addCodeToMethod","addImportToFile","copyTemplateFile","logger","withMainApplicationModifications","configOuter","sdkConfig","location","config","content","setupCustomerIOSDKInitializer","modResults","contents","getLocationInitOptions","_sdkConfig$location","enabled","trackingMode","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","injectCustomerIOInitializerIntoMainApplication","next","includes","locationOptions","ANDROID","error","warn"],"sources":["withMainApplicationModifications.ts"],"sourcesContent":["import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins';\nimport { withMainApplication } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';\nimport { PLATFORM } from '../helpers/constants/common';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type {\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';\nimport { logger } from '../utils/logger';\n\ntype MainApplicationModParams = {\n sdkConfig: NativeSDKConfig;\n location?: CustomerIOPluginLocationOptions;\n};\n\nexport const withMainApplicationModifications: ConfigPlugin<MainApplicationModParams> = (configOuter, { sdkConfig, location }) => {\n return withMainApplication(configOuter, async (config) => {\n const content = setupCustomerIOSDKInitializer(config, sdkConfig, location);\n config.modResults.contents = content;\n return config;\n });\n};\n\n/**\n * Build location options for native initializer from plugin config.\n * trackingMode comes from config.location.trackingMode (only used when location.enabled is true).\n */\nconst getLocationInitOptions = (\n location?: CustomerIOPluginLocationOptions,\n sdkConfig?: NativeSDKConfig\n) => ({\n enabled: location?.enabled === true,\n trackingMode: sdkConfig?.location?.trackingMode,\n});\n\nconst SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';\nconst SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';\nconst SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;\nconst SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;\n\n/**\n * Pure string transform: given the existing MainApplication contents, returns the contents\n * with the CustomerIOSDKInitializer import and onCreate call injected (idempotent — if the\n * initialize call is already present, the call-injection step is skipped).\n */\nexport function injectCustomerIOInitializerIntoMainApplication(\n contents: string\n): string {\n let next = addImportToFile(contents, SDK_INITIALIZER_IMPORT);\n if (!next.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n next = addCodeToMethod(\n next,\n CIO_MAINAPPLICATION_ONCREATE_REGEX,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET\n );\n }\n return next;\n}\n\n/**\n * Setup CustomerIOSDKInitializer for Android auto initialization\n */\nconst setupCustomerIOSDKInitializer = (\n config: ExportedConfigWithProps<ApplicationProjectFile>,\n sdkConfig: NativeSDKConfig,\n location?: CustomerIOPluginLocationOptions,\n): string => {\n const locationOptions = getLocationInitOptions(location, sdkConfig);\n\n try {\n // Always regenerate the CustomerIOSDKInitializer file to reflect config changes\n copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, (content) =>\n patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig, locationOptions)\n );\n return injectCustomerIOInitializerIntoMainApplication(config.modResults.contents);\n } catch (error) {\n logger.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);\n return config.modResults.contents;\n }\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAE1D,SAASC,kCAAkC,EAAEC,8BAA8B,EAAEC,iCAAiC,QAAQ,8BAA8B;AACpJ,SAASC,QAAQ,QAAQ,6BAA6B;AACtD,SAASC,yBAAyB,QAAQ,wCAAwC;AAKlF,SAASC,eAAe,EAAEC,eAAe,EAAEC,gBAAgB,QAAQ,kBAAkB;AACrF,SAASC,MAAM,QAAQ,iBAAiB;AAOxC,OAAO,MAAMC,gCAAwE,GAAGA,CAACC,WAAW,EAAE;EAAEC,SAAS;EAAEC;AAAS,CAAC,KAAK;EAChI,OAAOb,mBAAmB,CAACW,WAAW,EAAE,MAAOG,MAAM,IAAK;IACxD,MAAMC,OAAO,GAAGC,6BAA6B,CAACF,MAAM,EAAEF,SAAS,EAAEC,QAAQ,CAAC;IAC1EC,MAAM,CAACG,UAAU,CAACC,QAAQ,GAAGH,OAAO;IACpC,OAAOD,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMK,sBAAsB,GAAGA,CAC7BN,QAA0C,EAC1CD,SAA2B;EAAA,IAAAQ,mBAAA;EAAA,OACvB;IACJC,OAAO,EAAE,CAAAR,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEQ,OAAO,MAAK,IAAI;IACnCC,YAAY,EAAEV,SAAS,aAATA,SAAS,gBAAAQ,mBAAA,GAATR,SAAS,CAAEC,QAAQ,cAAAO,mBAAA,uBAAnBA,mBAAA,CAAqBE;EACrC,CAAC;AAAA,CAAC;AAEF,MAAMC,qBAAqB,GAAG,0BAA0B;AACxD,MAAMC,uBAAuB,GAAG,sBAAsB;AACtD,MAAMC,oBAAoB,GAAG,GAAGF,qBAAqB,KAAK;AAC1D,MAAMG,sBAAsB,GAAG,UAAUF,uBAAuB,IAAID,qBAAqB,EAAE;;AAE3F;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,8CAA8CA,CAC5DT,QAAgB,EACR;EACR,IAAIU,IAAI,GAAGrB,eAAe,CAACW,QAAQ,EAAEQ,sBAAsB,CAAC;EAC5D,IAAI,CAACE,IAAI,CAACC,QAAQ,CAAC3B,8BAA8B,CAAC,EAAE;IAClD0B,IAAI,GAAGtB,eAAe,CACpBsB,IAAI,EACJ3B,kCAAkC,EAClCE,iCACF,CAAC;EACH;EACA,OAAOyB,IAAI;AACb;;AAEA;AACA;AACA;AACA,MAAMZ,6BAA6B,GAAGA,CACpCF,MAAuD,EACvDF,SAA0B,EAC1BC,QAA0C,KAC/B;EACX,MAAMiB,eAAe,GAAGX,sBAAsB,CAACN,QAAQ,EAAED,SAAS,CAAC;EAEnE,IAAI;IACF;IACAJ,gBAAgB,CAACM,MAAM,EAAEW,oBAAoB,EAAED,uBAAuB,EAAGT,OAAO,IAC9EV,yBAAyB,CAACU,OAAO,EAAEX,QAAQ,CAAC2B,OAAO,EAAEnB,SAAS,EAAEkB,eAAe,CACjF,CAAC;IACD,OAAOH,8CAA8C,CAACb,MAAM,CAACG,UAAU,CAACC,QAAQ,CAAC;EACnF,CAAC,CAAC,OAAOc,KAAK,EAAE;IACdvB,MAAM,CAACwB,IAAI,CAAC,mBAAmBV,qBAAqB,GAAG,EAAES,KAAK,CAAC;IAC/D,OAAOlB,MAAM,CAACG,UAAU,CAACC,QAAQ;EACnC;AACF,CAAC","ignoreList":[]}
@@ -2,7 +2,7 @@ import { withAndroidManifest } from '@expo/config-plugins';
2
2
  /**
3
3
  * Adds a metadata entry to the Android manifest if it doesn't already exist
4
4
  */
5
- const addMetadataIfNotExists = (application, name, value) => {
5
+ export const addMetadataIfNotExists = (application, name, value) => {
6
6
  // Initialize meta-data array if it doesn't exist
7
7
  if (!application['meta-data']) {
8
8
  application['meta-data'] = [];
@@ -1 +1 @@
1
- {"version":3,"names":["withAndroidManifest","addMetadataIfNotExists","application","name","value","hasMetadata","some","metadata","$","push","withNotificationChannelMetadata","config","props","manifestProps","_props$pushNotificati","modResults","manifest","channel","pushNotification","id","importance","undefined","String"],"sources":["withNotificationChannelMetadata.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\n\n/**\n * Adds a metadata entry to the Android manifest if it doesn't already exist\n */\nconst addMetadataIfNotExists = (\n application: ManifestApplication,\n name: string,\n value: string\n): void => {\n // Initialize meta-data array if it doesn't exist\n if (!application['meta-data']) {\n application['meta-data'] = [];\n }\n\n // Check if metadata already exists\n const hasMetadata = application['meta-data'].some(\n (metadata) => metadata.$['android:name'] === name\n );\n\n // Add metadata if it doesn't exist\n if (!hasMetadata) {\n application['meta-data'].push({\n $: {\n 'android:name': name,\n 'android:value': value,\n },\n });\n }\n};\n\nexport const withNotificationChannelMetadata: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (config, props) => {\n return withAndroidManifest(config, (manifestProps) => {\n const application = manifestProps.modResults.manifest\n .application as ManifestApplication[];\n const channel = props.pushNotification?.channel;\n\n // Only proceed if channel configuration exists\n if (\n channel &&\n (channel.id || channel.name || channel.importance !== undefined)\n ) {\n if (channel.id) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_id',\n channel.id\n );\n }\n\n if (channel.name) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_name',\n channel.name\n );\n }\n\n if (channel.importance !== undefined) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_importance',\n String(channel.importance)\n );\n }\n }\n\n manifestProps.modResults.manifest.application = application;\n return manifestProps;\n });\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAK1D;AACA;AACA;AACA,MAAMC,sBAAsB,GAAGA,CAC7BC,WAAgC,EAChCC,IAAY,EACZC,KAAa,KACJ;EACT;EACA,IAAI,CAACF,WAAW,CAAC,WAAW,CAAC,EAAE;IAC7BA,WAAW,CAAC,WAAW,CAAC,GAAG,EAAE;EAC/B;;EAEA;EACA,MAAMG,WAAW,GAAGH,WAAW,CAAC,WAAW,CAAC,CAACI,IAAI,CAC9CC,QAAQ,IAAKA,QAAQ,CAACC,CAAC,CAAC,cAAc,CAAC,KAAKL,IAC/C,CAAC;;EAED;EACA,IAAI,CAACE,WAAW,EAAE;IAChBH,WAAW,CAAC,WAAW,CAAC,CAACO,IAAI,CAAC;MAC5BD,CAAC,EAAE;QACD,cAAc,EAAEL,IAAI;QACpB,eAAe,EAAEC;MACnB;IACF,CAAC,CAAC;EACJ;AACF,CAAC;AAED,OAAO,MAAMM,+BAEZ,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EACrB,OAAOZ,mBAAmB,CAACW,MAAM,EAAGE,aAAa,IAAK;IAAA,IAAAC,qBAAA;IACpD,MAAMZ,WAAW,GAAGW,aAAa,CAACE,UAAU,CAACC,QAAQ,CAClDd,WAAoC;IACvC,MAAMe,OAAO,IAAAH,qBAAA,GAAGF,KAAK,CAACM,gBAAgB,cAAAJ,qBAAA,uBAAtBA,qBAAA,CAAwBG,OAAO;;IAE/C;IACA,IACEA,OAAO,KACNA,OAAO,CAACE,EAAE,IAAIF,OAAO,CAACd,IAAI,IAAIc,OAAO,CAACG,UAAU,KAAKC,SAAS,CAAC,EAChE;MACA,IAAIJ,OAAO,CAACE,EAAE,EAAE;QACdlB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,qCAAqC,EACrCe,OAAO,CAACE,EACV,CAAC;MACH;MAEA,IAAIF,OAAO,CAACd,IAAI,EAAE;QAChBF,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,uCAAuC,EACvCe,OAAO,CAACd,IACV,CAAC;MACH;MAEA,IAAIc,OAAO,CAACG,UAAU,KAAKC,SAAS,EAAE;QACpCpB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,6CAA6C,EAC7CoB,MAAM,CAACL,OAAO,CAACG,UAAU,CAC3B,CAAC;MACH;IACF;IAEAP,aAAa,CAACE,UAAU,CAACC,QAAQ,CAACd,WAAW,GAAGA,WAAW;IAC3D,OAAOW,aAAa;EACtB,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withAndroidManifest","addMetadataIfNotExists","application","name","value","hasMetadata","some","metadata","$","push","withNotificationChannelMetadata","config","props","manifestProps","_props$pushNotificati","modResults","manifest","channel","pushNotification","id","importance","undefined","String"],"sources":["withNotificationChannelMetadata.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\n\n/**\n * Adds a metadata entry to the Android manifest if it doesn't already exist\n */\nexport const addMetadataIfNotExists = (\n application: ManifestApplication,\n name: string,\n value: string\n): void => {\n // Initialize meta-data array if it doesn't exist\n if (!application['meta-data']) {\n application['meta-data'] = [];\n }\n\n // Check if metadata already exists\n const hasMetadata = application['meta-data'].some(\n (metadata) => metadata.$['android:name'] === name\n );\n\n // Add metadata if it doesn't exist\n if (!hasMetadata) {\n application['meta-data'].push({\n $: {\n 'android:name': name,\n 'android:value': value,\n },\n });\n }\n};\n\nexport const withNotificationChannelMetadata: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (config, props) => {\n return withAndroidManifest(config, (manifestProps) => {\n const application = manifestProps.modResults.manifest\n .application as ManifestApplication[];\n const channel = props.pushNotification?.channel;\n\n // Only proceed if channel configuration exists\n if (\n channel &&\n (channel.id || channel.name || channel.importance !== undefined)\n ) {\n if (channel.id) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_id',\n channel.id\n );\n }\n\n if (channel.name) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_name',\n channel.name\n );\n }\n\n if (channel.importance !== undefined) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_importance',\n String(channel.importance)\n );\n }\n }\n\n manifestProps.modResults.manifest.application = application;\n return manifestProps;\n });\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAK1D;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGA,CACpCC,WAAgC,EAChCC,IAAY,EACZC,KAAa,KACJ;EACT;EACA,IAAI,CAACF,WAAW,CAAC,WAAW,CAAC,EAAE;IAC7BA,WAAW,CAAC,WAAW,CAAC,GAAG,EAAE;EAC/B;;EAEA;EACA,MAAMG,WAAW,GAAGH,WAAW,CAAC,WAAW,CAAC,CAACI,IAAI,CAC9CC,QAAQ,IAAKA,QAAQ,CAACC,CAAC,CAAC,cAAc,CAAC,KAAKL,IAC/C,CAAC;;EAED;EACA,IAAI,CAACE,WAAW,EAAE;IAChBH,WAAW,CAAC,WAAW,CAAC,CAACO,IAAI,CAAC;MAC5BD,CAAC,EAAE;QACD,cAAc,EAAEL,IAAI;QACpB,eAAe,EAAEC;MACnB;IACF,CAAC,CAAC;EACJ;AACF,CAAC;AAED,OAAO,MAAMM,+BAEZ,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EACrB,OAAOZ,mBAAmB,CAACW,MAAM,EAAGE,aAAa,IAAK;IAAA,IAAAC,qBAAA;IACpD,MAAMZ,WAAW,GAAGW,aAAa,CAACE,UAAU,CAACC,QAAQ,CAClDd,WAAoC;IACvC,MAAMe,OAAO,IAAAH,qBAAA,GAAGF,KAAK,CAACM,gBAAgB,cAAAJ,qBAAA,uBAAtBA,qBAAA,CAAwBG,OAAO;;IAE/C;IACA,IACEA,OAAO,KACNA,OAAO,CAACE,EAAE,IAAIF,OAAO,CAACd,IAAI,IAAIc,OAAO,CAACG,UAAU,KAAKC,SAAS,CAAC,EAChE;MACA,IAAIJ,OAAO,CAACE,EAAE,EAAE;QACdlB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,qCAAqC,EACrCe,OAAO,CAACE,EACV,CAAC;MACH;MAEA,IAAIF,OAAO,CAACd,IAAI,EAAE;QAChBF,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,uCAAuC,EACvCe,OAAO,CAACd,IACV,CAAC;MACH;MAEA,IAAIc,OAAO,CAACG,UAAU,KAAKC,SAAS,EAAE;QACpCpB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,6CAA6C,EAC7CoB,MAAM,CAACL,OAAO,CAACG,UAAU,CAC3B,CAAC;MACH;IACF;IAEAP,aAAa,CAACE,UAAU,CAACC,QAAQ,CAACd,WAAW,GAAGA,WAAW;IAC3D,OAAOW,aAAa;EACtB,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -17,6 +17,31 @@ function shouldDisableAndroid16Support(config, androidOptions) {
17
17
  return isExpoVersion53OrLower(config);
18
18
  }
19
19
 
20
+ /**
21
+ * Pure string transform: injects an androidx resolution-strategy block into the
22
+ * project-level build.gradle's `allprojects { ... }` section when
23
+ * `disableAndroid16Support` is true. Idempotent — returns input unchanged if the
24
+ * snippet is already present, or if the flag is false.
25
+ */
26
+ export function modifyProjectBuildGradleAndroid16Support(contents, options) {
27
+ if (!options.disableAndroid16Support) {
28
+ return contents;
29
+ }
30
+ if (contents.includes('androidx.core:core-ktx:1.13.1')) {
31
+ return contents;
32
+ }
33
+ const resolutionStrategy = `
34
+ configurations.all {
35
+ resolutionStrategy {
36
+ // Disable Android 16 support by forcing older androidx versions
37
+ // Compatible with API 35 and AGP 8.8.2 (prevents API 36/AGP 8.9.1+ requirement)
38
+ force 'androidx.core:core-ktx:1.13.1'
39
+ force 'androidx.lifecycle:lifecycle-process:2.8.7'
40
+ }
41
+ }`;
42
+ return contents.replace(/allprojects\s*\{/, `allprojects {${resolutionStrategy}`);
43
+ }
44
+
20
45
  /**
21
46
  * Adds dependency resolution strategy to force specific androidx versions.
22
47
  * This disables Android 16 support for apps using Expo SDK 53 or older gradle versions.
@@ -29,31 +54,9 @@ function shouldDisableAndroid16Support(config, androidOptions) {
29
54
  */
30
55
  export function withProjectBuildGradle(config, androidOptions) {
31
56
  return withExpoProjectBuildGradle(config, config => {
32
- const {
33
- modResults
34
- } = config;
35
-
36
- // Check if Android 16 support should be disabled
37
- if (!shouldDisableAndroid16Support(config, androidOptions)) {
38
- return config;
39
- }
40
-
41
- // Skip if already applied
42
- if (modResults.contents.includes('androidx.core:core-ktx:1.13.1')) {
43
- return config;
44
- }
45
- const resolutionStrategy = `
46
- configurations.all {
47
- resolutionStrategy {
48
- // Disable Android 16 support by forcing older androidx versions
49
- // Compatible with API 35 and AGP 8.8.2 (prevents API 36/AGP 8.9.1+ requirement)
50
- force 'androidx.core:core-ktx:1.13.1'
51
- force 'androidx.lifecycle:lifecycle-process:2.8.7'
52
- }
53
- }`;
54
-
55
- // Add resolution strategy inside allprojects block
56
- modResults.contents = modResults.contents.replace(/allprojects\s*\{/, `allprojects {${resolutionStrategy}`);
57
+ config.modResults.contents = modifyProjectBuildGradleAndroid16Support(config.modResults.contents, {
58
+ disableAndroid16Support: shouldDisableAndroid16Support(config, androidOptions)
59
+ });
57
60
  return config;
58
61
  });
59
62
  }
@@ -1 +1 @@
1
- {"version":3,"names":["withProjectBuildGradle","withExpoProjectBuildGradle","isExpoVersion53OrLower","shouldDisableAndroid16Support","config","androidOptions","disableAndroid16Support","undefined","modResults","contents","includes","resolutionStrategy","replace"],"sources":["withProjectBuildGradle.ts"],"sourcesContent":["import { withProjectBuildGradle as withExpoProjectBuildGradle } from '@expo/config-plugins';\nimport type { ExpoConfig } from '@expo/config-types';\nimport { isExpoVersion53OrLower } from '../ios/utils';\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\n\n/**\n * Determines if the androidx dependency fix should be applied based on config and Expo version.\n * The fix disables Android 16 support by downgrading androidx dependencies.\n * @param config The Expo config\n * @param androidOptions The Android plugin options\n * @returns true if the fix should be applied (Android 16 disabled)\n */\nfunction shouldDisableAndroid16Support(\n config: ExpoConfig,\n androidOptions?: CustomerIOPluginOptionsAndroid\n): boolean {\n // If user explicitly sets the option, respect their choice\n if (androidOptions?.disableAndroid16Support !== undefined) {\n return androidOptions.disableAndroid16Support;\n }\n\n // Auto-detect: Disable Android 16 for Expo SDK 53 or lower, enable for 54+\n return isExpoVersion53OrLower(config);\n}\n\n/**\n * Adds dependency resolution strategy to force specific androidx versions.\n * This disables Android 16 support for apps using Expo SDK 53 or older gradle versions.\n *\n * The fix prevents newer androidx versions that require Android API 36 and AGP 8.9.1+\n * from being pulled in. Expo SDK 53 uses Android API 35 and AGP 8.8.2, so we force\n * compatible versions.\n *\n * Expo SDK 54+ should support newer gradle versions and won't need this fix.\n */\nexport function withProjectBuildGradle(\n config: ExpoConfig,\n androidOptions?: CustomerIOPluginOptionsAndroid\n): ExpoConfig {\n return withExpoProjectBuildGradle(config, (config) => {\n const { modResults } = config;\n\n // Check if Android 16 support should be disabled\n if (!shouldDisableAndroid16Support(config, androidOptions)) {\n return config;\n }\n\n // Skip if already applied\n if (modResults.contents.includes('androidx.core:core-ktx:1.13.1')) {\n return config;\n }\n\n const resolutionStrategy = `\n configurations.all {\n resolutionStrategy {\n // Disable Android 16 support by forcing older androidx versions\n // Compatible with API 35 and AGP 8.8.2 (prevents API 36/AGP 8.9.1+ requirement)\n force 'androidx.core:core-ktx:1.13.1'\n force 'androidx.lifecycle:lifecycle-process:2.8.7'\n }\n }`;\n\n // Add resolution strategy inside allprojects block\n modResults.contents = modResults.contents.replace(\n /allprojects\\s*\\{/,\n `allprojects {${resolutionStrategy}`\n );\n\n return config;\n });\n}\n"],"mappings":"AAAA,SAASA,sBAAsB,IAAIC,0BAA0B,QAAQ,sBAAsB;AAE3F,SAASC,sBAAsB,QAAQ,cAAc;AAGrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,6BAA6BA,CACpCC,MAAkB,EAClBC,cAA+C,EACtC;EACT;EACA,IAAI,CAAAA,cAAc,aAAdA,cAAc,uBAAdA,cAAc,CAAEC,uBAAuB,MAAKC,SAAS,EAAE;IACzD,OAAOF,cAAc,CAACC,uBAAuB;EAC/C;;EAEA;EACA,OAAOJ,sBAAsB,CAACE,MAAM,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASJ,sBAAsBA,CACpCI,MAAkB,EAClBC,cAA+C,EACnC;EACZ,OAAOJ,0BAA0B,CAACG,MAAM,EAAGA,MAAM,IAAK;IACpD,MAAM;MAAEI;IAAW,CAAC,GAAGJ,MAAM;;IAE7B;IACA,IAAI,CAACD,6BAA6B,CAACC,MAAM,EAAEC,cAAc,CAAC,EAAE;MAC1D,OAAOD,MAAM;IACf;;IAEA;IACA,IAAII,UAAU,CAACC,QAAQ,CAACC,QAAQ,CAAC,+BAA+B,CAAC,EAAE;MACjE,OAAON,MAAM;IACf;IAEA,MAAMO,kBAAkB,GAAG;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;;IAEF;IACAH,UAAU,CAACC,QAAQ,GAAGD,UAAU,CAACC,QAAQ,CAACG,OAAO,CAC/C,kBAAkB,EAClB,gBAAgBD,kBAAkB,EACpC,CAAC;IAED,OAAOP,MAAM;EACf,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["withProjectBuildGradle","withExpoProjectBuildGradle","isExpoVersion53OrLower","shouldDisableAndroid16Support","config","androidOptions","disableAndroid16Support","undefined","modifyProjectBuildGradleAndroid16Support","contents","options","includes","resolutionStrategy","replace","modResults"],"sources":["withProjectBuildGradle.ts"],"sourcesContent":["import { withProjectBuildGradle as withExpoProjectBuildGradle } from '@expo/config-plugins';\nimport type { ExpoConfig } from '@expo/config-types';\nimport { isExpoVersion53OrLower } from '../ios/utils';\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\n\n/**\n * Determines if the androidx dependency fix should be applied based on config and Expo version.\n * The fix disables Android 16 support by downgrading androidx dependencies.\n * @param config The Expo config\n * @param androidOptions The Android plugin options\n * @returns true if the fix should be applied (Android 16 disabled)\n */\nfunction shouldDisableAndroid16Support(\n config: ExpoConfig,\n androidOptions?: CustomerIOPluginOptionsAndroid\n): boolean {\n // If user explicitly sets the option, respect their choice\n if (androidOptions?.disableAndroid16Support !== undefined) {\n return androidOptions.disableAndroid16Support;\n }\n\n // Auto-detect: Disable Android 16 for Expo SDK 53 or lower, enable for 54+\n return isExpoVersion53OrLower(config);\n}\n\n/**\n * Pure string transform: injects an androidx resolution-strategy block into the\n * project-level build.gradle's `allprojects { ... }` section when\n * `disableAndroid16Support` is true. Idempotent returns input unchanged if the\n * snippet is already present, or if the flag is false.\n */\nexport function modifyProjectBuildGradleAndroid16Support(\n contents: string,\n options: { disableAndroid16Support: boolean }\n): string {\n if (!options.disableAndroid16Support) {\n return contents;\n }\n\n if (contents.includes('androidx.core:core-ktx:1.13.1')) {\n return contents;\n }\n\n const resolutionStrategy = `\n configurations.all {\n resolutionStrategy {\n // Disable Android 16 support by forcing older androidx versions\n // Compatible with API 35 and AGP 8.8.2 (prevents API 36/AGP 8.9.1+ requirement)\n force 'androidx.core:core-ktx:1.13.1'\n force 'androidx.lifecycle:lifecycle-process:2.8.7'\n }\n }`;\n\n return contents.replace(\n /allprojects\\s*\\{/,\n `allprojects {${resolutionStrategy}`\n );\n}\n\n/**\n * Adds dependency resolution strategy to force specific androidx versions.\n * This disables Android 16 support for apps using Expo SDK 53 or older gradle versions.\n *\n * The fix prevents newer androidx versions that require Android API 36 and AGP 8.9.1+\n * from being pulled in. Expo SDK 53 uses Android API 35 and AGP 8.8.2, so we force\n * compatible versions.\n *\n * Expo SDK 54+ should support newer gradle versions and won't need this fix.\n */\nexport function withProjectBuildGradle(\n config: ExpoConfig,\n androidOptions?: CustomerIOPluginOptionsAndroid\n): ExpoConfig {\n return withExpoProjectBuildGradle(config, (config) => {\n config.modResults.contents = modifyProjectBuildGradleAndroid16Support(\n config.modResults.contents,\n { disableAndroid16Support: shouldDisableAndroid16Support(config, androidOptions) }\n );\n return config;\n });\n}\n"],"mappings":"AAAA,SAASA,sBAAsB,IAAIC,0BAA0B,QAAQ,sBAAsB;AAE3F,SAASC,sBAAsB,QAAQ,cAAc;AAGrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,6BAA6BA,CACpCC,MAAkB,EAClBC,cAA+C,EACtC;EACT;EACA,IAAI,CAAAA,cAAc,aAAdA,cAAc,uBAAdA,cAAc,CAAEC,uBAAuB,MAAKC,SAAS,EAAE;IACzD,OAAOF,cAAc,CAACC,uBAAuB;EAC/C;;EAEA;EACA,OAAOJ,sBAAsB,CAACE,MAAM,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,wCAAwCA,CACtDC,QAAgB,EAChBC,OAA6C,EACrC;EACR,IAAI,CAACA,OAAO,CAACJ,uBAAuB,EAAE;IACpC,OAAOG,QAAQ;EACjB;EAEA,IAAIA,QAAQ,CAACE,QAAQ,CAAC,+BAA+B,CAAC,EAAE;IACtD,OAAOF,QAAQ;EACjB;EAEA,MAAMG,kBAAkB,GAAG;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;EAEJ,OAAOH,QAAQ,CAACI,OAAO,CACrB,kBAAkB,EAClB,gBAAgBD,kBAAkB,EACpC,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASZ,sBAAsBA,CACpCI,MAAkB,EAClBC,cAA+C,EACnC;EACZ,OAAOJ,0BAA0B,CAACG,MAAM,EAAGA,MAAM,IAAK;IACpDA,MAAM,CAACU,UAAU,CAACL,QAAQ,GAAGD,wCAAwC,CACnEJ,MAAM,CAACU,UAAU,CAACL,QAAQ,EAC1B;MAAEH,uBAAuB,EAAEH,6BAA6B,CAACC,MAAM,EAAEC,cAAc;IAAE,CACnF,CAAC;IACD,OAAOD,MAAM;EACf,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -1,12 +1,15 @@
1
1
  import { withProjectBuildGradle } from '@expo/config-plugins';
2
2
  import { CIO_PROJECT_BUILDSCRIPTS_REGEX, CIO_PROJECT_GOOGLE_SNIPPET } from './../helpers/constants/android';
3
+ export function modifyProjectBuildGradleForGoogleServices(contents) {
4
+ const regex = new RegExp(CIO_PROJECT_GOOGLE_SNIPPET);
5
+ if (regex.test(contents)) {
6
+ return contents;
7
+ }
8
+ return contents.replace(CIO_PROJECT_BUILDSCRIPTS_REGEX, `$1\n${CIO_PROJECT_GOOGLE_SNIPPET}`);
9
+ }
3
10
  export const withProjectGoogleServices = configOuter => {
4
11
  return withProjectBuildGradle(configOuter, props => {
5
- const regex = new RegExp(CIO_PROJECT_GOOGLE_SNIPPET);
6
- const match = props.modResults.contents.match(regex);
7
- if (!match) {
8
- props.modResults.contents = props.modResults.contents.replace(CIO_PROJECT_BUILDSCRIPTS_REGEX, `$1\n${CIO_PROJECT_GOOGLE_SNIPPET}`);
9
- }
12
+ props.modResults.contents = modifyProjectBuildGradleForGoogleServices(props.modResults.contents);
10
13
  return props;
11
14
  });
12
15
  };
@@ -1 +1 @@
1
- {"version":3,"names":["withProjectBuildGradle","CIO_PROJECT_BUILDSCRIPTS_REGEX","CIO_PROJECT_GOOGLE_SNIPPET","withProjectGoogleServices","configOuter","props","regex","RegExp","match","modResults","contents","replace"],"sources":["withProjectGoogleServices.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withProjectBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n CIO_PROJECT_GOOGLE_SNIPPET,\n} from './../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withProjectGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const regex = new RegExp(CIO_PROJECT_GOOGLE_SNIPPET);\n const match = props.modResults.contents.match(regex);\n if (!match) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n `$1\\n${CIO_PROJECT_GOOGLE_SNIPPET}`\n );\n }\n\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,sBAAsB;AAE7D,SACEC,8BAA8B,EAC9BC,0BAA0B,QACrB,gCAAgC;AAGvC,OAAO,MAAMC,yBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOJ,sBAAsB,CAACI,WAAW,EAAGC,KAAK,IAAK;IACpD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACL,0BAA0B,CAAC;IACpD,MAAMM,KAAK,GAAGH,KAAK,CAACI,UAAU,CAACC,QAAQ,CAACF,KAAK,CAACF,KAAK,CAAC;IACpD,IAAI,CAACE,KAAK,EAAE;MACVH,KAAK,CAACI,UAAU,CAACC,QAAQ,GAAGL,KAAK,CAACI,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DV,8BAA8B,EAC9B,OAAOC,0BAA0B,EACnC,CAAC;IACH;IAEA,OAAOG,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withProjectBuildGradle","CIO_PROJECT_BUILDSCRIPTS_REGEX","CIO_PROJECT_GOOGLE_SNIPPET","modifyProjectBuildGradleForGoogleServices","contents","regex","RegExp","test","replace","withProjectGoogleServices","configOuter","props","modResults"],"sources":["withProjectGoogleServices.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withProjectBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n CIO_PROJECT_GOOGLE_SNIPPET,\n} from './../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport function modifyProjectBuildGradleForGoogleServices(contents: string): string {\n const regex = new RegExp(CIO_PROJECT_GOOGLE_SNIPPET);\n if (regex.test(contents)) {\n return contents;\n }\n return contents.replace(\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n `$1\\n${CIO_PROJECT_GOOGLE_SNIPPET}`\n );\n}\n\nexport const withProjectGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n props.modResults.contents = modifyProjectBuildGradleForGoogleServices(\n props.modResults.contents\n );\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,sBAAsB;AAE7D,SACEC,8BAA8B,EAC9BC,0BAA0B,QACrB,gCAAgC;AAGvC,OAAO,SAASC,yCAAyCA,CAACC,QAAgB,EAAU;EAClF,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACJ,0BAA0B,CAAC;EACpD,IAAIG,KAAK,CAACE,IAAI,CAACH,QAAQ,CAAC,EAAE;IACxB,OAAOA,QAAQ;EACjB;EACA,OAAOA,QAAQ,CAACI,OAAO,CACrBP,8BAA8B,EAC9B,OAAOC,0BAA0B,EACnC,CAAC;AACH;AAEA,OAAO,MAAMO,yBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOV,sBAAsB,CAACU,WAAW,EAAGC,KAAK,IAAK;IACpDA,KAAK,CAACC,UAAU,CAACR,QAAQ,GAAGD,yCAAyC,CACnEQ,KAAK,CAACC,UAAU,CAACR,QACnB,CAAC;IACD,OAAOO,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}