customerio-expo-plugin 2.5.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -31
- package/plugin/app.plugin.js +1 -1
- package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +56 -15
- package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/commonjs/android/withCIOAndroid.js +7 -2
- package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -1
- package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +1 -1
- package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js +45 -0
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -0
- package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js +1 -1
- package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js.map +1 -1
- package/plugin/lib/commonjs/android/withProjectStrings.js +14 -7
- package/plugin/lib/commonjs/android/withProjectStrings.js.map +1 -1
- package/plugin/lib/commonjs/helpers/constants/android.js +7 -1
- package/plugin/lib/commonjs/helpers/constants/android.js.map +1 -1
- package/plugin/lib/commonjs/helpers/constants/common.js +18 -0
- package/plugin/lib/commonjs/helpers/constants/common.js.map +1 -0
- package/plugin/lib/commonjs/helpers/constants/ios.js +7 -7
- package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -1
- package/plugin/lib/commonjs/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +2 -2
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js +62 -0
- package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js.map +1 -0
- package/plugin/lib/commonjs/index.js +13 -2
- package/plugin/lib/commonjs/index.js.map +1 -1
- package/plugin/lib/commonjs/ios/utils.js +1 -1
- package/plugin/lib/commonjs/ios/utils.js.map +1 -1
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +1 -1
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIos.js +17 -11
- package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js +133 -49
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +1 -1
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +17 -19
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js +1 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/postInstallHelper.js.map +1 -1
- package/plugin/lib/commonjs/types/cio-types.js.map +1 -1
- package/plugin/lib/commonjs/utils/android.js +109 -0
- package/plugin/lib/commonjs/utils/android.js.map +1 -0
- package/plugin/lib/commonjs/utils/config.js +43 -0
- package/plugin/lib/commonjs/utils/config.js.map +1 -0
- package/plugin/lib/commonjs/utils/plugin.js +49 -0
- package/plugin/lib/commonjs/utils/plugin.js.map +1 -0
- package/plugin/lib/commonjs/utils/validation.js +44 -0
- package/plugin/lib/commonjs/utils/validation.js.map +1 -0
- package/plugin/lib/commonjs/utils/xcode.js +67 -0
- package/plugin/lib/commonjs/utils/xcode.js.map +1 -0
- package/plugin/lib/module/android/withAndroidManifestUpdates.js +55 -14
- package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/module/android/withCIOAndroid.js +7 -2
- package/plugin/lib/module/android/withCIOAndroid.js.map +1 -1
- package/plugin/lib/module/android/withGoogleServicesJSON.js +1 -1
- package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/module/android/withMainApplicationModifications.js +38 -0
- package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -0
- package/plugin/lib/module/android/withNotificationChannelMetadata.js +1 -1
- package/plugin/lib/module/android/withNotificationChannelMetadata.js.map +1 -1
- package/plugin/lib/module/android/withProjectStrings.js +13 -6
- package/plugin/lib/module/android/withProjectStrings.js.map +1 -1
- package/plugin/lib/module/helpers/constants/android.js +6 -0
- package/plugin/lib/module/helpers/constants/android.js.map +1 -1
- package/plugin/lib/module/helpers/constants/common.js +12 -0
- package/plugin/lib/module/helpers/constants/common.js.map +1 -0
- package/plugin/lib/module/helpers/constants/ios.js +6 -6
- package/plugin/lib/module/helpers/constants/ios.js.map +1 -1
- package/plugin/lib/module/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
- package/plugin/lib/module/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +2 -2
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js +57 -0
- package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js.map +1 -0
- package/plugin/lib/module/index.js +14 -2
- package/plugin/lib/module/index.js.map +1 -1
- package/plugin/lib/module/ios/utils.js +1 -2
- package/plugin/lib/module/ios/utils.js.map +1 -1
- package/plugin/lib/module/ios/withAppDelegateModifications.js +3 -3
- package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIos.js +17 -11
- package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIosSwift.js +134 -50
- package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +2 -2
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js +18 -20
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/module/ios/withXcodeProject.js +1 -1
- package/plugin/lib/module/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/module/postInstallHelper.js.map +1 -1
- package/plugin/lib/module/types/cio-types.js.map +1 -1
- package/plugin/lib/module/utils/android.js +100 -0
- package/plugin/lib/module/utils/android.js.map +1 -0
- package/plugin/lib/module/utils/config.js +38 -0
- package/plugin/lib/module/utils/config.js.map +1 -0
- package/plugin/lib/module/utils/plugin.js +38 -0
- package/plugin/lib/module/utils/plugin.js.map +1 -0
- package/plugin/lib/module/utils/validation.js +39 -0
- package/plugin/lib/module/utils/validation.js.map +1 -0
- package/plugin/lib/module/utils/xcode.js +60 -0
- package/plugin/lib/module/utils/xcode.js.map +1 -0
- package/plugin/lib/typescript/android/withAndroidManifestUpdates.d.ts +1 -0
- package/plugin/lib/typescript/android/withCIOAndroid.d.ts +2 -2
- package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +3 -0
- package/plugin/lib/typescript/android/withProjectStrings.d.ts +2 -1
- package/plugin/lib/typescript/helpers/constants/android.d.ts +3 -0
- package/plugin/lib/typescript/helpers/constants/common.d.ts +11 -0
- package/plugin/lib/typescript/helpers/constants/ios.d.ts +3 -1
- package/plugin/lib/typescript/helpers/utils/patchPluginNativeCode.d.ts +7 -0
- package/plugin/lib/typescript/ios/utils.d.ts +2 -2
- package/plugin/lib/typescript/ios/withCIOIos.d.ts +2 -2
- package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +3 -3
- package/plugin/lib/typescript/types/cio-types.d.ts +46 -6
- package/plugin/lib/typescript/utils/android.d.ts +5 -0
- package/plugin/lib/typescript/utils/config.d.ts +8 -0
- package/plugin/lib/typescript/utils/plugin.d.ts +4 -0
- package/plugin/lib/typescript/utils/validation.d.ts +3 -0
- package/plugin/lib/typescript/utils/xcode.d.ts +28 -0
- package/plugin/src/android/withAndroidManifestUpdates.ts +70 -21
- package/plugin/src/android/withCIOAndroid.ts +8 -2
- package/plugin/src/android/withGoogleServicesJSON.ts +2 -2
- package/plugin/src/android/withMainApplicationModifications.ts +50 -0
- package/plugin/src/android/withNotificationChannelMetadata.ts +7 -3
- package/plugin/src/android/withProjectStrings.ts +20 -10
- package/plugin/src/helpers/constants/android.ts +7 -0
- package/plugin/src/helpers/constants/common.ts +12 -0
- package/plugin/src/helpers/constants/ios.ts +11 -13
- package/plugin/src/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
- package/plugin/src/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
- package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +8 -7
- package/plugin/src/helpers/utils/patchPluginNativeCode.ts +97 -0
- package/plugin/src/index.ts +18 -2
- package/plugin/src/ios/utils.ts +5 -5
- package/plugin/src/ios/withAppDelegateModifications.ts +11 -8
- package/plugin/src/ios/withCIOIos.ts +19 -11
- package/plugin/src/ios/withCIOIosSwift.ts +195 -73
- package/plugin/src/ios/withGoogleServicesJsonFile.ts +7 -10
- package/plugin/src/ios/withNotificationsXcodeProject.ts +25 -26
- package/plugin/src/ios/withXcodeProject.ts +1 -1
- package/plugin/src/postInstallHelper.js +1 -1
- package/plugin/src/types/cio-types.ts +48 -8
- package/plugin/src/utils/android.ts +112 -0
- package/plugin/src/utils/config.ts +53 -0
- package/plugin/src/utils/plugin.ts +46 -0
- package/plugin/src/utils/validation.ts +54 -0
- package/plugin/src/utils/xcode.ts +74 -0
- package/plugin/lib/commonjs/helpers/constants/globals.d.js +0 -2
- package/plugin/lib/commonjs/helpers/constants/globals.d.js.map +0 -1
- package/plugin/lib/commonjs/helpers/utils/pluginUtils.js +0 -26
- package/plugin/lib/commonjs/helpers/utils/pluginUtils.js.map +0 -1
- package/plugin/lib/module/helpers/constants/globals.d.js +0 -2
- package/plugin/lib/module/helpers/constants/globals.d.js.map +0 -1
- package/plugin/lib/module/helpers/utils/pluginUtils.js +0 -19
- package/plugin/lib/module/helpers/utils/pluginUtils.js.map +0 -1
- package/plugin/lib/typescript/helpers/utils/pluginUtils.d.ts +0 -4
- package/plugin/src/helpers/constants/globals.d.ts +0 -8
- package/plugin/src/helpers/utils/pluginUtils.ts +0 -22
|
@@ -14,7 +14,7 @@ export async function injectCIOPodfileCode(iosPath, isFcmPushProvider) {
|
|
|
14
14
|
const lineInPodfileToInjectSnippetBefore = /post_install do \|installer\|/;
|
|
15
15
|
const snippetToInjectInPodfile = `
|
|
16
16
|
${blockStart}
|
|
17
|
-
pod 'customerio-reactnative/${isFcmPushProvider ?
|
|
17
|
+
pod 'customerio-reactnative/${isFcmPushProvider ? 'fcm' : 'apn'}', :path => '${getRelativePathToRNSDK(iosPath)}'
|
|
18
18
|
${blockEnd}
|
|
19
19
|
`.trim();
|
|
20
20
|
FileManagement.write(filename, injectCodeByRegex(podfile, lineInPodfileToInjectSnippetBefore, snippetToInjectInPodfile).join('\n'));
|
|
@@ -33,7 +33,7 @@ export async function injectCIONotificationPodfileCode(iosPath, useFrameworks, i
|
|
|
33
33
|
${blockStart}
|
|
34
34
|
target 'NotificationService' do
|
|
35
35
|
${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}
|
|
36
|
-
pod 'customerio-reactnative-richpush/${isFcmPushProvider ?
|
|
36
|
+
pod 'customerio-reactnative-richpush/${isFcmPushProvider ? 'fcm' : 'apn'}', :path => '${getRelativePathToRNSDK(iosPath)}'
|
|
37
37
|
end
|
|
38
38
|
${blockEnd}
|
|
39
39
|
`.trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getRelativePathToRNSDK","injectCodeByRegex","FileManagement","injectCIOPodfileCode","iosPath","isFcmPushProvider","blockStart","blockEnd","filename","podfile","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","snippetToInjectInPodfile","trim","write","join","console","log","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string
|
|
1
|
+
{"version":3,"names":["getRelativePathToRNSDK","injectCodeByRegex","FileManagement","injectCIOPodfileCode","iosPath","isFcmPushProvider","blockStart","blockEnd","filename","podfile","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","snippetToInjectInPodfile","trim","write","join","console","log","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(\n iosPath: string,\n isFcmPushProvider: boolean\n) {\n const blockStart = '# --- CustomerIO Host App START ---';\n const blockEnd = '# --- CustomerIO Host App END ---';\n\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n // We need to decide what line of code in the Podfile to insert our native code.\n // The \"post_install\" line is always present in an Expo project Podfile so it's reliable.\n // Find that line in the Podfile and then we will insert our code above that line.\n const lineInPodfileToInjectSnippetBefore = /post_install do \\|installer\\|/;\n\n const snippetToInjectInPodfile = `\n${blockStart}\n pod 'customerio-reactnative/${isFcmPushProvider ? 'fcm' : 'apn'\n }', :path => '${getRelativePathToRNSDK(iosPath)}'\n${blockEnd}\n`.trim();\n\n FileManagement.write(\n filename,\n injectCodeByRegex(\n podfile,\n lineInPodfileToInjectSnippetBefore,\n snippetToInjectInPodfile\n ).join('\\n')\n );\n } else {\n console.log('CustomerIO Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'],\n isFcmPushProvider: boolean\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n\n const blockStart = '# --- CustomerIO Notification START ---';\n const blockEnd = '# --- CustomerIO Notification END ---';\n\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n const snippetToInjectInPodfile = `\n${blockStart}\ntarget 'NotificationService' do\n ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}\n pod 'customerio-reactnative-richpush/${isFcmPushProvider ? 'fcm' : 'apn'\n }', :path => '${getRelativePathToRNSDK(iosPath)}'\nend\n${blockEnd}\n`.trim();\n\n FileManagement.append(filename, snippetToInjectInPodfile);\n }\n}\n"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,kBAAkB;AACzD,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,OAAO,eAAeC,oBAAoBA,CACxCC,OAAe,EACfC,iBAA0B,EAC1B;EACA,MAAMC,UAAU,GAAG,qCAAqC;EACxD,MAAMC,QAAQ,GAAG,mCAAmC;EAEpD,MAAMC,QAAQ,GAAG,GAAGJ,OAAO,UAAU;EACrC,MAAMK,OAAO,GAAG,MAAMP,cAAc,CAACQ,IAAI,CAACF,QAAQ,CAAC;EACnD,MAAMG,OAAO,GAAGF,OAAO,CAACG,KAAK,CAAC,IAAIC,MAAM,CAACP,UAAU,CAAC,CAAC;EAErD,IAAI,CAACK,OAAO,EAAE;IACZ;IACA;IACA;IACA,MAAMG,kCAAkC,GAAG,+BAA+B;IAE1E,MAAMC,wBAAwB,GAAG;AACrC,EAAET,UAAU;AACZ,gCAAgCD,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBAC3CL,sBAAsB,CAACI,OAAO,CAAC;AACrD,EAAEG,QAAQ;AACV,CAAC,CAACS,IAAI,CAAC,CAAC;IAEJd,cAAc,CAACe,KAAK,CAClBT,QAAQ,EACRP,iBAAiB,CACfQ,OAAO,EACPK,kCAAkC,EAClCC,wBACF,CAAC,CAACG,IAAI,CAAC,IAAI,CACb,CAAC;EACH,CAAC,MAAM;IACLC,OAAO,CAACC,GAAG,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEA,OAAO,eAAeC,gCAAgCA,CACpDjB,OAAe,EACfkB,aAA0D,EAC1DjB,iBAA0B,EAC1B;EACA,MAAMG,QAAQ,GAAG,GAAGJ,OAAO,UAAU;EACrC,MAAMK,OAAO,GAAG,MAAMP,cAAc,CAACQ,IAAI,CAACF,QAAQ,CAAC;EAEnD,MAAMF,UAAU,GAAG,yCAAyC;EAC5D,MAAMC,QAAQ,GAAG,uCAAuC;EAExD,MAAMI,OAAO,GAAGF,OAAO,CAACG,KAAK,CAAC,IAAIC,MAAM,CAACP,UAAU,CAAC,CAAC;EAErD,IAAI,CAACK,OAAO,EAAE;IACZ,MAAMI,wBAAwB,GAAG;AACrC,EAAET,UAAU;AACZ;AACA,IAAIgB,aAAa,KAAK,QAAQ,GAAG,qCAAqC,GAAG,EAAE;AAC3E,yCAAyCjB,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBACpDL,sBAAsB,CAACI,OAAO,CAAC;AACrD;AACA,EAAEG,QAAQ;AACV,CAAC,CAACS,IAAI,CAAC,CAAC;IAEJd,cAAc,CAACqB,MAAM,CAACf,QAAQ,EAAEO,wBAAwB,CAAC;EAC3D;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { PLATFORM } from '../constants/common';
|
|
2
|
+
import { getPluginVersion } from '../../utils/plugin';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shared utility function to perform common SDK config replacements
|
|
6
|
+
* for both iOS and Android template files
|
|
7
|
+
*/
|
|
8
|
+
export function patchNativeSDKInitializer(rawContent, platform, sdkConfig) {
|
|
9
|
+
var _siteId, _migrationSiteId;
|
|
10
|
+
let content = rawContent;
|
|
11
|
+
|
|
12
|
+
// Helper function to replace placeholders with platform-specific fallback values
|
|
13
|
+
const replaceValue = (placeholder, value, transform, fallback = platform === PLATFORM.ANDROID ? 'null' : 'nil') => {
|
|
14
|
+
if (value !== undefined && value !== null) {
|
|
15
|
+
content = content.replace(placeholder, transform(value));
|
|
16
|
+
} else {
|
|
17
|
+
content = content.replace(placeholder, fallback);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Replace EXPO_PLUGIN_VERSION with actual plugin version
|
|
22
|
+
const pluginVersion = getPluginVersion();
|
|
23
|
+
content = content.replace(/\{\{EXPO_PLUGIN_VERSION\}\}/g, pluginVersion);
|
|
24
|
+
|
|
25
|
+
// Replace CDP API Key (required field)
|
|
26
|
+
content = content.replace(/\{\{CDP_API_KEY\}\}/g, sdkConfig.cdpApiKey);
|
|
27
|
+
|
|
28
|
+
// Handle region - use empty string as fallback (nil not supported for region)
|
|
29
|
+
replaceValue(/\{\{REGION\}\}/g, sdkConfig.region, configValue => `"${configValue}"`, '""');
|
|
30
|
+
|
|
31
|
+
// Handle logLevel - use nil/null as fallback
|
|
32
|
+
replaceValue(/\{\{LOG_LEVEL\}\}/g, sdkConfig.logLevel, configValue => `"${configValue}"`);
|
|
33
|
+
|
|
34
|
+
// Handle optional boolean configurations
|
|
35
|
+
replaceValue(/\{\{AUTO_TRACK_DEVICE_ATTRIBUTES\}\}/g, sdkConfig.autoTrackDeviceAttributes, configValue => configValue.toString());
|
|
36
|
+
replaceValue(/\{\{TRACK_APPLICATION_LIFECYCLE_EVENTS\}\}/g, sdkConfig.trackApplicationLifecycleEvents, configValue => configValue.toString());
|
|
37
|
+
|
|
38
|
+
// Handle screenViewUse - use nil/null as fallback
|
|
39
|
+
replaceValue(/\{\{SCREEN_VIEW_USE\}\}/g, sdkConfig.screenViewUse, configValue => `"${configValue}"`);
|
|
40
|
+
|
|
41
|
+
// Handle siteId/migrationSiteId business logic
|
|
42
|
+
let siteId = sdkConfig.siteId;
|
|
43
|
+
let migrationSiteId = sdkConfig.migrationSiteId;
|
|
44
|
+
|
|
45
|
+
// Business rule: if only siteId provided, copy to migrationSiteId; if only migrationSiteId provided, set siteId to undefined
|
|
46
|
+
if (siteId && !migrationSiteId) {
|
|
47
|
+
migrationSiteId = siteId;
|
|
48
|
+
} else if (migrationSiteId && !siteId) {
|
|
49
|
+
siteId = undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Replace siteId and migrationSiteId placeholders (trim whitespace and handle empty strings)
|
|
53
|
+
replaceValue(/\{\{SITE_ID\}\}/g, ((_siteId = siteId) === null || _siteId === void 0 ? void 0 : _siteId.trim()) || undefined, configValue => `"${configValue}"`);
|
|
54
|
+
replaceValue(/\{\{MIGRATION_SITE_ID\}\}/g, ((_migrationSiteId = migrationSiteId) === null || _migrationSiteId === void 0 ? void 0 : _migrationSiteId.trim()) || undefined, configValue => `"${configValue}"`);
|
|
55
|
+
return content;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=patchPluginNativeCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PLATFORM","getPluginVersion","patchNativeSDKInitializer","rawContent","platform","sdkConfig","_siteId","_migrationSiteId","content","replaceValue","placeholder","value","transform","fallback","ANDROID","undefined","replace","pluginVersion","cdpApiKey","region","configValue","logLevel","autoTrackDeviceAttributes","toString","trackApplicationLifecycleEvents","screenViewUse","siteId","migrationSiteId","trim"],"sources":["patchPluginNativeCode.ts"],"sourcesContent":["import type { NativeSDKConfig } from '../../types/cio-types';\nimport { PLATFORM, type Platform } from '../constants/common';\nimport { getPluginVersion } from '../../utils/plugin';\n\n/**\n * Shared utility function to perform common SDK config replacements\n * for both iOS and Android template files\n */\nexport function patchNativeSDKInitializer(\n rawContent: string,\n platform: Platform,\n sdkConfig: NativeSDKConfig\n): string {\n let content = rawContent;\n\n // Helper function to replace placeholders with platform-specific fallback values\n const replaceValue = <T>(\n placeholder: RegExp,\n value: T | undefined,\n transform: (configValue: T) => string,\n fallback: string = platform === PLATFORM.ANDROID ? 'null' : 'nil'\n ) => {\n if (value !== undefined && value !== null) {\n content = content.replace(placeholder, transform(value));\n } else {\n content = content.replace(placeholder, fallback);\n }\n };\n\n // Replace EXPO_PLUGIN_VERSION with actual plugin version\n const pluginVersion = getPluginVersion();\n content = content.replace(/\\{\\{EXPO_PLUGIN_VERSION\\}\\}/g, pluginVersion);\n\n // Replace CDP API Key (required field)\n content = content.replace(/\\{\\{CDP_API_KEY\\}\\}/g, sdkConfig.cdpApiKey);\n\n // Handle region - use empty string as fallback (nil not supported for region)\n replaceValue(\n /\\{\\{REGION\\}\\}/g,\n sdkConfig.region,\n (configValue) => `\"${configValue}\"`,\n '\"\"'\n );\n\n // Handle logLevel - use nil/null as fallback\n replaceValue(\n /\\{\\{LOG_LEVEL\\}\\}/g,\n sdkConfig.logLevel,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle optional boolean configurations\n replaceValue(\n /\\{\\{AUTO_TRACK_DEVICE_ATTRIBUTES\\}\\}/g,\n sdkConfig.autoTrackDeviceAttributes,\n (configValue) => configValue.toString()\n );\n\n replaceValue(\n /\\{\\{TRACK_APPLICATION_LIFECYCLE_EVENTS\\}\\}/g,\n sdkConfig.trackApplicationLifecycleEvents,\n (configValue) => configValue.toString()\n );\n\n // Handle screenViewUse - use nil/null as fallback\n replaceValue(\n /\\{\\{SCREEN_VIEW_USE\\}\\}/g,\n sdkConfig.screenViewUse,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle siteId/migrationSiteId business logic\n let siteId = sdkConfig.siteId;\n let migrationSiteId = sdkConfig.migrationSiteId;\n\n // Business rule: if only siteId provided, copy to migrationSiteId; if only migrationSiteId provided, set siteId to undefined\n if (siteId && !migrationSiteId) {\n migrationSiteId = siteId;\n } else if (migrationSiteId && !siteId) {\n siteId = undefined;\n }\n\n // Replace siteId and migrationSiteId placeholders (trim whitespace and handle empty strings)\n replaceValue(\n /\\{\\{SITE_ID\\}\\}/g,\n siteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n replaceValue(\n /\\{\\{MIGRATION_SITE_ID\\}\\}/g,\n migrationSiteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n return content;\n}\n"],"mappings":"AACA,SAASA,QAAQ,QAAuB,qBAAqB;AAC7D,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CACvCC,UAAkB,EAClBC,QAAkB,EAClBC,SAA0B,EAClB;EAAA,IAAAC,OAAA,EAAAC,gBAAA;EACR,IAAIC,OAAO,GAAGL,UAAU;;EAExB;EACA,MAAMM,YAAY,GAAGA,CACnBC,WAAmB,EACnBC,KAAoB,EACpBC,SAAqC,EACrCC,QAAgB,GAAGT,QAAQ,KAAKJ,QAAQ,CAACc,OAAO,GAAG,MAAM,GAAG,KAAK,KAC9D;IACH,IAAIH,KAAK,KAAKI,SAAS,IAAIJ,KAAK,KAAK,IAAI,EAAE;MACzCH,OAAO,GAAGA,OAAO,CAACQ,OAAO,CAACN,WAAW,EAAEE,SAAS,CAACD,KAAK,CAAC,CAAC;IAC1D,CAAC,MAAM;MACLH,OAAO,GAAGA,OAAO,CAACQ,OAAO,CAACN,WAAW,EAAEG,QAAQ,CAAC;IAClD;EACF,CAAC;;EAED;EACA,MAAMI,aAAa,GAAGhB,gBAAgB,CAAC,CAAC;EACxCO,OAAO,GAAGA,OAAO,CAACQ,OAAO,CAAC,8BAA8B,EAAEC,aAAa,CAAC;;EAExE;EACAT,OAAO,GAAGA,OAAO,CAACQ,OAAO,CAAC,sBAAsB,EAAEX,SAAS,CAACa,SAAS,CAAC;;EAEtE;EACAT,YAAY,CACV,iBAAiB,EACjBJ,SAAS,CAACc,MAAM,EACfC,WAAW,IAAK,IAAIA,WAAW,GAAG,EACnC,IACF,CAAC;;EAED;EACAX,YAAY,CACV,oBAAoB,EACpBJ,SAAS,CAACgB,QAAQ,EACjBD,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;;EAED;EACAX,YAAY,CACV,uCAAuC,EACvCJ,SAAS,CAACiB,yBAAyB,EAClCF,WAAW,IAAKA,WAAW,CAACG,QAAQ,CAAC,CACxC,CAAC;EAEDd,YAAY,CACV,6CAA6C,EAC7CJ,SAAS,CAACmB,+BAA+B,EACxCJ,WAAW,IAAKA,WAAW,CAACG,QAAQ,CAAC,CACxC,CAAC;;EAED;EACAd,YAAY,CACV,0BAA0B,EAC1BJ,SAAS,CAACoB,aAAa,EACtBL,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;;EAED;EACA,IAAIM,MAAM,GAAGrB,SAAS,CAACqB,MAAM;EAC7B,IAAIC,eAAe,GAAGtB,SAAS,CAACsB,eAAe;;EAE/C;EACA,IAAID,MAAM,IAAI,CAACC,eAAe,EAAE;IAC9BA,eAAe,GAAGD,MAAM;EAC1B,CAAC,MAAM,IAAIC,eAAe,IAAI,CAACD,MAAM,EAAE;IACrCA,MAAM,GAAGX,SAAS;EACpB;;EAEA;EACAN,YAAY,CACV,kBAAkB,EAClB,EAAAH,OAAA,GAAAoB,MAAM,cAAApB,OAAA,uBAANA,OAAA,CAAQsB,IAAI,CAAC,CAAC,KAAIb,SAAS,EAC1BK,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;EAEDX,YAAY,CACV,4BAA4B,EAC5B,EAAAF,gBAAA,GAAAoB,eAAe,cAAApB,gBAAA,uBAAfA,gBAAA,CAAiBqB,IAAI,CAAC,CAAC,KAAIb,SAAS,EACnCK,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;EAED,OAAOZ,OAAO;AAChB","ignoreList":[]}
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { withCIOAndroid } from './android/withCIOAndroid';
|
|
2
|
+
import { isExpoVersion53OrHigher } from './ios/utils';
|
|
2
3
|
import { withCIOIos } from './ios/withCIOIos';
|
|
4
|
+
import { validateNativeSDKConfig } from './utils/validation';
|
|
5
|
+
|
|
3
6
|
// Entry point for config plugin
|
|
4
7
|
function withCustomerIOPlugin(config, props) {
|
|
8
|
+
// Check if config is being used with unsupported Expo version
|
|
9
|
+
if (props.config && !isExpoVersion53OrHigher(config)) {
|
|
10
|
+
throw new Error('CustomerIO auto initialization (config property) requires Expo SDK 53 or higher. ' + 'Please upgrade to Expo SDK 53+ or use manual initialization instead. ' + 'See documentation for manual setup instructions.');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Validate SDK config if provided
|
|
14
|
+
if (props.config) {
|
|
15
|
+
validateNativeSDKConfig(props.config);
|
|
16
|
+
}
|
|
5
17
|
if (props.ios) {
|
|
6
|
-
config = withCIOIos(config, props.ios);
|
|
18
|
+
config = withCIOIos(config, props.config, props.ios);
|
|
7
19
|
}
|
|
8
20
|
if (props.android) {
|
|
9
|
-
config = withCIOAndroid(config, props.android);
|
|
21
|
+
config = withCIOAndroid(config, props.config, props.android);
|
|
10
22
|
}
|
|
11
23
|
return config;
|
|
12
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withCIOAndroid","withCIOIos","withCustomerIOPlugin","config","props","ios","android"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type { CustomerIOPluginOptions } from './types/cio-types';\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n if (props.ios) {\n config = withCIOIos(config, props.ios);\n }\n\n if (props.android) {\n config = withCIOAndroid(config, props.android);\n }\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,QAAQ,kBAAkB;
|
|
1
|
+
{"version":3,"names":["withCIOAndroid","isExpoVersion53OrHigher","withCIOIos","validateNativeSDKConfig","withCustomerIOPlugin","config","props","Error","ios","android"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { isExpoVersion53OrHigher } from './ios/utils';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type { CustomerIOPluginOptions } from './types/cio-types';\nimport { validateNativeSDKConfig } from './utils/validation';\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n // Check if config is being used with unsupported Expo version\n if (props.config && !isExpoVersion53OrHigher(config)) {\n throw new Error(\n 'CustomerIO auto initialization (config property) requires Expo SDK 53 or higher. ' +\n 'Please upgrade to Expo SDK 53+ or use manual initialization instead. ' +\n 'See documentation for manual setup instructions.'\n );\n }\n\n // Validate SDK config if provided\n if (props.config) {\n validateNativeSDKConfig(props.config);\n }\n\n if (props.ios) {\n config = withCIOIos(config, props.config, props.ios);\n }\n\n if (props.android) {\n config = withCIOAndroid(config, props.config, props.android);\n }\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,uBAAuB,QAAQ,aAAa;AACrD,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,SAASC,uBAAuB,QAAQ,oBAAoB;;AAE5D;AACA,SAASC,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA;EACA,IAAIA,KAAK,CAACD,MAAM,IAAI,CAACJ,uBAAuB,CAACI,MAAM,CAAC,EAAE;IACpD,MAAM,IAAIE,KAAK,CACb,mFAAmF,GACnF,uEAAuE,GACvE,kDACF,CAAC;EACH;;EAEA;EACA,IAAID,KAAK,CAACD,MAAM,EAAE;IAChBF,uBAAuB,CAACG,KAAK,CAACD,MAAM,CAAC;EACvC;EAEA,IAAIC,KAAK,CAACE,GAAG,EAAE;IACbH,MAAM,GAAGH,UAAU,CAACG,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACE,GAAG,CAAC;EACtD;EAEA,IAAIF,KAAK,CAACG,OAAO,EAAE;IACjBJ,MAAM,GAAGL,cAAc,CAACK,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACG,OAAO,CAAC;EAC9D;EAEA,OAAOJ,MAAM;AACf;AAEA,eAAeD,oBAAoB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["semver","isFcmPushProvider","iosOptions","_iosOptions$pushNotif","pushNotification","provider","isExpoVersion53OrHigher","config","sdkVersion","validVersion","valid","coerce","gte"],"sources":["utils.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"names":["semver","isFcmPushProvider","iosOptions","_iosOptions$pushNotif","pushNotification","provider","isExpoVersion53OrHigher","config","sdkVersion","validVersion","valid","coerce","gte"],"sources":["utils.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\nimport * as semver from 'semver';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\n/**\n * Returns true if FCM is configured to be used as push provider\n * @param iosOptions The plugin iOS configuration options\n * @returns true if FCM is configured to be used as push provider\n */\nexport const isFcmPushProvider = (\n iosOptions?: CustomerIOPluginOptionsIOS\n): boolean => {\n return iosOptions?.pushNotification?.provider === 'fcm';\n};\n\nexport const isExpoVersion53OrHigher = (config: ExpoConfig): boolean => {\n const sdkVersion = config.sdkVersion || '';\n\n // If sdkVersion is not a valid semver, coerce it to a valid one if possible\n const validVersion = semver.valid(sdkVersion) || semver.coerce(sdkVersion);\n\n // If we couldn't get a valid version, return false\n if (!validVersion) return false;\n\n // Check if the version is greater than or equal to 53.0.0\n return semver.gte(validVersion, '53.0.0');\n};\n"],"mappings":"AACA,OAAO,KAAKA,MAAM,MAAM,QAAQ;AAGhC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAC5BC,UAAuC,IAC3B;EAAA,IAAAC,qBAAA;EACZ,OAAO,CAAAD,UAAU,aAAVA,UAAU,gBAAAC,qBAAA,GAAVD,UAAU,CAAEE,gBAAgB,cAAAD,qBAAA,uBAA5BA,qBAAA,CAA8BE,QAAQ,MAAK,KAAK;AACzD,CAAC;AAED,OAAO,MAAMC,uBAAuB,GAAIC,MAAkB,IAAc;EACtE,MAAMC,UAAU,GAAGD,MAAM,CAACC,UAAU,IAAI,EAAE;;EAE1C;EACA,MAAMC,YAAY,GAAGT,MAAM,CAACU,KAAK,CAACF,UAAU,CAAC,IAAIR,MAAM,CAACW,MAAM,CAACH,UAAU,CAAC;;EAE1E;EACA,IAAI,CAACC,YAAY,EAAE,OAAO,KAAK;;EAE/B;EACA,OAAOT,MAAM,CAACY,GAAG,CAACH,YAAY,EAAE,QAAQ,CAAC;AAC3C,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { withAppDelegate } from '@expo/config-plugins';
|
|
2
2
|
import { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';
|
|
3
|
-
import { CIO_APPDELEGATEDECLARATION_REGEX, CIO_APPDELEGATEHEADER_IMPORT_SNIPPET, CIO_APPDELEGATEHEADER_REGEX, CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET, CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET, CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET,
|
|
4
|
-
import { injectCodeBeforeMultiLineRegex, injectCodeByLineNumber, injectCodeByMultiLineRegex, injectCodeByMultiLineRegexAndReplaceLine,
|
|
3
|
+
import { CIO_APPDELEGATEDECLARATION_REGEX, CIO_APPDELEGATEHEADER_IMPORT_SNIPPET, CIO_APPDELEGATEHEADER_REGEX, CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET, CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET, CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET, CIO_DEEPLINK_COMMENT_REGEX, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET, CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET, CIO_INITIALIZECIOSDK_SNIPPET, CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX, CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET, CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET, CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX, CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET } from '../helpers/constants/ios';
|
|
4
|
+
import { injectCodeBeforeMultiLineRegex, injectCodeByLineNumber, injectCodeByMultiLineRegex, injectCodeByMultiLineRegexAndReplaceLine, matchRegexExists, replaceCodeByRegex } from '../helpers/utils/codeInjection';
|
|
5
5
|
import { FileManagement } from '../helpers/utils/fileManagement';
|
|
6
6
|
import { isFcmPushProvider } from './utils';
|
|
7
7
|
const addImport = (stringContents, appName) => {
|
|
@@ -85,7 +85,7 @@ const addHandleDeeplinkInKilledState = stringContents => {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// Check if the app delegate is using RCTBridge or LaunchOptions
|
|
88
|
-
let snippet
|
|
88
|
+
let snippet;
|
|
89
89
|
let regex = CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;
|
|
90
90
|
if (matchRegexExists(stringContents, CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX)) {
|
|
91
91
|
snippet = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withAppDelegate","getAppDelegateHeaderFilePath","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_DEEPLINK_COMMENT_REGEX","CIO_INITIALIZECIOSDK_SNIPPET","injectCodeBeforeMultiLineRegex","injectCodeByLineNumber","injectCodeByMultiLineRegex","injectCodeByMultiLineRegexAndReplaceLine","replaceCodeByRegex","matchRegexExists","FileManagement","isFcmPushProvider","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","addNotificationHandlerDeclaration","addNotificationConfiguration","addInitializeNativeCioSdk","addHandleDeeplinkInKilledStateConfiguration","regex","addDidFailToRegisterForRemoteNotificationsWithError","addDidRegisterForRemoteNotificationsWithDeviceToken","addExpoNotificationsHeaderModification","addFirebaseDelegateForwardDeclarationIfNeeded","addAppdelegateHeaderModification","replace","interfaceDeclaration","_groupedDelegates","existingDelegates","includes","trim","addHandleDeeplinkInKilledState","snippet","withAppDelegateModifications","configOuter","props","config","modResults","contents","RegExp","modRequest","projectName","_props$pushNotificati","_props$pushNotificati2","headerPath","projectRoot","headerContent","read","write","pushNotification","disableNotificationRegistration","handleDeeplinkInKilledState","console","log"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_IMPORT_SNIPPET,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET,\n CIO_DEEPLINK_COMMENT_REGEX,\n CIO_INITIALIZECIOSDK_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeBeforeMultiLineRegex,\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n replaceCodeByRegex,\n matchRegexExists,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { isFcmPushProvider } from './utils';\n\nconst addImport = (stringContents: string, appName: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = getImportSnippet(appName);\n\n const match = stringContents.match(importRegex);\n let endOfMatchIndex: number;\n if (!match || match.index === undefined) {\n // No imports found, just add to start of file:\n endOfMatchIndex = 0;\n } else {\n // Add after first import:\n endOfMatchIndex = match.index + match[0].length;\n }\n\n stringContents = injectCodeByLineNumber(\n stringContents,\n endOfMatchIndex,\n addedImport\n );\n\n return stringContents;\n};\n\nconst addNotificationHandlerDeclaration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addNotificationConfiguration = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addInitializeNativeCioSdk = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_INITIALIZECIOSDK_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledStateConfiguration = (\n stringContents: string,\n regex: RegExp\n) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n regex,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET\n );\n\n return stringContents;\n};\n\n// Adds required import for Expo Notifications package in AppDelegate.\n// Required to call functions from the package.\nconst addExpoNotificationsHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n `\n#if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n#import <EXNotifications/EXNotificationCenterDelegate.h>\n#endif\n`\n );\n\n return stringContents;\n};\n\nconst addFirebaseDelegateForwardDeclarationIfNeeded = (stringContents: string) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n '@protocol FIRMessagingDelegate;'\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n // Add UNUserNotificationCenterDelegate if needed\n stringContents = stringContents.replace(\n CIO_APPDELEGATEHEADER_REGEX,\n (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {\n if (\n existingDelegates &&\n existingDelegates.includes(\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET\n )\n ) {\n // The AppDelegate declaration already includes UNUserNotificationCenterDelegate, so we don't need to modify it\n return match;\n } else if (existingDelegates) {\n // Other delegates exist, append ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration}<${existingDelegates}, ${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n } else {\n // No delegates exist, add ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration.trim()} <${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n }\n }\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledState = (stringContents: string) => {\n // Find if the deep link code snippet is already present\n if (matchRegexExists(stringContents, CIO_DEEPLINK_COMMENT_REGEX)) {\n return stringContents;\n }\n\n // Check if the app delegate is using RCTBridge or LaunchOptions\n let snippet = undefined;\n let regex = CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n if (\n matchRegexExists(\n stringContents,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;\n regex = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n } else if (\n matchRegexExists(\n stringContents,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET;\n }\n // Add code only if the app delegate is using RCTBridge or LaunchOptions\n if (snippet !== undefined) {\n stringContents = addHandleDeeplinkInKilledStateConfiguration(\n stringContents,\n regex\n );\n stringContents = replaceCodeByRegex(stringContents, regex, snippet);\n }\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withAppDelegate(configOuter, async (config) => {\n let stringContents = config.modResults.contents;\n const regex = new RegExp(\n `#import <${config.modRequest.projectName}-Swift.h>`\n );\n const match = stringContents.match(regex);\n\n if (!match) {\n const headerPath = getAppDelegateHeaderFilePath(\n config.modRequest.projectRoot\n );\n let headerContent = await FileManagement.read(headerPath);\n headerContent = addAppdelegateHeaderModification(headerContent);\n FileManagement.write(headerPath, headerContent);\n\n stringContents = addImport(\n stringContents,\n config.modRequest.projectName as string\n );\n stringContents = addNotificationHandlerDeclaration(stringContents);\n\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (props.pushNotification?.disableNotificationRegistration !== true) {\n stringContents = addNotificationConfiguration(stringContents);\n }\n\n stringContents = addInitializeNativeCioSdk(stringContents);\n\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n stringContents = addHandleDeeplinkInKilledState(stringContents);\n }\n\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);\n\n if (isFcmPushProvider(props)) {\n stringContents = addFirebaseDelegateForwardDeclarationIfNeeded(stringContents);\n }\n\n stringContents = addExpoNotificationsHeaderModification(stringContents);\n\n config.modResults.contents = stringContents;\n } else {\n console.log('Customerio AppDelegate changes already exist. Skipping...');\n }\n\n return config;\n });\n};\nfunction getImportSnippet(appName: string) {\n return `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <${appName}-Swift.h>\n `;\n}\n"],"mappings":"AACA,SAASA,eAAe,QAAQ,sBAAsB;AACtD,SAASC,4BAA4B,QAAQ,sCAAsC;AAEnF,SACEC,gCAAgC,EAChCC,oCAAoC,EACpCC,2BAA2B,EAC3BC,sDAAsD,EACtDC,2CAA2C,EAC3CC,yCAAyC,EACzCC,4CAA4C,EAC5CC,0DAA0D,EAC1DC,4DAA4D,EAC5DC,kCAAkC,EAClCC,0DAA0D,EAC1DC,4DAA4D,EAC5DC,gDAAgD,EAChDC,8CAA8C,EAC9CC,yCAAyC,EACzCC,8CAA8C,EAC9CC,0BAA0B,EAC1BC,4BAA4B,QACvB,0BAA0B;AACjC,SACEC,8BAA8B,EAC9BC,sBAAsB,EACtBC,0BAA0B,EAC1BC,wCAAwC,EACxCC,kBAAkB,EAClBC,gBAAgB,QACX,gCAAgC;AACvC,SAASC,cAAc,QAAQ,iCAAiC;AAEhE,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,MAAMC,SAAS,GAAGA,CAACC,cAAsB,EAAEC,OA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c,EACd+B,MAAM,CAACI,UAAU,CAACC,WACpB,CAAC;MACDpC,cAAc,GAAGU,iCAAiC,CAACV,cAAc,CAAC;;MAElE;MACA;MACA,IAAI,EAAAqC,qBAAA,GAAAP,KAAK,CAACc,gBAAgB,cAAAP,qBAAA,uBAAtBA,qBAAA,CAAwBQ,+BAA+B,MAAK,IAAI,EAAE;QACpE7C,cAAc,GAAGW,4BAA4B,CAACX,cAAc,CAAC;MAC/D;MAEAA,cAAc,GAAGY,yBAAyB,CAACZ,cAAc,CAAC;MAE1D,IAAI,EAAAsC,sBAAA,GAAAR,KAAK,CAACc,gBAAgB,cAAAN,sBAAA,uBAAtBA,sBAAA,CAAwBQ,2BAA2B,MAAK,IAAI,EAAE;QAChE9C,cAAc,GAAG0B,8BAA8B,CAAC1B,cAAc,CAAC;MACjE;MAEAA,cAAc,GACZe,mDAAmD,CAACf,cAAc,CAAC;MACrEA,cAAc,GACZgB,mDAAmD,CAAChB,cAAc,CAAC;MAErE,IAAIF,iBAAiB,CAACgC,KAAK,CAAC,EAAE;QAC5B9B,cAAc,GAAGkB,6CAA6C,CAAClB,cAAc,CAAC;MAChF;MAEAA,cAAc,GAAGiB,sCAAsC,CAACjB,cAAc,CAAC;MAEvE+B,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGjC,cAAc;IAC7C,CAAC,MAAM;MACL+C,OAAO,CAACC,GAAG,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOjB,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AACD,SAAS3B,gBAAgBA,CAACH,OAAe,EAAE;EACzC,OAAO;AACT;AACA;AACA,WAAWA,OAAO;AAClB,GAAG;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["withAppDelegate","getAppDelegateHeaderFilePath","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_DEEPLINK_COMMENT_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_INITIALIZECIOSDK_SNIPPET","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","injectCodeBeforeMultiLineRegex","injectCodeByLineNumber","injectCodeByMultiLineRegex","injectCodeByMultiLineRegexAndReplaceLine","matchRegexExists","replaceCodeByRegex","FileManagement","isFcmPushProvider","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","addNotificationHandlerDeclaration","addNotificationConfiguration","addInitializeNativeCioSdk","addHandleDeeplinkInKilledStateConfiguration","regex","addDidFailToRegisterForRemoteNotificationsWithError","addDidRegisterForRemoteNotificationsWithDeviceToken","addExpoNotificationsHeaderModification","addFirebaseDelegateForwardDeclarationIfNeeded","addAppdelegateHeaderModification","replace","interfaceDeclaration","_groupedDelegates","existingDelegates","includes","trim","addHandleDeeplinkInKilledState","snippet","withAppDelegateModifications","configOuter","props","config","modResults","contents","RegExp","modRequest","projectName","_props$pushNotificati","_props$pushNotificati2","headerPath","projectRoot","headerContent","read","write","pushNotification","disableNotificationRegistration","handleDeeplinkInKilledState","console","log"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_IMPORT_SNIPPET,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET,\n CIO_DEEPLINK_COMMENT_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_INITIALIZECIOSDK_SNIPPET,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeBeforeMultiLineRegex,\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n matchRegexExists,\n replaceCodeByRegex,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { isFcmPushProvider } from './utils';\n\nconst addImport = (stringContents: string, appName: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = getImportSnippet(appName);\n\n const match = stringContents.match(importRegex);\n let endOfMatchIndex: number;\n if (!match || match.index === undefined) {\n // No imports found, just add to start of file:\n endOfMatchIndex = 0;\n } else {\n // Add after first import:\n endOfMatchIndex = match.index + match[0].length;\n }\n\n stringContents = injectCodeByLineNumber(\n stringContents,\n endOfMatchIndex,\n addedImport\n );\n\n return stringContents;\n};\n\nconst addNotificationHandlerDeclaration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addNotificationConfiguration = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addInitializeNativeCioSdk = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_INITIALIZECIOSDK_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledStateConfiguration = (\n stringContents: string,\n regex: RegExp\n) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n regex,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET\n );\n\n return stringContents;\n};\n\n// Adds required import for Expo Notifications package in AppDelegate.\n// Required to call functions from the package.\nconst addExpoNotificationsHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n `\n#if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n#import <EXNotifications/EXNotificationCenterDelegate.h>\n#endif\n`\n );\n\n return stringContents;\n};\n\nconst addFirebaseDelegateForwardDeclarationIfNeeded = (\n stringContents: string\n) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n '@protocol FIRMessagingDelegate;'\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n // Add UNUserNotificationCenterDelegate if needed\n stringContents = stringContents.replace(\n CIO_APPDELEGATEHEADER_REGEX,\n (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {\n if (\n existingDelegates &&\n existingDelegates.includes(\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET\n )\n ) {\n // The AppDelegate declaration already includes UNUserNotificationCenterDelegate, so we don't need to modify it\n return match;\n } else if (existingDelegates) {\n // Other delegates exist, append ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration}<${existingDelegates}, ${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n } else {\n // No delegates exist, add ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration.trim()} <${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n }\n }\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledState = (stringContents: string) => {\n // Find if the deep link code snippet is already present\n if (matchRegexExists(stringContents, CIO_DEEPLINK_COMMENT_REGEX)) {\n return stringContents;\n }\n\n // Check if the app delegate is using RCTBridge or LaunchOptions\n let snippet;\n let regex = CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n if (\n matchRegexExists(\n stringContents,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;\n regex = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n } else if (\n matchRegexExists(\n stringContents,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET;\n }\n // Add code only if the app delegate is using RCTBridge or LaunchOptions\n if (snippet !== undefined) {\n stringContents = addHandleDeeplinkInKilledStateConfiguration(\n stringContents,\n regex\n );\n stringContents = replaceCodeByRegex(stringContents, regex, snippet);\n }\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withAppDelegate(configOuter, async (config) => {\n let stringContents = config.modResults.contents;\n const regex = new RegExp(\n `#import <${config.modRequest.projectName}-Swift.h>`\n );\n const match = stringContents.match(regex);\n\n if (!match) {\n const headerPath = getAppDelegateHeaderFilePath(\n config.modRequest.projectRoot\n );\n let headerContent = await FileManagement.read(headerPath);\n headerContent = addAppdelegateHeaderModification(headerContent);\n FileManagement.write(headerPath, headerContent);\n\n stringContents = addImport(\n stringContents,\n config.modRequest.projectName as string\n );\n stringContents = addNotificationHandlerDeclaration(stringContents);\n\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (props.pushNotification?.disableNotificationRegistration !== true) {\n stringContents = addNotificationConfiguration(stringContents);\n }\n\n stringContents = addInitializeNativeCioSdk(stringContents);\n\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n stringContents = addHandleDeeplinkInKilledState(stringContents);\n }\n\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);\n\n if (isFcmPushProvider(props)) {\n stringContents =\n addFirebaseDelegateForwardDeclarationIfNeeded(stringContents);\n }\n\n stringContents = addExpoNotificationsHeaderModification(stringContents);\n\n config.modResults.contents = stringContents;\n } else {\n console.log('Customerio AppDelegate changes already exist. Skipping...');\n }\n\n return config;\n });\n};\nfunction getImportSnippet(appName: string) {\n return `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <${appName}-Swift.h>\n `;\n}\n"],"mappings":"AACA,SAASA,eAAe,QAAQ,sBAAsB;AACtD,SAASC,4BAA4B,QAAQ,sCAAsC;AAEnF,SACEC,gCAAgC,EAChCC,oCAAoC,EACpCC,2BAA2B,EAC3BC,sDAAsD,EACtDC,2CAA2C,EAC3CC,yCAAyC,EACzCC,0BAA0B,EAC1BC,0DAA0D,EAC1DC,4DAA4D,EAC5DC,kCAAkC,EAClCC,0DAA0D,EAC1DC,4DAA4D,EAC5DC,4BAA4B,EAC5BC,gDAAgD,EAChDC,yCAAyC,EACzCC,8CAA8C,EAC9CC,4CAA4C,EAC5CC,8CAA8C,QACzC,0BAA0B;AACjC,SACEC,8BAA8B,EAC9BC,sBAAsB,EACtBC,0BAA0B,EAC1BC,wCAAwC,EACxCC,gBAAgB,EAChBC,kBAAkB,QACb,gCAAgC;AACvC,SAASC,cAAc,QAAQ,iCAAiC;AAEhE,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,MAAMC,SAAS,GAAGA,CAACC,cAAsB,EAAEC,OAAe,KAAK;EAC7D,MAAMC,WAAW,GAAG,mBAAmB;EACvC,MAAMC,WAAW,GAAGC,gBAAgB,CAACH,OAAO,CAAC;EAE7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,qBAAA,GAAAP,KAAK,CAACc,gBAAgB,cAAAP,qBAAA,uBAAtBA,qBAAA,CAAwBQ,+BAA+B,MAAK,IAAI,EAAE;QACpE7C,cAAc,GAAGW,4BAA4B,CAACX,cAAc,CAAC;MAC/D;MAEAA,cAAc,GAAGY,yBAAyB,CAACZ,cAAc,CAAC;MAE1D,IAAI,EAAAsC,sBAAA,GAAAR,KAAK,CAACc,gBAAgB,cAAAN,sBAAA,uBAAtBA,sBAAA,CAAwBQ,2BAA2B,MAAK,IAAI,EAAE;QAChE9C,cAAc,GAAG0B,8BAA8B,CAAC1B,cAAc,CAAC;MACjE;MAEAA,cAAc,GACZe,mDAAmD,CAACf,cAAc,CAAC;MACrEA,cAAc,GACZgB,mDAAmD,CAAChB,cAAc,CAAC;MAErE,IAAIF,iBAAiB,CAACgC,KAAK,CAAC,EAAE;QAC5B9B,cAAc,GACZkB,6CAA6C,CAAClB,cAAc,CAAC;MACjE;MAEAA,cAAc,GAAGiB,sCAAsC,CAACjB,cAAc,CAAC;MAEvE+B,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGjC,cAAc;IAC7C,CAAC,MAAM;MACL+C,OAAO,CAACC,GAAG,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOjB,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AACD,SAAS3B,gBAAgBA,CAACH,OAAe,EAAE;EACzC,OAAO;AACT;AACA;AACA,WAAWA,OAAO;AAClB,GAAG;AACH","ignoreList":[]}
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
+
import { mergeConfigWithEnvValues } from '../utils/config';
|
|
2
|
+
import { isExpoVersion53OrHigher } from './utils';
|
|
1
3
|
import { withAppDelegateModifications } from './withAppDelegateModifications';
|
|
4
|
+
import { withCIOIosSwift } from './withCIOIosSwift';
|
|
5
|
+
import { withGoogleServicesJsonFile } from './withGoogleServicesJsonFile';
|
|
2
6
|
import { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';
|
|
3
7
|
import { withCioXcodeProject } from './withXcodeProject';
|
|
4
|
-
|
|
5
|
-
import { withCIOIosSwift } from './withCIOIosSwift';
|
|
6
|
-
import { isExpoVersion53OrHigher } from './utils';
|
|
7
|
-
export function withCIOIos(config, props) {
|
|
8
|
-
const cioProps = mergeDeprecatedPropertiesAndLogWarnings(props);
|
|
8
|
+
export function withCIOIos(config, sdkConfig, props) {
|
|
9
9
|
const isSwiftProject = isExpoVersion53OrHigher(config);
|
|
10
|
-
|
|
10
|
+
const platformConfig = mergeDeprecatedPropertiesAndLogWarnings(props);
|
|
11
|
+
if (platformConfig.pushNotification) {
|
|
11
12
|
if (isSwiftProject) {
|
|
12
|
-
config = withCIOIosSwift(config,
|
|
13
|
+
config = withCIOIosSwift(config, sdkConfig, platformConfig);
|
|
13
14
|
} else {
|
|
14
|
-
|
|
15
|
+
// Auto initialization is only supported in Swift projects (Expo SDK 53+)
|
|
16
|
+
// Legacy Objective-C projects only support push notifications
|
|
17
|
+
config = withAppDelegateModifications(config, platformConfig);
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
config =
|
|
18
|
-
config =
|
|
19
|
+
platformConfig.pushNotification.env = platformConfig.pushNotification.env || mergeConfigWithEnvValues(platformConfig, sdkConfig);
|
|
20
|
+
config = withCioNotificationsXcodeProject(config, platformConfig);
|
|
21
|
+
config = withCioXcodeProject(config, platformConfig);
|
|
22
|
+
config = withGoogleServicesJsonFile(config, platformConfig);
|
|
23
|
+
} else if (sdkConfig && isSwiftProject) {
|
|
24
|
+
config = withCIOIosSwift(config, sdkConfig, platformConfig);
|
|
19
25
|
}
|
|
20
26
|
return config;
|
|
21
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["mergeConfigWithEnvValues","isExpoVersion53OrHigher","withAppDelegateModifications","withCIOIosSwift","withGoogleServicesJsonFile","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","sdkConfig","props","isSwiftProject","platformConfig","mergeDeprecatedPropertiesAndLogWarnings","pushNotification","env","deprecatedTopLevelProperties","showPushAppInForeground","autoTrackPushEvents","handleDeeplinkInKilledState","disableNotificationRegistration","autoFetchDeviceToken","Object","entries","forEach","key","value","undefined","console","warn","propKey"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginPushNotificationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { mergeConfigWithEnvValues } from '../utils/config';\nimport { isExpoVersion53OrHigher } from './utils';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCIOIosSwift } from './withCIOIosSwift';\nimport { withGoogleServicesJsonFile } from './withGoogleServicesJsonFile';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n sdkConfig: NativeSDKConfig | undefined,\n props: CustomerIOPluginOptionsIOS\n) {\n const isSwiftProject = isExpoVersion53OrHigher(config);\n const platformConfig = mergeDeprecatedPropertiesAndLogWarnings(props);\n\n if (platformConfig.pushNotification) {\n if (isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig);\n } else {\n // Auto initialization is only supported in Swift projects (Expo SDK 53+)\n // Legacy Objective-C projects only support push notifications\n config = withAppDelegateModifications(config, platformConfig);\n }\n\n platformConfig.pushNotification.env = platformConfig.pushNotification.env\n || mergeConfigWithEnvValues(platformConfig, sdkConfig);\n config = withCioNotificationsXcodeProject(config, platformConfig);\n config = withCioXcodeProject(config, platformConfig);\n config = withGoogleServicesJsonFile(config, platformConfig);\n } else if (sdkConfig && isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig);\n }\n\n return config;\n}\n\n/** The basic purpose of this function is to centralize where we handle the deprecation\n by merging the deprecated properties into the new ios.pushNotification.* properties\n and logging a warning if they are set. This way, we can remove the deprecated properties\n from the top level of the ios object in the future, and update this function\n while the rest of the plugin code remains unchanged.\n*/\nconst mergeDeprecatedPropertiesAndLogWarnings = (\n props: CustomerIOPluginOptionsIOS\n) => {\n // The deprecatedTopLevelProperties maps the top level properties\n // that are deprecated to the new ios.pushNotification.* properties\n // that should be used instead. The deprecated properties are\n // still available for backwards compatibility, but they will\n // be removed in the future.\n\n const deprecatedTopLevelProperties = {\n showPushAppInForeground: props.showPushAppInForeground,\n autoTrackPushEvents: props.autoTrackPushEvents,\n handleDeeplinkInKilledState: props.handleDeeplinkInKilledState,\n disableNotificationRegistration: props.disableNotificationRegistration,\n autoFetchDeviceToken: props.autoFetchDeviceToken,\n };\n\n // loop over all the deprecated properties and log a warning if they are set\n Object.entries(deprecatedTopLevelProperties).forEach(([key, value]) => {\n if (value !== undefined) {\n console.warn(\n `The ios.${key} property is deprecated. Please use ios.pushNotification.${key} instead.`\n );\n\n if (props.pushNotification === undefined) {\n props.pushNotification = {} as CustomerIOPluginPushNotificationOptions;\n }\n const propKey = key as keyof CustomerIOPluginPushNotificationOptions;\n if (props.pushNotification[propKey] === undefined) {\n props.pushNotification = {\n ...props.pushNotification,\n [propKey]: value,\n };\n } else {\n console.warn(\n `The ios.${key} property is deprecated. Since the value of ios.pushNotification.${key} is set, it will be used.`\n );\n }\n }\n });\n\n return props;\n};\n"],"mappings":"AAOA,SAASA,wBAAwB,QAAQ,iBAAiB;AAC1D,SAASC,uBAAuB,QAAQ,SAAS;AACjD,SAASC,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,OAAO,SAASC,UAAUA,CACxBC,MAAkB,EAClBC,SAAsC,EACtCC,KAAiC,EACjC;EACA,MAAMC,cAAc,GAAGV,uBAAuB,CAACO,MAAM,CAAC;EACtD,MAAMI,cAAc,GAAGC,uCAAuC,C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