customerio-expo-plugin 2.5.0 → 2.6.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 (161) hide show
  1. package/package.json +13 -31
  2. package/plugin/app.plugin.js +1 -1
  3. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +4 -4
  4. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
  5. package/plugin/lib/commonjs/android/withCIOAndroid.js +6 -1
  6. package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -1
  7. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +1 -1
  8. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  9. package/plugin/lib/commonjs/android/withMainApplicationModifications.js +45 -0
  10. package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -0
  11. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js +1 -1
  12. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js.map +1 -1
  13. package/plugin/lib/commonjs/android/withProjectStrings.js +14 -7
  14. package/plugin/lib/commonjs/android/withProjectStrings.js.map +1 -1
  15. package/plugin/lib/commonjs/helpers/constants/android.js +7 -1
  16. package/plugin/lib/commonjs/helpers/constants/android.js.map +1 -1
  17. package/plugin/lib/commonjs/helpers/constants/common.js +18 -0
  18. package/plugin/lib/commonjs/helpers/constants/common.js.map +1 -0
  19. package/plugin/lib/commonjs/helpers/constants/ios.js +7 -7
  20. package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -1
  21. package/plugin/lib/commonjs/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
  22. package/plugin/lib/commonjs/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
  23. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +2 -2
  24. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  25. package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js +62 -0
  26. package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js.map +1 -0
  27. package/plugin/lib/commonjs/index.js +13 -2
  28. package/plugin/lib/commonjs/index.js.map +1 -1
  29. package/plugin/lib/commonjs/ios/utils.js +1 -1
  30. package/plugin/lib/commonjs/ios/utils.js.map +1 -1
  31. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +1 -1
  32. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
  33. package/plugin/lib/commonjs/ios/withCIOIos.js +17 -11
  34. package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
  35. package/plugin/lib/commonjs/ios/withCIOIosSwift.js +133 -49
  36. package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
  37. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +1 -1
  38. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
  39. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +17 -19
  40. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  41. package/plugin/lib/commonjs/ios/withXcodeProject.js +1 -1
  42. package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -1
  43. package/plugin/lib/commonjs/postInstallHelper.js.map +1 -1
  44. package/plugin/lib/commonjs/types/cio-types.js.map +1 -1
  45. package/plugin/lib/commonjs/utils/android.js +109 -0
  46. package/plugin/lib/commonjs/utils/android.js.map +1 -0
  47. package/plugin/lib/commonjs/utils/config.js +43 -0
  48. package/plugin/lib/commonjs/utils/config.js.map +1 -0
  49. package/plugin/lib/commonjs/utils/plugin.js +49 -0
  50. package/plugin/lib/commonjs/utils/plugin.js.map +1 -0
  51. package/plugin/lib/commonjs/utils/validation.js +44 -0
  52. package/plugin/lib/commonjs/utils/validation.js.map +1 -0
  53. package/plugin/lib/commonjs/utils/xcode.js +67 -0
  54. package/plugin/lib/commonjs/utils/xcode.js.map +1 -0
  55. package/plugin/lib/module/android/withAndroidManifestUpdates.js +4 -4
  56. package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
  57. package/plugin/lib/module/android/withCIOAndroid.js +6 -1
  58. package/plugin/lib/module/android/withCIOAndroid.js.map +1 -1
  59. package/plugin/lib/module/android/withGoogleServicesJSON.js +1 -1
  60. package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  61. package/plugin/lib/module/android/withMainApplicationModifications.js +38 -0
  62. package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -0
  63. package/plugin/lib/module/android/withNotificationChannelMetadata.js +1 -1
  64. package/plugin/lib/module/android/withNotificationChannelMetadata.js.map +1 -1
  65. package/plugin/lib/module/android/withProjectStrings.js +13 -6
  66. package/plugin/lib/module/android/withProjectStrings.js.map +1 -1
  67. package/plugin/lib/module/helpers/constants/android.js +6 -0
  68. package/plugin/lib/module/helpers/constants/android.js.map +1 -1
  69. package/plugin/lib/module/helpers/constants/common.js +12 -0
  70. package/plugin/lib/module/helpers/constants/common.js.map +1 -0
  71. package/plugin/lib/module/helpers/constants/ios.js +6 -6
  72. package/plugin/lib/module/helpers/constants/ios.js.map +1 -1
  73. package/plugin/lib/module/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
  74. package/plugin/lib/module/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
  75. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +2 -2
  76. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  77. package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js +57 -0
  78. package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js.map +1 -0
  79. package/plugin/lib/module/index.js +14 -2
  80. package/plugin/lib/module/index.js.map +1 -1
  81. package/plugin/lib/module/ios/utils.js +1 -2
  82. package/plugin/lib/module/ios/utils.js.map +1 -1
  83. package/plugin/lib/module/ios/withAppDelegateModifications.js +3 -3
  84. package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
  85. package/plugin/lib/module/ios/withCIOIos.js +17 -11
  86. package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
  87. package/plugin/lib/module/ios/withCIOIosSwift.js +134 -50
  88. package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
  89. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +2 -2
  90. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
  91. package/plugin/lib/module/ios/withNotificationsXcodeProject.js +18 -20
  92. package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  93. package/plugin/lib/module/ios/withXcodeProject.js +1 -1
  94. package/plugin/lib/module/ios/withXcodeProject.js.map +1 -1
  95. package/plugin/lib/module/postInstallHelper.js.map +1 -1
  96. package/plugin/lib/module/types/cio-types.js.map +1 -1
  97. package/plugin/lib/module/utils/android.js +100 -0
  98. package/plugin/lib/module/utils/android.js.map +1 -0
  99. package/plugin/lib/module/utils/config.js +38 -0
  100. package/plugin/lib/module/utils/config.js.map +1 -0
  101. package/plugin/lib/module/utils/plugin.js +38 -0
  102. package/plugin/lib/module/utils/plugin.js.map +1 -0
  103. package/plugin/lib/module/utils/validation.js +39 -0
  104. package/plugin/lib/module/utils/validation.js.map +1 -0
  105. package/plugin/lib/module/utils/xcode.js +60 -0
  106. package/plugin/lib/module/utils/xcode.js.map +1 -0
  107. package/plugin/lib/typescript/android/withCIOAndroid.d.ts +2 -2
  108. package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +3 -0
  109. package/plugin/lib/typescript/android/withProjectStrings.d.ts +2 -1
  110. package/plugin/lib/typescript/helpers/constants/android.d.ts +3 -0
  111. package/plugin/lib/typescript/helpers/constants/common.d.ts +11 -0
  112. package/plugin/lib/typescript/helpers/constants/ios.d.ts +3 -1
  113. package/plugin/lib/typescript/helpers/utils/patchPluginNativeCode.d.ts +7 -0
  114. package/plugin/lib/typescript/ios/utils.d.ts +2 -2
  115. package/plugin/lib/typescript/ios/withCIOIos.d.ts +2 -2
  116. package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +3 -3
  117. package/plugin/lib/typescript/types/cio-types.d.ts +46 -6
  118. package/plugin/lib/typescript/utils/android.d.ts +5 -0
  119. package/plugin/lib/typescript/utils/config.d.ts +8 -0
  120. package/plugin/lib/typescript/utils/plugin.d.ts +4 -0
  121. package/plugin/lib/typescript/utils/validation.d.ts +3 -0
  122. package/plugin/lib/typescript/utils/xcode.d.ts +28 -0
  123. package/plugin/src/android/withAndroidManifestUpdates.ts +5 -5
  124. package/plugin/src/android/withCIOAndroid.ts +7 -1
  125. package/plugin/src/android/withGoogleServicesJSON.ts +2 -2
  126. package/plugin/src/android/withMainApplicationModifications.ts +50 -0
  127. package/plugin/src/android/withNotificationChannelMetadata.ts +7 -3
  128. package/plugin/src/android/withProjectStrings.ts +20 -10
  129. package/plugin/src/helpers/constants/android.ts +7 -0
  130. package/plugin/src/helpers/constants/common.ts +12 -0
  131. package/plugin/src/helpers/constants/ios.ts +11 -13
  132. package/plugin/src/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
  133. package/plugin/src/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
  134. package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +8 -7
  135. package/plugin/src/helpers/utils/patchPluginNativeCode.ts +97 -0
  136. package/plugin/src/index.ts +18 -2
  137. package/plugin/src/ios/utils.ts +5 -5
  138. package/plugin/src/ios/withAppDelegateModifications.ts +11 -8
  139. package/plugin/src/ios/withCIOIos.ts +19 -11
  140. package/plugin/src/ios/withCIOIosSwift.ts +195 -73
  141. package/plugin/src/ios/withGoogleServicesJsonFile.ts +7 -10
  142. package/plugin/src/ios/withNotificationsXcodeProject.ts +25 -26
  143. package/plugin/src/ios/withXcodeProject.ts +1 -1
  144. package/plugin/src/postInstallHelper.js +1 -1
  145. package/plugin/src/types/cio-types.ts +48 -8
  146. package/plugin/src/utils/android.ts +112 -0
  147. package/plugin/src/utils/config.ts +53 -0
  148. package/plugin/src/utils/plugin.ts +46 -0
  149. package/plugin/src/utils/validation.ts +54 -0
  150. package/plugin/src/utils/xcode.ts +74 -0
  151. package/plugin/lib/commonjs/helpers/constants/globals.d.js +0 -2
  152. package/plugin/lib/commonjs/helpers/constants/globals.d.js.map +0 -1
  153. package/plugin/lib/commonjs/helpers/utils/pluginUtils.js +0 -26
  154. package/plugin/lib/commonjs/helpers/utils/pluginUtils.js.map +0 -1
  155. package/plugin/lib/module/helpers/constants/globals.d.js +0 -2
  156. package/plugin/lib/module/helpers/constants/globals.d.js.map +0 -1
  157. package/plugin/lib/module/helpers/utils/pluginUtils.js +0 -19
  158. package/plugin/lib/module/helpers/utils/pluginUtils.js.map +0 -1
  159. package/plugin/lib/typescript/helpers/utils/pluginUtils.d.ts +0 -4
  160. package/plugin/src/helpers/constants/globals.d.ts +0 -8
  161. package/plugin/src/helpers/utils/pluginUtils.ts +0 -22
