customerio-expo-plugin 2.7.1 → 2.7.3

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 (106) hide show
  1. package/package.json +4 -3
  2. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +5 -4
  3. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
  4. package/plugin/lib/commonjs/android/withAppGoogleServices.js +2 -1
  5. package/plugin/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
  6. package/plugin/lib/commonjs/android/withCIOAndroid.js +17 -11
  7. package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -1
  8. package/plugin/lib/commonjs/android/withGistMavenRepository.js +2 -1
  9. package/plugin/lib/commonjs/android/withGistMavenRepository.js.map +1 -1
  10. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +4 -3
  11. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  12. package/plugin/lib/commonjs/android/withMainApplicationModifications.js +2 -1
  13. package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -1
  14. package/plugin/lib/commonjs/helpers/utils/fileManagement.js +5 -4
  15. package/plugin/lib/commonjs/helpers/utils/fileManagement.js.map +1 -1
  16. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +2 -1
  17. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  18. package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js +5 -1
  19. package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js.map +1 -1
  20. package/plugin/lib/commonjs/index.js +3 -11
  21. package/plugin/lib/commonjs/index.js.map +1 -1
  22. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +2 -1
  23. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
  24. package/plugin/lib/commonjs/ios/withCIOIos.js +7 -3
  25. package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
  26. package/plugin/lib/commonjs/ios/withCIOIosSwift.js +11 -10
  27. package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
  28. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +8 -7
  29. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
  30. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +29 -23
  31. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  32. package/plugin/lib/commonjs/utils/android.js +2 -1
  33. package/plugin/lib/commonjs/utils/android.js.map +1 -1
  34. package/plugin/lib/commonjs/utils/config.js +3 -2
  35. package/plugin/lib/commonjs/utils/config.js.map +1 -1
  36. package/plugin/lib/commonjs/utils/logger.js +35 -0
  37. package/plugin/lib/commonjs/utils/logger.js.map +1 -0
  38. package/plugin/lib/commonjs/utils/validation.js +68 -25
  39. package/plugin/lib/commonjs/utils/validation.js.map +1 -1
  40. package/plugin/lib/commonjs/utils/xcode.js +2 -1
  41. package/plugin/lib/commonjs/utils/xcode.js.map +1 -1
  42. package/plugin/lib/module/android/withAndroidManifestUpdates.js +6 -4
  43. package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
  44. package/plugin/lib/module/android/withAppGoogleServices.js +2 -1
  45. package/plugin/lib/module/android/withAppGoogleServices.js.map +1 -1
  46. package/plugin/lib/module/android/withCIOAndroid.js +17 -11
  47. package/plugin/lib/module/android/withCIOAndroid.js.map +1 -1
  48. package/plugin/lib/module/android/withGistMavenRepository.js +2 -1
  49. package/plugin/lib/module/android/withGistMavenRepository.js.map +1 -1
  50. package/plugin/lib/module/android/withGoogleServicesJSON.js +4 -3
  51. package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  52. package/plugin/lib/module/android/withMainApplicationModifications.js +2 -1
  53. package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -1
  54. package/plugin/lib/module/helpers/utils/fileManagement.js +6 -5
  55. package/plugin/lib/module/helpers/utils/fileManagement.js.map +1 -1
  56. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +2 -1
  57. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  58. package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js +5 -1
  59. package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js.map +1 -1
  60. package/plugin/lib/module/index.js +3 -12
  61. package/plugin/lib/module/index.js.map +1 -1
  62. package/plugin/lib/module/ios/withAppDelegateModifications.js +2 -1
  63. package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
  64. package/plugin/lib/module/ios/withCIOIos.js +7 -3
  65. package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
  66. package/plugin/lib/module/ios/withCIOIosSwift.js +11 -10
  67. package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
  68. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +8 -7
  69. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
  70. package/plugin/lib/module/ios/withNotificationsXcodeProject.js +29 -23
  71. package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  72. package/plugin/lib/module/utils/android.js +2 -1
  73. package/plugin/lib/module/utils/android.js.map +1 -1
  74. package/plugin/lib/module/utils/config.js +4 -2
  75. package/plugin/lib/module/utils/config.js.map +1 -1
  76. package/plugin/lib/module/utils/logger.js +29 -0
  77. package/plugin/lib/module/utils/logger.js.map +1 -0
  78. package/plugin/lib/module/utils/validation.js +68 -27
  79. package/plugin/lib/module/utils/validation.js.map +1 -1
  80. package/plugin/lib/module/utils/xcode.js +2 -1
  81. package/plugin/lib/module/utils/xcode.js.map +1 -1
  82. package/plugin/lib/typescript/android/withCIOAndroid.d.ts +1 -1
  83. package/plugin/lib/typescript/ios/withCIOIos.d.ts +1 -1
  84. package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +1 -1
  85. package/plugin/lib/typescript/utils/logger.d.ts +8 -0
  86. package/plugin/lib/typescript/utils/validation.d.ts +6 -3
  87. package/plugin/src/android/withAndroidManifestUpdates.ts +5 -4
  88. package/plugin/src/android/withAppGoogleServices.ts +2 -1
  89. package/plugin/src/android/withCIOAndroid.ts +18 -12
  90. package/plugin/src/android/withGistMavenRepository.ts +3 -2
  91. package/plugin/src/android/withGoogleServicesJSON.ts +4 -3
  92. package/plugin/src/android/withMainApplicationModifications.ts +2 -1
  93. package/plugin/src/helpers/utils/fileManagement.ts +10 -9
  94. package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +2 -1
  95. package/plugin/src/helpers/utils/patchPluginNativeCode.ts +6 -1
  96. package/plugin/src/index.ts +3 -13
  97. package/plugin/src/ios/withAppDelegateModifications.ts +2 -1
  98. package/plugin/src/ios/withCIOIos.ts +12 -8
  99. package/plugin/src/ios/withCIOIosSwift.ts +15 -14
  100. package/plugin/src/ios/withGoogleServicesJsonFile.ts +8 -7
  101. package/plugin/src/ios/withNotificationsXcodeProject.ts +31 -35
  102. package/plugin/src/utils/android.ts +2 -1
  103. package/plugin/src/utils/config.ts +3 -2
  104. package/plugin/src/utils/logger.ts +37 -0
  105. package/plugin/src/utils/validation.ts +96 -32
  106. package/plugin/src/utils/xcode.ts +2 -1
