customerio-expo-plugin 0.0.5 → 1.0.0-alpha.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.
Files changed (155) hide show
  1. package/lib/commonjs/analytics/injectAnalytics.js +31 -0
  2. package/lib/commonjs/analytics/injectAnalytics.js.map +1 -0
  3. package/lib/commonjs/android/withAppGoogleServices.js +22 -0
  4. package/lib/commonjs/android/withAppGoogleServices.js.map +1 -0
  5. package/lib/commonjs/android/withCIOAndroid.js +18 -0
  6. package/lib/commonjs/android/withCIOAndroid.js.map +1 -0
  7. package/lib/commonjs/android/withGistMavenRepository.js +21 -0
  8. package/lib/commonjs/android/withGistMavenRepository.js.map +1 -0
  9. package/lib/commonjs/android/withGoogleServicesJSON.js +34 -0
  10. package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -0
  11. package/lib/commonjs/android/withProjectGoogleServices.js +20 -0
  12. package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -0
  13. package/lib/commonjs/helpers/constants/android.js +21 -0
  14. package/lib/commonjs/helpers/constants/android.js.map +1 -0
  15. package/lib/commonjs/helpers/constants/globals.d.js +2 -0
  16. package/lib/commonjs/helpers/constants/globals.d.js.map +1 -0
  17. package/lib/commonjs/helpers/constants/ios.js +140 -0
  18. package/lib/commonjs/helpers/constants/ios.js.map +1 -0
  19. package/{build/helpers/ios/CIONotificationService-Info.plist → lib/commonjs/helpers/native-files/ios/NotificationService-Info.plist} +2 -2
  20. package/{build/helpers/ios/CIONotificationService.h → lib/commonjs/helpers/native-files/ios/NotificationService.h} +0 -0
  21. package/{build/helpers/ios/CIONotificationService.m → lib/commonjs/helpers/native-files/ios/NotificationService.m} +2 -6
  22. package/{build/helpers/ios/CIONotificationService.swift → lib/commonjs/helpers/native-files/ios/NotificationService.swift} +0 -2
  23. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/PushNotification.swift +1 -10
  24. package/lib/commonjs/helpers/utils/codeInjection.js +33 -0
  25. package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -0
  26. package/lib/commonjs/helpers/utils/fileManagement.js +76 -0
  27. package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -0
  28. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +37 -0
  29. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  30. package/lib/commonjs/index.js +23 -0
  31. package/lib/commonjs/index.js.map +1 -0
  32. package/lib/commonjs/ios/withAppDelegateModifications.js +85 -0
  33. package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -0
  34. package/lib/commonjs/ios/withAppDelegateXcodeProject.js +79 -0
  35. package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +1 -0
  36. package/lib/commonjs/ios/withCIOIos.js +23 -0
  37. package/lib/commonjs/ios/withCIOIos.js.map +1 -0
  38. package/lib/commonjs/ios/withNotificationsXcodeProject.js +158 -0
  39. package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -0
  40. package/lib/commonjs/ios/withXcodeProject.js +28 -0
  41. package/lib/commonjs/ios/withXcodeProject.js.map +1 -0
  42. package/lib/commonjs/types/cio-types.js +2 -0
  43. package/lib/commonjs/types/cio-types.js.map +1 -0
  44. package/lib/commonjs/version.js +9 -0
  45. package/lib/commonjs/version.js.map +1 -0
  46. package/lib/module/analytics/injectAnalytics.js +24 -0
  47. package/lib/module/analytics/injectAnalytics.js.map +1 -0
  48. package/lib/module/android/withAppGoogleServices.js +15 -0
  49. package/lib/module/android/withAppGoogleServices.js.map +1 -0
  50. package/lib/module/android/withCIOAndroid.js +12 -0
  51. package/lib/module/android/withCIOAndroid.js.map +1 -0
  52. package/lib/module/android/withGistMavenRepository.js +14 -0
  53. package/lib/module/android/withGistMavenRepository.js.map +1 -0
  54. package/lib/module/android/withGoogleServicesJSON.js +27 -0
  55. package/lib/module/android/withGoogleServicesJSON.js.map +1 -0
  56. package/lib/module/android/withProjectGoogleServices.js +13 -0
  57. package/lib/module/android/withProjectGoogleServices.js.map +1 -0
  58. package/lib/module/helpers/constants/android.js +8 -0
  59. package/lib/module/helpers/constants/android.js.map +1 -0
  60. package/lib/module/helpers/constants/globals.d.js +2 -0
  61. package/lib/module/helpers/constants/globals.d.js.map +1 -0
  62. package/lib/module/helpers/constants/ios.js +103 -0
  63. package/lib/module/helpers/constants/ios.js.map +1 -0
  64. package/lib/module/helpers/native-files/ios/NotificationService-Info.plist +31 -0
  65. package/lib/module/helpers/native-files/ios/NotificationService.h +5 -0
  66. package/lib/module/helpers/native-files/ios/NotificationService.m +26 -0
  67. package/lib/module/helpers/native-files/ios/NotificationService.swift +19 -0
  68. package/lib/module/helpers/native-files/ios/PushNotification.swift +47 -0
  69. package/lib/module/helpers/utils/codeInjection.js +24 -0
  70. package/lib/module/helpers/utils/codeInjection.js.map +1 -0
  71. package/lib/module/helpers/utils/fileManagement.js +69 -0
  72. package/lib/module/helpers/utils/fileManagement.js.map +1 -0
  73. package/lib/module/helpers/utils/injectCIOPodfileCode.js +30 -0
  74. package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  75. package/lib/module/index.js +16 -0
  76. package/lib/module/index.js.map +1 -0
  77. package/lib/module/ios/withAppDelegateModifications.js +78 -0
  78. package/lib/module/ios/withAppDelegateModifications.js.map +1 -0
  79. package/lib/module/ios/withAppDelegateXcodeProject.js +71 -0
  80. package/lib/module/ios/withAppDelegateXcodeProject.js.map +1 -0
  81. package/lib/module/ios/withCIOIos.js +17 -0
  82. package/lib/module/ios/withCIOIos.js.map +1 -0
  83. package/lib/module/ios/withNotificationsXcodeProject.js +150 -0
  84. package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -0
  85. package/lib/module/ios/withXcodeProject.js +21 -0
  86. package/lib/module/ios/withXcodeProject.js.map +1 -0
  87. package/lib/module/types/cio-types.js +2 -0
  88. package/lib/module/types/cio-types.js.map +1 -0
  89. package/lib/module/version.js +2 -0
  90. package/lib/module/version.js.map +1 -0
  91. package/lib/typescript/analytics/injectAnalytics.d.ts +3 -0
  92. package/lib/typescript/android/withAppGoogleServices.d.ts +3 -0
  93. package/lib/typescript/android/withCIOAndroid.d.ts +3 -0
  94. package/lib/typescript/android/withGistMavenRepository.d.ts +3 -0
  95. package/lib/typescript/android/withGoogleServicesJSON.d.ts +3 -0
  96. package/lib/typescript/android/withProjectGoogleServices.d.ts +3 -0
  97. package/lib/typescript/helpers/constants/android.d.ts +7 -0
  98. package/lib/typescript/helpers/constants/ios.d.ts +31 -0
  99. package/lib/typescript/helpers/utils/codeInjection.d.ts +4 -0
  100. package/lib/typescript/helpers/utils/fileManagement.d.ts +12 -0
  101. package/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +2 -0
  102. package/lib/typescript/index.d.ts +4 -0
  103. package/lib/typescript/ios/withAppDelegateModifications.d.ts +2 -0
  104. package/lib/typescript/ios/withAppDelegateXcodeProject.d.ts +3 -0
  105. package/lib/typescript/ios/withCIOIos.d.ts +3 -0
  106. package/lib/typescript/ios/withNotificationsXcodeProject.d.ts +3 -0
  107. package/lib/typescript/ios/withXcodeProject.d.ts +3 -0
  108. package/lib/typescript/types/cio-types.d.ts +25 -0
  109. package/lib/typescript/version.d.ts +1 -0
  110. package/package.json +88 -13
  111. package/src/analytics/injectAnalytics.ts +36 -0
  112. package/src/android/withAppGoogleServices.ts +26 -0
  113. package/src/android/withCIOAndroid.ts +19 -0
  114. package/src/android/withGistMavenRepository.ts +26 -0
  115. package/src/android/withGoogleServicesJSON.ts +36 -0
  116. package/src/android/withProjectGoogleServices.ts +24 -0
  117. package/src/helpers/constants/android.ts +14 -0
  118. package/src/helpers/constants/globals.d.ts +8 -0
  119. package/src/helpers/constants/ios.ts +116 -0
  120. package/src/helpers/native-files/ios/NotificationService-Info.plist +31 -0
  121. package/src/helpers/native-files/ios/NotificationService.h +5 -0
  122. package/src/helpers/native-files/ios/NotificationService.m +26 -0
  123. package/src/helpers/native-files/ios/NotificationService.swift +19 -0
  124. package/src/helpers/native-files/ios/PushNotification.swift +47 -0
  125. package/src/helpers/utils/codeInjection.ts +46 -0
  126. package/src/helpers/utils/fileManagement.ts +87 -0
  127. package/src/helpers/utils/injectCIOPodfileCode.ts +53 -0
  128. package/src/index.ts +26 -0
  129. package/src/ios/withAppDelegateModifications.ts +166 -0
  130. package/src/ios/withAppDelegateXcodeProject.ts +89 -0
  131. package/src/ios/withCIOIos.ts +25 -0
  132. package/src/ios/withNotificationsXcodeProject.ts +237 -0
  133. package/src/ios/withXcodeProject.ts +25 -0
  134. package/src/types/cio-types.ts +31 -0
  135. package/src/version.ts +1 -0
  136. package/build/helpers/.DS_Store +0 -0
  137. package/build/helpers/ios/.DS_Store +0 -0
  138. package/build/package.json +0 -36
  139. package/build/src/android/withAppGoogleServices.js +0 -12
  140. package/build/src/android/withCIOAndroid.js +0 -15
  141. package/build/src/android/withGistMavenRepository.js +0 -12
  142. package/build/src/android/withGoogleServicesJSON.js +0 -24
  143. package/build/src/android/withProjectGoogleServices.js +0 -12
  144. package/build/src/helpers/constants/android.js +0 -9
  145. package/build/src/helpers/constants/ios.js +0 -102
  146. package/build/src/helpers/utils/codeInjection.js +0 -30
  147. package/build/src/helpers/utils/fileManagement.js +0 -40
  148. package/build/src/helpers/utils/injectCIOPodfileCode.js +0 -37
  149. package/build/src/index.js +0 -11
  150. package/build/src/ios/withAppDelegateModifications.js +0 -77
  151. package/build/src/ios/withAppDelegateXcodeProject.js +0 -78
  152. package/build/src/ios/withCIOIos.js +0 -15
  153. package/build/src/ios/withNotificationsXcodeProject.js +0 -133
  154. package/build/src/ios/withXcodeProject.js +0 -22
  155. package/build/src/types/cio-types.js +0 -8
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.injectCIONotificationPodfileCode = injectCIONotificationPodfileCode;
7
+ exports.injectCIOPodfileCode = injectCIOPodfileCode;
8
+ var _ios = require("../constants/ios");
9
+ var _fileManagement = require("./fileManagement");
10
+ async function injectCIOPodfileCode(iosPath) {
11
+ const filename = `${iosPath}/Podfile`;
12
+ const podfile = await _fileManagement.FileManagement.read(filename);
13
+ const matches = podfile.match(_ios.CIO_PODFILE_REGEX);
14
+ const targetMatch = podfile.match(_ios.CIO_CIO_TARGET_REGEX);
15
+ if (!targetMatch) {
16
+ const lines = podfile.split('\n');
17
+ const index = lines.findIndex(line => _ios.CIO_PODFILE_POST_INSTALL_REGEX.test(line));
18
+ let content = lines;
19
+ if (index > -1) {
20
+ content = [...lines.slice(0, index - 1), !matches ? _ios.CIO_PODFILE_SNIPPET : '', _ios.CIO_PODFILE_TARGET_NAMES_SNIPPET, ...lines.slice(index - 1, index + 1), _ios.CIO_PODFILE_POST_INSTALL_SNIPPET, ...lines.slice(index + 1)];
21
+ } else {
22
+ content.push(_ios.CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);
23
+ }
24
+ _fileManagement.FileManagement.write(filename, content.join('\n'));
25
+ } else {
26
+ console.log('Customerio Podfile snippets already exists. Skipping...');
27
+ }
28
+ }
29
+ async function injectCIONotificationPodfileCode(iosPath) {
30
+ const filename = `${iosPath}/Podfile`;
31
+ const podfile = await _fileManagement.FileManagement.read(filename);
32
+ const matches = podfile.match(_ios.CIO_PODFILE_NOTIFICATION_REGEX);
33
+ if (!matches) {
34
+ _fileManagement.FileManagement.append(filename, _ios.CIO_PODFILE_NOTIFICATION_SNIPPET);
35
+ }
36
+ }
37
+ //# sourceMappingURL=injectCIOPodfileCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["injectCIOPodfileCode","iosPath","filename","podfile","FileManagement","read","matches","match","CIO_PODFILE_REGEX","targetMatch","CIO_CIO_TARGET_REGEX","lines","split","index","findIndex","line","CIO_PODFILE_POST_INSTALL_REGEX","test","content","slice","CIO_PODFILE_SNIPPET","CIO_PODFILE_TARGET_NAMES_SNIPPET","CIO_PODFILE_POST_INSTALL_SNIPPET","push","CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET","write","join","console","log","injectCIONotificationPodfileCode","CIO_PODFILE_NOTIFICATION_REGEX","append","CIO_PODFILE_NOTIFICATION_SNIPPET"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import {\n CIO_PODFILE_REGEX,\n CIO_PODFILE_SNIPPET,\n CIO_PODFILE_POST_INSTALL_REGEX,\n CIO_PODFILE_TARGET_NAMES_SNIPPET,\n CIO_PODFILE_POST_INSTALL_SNIPPET,\n CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET,\n CIO_PODFILE_NOTIFICATION_SNIPPET,\n CIO_PODFILE_NOTIFICATION_REGEX,\n CIO_CIO_TARGET_REGEX,\n} from '../constants/ios';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_REGEX);\n const targetMatch = podfile.match(CIO_CIO_TARGET_REGEX);\n\n if (!targetMatch) {\n const lines = podfile.split('\\n');\n const index = lines.findIndex((line) =>\n CIO_PODFILE_POST_INSTALL_REGEX.test(line)\n );\n let content: string[] = lines;\n if (index > -1) {\n content = [\n ...lines.slice(0, index - 1),\n !matches ? CIO_PODFILE_SNIPPET : '',\n CIO_PODFILE_TARGET_NAMES_SNIPPET,\n ...lines.slice(index - 1, index + 1),\n CIO_PODFILE_POST_INSTALL_SNIPPET,\n ...lines.slice(index + 1),\n ];\n } else {\n content.push(CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);\n }\n\n FileManagement.write(filename, content.join('\\n'));\n } else {\n console.log('Customerio Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(iosPath: string) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_NOTIFICATION_REGEX);\n\n if (!matches) {\n FileManagement.append(filename, CIO_PODFILE_NOTIFICATION_SNIPPET);\n }\n}\n"],"mappings":";;;;;;;AAAA;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AME,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EACnD,MAAMI,OAAO,GAAGH,OAAO,CAACI,KAAK,CAACuB,mCAA8B,CAAC;EAE7D,IAAI,CAACxB,OAAO,EAAE;IACZF,8BAAc,CAAC2B,MAAM,CAAC7B,QAAQ,EAAE8B,qCAAgC,CAAC;EACnE;AACF"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _injectAnalytics = require("./analytics/injectAnalytics");
8
+ var _withCIOAndroid = require("./android/withCIOAndroid");
9
+ var _withCIOIos = require("./ios/withCIOIos");
10
+ // Entry point for config plugin
11
+ function withCustomerIOPlugin(config, props) {
12
+ if (props.ios) {
13
+ config = (0, _withCIOIos.withCIOIos)(config, props.ios);
14
+ }
15
+ if (props.android) {
16
+ config = (0, _withCIOAndroid.withCIOAndroid)(config, props.android);
17
+ }
18
+ config = (0, _injectAnalytics.withAnalytics)(config, props);
19
+ return config;
20
+ }
21
+ var _default = withCustomerIOPlugin;
22
+ exports.default = _default;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withCustomerIOPlugin","config","props","ios","withCIOIos","android","withCIOAndroid","withAnalytics"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withAnalytics } from './analytics/injectAnalytics';\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 config = withAnalytics(config, props);\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":";;;;;;AAEA;AACA;AACA;AAGA;AACA,SAASA,oBAAoB,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA,IAAIA,KAAK,CAACC,GAAG,EAAE;IACbF,MAAM,GAAG,IAAAG,sBAAU,EAACH,MAAM,EAAEC,KAAK,CAACC,GAAG,CAAC;EACxC;EAEA,IAAID,KAAK,CAACG,OAAO,EAAE;IACjBJ,MAAM,GAAG,IAAAK,8BAAc,EAACL,MAAM,EAAEC,KAAK,CAACG,OAAO,CAAC;EAChD;EAEAJ,MAAM,GAAG,IAAAM,8BAAa,EAACN,MAAM,EAAEC,KAAK,CAAC;EAErC,OAAOD,MAAM;AACf;AAAC,eAEcD,oBAAoB;AAAA"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withAppDelegateModifications = void 0;
7
+ var _configPlugins = require("@expo/config-plugins");
8
+ var _Paths = require("@expo/config-plugins/build/ios/Paths");
9
+ var _ios = require("../helpers/constants/ios");
10
+ var _codeInjection = require("../helpers/utils/codeInjection");
11
+ var _fileManagement = require("../helpers/utils/fileManagement");
12
+ const pushCodeSnippets = [_ios.CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET, _ios.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET];
13
+ const additionalMethodsForPushNotifications = `${pushCodeSnippets.join('\n')}\n`; // Join newlines and ensure a newline at the end.
14
+
15
+ const addImport = (stringContents, appName) => {
16
+ const importRegex = /^(#import .*)\n/gm;
17
+ const addedImport = getImportSnippet(appName);
18
+ const match = stringContents.match(importRegex);
19
+ let endOfMatchIndex;
20
+ if (!match || match.index === undefined) {
21
+ // No imports found, just add to start of file:
22
+ endOfMatchIndex = 0;
23
+ } else {
24
+ // Add after first import:
25
+ endOfMatchIndex = match.index + match[0].length;
26
+ }
27
+ stringContents = (0, _codeInjection.injectCodeByLineNumber)(stringContents, endOfMatchIndex, addedImport).join('\n');
28
+ return stringContents;
29
+ };
30
+ const addNotificationHandlerDeclaration = stringContents => {
31
+ stringContents = (0, _codeInjection.injectCodeByMultiLineRegex)(stringContents, _ios.CIO_APPDELEGATEDECLARATION_REGEX, _ios.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET);
32
+ return stringContents;
33
+ };
34
+ const addNotificationConfiguration = stringContents => {
35
+ stringContents = (0, _codeInjection.injectCodeByMultiLineRegex)(stringContents, _ios.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, _ios.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET);
36
+ return stringContents;
37
+ };
38
+ const addDidFailToRegisterForRemoteNotificationsWithError = stringContents => {
39
+ stringContents = (0, _codeInjection.injectCodeByMultiLineRegexAndReplaceLine)(stringContents, _ios.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX, _ios.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET);
40
+ return stringContents;
41
+ };
42
+ const AddDidRegisterForRemoteNotificationsWithDeviceToken = stringContents => {
43
+ stringContents = (0, _codeInjection.injectCodeByMultiLineRegexAndReplaceLine)(stringContents, _ios.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX, _ios.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET);
44
+ return stringContents;
45
+ };
46
+ const addAdditionalMethodsForPushNotifications = stringContents => {
47
+ stringContents = (0, _codeInjection.injectCodeByMultiLineRegex)(stringContents, _ios.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX, additionalMethodsForPushNotifications);
48
+ return stringContents;
49
+ };
50
+ const addAppdelegateHeaderModification = stringContents => {
51
+ stringContents = (0, _codeInjection.injectCodeByMultiLineRegexAndReplaceLine)(stringContents, _ios.CIO_APPDELEGATEHEADER_REGEX, _ios.CIO_APPDELEGATEHEADER_SNIPPET);
52
+ return stringContents;
53
+ };
54
+ const withAppDelegateModifications = configOuter => {
55
+ return (0, _configPlugins.withAppDelegate)(configOuter, async config => {
56
+ let stringContents = config.modResults.contents;
57
+ const regex = new RegExp(`#import <${config.modRequest.projectName}-Swift.h>`);
58
+ const match = stringContents.match(regex);
59
+ if (!match) {
60
+ const headerPath = (0, _Paths.getAppDelegateHeaderFilePath)(config.modRequest.projectRoot);
61
+ let headerContent = await _fileManagement.FileManagement.read(headerPath);
62
+ headerContent = addAppdelegateHeaderModification(headerContent);
63
+ _fileManagement.FileManagement.write(headerPath, headerContent);
64
+ stringContents = addImport(stringContents, config.modRequest.projectName);
65
+ stringContents = addNotificationHandlerDeclaration(stringContents);
66
+ stringContents = addNotificationConfiguration(stringContents);
67
+ stringContents = addAdditionalMethodsForPushNotifications(stringContents);
68
+ stringContents = addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
69
+ stringContents = AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
70
+ config.modResults.contents = stringContents;
71
+ } else {
72
+ console.log('Customerio AppDelegate changes already exist. Skipping...');
73
+ }
74
+ return config;
75
+ });
76
+ };
77
+ exports.withAppDelegateModifications = withAppDelegateModifications;
78
+ function getImportSnippet(appName) {
79
+ return `
80
+ // Add swift bridge imports
81
+ #import <ExpoModulesCore-Swift.h>
82
+ #import <${appName}-Swift.h>
83
+ `;
84
+ }
85
+ //# sourceMappingURL=withAppDelegateModifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["pushCodeSnippets","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","additionalMethodsForPushNotifications","join","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","injectCodeByLineNumber","addNotificationHandlerDeclaration","injectCodeByMultiLineRegex","CIO_APPDELEGATEDECLARATION_REGEX","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","addNotificationConfiguration","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","addDidFailToRegisterForRemoteNotificationsWithError","injectCodeByMultiLineRegexAndReplaceLine","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","AddDidRegisterForRemoteNotificationsWithDeviceToken","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","addAdditionalMethodsForPushNotifications","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","addAppdelegateHeaderModification","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_SNIPPET","withAppDelegateModifications","configOuter","withAppDelegate","config","modResults","contents","regex","RegExp","modRequest","projectName","headerPath","getAppDelegateHeaderFilePath","projectRoot","headerContent","FileManagement","read","write","console","log"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import { ConfigPlugin, withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\n\nconst pushCodeSnippets = [\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n];\n\nconst additionalMethodsForPushNotifications = `${pushCodeSnippets.join(\n '\\n'\n)}\\n`; // Join newlines and ensure a newline at the end.\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 ).join('\\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 = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_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\nconst addAdditionalMethodsForPushNotifications = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n additionalMethodsForPushNotifications\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET\n );\n\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<any> = (\n configOuter\n) => {\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 stringContents = addNotificationConfiguration(stringContents);\n stringContents = addAdditionalMethodsForPushNotifications(stringContents);\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n AddDidRegisterForRemoteNotificationsWithDeviceToken(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":";;;;;;AAAA;AACA;AAEA;AAeA;AAKA;AAEA,MAAMA,gBAAgB,GAAG,CACvBC,sDAAiD,EACjDC,+CAA0C,CAC3C;AAED,MAAMC,qCAAqC,GAAI,GAAEH,gBAAgB,CAACI,IAAI,CACpE,IAAI,CACJ,IAAG,CAAC,CAAC;;AAEP,MAAMC,SAAS,GAAG,CAACC,cAAsB,EAAEC,OAAe,KAAK;EAC7D,MAAMC,WAAW,GAAG,mBAAmB;EACvC,MAAMC,WAAW,GAAGC,gBAAgB,CAACH,OAAO,CAAC;EAE7C,MAAMI,KAAK,GAAGL,cAAc,CAACK,KAAK,CAACH,WAAW,CAAC;EAC/C,IAAII,eAAuB;EAC3B,IAAI,CAACD,KAAK,IAAIA,KAAK,CAACE,KAAK,KAAKC,SAAS,EAAE;IACvC;IACAF,eAAe,GAAG,CAAC;EACrB,CAAC,MAAM;IACL;IACAA,eAAe,GAAGD,KAAK,CAACE,KAAK,GAAGF,KAAK,CAAC,CAAC,CAAC,CAACI,MAAM;EACjD;EAEAT,cAAc,GAAG,IAAAU,qCAAsB,EACrCV,cAAc,EACdM,eAAe,EACfH,WAAW,CACZ,CAACL,IAAI,CAAC,IAAI,CAAC;EAEZ,OAAOE,cAAc;AACvB,CAAC;AAED,MAAMW,iCAAiC,GAAIX,cAAsB,IAAK;EACpEA,cAAc,GAAG,IAAAY,yCAA0B,EACzCZ,cAAc,EACda,qCAAgC,EAChCC,mDAA8C,CAC/C;EAED,OAAOd,cAAc;AACvB,CAAC;AAED,MAAMe,4BAA4B,GAAIf,cAAsB,IAAK;EAC/DA,cAAc,GAAG,IAAAY,yCAA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,IAAI,CAACL,UAAU,CAAC;MACzDG,aAAa,GAAGhB,gCAAgC,CAACgB,aAAa,CAAC;MAC/DC,8BAAc,CAACE,KAAK,CAACN,UAAU,EAAEG,aAAa,CAAC;MAE/C3C,cAAc,GAAGD,SAAS,CACxBC,cAAc,EACdiC,MAAM,CAACK,UAAU,CAACC,WAAW,CAC9B;MACDvC,cAAc,GAAGW,iCAAiC,CAACX,cAAc,CAAC;MAClEA,cAAc,GAAGe,4BAA4B,CAACf,cAAc,CAAC;MAC7DA,cAAc,GAAGyB,wCAAwC,CAACzB,cAAc,CAAC;MACzEA,cAAc,GACZkB,mDAAmD,CAAClB,cAAc,CAAC;MACrEA,cAAc,GACZsB,mDAAmD,CAACtB,cAAc,CAAC;MAErEiC,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGnC,cAAc;IAC7C,CAAC,MAAM;MACL+C,OAAO,CAACC,GAAG,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOf,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAAC;AACF,SAAS7B,gBAAgB,CAACH,OAAe,EAAE;EACzC,OAAQ;AACV;AACA;AACA,WAAWA,OAAQ;AACnB,GAAG;AACH"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withCioAppdelegateXcodeProject = void 0;
7
+ var _configPlugins = require("@expo/config-plugins");
8
+ var _xcode = _interopRequireDefault(require("xcode"));
9
+ var _ios = require("../helpers/constants/ios");
10
+ var _fileManagement = require("./../helpers/utils/fileManagement");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ const addNotificationSwiftFile = async options => {
13
+ const {
14
+ iosPath,
15
+ appName
16
+ } = options;
17
+ const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
18
+ const xcodeProject = _xcode.default.project(projPath);
19
+ xcodeProject.parse(async function (err) {
20
+ const file = 'PushNotification.swift';
21
+ const getTargetFile = filename => `${iosPath}/${appName}/${filename}`;
22
+ if (err) {
23
+ throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
24
+ }
25
+ if (!_fileManagement.FileManagement.exists(getTargetFile(file))) {
26
+ _fileManagement.FileManagement.mkdir(`${iosPath}/${appName}`, {
27
+ recursive: true
28
+ });
29
+ const targetFile = getTargetFile(file);
30
+ _fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
31
+ } else {
32
+ console.log(`${getTargetFile(file)} already exists. Skipping...`);
33
+ }
34
+ });
35
+ };
36
+ const withCioAppdelegateXcodeProject = (configOuter, props) => {
37
+ return (0, _configPlugins.withXcodeProject)(configOuter, async config => {
38
+ const {
39
+ modRequest,
40
+ ios,
41
+ version: bundleShortVersion
42
+ } = config;
43
+ const {
44
+ appleTeamId,
45
+ iosDeploymentTarget
46
+ } = props;
47
+ if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js.');
48
+ const {
49
+ projectName,
50
+ platformProjectRoot
51
+ } = modRequest;
52
+ const {
53
+ bundleIdentifier,
54
+ buildNumber
55
+ } = ios;
56
+ if (bundleShortVersion === undefined) {
57
+ throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js');
58
+ }
59
+ if (bundleIdentifier === undefined) {
60
+ throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js');
61
+ }
62
+ if (projectName === undefined) {
63
+ throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js');
64
+ }
65
+ const options = {
66
+ appleTeamId,
67
+ bundleIdentifier,
68
+ bundleShortVersion,
69
+ bundleVersion: buildNumber || _ios.DEFAULT_BUNDLE_VERSION,
70
+ iosPath: platformProjectRoot,
71
+ appName: projectName,
72
+ iosDeploymentTarget
73
+ };
74
+ await addNotificationSwiftFile(options);
75
+ return config;
76
+ });
77
+ };
78
+ exports.withCioAppdelegateXcodeProject = withCioAppdelegateXcodeProject;
79
+ //# sourceMappingURL=withAppDelegateXcodeProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["addNotificationSwiftFile","options","iosPath","appName","projPath","xcodeProject","xcode","project","parse","err","file","getTargetFile","filename","Error","JSON","stringify","FileManagement","exists","mkdir","recursive","targetFile","copyFile","LOCAL_PATH_TO_CIO_NSE_FILES","console","log","withCioAppdelegateXcodeProject","configOuter","props","withXcodeProject","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","undefined","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","DEFAULT_BUNDLE_VERSION"],"sources":["withAppDelegateXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport xcode from 'xcode';\n\nimport {\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\n\nconst addNotificationSwiftFile = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n const { iosPath, appName } = options;\n const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;\n const xcodeProject = xcode.project(projPath);\n\n xcodeProject.parse(async function (err: Error) {\n const file = 'PushNotification.swift';\n const getTargetFile = (filename: string) =>\n `${iosPath}/${appName}/${filename}`;\n if (err) {\n throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);\n }\n\n if (!FileManagement.exists(getTargetFile(file))) {\n FileManagement.mkdir(`${iosPath}/${appName}`, {\n recursive: true,\n });\n\n const targetFile = getTargetFile(file);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(file)} already exists. Skipping...`);\n }\n });\n};\n\nexport const withCioAppdelegateXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js.'\n );\n\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js'\n );\n }\n\n const options = {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n iosDeploymentTarget,\n };\n\n await addNotificationSwiftFile(options);\n\n return config;\n });\n};\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AAKA;AAAmE;AAEnE,MAAMA,wBAAwB,GAAG,MAC/BC,OAAmC,IAChC;EACH,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGF,OAAO;EACpC,MAAMG,QAAQ,GAAI,GAAEF,OAAQ,IAAGC,OAAQ,4BAA2B;EAClE,MAAME,YAAY,GAAGC,cAAK,CAACC,OAAO,CAACH,QAAQ,CAAC;EAE5CC,YAAY,CAACG,KAAK,CAAC,gBAAgBC,GAAU,EAAE;IAC7C,MAAMC,IAAI,GAAG,wBAAwB;IACrC,MAAMC,aAAa,GAAIC,QAAgB,IACpC,GAAEV,OAAQ,IAAGC,OAAQ,IAAGS,QAAS,EAAC;IACrC,IAAIH,GAAG,EAAE;MACP,MAAM,IAAII,KAAK,CAAE,8BAA6BC,IAAI,CAACC,SAAS,CAACN,GAAG,CAAE,EAAC,CAAC;IACtE;IAEA,IAAI,CAACO,8BAAc,CAACC,MAAM,CAACN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B;MAClBQ,aAAa,EAAED,WAAW,IAAIE,2BAAsB;MACpDxC,OAAO,EAAEoC,mBAAmB;MAC5BnC,OAAO,EAAEkC,WAAW;MACpBF;IACF,CAAC;IAED,MAAMnC,wBAAwB,CAACC,OAAO,CAAC;IAEvC,OAAO4B,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withCIOIos = withCIOIos;
7
+ var _withAppDelegateModifications = require("./withAppDelegateModifications");
8
+ var _withAppDelegateXcodeProject = require("./withAppDelegateXcodeProject");
9
+ var _withNotificationsXcodeProject = require("./withNotificationsXcodeProject");
10
+ var _withXcodeProject = require("./withXcodeProject");
11
+ function withCIOIos(config, props) {
12
+ var _props$pushNotificati;
13
+ if ((_props$pushNotificati = props.pushNotification) !== null && _props$pushNotificati !== void 0 && _props$pushNotificati.useRichPush) {
14
+ config = (0, _withNotificationsXcodeProject.withCioNotificationsXcodeProject)(config, props);
15
+ }
16
+ if (props.pushNotification) {
17
+ config = (0, _withAppDelegateModifications.withAppDelegateModifications)(config, props);
18
+ config = (0, _withAppDelegateXcodeProject.withCioAppdelegateXcodeProject)(config, props);
19
+ }
20
+ config = (0, _withXcodeProject.withCioXcodeProject)(config, props);
21
+ return config;
22
+ }
23
+ //# sourceMappingURL=withCIOIos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withCIOIos","config","props","pushNotification","useRichPush","withCioNotificationsXcodeProject","withAppDelegateModifications","withCioAppdelegateXcodeProject","withCioXcodeProject"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioAppdelegateXcodeProject } from './withAppDelegateXcodeProject';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n if (props.pushNotification?.useRichPush) {\n config = withCioNotificationsXcodeProject(config, props);\n }\n\n if (props.pushNotification) {\n config = withAppDelegateModifications(config, props);\n config = withCioAppdelegateXcodeProject(config, props);\n }\n\n config = withCioXcodeProject(config, props);\n\n return config;\n}\n"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AAEO,SAASA,UAAU,CACxBC,MAAkB,EAClBC,KAAiC,EACjC;EAAA;EACA,6BAAIA,KAAK,CAACC,gBAAgB,kDAAtB,sBAAwBC,WAAW,EAAE;IACvCH,MAAM,GAAG,IAAAI,+DAAgC,EAACJ,MAAM,EAAEC,KAAK,CAAC;EAC1D;EAEA,IAAIA,KAAK,CAACC,gBAAgB,EAAE;IAC1BF,MAAM,GAAG,IAAAK,0DAA4B,EAACL,MAAM,EAAEC,KAAK,CAAC;IACpDD,MAAM,GAAG,IAAAM,2DAA8B,EAACN,MAAM,EAAEC,KAAK,CAAC;EACxD;EAEAD,MAAM,GAAG,IAAAO,qCAAmB,EAACP,MAAM,EAAEC,KAAK,CAAC;EAE3C,OAAOD,MAAM;AACf"}
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withCioNotificationsXcodeProject = void 0;
7
+ var _configPlugins = require("@expo/config-plugins");
8
+ var _xcode = _interopRequireDefault(require("xcode"));
9
+ var _ios = require("../helpers/constants/ios");
10
+ var _codeInjection = require("../helpers/utils/codeInjection");
11
+ var _injectCIOPodfileCode = require("../helpers/utils/injectCIOPodfileCode");
12
+ var _fileManagement = require("./../helpers/utils/fileManagement");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ const PLIST_FILENAME = `${_ios.CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
15
+ const TARGETED_DEVICE_FAMILY = `"1,2"`;
16
+ const addNotificationServiceExtension = async options => {
17
+ const {
18
+ appleTeamId,
19
+ bundleIdentifier,
20
+ bundleShortVersion,
21
+ bundleVersion,
22
+ iosPath,
23
+ appName,
24
+ iosDeploymentTarget
25
+ } = options;
26
+ const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
27
+ const xcodeProject = _xcode.default.project(projPath);
28
+ xcodeProject.parse(async function (err) {
29
+ if (err) {
30
+ throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
31
+ }
32
+ await (0, _injectCIOPodfileCode.injectCIONotificationPodfileCode)(iosPath);
33
+ _fileManagement.FileManagement.mkdir(`${iosPath}/${_ios.CIO_NOTIFICATION_TARGET_NAME}`, {
34
+ recursive: true
35
+ });
36
+ const files = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.swift', 'NotificationService.m'];
37
+ const getTargetFile = filename => `${iosPath}/${_ios.CIO_NOTIFICATION_TARGET_NAME}/${filename}`;
38
+ files.forEach(filename => {
39
+ const targetFile = getTargetFile(filename);
40
+ _fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
41
+ });
42
+
43
+ /* MODIFY COPIED EXTENSION FILES */
44
+ const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);
45
+ updateNseInfoPlist({
46
+ bundleVersion,
47
+ bundleShortVersion,
48
+ infoPlistTargetFile
49
+ });
50
+
51
+ // Create new PBXGroup for the extension
52
+ const extGroup = xcodeProject.addPbxGroup(files, _ios.CIO_NOTIFICATION_TARGET_NAME, _ios.CIO_NOTIFICATION_TARGET_NAME);
53
+
54
+ // Add the new PBXGroup to the top level group. This makes the
55
+ // files / folder appear in the file explorer in Xcode.
56
+ const groups = xcodeProject.hash.project.objects['PBXGroup'];
57
+ Object.keys(groups).forEach(key => {
58
+ if (groups[key].name === undefined) {
59
+ xcodeProject.addToPbxGroup(extGroup.uuid, key);
60
+ }
61
+ });
62
+
63
+ // WORK AROUND for codeProject.addTarget BUG
64
+ // Xcode projects don't contain these if there is only one target
65
+ // An upstream fix should be made to the code referenced in this link:
66
+ // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
67
+ const projObjects = xcodeProject.hash.project.objects;
68
+ projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
69
+ projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
70
+ if (xcodeProject.pbxTargetByName(_ios.CIO_NOTIFICATION_TARGET_NAME)) {
71
+ console.warn(`${_ios.CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
72
+ return;
73
+ }
74
+
75
+ // Add the NSE target
76
+ // This also adds PBXTargetDependency and PBXContainerItemProxy
77
+ const nseTarget = xcodeProject.addTarget(_ios.CIO_NOTIFICATION_TARGET_NAME, 'app_extension', _ios.CIO_NOTIFICATION_TARGET_NAME, `${bundleIdentifier}.richpush`);
78
+
79
+ // Add build phases to the new target
80
+ xcodeProject.addBuildPhase(['NotificationService.m', 'NotificationService.swift'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
81
+ xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', nseTarget.uuid);
82
+ xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', nseTarget.uuid);
83
+
84
+ // Edit the Deployment info of the target
85
+ const configurations = xcodeProject.pbxXCBuildConfigurationSection();
86
+ for (const key in configurations) {
87
+ if (typeof configurations[key].buildSettings !== 'undefined' && configurations[key].buildSettings.PRODUCT_NAME === `"${_ios.CIO_NOTIFICATION_TARGET_NAME}"`) {
88
+ const buildSettingsObj = configurations[key].buildSettings;
89
+ buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
90
+ buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '13.0';
91
+ buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
92
+ buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
93
+ buildSettingsObj.SWIFT_VERSION = 4.2;
94
+ }
95
+ }
96
+
97
+ // Add development team to the target & the main
98
+ xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);
99
+ xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);
100
+ _fileManagement.FileManagement.writeFile(projPath, xcodeProject.writeSync());
101
+ });
102
+ };
103
+ const withCioNotificationsXcodeProject = (configOuter, props) => {
104
+ return (0, _configPlugins.withXcodeProject)(configOuter, async config => {
105
+ const {
106
+ modRequest,
107
+ ios,
108
+ version: bundleShortVersion
109
+ } = config;
110
+ const {
111
+ appleTeamId,
112
+ iosDeploymentTarget
113
+ } = props;
114
+ if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.');
115
+ const {
116
+ projectName,
117
+ platformProjectRoot
118
+ } = modRequest;
119
+ const {
120
+ bundleIdentifier,
121
+ buildNumber
122
+ } = ios;
123
+ if (bundleShortVersion === undefined) {
124
+ throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js or app.json');
125
+ }
126
+ if (bundleIdentifier === undefined) {
127
+ throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json');
128
+ }
129
+ if (projectName === undefined) {
130
+ throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js or app.json');
131
+ }
132
+ const options = {
133
+ appleTeamId,
134
+ bundleIdentifier,
135
+ bundleShortVersion,
136
+ bundleVersion: buildNumber || _ios.DEFAULT_BUNDLE_VERSION,
137
+ iosPath: platformProjectRoot,
138
+ appName: projectName,
139
+ iosDeploymentTarget
140
+ };
141
+ await addNotificationServiceExtension(options);
142
+ return config;
143
+ });
144
+ };
145
+ exports.withCioNotificationsXcodeProject = withCioNotificationsXcodeProject;
146
+ const updateNseInfoPlist = payload => {
147
+ const BUNDLE_SHORT_VERSION_RE = /\{\{BUNDLE_SHORT_VERSION\}\}/;
148
+ const BUNDLE_VERSION_RE = /\{\{BUNDLE_VERSION\}\}/;
149
+ let plistFileString = _fileManagement.FileManagement.readFile(payload.infoPlistTargetFile);
150
+ if (payload.bundleVersion) {
151
+ plistFileString = (0, _codeInjection.injectCodeByMultiLineRegex)(plistFileString, BUNDLE_VERSION_RE, payload.bundleVersion);
152
+ }
153
+ if (payload.bundleShortVersion) {
154
+ plistFileString = (0, _codeInjection.injectCodeByMultiLineRegex)(plistFileString, BUNDLE_SHORT_VERSION_RE, payload.bundleShortVersion);
155
+ }
156
+ _fileManagement.FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
157
+ };
158
+ //# sourceMappingURL=withNotificationsXcodeProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PLIST_FILENAME","CIO_NOTIFICATION_TARGET_NAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","appleTeamId","bundleIdentifier","bundleShortVersion","bundleVersion","iosPath","appName","iosDeploymentTarget","projPath","xcodeProject","xcode","project","parse","err","Error","JSON","stringify","injectCIONotificationPodfileCode","FileManagement","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","LOCAL_PATH_TO_CIO_NSE_FILES","infoPlistTargetFile","updateNseInfoPlist","extGroup","addPbxGroup","groups","hash","objects","Object","keys","key","name","undefined","addToPbxGroup","uuid","projObjects","pbxTargetByName","console","warn","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","writeFile","writeSync","withCioNotificationsXcodeProject","configOuter","props","withXcodeProject","config","modRequest","ios","version","projectName","platformProjectRoot","buildNumber","DEFAULT_BUNDLE_VERSION","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","injectCodeByMultiLineRegex"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport xcode from 'xcode';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport { injectCodeByMultiLineRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n appName,\n iosDeploymentTarget,\n } = options;\n\n const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;\n\n const xcodeProject = xcode.project(projPath);\n\n xcodeProject.parse(async function (err: Error) {\n if (err) {\n throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);\n }\n\n await injectCIONotificationPodfileCode(iosPath);\n\n FileManagement.mkdir(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.m',\n ];\n\n const getTargetFile = (filename: string) =>\n `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}/${filename}`;\n\n files.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects['PBXGroup'];\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects['PBXTargetDependency'] =\n projObjects['PBXTargetDependency'] || {};\n projObjects['PBXContainerItemProxy'] =\n projObjects['PBXTargetDependency'] || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget || '13.0';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n\n FileManagement.writeFile(projPath, xcodeProject.writeSync());\n });\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'\n );\n\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\n );\n }\n\n const options = {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n iosDeploymentTarget,\n };\n\n await addNotificationServiceExtension(options);\n\n return config;\n });\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = injectCodeByMultiLineRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = injectCodeByMultiLineRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AAKA;AACA;AAEA;AAAmE;AAEnE,MAAMA,cAAc,GAAI,GAAEC,iCAA6B,aAAY;AAEnE,MAAMC,sBAAsB,GAAI,OAAM;AAEtC,MAAMC,+BAA+B,GAAG,MACtCC,OAAmC,IAChC;EACH,MAAM;IACJC,WAAW;IACXC,gBAAgB;IAChBC,kBAAkB;IAClBC,aAAa;IACbC,OAAO;IACPC,OAAO;IACPC;EACF,CAAC,GAAGP,OAAO;EAEX,MAAMQ,QAAQ,GAAI,GAAEH,OAAQ,IAAGC,OAAQ,4BAA2B;EAElE,MAAMG,YAAY,GAAGC,cAAK,CAACC,OAAO,CAACH,QAAQ,CAAC;EAE5CC,YAAY,CAACG,KAAK,CAAC,gBAAgBC,GAAU,EAAE;IAC7C,IAAIA,GAAG,EAAE;MACP,MAAM,IAAIC,KAAK,CAAE,8BAA6BC,IAAI,CAACC,SAAS,CAACH,GAAG,CAAE,EAAC,CAAC;IACtE;IAEA,MAAM,IAAAI,sDAAgC,EAACZ,OAAO,CAAC;IAE/Ca,8BAAc,CAACC,KAAK,CAAE,GAAEd,OAAQ,IAAGR,iCAA6B,EAAC,EAAE;MACjE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CAAC;IAE9C,OAAOiE,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAAC;AAEF,MAAMpC,kBAAkB,GAAI4C,OAI3B,IAAK;EACJ,MAAMC,uBAAuB,GAAG,8BAA8B;EAC9D,MAAMC,iBAAiB,GAAG,wBAAwB;EAElD,IAAIC,eAAe,GAAG1D,8BAAc,CAAC2D,QAAQ,CAACJ,OAAO,CAAC7C,mBAAmB,CAAC;EAE1E,IAAI6C,OAAO,CAACrE,aAAa,EAAE;IACzBwE,eAAe,GAAG,IAAAE,yCAA0B,EAC1CF,eAAe,EACfD,iBAAiB,EACjBF,OAAO,CAACrE,aAAa,CACtB;EACH;EAEA,IAAIqE,OAAO,CAACtE,kBAAkB,EAAE;IAC9ByE,eAAe,GAAG,IAAAE,yCAA0B,EAC1CF,eAAe,EACfF,uBAAuB,EACvBD,OAAO,CAACtE,kBAAkB,CAC3B;EACH;EAEAe,8BAAc,CAACyC,SAAS,CAACc,OAAO,CAAC7C,mBAAmB,EAAEgD,eAAe,CAAC;AACxE,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withCioXcodeProject = void 0;
7
+ var _configPlugins = require("@expo/config-plugins");
8
+ var _injectCIOPodfileCode = require("../helpers/utils/injectCIOPodfileCode");
9
+ const withCioXcodeProject = (config, cioProps) => {
10
+ return (0, _configPlugins.withXcodeProject)(config, async props => {
11
+ var _props$ios, _props$ios2;
12
+ const options = {
13
+ iosPath: props.modRequest.platformProjectRoot,
14
+ bundleIdentifier: (_props$ios = props.ios) === null || _props$ios === void 0 ? void 0 : _props$ios.bundleIdentifier,
15
+ devTeam: cioProps === null || cioProps === void 0 ? void 0 : cioProps.devTeam,
16
+ bundleVersion: (_props$ios2 = props.ios) === null || _props$ios2 === void 0 ? void 0 : _props$ios2.buildNumber,
17
+ bundleShortVersion: props === null || props === void 0 ? void 0 : props.version,
18
+ iosDeploymentTarget: cioProps === null || cioProps === void 0 ? void 0 : cioProps.iosDeploymentTarget
19
+ };
20
+ const {
21
+ iosPath
22
+ } = options;
23
+ await (0, _injectCIOPodfileCode.injectCIOPodfileCode)(iosPath);
24
+ return props;
25
+ });
26
+ };
27
+ exports.withCioXcodeProject = withCioXcodeProject;
28
+ //# sourceMappingURL=withXcodeProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withCioXcodeProject","config","cioProps","withXcodeProject","props","options","iosPath","modRequest","platformProjectRoot","bundleIdentifier","ios","devTeam","bundleVersion","buildNumber","bundleShortVersion","version","iosDeploymentTarget","injectCIOPodfileCode"],"sources":["withXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\n\nimport { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nexport const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS> = (\n config,\n cioProps\n) => {\n return withXcodeProject(config, async (props) => {\n const options: CustomerIOPluginOptionsIOS = {\n iosPath: props.modRequest.platformProjectRoot,\n bundleIdentifier: props.ios?.bundleIdentifier,\n devTeam: cioProps?.devTeam,\n bundleVersion: props.ios?.buildNumber,\n bundleShortVersion: props?.version,\n iosDeploymentTarget: cioProps?.iosDeploymentTarget,\n };\n const { iosPath } = options;\n\n await injectCIOPodfileCode(iosPath);\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAGO,MAAMA,mBAA6D,GAAG,CAC3EC,MAAM,EACNC,QAAQ,KACL;EACH,OAAO,IAAAC,+BAAgB,EAACF,MAAM,EAAE,MAAOG,KAAK,IAAK;IAAA;IAC/C,MAAMC,OAAmC,GAAG;MAC1CC,OAAO,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MAC7CC,gBAAgB,gBAAEL,KAAK,CAACM,GAAG,+CAAT,WAAWD,gBAAgB;MAC7CE,OAAO,EAAET,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAES,OAAO;MAC1BC,aAAa,iBAAER,KAAK,CAACM,GAAG,gDAAT,YAAWG,WAAW;MACrCC,kBAAkB,EAAEV,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEW,OAAO;MAClCC,mBAAmB,EAAEd,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEc;IACjC,CAAC;IACD,MAAM;MAAEV;IAAQ,CAAC,GAAGD,OAAO;IAE3B,MAAM,IAAAY,0CAAoB,EAACX,OAAO,CAAC;IAEnC,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=cio-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["// properties set by the user in their app config file (e.g: app.json or app.plugin.js)\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n// Plugin options for pre-build\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n pushNotification?: {\n useRichPush: boolean;\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFilePath?: string;\n};\n\nexport type CustomerIOPluginOptions = {\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n"],"mappings":""}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LIB_VERSION = void 0;
7
+ const LIB_VERSION = "1.0.0-alpha.2";
8
+ exports.LIB_VERSION = LIB_VERSION;
9
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LIB_VERSION"],"sources":["version.ts"],"sourcesContent":["export const LIB_VERSION = \"1.0.0-alpha.2\";\n"],"mappings":";;;;;;AAAO,MAAMA,WAAW,GAAG,eAAe;AAAC"}
@@ -0,0 +1,24 @@
1
+ import { LIB_VERSION } from './../version';
2
+ import { withXcodeProject } from '@expo/config-plugins';
3
+ import { FileManagement } from '../helpers/utils/fileManagement';
4
+ export const withAnalytics = config => {
5
+ return withXcodeProject(config, async props => {
6
+ const expoVersionSnippet = `"expoVersion": "${LIB_VERSION}"`;
7
+ let versionRegEx = new RegExp(expoVersionSnippet);
8
+ const filename = `node_modules/customerio-reactnative/package.json`;
9
+ if (FileManagement.exists(filename)) {
10
+ const pJsonFile = await FileManagement.read(filename);
11
+ const lines = pJsonFile.split('\n');
12
+ const missingMmatch = pJsonFile.match(versionRegEx);
13
+ const expoVersionRegex = /"expoVersion": ".*"/;
14
+ const existatch = pJsonFile.match(expoVersionRegex);
15
+ if (existatch && !missingMmatch) {
16
+ const index = lines.findIndex(line => expoVersionRegex.test(line));
17
+ const content = [...lines.slice(0, index), ` ${expoVersionSnippet},`, ...lines.slice(index + 1)];
18
+ FileManagement.write(filename, content.join('\n'));
19
+ }
20
+ }
21
+ return props;
22
+ });
23
+ };
24
+ //# sourceMappingURL=injectAnalytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LIB_VERSION","withXcodeProject","FileManagement","withAnalytics","config","props","expoVersionSnippet","versionRegEx","RegExp","filename","exists","pJsonFile","read","lines","split","missingMmatch","match","expoVersionRegex","existatch","index","findIndex","line","test","content","slice","write","join"],"sources":["injectAnalytics.ts"],"sourcesContent":["import { LIB_VERSION } from './../version';\nimport { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptions } from '../types/cio-types';\n\n\nexport const withAnalytics: ConfigPlugin<CustomerIOPluginOptions> = (config) => {\n return withXcodeProject(config, async (props) => {\n const expoVersionSnippet = `\"expoVersion\": \"${LIB_VERSION}\"`;\n let versionRegEx = new RegExp(expoVersionSnippet);\n const filename = `node_modules/customerio-reactnative/package.json`;\n if (FileManagement.exists(filename)) {\n const pJsonFile = await FileManagement.read(filename);\n const lines = pJsonFile.split('\\n');\n const missingMmatch = pJsonFile.match(versionRegEx);\n const expoVersionRegex = /\"expoVersion\": \".*\"/;\n const existatch = pJsonFile.match(expoVersionRegex);\n\n if (existatch && !missingMmatch) {\n const index = lines.findIndex((line) =>\n expoVersionRegex.test(line)\n );\n\n const content = [\n ...lines.slice(0, index),\n ` ${expoVersionSnippet},`,\n ...lines.slice(index + 1),\n ];\n\n FileManagement.write(filename, content.join('\\n'));\n }\n }\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,cAAc;AAC1C,SAAuBC,gBAAgB,QAAQ,sBAAsB;AACrE,SAASC,cAAc,QAAQ,iCAAiC;AAIhE,OAAO,MAAMC,aAAoD,GAAIC,MAAM,IAAK;EAC9E,OAAOH,gBAAgB,CAACG,MAAM,EAAE,MAAOC,KAAK,IAAK;IAC/C,MAAMC,kBAAkB,GAAI,mBAAkBN,WAAY,GAAE;IAC5D,IAAIO,YAAY,GAAG,IAAIC,MAAM,CAACF,kBAAkB,CAAC;IACjD,MAAMG,QAAQ,GAAI,kDAAiD;IACnE,IAAIP,cAAc,CAACQ,MAAM,CAACD,QAAQ,CAAC,EAAE;MACnC,MAAME,SAAS,GAAG,MAAMT,cAAc,CAACU,IAAI,CAACH,QAAQ,CAAC;MACrD,MAAMI,KAAK,GAAGF,SAAS,CAACG,KAAK,CAAC,IAAI,CAAC;MACnC,MAAMC,aAAa,GAAGJ,SAAS,CAACK,KAAK,CAACT,YAAY,CAAC;MACnD,MAAMU,gBAAgB,GAAG,qBAAqB;MAC9C,MAAMC,SAAS,GAAGP,SAAS,CAACK,KAAK,CAACC,gBAAgB,CAAC;MAEnD,IAAIC,SAAS,IAAI,CAACH,aAAa,EAAE;QAC/B,MAAMI,KAAK,GAAGN,KAAK,CAACO,SAAS,CAAEC,IAAI,IACjCJ,gBAAgB,CAACK,IAAI,CAACD,IAAI,CAAC,CAC5B;QAED,MAAME,OAAO,GAAG,CACd,GAAGV,KAAK,CAACW,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EACvB,KAAIb,kBAAmB,GAAE,EAC1B,GAAGO,KAAK,CAACW,KAAK,CAACL,KAAK,GAAG,CAAC,CAAC,CAC1B;QAEDjB,cAAc,CAACuB,KAAK,CAAChB,QAAQ,EAAEc,OAAO,CAACG,IAAI,CAAC,IAAI,CAAC,CAAC;MACpD;IACF;IAEA,OAAOrB,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { withAppBuildGradle } from '@expo/config-plugins';
2
+ import { CIO_APP_APPLY_REGEX, CIO_APP_GOOGLE_SNIPPET } from '../helpers/constants/android';
3
+ export const withAppGoogleServices = configOuter => {
4
+ return withAppBuildGradle(configOuter, props => {
5
+ const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);
6
+ const match = props.modResults.contents.match(regex);
7
+ if (!match) {
8
+ props.modResults.contents = props.modResults.contents.replace(CIO_APP_APPLY_REGEX, `$1\n${CIO_APP_GOOGLE_SNIPPET}`);
9
+ } else {
10
+ console.log('app/build.gradle snippet already exists. Skipping...');
11
+ }
12
+ return props;
13
+ });
14
+ };
15
+ //# sourceMappingURL=withAppGoogleServices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withAppBuildGradle","CIO_APP_APPLY_REGEX","CIO_APP_GOOGLE_SNIPPET","withAppGoogleServices","configOuter","props","regex","RegExp","match","modResults","contents","replace","console","log"],"sources":["withAppGoogleServices.ts"],"sourcesContent":["import { ConfigPlugin, 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';\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 console.log('app/build.gradle snippet already exists. Skipping...');\n }\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,kBAAkB,QAAQ,sBAAsB;AAEvE,SACEC,mBAAmB,EACnBC,sBAAsB,QACjB,8BAA8B;AAGrC,OAAO,MAAMC,qBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOJ,kBAAkB,CAACI,WAAW,EAAGC,KAAK,IAAK;IAChD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACL,sBAAsB,CAAC;IAChD,MAAMM,KAAK,GAAGH,KAAK,CAACI,UAAU,CAACC,QAAQ,CAACF,KAAK,CAACF,KAAK,CAAC;IACpD,IAAI,CAACE,KAAK,EAAE;MACVH,KAAK,CAACI,UAAU,CAACC,QAAQ,GAAGL,KAAK,CAACI,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DV,mBAAmB,EAClB,OAAMC,sBAAuB,EAAC,CAChC;IACH,CAAC,MAAM;MACLU,OAAO,CAACC,GAAG,CAAC,sDAAsD,CAAC;IACrE;IAEA,OAAOR,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}