customerio-expo-plugin 2.7.0 → 2.7.2
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 +4 -3
- package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +5 -4
- package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/commonjs/android/withAppGoogleServices.js +2 -1
- package/plugin/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
- package/plugin/lib/commonjs/android/withCIOAndroid.js +17 -11
- package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -1
- package/plugin/lib/commonjs/android/withGistMavenRepository.js +2 -1
- package/plugin/lib/commonjs/android/withGistMavenRepository.js.map +1 -1
- package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +4 -3
- package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js +2 -1
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -1
- package/plugin/lib/commonjs/helpers/native-files/ios/CustomerIOSDKInitializer.swift +10 -4
- package/plugin/lib/commonjs/helpers/utils/fileManagement.js +5 -4
- package/plugin/lib/commonjs/helpers/utils/fileManagement.js.map +1 -1
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +2 -1
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js +5 -1
- package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js.map +1 -1
- package/plugin/lib/commonjs/index.js +3 -11
- package/plugin/lib/commonjs/index.js.map +1 -1
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +2 -1
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIos.js +7 -3
- package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js +11 -10
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +8 -7
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +29 -23
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/utils/android.js +2 -1
- package/plugin/lib/commonjs/utils/android.js.map +1 -1
- package/plugin/lib/commonjs/utils/config.js +3 -2
- package/plugin/lib/commonjs/utils/config.js.map +1 -1
- package/plugin/lib/commonjs/utils/logger.js +35 -0
- package/plugin/lib/commonjs/utils/logger.js.map +1 -0
- package/plugin/lib/commonjs/utils/validation.js +68 -25
- package/plugin/lib/commonjs/utils/validation.js.map +1 -1
- package/plugin/lib/commonjs/utils/xcode.js +2 -1
- package/plugin/lib/commonjs/utils/xcode.js.map +1 -1
- package/plugin/lib/module/android/withAndroidManifestUpdates.js +6 -4
- package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/module/android/withAppGoogleServices.js +2 -1
- package/plugin/lib/module/android/withAppGoogleServices.js.map +1 -1
- package/plugin/lib/module/android/withCIOAndroid.js +17 -11
- package/plugin/lib/module/android/withCIOAndroid.js.map +1 -1
- package/plugin/lib/module/android/withGistMavenRepository.js +2 -1
- package/plugin/lib/module/android/withGistMavenRepository.js.map +1 -1
- package/plugin/lib/module/android/withGoogleServicesJSON.js +4 -3
- package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/module/android/withMainApplicationModifications.js +2 -1
- package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -1
- package/plugin/lib/module/helpers/native-files/ios/CustomerIOSDKInitializer.swift +10 -4
- package/plugin/lib/module/helpers/utils/fileManagement.js +6 -5
- package/plugin/lib/module/helpers/utils/fileManagement.js.map +1 -1
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +2 -1
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js +5 -1
- package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js.map +1 -1
- package/plugin/lib/module/index.js +3 -12
- package/plugin/lib/module/index.js.map +1 -1
- package/plugin/lib/module/ios/withAppDelegateModifications.js +2 -1
- package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIos.js +7 -3
- package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIosSwift.js +11 -10
- package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +8 -7
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js +29 -23
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/module/utils/android.js +2 -1
- package/plugin/lib/module/utils/android.js.map +1 -1
- package/plugin/lib/module/utils/config.js +4 -2
- package/plugin/lib/module/utils/config.js.map +1 -1
- package/plugin/lib/module/utils/logger.js +29 -0
- package/plugin/lib/module/utils/logger.js.map +1 -0
- package/plugin/lib/module/utils/validation.js +68 -27
- package/plugin/lib/module/utils/validation.js.map +1 -1
- package/plugin/lib/module/utils/xcode.js +2 -1
- package/plugin/lib/module/utils/xcode.js.map +1 -1
- package/plugin/lib/typescript/android/withCIOAndroid.d.ts +1 -1
- package/plugin/lib/typescript/ios/withCIOIos.d.ts +1 -1
- package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +1 -1
- package/plugin/lib/typescript/utils/logger.d.ts +8 -0
- package/plugin/lib/typescript/utils/validation.d.ts +6 -3
- package/plugin/src/android/withAndroidManifestUpdates.ts +5 -4
- package/plugin/src/android/withAppGoogleServices.ts +2 -1
- package/plugin/src/android/withCIOAndroid.ts +18 -12
- package/plugin/src/android/withGistMavenRepository.ts +3 -2
- package/plugin/src/android/withGoogleServicesJSON.ts +4 -3
- package/plugin/src/android/withMainApplicationModifications.ts +2 -1
- package/plugin/src/helpers/native-files/ios/CustomerIOSDKInitializer.swift +10 -4
- package/plugin/src/helpers/utils/fileManagement.ts +10 -9
- package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +2 -1
- package/plugin/src/helpers/utils/patchPluginNativeCode.ts +6 -1
- package/plugin/src/index.ts +3 -13
- package/plugin/src/ios/withAppDelegateModifications.ts +2 -1
- package/plugin/src/ios/withCIOIos.ts +12 -8
- package/plugin/src/ios/withCIOIosSwift.ts +15 -14
- package/plugin/src/ios/withGoogleServicesJsonFile.ts +8 -7
- package/plugin/src/ios/withNotificationsXcodeProject.ts +31 -35
- package/plugin/src/utils/android.ts +2 -1
- package/plugin/src/utils/config.ts +3 -2
- package/plugin/src/utils/logger.ts +37 -0
- package/plugin/src/utils/validation.ts +96 -32
- package/plugin/src/utils/xcode.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "customerio-expo-plugin",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"description": "Expo config plugin for the Customer IO React Native SDK",
|
|
5
5
|
"main": "plugin/lib/commonjs/index",
|
|
6
6
|
"module": "plugin/lib/module/index",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"registry": "https://registry.npmjs.org/"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"customerio-reactnative": "4.8.
|
|
58
|
+
"customerio-reactnative": "4.8.2"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@eslint/js": "^9.33.0",
|
|
@@ -83,7 +83,8 @@
|
|
|
83
83
|
},
|
|
84
84
|
"eslintIgnore": [
|
|
85
85
|
"node_modules/",
|
|
86
|
-
"plugin/lib/"
|
|
86
|
+
"plugin/lib/",
|
|
87
|
+
"ci-test-apps/"
|
|
87
88
|
],
|
|
88
89
|
"prettier": {
|
|
89
90
|
"quoteProps": "consistent",
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.withAndroidManifestUpdates = exports.DEFAULT_LOW_PRIORITY = void 0;
|
|
7
7
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
|
+
var _logger = require("../utils/logger");
|
|
8
9
|
// Default low priority for Firebase messaging service when setHighPriorityPushHandler is false
|
|
9
10
|
const DEFAULT_LOW_PRIORITY = exports.DEFAULT_LOW_PRIORITY = -10;
|
|
10
11
|
const withAndroidManifestUpdates = (configOuter, options) => {
|
|
@@ -29,13 +30,13 @@ const withAndroidManifestUpdates = (configOuter, options) => {
|
|
|
29
30
|
// Handle priority based on setHighPriorityPushHandler value
|
|
30
31
|
if (options.setHighPriorityPushHandler === true) {
|
|
31
32
|
// High priority - no priority attribute means default high priority
|
|
32
|
-
|
|
33
|
+
_logger.logger.info('Successfully set CustomerIO push handler as high priority in AndroidManifest.xml');
|
|
33
34
|
} else if (options.setHighPriorityPushHandler === false) {
|
|
34
35
|
// Low priority - set fixed priority
|
|
35
36
|
intentFilter.$ = {
|
|
36
37
|
'android:priority': DEFAULT_LOW_PRIORITY.toString()
|
|
37
38
|
};
|
|
38
|
-
|
|
39
|
+
_logger.logger.info(`Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
|
|
39
40
|
}
|
|
40
41
|
application[0].service.push({
|
|
41
42
|
'$': {
|
|
@@ -52,7 +53,7 @@ const withAndroidManifestUpdates = (configOuter, options) => {
|
|
|
52
53
|
const intentFilter = existingService['intent-filter'][0];
|
|
53
54
|
if (intentFilter.$ && intentFilter.$['android:priority']) {
|
|
54
55
|
delete intentFilter.$['android:priority'];
|
|
55
|
-
|
|
56
|
+
_logger.logger.info('Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml');
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
} else if (options.setHighPriorityPushHandler === false) {
|
|
@@ -67,7 +68,7 @@ const withAndroidManifestUpdates = (configOuter, options) => {
|
|
|
67
68
|
intentFilter.$ = {};
|
|
68
69
|
}
|
|
69
70
|
intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();
|
|
70
|
-
|
|
71
|
+
_logger.logger.info(`Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
props.modResults.manifest.application = application;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","DEFAULT_LOW_PRIORITY","exports","withAndroidManifestUpdates","configOuter","options","withAndroidManifest","props","application","modResults","manifest","customerIOMessagingpush","service","existingServiceIndex","findIndex","$","intentFilter","action","setHighPriorityPushHandler","
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_logger","DEFAULT_LOW_PRIORITY","exports","withAndroidManifestUpdates","configOuter","options","withAndroidManifest","props","application","modResults","manifest","customerIOMessagingpush","service","existingServiceIndex","findIndex","$","intentFilter","action","setHighPriorityPushHandler","logger","info","toString","push","existingService","length"],"sources":["withAndroidManifestUpdates.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { logger } from '../utils/logger';\n\n// Default low priority for Firebase messaging service when setHighPriorityPushHandler is false\nexport const DEFAULT_LOW_PRIORITY = -10;\n\n\nexport const withAndroidManifestUpdates: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, options) => {\n return withAndroidManifest(configOuter, (props) => {\n const application = props.modResults.manifest\n .application as ManifestApplication[];\n const customerIOMessagingpush =\n 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';\n\n if (!application[0].service) {\n application[0].service = [];\n }\n\n const existingServiceIndex = application[0].service.findIndex(\n (service) => service.$['android:name'] === customerIOMessagingpush\n );\n\n if (existingServiceIndex === -1) {\n // Intent filter structure for Firebase messaging service\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter: any = {\n action: [\n {\n $: {\n 'android:name': 'com.google.firebase.MESSAGING_EVENT',\n },\n },\n ],\n };\n\n // Handle priority based on setHighPriorityPushHandler value\n if (options.setHighPriorityPushHandler === true) {\n // High priority - no priority attribute means default high priority\n logger.info(\n 'Successfully set CustomerIO push handler as high priority in AndroidManifest.xml'\n );\n } else if (options.setHighPriorityPushHandler === false) {\n // Low priority - set fixed priority\n intentFilter.$ = {\n 'android:priority': DEFAULT_LOW_PRIORITY.toString(),\n };\n logger.info(\n `Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n\n application[0].service.push({\n '$': {\n 'android:name': customerIOMessagingpush,\n 'android:exported': 'false',\n },\n 'intent-filter': [intentFilter],\n });\n } else if (options.setHighPriorityPushHandler === true) {\n // Service exists, need to ensure it becomes high priority (remove priority attribute)\n const existingService = application[0].service[existingServiceIndex];\n\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (intentFilter.$ && intentFilter.$['android:priority']) {\n delete intentFilter.$['android:priority'];\n logger.info(\n 'Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml'\n );\n }\n }\n } else if (options.setHighPriorityPushHandler === false) {\n // Service exists, update to low priority\n const existingService = application[0].service[existingServiceIndex];\n\n // Update existing service intent-filter with fixed priority\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (!intentFilter.$) {\n intentFilter.$ = {};\n }\n intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();\n logger.info(\n `Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n }\n\n props.modResults.manifest.application = application;\n return props;\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAIA,IAAAC,OAAA,GAAAD,OAAA;AAEA;AACO,MAAME,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,CAAC,EAAE;AAGhC,MAAME,0BAEZ,GAAGA,CAACC,WAAW,EAAEC,OAAO,KAAK;EAC5B,OAAO,IAAAC,kCAAmB,EAACF,WAAW,EAAGG,KAAK,IAAK;IACjD,MAAMC,WAAW,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,CAC1CF,WAAoC;IACvC,MAAMG,uBAAuB,GAC3B,8DAA8D;IAEhE,IAAI,CAACH,WAAW,CAAC,CAAC,CAAC,CAACI,OAAO,EAAE;MAC3BJ,WAAW,CAAC,CAAC,CAAC,CAACI,OAAO,GAAG,EAAE;IAC7B;IAEA,MAAMC,oBAAoB,GAAGL,WAAW,CAAC,CAAC,CAAC,CAACI,OAAO,CAACE,SAAS,CAC1DF,OAAO,IAAKA,OAAO,CAACG,CAAC,CAAC,cAAc,CAAC,KAAKJ,uBAC7C,CAAC;IAED,IAAIE,oBAAoB,KAAK,CAAC,CAAC,EAAE;MAC/B;MACA;MACA,MAAMG,YAAiB,GAAG;QACxBC,MAAM,EAAE,CACN;UACEF,CAAC,EAAE;YACD,cAAc,EAAE;UAClB;QACF,CAAC;MAEL,CAAC;;MAED;MACA,IAAIV,OAAO,CAACa,0BAA0B,KAAK,IAAI,EAAE;QAC/C;QACAC,cAAM,CAACC,IAAI,CACT,kFACF,CAAC;MACH,CAAC,MAAM,IAAIf,OAAO,CAACa,0BAA0B,KAAK,KAAK,EAAE;QACvD;QACAF,YAAY,CAACD,CAAC,GAAG;UACf,kBAA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AC;QACrB;QACAC,YAAY,CAACD,CAAC,CAAC,kBAAkB,CAAC,GAAGd,oBAAoB,CAACoB,QAAQ,CAAC,CAAC;QACpEF,cAAM,CAACC,IAAI,CACT,0EAA0EnB,oBAAoB,0BAChG,CAAC;MACH;IACF;IAEAM,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACF,WAAW,GAAGA,WAAW;IACnD,OAAOD,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACL,OAAA,CAAAC,0BAAA,GAAAA,0BAAA","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.withAppGoogleServices = void 0;
|
|
7
7
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
8
|
var _android = require("../helpers/constants/android");
|
|
9
|
+
var _logger = require("../utils/logger");
|
|
9
10
|
const withAppGoogleServices = configOuter => {
|
|
10
11
|
return (0, _configPlugins.withAppBuildGradle)(configOuter, props => {
|
|
11
12
|
const regex = new RegExp(_android.CIO_APP_GOOGLE_SNIPPET);
|
|
@@ -13,7 +14,7 @@ const withAppGoogleServices = configOuter => {
|
|
|
13
14
|
if (!match) {
|
|
14
15
|
props.modResults.contents = props.modResults.contents.replace(_android.CIO_APP_APPLY_REGEX, `$1\n${_android.CIO_APP_GOOGLE_SNIPPET}`);
|
|
15
16
|
} else {
|
|
16
|
-
|
|
17
|
+
_logger.logger.info('app/build.gradle snippet already exists. Skipping...');
|
|
17
18
|
}
|
|
18
19
|
return props;
|
|
19
20
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_android","withAppGoogleServices","configOuter","withAppBuildGradle","props","regex","RegExp","CIO_APP_GOOGLE_SNIPPET","match","modResults","contents","replace","CIO_APP_APPLY_REGEX","
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_android","_logger","withAppGoogleServices","configOuter","withAppBuildGradle","props","regex","RegExp","CIO_APP_GOOGLE_SNIPPET","match","modResults","contents","replace","CIO_APP_APPLY_REGEX","logger","info","exports"],"sources":["withAppGoogleServices.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAppBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_APP_APPLY_REGEX,\n CIO_APP_GOOGLE_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { logger } from '../utils/logger';\n\nexport const withAppGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withAppBuildGradle(configOuter, (props) => {\n const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);\n const match = props.modResults.contents.match(regex);\n if (!match) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_APP_APPLY_REGEX,\n `$1\\n${CIO_APP_GOOGLE_SNIPPET}`\n );\n } else {\n logger.info('app/build.gradle snippet already exists. Skipping...');\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAF,OAAA;AAEO,MAAMG,qBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,iCAAkB,EAACD,WAAW,EAAGE,KAAK,IAAK;IAChD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACC,+BAAsB,CAAC;IAChD,MAAMC,KAAK,GAAGJ,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACF,KAAK,CAACH,KAAK,CAAC;IACpD,IAAI,CAACG,KAAK,EAAE;MACVJ,KAAK,CAACK,UAAU,CAACC,QAAQ,GAAGN,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DC,4BAAmB,EACnB,OAAOL,+BAAsB,EAC/B,CAAC;IACH,CAAC,MAAM;MACLM,cAAM,CAACC,IAAI,CAAC,sDAAsD,CAAC;IACrE;IAEA,OAAOV,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACW,OAAA,CAAAd,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -13,22 +13,28 @@ var _withNotificationChannelMetadata = require("./withNotificationChannelMetadat
|
|
|
13
13
|
var _withProjectGoogleServices = require("./withProjectGoogleServices");
|
|
14
14
|
var _withProjectStrings = require("./withProjectStrings");
|
|
15
15
|
function withCIOAndroid(config, sdkConfig, props) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
// Only run notification setup if props are provided
|
|
17
|
+
if (props) {
|
|
18
|
+
var _props$pushNotificati;
|
|
19
|
+
config = (0, _withGistMavenRepository.withGistMavenRepository)(config, props);
|
|
20
|
+
config = (0, _withProjectGoogleServices.withProjectGoogleServices)(config, props);
|
|
21
|
+
config = (0, _withAppGoogleServices.withAppGoogleServices)(config, props);
|
|
22
|
+
config = (0, _withGoogleServicesJSON.withGoogleServicesJSON)(config, props);
|
|
23
|
+
if (props.setHighPriorityPushHandler !== undefined) {
|
|
24
|
+
config = (0, _withAndroidManifestUpdates.withAndroidManifestUpdates)(config, props);
|
|
25
|
+
}
|
|
26
|
+
if ((_props$pushNotificati = props.pushNotification) !== null && _props$pushNotificati !== void 0 && _props$pushNotificati.channel) {
|
|
27
|
+
config = (0, _withNotificationChannelMetadata.withNotificationChannelMetadata)(config, props);
|
|
28
|
+
}
|
|
27
29
|
}
|
|
30
|
+
|
|
28
31
|
// Add auto initialization if sdkConfig is provided
|
|
29
32
|
if (sdkConfig) {
|
|
30
33
|
config = (0, _withMainApplicationModifications.withMainApplicationModifications)(config, sdkConfig);
|
|
31
34
|
}
|
|
35
|
+
|
|
36
|
+
// Update project strings for user agent metadata
|
|
37
|
+
config = (0, _withProjectStrings.withProjectStrings)(config);
|
|
32
38
|
return config;
|
|
33
39
|
}
|
|
34
40
|
//# sourceMappingURL=withCIOAndroid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_withAndroidManifestUpdates","require","_withAppGoogleServices","_withGistMavenRepository","_withGoogleServicesJSON","_withMainApplicationModifications","_withNotificationChannelMetadata","_withProjectGoogleServices","_withProjectStrings","withCIOAndroid","config","sdkConfig","props","_props$pushNotificati","withGistMavenRepository","withProjectGoogleServices","withAppGoogleServices","withGoogleServicesJSON","
|
|
1
|
+
{"version":3,"names":["_withAndroidManifestUpdates","require","_withAppGoogleServices","_withGistMavenRepository","_withGoogleServicesJSON","_withMainApplicationModifications","_withNotificationChannelMetadata","_withProjectGoogleServices","_withProjectStrings","withCIOAndroid","config","sdkConfig","props","_props$pushNotificati","withGistMavenRepository","withProjectGoogleServices","withAppGoogleServices","withGoogleServicesJSON","setHighPriorityPushHandler","undefined","withAndroidManifestUpdates","pushNotification","channel","withNotificationChannelMetadata","withMainApplicationModifications","withProjectStrings"],"sources":["withCIOAndroid.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsAndroid, NativeSDKConfig } from '../types/cio-types';\nimport { withAndroidManifestUpdates } from './withAndroidManifestUpdates';\nimport { withAppGoogleServices } from './withAppGoogleServices';\nimport { withGistMavenRepository } from './withGistMavenRepository';\nimport { withGoogleServicesJSON } from './withGoogleServicesJSON';\nimport { withMainApplicationModifications } from './withMainApplicationModifications';\nimport { withNotificationChannelMetadata } from './withNotificationChannelMetadata';\nimport { withProjectGoogleServices } from './withProjectGoogleServices';\nimport { withProjectStrings } from './withProjectStrings';\n\nexport function withCIOAndroid(\n config: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsAndroid,\n): ExpoConfig {\n // Only run notification setup if props are provided\n if (props) {\n config = withGistMavenRepository(config, props);\n config = withProjectGoogleServices(config, props);\n config = withAppGoogleServices(config, props);\n config = withGoogleServicesJSON(config, props);\n if (props.setHighPriorityPushHandler !== undefined) {\n config = withAndroidManifestUpdates(config, props);\n }\n if (props.pushNotification?.channel) {\n config = withNotificationChannelMetadata(config, props);\n }\n }\n\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n config = withMainApplicationModifications(config, sdkConfig);\n }\n\n // Update project strings for user agent metadata\n config = withProjectStrings(config);\n\n return config;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,2BAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AACA,IAAAI,iCAAA,GAAAJ,OAAA;AACA,IAAAK,gCAAA,GAAAL,OAAA;AACA,IAAAM,0BAAA,GAAAN,OAAA;AACA,IAAAO,mBAAA,GAAAP,OAAA;AAEO,SAASQ,cAAcA,CAC5BC,MAAkB,EAClBC,SAA2B,EAC3BC,KAAsC,EAC1B;EACZ;EACA,IAAIA,KAAK,EAAE;IAAA,IAAAC,qBAAA;IACTH,MAAM,GAAG,IAAAI,gDAAuB,EAACJ,MAAM,EAAEE,KAAK,CAAC;IAC/CF,MAAM,GAAG,IAAAK,oDAAyB,EAACL,MAAM,EAAEE,KAAK,CAAC;IACjDF,MAAM,GAAG,IAAAM,4CAAqB,EAACN,MAAM,EAAEE,KAAK,CAAC;IAC7CF,MAAM,GAAG,IAAAO,8CAAsB,EAACP,MAAM,EAAEE,KAAK,CAAC;IAC9C,IAAIA,KAAK,CAACM,0BAA0B,KAAKC,SAAS,EAAE;MAClDT,MAAM,GAAG,IAAAU,sDAA0B,EAACV,MAAM,EAAEE,KAAK,CAAC;IACpD;IACA,KAAAC,qBAAA,GAAID,KAAK,CAACS,gBAAgB,cAAAR,qBAAA,eAAtBA,qBAAA,CAAwBS,OAAO,EAAE;MACnCZ,MAAM,GAAG,IAAAa,gEAA+B,EAACb,MAAM,EAAEE,KAAK,CAAC;IACzD;EACF;;EAEA;EACA,IAAID,SAAS,EAAE;IACbD,MAAM,GAAG,IAAAc,kEAAgC,EAACd,MAAM,EAAEC,SAAS,CAAC;EAC9D;;EAEA;EACAD,MAAM,GAAG,IAAAe,sCAAkB,EAACf,MAAM,CAAC;EAEnC,OAAOA,MAAM;AACf","ignoreList":[]}
|
|
@@ -6,13 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.withGistMavenRepository = void 0;
|
|
7
7
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
8
|
var _android = require("../helpers/constants/android");
|
|
9
|
+
var _logger = require("../utils/logger");
|
|
9
10
|
const withGistMavenRepository = configOuter => {
|
|
10
11
|
return (0, _configPlugins.withProjectBuildGradle)(configOuter, props => {
|
|
11
12
|
const targetMatch = props.modResults.contents.match(_android.CIO_GIST_MAVEN_REGEX);
|
|
12
13
|
if (!targetMatch) {
|
|
13
14
|
props.modResults.contents = props.modResults.contents.replace(_android.CIO_PROJECT_ALLPROJECTS_REGEX, `$1\n${_android.CIO_PROJECT_GIST_MAVEN_SNIPPET}`);
|
|
14
15
|
} else {
|
|
15
|
-
|
|
16
|
+
_logger.logger.info('build.gradle snippet already exists. Skipping...');
|
|
16
17
|
}
|
|
17
18
|
return props;
|
|
18
19
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_android","withGistMavenRepository","configOuter","withProjectBuildGradle","props","targetMatch","modResults","contents","match","CIO_GIST_MAVEN_REGEX","replace","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_android","_logger","withGistMavenRepository","configOuter","withProjectBuildGradle","props","targetMatch","modResults","contents","match","CIO_GIST_MAVEN_REGEX","replace","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","logger","info","exports"],"sources":["withGistMavenRepository.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withProjectBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_GIST_MAVEN_REGEX,\n CIO_PROJECT_ALLPROJECTS_REGEX,\n CIO_PROJECT_GIST_MAVEN_SNIPPET,\n} from '../helpers/constants/android';\nimport { logger } from '../utils/logger';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGistMavenRepository: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const targetMatch = props.modResults.contents.match(CIO_GIST_MAVEN_REGEX);\n if (!targetMatch) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_PROJECT_ALLPROJECTS_REGEX,\n `$1\\n${CIO_PROJECT_GIST_MAVEN_SNIPPET}`\n );\n } else {\n logger.info('build.gradle snippet already exists. Skipping...');\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAF,OAAA;AAGO,MAAMG,uBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,qCAAsB,EAACD,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,WAAW,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACC,6BAAoB,CAAC;IACzE,IAAI,CAACJ,WAAW,EAAE;MAChBD,KAAK,CAACE,UAAU,CAACC,QAAQ,GAAGH,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACG,OAAO,CAC3DC,sCAA6B,EAC7B,OAAOC,uCAA8B,EACvC,CAAC;IACH,CAAC,MAAM;MACLC,cAAM,CAACC,IAAI,CAAC,kDAAkD,CAAC;IACjE;IAEA,OAAOV,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACW,OAAA,CAAAd,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.withGoogleServicesJSON = void 0;
|
|
7
7
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
|
+
var _logger = require("../utils/logger");
|
|
8
9
|
var _fileManagement = require("./../helpers/utils/fileManagement");
|
|
9
10
|
const withGoogleServicesJSON = (configOuter, cioProps) => {
|
|
10
11
|
return (0, _configPlugins.withProjectBuildGradle)(configOuter, props => {
|
|
@@ -21,13 +22,13 @@ const withGoogleServicesJSON = (configOuter, cioProps) => {
|
|
|
21
22
|
try {
|
|
22
23
|
_fileManagement.FileManagement.copyFile(googleServicesFile, `${androidPath}/app/google-services.json`);
|
|
23
24
|
} catch {
|
|
24
|
-
|
|
25
|
+
_logger.logger.info(`There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`);
|
|
25
26
|
}
|
|
26
27
|
} else {
|
|
27
|
-
|
|
28
|
+
_logger.logger.info(`The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${androidPath}/app/google-services.json`);
|
|
28
29
|
}
|
|
29
30
|
} else {
|
|
30
|
-
|
|
31
|
+
_logger.logger.info(`File already exists: ${androidPath}/app/google-services.json. Skipping...`);
|
|
31
32
|
}
|
|
32
33
|
return props;
|
|
33
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_fileManagement","withGoogleServicesJSON","configOuter","cioProps","withProjectBuildGradle","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFile","FileManagement","exists","copyFile","
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_logger","_fileManagement","withGoogleServicesJSON","configOuter","cioProps","withProjectBuildGradle","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFile","FileManagement","exists","copyFile","logger","info","exports"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withProjectBuildGradle } from '@expo/config-plugins';\n\nimport { logger } from '../utils/logger';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGoogleServicesJSON: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, cioProps) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const options: CustomerIOPluginOptionsAndroid = {\n androidPath: props.modRequest.platformProjectRoot,\n googleServicesFile: cioProps?.googleServicesFile,\n };\n const { androidPath, googleServicesFile } = options;\n if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${androidPath}/app/google-services.json`\n );\n } catch {\n logger.info(\n `There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n logger.info(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n logger.info(\n `File already exists: ${androidPath}/app/google-services.json. Skipping...`\n );\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,sBAEZ,GAAGA,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAO,IAAAC,qCAAsB,EAACF,WAAW,EAAGG,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,kBAAkB,EAAEP,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEO;IAChC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAmB,CAAC,GAAGJ,OAAO;IACnD,IAAI,CAACK,8BAAc,CAACC,MAAM,CAAC,GAAGL,WAAW,2BAA2B,CAAC,EAAE;MACrE,IAAIG,kBAAkB,IAAIC,8BAAc,CAACC,MAAM,CAACF,kBAAkB,CAAC,EAAE;QACnE,IAAI;UACFC,8BAAc,CAACE,QAAQ,CACrBH,kBAAkB,EAClB,GAAGH,WAAW,2BAChB,CAAC;QACH,CAAC,CAAC,MAAM;UACNO,cAAM,CAACC,IAAI,CACT,4FAA4FR,WAAW,2BACzG,CAAC;QACH;MACF,CAAC,MAAM;QACLO,cAAM,CAACC,IAAI,CACT,wCAAwCL,kBAAkB,yDAAyDH,WAAW,2BAChI,CAAC;MACH;IACF,CAAC,MAAM;MACLO,cAAM,CAACC,IAAI,CACT,wBAAwBR,WAAW,wCACrC,CAAC;IACH;IAEA,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACW,OAAA,CAAAf,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -9,6 +9,7 @@ var _android = require("../helpers/constants/android");
|
|
|
9
9
|
var _common = require("../helpers/constants/common");
|
|
10
10
|
var _patchPluginNativeCode = require("../helpers/utils/patchPluginNativeCode");
|
|
11
11
|
var _android2 = require("../utils/android");
|
|
12
|
+
var _logger = require("../utils/logger");
|
|
12
13
|
const withMainApplicationModifications = (configOuter, sdkConfig) => {
|
|
13
14
|
return (0, _configPlugins.withMainApplication)(configOuter, async config => {
|
|
14
15
|
const content = setupCustomerIOSDKInitializer(config, sdkConfig);
|
|
@@ -37,7 +38,7 @@ const setupCustomerIOSDKInitializer = (config, sdkConfig) => {
|
|
|
37
38
|
content = (0, _android2.addCodeToMethod)(content, _android.CIO_MAINAPPLICATION_ONCREATE_REGEX, _android.CIO_NATIVE_SDK_INITIALIZE_SNIPPET);
|
|
38
39
|
}
|
|
39
40
|
} catch (error) {
|
|
40
|
-
|
|
41
|
+
_logger.logger.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);
|
|
41
42
|
return config.modResults.contents;
|
|
42
43
|
}
|
|
43
44
|
return content;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_android","_common","_patchPluginNativeCode","_android2","withMainApplicationModifications","configOuter","sdkConfig","withMainApplication","config","content","setupCustomerIOSDKInitializer","modResults","contents","exports","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","copyTemplateFile","patchNativeSDKInitializer","PLATFORM","ANDROID","addImportToFile","includes","CIO_NATIVE_SDK_INITIALIZE_CALL","addCodeToMethod","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","error","
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_android","_common","_patchPluginNativeCode","_android2","_logger","withMainApplicationModifications","configOuter","sdkConfig","withMainApplication","config","content","setupCustomerIOSDKInitializer","modResults","contents","exports","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","copyTemplateFile","patchNativeSDKInitializer","PLATFORM","ANDROID","addImportToFile","includes","CIO_NATIVE_SDK_INITIALIZE_CALL","addCodeToMethod","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","error","logger","warn"],"sources":["withMainApplicationModifications.ts"],"sourcesContent":["import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins';\nimport { withMainApplication } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';\nimport { PLATFORM } from '../helpers/constants/common';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type { NativeSDKConfig } from '../types/cio-types';\nimport { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';\nimport { logger } from '../utils/logger';\n\nexport const withMainApplicationModifications: ConfigPlugin<NativeSDKConfig> = (configOuter, sdkConfig) => {\n return withMainApplication(configOuter, async (config) => {\n const content = setupCustomerIOSDKInitializer(config, sdkConfig);\n config.modResults.contents = content;\n return config;\n });\n};\n\n/**\n * Setup CustomerIOSDKInitializer for Android auto initialization\n */\nconst setupCustomerIOSDKInitializer = (\n config: ExportedConfigWithProps<ApplicationProjectFile>,\n sdkConfig: NativeSDKConfig,\n): string => {\n const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';\n const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';\n\n const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;\n const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;\n\n let content = config.modResults.contents;\n\n try {\n // Always regenerate the CustomerIOSDKInitializer file to reflect config changes\n copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, (content) =>\n patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig)\n );\n // Add import if not already present\n content = addImportToFile(content, SDK_INITIALIZER_IMPORT);\n // Add initialization code to onCreate if not already present\n if (!content.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n content = addCodeToMethod(content, CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);\n }\n } catch (error) {\n logger.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);\n return config.modResults.contents;\n }\n\n return content;\n};\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AAEA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAEO,MAAMM,gCAA+D,GAAGA,CAACC,WAAW,EAAEC,SAAS,KAAK;EACzG,OAAO,IAAAC,kCAAmB,EAACF,WAAW,EAAE,MAAOG,MAAM,IAAK;IACxD,MAAMC,OAAO,GAAGC,6BAA6B,CAACF,MAAM,EAAEF,SAAS,CAAC;IAChEE,MAAM,CAACG,UAAU,CAACC,QAAQ,GAAGH,OAAO;IACpC,OAAOD,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AAFAK,OAAA,CAAAT,gCAAA,GAAAA,gCAAA;AAGA,MAAMM,6BAA6B,GAAGA,CACpCF,MAAuD,EACvDF,SAA0B,KACf;EACX,MAAMQ,qBAAqB,GAAG,0BAA0B;EACxD,MAAMC,uBAAuB,GAAG,sBAAsB;EAEtD,MAAMC,oBAAoB,GAAG,GAAGF,qBAAqB,KAAK;EAC1D,MAAMG,sBAAsB,GAAG,UAAUF,uBAAuB,IAAID,qBAAqB,EAAE;EAE3F,IAAIL,OAAO,GAAGD,MAAM,CAACG,UAAU,CAACC,QAAQ;EAExC,IAAI;IACF;IACA,IAAAM,0BAAgB,EAACV,MAAM,EAAEQ,oBAAoB,EAAED,uBAAuB,EAAGN,OAAO,IAC9E,IAAAU,gDAAyB,EAACV,OAAO,EAAEW,gBAAQ,CAACC,OAAO,EAAEf,SAAS,CAChE,CAAC;IACD;IACAG,OAAO,GAAG,IAAAa,yBAAe,EAACb,OAAO,EAAEQ,sBAAsB,CAAC;IAC1D;IACA,IAAI,CAACR,OAAO,CAACc,QAAQ,CAACC,uCAA8B,CAAC,EAAE;MACrDf,OAAO,GAAG,IAAAgB,yBAAe,EAAChB,OAAO,EAAEiB,2CAAkC,EAAEC,0CAAiC,CAAC;IAC3G;EACF,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdC,cAAM,CAACC,IAAI,CAAC,mBAAmBhB,qBAAqB,GAAG,EAAEc,KAAK,CAAC;IAC/D,OAAOpB,MAAM,CAACG,UAAU,CAACC,QAAQ;EACnC;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import CioDataPipelines
|
|
2
2
|
import CioInternalCommon
|
|
3
3
|
import CioMessagingInApp
|
|
4
|
-
import customerio_reactnative
|
|
5
4
|
|
|
6
5
|
class CustomerIOSDKInitializer {
|
|
7
6
|
static func initialize() {
|
|
@@ -27,9 +26,16 @@ class CustomerIOSDKInitializer {
|
|
|
27
26
|
CustomerIO.initialize(withConfig: builder.build())
|
|
28
27
|
|
|
29
28
|
if let siteId = siteId {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
let inAppConfig = MessagingInAppConfigBuilder(siteId: siteId, region: region).build()
|
|
30
|
+
MessagingInApp.initialize(withConfig: inAppConfig)
|
|
31
|
+
let logger = DIGraphShared.shared.logger
|
|
32
|
+
// Retrieves ReactInAppEventListener from DI graph, populated when it is accessed in React Native SDK.
|
|
33
|
+
if let listener: InAppEventListener? = DIGraphShared.shared.getOverriddenInstance() {
|
|
34
|
+
logger.debug("[Expo][InApp] React InAppEventListener found in DI graph and set")
|
|
35
|
+
MessagingInApp.shared.setEventListener(listener)
|
|
36
|
+
} else {
|
|
37
|
+
logger.debug("[Expo][InApp] React InAppEventListener not found in DI graph, will be set by React Native module when accessed")
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
}
|
|
35
41
|
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.FileManagement = void 0;
|
|
7
7
|
var _fs = require("fs");
|
|
8
|
+
var _logger = require("../../utils/logger");
|
|
8
9
|
class FileManagement {
|
|
9
10
|
static async read(path) {
|
|
10
11
|
return new Promise((resolve, reject) => {
|
|
@@ -46,28 +47,28 @@ class FileManagement {
|
|
|
46
47
|
try {
|
|
47
48
|
(0, _fs.copyFileSync)(src, dest);
|
|
48
49
|
} catch (err) {
|
|
49
|
-
|
|
50
|
+
_logger.logger.error(`Error copying file from ${src} to ${dest}: `, err);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
static mkdir(path, options) {
|
|
53
54
|
try {
|
|
54
55
|
(0, _fs.mkdirSync)(path, options);
|
|
55
56
|
} catch (err) {
|
|
56
|
-
|
|
57
|
+
_logger.logger.error(`Error creating directory ${path}: `, err);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
static writeFile(path, data) {
|
|
60
61
|
try {
|
|
61
62
|
(0, _fs.writeFileSync)(path, data);
|
|
62
63
|
} catch (err) {
|
|
63
|
-
|
|
64
|
+
_logger.logger.error(`Error writing to file ${path}: `, err);
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
static readFile(path) {
|
|
67
68
|
try {
|
|
68
69
|
return (0, _fs.readFileSync)(path, 'utf-8');
|
|
69
70
|
} catch (err) {
|
|
70
|
-
|
|
71
|
+
_logger.logger.error(`Error reading file ${path}: `, err);
|
|
71
72
|
}
|
|
72
73
|
return '';
|
|
73
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_fs","require","FileManagement","read","path","Promise","resolve","reject","readFile","err","data","write","contents","writeFile","append","appendFile","exists","existsSync","copyFile","src","dest","copyFileSync","
|
|
1
|
+
{"version":3,"names":["_fs","require","_logger","FileManagement","read","path","Promise","resolve","reject","readFile","err","data","write","contents","writeFile","append","appendFile","exists","existsSync","copyFile","src","dest","copyFileSync","logger","error","mkdir","options","mkdirSync","writeFileSync","readFileSync","exports"],"sources":["fileManagement.ts"],"sourcesContent":["import type { MakeDirectoryOptions } from 'fs';\nimport {\n appendFile,\n copyFileSync,\n existsSync,\n mkdirSync,\n readFile,\n readFileSync,\n writeFile,\n writeFileSync,\n} from 'fs';\nimport { logger } from '../../utils/logger';\n\nexport class FileManagement {\n static async read(path: string): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n readFile(path, 'utf8', (err, data) => {\n if (err || !data) {\n reject(err);\n return;\n }\n resolve(data);\n });\n });\n }\n\n static async write(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n writeFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static async append(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n appendFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static exists(path: string) {\n return existsSync(path);\n }\n\n static copyFile(src: string, dest: string) {\n try {\n copyFileSync(src, dest);\n } catch (err) {\n logger.error(`Error copying file from ${src} to ${dest}: `, err);\n }\n }\n\n static mkdir(path: string, options: MakeDirectoryOptions) {\n try {\n mkdirSync(path, options);\n } catch (err) {\n logger.error(`Error creating directory ${path}: `, err);\n }\n }\n\n static writeFile(path: string, data: string) {\n try {\n writeFileSync(path, data);\n } catch (err) {\n logger.error(`Error writing to file ${path}: `, err);\n }\n }\n\n static readFile(path: string) {\n try {\n return readFileSync(path, 'utf-8');\n } catch (err) {\n logger.error(`Error reading file ${path}: `, err);\n }\n\n return '';\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,GAAA,GAAAC,OAAA;AAUA,IAAAC,OAAA,GAAAD,OAAA;AAEO,MAAME,cAAc,CAAC;EAC1B,aAAaC,IAAIA,CAACC,IAAY,EAAmB;IAC/C,OAAO,IAAIC,OAAO,CAAS,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC9C,IAAAC,YAAQ,EAACJ,IAAI,EAAE,MAAM,EAAE,CAACK,GAAG,EAAEC,IAAI,KAAK;QACpC,IAAID,GAAG,IAAI,CAACC,IAAI,EAAE;UAChBH,MAAM,CAACE,GAAG,CAAC;UACX;QACF;QACAH,OAAO,CAACI,IAAI,CAAC;MACf,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaC,KAAKA,CAACP,IAAY,EAAEQ,QAAgB,EAAiB;IAChE,OAAO,IAAIP,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC5C,IAAAM,aAAS,EAACT,IAAI,EAAEQ,QAAQ,EAAE,MAAM,EAAGH,GAAG,IAAK;QACzC,IAAIA,GAAG,EAAE;UACPF,MAAM,CAACE,GAAG,CAAC;UACX;QACF;QACAH,OAAO,CAAC,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AE;IAC5B,IAAI;MACF,OAAO,IAAAwB,gBAAY,EAACxB,IAAI,EAAE,OAAO,CAAC;IACpC,CAAC,CAAC,OAAOK,GAAG,EAAE;MACZa,cAAM,CAACC,KAAK,CAAC,sBAAsBnB,IAAI,IAAI,EAAEK,GAAG,CAAC;IACnD;IAEA,OAAO,EAAE;EACX;AACF;AAACoB,OAAA,CAAA3B,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.injectCIONotificationPodfileCode = injectCIONotificationPodfileCode;
|
|
7
7
|
exports.injectCIOPodfileCode = injectCIOPodfileCode;
|
|
8
|
+
var _logger = require("../../utils/logger");
|
|
8
9
|
var _ios = require("../constants/ios");
|
|
9
10
|
var _codeInjection = require("./codeInjection");
|
|
10
11
|
var _fileManagement = require("./fileManagement");
|
|
@@ -26,7 +27,7 @@ ${blockEnd}
|
|
|
26
27
|
`.trim();
|
|
27
28
|
_fileManagement.FileManagement.write(filename, (0, _codeInjection.injectCodeByRegex)(podfile, lineInPodfileToInjectSnippetBefore, snippetToInjectInPodfile).join('\n'));
|
|
28
29
|
} else {
|
|
29
|
-
|
|
30
|
+
_logger.logger.info('CustomerIO Podfile snippets already exists. Skipping...');
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
async function injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmPushProvider) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_logger","require","_ios","_codeInjection","_fileManagement","injectCIOPodfileCode","iosPath","isFcmPushProvider","blockStart","blockEnd","filename","podfile","FileManagement","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","snippetToInjectInPodfile","getRelativePathToRNSDK","trim","write","injectCodeByRegex","join","logger","info","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { logger } from '../../utils/logger';\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 logger.info('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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C5D,MAAMC,QAAQ,GAAG,uCAAuC;EAExD,MAAMK,OAAO,GAAGH,OAAO,CAACI,KAAK,CAAC,IAAIC,MAAM,CAACR,UAAU,CAAC,CAAC;EAErD,IAAI,CAACM,OAAO,EAAE;IACZ,MAAMI,wBAAwB,GAAG;AACrC,EAAEV,UAAU;AACZ;AACA,IAAImB,aAAa,KAAK,QAAQ,GAAG,qCAAqC,GAAG,EAAE;AAC3E,yCAAyCpB,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBACpD,IAAAY,2BAAsB,EAACb,OAAO,CAAC;AACrD;AACA,EAAEG,QAAQ;AACV,CAAC,CAACW,IAAI,CAAC,CAAC;IAEJR,8BAAc,CAACgB,MAAM,CAAClB,QAAQ,EAAEQ,wBAAwB,CAAC;EAC3D;AACF","ignoreList":[]}
|
|
@@ -4,14 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.patchNativeSDKInitializer = patchNativeSDKInitializer;
|
|
7
|
-
var _common = require("../constants/common");
|
|
8
7
|
var _plugin = require("../../utils/plugin");
|
|
8
|
+
var _validation = require("../../utils/validation");
|
|
9
|
+
var _common = require("../constants/common");
|
|
9
10
|
/**
|
|
10
11
|
* Shared utility function to perform common SDK config replacements
|
|
11
12
|
* for both iOS and Android template files
|
|
12
13
|
*/
|
|
13
14
|
function patchNativeSDKInitializer(rawContent, platform, sdkConfig) {
|
|
14
15
|
var _siteId, _migrationSiteId;
|
|
16
|
+
// Validate SDK configuration to ensure all fields are present and
|
|
17
|
+
// correct at the time of patching in prebuild
|
|
18
|
+
(0, _validation.validateNativeSDKConfig)(sdkConfig);
|
|
15
19
|
let content = rawContent;
|
|
16
20
|
|
|
17
21
|
// Helper function to replace placeholders with platform-specific fallback values
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_plugin","require","_validation","_common","patchNativeSDKInitializer","rawContent","platform","sdkConfig","_siteId","_migrationSiteId","validateNativeSDKConfig","content","replaceValue","placeholder","value","transform","fallback","PLATFORM","ANDROID","undefined","replace","pluginVersion","getPluginVersion","cdpApiKey","region","configValue","logLevel","autoTrackDeviceAttributes","toString","trackApplicationLifecycleEvents","screenViewUse","siteId","migrationSiteId","trim"],"sources":["patchPluginNativeCode.ts"],"sourcesContent":["import type { NativeSDKConfig } from '../../types/cio-types';\nimport { getPluginVersion } from '../../utils/plugin';\nimport { validateNativeSDKConfig } from '../../utils/validation';\nimport { PLATFORM, type Platform } from '../constants/common';\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 // Validate SDK configuration to ensure all fields are present and \n // correct at the time of patching in prebuild\n validateNativeSDKConfig(sdkConfig);\n\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,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACO,SAASG,yBAAyBA,CACvCC,UAAkB,EAClBC,QAAkB,EAClBC,SAA0B,EAClB;EAAA,IAAAC,OAAA,EAAAC,gBAAA;EACR;EACA;EACA,IAAAC,mCAAuB,EAACH,SAAS,CAAC;EAElC,IAAII,OAAO,GAAGN,UAAU;;EAExB;EACA,MAAMO,YAAY,GAAGA,CACnBC,WAAmB,EACnBC,KAAoB,EACpBC,SAAqC,EACrCC,QAAgB,GAAGV,QAAQ,KAAKW,gBAAQ,CAACC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eAAe,GAAGD,MAAM;EAC1B,CAAC,MAAM,IAAIC,eAAe,IAAI,CAACD,MAAM,EAAE;IACrCA,MAAM,GAAGZ,SAAS;EACpB;;EAEA;EACAP,YAAY,CACV,kBAAkB,EAClB,EAAAJ,OAAA,GAAAuB,MAAM,cAAAvB,OAAA,uBAANA,OAAA,CAAQyB,IAAI,CAAC,CAAC,KAAId,SAAS,EAC1BM,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;EAEDb,YAAY,CACV,4BAA4B,EAC5B,EAAAH,gBAAA,GAAAuB,eAAe,cAAAvB,gBAAA,uBAAfA,gBAAA,CAAiBwB,IAAI,CAAC,CAAC,KAAId,SAAS,EACnCM,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;EAED,OAAOd,OAAO;AAChB","ignoreList":[]}
|
|
@@ -7,7 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
var _withCIOAndroid = require("./android/withCIOAndroid");
|
|
8
8
|
var _utils = require("./ios/utils");
|
|
9
9
|
var _withCIOIos = require("./ios/withCIOIos");
|
|
10
|
-
var _validation = require("./utils/validation");
|
|
11
10
|
// Entry point for config plugin
|
|
12
11
|
function withCustomerIOPlugin(config, props) {
|
|
13
12
|
// Check if config is being used with unsupported Expo version
|
|
@@ -15,16 +14,9 @@ function withCustomerIOPlugin(config, props) {
|
|
|
15
14
|
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.');
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
if (props.ios) {
|
|
23
|
-
config = (0, _withCIOIos.withCIOIos)(config, props.config, props.ios);
|
|
24
|
-
}
|
|
25
|
-
if (props.android) {
|
|
26
|
-
config = (0, _withCIOAndroid.withCIOAndroid)(config, props.config, props.android);
|
|
27
|
-
}
|
|
17
|
+
// Apply platform specific modifications
|
|
18
|
+
config = (0, _withCIOIos.withCIOIos)(config, props.config, props.ios);
|
|
19
|
+
config = (0, _withCIOAndroid.withCIOAndroid)(config, props.config, props.android);
|
|
28
20
|
return config;
|
|
29
21
|
}
|
|
30
22
|
var _default = exports.default = withCustomerIOPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_withCIOAndroid","require","_utils","_withCIOIos","
|
|
1
|
+
{"version":3,"names":["_withCIOAndroid","require","_utils","_withCIOIos","withCustomerIOPlugin","config","props","isExpoVersion53OrHigher","Error","withCIOIos","ios","withCIOAndroid","android","_default","exports","default"],"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';\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 // Apply platform specific modifications\n config = withCIOIos(config, props.config, props.ios);\n config = withCIOAndroid(config, props.config, props.android);\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAGA;AACA,SAASG,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA;EACA,IAAIA,KAAK,CAACD,MAAM,IAAI,CAAC,IAAAE,8BAAuB,EAACF,MAAM,CAAC,EAAE;IACpD,MAAM,IAAIG,KAAK,CACb,mFAAmF,GACnF,uEAAuE,GACvE,kDACF,CAAC;EACH;;EAEA;EACAH,MAAM,GAAG,IAAAI,sBAAU,EAACJ,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACI,GAAG,CAAC;EACpDL,MAAM,GAAG,IAAAM,8BAAc,EAACN,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACM,OAAO,CAAC;EAE5D,OAAOP,MAAM;AACf;AAAC,IAAAQ,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcX,oBAAoB","ignoreList":[]}
|
|
@@ -9,6 +9,7 @@ var _Paths = require("@expo/config-plugins/build/ios/Paths");
|
|
|
9
9
|
var _ios = require("../helpers/constants/ios");
|
|
10
10
|
var _codeInjection = require("../helpers/utils/codeInjection");
|
|
11
11
|
var _fileManagement = require("../helpers/utils/fileManagement");
|
|
12
|
+
var _logger = require("../utils/logger");
|
|
12
13
|
var _utils = require("./utils");
|
|
13
14
|
const addImport = (stringContents, appName) => {
|
|
14
15
|
const importRegex = /^(#import .*)\n/gm;
|
|
@@ -137,7 +138,7 @@ const withAppDelegateModifications = (configOuter, props) => {
|
|
|
137
138
|
stringContents = addExpoNotificationsHeaderModification(stringContents);
|
|
138
139
|
config.modResults.contents = stringContents;
|
|
139
140
|
} else {
|
|
140
|
-
|
|
141
|
+
_logger.logger.info('Customerio AppDelegate changes already exist. Skipping...');
|
|
141
142
|
}
|
|
142
143
|
return config;
|
|
143
144
|
});
|