@@ -1 +1 @@
1
- {"version":3,"names":["withXcodeProject","CIO_NOTIFICATION_TARGET_NAME","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","DEFAULT_BUNDLE_VERSION","replaceCodeByRegex","injectCIONotificationPodfileCode","getIosNativeFilesPath","FileManagement","isExpoVersion53OrHigher","isFcmPushProvider","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","isExpo53OrHigher","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","console","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","iosPath","appName","modifiedProjectFile","modResults","_options$pushNotifica2","isFcmProvider","pbxTargetByName","warn","nsePath","mkdir","recursive","platformSpecificFiles","commonFiles","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","env","extGroup","addPbxGroup","groups","hash","project","objects","PBXGroup","Object","keys","key","name","path","addToPbxGroup","uuid","projObjects","PBXTargetDependency","PBXContainerItemProxy","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","writeFile","envFileName","richPushConfig","CDP_API_KEY_RE","REGION_RE","envFileContent","cdpApiKey","region","regionMap","us","eu","mappedRegion","toLowerCase","sourceFile","targetFileName","appPath","exists","log","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","_options$pushNotifica3","_options$pushNotifica4","_options$pushNotifica5","_options$pushNotifica6","_options$pushNotifica7","REGISTER_RE","disableNotificationRegistration","snippet","toUpperCase","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';\nimport { withXcodeProject } from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS, RichPushConfig } from '../types/cio-types';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport { isExpoVersion53OrHigher, isFcmPushProvider } from './utils';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\nconst ENV_FILENAME = 'Env.swift';\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n isExpo53OrHigher: boolean,\n) => {\n try {\n // PushService file is only needed for pre-Expo 53 code generation\n if (options.pushNotification && !isExpo53OrHigher) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush === true) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: unknown) {\n console.error(error);\n return null;\n }\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget, useFrameworks } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'\n );\n\n // projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\n );\n }\n\n const options = {\n ...props,\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n } satisfies CustomerIOPluginOptionsIOS;\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults,\n isExpoVersion53OrHigher(configOuter),\n );\n\n if (modifiedProjectFile) {\n config.modResults = modifiedProjectFile;\n }\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n const isFcmProvider = isFcmPushProvider(options);\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);\n\n // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const platformSpecificFiles = ['NotificationService.swift'];\n\n const commonFiles = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n // Copy platform-specific files\n platformSpecificFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${isFcmProvider ? 'fcm' : 'apn'\n }/${filename}`,\n targetFile\n );\n });\n\n // Copy common files\n commonFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/common/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(getTargetFile(ENV_FILENAME), options.pushNotification?.env);\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n [...platformSpecificFiles, ...commonFiles], // Combine platform-specific and common files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects.PBXGroup;\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined && groups[key].path === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects.PBXTargetDependency = projObjects.PBXTargetDependency || {};\n projObjects.PBXContainerItemProxy = projObjects.PBXTargetDependency || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift', 'Env.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget || '15.1';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n\nconst updateNseEnv = (\n envFileName: string,\n richPushConfig?: RichPushConfig\n) => {\n const CDP_API_KEY_RE = /\\{\\{CDP_API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n // Use merged config values (config takes precedence over env)\n const cdpApiKey = richPushConfig?.cdpApiKey;\n const region = richPushConfig?.region;\n\n if (!cdpApiKey) {\n throw new Error(\n 'NotificationServiceExtension failed: cdpApiKey missing. Provide in config.cdpApiKey or ios.pushNotification.env.cdpApiKey.'\n );\n }\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n cdpApiKey\n );\n\n if (region) {\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n };\n const mappedRegion =\n regionMap[region.toLowerCase() as keyof typeof regionMap] || '';\n if (!mappedRegion) {\n console.warn(\n `${region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`\n );\n } else {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n REGION_RE,\n mappedRegion\n );\n }\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject\n) {\n // Maybe copy a different file with FCM config based on config\n const { iosPath, appName } = options;\n const isFcmProvider = isFcmPushProvider(options);\n // PushService.swift is platform-specific and always lives in the platform folder\n const sourceFile = `${isFcmProvider ? 'fcm' : 'apn'}/PushService.swift`;\n const targetFileName = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(targetFileName);\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(targetFileName))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${sourceFile}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(targetFileName)} already exists. Skipping...`);\n return;\n }\n\n updatePushFile(options, targetFile);\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);\n}\n\nconst updatePushFile = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const REGISTER_RE = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n const disableNotificationRegistration =\n options.pushNotification?.disableNotificationRegistration;\n const { cdpApiKey, region } = options.pushNotification?.env || {\n cdpApiKey: undefined,\n region: undefined,\n };\n if (!cdpApiKey) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.pushNotification.env.cdpApiKey is missing from app.config.js or app.json.'\n );\n }\n\n let snippet = '';\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{CDP_API_KEY\\}\\}/,\n cdpApiKey\n );\n\n if (region) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{REGION\\}\\}/,\n region.toUpperCase()\n );\n }\n\n const autoTrackPushEvents =\n options.pushNotification?.autoTrackPushEvents !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n options.pushNotification?.autoFetchDeviceToken !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n options.pushNotification?.showPushAppInForeground !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QA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A2G,sBAAA,uBAAxBA,sBAAA,CAA0BO,mBAAmB,MAAK,KAAK;EACzD5B,cAAc,GAAGpG,kBAAkB,CACjCoG,cAAc,EACd,gCAAgC,EAChC4B,mBAAmB,CAACC,QAAQ,CAAC,CAC/B,CAAC;EAED,MAAMC,oBAAoB,GACxB,EAAAR,sBAAA,GAAAhH,OAAO,CAACI,gBAAgB,cAAA4G,sBAAA,uBAAxBA,sBAAA,CAA0BQ,oBAAoB,MAAK,KAAK;EAC1D9B,cAAc,GAAGpG,kBAAkB,CACjCoG,cAAc,EACd,iCAAiC,EACjC8B,oBAAoB,CAACD,QAAQ,CAAC,CAChC,CAAC;EAED,MAAME,uBAAuB,GAC3B,EAAAR,sBAAA,GAAAjH,OAAO,CAACI,gBAAgB,cAAA6G,sBAAA,uBAAxBA,sBAAA,CAA0BQ,uBAAuB,MAAK,KAAK;EAC7D/B,cAAc,GAAGpG,kBAAkB,CACjCoG,cAAc,EACd,qCAAqC,EACrC+B,uBAAuB,CAACF,QAAQ,CAAC,CACnC,CAAC;EAED9H,cAAc,CAAC4F,SAAS,CAACC,WAAW,EAAEI,cAAc,CAAC;AACvD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withXcodeProject","CIO_NOTIFICATION_TARGET_NAME","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","DEFAULT_BUNDLE_VERSION","replaceCodeByRegex","injectCIONotificationPodfileCode","logger","getIosNativeFilesPath","validateRichPushConfig","FileManagement","isExpoVersion53OrHigher","isFcmPushProvider","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","isExpo53OrHigher","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","String","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","iosPath","appName","modifiedProjectFile","modResults","_options$pushNotifica2","isFcmProvider","pbxTargetByName","warn","nsePath","mkdir","recursive","platformSpecificFiles","commonFiles","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","env","extGroup","addPbxGroup","groups","hash","project","objects","PBXGroup","Object","keys","key","name","path","addToPbxGroup","uuid","projObjects","PBXTargetDependency","PBXContainerItemProxy","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","writeFile","envFileName","richPushConfig","CDP_API_KEY_RE","REGION_RE","envFileContent","cdpApiKey","region","regionKey","toLowerCase","regionMap","us","eu","mappedRegion","sourceFile","targetFileName","appPath","exists","info","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","_options$pushNotifica3","_options$pushNotifica4","_options$pushNotifica5","_options$pushNotifica6","_options$pushNotifica7","REGISTER_RE","disableNotificationRegistration","snippet","toUpperCase","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';\nimport { withXcodeProject } from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS, RichPushConfig } from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { validateRichPushConfig } from '../utils/validation';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport { isExpoVersion53OrHigher, isFcmPushProvider } from './utils';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\nconst ENV_FILENAME = 'Env.swift';\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n isExpo53OrHigher: boolean,\n) => {\n try {\n // PushService file is only needed for pre-Expo 53 code generation\n if (options.pushNotification && !isExpo53OrHigher) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush === true) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: unknown) {\n logger.error(String(error));\n return null;\n }\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget, useFrameworks } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'\n );\n\n // projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\n );\n }\n\n const options = {\n ...props,\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n } satisfies CustomerIOPluginOptionsIOS;\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults,\n isExpoVersion53OrHigher(configOuter),\n );\n\n if (modifiedProjectFile) {\n config.modResults = modifiedProjectFile;\n }\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n const isFcmProvider = isFcmPushProvider(options);\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);\n\n // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const platformSpecificFiles = ['NotificationService.swift'];\n\n const commonFiles = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n // Copy platform-specific files\n platformSpecificFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${isFcmProvider ? 'fcm' : 'apn'\n }/${filename}`,\n targetFile\n );\n });\n\n // Copy common files\n commonFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/common/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(getTargetFile(ENV_FILENAME), options.pushNotification?.env);\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n [...platformSpecificFiles, ...commonFiles], // Combine platform-specific and common files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects.PBXGroup;\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined && groups[key].path === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects.PBXTargetDependency = projObjects.PBXTargetDependency || {};\n projObjects.PBXContainerItemProxy = projObjects.PBXTargetDependency || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift', 'Env.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget || '15.1';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n\nconst updateNseEnv = (\n envFileName: string,\n richPushConfig?: RichPushConfig\n) => {\n const CDP_API_KEY_RE = /\\{\\{CDP_API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n // Use merged config values (config takes precedence over env)\n const cdpApiKey = richPushConfig?.cdpApiKey;\n const region = richPushConfig?.region;\n\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n cdpApiKey || 'MISSING_API_KEY',\n );\n\n // Simplify region mapping with case insensitive keys and fallback for invalid regions\n const regionKey = region?.toLowerCase() ?? '';\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n } as const;\n const mappedRegion = regionMap[regionKey as keyof typeof regionMap];\n if (!mappedRegion) {\n logger.warn(\n `${regionKey} is an invalid region. Please use the values from the docs: https://docs.customer.io/integrations/sdk/expo/getting-started/packages-options/#configuring-the-expo-plugin`\n );\n // Fallback to US if invalid region provided\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, regionMap.us);\n } else {\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, mappedRegion);\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject\n) {\n // Maybe copy a different file with FCM config based on config\n const { iosPath, appName } = options;\n const isFcmProvider = isFcmPushProvider(options);\n // PushService.swift is platform-specific and always lives in the platform folder\n const sourceFile = `${isFcmProvider ? 'fcm' : 'apn'}/PushService.swift`;\n const targetFileName = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(targetFileName);\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(targetFileName))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${sourceFile}`,\n targetFile\n );\n } else {\n logger.info(`${getTargetFile(targetFileName)} already exists. Skipping...`);\n return;\n }\n\n updatePushFile(options, targetFile);\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);\n}\n\nconst updatePushFile = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const REGISTER_RE = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n const disableNotificationRegistration =\n options.pushNotification?.disableNotificationRegistration;\n const richPushConfig = options.pushNotification?.env;\n const { cdpApiKey, region } = richPushConfig || {\n cdpApiKey: 'MISSING_API_KEY',\n region: undefined,\n };\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n\n let snippet = '';\n // unless this property is explicitly set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{CDP_API_KEY\\}\\}/,\n cdpApiKey,\n );\n\n if (region) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{REGION\\}\\}/,\n region.toUpperCase()\n );\n }\n\n const autoTrackPushEvents =\n options.pushNotification?.autoTrackPushEvents !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n options.pushNotification?.autoFetchDeviceToken !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n options.pushNotification?.showPushAppInForeground !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showP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CAACsG,cAAc,EAAEyB,WAAW,EAAEE,OAAO,CAAC;EAEzE3B,cAAc,GAAGtG,kBAAkB,CACjCsG,cAAc,EACd,qBAAqB,EACrBC,SACF,CAAC;EAED,IAAIC,MAAM,EAAE;IACVF,cAAc,GAAGtG,kBAAkB,CACjCsG,cAAc,EACd,gBAAgB,EAChBE,MAAM,CAAC0B,WAAW,CAAC,CACrB,CAAC;EACH;EAEA,MAAMC,mBAAmB,GACvB,EAAAP,sBAAA,GAAAhH,OAAO,CAACI,gBAAgB,cAAA4G,sBAAA,uBAAxBA,sBAAA,CAA0BO,mBAAmB,MAAK,KAAK;EACzD7B,cAAc,GAAGtG,kBAAkB,CACjCsG,cAAc,EACd,gCAAgC,EAChC6B,mBAAmB,CAACC,QAAQ,CAAC,CAC/B,CAAC;EAED,MAAMC,oBAAoB,GACxB,EAAAR,sBAAA,GAAAjH,OAAO,CAACI,gBAAgB,cAAA6G,sBAAA,uBAAxBA,sBAAA,CAA0BQ,oBAAoB,MAAK,KAAK;EAC1D/B,cAAc,GAAGtG,kBAAkB,CACjCsG,cAAc,EACd,iCAAiC,EACjC+B,oBAAoB,CAACD,QAAQ,CAAC,CAChC,CAAC;EAED,MAAME,uBAAuB,GAC3B,EAAAR,sBAAA,GAAAlH,OAAO,CAACI,gBAAgB,cAAA8G,sBAAA,uBAAxBA,sBAAA,CAA0BQ,uBAAuB,MAAK,KAAK;EAC7DhC,cAAc,GAAGtG,kBAAkB,CACjCsG,cAAc,EACd,qCAAqC,EACrCgC,uBAAuB,CAACF,QAAQ,CAAC,CACnC,CAAC;EAED/H,cAAc,CAAC4F,SAAS,CAACC,WAAW,EAAEI,cAAc,CAAC;AACvD,CAAC","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  import path from 'path';
2
2
  import { FileManagement } from '../helpers/utils/fileManagement';
3
+ import { logger } from './logger';
3
4
  import { getAndroidNativeFilesPath } from './plugin';
4
5
 
5
6
  // Generic utility to add import to Kotlin files
@@ -93,7 +94,7 @@ export const copyTemplateFile = (expoConfig, filename, classPackage, patchConten
93
94
  const destinationPath = path.join(packagePath, filename);
94
95
  FileManagement.writeFile(destinationPath, content);
95
96
  } catch (error) {
96
- console.warn(`Failed to copy ${filename} to Android project:`, error);
97
+ logger.warn(`Failed to copy ${filename} to Android project:`, error);
97
98
  throw error;
98
99
  }
99
100
  };
@@ -1 +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,OAAOD,OAAO;EAChB;EAEA,MAAMG,WAAW,GAAG,yBAAyB;EAC7C,MAAMC,OAAO,GAAG,CAAC,GAAGJ,OAAO,CAACK,QAAQ,CAACF,WAAW,CAAC,CAAC;EAElD,IAAIC,OAAO,CAACE,MAAM,KAAK,CAAC,EAAE;IACxB,MAAMC,YAAY,GAAG,2BAA2B;IAChD,MAAMC,YAAY,GAAGR,OAAO,CAACS,KAAK,CAACF,YAAY,CAAC;IAChD,IAAI,CAACC,YAAY,EAAE,OAAOR,OAAO;IAEjC,MAAMU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D,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":[]}
1
+ {"version":3,"names":["path","FileManagement","logger","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","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 { logger } from './logger';\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 logger.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,MAAM,QAAQ,UAAU;AACjC,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,OAAOD,OAAO;EAChB;EAEA,MAAMG,WAAW,GAAG,yBAAyB;EAC7C,MAAMC,OAAO,GAAG,CAAC,GAAGJ,OAAO,CAACK,QAAQ,CAACF,WA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O,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;EAE9E,IAAI;IACF9D,cAAc,CAAC+D,KAAK,CAACF,WAAW,EAAE;MAAEG,SAAS,EAAE;IAAK,CAAC,CAAC;IACtD,MAAMC,UAAU,GAAGlE,IAAI,CAAC6D,IAAI,CAAC1D,yBAAyB,CAAC,CAAC,EAAEoD,QAAQ,CAAC;IACnE,MAAMlD,OAAO,GAAGoD,YAAY,CAACxD,cAAc,CAACkE,QAAQ,CAACD,UAAU,CAAC,CAAC;IACjE,MAAME,eAAe,GAAGpE,IAAI,CAAC6D,IAAI,CAACC,WAAW,EAAEP,QAAQ,CAAC;IACxDtD,cAAc,CAACoE,SAAS,CAACD,eAAe,EAAE/D,OAAO,CAAC;EACpD,CAAC,CAAC,OAAOiE,KAAK,EAAE;IACdpE,MAAM,CAACqE,IAAI,CAAC,kBAAkBhB,QAAQ,sBAAsB,EAAEe,KAAK,CAAC;IACpE,MAAMA,KAAK;EACb;AACF,CAAC","ignoreList":[]}
@@ -1,3 +1,5 @@
1
+ import { logger } from './logger';
2
+
1
3
  /**
2
4
  * Merges config values with env values for backward compatibility.
3
5
  * If env is provided, it takes precedence. If nativeConfig is provided but env is not,
@@ -15,12 +17,12 @@ function mergeConfigWithEnvValues(props, nativeConfig) {
15
17
  if (nativeCdpApiKey && envCdpApiKey) {
16
18
  if (nativeCdpApiKey !== envCdpApiKey || (nativeRegion === null || nativeRegion === void 0 ? void 0 : nativeRegion.toLowerCase()) !== (envRegion === null || envRegion === void 0 ? void 0 : envRegion.toLowerCase())) {
17
19
  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);
20
+ logger.error(errorMessage);
19
21
  throw new Error(errorMessage);
20
22
  }
21
23
 
22
24
  // 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.`);
25
+ logger.warn(`Both 'config' and 'ios.pushNotification.env' are provided with matching values. ` + `Consider removing 'ios.pushNotification.env' since 'config' is already specified.`);
24
26
  }
25
27
 
26
28
  // Return config (values are guaranteed to be the same if both exist)
@@ -1 +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":[]}
1
+ {"version":3,"names":["logger","mergeConfigWithEnvValues","props","nativeConfig","_props$pushNotificati","nativeCdpApiKey","cdpApiKey","nativeRegion","region","envConfig","pushNotification","env","envCdpApiKey","envRegion","toLowerCase","errorMessage","error","Error","warn","undefined"],"sources":["config.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS, NativeSDKConfig, RichPushConfig } from '../types/cio-types';\nimport { logger } from './logger';\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 logger.error(errorMessage);\n throw new Error(errorMessage);\n }\n\n // Values match - warn about redundant configuration\n logger.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":"AACA,SAASA,MAAM,QAAQ,UAAU;;AAEjC;AACA;AACA;AACA;AACA;AACA,SAASC,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;MAEhCb,MAAM,CAACgB,KAAK,CAACD,YAAY,CAAC;MAC1B,MAAM,IAAIE,KAAK,CAACF,YAAY,CAAC;IAC/B;;IAEA;IACAf,MAAM,CAACkB,IAAI,CACT,kFAAkF,GAClF,mFACF,CAAC;EACH;;EAEA;EACA,MAAMZ,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,OAAOW,SAAS;AAClB;AAEA,SAASlB,wBAAwB","ignoreList":[]}
@@ -0,0 +1,29 @@
1
+ // Use CUSTOMERIO_DEBUG_MODE if defined; otherwise enable in development mode only
2
+ const VERBOSE_MODE = process.env.CUSTOMERIO_DEBUG_MODE !== undefined ? process.env.CUSTOMERIO_DEBUG_MODE === 'true' : process.env.NODE_ENV === 'development';
3
+ const PREFIX = '[CustomerIO]';
4
+ const formatMessage = message => `${PREFIX} ${message}`;
5
+ export const logger = {
6
+ format: formatMessage,
7
+ error: (message, ...args) => {
8
+ console.error(formatMessage(message), ...args);
9
+ },
10
+ warn: (message, ...args) => {
11
+ console.warn(formatMessage(message), ...args);
12
+ },
13
+ info: (message, ...args) => {
14
+ if (VERBOSE_MODE) {
15
+ console.info(formatMessage(message), ...args);
16
+ }
17
+ },
18
+ log: (message, ...args) => {
19
+ if (VERBOSE_MODE) {
20
+ console.log(formatMessage(message), ...args);
21
+ }
22
+ },
23
+ debug: (message, ...args) => {
24
+ if (VERBOSE_MODE) {
25
+ console.debug(formatMessage(message), ...args);
26
+ }
27
+ }
28
+ };
29
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["VERBOSE_MODE","process","env","CUSTOMERIO_DEBUG_MODE","undefined","NODE_ENV","PREFIX","formatMessage","message","logger","format","error","args","console","warn","info","log","debug"],"sources":["logger.ts"],"sourcesContent":["// Use CUSTOMERIO_DEBUG_MODE if defined; otherwise enable in development mode only\nconst VERBOSE_MODE =\n process.env.CUSTOMERIO_DEBUG_MODE !== undefined\n ? process.env.CUSTOMERIO_DEBUG_MODE === 'true'\n : process.env.NODE_ENV === 'development';\nconst PREFIX = '[CustomerIO]';\nconst formatMessage = (message: string): string => `${PREFIX} ${message}`;\n\nexport const logger = {\n format: formatMessage,\n\n error: (message: string, ...args: unknown[]): void => {\n console.error(formatMessage(message), ...args);\n },\n\n warn: (message: string, ...args: unknown[]): void => {\n console.warn(formatMessage(message), ...args);\n },\n\n info: (message: string, ...args: unknown[]): void => {\n if (VERBOSE_MODE) {\n console.info(formatMessage(message), ...args);\n }\n },\n\n log: (message: string, ...args: unknown[]): void => {\n if (VERBOSE_MODE) {\n console.log(formatMessage(message), ...args);\n }\n },\n\n debug: (message: string, ...args: unknown[]): void => {\n if (VERBOSE_MODE) {\n console.debug(formatMessage(message), ...args);\n }\n }\n};\n"],"mappings":"AAAA;AACA,MAAMA,YAAY,GAChBC,OAAO,CAACC,GAAG,CAACC,qBAAqB,KAAKC,SAAS,GAC3CH,OAAO,CAACC,GAAG,CAACC,qBAAqB,KAAK,MAAM,GAC5CF,OAAO,CAACC,GAAG,CAACG,QAAQ,KAAK,aAAa;AAC5C,MAAMC,MAAM,GAAG,cAAc;AAC7B,MAAMC,aAAa,GAAIC,OAAe,IAAa,GAAGF,MAAM,IAAIE,OAAO,EAAE;AAEzE,OAAO,MAAMC,MAAM,GAAG;EACpBC,MAAM,EAAEH,aAAa;EAErBI,KAAK,EAAEA,CAACH,OAAe,EAAE,GAAGI,IAAe,KAAW;IACpDC,OAAO,CAACF,KAAK,CAACJ,aAAa,CAACC,OAAO,CAAC,EAAE,GAAGI,IAAI,CAAC;EAChD,CAAC;EAEDE,IAAI,EAAEA,CAACN,OAAe,EAAE,GAAGI,IAAe,KAAW;IACnDC,OAAO,CAACC,IAAI,CAACP,aAAa,CAACC,OAAO,CAAC,EAAE,GAAGI,IAAI,CAAC;EAC/C,CAAC;EAEDG,IAAI,EAAEA,CAACP,OAAe,EAAE,GAAGI,IAAe,KAAW;IACnD,IAAIZ,YAAY,EAAE;MAChBa,OAAO,CAACE,IAAI,CAACR,aAAa,CAACC,OAAO,CAAC,EAAE,GAAGI,IAAI,CAAC;IAC/C;EACF,CAAC;EAEDI,GAAG,EAAEA,CAACR,OAAe,EAAE,GAAGI,IAAe,KAAW;IAClD,IAAIZ,YAAY,EAAE;MAChBa,OAAO,CAACG,GAAG,CAACT,aAAa,CAACC,OAAO,CAAC,EAAE,GAAGI,IAAI,CAAC;IAC9C;EACF,CAAC;EAEDK,KAAK,EAAEA,CAACT,OAAe,EAAE,GAAGI,IAAe,KAAW;IACpD,IAAIZ,YAAY,EAAE;MAChBa,OAAO,CAACI,KAAK,CAACV,aAAa,CAACC,OAAO,CAAC,EAAE,GAAGI,IAAI,CAAC;IAChD;EACF;AACF,CAAC","ignoreList":[]}
@@ -1,39 +1,80 @@
1
- function validateRequired(value, fieldName, context) {
2
- if (value === undefined || value === null) {
3
- throw new Error(`${context}: ${fieldName} is required, received: ${value}`);
1
+ import { logger } from './logger';
2
+
3
+ /**
4
+ * Validates a condition and handles errors based on CUSTOMERIO_STRICT_MODE flag.
5
+ * @param isValid - Function that returns true if validation passes
6
+ * @param messageFactory - Function that returns the error message if validation fails
7
+ * @returns true if validation passes, false if it fails
8
+ */
9
+ function validate(isValid, messageFactory) {
10
+ if (isValid()) {
11
+ return true;
12
+ }
13
+
14
+ // Throw errors unless explicitly disabled, default to strict validation
15
+ const message = messageFactory();
16
+ // Throw an error if strict mode is enabled, log a warning otherwise
17
+ if (process.env.CUSTOMERIO_STRICT_MODE === 'true') {
18
+ throw new Error(logger.format(message));
19
+ } else {
20
+ logger.warn(message);
4
21
  }
22
+ return false;
23
+ }
24
+ function isUndefined(value) {
25
+ return value === undefined;
26
+ }
27
+ function validateRequired(value, fieldName, context) {
28
+ return validate(() => !isUndefined(value) && value !== null, () => `${context}: ${fieldName} is required, received: ${value}`);
5
29
  }
6
30
  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
- }
31
+ return validate(() => isUndefined(value) || typeof value === 'string' && value.trim() !== '', () => `${context}: ${fieldName} must be a non-empty string, received: ${typeof value === 'string' ? `"${value}"` : value}`);
10
32
  }