@@ -0,0 +1 @@
1
+ {"version":3,"names":["path","FileManagement","getAndroidNativeFilesPath","addImportToFile","content","importStatement","includes","importRegex","imports","matchAll","length","packageRegex","packageMatch","match","insertPosition","index","substring","lastImport","findMatchingBracketPosition","bracket","startPos","openBracket","closeBracket","depth","foundOpen","i","char","addCodeToMethod","methodRegex","codeToAdd","methodMatch","undefined","methodStart","methodContent","openBraceIndex","indexOf","absoluteOpenBracePos","closeBracePos","linesUpToOpenBrace","split","braceLine","methodIndentMatch","methodIndent","indentLevel","afterBrace","afterBraceLines","filter","l","trim","nextLineIndentMatch","slice","finalIndent","copyTemplateFile","expoConfig","filename","classPackage","patchContent","projectRoot","modRequest","mainSourceDir","join","packagePath","replace","mkdir","recursive","sourcePath","readFile","destinationPath","writeFile","error","console","warn"],"sources":["android.ts"],"sourcesContent":["import type { ExportedConfigWithProps } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport path from 'path';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport { getAndroidNativeFilesPath } from './plugin';\n\n// Generic utility to add import to Kotlin files\nexport const addImportToFile = (content: string, importStatement: string): string => {\n if (content.includes(importStatement)) {\n return content;\n }\n\n const importRegex = /^import\\s+[^\\s\\n]+.*$/gm;\n const imports = [...content.matchAll(importRegex)];\n\n if (imports.length === 0) {\n const packageRegex = /package\\s+[^\\s;]+[;\\s]*\\n/;\n const packageMatch = content.match(packageRegex);\n if (!packageMatch) return content;\n\n const insertPosition = (packageMatch.index ?? 0) + packageMatch[0].length;\n return content.substring(0, insertPosition) + `\\n${importStatement}\\n` + content.substring(insertPosition);\n }\n\n const lastImport = imports[imports.length - 1];\n const insertPosition = (lastImport.index ?? 0) + lastImport[0].length;\n return content.substring(0, insertPosition) + `\\n\\n${importStatement}` + content.substring(insertPosition);\n};\n\n// Find matching bracket position (simplified version inspired by the library method)\nconst findMatchingBracketPosition = (content: string, bracket: string, startPos: number): number => {\n const openBracket = bracket;\n const closeBracket = bracket === '{' ? '}' : bracket === '(' ? ')' : ']';\n\n let depth = 0;\n let foundOpen = false;\n\n for (let i = startPos; i < content.length; i++) {\n const char = content[i];\n if (char === openBracket) {\n foundOpen = true;\n depth++;\n } else if (char === closeBracket) {\n depth--;\n if (foundOpen && depth === 0) {\n return i;\n }\n }\n }\n return -1;\n};\n\n// Generic utility to add code to end of a method (before closing brace)\nexport const addCodeToMethod = (content: string, methodRegex: RegExp, codeToAdd: string): string => {\n const methodMatch = content.match(methodRegex);\n if (!methodMatch || methodMatch.index === undefined) return content;\n\n const methodStart = methodMatch.index;\n const methodContent = methodMatch[0];\n\n // Find the opening brace position within the method match\n const openBraceIndex = methodContent.indexOf('{');\n if (openBraceIndex === -1) return content;\n\n // Find the matching closing brace\n const absoluteOpenBracePos = methodStart + openBraceIndex;\n const closeBracePos = findMatchingBracketPosition(content, '{', absoluteOpenBracePos);\n if (closeBracePos === -1) return content;\n\n // Detect indentation of the method's opening brace line\n const linesUpToOpenBrace = content.substring(0, absoluteOpenBracePos).split('\\n');\n const braceLine = linesUpToOpenBrace[linesUpToOpenBrace.length - 1];\n const methodIndentMatch = braceLine.match(/^(\\s*)/);\n const methodIndent = methodIndentMatch ? methodIndentMatch[1] : '';\n // Assume one indentation level is two spaces if not detected from next line\n let indentLevel = ' ';\n // Try to detect indentation from the next line after the opening brace\n const afterBrace = content.substring(absoluteOpenBracePos + 1, closeBracePos);\n const afterBraceLines = afterBrace.split('\\n').filter(l => l.trim().length > 0);\n if (afterBraceLines.length > 0) {\n const nextLineIndentMatch = afterBraceLines[0].match(/^(\\s*)/);\n if (nextLineIndentMatch && nextLineIndentMatch[1].length > methodIndent.length) {\n indentLevel = nextLineIndentMatch[1].slice(methodIndent.length);\n }\n }\n const finalIndent = methodIndent + indentLevel;\n // Insert code just before the closing brace, with detected indentation\n return content.substring(0, closeBracePos) + '\\n' + finalIndent + codeToAdd + '\\n' + methodIndent + content.substring(closeBracePos);\n};\n\n// Copy template file to Android project with content transformation\nexport const copyTemplateFile = (\n expoConfig: ExportedConfigWithProps<ApplicationProjectFile>,\n filename: string,\n classPackage: string,\n patchContent: (content: string) => string,\n): void => {\n const projectRoot = expoConfig.modRequest.projectRoot;\n const mainSourceDir = path.join(projectRoot, 'android/app/src/main/java');\n const packagePath = path.join(mainSourceDir, classPackage.replace(/\\./g, '/'));\n\n try {\n FileManagement.mkdir(packagePath, { recursive: true });\n const sourcePath = path.join(getAndroidNativeFilesPath(), filename);\n const content = patchContent(FileManagement.readFile(sourcePath));\n const destinationPath = path.join(packagePath, filename);\n FileManagement.writeFile(destinationPath, content);\n } catch (error) {\n console.warn(`Failed to copy ${filename} to Android project:`, error);\n throw error;\n }\n};\n"],"mappings":"AAEA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,yBAAyB,QAAQ,UAAU;;AAEpD;AACA,OAAO,MAAMC,eAAe,GAAGA,CAACC,OAAe,EAAEC,eAAuB,KAAa;EACnF,IAAID,OAAO,CAACE,QAAQ,CAACD,eAAe,CAAC,EAAE;IACrC,OAA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,CAACH,WAAW,EAAE,2BAA2B,CAAC;EACzE,MAAMI,WAAW,GAAG7D,IAAI,CAAC4D,IAAI,CAACD,aAAa,EAAEJ,YAAY,CAACO,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;EAE9E,IAAI;IACF7D,cAAc,CAAC8D,KAAK,CAACF,WAAW,EAAE;MAAEG,SAAS,EAAE;IAAK,CAAC,CAAC;IACtD,MAAMC,UAAU,GAAGjE,IAAI,CAAC4D,IAAI,CAAC1D,yBAAyB,CAAC,CAAC,EAAEoD,QAAQ,CAAC;IACnE,MAAMlD,OAAO,GAAGoD,YAAY,CAACvD,cAAc,CAACiE,QAAQ,CAACD,UAAU,CAAC,CAAC;IACjE,MAAME,eAAe,GAAGnE,IAAI,CAAC4D,IAAI,CAACC,WAAW,EAAEP,QAAQ,CAAC;IACxDrD,cAAc,CAACmE,SAAS,CAACD,eAAe,EAAE/D,OAAO,CAAC;EACpD,CAAC,CAAC,OAAOiE,KAAK,EAAE;IACdC,OAAO,CAACC,IAAI,CAAC,kBAAkBjB,QAAQ,sBAAsB,EAAEe,KAAK,CAAC;IACrE,MAAMA,KAAK;EACb;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Merges config values with env values for backward compatibility.
3
+ * If env is provided, it takes precedence. If nativeConfig is provided but env is not,
4
+ * nativeConfig values are used. This prioritizes existing env configuration for backward compatibility.
5
+ */
6
+ function mergeConfigWithEnvValues(props, nativeConfig) {
7
+ var _props$pushNotificati;
8
+ const nativeCdpApiKey = nativeConfig === null || nativeConfig === void 0 ? void 0 : nativeConfig.cdpApiKey;
9
+ const nativeRegion = nativeConfig === null || nativeConfig === void 0 ? void 0 : nativeConfig.region;
10
+ const envConfig = (_props$pushNotificati = props.pushNotification) === null || _props$pushNotificati === void 0 ? void 0 : _props$pushNotificati.env;
11
+ const envCdpApiKey = envConfig === null || envConfig === void 0 ? void 0 : envConfig.cdpApiKey;
12
+ const envRegion = envConfig === null || envConfig === void 0 ? void 0 : envConfig.region;
13
+
14
+ // Check for conflicts between env and nativeConfig
15
+ if (nativeCdpApiKey && envCdpApiKey) {
16
+ if (nativeCdpApiKey !== envCdpApiKey || (nativeRegion === null || nativeRegion === void 0 ? void 0 : nativeRegion.toLowerCase()) !== (envRegion === null || envRegion === void 0 ? void 0 : envRegion.toLowerCase())) {
17
+ const errorMessage = `Configuration conflict: 'config' and 'ios.pushNotification.env' values must match when both are provided.\n` + ` config.cdpApiKey: "${nativeCdpApiKey}"\n` + ` env.cdpApiKey: "${envCdpApiKey}"\n` + ` config.region: "${nativeRegion}"\n` + ` env.region: "${envRegion}"`;
18
+ console.error(errorMessage);
19
+ throw new Error(errorMessage);
20
+ }
21
+
22
+ // Values match - warn about redundant configuration
23
+ console.warn(`Both 'config' and 'ios.pushNotification.env' are provided with matching values. ` + `Consider removing 'ios.pushNotification.env' since 'config' is already specified.`);
24
+ }
25
+
26
+ // Return config (values are guaranteed to be the same if both exist)
27
+ const cdpApiKey = nativeCdpApiKey || envCdpApiKey;
28
+ const region = nativeRegion || envRegion;
29
+ if (cdpApiKey) {
30
+ return {
31
+ cdpApiKey,
32
+ region
33
+ };
34
+ }
35
+ return undefined;
36
+ }
37
+ export { mergeConfigWithEnvValues };
38
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["mergeConfigWithEnvValues","props","nativeConfig","_props$pushNotificati","nativeCdpApiKey","cdpApiKey","nativeRegion","region","envConfig","pushNotification","env","envCdpApiKey","envRegion","toLowerCase","errorMessage","console","error","Error","warn","undefined"],"sources":["config.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS, NativeSDKConfig, RichPushConfig } from '../types/cio-types';\n\n/**\n * Merges config values with env values for backward compatibility.\n * If env is provided, it takes precedence. If nativeConfig is provided but env is not,\n * nativeConfig values are used. This prioritizes existing env configuration for backward compatibility.\n */\nfunction mergeConfigWithEnvValues(\n props: CustomerIOPluginOptionsIOS,\n nativeConfig?: NativeSDKConfig\n): RichPushConfig | undefined {\n const nativeCdpApiKey = nativeConfig?.cdpApiKey;\n const nativeRegion = nativeConfig?.region;\n\n const envConfig = props.pushNotification?.env;\n const envCdpApiKey = envConfig?.cdpApiKey;\n const envRegion = envConfig?.region;\n\n // Check for conflicts between env and nativeConfig\n if (nativeCdpApiKey && envCdpApiKey) {\n if (nativeCdpApiKey !== envCdpApiKey || nativeRegion?.toLowerCase() !== envRegion?.toLowerCase()) {\n const errorMessage = `Configuration conflict: 'config' and 'ios.pushNotification.env' values must match when both are provided.\\n` +\n ` config.cdpApiKey: \"${nativeCdpApiKey}\"\\n` +\n ` env.cdpApiKey: \"${envCdpApiKey}\"\\n` +\n ` config.region: \"${nativeRegion}\"\\n` +\n ` env.region: \"${envRegion}\"`;\n\n console.error(errorMessage);\n throw new Error(errorMessage);\n }\n\n // Values match - warn about redundant configuration\n console.warn(\n `Both 'config' and 'ios.pushNotification.env' are provided with matching values. ` +\n `Consider removing 'ios.pushNotification.env' since 'config' is already specified.`\n );\n }\n\n // Return config (values are guaranteed to be the same if both exist)\n const cdpApiKey = nativeCdpApiKey || envCdpApiKey;\n const region = nativeRegion || envRegion;\n\n if (cdpApiKey) {\n return {\n cdpApiKey,\n region,\n };\n }\n\n return undefined;\n}\n\nexport { mergeConfigWithEnvValues };\n"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA,SAASA,wBAAwBA,CAC/BC,KAAiC,EACjCC,YAA8B,EACF;EAAA,IAAAC,qBAAA;EAC5B,MAAMC,eAAe,GAAGF,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEG,SAAS;EAC/C,MAAMC,YAAY,GAAGJ,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEK,MAAM;EAEzC,MAAMC,SAAS,IAAAL,qBAAA,GAAGF,KAAK,CAACQ,gBAAgB,cAAAN,qBAAA,uBAAtBA,qBAAA,CAAwBO,GAAG;EAC7C,MAAMC,YAAY,GAAGH,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEH,SAAS;EACzC,MAAMO,SAAS,GAAGJ,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAED,MAAM;;EAEnC;EACA,IAAIH,eAAe,IAAIO,YAAY,EAAE;IACnC,IAAIP,eAAe,KAAKO,YAAY,IAAI,CAAAL,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEO,WAAW,CAAC,CAAC,OAAKD,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEC,WAAW,CAAC,CAAC,GAAE;MAChG,MAAMC,YAAY,GAAG,6GAA6G,GAChI,wBAAwBV,eAAe,KAAK,GAC5C,qBAAqBO,YAAY,KAAK,GACtC,qBAAqBL,YAAY,KAAK,GACtC,kBAAkBM,SAAS,GAAG;MAEhCG,OAAO,CAACC,KAAK,CAACF,YAAY,CAAC;MAC3B,MAAM,IAAIG,KAAK,CAACH,YAAY,CAAC;IAC/B;;IAEA;IACAC,OAAO,CAACG,IAAI,CACV,kFAAkF,GAClF,mFACF,CAAC;EACH;;EAEA;EACA,MAAMb,SAAS,GAAGD,eAAe,IAAIO,YAAY;EACjD,MAAMJ,MAAM,GAAGD,YAAY,IAAIM,SAAS;EAExC,IAAIP,SAAS,EAAE;IACb,OAAO;MACLA,SAAS;MACTE;IACF,CAAC;EACH;EAEA,OAAOY,SAAS;AAClB;AAEA,SAASnB,wBAAwB","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ const findPluginPackageRoot = () => {
4
+ const finder = require('find-package-json');
5
+ const f = finder(__dirname);
6
+ const root = f.next().filename;
7
+ return path.dirname(root);
8
+ };
9
+ const pluginPackageRoot = findPluginPackageRoot();
10
+
11
+ // Returns path to plugin's native template files directory
12
+ export const getNativeFilesPath = () => {
13
+ return path.join(pluginPackageRoot, 'plugin/src/helpers/native-files/');
14
+ };
15
+
16
+ // Returns path to plugin's Android native template files
17
+ export const getAndroidNativeFilesPath = () => {
18
+ return path.join(getNativeFilesPath(), 'android');
19
+ };
20
+
21
+ // Returns path to plugin's iOS native template files
22
+ export const getIosNativeFilesPath = () => {
23
+ return path.join(getNativeFilesPath(), 'ios');
24
+ };
25
+
26
+ // Reads the version of the plugin from its `package.json` and returns it as a string.
27
+ export const getPluginVersion = () => {
28
+ const packageJsonPath = path.resolve(pluginPackageRoot, 'package.json');
29
+ if (!fs.existsSync(packageJsonPath)) {
30
+ throw new Error(`package.json not found at ${packageJsonPath}`);
31
+ }
32
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
33
+ if (!packageJson.version) {
34
+ throw new Error(`"version" field is missing in ${packageJsonPath}`);
35
+ }
36
+ return packageJson.version;
37
+ };
38
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fs","path","findPluginPackageRoot","finder","require","f","__dirname","root","next","filename","dirname","pluginPackageRoot","getNativeFilesPath","join","getAndroidNativeFilesPath","getIosNativeFilesPath","getPluginVersion","packageJsonPath","resolve","existsSync","Error","packageJson","JSON","parse","readFileSync","version"],"sources":["plugin.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nconst findPluginPackageRoot = (): string => {\n const finder = require('find-package-json');\n const f = finder(__dirname);\n const root = f.next().filename;\n return path.dirname(root);\n};\n\nconst pluginPackageRoot = findPluginPackageRoot();\n\n// Returns path to plugin's native template files directory\nexport const getNativeFilesPath = (): string => {\n return path.join(\n pluginPackageRoot,\n 'plugin/src/helpers/native-files/'\n );\n};\n\n// Returns path to plugin's Android native template files\nexport const getAndroidNativeFilesPath = (): string => {\n return path.join(getNativeFilesPath(), 'android');\n};\n\n// Returns path to plugin's iOS native template files\nexport const getIosNativeFilesPath = (): string => {\n return path.join(getNativeFilesPath(), 'ios');\n};\n\n// Reads the version of the plugin from its `package.json` and returns it as a string.\nexport const getPluginVersion = (): string => {\n const packageJsonPath = path.resolve(\n pluginPackageRoot,\n 'package.json'\n );\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(`package.json not found at ${packageJsonPath}`);\n }\n\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n if (!packageJson.version) {\n throw new Error(`\"version\" field is missing in ${packageJsonPath}`);\n }\n return packageJson.version;\n};\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAEvB,MAAMC,qBAAqB,GAAGA,CAAA,KAAc;EAC1C,MAAMC,MAAM,GAAGC,OAAO,CAAC,mBAAmB,CAAC;EAC3C,MAAMC,CAAC,GAAGF,MAAM,CAACG,SAAS,CAAC;EAC3B,MAAMC,IAAI,GAAGF,CAAC,CAACG,IAAI,CAAC,CAAC,CAACC,QAAQ;EAC9B,OAAOR,IAAI,CAACS,OAAO,CAACH,IAAI,CAAC;AAC3B,CAAC;AAED,MAAMI,iBAAiB,GAAGT,qBAAqB,CAAC,CAAC;;AAEjD;AACA,OAAO,MAAMU,kBAAkB,GAAGA,CAAA,KAAc;EAC9C,OAAOX,IAAI,CAACY,IAAI,CACdF,iBAAiB,EACjB,kCACF,CAAC;AACH,CAAC;;AAED;AACA,OAAO,MAAMG,yBAAyB,GAAGA,CAAA,KAAc;EACrD,OAAOb,IAAI,CAACY,IAAI,CAACD,kBAAkB,CAAC,CAAC,EAAE,SAAS,CAAC;AACnD,CAAC;;AAED;AACA,OAAO,MAAMG,qBAAqB,GAAGA,CAAA,KAAc;EACjD,OAAOd,IAAI,CAACY,IAAI,CAACD,kBAAkB,CAAC,CAAC,EAAE,KAAK,CAAC;AAC/C,CAAC;;AAED;AACA,OAAO,MAAMI,gBAAgB,GAAGA,CAAA,KAAc;EAC5C,MAAMC,eAAe,GAAGhB,IAAI,CAACiB,OAAO,CAClCP,iBAAiB,EACjB,cACF,CAAC;EACD,IAAI,CAACX,EAAE,CAACmB,UAAU,CAACF,eAAe,CAAC,EAAE;IACnC,MAAM,IAAIG,KAAK,CAAC,6BAA6BH,eAAe,EAAE,CAAC;EACjE;EAEA,MAAMI,WAAW,GAAGC,IAAI,CAACC,KAAK,CAACvB,EAAE,CAACwB,YAAY,CAACP,eAAe,EAAE,MAAM,CAAC,CAAC;EACxE,IAAI,CAACI,WAAW,CAACI,OAAO,EAAE;IACxB,MAAM,IAAIL,KAAK,CAAC,iCAAiCH,eAAe,EAAE,CAAC;EACrE;EACA,OAAOI,WAAW,CAACI,OAAO;AAC5B,CAAC","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ function validateRequired(value, fieldName, context) {
2
+ if (value === undefined || value === null) {
3
+ throw new Error(`${context}: ${fieldName} is required, received: ${value}`);
4
+ }
5
+ }
6
+ function validateString(value, fieldName, context) {
7
+ if (value !== undefined && (typeof value !== 'string' || value.trim() === '')) {
8
+ throw new Error(`${context}: ${fieldName} must be a non-empty string, received: ${typeof value === 'string' ? `"${value}"` : value}`);
9
+ }
10
+ }
11
+ function validateBoolean(value, fieldName, context) {
12
+ if (value !== undefined && typeof value !== 'boolean') {
13
+ throw new Error(`${context}: ${fieldName} must be a boolean, received: ${value}`);
14
+ }
15
+ }
16
+ function validateEnum(value, fieldName, allowedValues, context) {
17
+ if (value === undefined) return;
18
+ validateString(value, fieldName, context);
19
+ const lowerValue = value.toLowerCase();
20
+ const lowerAllowedValues = allowedValues.map(v => v.toLowerCase());
21
+ if (!lowerAllowedValues.includes(lowerValue)) {
22
+ const valuesStr = allowedValues.map(v => `"${v}"`).join(', ');
23
+ throw new Error(`${context}: ${fieldName} must be one of ${valuesStr}, received: ${value}`);
24
+ }
25
+ }
26
+ function validateNativeSDKConfig(config) {
27
+ const context = 'NativeSDKConfig';
28
+ validateRequired(config.cdpApiKey, 'cdpApiKey', context);
29
+ validateString(config.cdpApiKey, 'cdpApiKey', context);
30
+ validateEnum(config.region, 'region', ['US', 'EU'], context);
31
+ validateEnum(config.screenViewUse, 'screenViewUse', ['all', 'inapp'], context);
32
+ validateEnum(config.logLevel, 'logLevel', ['none', 'error', 'info', 'debug'], context);
33
+ validateBoolean(config.autoTrackDeviceAttributes, 'autoTrackDeviceAttributes', context);
34
+ validateBoolean(config.trackApplicationLifecycleEvents, 'trackApplicationLifecycleEvents', context);
35
+ validateString(config.siteId, 'siteId', context);
36
+ validateString(config.migrationSiteId, 'migrationSiteId', context);
37
+ }
38
+ export { validateNativeSDKConfig };
39
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["validateRequired","value","fieldName","context","undefined","Error","validateString","trim","validateBoolean","validateEnum","allowedValues","lowerValue","toLowerCase","lowerAllowedValues","map","v","includes","valuesStr","join","validateNativeSDKConfig","config","cdpApiKey","region","screenViewUse","logLevel","autoTrackDeviceAttributes","trackApplicationLifecycleEvents","siteId","migrationSiteId"],"sources":["validation.ts"],"sourcesContent":["import type { NativeSDKConfig } from '../types/cio-types';\n\nfunction validateRequired(value: unknown, fieldName: string, context: string): void {\n if (value === undefined || value === null) {\n throw new Error(`${context}: ${fieldName} is required, received: ${value}`);\n }\n}\n\nfunction validateString(value: unknown, fieldName: string, context: string): void {\n if (value !== undefined && (typeof value !== 'string' || value.trim() === '')) {\n throw new Error(`${context}: ${fieldName} must be a non-empty string, received: ${typeof value === 'string' ? `\"${value}\"` : value}`);\n }\n}\n\nfunction validateBoolean(value: unknown, fieldName: string, context: string): void {\n if (value !== undefined && typeof value !== 'boolean') {\n throw new Error(`${context}: ${fieldName} must be a boolean, received: ${value}`);\n }\n}\n\nfunction validateEnum<T extends string>(\n value: unknown,\n fieldName: string,\n allowedValues: readonly T[],\n context: string\n): void {\n if (value === undefined) return;\n\n validateString(value, fieldName, context);\n\n const lowerValue = (value as string).toLowerCase();\n const lowerAllowedValues = allowedValues.map(v => v.toLowerCase());\n if (!lowerAllowedValues.includes(lowerValue)) {\n const valuesStr = allowedValues.map(v => `\"${v}\"`).join(', ');\n throw new Error(`${context}: ${fieldName} must be one of ${valuesStr}, received: ${value}`);\n }\n}\n\nfunction validateNativeSDKConfig(config: NativeSDKConfig): void {\n const context = 'NativeSDKConfig';\n\n validateRequired(config.cdpApiKey, 'cdpApiKey', context);\n validateString(config.cdpApiKey, 'cdpApiKey', context);\n\n validateEnum(config.region, 'region', ['US', 'EU'] as const, context);\n validateEnum(config.screenViewUse, 'screenViewUse', ['all', 'inapp'] as const, context);\n validateEnum(config.logLevel, 'logLevel', ['none', 'error', 'info', 'debug'] as const, context);\n validateBoolean(config.autoTrackDeviceAttributes, 'autoTrackDeviceAttributes', context);\n validateBoolean(config.trackApplicationLifecycleEvents, 'trackApplicationLifecycleEvents', context);\n validateString(config.siteId, 'siteId', context);\n validateString(config.migrationSiteId, 'migrationSiteId', context);\n}\n\nexport { validateNativeSDKConfig };\n"],"mappings":"AAEA,SAASA,gBAAgBA,CAACC,KAAc,EAAEC,SAAiB,EAAEC,OAAe,EAAQ;EAClF,IAAIF,KAAK,KAAKG,SAAS,IAAIH,KAAK,KAAK,IAAI,EAAE;IACzC,MAAM,IAAII,KAAK,CAAC,GAAGF,OAAO,KAAKD,SAAS,2BAA2BD,KAAK,EAAE,CAAC;EAC7E;AACF;AAEA,SAASK,cAAcA,CAACL,KAAc,EAAEC,SAAiB,EAAEC,OAAe,EAAQ;EAChF,IAAIF,KAAK,KAAKG,SAAS,KAAK,OAAOH,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACM,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE;IAC7E,MAAM,IAAIF,KAAK,CAAC,GAAGF,OAAO,KAAKD,SAAS,0CAA0C,OAAOD,KAAK,KAAK,QAAQ,GAAG,IAAIA,KAAK,GAAG,GAAGA,KAAK,EAAE,CAAC;EACvI;AACF;AAEA,SAASO,eAAeA,CAACP,KAAc,EAAEC,SAAiB,EAAEC,OAAe,EAAQ;EACjF,IAAIF,KAAK,KAAKG,SAAS,IAAI,OAAOH,KAAK,KAAK,SAAS,EAAE;IACrD,MAAM,IAAII,KAAK,CAAC,GAAGF,OAAO,KAAKD,SAAS,iCAAiCD,KAAK,EAAE,CAAC;EACnF;AACF;AAEA,SAASQ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AAE,2BAA2B,EAAEtB,OAAO,CAAC;EACvFK,eAAe,CAACY,MAAM,CAACM,+BAA+B,EAAE,iCAAiC,EAAEvB,OAAO,CAAC;EACnGG,cAAc,CAACc,MAAM,CAACO,MAAM,EAAE,QAAQ,EAAExB,OAAO,CAAC;EAChDG,cAAc,CAACc,MAAM,CAACQ,eAAe,EAAE,iBAAiB,EAAEzB,OAAO,CAAC;AACpE;AAEA,SAASgB,uBAAuB","ignoreList":[]}
@@ -0,0 +1,60 @@
1
+ import path from 'path';
2
+ import { FileManagement } from "../helpers/utils/fileManagement";
3
+
4
+ /**
5
+ * Gets an existing CustomerIO group or creates a new one in the Xcode project
6
+ * @param xcodeProject The Xcode project instance
7
+ * @param projectName The iOS project name
8
+ * @returns The CustomerIO group reference
9
+ */
10
+ export function getOrCreateCustomerIOGroup(xcodeProject, projectName) {
11
+ // Check if CustomerIO group already exists
12
+ let customerIOGroup = xcodeProject.pbxGroupByName('CustomerIO');
13
+ if (customerIOGroup) {
14
+ return customerIOGroup;
15
+ }
16
+
17
+ // Create new CustomerIO group and add it to the project
18
+ customerIOGroup = xcodeProject.pbxCreateGroup('CustomerIO');
19
+ const projectGroupKey = xcodeProject.findPBXGroupKey({
20
+ name: projectName
21
+ });
22
+ xcodeProject.addToPbxGroup(customerIOGroup, projectGroupKey);
23
+ return customerIOGroup;
24
+ }
25
+
26
+ /**
27
+ * Copies template file to iOS project, applies transformations, and registers with Xcode
28
+ * @param params.xcodeProject Xcode project instance
29
+ * @param params.iosProjectRoot iOS project root path
30
+ * @param params.projectName iOS project name
31
+ * @param params.sourceFilePath Source template file path
32
+ * @param params.targetFileName Target file name
33
+ * @param params.transform Content transformation function
34
+ * @param params.customerIOGroup CustomerIO group (auto-created if not provided)
35
+ * @returns Destination file path
36
+ */
37
+ export function copyFileToXcode({
38
+ xcodeProject,
39
+ iosProjectRoot,
40
+ projectName,
41
+ sourceFilePath,
42
+ targetFileName,
43
+ transform,
44
+ customerIOGroup = getOrCreateCustomerIOGroup(xcodeProject, projectName)
45
+ }) {
46
+ // Construct the full destination path within the iOS project directory
47
+ const destinationPath = path.join(iosProjectRoot, projectName, targetFileName);
48
+ try {
49
+ // Read template, apply transformations, and write to project
50
+ const content = transform(FileManagement.readFile(sourceFilePath));
51
+ FileManagement.writeFile(destinationPath, content);
52
+ // Register file with Xcode project
53
+ xcodeProject.addSourceFile(`${projectName}/${targetFileName}`, null, customerIOGroup);
54
+ return destinationPath;
55
+ } catch (error) {
56
+ console.warn(`Failed to add ${targetFileName} to Xcode project:`, error);
57
+ throw error;
58
+ }
59
+ }
60
+ //# sourceMappingURL=xcode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["path","FileManagement","getOrCreateCustomerIOGroup","xcodeProject","projectName","customerIOGroup","pbxGroupByName","pbxCreateGroup","projectGroupKey","findPBXGroupKey","name","addToPbxGroup","copyFileToXcode","iosProjectRoot","sourceFilePath","targetFileName","transform","destinationPath","join","content","readFile","writeFile","addSourceFile","error","console","warn"],"sources":["xcode.ts"],"sourcesContent":["import type { XcodeProject } from \"@expo/config-plugins\";\nimport path from 'path';\nimport { FileManagement } from \"../helpers/utils/fileManagement\";\n\n/**\n * Gets an existing CustomerIO group or creates a new one in the Xcode project\n * @param xcodeProject The Xcode project instance\n * @param projectName The iOS project name\n * @returns The CustomerIO group reference\n */\nexport function getOrCreateCustomerIOGroup(\n xcodeProject: XcodeProject,\n projectName: string,\n): XcodeProject['pbxCreateGroup'] {\n // Check if CustomerIO group already exists\n let customerIOGroup = xcodeProject.pbxGroupByName('CustomerIO');\n if (customerIOGroup) {\n return customerIOGroup;\n }\n\n // Create new CustomerIO group and add it to the project\n customerIOGroup = xcodeProject.pbxCreateGroup('CustomerIO');\n const projectGroupKey = xcodeProject.findPBXGroupKey({ name: projectName });\n xcodeProject.addToPbxGroup(customerIOGroup, projectGroupKey);\n return customerIOGroup;\n}\n\n/**\n * Copies template file to iOS project, applies transformations, and registers with Xcode\n * @param params.xcodeProject Xcode project instance\n * @param params.iosProjectRoot iOS project root path\n * @param params.projectName iOS project name\n * @param params.sourceFilePath Source template file path\n * @param params.targetFileName Target file name\n * @param params.transform Content transformation function\n * @param params.customerIOGroup CustomerIO group (auto-created if not provided)\n * @returns Destination file path\n */\nexport function copyFileToXcode({\n xcodeProject,\n iosProjectRoot,\n projectName,\n sourceFilePath,\n targetFileName,\n transform,\n customerIOGroup = getOrCreateCustomerIOGroup(xcodeProject, projectName),\n}: {\n xcodeProject: XcodeProject;\n iosProjectRoot: string;\n projectName: string;\n sourceFilePath: string;\n targetFileName: string;\n transform: (content: string) => string;\n customerIOGroup?: XcodeProject['pbxCreateGroup'];\n}): string {\n // Construct the full destination path within the iOS project directory\n const destinationPath = path.join(\n iosProjectRoot,\n projectName,\n targetFileName\n );\n\n try {\n // Read template, apply transformations, and write to project\n const content = transform(FileManagement.readFile(sourceFilePath));\n FileManagement.writeFile(destinationPath, content);\n // Register file with Xcode project\n xcodeProject.addSourceFile(`${projectName}/${targetFileName}`, null, customerIOGroup);\n return destinationPath;\n } catch (error) {\n console.warn(`Failed to add ${targetFileName} to Xcode project:`, error);\n throw error;\n }\n}\n"],"mappings":"AACA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,cAAc,QAAQ,iCAAiC;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,0BAA0BA,CACxCC,YAA0B,EAC1BC,WAAmB,EACa;EAChC;EACA,IAAIC,eAAe,GAAGF,YAAY,CAACG,cAAc,CAAC,YAAY,CAAC;EAC/D,IAAID,eAAe,EAAE;IACnB,OAAOA,eAAe;EACxB;;EAEA;EACAA,eAAe,GAAGF,YAAY,CAACI,cAAc,CAAC,YAAY,CAAC;EAC3D,MAAMC,eAAe,GAAGL,YAAY,CAACM,eAAe,CAAC;IAAEC,IAAI,EAAEN;EAAY,CAAC,CAAC;EAC3ED,YAAY,CAACQ,aAAa,CAACN,eAAe,EAAEG,eAAe,CAAC;EAC5D,OAAOH,eAAe;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,eAAeA,CAAC;EAC9BT,YAAY;EACZU,cAAc;EACdT,WAAW;EACXU,cAAc;EACdC,cAAc;EACdC,SAAS;EACTX,eAAe,GAAGH,0BAA0B,CAACC,YAAY,EAAEC,WAAW;AASxE,CAAC,EAAU;EACT;EACA,MAAMa,eAAe,GAAGjB,IAAI,CAACkB,IAAI,CAC/BL,cAAc,EACdT,WAAW,EACXW,cACF,CAAC;EAED,IAAI;IACF;IACA,MAAMI,OAAO,GAAGH,SAAS,CAACf,cAAc,CAACmB,QAAQ,CAACN,cAAc,CAAC,CAAC;IAClEb,cAAc,CAACoB,SAAS,CAACJ,eAAe,EAAEE,OAAO,CAAC;IAClD;IACAhB,YAAY,CAACmB,aAAa,CAAC,GAAGlB,WAAW,IAAIW,cAAc,EAAE,EAAE,IAAI,EAAEV,eAAe,CAAC;IACrF,OAAOY,eAAe;EACxB,CAAC,CAAC,OAAOM,KAAK,EAAE;IACdC,OAAO,CAACC,IAAI,CAAC,iBAAiBV,cAAc,oBAAoB,EAAEQ,KAAK,CAAC;IACxE,MAAMA,KAAK;EACb;AACF","ignoreList":[]}
@@ -1,3 +1,3 @@
1
1
  import type { ExpoConfig } from '@expo/config-types';