11
33
  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
- }
34
+ return validate(() => isUndefined(value) || typeof value === 'boolean', () => `${context}: ${fieldName} must be a boolean, received: ${value}`);
15
35
  }
16
36
  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}`);
37
+ if (isUndefined(value)) return true;
38
+
39
+ // First validate it's a string
40
+ if (!validateString(value, fieldName, context)) {
41
+ return false;
24
42
  }
43
+
44
+ // Then validate it's in the allowed values
45
+ return validate(() => {
46
+ const lowerValue = value.toLowerCase();
47
+ const lowerAllowedValues = allowedValues.map(v => v.toLowerCase());
48
+ return lowerAllowedValues.includes(lowerValue);
49
+ }, () => {
50
+ const valuesStr = allowedValues.map(v => `"${v}"`).join(', ');
51
+ return `${context}: ${fieldName} must be one of ${valuesStr}, received: ${value}`;
52
+ });
53
+ }
54
+ function validateRegion(value, fieldName, context) {
55
+ return validateEnum(value, fieldName, ['US', 'EU'], context);
25
56
  }
26
57
  function validateNativeSDKConfig(config) {
27
58
  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 };
59
+ let isValid = true;
60
+ isValid = validateRequired(config.cdpApiKey, 'cdpApiKey', context) && isValid;
61
+ isValid = validateString(config.cdpApiKey, 'cdpApiKey', context) && isValid;
62
+ isValid = validateRegion(config.region, 'region', context) && isValid;
63
+ isValid = validateEnum(config.screenViewUse, 'screenViewUse', ['all', 'inapp'], context) && isValid;
64
+ isValid = validateEnum(config.logLevel, 'logLevel', ['none', 'error', 'info', 'debug'], context) && isValid;
65
+ isValid = validateBoolean(config.autoTrackDeviceAttributes, 'autoTrackDeviceAttributes', context) && isValid;
66
+ isValid = validateBoolean(config.trackApplicationLifecycleEvents, 'trackApplicationLifecycleEvents', context) && isValid;
67
+ isValid = validateString(config.siteId, 'siteId', context) && isValid;
68
+ isValid = validateString(config.migrationSiteId, 'migrationSiteId', context) && isValid;
69
+ return isValid;
70
+ }
71
+ function validateRichPushConfig(config) {
72
+ const context = 'NotificationServiceExtension';
73
+ let isValid = true;
74
+ isValid = validateRequired(config === null || config === void 0 ? void 0 : config.cdpApiKey, 'cdpApiKey', context) && isValid;
75
+ isValid = validateString(config === null || config === void 0 ? void 0 : config.cdpApiKey, 'cdpApiKey', context) && isValid;
76
+ isValid = validateRegion(config === null || config === void 0 ? void 0 : config.region, 'region', context) && isValid;
77
+ return isValid;
78
+ }
79
+ export { validateNativeSDKConfig, validateRequired, validateRichPushConfig, validateString };
39
80
  //# sourceMappingURL=validation.js.map
@@ -1 +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,YAAYA,CACnBR,KAAc,EACdC,SAAiB,EACjBQ,aAA2B,EAC3BP,OAAe,EACT;EACN,IAAIF,KAAK,KAAKG,SAAS,EAAE;EAEzBE,cAAc,CAACL,KAAK,EAAEC,SAAS,EAAEC,OAAO,CAAC;EAEzC,MAAMQ,UAAU,GAAIV,KAAK,CAAYW,WAAW,CAAC,CAAC;EAClD,MAAMC,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OAAO,CAAC;AACpE;AAEA,SAASgB,uBAAuB","ignoreList":[]}
1
+ {"version":3,"names":["logger","validate","isValid","messageFactory","message","process","env","CUSTOMERIO_STRICT_MODE","Error","format","warn","isUndefined","value","undefined","validateRequired","fieldName","context","validateString","trim","validateBoolean","validateEnum","allowedValues","lowerValue","toLowerCase","lowerAllowedValues","map","v","includes","valuesStr","join","validateRegion","validateNativeSDKConfig","config","cdpApiKey","region","screenViewUse","logLevel","autoTrackDeviceAttributes","trackApplicationLifecycleEvents","siteId","migrationSiteId","validateRichPushConfig"],"sources":["validation.ts"],"sourcesContent":["import type { NativeSDKConfig, RichPushConfig } from '../types/cio-types';\nimport { logger } from './logger';\n\n/**\n * Validates a condition and handles errors based on CUSTOMERIO_STRICT_MODE flag.\n * @param isValid - Function that returns true if validation passes\n * @param messageFactory - Function that returns the error message if validation fails\n * @returns true if validation passes, false if it fails\n */\nfunction validate(isValid: () => boolean, messageFactory: () => string): boolean {\n if (isValid()) {\n return true;\n }\n\n // Throw errors unless explicitly disabled, default to strict validation\n const message = messageFactory();\n // Throw an error if strict mode is enabled, log a warning otherwise\n if (process.env.CUSTOMERIO_STRICT_MODE === 'true') {\n throw new Error(logger.format(message));\n } else {\n logger.warn(message);\n }\n return false;\n}\n\nfunction isUndefined(value: unknown): boolean {\n return value === undefined;\n}\n\nfunction validateRequired(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => !isUndefined(value) && value !== null,\n () => `${context}: ${fieldName} is required, received: ${value}`\n );\n}\n\nfunction validateString(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => isUndefined(value) || (typeof value === 'string' && value.trim() !== ''),\n () => `${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): boolean {\n return validate(\n () => isUndefined(value) || typeof value === 'boolean',\n () => `${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): boolean {\n if (isUndefined(value)) return true;\n\n // First validate it's a string\n if (!validateString(value, fieldName, context)) {\n return false;\n }\n\n // Then validate it's in the allowed values\n return validate(\n () => {\n const lowerValue = (value as string).toLowerCase();\n const lowerAllowedValues = allowedValues.map(v => v.toLowerCase());\n return lowerAllowedValues.includes(lowerValue);\n },\n () => {\n const valuesStr = allowedValues.map(v => `\"${v}\"`).join(', ');\n return `${context}: ${fieldName} must be one of ${valuesStr}, received: ${value}`;\n }\n );\n}\n\nfunction validateRegion(value: unknown, fieldName: string, context: string): boolean {\n return validateEnum(value, fieldName, ['US', 'EU'], context);\n}\n\nfunction validateNativeSDKConfig(config: NativeSDKConfig): boolean {\n const context = 'NativeSDKConfig';\n\n let isValid = true;\n\n isValid = validateRequired(config.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateString(config.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateRegion(config.region, 'region', context) && isValid;\n isValid = validateEnum(config.screenViewUse, 'screenViewUse', ['all', 'inapp'], context) && isValid;\n isValid = validateEnum(config.logLevel, 'logLevel', ['none', 'error', 'info', 'debug'], context) && isValid;\n isValid = validateBoolean(config.autoTrackDeviceAttributes, 'autoTrackDeviceAttributes', context) && isValid;\n isValid = validateBoolean(config.trackApplicationLifecycleEvents, 'trackApplicationLifecycleEvents', context) && isValid;\n isValid = validateString(config.siteId, 'siteId', context) && isValid;\n isValid = validateString(config.migrationSiteId, 'migrationSiteId', context) && isValid;\n\n return isValid;\n}\n\nfunction validateRichPushConfig(config: RichPushConfig | undefined): boolean {\n const context = 'NotificationServiceExtension';\n\n let isValid = true;\n\n isValid = validateRequired(config?.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateString(config?.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateRegion(config?.region, 'region', context) && isValid;\n\n return isValid;\n}\n\nexport {\n validateNativeSDKConfig,\n validateRequired,\n validateR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B,OAAO,CAAC,IAAId,OAAO;EAC5EA,OAAO,GAAG4B,cAAc,CAACE,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEE,MAAM,EAAE,QAAQ,EAAElB,OAAO,CAAC,IAAId,OAAO;EAEtE,OAAOA,OAAO;AAChB;AAEA,SACE6B,uBAAuB,EACvBjB,gBAAgB,EAChB2B,sBAAsB,EACtBxB,cAAc","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  import path from 'path';
2
2
  import { FileManagement } from "../helpers/utils/fileManagement";
3
+ import { logger } from './logger';
3
4
 
4
5
  /**
5
6
  * Gets an existing CustomerIO group or creates a new one in the Xcode project
@@ -53,7 +54,7 @@ export function copyFileToXcode({
53
54
  xcodeProject.addSourceFile(`${projectName}/${targetFileName}`, null, customerIOGroup);
54
55
  return destinationPath;
55
56
  } catch (error) {
56
- console.warn(`Failed to add ${targetFileName} to Xcode project:`, error);
57
+ logger.warn(`Failed to add ${targetFileName} to Xcode project:`, error);
57
58
  throw error;
58
59
  }
59
60
  }
@@ -1 +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
+ {"version":3,"names":["path","FileManagement","logger","getOrCreateCustomerIOGroup","xcodeProject","projectName","customerIOGroup","pbxGroupByName","pbxCreateGroup","projectGroupKey","findPBXGroupKey","name","addToPbxGroup","copyFileToXcode","iosProjectRoot","sourceFilePath","targetFileName","transform","destinationPath","join","content","readFile","writeFile","addSourceFile","error","warn"],"sources":["xcode.ts"],"sourcesContent":["import type { XcodeProject } from \"@expo/config-plugins\";\nimport path from 'path';\nimport { FileManagement } from \"../helpers/utils/fileManagement\";\nimport { logger } from './logger';\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 logger.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;AAChE,SAASC,MAAM,QAAQ,UAAU;;AAEjC;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,GAAGlB,IAAI,CAACmB,IAAI,CAC/BL,cAAc,EACdT,WAAW,EACXW,cACF,CAAC;EAED,IAAI;IACF;IACA,MAAMI,OAAO,GAAGH,SAAS,CAAChB,cAAc,CAACoB,QAAQ,CAACN,cAAc,CAAC,CAAC;IAClEd,cAAc,CAACqB,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;IACdtB,MAAM,CAACuB,IAAI,CAAC,iBAAiBT,cAAc,oBAAoB,EAAEQ,KAAK,CAAC;IACvE,MAAMA,KAAK;EACb;AACF","ignoreList":[]}
@@ -1,3 +1,3 @@
1
1
  import type { ExpoConfig } from '@expo/config-types';
2
2
  import type { CustomerIOPluginOptionsAndroid, NativeSDKConfig } from '../types/cio-types';
3
- export declare function withCIOAndroid(config: ExpoConfig, sdkConfig: NativeSDKConfig | undefined, props: CustomerIOPluginOptionsAndroid): ExpoConfig;
3
+ export declare function withCIOAndroid(config: ExpoConfig, sdkConfig?: NativeSDKConfig, props?: CustomerIOPluginOptionsAndroid): ExpoConfig;
@@ -1,3 +1,3 @@
1
1
  import type { ExpoConfig } from '@expo/config-types';
2
2
  import type { CustomerIOPluginOptionsIOS, NativeSDKConfig } from '../types/cio-types';
3
- export declare function withCIOIos(config: ExpoConfig, sdkConfig: NativeSDKConfig | undefined, props: CustomerIOPluginOptionsIOS): ExpoConfig;
3
+ export declare function withCIOIos(config: ExpoConfig, sdkConfig?: NativeSDKConfig, props?: CustomerIOPluginOptionsIOS): ExpoConfig;
@@ -1,3 +1,3 @@
1
1
  import type { ExpoConfig } from '@expo/config-types';
2
2
  import type { CustomerIOPluginOptionsIOS, NativeSDKConfig } from '../types/cio-types';
3
- export declare const withCIOIosSwift: (configOuter: ExpoConfig, sdkConfig: NativeSDKConfig | undefined, props: CustomerIOPluginOptionsIOS) => ExpoConfig;
3
+ export declare const withCIOIosSwift: (configOuter: ExpoConfig, sdkConfig?: NativeSDKConfig, props?: CustomerIOPluginOptionsIOS) => ExpoConfig;
@@ -0,0 +1,8 @@
1
+ export declare const logger: {
2
+ format: (message: string) => string;
3
+ error: (message: string, ...args: unknown[]) => void;
4
+ warn: (message: string, ...args: unknown[]) => void;
5
+ info: (message: string, ...args: unknown[]) => void;
6
+ log: (message: string, ...args: unknown[]) => void;
7
+ debug: (message: string, ...args: unknown[]) => void;
8
+ };
@@ -1,3 +1,6 @@
1
- import type { NativeSDKConfig } from '../types/cio-types';
2
- declare function validateNativeSDKConfig(config: NativeSDKConfig): void;
3
- export { validateNativeSDKConfig };
1
+ import type { NativeSDKConfig, RichPushConfig } from '../types/cio-types';
2
+ declare function validateRequired(value: unknown, fieldName: string, context: string): boolean;
3
+ declare function validateString(value: unknown, fieldName: string, context: string): boolean;
4
+ declare function validateNativeSDKConfig(config: NativeSDKConfig): boolean;
5
+ declare function validateRichPushConfig(config: RichPushConfig | undefined): boolean;
6
+ export { validateNativeSDKConfig, validateRequired, validateRichPushConfig, validateString };
@@ -3,6 +3,7 @@ import { withAndroidManifest } from '@expo/config-plugins';
3
3
  import type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';
4
4
 
5
5
  import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
6
+ import { logger } from '../utils/logger';
6
7
 
7
8
  // Default low priority for Firebase messaging service when setHighPriorityPushHandler is false
8
9
  export const DEFAULT_LOW_PRIORITY = -10;
@@ -41,7 +42,7 @@ export const withAndroidManifestUpdates: ConfigPlugin<
41
42
  // Handle priority based on setHighPriorityPushHandler value
42
43
  if (options.setHighPriorityPushHandler === true) {
43
44
  // High priority - no priority attribute means default high priority
44
- console.log(
45
+ logger.info(
45
46
  'Successfully set CustomerIO push handler as high priority in AndroidManifest.xml'
46
47
  );
47
48
  } else if (options.setHighPriorityPushHandler === false) {
@@ -49,7 +50,7 @@ export const withAndroidManifestUpdates: ConfigPlugin<
49
50
  intentFilter.$ = {
50
51
  'android:priority': DEFAULT_LOW_PRIORITY.toString(),
51
52
  };
52
- console.log(
53
+ logger.info(
53
54
  `Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`
54
55
  );
55
56
  }
@@ -70,7 +71,7 @@ export const withAndroidManifestUpdates: ConfigPlugin<
70
71
  const intentFilter = existingService['intent-filter'][0] as any;
71
72
  if (intentFilter.$ && intentFilter.$['android:priority']) {
72
73
  delete intentFilter.$['android:priority'];
73
- console.log(
74
+ logger.info(
74
75
  'Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml'
75
76
  );
76
77
  }
@@ -87,7 +88,7 @@ export const withAndroidManifestUpdates: ConfigPlugin<
87
88
  intentFilter.$ = {};
88
89
  }
89
90
  intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();
90
- console.log(
91
+ logger.info(
91
92
  `Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`
92
93
  );
93
94
  }
@@ -6,6 +6,7 @@ import {
6
6
  CIO_APP_GOOGLE_SNIPPET,
7
7
  } from '../helpers/constants/android';
8
8
  import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
9
+ import { logger } from '../utils/logger';
9
10
 
10
11
  export const withAppGoogleServices: ConfigPlugin<
11
12
  CustomerIOPluginOptionsAndroid
@@ -19,7 +20,7 @@ export const withAppGoogleServices: ConfigPlugin<
19
20
  `$1\n${CIO_APP_GOOGLE_SNIPPET}`
20
21
  );
21
22
  } else {
22
- console.log('app/build.gradle snippet already exists. Skipping...');
23
+ logger.info('app/build.gradle snippet already exists. Skipping...');
23
24
  }
24
25
 
25
26
  return props;