2
- import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
3
- export declare function withCIOAndroid(config: ExpoConfig, props: CustomerIOPluginOptionsAndroid): ExpoConfig;
2
+ import type { CustomerIOPluginOptionsAndroid, NativeSDKConfig } from '../types/cio-types';
3
+ export declare function withCIOAndroid(config: ExpoConfig, sdkConfig: NativeSDKConfig | undefined, props: CustomerIOPluginOptionsAndroid): ExpoConfig;
@@ -0,0 +1,3 @@
1
+ import type { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { NativeSDKConfig } from '../types/cio-types';
3
+ export declare const withMainApplicationModifications: ConfigPlugin<NativeSDKConfig>;
@@ -1,4 +1,5 @@
1
1
  import type { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { ResourceXML } from '@expo/config-plugins/build/android/Resources';
2
3
  /**
3
4
  * Adds or updates string resources in Android's strings.xml required by the plugin
4
5
  */
@@ -9,7 +10,7 @@ export declare const withProjectStrings: ConfigPlugin;
9
10
  * @param stringResources - Array of string resources to add or update
10
11
  * @returns Updated strings.xml object
11
12
  */
12
- export declare function addStringsToXml(stringsXml: any, stringResources: {
13
+ export declare function addStringsToXml(stringsXml: ResourceXML, stringResources: {
13
14
  name: string;
14
15
  value: string;
15
16
  }[]): void;
@@ -5,3 +5,6 @@ export declare const CIO_PROJECT_ALLPROJECTS_REGEX: RegExp;
5
5
  export declare const CIO_PROJECT_GIST_MAVEN_SNIPPET = " maven { url \"https://maven.gist.build\" }";
6
6
  export declare const CIO_APP_GOOGLE_SNIPPET = "apply plugin: \"com.google.gms.google-services\" // Google Services plugin";
7
7
  export declare const CIO_PROJECT_GOOGLE_SNIPPET = " classpath \"com.google.gms:google-services:4.3.13\" // Google Services plugin";
8
+ export declare const CIO_MAINAPPLICATION_ONCREATE_REGEX: RegExp;
9
+ export declare const CIO_NATIVE_SDK_INITIALIZE_CALL = "CustomerIOSDKInitializer.initialize(this)";
10
+ export declare const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = "// Auto Initialize Native Customer.io SDK\n CustomerIOSDKInitializer.initialize(this)";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Platform constants for native SDK initialization
3
+ */
4
+ export declare const PLATFORM: {
5
+ readonly IOS: "ios";
6
+ readonly ANDROID: "android";
7
+ };
8
+ /**
9
+ * Platform type definition
10
+ */
11
+ export type Platform = typeof PLATFORM[keyof typeof PLATFORM];
@@ -1,4 +1,3 @@
1
- export declare const LOCAL_PATH_TO_CIO_NSE_FILES: any;
2
1
  export declare function getRelativePathToRNSDK(iosPath: string): any;
3
2
  export declare const IOS_DEPLOYMENT_TARGET = "13.0";
4
3
  export declare const GROUP_IDENTIFIER_TEMPLATE_REGEX: RegExp;
@@ -31,3 +30,6 @@ export declare const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET = "\n //
31
30
  export declare const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = "\n@objc(registerPushNotification)\n public func registerPushNotification() {\n\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }\n }";
32
31
  export declare const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = "\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }";
33
32
  export declare const CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER: RegExp;
33
+ export declare const CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX: RegExp;
34
+ export declare const CIO_NATIVE_SDK_INITIALIZE_CALL = "CustomerIOSDKInitializer.initialize()";
35
+ export declare const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = "// Auto Initialize Native Customer.io SDK\n CustomerIOSDKInitializer.initialize()\n ";
@@ -0,0 +1,7 @@
1
+ import type { NativeSDKConfig } from '../../types/cio-types';
2
+ import { type Platform } from '../constants/common';
3
+ /**
4
+ * Shared utility function to perform common SDK config replacements
5
+ * for both iOS and Android template files
6
+ */
7
+ export declare function patchNativeSDKInitializer(rawContent: string, platform: Platform, sdkConfig: NativeSDKConfig): string;
@@ -1,7 +1,7 @@
1
- import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
2
1
  import type { ExpoConfig } from '@expo/config-types';
2
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
3
  /**
4
- * Returns t
4
+ * Returns true if FCM is configured to be used as push provider
5
5
  * @param iosOptions The plugin iOS configuration options
6
6
  * @returns true if FCM is configured to be used as push provider
7
7
  */
@@ -1,3 +1,3 @@
1
1
  import type { ExpoConfig } from '@expo/config-types';
2
- import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
- export declare function withCIOIos(config: ExpoConfig, props: CustomerIOPluginOptionsIOS): ExpoConfig;
2
+ import type { CustomerIOPluginOptionsIOS, NativeSDKConfig } from '../types/cio-types';
3
+ export declare function withCIOIos(config: ExpoConfig, sdkConfig: NativeSDKConfig | undefined, props: CustomerIOPluginOptionsIOS): ExpoConfig;
@@ -1,3 +1,3 @@
1
- import type { ConfigPlugin } from '@expo/config-plugins';
2
- import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
- export declare const withCIOIosSwift: ConfigPlugin<CustomerIOPluginOptionsIOS>;
1
+ import type { ExpoConfig } from '@expo/config-types';
2
+ import type { CustomerIOPluginOptionsIOS, NativeSDKConfig } from '../types/cio-types';
3
+ export declare const withCIOIosSwift: (configOuter: ExpoConfig, sdkConfig: NativeSDKConfig | undefined, props: CustomerIOPluginOptionsIOS) => ExpoConfig;
@@ -1,7 +1,15 @@
1
+ /**
2
+ * Properties set by the user in their app config file (e.g: app.json or app.plugin.js)
3
+ * @public
4
+ */
1
5
  export type CustomerIOPluginProperties = {
2
6
  devTeam: string;
3
7
  iosDeploymentTarget: string;
4
8
  };
9
+ /**
10
+ * Plugin options for iOS platform configuration
11
+ * @public
12
+ */
5
13
  export type CustomerIOPluginOptionsIOS = {
6
14
  iosPath: string;
7
15
  devTeam?: string;
@@ -38,6 +46,10 @@ export type CustomerIOPluginOptionsIOS = {
38
46
  */
39
47
  disableNotificationRegistration?: boolean;
40
48
  };
49
+ /**
50
+ * Plugin options for Android platform configuration
51
+ * @public
52
+ */
41
53
  export type CustomerIOPluginOptionsAndroid = {
42
54
  androidPath: string;
43
55
  googleServicesFile?: string;
@@ -50,10 +62,41 @@ export type CustomerIOPluginOptionsAndroid = {
50
62
  };
51
63
  };
52
64
  };
65
+ /**
66
+ * SDK configuration options for auto initialization
67
+ * @public
68
+ */
69
+ export type NativeSDKConfig = {
70
+ cdpApiKey: string;
71
+ region?: 'US' | 'EU';
72
+ autoTrackDeviceAttributes?: boolean;
73
+ trackApplicationLifecycleEvents?: boolean;
74
+ screenViewUse?: 'all' | 'inapp';
75
+ logLevel?: 'none' | 'error' | 'info' | 'debug';
76
+ siteId?: string;
77
+ migrationSiteId?: string;
78
+ };
79
+ /**
80
+ * Combined plugin options for both iOS and Android platforms
81
+ * @public
82
+ */
53
83
  export type CustomerIOPluginOptions = {
84
+ config?: NativeSDKConfig;
54
85
  android: CustomerIOPluginOptionsAndroid;
55
86
  ios: CustomerIOPluginOptionsIOS;
56
87
  };
88
+ /**
89
+ * Rich push configuration used to initialize Notification Service Extension (NSE) on the native side
90
+ * @public
91
+ */
92
+ export type RichPushConfig = {
93
+ cdpApiKey: string;
94
+ region?: string;
95
+ };
96
+ /**
97
+ * Push notification configuration options
98
+ * @public
99
+ */
57
100
  export type CustomerIOPluginPushNotificationOptions = {
58
101
  provider?: 'apn' | 'fcm';
59
102
  googleServicesFile?: string;
@@ -64,11 +107,8 @@ export type CustomerIOPluginPushNotificationOptions = {
64
107
  disableNotificationRegistration?: boolean;
65
108
  handleDeeplinkInKilledState?: boolean;
66
109
  /**
67
- * These values will be used to initialize the Notification Service Extension (NSE) on the native side.
68
- * They should match the values you use to initialize the SDK in your app
110
+ * Rich push config should match the values used to initialize SDK in the app.
111
+ * Optional if `config` is provided at the top level.
69
112
  */
70
- env: {
71
- cdpApiKey: string;
72
- region: string;
73
- };
113
+ env?: RichPushConfig;
74
114
  };
@@ -0,0 +1,5 @@
1
+ import type { ExportedConfigWithProps } from '@expo/config-plugins';
2
+ import type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';
3
+ export declare const addImportToFile: (content: string, importStatement: string) => string;
4
+ export declare const addCodeToMethod: (content: string, methodRegex: RegExp, codeToAdd: string) => string;
5
+ export declare const copyTemplateFile: (expoConfig: ExportedConfigWithProps<ApplicationProjectFile>, filename: string, classPackage: string, patchContent: (content: string) => string) => void;
@@ -0,0 +1,8 @@
1
+ import type { CustomerIOPluginOptionsIOS, NativeSDKConfig, RichPushConfig } from '../types/cio-types';
2
+ /**
3
+ * Merges config values with env values for backward compatibility.
4
+ * If env is provided, it takes precedence. If nativeConfig is provided but env is not,
5
+ * nativeConfig values are used. This prioritizes existing env configuration for backward compatibility.
6
+ */
7
+ declare function mergeConfigWithEnvValues(props: CustomerIOPluginOptionsIOS, nativeConfig?: NativeSDKConfig): RichPushConfig | undefined;
8
+ export { mergeConfigWithEnvValues };
@@ -0,0 +1,4 @@
1
+ export declare const getNativeFilesPath: () => string;
2
+ export declare const getAndroidNativeFilesPath: () => string;
3
+ export declare const getIosNativeFilesPath: () => string;
4
+ export declare const getPluginVersion: () => string;
@@ -0,0 +1,3 @@
1
+ import type { NativeSDKConfig } from '../types/cio-types';
2
+ declare function validateNativeSDKConfig(config: NativeSDKConfig): void;
3
+ export { validateNativeSDKConfig };
@@ -0,0 +1,28 @@
1
+ import type { XcodeProject } from "@expo/config-plugins";
2
+ /**
3
+ * Gets an existing CustomerIO group or creates a new one in the Xcode project
4
+ * @param xcodeProject The Xcode project instance
5
+ * @param projectName The iOS project name
6
+ * @returns The CustomerIO group reference
7
+ */
8
+ export declare function getOrCreateCustomerIOGroup(xcodeProject: XcodeProject, projectName: string): XcodeProject['pbxCreateGroup'];
9
+ /**
10
+ * Copies template file to iOS project, applies transformations, and registers with Xcode
11
+ * @param params.xcodeProject Xcode project instance
12
+ * @param params.iosProjectRoot iOS project root path
13
+ * @param params.projectName iOS project name
14
+ * @param params.sourceFilePath Source template file path
15
+ * @param params.targetFileName Target file name
16
+ * @param params.transform Content transformation function
17
+ * @param params.customerIOGroup CustomerIO group (auto-created if not provided)
18
+ * @returns Destination file path
19
+ */
20
+ export declare function copyFileToXcode({ xcodeProject, iosProjectRoot, projectName, sourceFilePath, targetFileName, transform, customerIOGroup, }: {
21
+ xcodeProject: XcodeProject;
22
+ iosProjectRoot: string;
23
+ projectName: string;
24
+ sourceFilePath: string;
25
+ targetFileName: string;
26
+ transform: (content: string) => string;
27
+ customerIOGroup?: XcodeProject['pbxCreateGroup'];
28
+ }): string;
@@ -13,16 +13,16 @@ export const withAndroidManifestUpdates: ConfigPlugin<
13
13
  const customerIOMessagingpush =
14
14
  'io.customer.messagingpush.CustomerIOFirebaseMessagingService';
15
15
 
16
- if (!application[0]['service']) {
17
- application[0]['service'] = [];
16
+ if (!application[0].service) {
17
+ application[0].service = [];
18
18
  }
19
19
 
20
- const hasService = application[0]['service'].some(
21
- (service) => service['$']['android:name'] === customerIOMessagingpush
20
+ const hasService = application[0].service.some(
21
+ (service) => service.$['android:name'] === customerIOMessagingpush
22
22
  );
23
23
 
24
24
  if (!hasService) {
25
- application[0]['service'].push({
25
+ application[0].service.push({
26
26
  '$': {
27
27
  'android:name': customerIOMessagingpush,
28
28
  'android:exported': 'false',
@@ -1,16 +1,18 @@
1
1
  import type { ExpoConfig } from '@expo/config-types';
2
2
 
3
- import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
3
+ import type { CustomerIOPluginOptionsAndroid, NativeSDKConfig } from '../types/cio-types';
4
4
  import { withAndroidManifestUpdates } from './withAndroidManifestUpdates';
5
5
  import { withAppGoogleServices } from './withAppGoogleServices';
6
6
  import { withGistMavenRepository } from './withGistMavenRepository';
7
7
  import { withGoogleServicesJSON } from './withGoogleServicesJSON';
8
+ import { withMainApplicationModifications } from './withMainApplicationModifications';
8
9
  import { withNotificationChannelMetadata } from './withNotificationChannelMetadata';
9
10
  import { withProjectGoogleServices } from './withProjectGoogleServices';
10
11
  import { withProjectStrings } from './withProjectStrings';
11
12
 
12
13
  export function withCIOAndroid(
13
14
  config: ExpoConfig,
15
+ sdkConfig: NativeSDKConfig | undefined,
14
16
  props: CustomerIOPluginOptionsAndroid
15
17
  ): ExpoConfig {
16
18
  config = withGistMavenRepository(config, props);
@@ -24,6 +26,10 @@ export function withCIOAndroid(
24
26
  if (props.pushNotification?.channel) {
25
27
  config = withNotificationChannelMetadata(config, props);
26
28
  }
29
+ // Add auto initialization if sdkConfig is provided
30
+ if (sdkConfig) {
31
+ config = withMainApplicationModifications(config, sdkConfig);
32
+ }
27
33
 
28
34
  return config;
29
35
  }
@@ -1,5 +1,5 @@
1
- import { withProjectBuildGradle } from '@expo/config-plugins';
2
1
  import type { ConfigPlugin } from '@expo/config-plugins';
2
+ import { withProjectBuildGradle } from '@expo/config-plugins';
3
3
 
4
4
  import { FileManagement } from './../helpers/utils/fileManagement';
5
5
  import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
@@ -20,7 +20,7 @@ export const withGoogleServicesJSON: ConfigPlugin<
20
20
  googleServicesFile,
21
21
  `${androidPath}/app/google-services.json`
22
22
  );
23
- } catch (e) {
23
+ } catch {
24
24
  console.log(
25
25
  `There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`
26
26
  );
@@ -0,0 +1,50 @@
1
+ import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins';
2
+ import { withMainApplication } from '@expo/config-plugins';
3
+ import type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';
4
+ import { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';
5
+ import { PLATFORM } from '../helpers/constants/common';
6
+ import { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';
7
+ import type { NativeSDKConfig } from '../types/cio-types';
8
+ import { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';
9
+
10
+ export const withMainApplicationModifications: ConfigPlugin<NativeSDKConfig> = (configOuter, sdkConfig) => {
11
+ return withMainApplication(configOuter, async (config) => {
12
+ const content = setupCustomerIOSDKInitializer(config, sdkConfig);
13
+ config.modResults.contents = content;
14
+ return config;
15
+ });
16
+ };
17
+
18
+ /**
19
+ * Setup CustomerIOSDKInitializer for Android auto initialization
20
+ */
21
+ const setupCustomerIOSDKInitializer = (
22
+ config: ExportedConfigWithProps<ApplicationProjectFile>,
23
+ sdkConfig: NativeSDKConfig,
24
+ ): string => {
25
+ const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';
26
+ const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';
27
+
28
+ const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;
29
+ const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;
30
+
31
+ let content = config.modResults.contents;
32
+
33
+ try {
34
+ // Always regenerate the CustomerIOSDKInitializer file to reflect config changes
35
+ copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, (content) =>
36
+ patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig)
37
+ );
38
+ // Add import if not already present
39
+ content = addImportToFile(content, SDK_INITIALIZER_IMPORT);
40
+ // Add initialization code to onCreate if not already present
41
+ if (!content.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {
42
+ content = addCodeToMethod(content, CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);
43
+ }
44
+ } catch (error) {
45
+ console.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);
46
+ return config.modResults.contents;
47
+ }
48
+
49
+ return content;
50
+ };