customerio-expo-plugin 0.0.4 → 1.0.0-alpha.1

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 (143) hide show
  1. package/lib/commonjs/android/withAppGoogleServices.js +16 -0
  2. package/lib/commonjs/android/withAppGoogleServices.js.map +1 -0
  3. package/lib/commonjs/android/withCIOAndroid.js +18 -0
  4. package/lib/commonjs/android/withCIOAndroid.js.map +1 -0
  5. package/lib/commonjs/android/withGistMavenRepository.js +16 -0
  6. package/lib/commonjs/android/withGistMavenRepository.js.map +1 -0
  7. package/lib/commonjs/android/withGoogleServicesJSON.js +30 -0
  8. package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -0
  9. package/lib/commonjs/android/withProjectGoogleServices.js +16 -0
  10. package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -0
  11. package/lib/commonjs/helpers/constants/android.js +19 -0
  12. package/lib/commonjs/helpers/constants/android.js.map +1 -0
  13. package/lib/commonjs/helpers/constants/globals.d.js +2 -0
  14. package/lib/commonjs/helpers/constants/globals.d.js.map +1 -0
  15. package/lib/commonjs/helpers/constants/ios.js +138 -0
  16. package/lib/commonjs/helpers/constants/ios.js.map +1 -0
  17. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService-Info.plist +0 -0
  18. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService.h +0 -0
  19. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService.m +0 -0
  20. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService.swift +0 -0
  21. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/PushNotification.swift +0 -0
  22. package/lib/commonjs/helpers/utils/codeInjection.js +33 -0
  23. package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -0
  24. package/lib/commonjs/helpers/utils/fileManagement.js +44 -0
  25. package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -0
  26. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +32 -0
  27. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  28. package/lib/commonjs/index.js +17 -0
  29. package/lib/commonjs/index.js.map +1 -0
  30. package/lib/commonjs/ios/withAppDelegateModifications.js +76 -0
  31. package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -0
  32. package/lib/commonjs/ios/withAppDelegateXcodeProject.js +96 -0
  33. package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +1 -0
  34. package/lib/commonjs/ios/withCIOIos.js +18 -0
  35. package/lib/commonjs/ios/withCIOIos.js.map +1 -0
  36. package/lib/commonjs/ios/withNotificationsXcodeProject.js +157 -0
  37. package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -0
  38. package/lib/commonjs/ios/withXcodeProject.js +28 -0
  39. package/lib/commonjs/ios/withXcodeProject.js.map +1 -0
  40. package/lib/commonjs/types/cio-types.js +15 -0
  41. package/lib/commonjs/types/cio-types.js.map +1 -0
  42. package/lib/module/android/withAppGoogleServices.js +9 -0
  43. package/lib/module/android/withAppGoogleServices.js.map +1 -0
  44. package/lib/module/android/withCIOAndroid.js +12 -0
  45. package/lib/module/android/withCIOAndroid.js.map +1 -0
  46. package/lib/module/android/withGistMavenRepository.js +9 -0
  47. package/lib/module/android/withGistMavenRepository.js.map +1 -0
  48. package/lib/module/android/withGoogleServicesJSON.js +23 -0
  49. package/lib/module/android/withGoogleServicesJSON.js.map +1 -0
  50. package/lib/module/android/withProjectGoogleServices.js +9 -0
  51. package/lib/module/android/withProjectGoogleServices.js.map +1 -0
  52. package/lib/module/helpers/constants/android.js +7 -0
  53. package/lib/module/helpers/constants/android.js.map +1 -0
  54. package/lib/module/helpers/constants/globals.d.js +2 -0
  55. package/lib/module/helpers/constants/globals.d.js.map +1 -0
  56. package/lib/module/helpers/constants/ios.js +102 -0
  57. package/lib/module/helpers/constants/ios.js.map +1 -0
  58. package/lib/module/helpers/native-files/ios/CIONotificationService-Info.plist +31 -0
  59. package/lib/module/helpers/native-files/ios/CIONotificationService.h +5 -0
  60. package/lib/module/helpers/native-files/ios/CIONotificationService.m +30 -0
  61. package/lib/module/helpers/native-files/ios/CIONotificationService.swift +21 -0
  62. package/lib/module/helpers/native-files/ios/PushNotification.swift +56 -0
  63. package/lib/module/helpers/utils/codeInjection.js +24 -0
  64. package/lib/module/helpers/utils/codeInjection.js.map +1 -0
  65. package/lib/module/helpers/utils/fileManagement.js +37 -0
  66. package/lib/module/helpers/utils/fileManagement.js.map +1 -0
  67. package/lib/module/helpers/utils/injectCIOPodfileCode.js +25 -0
  68. package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  69. package/lib/module/index.js +10 -0
  70. package/lib/module/index.js.map +1 -0
  71. package/lib/module/ios/withAppDelegateModifications.js +69 -0
  72. package/lib/module/ios/withAppDelegateModifications.js.map +1 -0
  73. package/lib/module/ios/withAppDelegateXcodeProject.js +88 -0
  74. package/lib/module/ios/withAppDelegateXcodeProject.js.map +1 -0
  75. package/lib/module/ios/withCIOIos.js +12 -0
  76. package/lib/module/ios/withCIOIos.js.map +1 -0
  77. package/lib/module/ios/withNotificationsXcodeProject.js +149 -0
  78. package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -0
  79. package/lib/module/ios/withXcodeProject.js +21 -0
  80. package/lib/module/ios/withXcodeProject.js.map +1 -0
  81. package/lib/module/types/cio-types.js +10 -0
  82. package/lib/module/types/cio-types.js.map +1 -0
  83. package/lib/typescript/android/withAppGoogleServices.d.ts +3 -0
  84. package/lib/typescript/android/withCIOAndroid.d.ts +3 -0
  85. package/lib/typescript/android/withGistMavenRepository.d.ts +3 -0
  86. package/lib/typescript/android/withGoogleServicesJSON.d.ts +3 -0
  87. package/lib/typescript/android/withProjectGoogleServices.d.ts +3 -0
  88. package/lib/typescript/helpers/constants/android.d.ts +6 -0
  89. package/lib/typescript/helpers/constants/ios.d.ts +30 -0
  90. package/lib/typescript/helpers/utils/codeInjection.d.ts +4 -0
  91. package/lib/typescript/helpers/utils/fileManagement.d.ts +5 -0
  92. package/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +2 -0
  93. package/lib/typescript/index.d.ts +4 -0
  94. package/lib/typescript/ios/withAppDelegateModifications.d.ts +2 -0
  95. package/lib/typescript/ios/withAppDelegateXcodeProject.d.ts +3 -0
  96. package/lib/typescript/ios/withCIOIos.d.ts +3 -0
  97. package/lib/typescript/ios/withNotificationsXcodeProject.d.ts +3 -0
  98. package/lib/typescript/ios/withXcodeProject.d.ts +3 -0
  99. package/lib/typescript/types/cio-types.d.ts +22 -0
  100. package/package.json +87 -13
  101. package/src/android/withAppGoogleServices.ts +19 -0
  102. package/src/android/withCIOAndroid.ts +19 -0
  103. package/src/android/withGistMavenRepository.ts +19 -0
  104. package/src/android/withGoogleServicesJSON.ts +30 -0
  105. package/src/android/withProjectGoogleServices.ts +19 -0
  106. package/src/helpers/constants/android.ts +12 -0
  107. package/src/helpers/constants/globals.d.ts +8 -0
  108. package/src/helpers/constants/ios.ts +116 -0
  109. package/src/helpers/native-files/ios/CIONotificationService-Info.plist +31 -0
  110. package/src/helpers/native-files/ios/CIONotificationService.h +5 -0
  111. package/src/helpers/native-files/ios/CIONotificationService.m +30 -0
  112. package/src/helpers/native-files/ios/CIONotificationService.swift +21 -0
  113. package/src/helpers/native-files/ios/PushNotification.swift +56 -0
  114. package/src/helpers/utils/codeInjection.ts +46 -0
  115. package/src/helpers/utils/fileManagement.ts +39 -0
  116. package/src/helpers/utils/injectCIOPodfileCode.ts +47 -0
  117. package/src/index.ts +21 -0
  118. package/src/ios/withAppDelegateModifications.ts +150 -0
  119. package/src/ios/withAppDelegateXcodeProject.ts +110 -0
  120. package/src/ios/withCIOIos.ts +19 -0
  121. package/src/ios/withNotificationsXcodeProject.ts +231 -0
  122. package/src/ios/withXcodeProject.ts +25 -0
  123. package/src/types/cio-types.ts +28 -0
  124. package/build/helpers/.DS_Store +0 -0
  125. package/build/helpers/ios/.DS_Store +0 -0
  126. package/build/package.json +0 -36
  127. package/build/src/android/withAppGoogleServices.js +0 -12
  128. package/build/src/android/withCIOAndroid.js +0 -15
  129. package/build/src/android/withGistMavenRepository.js +0 -12
  130. package/build/src/android/withGoogleServicesJSON.js +0 -24
  131. package/build/src/android/withProjectGoogleServices.js +0 -12
  132. package/build/src/helpers/constants/android.js +0 -9
  133. package/build/src/helpers/constants/ios.js +0 -102
  134. package/build/src/helpers/utils/codeInjection.js +0 -30
  135. package/build/src/helpers/utils/fileManagement.js +0 -40
  136. package/build/src/helpers/utils/injectCIOPodfileCode.js +0 -37
  137. package/build/src/index.js +0 -11
  138. package/build/src/ios/withAppDelegateModifications.js +0 -77
  139. package/build/src/ios/withAppDelegateXcodeProject.js +0 -78
  140. package/build/src/ios/withCIOIos.js +0 -15
  141. package/build/src/ios/withNotificationsXcodeProject.js +0 -133
  142. package/build/src/ios/withXcodeProject.js +0 -22
  143. package/build/src/types/cio-types.js +0 -8
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LOCAL_PATH_TO_CIO_NSE_FILES","IOS_DEPLOYMENT_TARGET","CIO_PODFILE_REGEX","CIO_PODFILE_NOTIFICATION_REGEX","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_PODFILE_POST_INSTALL_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","CIO_PODFILE_SNIPPET","CIO_PODFILE_TARGET_NAMES_SNIPPET","CIO_PODFILE_POST_INSTALL_SNIPPET","CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["export const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\nexport const CIO_PODFILE_REGEX = /pod 'RCT-Folly'/;\nexport const CIO_PODFILE_NOTIFICATION_REGEX =\n /target 'CIONotificationService' do/;\nexport const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;\nexport const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;\nexport const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;\nexport const CIO_PODFILE_POST_INSTALL_REGEX = /post_install do \\|installer\\|/;\nexport const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX =\n /(- \\(BOOL\\)application:\\(UIApplication \\*\\)application didFinishLaunchingWithOptions:\\(NSDictionary \\*\\)launchOptions(\\s|\\n)*?\\{)((.|\\n)*)\\[super(\\s)application:application(\\s)didFinishLaunchingWithOptions:launchOptions\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX =\n /return \\[super application:application didFailToRegisterForRemoteNotificationsWithError:error\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX =\n /(- \\(void\\)application:\\(UIApplication \\*\\)application didFailToRegisterForRemoteNotificationsWithError:\\(NSError \\*\\)error(\\s|\\n)*?\\{)(.|\\n){2}.*\\n\\}/;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX =\n /return \\[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\\];/;\n\nexport const CIO_APPDELEGATEDECLARATION_REGEX =\n /@implementation AppDelegate(.|\\n)/;\n\nexport const CIO_APPDELEGATEHEADER_REGEX =\n /@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate>/;\nexport const DEFAULT_BUNDLE_VERSION = '1';\nexport const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';\nexport const CIO_TARGET_NAME = 'CustomerIOSDK';\nexport const CIO_NOTIFICATION_TARGET_NAME = 'CIONotificationService';\nexport const CIO_APPDELEGATEHEADER_SNIPPET = `\n#import <UserNotifications/UserNotifications.h>\n\n@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>\n`;\n\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\n// Configure Customerio push notifications SDK by adding to application:didFinishLaunchingWithOptions: delegate method\n// From Braze docs: https://www.customer.io/docs/sdk/react-native/push/#obj-c-push\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification:self];\n`;\n\n// Enable push handling - notification response\nexport const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = `\n- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {\n [pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];\n}`;\n\n// Foreground push handling\nexport const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `\n// show push when the app is in foreground\n- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {\n completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);\n}`;\nexport const CIO_PODFILE_NOTIFICATION_SNIPPET = `\ntarget '${CIO_NOTIFICATION_TARGET_NAME}' do\n pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'\nend`;\nexport const CIO_PODFILE_SNIPPET = `\n pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec'\n pod 'boost', :podspec => '../node_modules/react-native/third-party-podspecs/boost.podspec'\n pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'`;\nexport const CIO_PODFILE_TARGET_NAMES_SNIPPET = `\n cio_target_names = [\n 'CustomerIOTracking',\n 'CustomerIOCommon',\n 'CustomerIOMessagingPushAPN',\n 'CustomerIOMessagingPush'\n ]`;\nexport const CIO_PODFILE_POST_INSTALL_SNIPPET = `\n installer.pods_project.targets.each do |target|\n if cio_target_names.include? target.name\n puts \"Modifying target #{target.name}\"\n\n target.build_configurations.each do |config|\n puts \"Setting build config settings for #{target.name}\"\n config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'\n end\n end\n end`;\nexport const CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET = `\ncio_target_names = [\n 'CustomerIOTracking',\n 'CustomerIOCommon',\n 'CustomerIOMessagingPushAPN',\n 'CustomerIOMessagingPush'\n]\n\npost_install do |installer|\n\n installer.pods_project.targets.each do |target|\n if cio_target_names.include? target.name\n puts \"Modifying target #{target.name}\"\n\n target.build_configurations.each do |config|\n puts \"Setting build config settings for #{target.name}\"\n config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'\n end\n end\n end\n react_native_post_install(installer)\n __apply_Xcode_12_5_M1_post_install_workaround(installer)\nend`;\n"],"mappings":"AAAA,OAAO,MAAMA,2BAA2B,GAAI,kEAAiE;AAC7G,OAAO,MAAMC,qBAAqB,GAAG,MAAM;AAC3C,OAAO,MAAMC,iBAAiB,GAAG,iBAAiB;AAClD,OAAO,MAAMC,8BAA8B,GACzC,oCAAoC;AACtC,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,mCAAmC,GAAG,4BAA4B;AAC/E,OAAO,MAAMC,6BAA6B,GAAG,sBAAsB;AACnE,OAAO,MAAMC,8BAA8B,GAAG,+BAA+B;AAC7E,OAAO,MAAMC,kCAAkC,GAC7C,gOAAgO;AAElO,OAAO,MAAMC,0DAA0D,GACrE,kGAAkG;AAEpG,OAAO,MAAMC,8DAA8D,GACzE,wJAAwJ;AAE1J,OAAO,MAAMC,0DAA0D,GACrE,wGAAwG;AAE1G,OAAO,MAAMC,gCAAgC,GAC3C,mCAAmC;AAErC,OAAO,MAAMC,2BAA2B,GACtC,mEAAmE;AACrE,OAAO,MAAMC,sBAAsB,GAAG,GAAG;AACzC,OAAO,MAAMC,4BAA4B,GAAG,KAAK;AACjD,OAAO,MAAMC,eAAe,GAAG,eAAe;AAC9C,OAAO,MAAMC,4BAA4B,GAAG,wBAAwB;AACpE,OAAO,MAAMC,6BAA6B,GAAI;AAC9C;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,8CAA8C,GAAI;AAC/D;AACA,CAAC;AAED,OAAO,MAAMC,4DAA4D,GAAI;AAC7E;AACA,CAAC;AAED,OAAO,MAAMC,4DAA4D,GAAI;AAC7E;AACA,CAAC;;AAED;AACA;AACA,OAAO,MAAMC,2CAA2C,GAAI;AAC5D;AACA;AACA,CAAC;;AAED;AACA,OAAO,MAAMC,iDAAiD,GAAI;AAClE;AACA;AACA,EAAE;;AAEF;AACA,OAAO,MAAMC,0CAA0C,GAAI;AAC3D;AACA;AACA;AACA,EAAE;AACF,OAAO,MAAMC,gCAAgC,GAAI;AACjD,UAAUR,4BAA6B;AACvC;AACA,IAAI;AACJ,OAAO,MAAMS,mBAAmB,GAAI;AACpC;AACA;AACA,wDAAwD;AACxD,OAAO,MAAMC,gCAAgC,GAAI;AACjD;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ,OAAO,MAAMC,gCAAgC,GAAI;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR,OAAO,MAAMC,yCAAyC,GAAI;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI"}
@@ -0,0 +1,31 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleShortVersionString</key>
6
+ <string>{{BUNDLE_SHORT_VERSION}}</string>
7
+ <key>CFBundleVersion</key>
8
+ <string>{{BUNDLE_VERSION}}</string>
9
+ <key>CFBundleDevelopmentRegion</key>
10
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
11
+ <key>CFBundleDisplayName</key>
12
+ <string>CIONotificationServiceExtension</string>
13
+ <key>CFBundleExecutable</key>
14
+ <string>$(EXECUTABLE_NAME)</string>
15
+ <key>CFBundleIdentifier</key>
16
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
17
+ <key>CFBundleInfoDictionaryVersion</key>
18
+ <string>6.0</string>
19
+ <key>CFBundleName</key>
20
+ <string>$(PRODUCT_NAME)</string>
21
+ <key>CFBundlePackageType</key>
22
+ <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
23
+ <key>NSExtension</key>
24
+ <dict>
25
+ <key>NSExtensionPointIdentifier</key>
26
+ <string>com.apple.usernotifications.service</string>
27
+ <key>NSExtensionPrincipalClass</key>
28
+ <string>CIONotificationService</string>
29
+ </dict>
30
+ </dict>
31
+ </plist>
@@ -0,0 +1,5 @@
1
+ #import <UserNotifications/UserNotifications.h>
2
+
3
+ @interface NotificationService : UNNotificationServiceExtension
4
+
5
+ @end
@@ -0,0 +1,30 @@
1
+
2
+ #import "CIONotificationService.h"
3
+ // MARK: - CIO-TECH-ASSISTANCE
4
+ // Import "Your-target-name-Swift.h" file
5
+ #import "CIONotificationService-Swift.h"
6
+
7
+ @interface NotificationService ()
8
+
9
+ @property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
10
+ @property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
11
+
12
+ @end
13
+
14
+ @implementation NotificationService
15
+
16
+ - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
17
+ // MARK: - CIO-TECH-ASSISTANCE
18
+ NotificationServiceCioManager* cioManagerObj = [[NotificationServiceCioManager alloc] init];
19
+ [cioManagerObj didReceive:request withContentHandler:contentHandler];
20
+ }
21
+
22
+ - (void)serviceExtensionTimeWillExpire {
23
+ // Called just before the extension will be terminated by the system.
24
+ // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
25
+ // MARK: - CIO-TECH-ASSISTANCE
26
+ NotificationServiceCioManager* cioManagerObj = [[NotificationServiceCioManager alloc] init];
27
+ [cioManagerObj serviceExtensionTimeWillExpire];
28
+ }
29
+
30
+ @end
@@ -0,0 +1,21 @@
1
+ import Foundation
2
+ import UserNotifications
3
+ import CioMessagingPush
4
+
5
+ // MARK: - CIO-TECH-ASSISTANCE
6
+ // This is another example of handling ObjC calls for Swift CustomerIO SDK
7
+ @objc
8
+ public class NotificationServiceCioManager : NSObject {
9
+
10
+ public override init() {}
11
+
12
+ @objc(didReceive:withContentHandler:)
13
+ public func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
14
+ MessagingPush.shared.didReceive(request, withContentHandler: contentHandler)
15
+ }
16
+
17
+ @objc(serviceExtensionTimeWillExpire)
18
+ public func serviceExtensionTimeWillExpire() {
19
+ MessagingPush.shared.serviceExtensionTimeWillExpire()
20
+ }
21
+ }
@@ -0,0 +1,56 @@
1
+ //
2
+ // PushNotification.swift
3
+ // testandroidapp
4
+ //
5
+ // Created by Segun Xtreem on 10/09/2022.
6
+ //
7
+
8
+ import Foundation
9
+ import CioMessagingPushAPN
10
+ import CioTracking
11
+ import UserNotifications
12
+ import UIKit
13
+
14
+ @objc
15
+ public class CIOAppPushNotificationsHandler : NSObject {
16
+
17
+ public override init() {}
18
+
19
+ // MARK: - ObjCNEW
20
+ @objc(registerPushNotification:)
21
+ public func registerPushNotification(withNotificationDelegate notificationDelegate: UNUserNotificationCenterDelegate) {
22
+
23
+ let center = UNUserNotificationCenter.current()
24
+ center.delegate = notificationDelegate // MARK: - ObjCNEW
25
+ center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
26
+ if error == nil{
27
+ DispatchQueue.main.async {
28
+ UIApplication.shared.registerForRemoteNotifications()
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ @objc(application:deviceToken:)
35
+ public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
36
+ MessagingPush.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
37
+ }
38
+
39
+ @objc(application:error:)
40
+ public func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
41
+ MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
42
+ }
43
+
44
+ // MARK: - ObjCNEW
45
+ @objc(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)
46
+ public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
47
+ let handled = MessagingPush.shared.userNotificationCenter(center, didReceive: response,
48
+ withCompletionHandler: completionHandler)
49
+
50
+ // If the Customer.io SDK does not handle the push, it's up to you to handle it and call the
51
+ // completion handler. If the SDK did handle it, it called the completion handler for you.
52
+ if !handled {
53
+ completionHandler()
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,24 @@
1
+ export function injectCodeByRegex(fileContent, lineRegex, snippet) {
2
+ const lines = fileContent.split('\n');
3
+ const index = lines.findIndex(line => lineRegex.test(line));
4
+ let content = lines;
5
+ if (index > -1) {
6
+ content = [...lines.slice(0, index), snippet, ...lines.slice(index)];
7
+ }
8
+ return content;
9
+ }
10
+ export function injectCodeByMultiLineRegex(fileContent, lineRegex, snippet) {
11
+ return fileContent.replace(lineRegex, `$&\n${snippet}`);
12
+ }
13
+ export function injectCodeByMultiLineRegexAndReplaceLine(fileContent, lineRegex, snippet) {
14
+ return fileContent.replace(lineRegex, `${snippet}`);
15
+ }
16
+ export function injectCodeByLineNumber(fileContent, index, snippet) {
17
+ const lines = fileContent.split('\n');
18
+ let content = lines;
19
+ if (index > -1) {
20
+ content = [...lines.slice(0, index), snippet, ...lines.slice(index)];
21
+ }
22
+ return content;
23
+ }
24
+ //# sourceMappingURL=codeInjection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["injectCodeByRegex","fileContent","lineRegex","snippet","lines","split","index","findIndex","line","test","content","slice","injectCodeByMultiLineRegex","replace","injectCodeByMultiLineRegexAndReplaceLine","injectCodeByLineNumber"],"sources":["codeInjection.ts"],"sourcesContent":["export function injectCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n const index = lines.findIndex((line) => lineRegex.test(line));\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n\nexport function injectCodeByMultiLineRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `$&\\n${snippet}`);\n}\n\nexport function injectCodeByMultiLineRegexAndReplaceLine(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `${snippet}`);\n}\n\nexport function injectCodeByLineNumber(\n fileContent: string,\n index: number,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n"],"mappings":"AAAA,OAAO,SAASA,iBAAiB,CAC/BC,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,MAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IAAKN,SAAS,CAACO,IAAI,CAACD,IAAI,CAAC,CAAC;EAC7D,IAAIE,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EAAEH,OAAO,EAAE,GAAGC,KAAK,CAACO,KAAK,CAACL,KAAK,CAAC,CAAC;EACtE;EAEA,OAAOI,OAAO;AAChB;AAEA,OAAO,SAASE,0BAA0B,CACxCX,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,OAAMC,OAAQ,EAAC,CAAC;AACzD;AAEA,OAAO,SAASW,wCAAwC,CACtDb,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,GAAEC,OAAQ,EAAC,CAAC;AACrD;AAEA,OAAO,SAASY,sBAAsB,CACpCd,WAAmB,EACnBK,KAAa,EACbH,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,IAAIK,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EAAEH,OAAO,EAAE,GAAGC,KAAK,CAACO,KAAK,CAACL,KAAK,CAAC,CAAC;EACtE;EAEA,OAAOI,OAAO;AAChB"}
@@ -0,0 +1,37 @@
1
+ import { readFile, writeFile, appendFile } from 'fs';
2
+ export class FileManagement {
3
+ static async read(path) {
4
+ return new Promise((resolve, reject) => {
5
+ readFile(path, 'utf8', (err, data) => {
6
+ if (err || !data) {
7
+ reject(err);
8
+ return;
9
+ }
10
+ resolve(data);
11
+ });
12
+ });
13
+ }
14
+ static async write(path, contents) {
15
+ return new Promise((resolve, reject) => {
16
+ writeFile(path, contents, 'utf8', err => {
17
+ if (err) {
18
+ reject(err);
19
+ return;
20
+ }
21
+ resolve();
22
+ });
23
+ });
24
+ }
25
+ static async append(path, contents) {
26
+ return new Promise((resolve, reject) => {
27
+ appendFile(path, contents, 'utf8', err => {
28
+ if (err) {
29
+ reject(err);
30
+ return;
31
+ }
32
+ resolve();
33
+ });
34
+ });
35
+ }
36
+ }
37
+ //# sourceMappingURL=fileManagement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["readFile","writeFile","appendFile","FileManagement","read","path","Promise","resolve","reject","err","data","write","contents","append"],"sources":["fileManagement.ts"],"sourcesContent":["import { readFile, writeFile, appendFile } from 'fs';\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"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,SAAS,EAAEC,UAAU,QAAQ,IAAI;AAEpD,OAAO,MAAMC,cAAc,CAAC;EAC1B,aAAaC,IAAI,CAACC,IAAY,EAAmB;IAC/C,OAAO,IAAIC,OAAO,CAAS,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC9CR,QAAQ,CAACK,IAAI,EAAE,MAAM,EAAE,CAACI,GAAG,EAAEC,IAAI,KAAK;QACpC,IAAID,GAAG,IAAI,CAACC,IAAI,EAAE;UAChBF,MAAM,CAACC,GAAG,CAAC;UACX;QACF;QACAF,OAAO,CAACG,IAAI,CAAC;MACf,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaC,KAAK,CAACN,IAAY,EAAEO,QAAgB,EAAiB;IAChE,OAAO,IAAIN,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC5CP,SAAS,CAACI,IAAI,EAAEO,QAAQ,EAAE,MAAM,EAAGH,GAAG,IAAK;QACzC,IAAIA,GAAG,EAAE;UACPD,MAAM,CAACC,GAAG,CAAC;UACX;QACF;QACAF,OAAO,EAAE;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaM,MAAM,CAACR,IAAY,EAAEO,QAAgB,EAAiB;IACjE,OAAO,IAAIN,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC5CN,UAAU,CAACG,IAAI,EAAEO,QAAQ,EAAE,MAAM,EAAGH,GAAG,IAAK;QAC1C,IAAIA,GAAG,EAAE;UACPD,MAAM,CAACC,GAAG,CAAC;UACX;QACF;QACAF,OAAO,EAAE;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;AACF"}
@@ -0,0 +1,25 @@
1
+ import { CIO_PODFILE_REGEX, CIO_PODFILE_SNIPPET, CIO_PODFILE_POST_INSTALL_REGEX, CIO_PODFILE_TARGET_NAMES_SNIPPET, CIO_PODFILE_POST_INSTALL_SNIPPET, CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET, CIO_PODFILE_NOTIFICATION_SNIPPET, CIO_PODFILE_NOTIFICATION_REGEX } from '../constants/ios';
2
+ import { FileManagement } from './fileManagement';
3
+ export async function injectCIOPodfileCode(iosPath) {
4
+ const filename = `${iosPath}/Podfile`;
5
+ const podfile = await FileManagement.read(filename);
6
+ const matches = podfile.match(CIO_PODFILE_REGEX);
7
+ const lines = podfile.split('\n');
8
+ const index = lines.findIndex(line => CIO_PODFILE_POST_INSTALL_REGEX.test(line));
9
+ let content = lines;
10
+ if (index > -1) {
11
+ content = [...lines.slice(0, index - 1), !matches ? CIO_PODFILE_SNIPPET : '', CIO_PODFILE_TARGET_NAMES_SNIPPET, ...lines.slice(index - 1, index + 1), CIO_PODFILE_POST_INSTALL_SNIPPET, ...lines.slice(index + 1)];
12
+ } else {
13
+ content.push(CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);
14
+ }
15
+ FileManagement.write(filename, content.join('\n'));
16
+ }
17
+ export async function injectCIONotificationPodfileCode(iosPath) {
18
+ const filename = `${iosPath}/Podfile`;
19
+ const podfile = await FileManagement.read(filename);
20
+ const matches = podfile.match(CIO_PODFILE_NOTIFICATION_REGEX);
21
+ if (!matches) {
22
+ FileManagement.append(filename, CIO_PODFILE_NOTIFICATION_SNIPPET);
23
+ }
24
+ }
25
+ //# sourceMappingURL=injectCIOPodfileCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CIO_PODFILE_REGEX","CIO_PODFILE_SNIPPET","CIO_PODFILE_POST_INSTALL_REGEX","CIO_PODFILE_TARGET_NAMES_SNIPPET","CIO_PODFILE_POST_INSTALL_SNIPPET","CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","CIO_PODFILE_NOTIFICATION_REGEX","FileManagement","injectCIOPodfileCode","iosPath","filename","podfile","read","matches","match","lines","split","index","findIndex","line","test","content","slice","push","write","join","injectCIONotificationPodfileCode","append"],"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} 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\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}\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_NO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C,CAAC;AACpD;AAEA,OAAO,eAAeC,gCAAgC,CAACjB,OAAe,EAAE;EACtE,MAAMC,QAAQ,GAAI,GAAED,OAAQ,UAAS;EACrC,MAAME,OAAO,GAAG,MAAMJ,cAAc,CAACK,IAAI,CAACF,QAAQ,CAAC;EACnD,MAAMG,OAAO,GAAGF,OAAO,CAACG,KAAK,CAACR,8BAA8B,CAAC;EAE7D,IAAI,CAACO,OAAO,EAAE;IACZN,cAAc,CAACoB,MAAM,CAACjB,QAAQ,EAAEL,gCAAgC,CAAC;EACnE;AACF"}
@@ -0,0 +1,10 @@
1
+ import { withCIOAndroid } from './android/withCIOAndroid';
2
+ import { withCIOIos } from './ios/withCIOIos';
3
+ // Entry point for config plugin
4
+ function withCustomerIOPlugin(config, props) {
5
+ config = withCIOIos(config, props);
6
+ config = withCIOAndroid(config, props);
7
+ return config;
8
+ }
9
+ export default withCustomerIOPlugin;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withCIOAndroid","withCIOIos","withCustomerIOPlugin","config","props"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginOptionsAndroid,\n} from './types/cio-types';\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS | CustomerIOPluginOptionsAndroid\n) {\n config = withCIOIos(config, props as CustomerIOPluginOptionsIOS);\n config = withCIOAndroid(config, props as CustomerIOPluginOptionsAndroid);\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,QAAQ,kBAAkB;AAM7C;AACA,SAASC,oBAAoB,CAC3BC,MAAkB,EAClBC,KAAkE,EAClE;EACAD,MAAM,GAAGF,UAAU,CAACE,MAAM,EAAEC,KAAK,CAA+B;EAChED,MAAM,GAAGH,cAAc,CAACG,MAAM,EAAEC,KAAK,CAAmC;EAExE,OAAOD,MAAM;AACf;AAEA,eAAeD,oBAAoB"}
@@ -0,0 +1,69 @@
1
+ import { withAppDelegate } from '@expo/config-plugins';
2
+ import { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';
3
+ import { CIO_APPDELEGATEDECLARATION_REGEX, CIO_APPDELEGATEHEADER_REGEX, CIO_APPDELEGATEHEADER_SNIPPET, CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET, CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET, CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET, CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET } from '../helpers/constants/ios';
4
+ import { injectCodeByLineNumber, injectCodeByMultiLineRegex, injectCodeByMultiLineRegexAndReplaceLine } from '../helpers/utils/codeInjection';
5
+ import { FileManagement } from '../helpers/utils/fileManagement';
6
+ const pushCodeSnippets = [CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET, CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET];
7
+ const additionalMethodsForPushNotifications = `${pushCodeSnippets.join('\n')}\n`; // Join w/ newlines and ensure a newline at the end.
8
+
9
+ const addImport = stringContents => {
10
+ const importRegex = /^(#import .*)\n/gm;
11
+ const addedImport = `
12
+ // Add swift bridge imports
13
+ #import <ExpoModulesCore-Swift.h>
14
+ #import <testiosapp-Swift.h>
15
+ `;
16
+ const match = stringContents.match(importRegex);
17
+ let endOfMatchIndex;
18
+ if (!match || match.index === undefined) {
19
+ // No imports found, just add to start of file:
20
+ endOfMatchIndex = 0;
21
+ } else {
22
+ // Add after first import:
23
+ endOfMatchIndex = match.index + match[0].length;
24
+ }
25
+ stringContents = injectCodeByLineNumber(stringContents, endOfMatchIndex, addedImport).join('\n');
26
+ return stringContents;
27
+ };
28
+ const addNotificationHandlerDeclaration = stringContents => {
29
+ stringContents = injectCodeByMultiLineRegex(stringContents, CIO_APPDELEGATEDECLARATION_REGEX, CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET);
30
+ return stringContents;
31
+ };
32
+ const addNotificationConfiguration = stringContents => {
33
+ stringContents = injectCodeByMultiLineRegex(stringContents, CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET);
34
+ return stringContents;
35
+ };
36
+ const addDidFailToRegisterForRemoteNotificationsWithError = stringContents => {
37
+ stringContents = injectCodeByMultiLineRegexAndReplaceLine(stringContents, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET);
38
+ return stringContents;
39
+ };
40
+ const AddDidRegisterForRemoteNotificationsWithDeviceToken = stringContents => {
41
+ stringContents = injectCodeByMultiLineRegexAndReplaceLine(stringContents, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET);
42
+ return stringContents;
43
+ };
44
+ const addAdditionalMethodsForPushNotifications = stringContents => {
45
+ stringContents = injectCodeByMultiLineRegex(stringContents, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX, additionalMethodsForPushNotifications);
46
+ return stringContents;
47
+ };
48
+ const addAppdelegateHeaderModification = stringContents => {
49
+ stringContents = injectCodeByMultiLineRegexAndReplaceLine(stringContents, CIO_APPDELEGATEHEADER_REGEX, CIO_APPDELEGATEHEADER_SNIPPET);
50
+ return stringContents;
51
+ };
52
+ export const withAppDelegateModifications = configOuter => {
53
+ return withAppDelegate(configOuter, async config => {
54
+ let stringContents = config.modResults.contents;
55
+ const headerPath = getAppDelegateHeaderFilePath(config.modRequest.projectRoot);
56
+ let headerContent = await FileManagement.read(headerPath);
57
+ headerContent = addAppdelegateHeaderModification(headerContent);
58
+ FileManagement.write(headerPath, headerContent);
59
+ stringContents = addImport(stringContents);
60
+ stringContents = addNotificationHandlerDeclaration(stringContents);
61
+ stringContents = addNotificationConfiguration(stringContents);
62
+ stringContents = addAdditionalMethodsForPushNotifications(stringContents);
63
+ stringContents = addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
64
+ stringContents = AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
65
+ config.modResults.contents = stringContents;
66
+ return config;
67
+ });
68
+ };
69
+ //# sourceMappingURL=withAppDelegateModifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withAppDelegate","getAppDelegateHeaderFilePath","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","injectCodeByLineNumber","injectCodeByMultiLineRegex","injectCodeByMultiLineRegexAndReplaceLine","FileManagement","pushCodeSnippets","additionalMethodsForPushNotifications","join","addImport","stringContents","importRegex","addedImport","match","endOfMatchIndex","index","undefined","length","addNotificationHandlerDeclaration","addNotificationConfiguration","addDidFailToRegisterForRemoteNotificationsWithError","AddDidRegisterForRemoteNotificationsWithDeviceToken","addAdditionalMethodsForPushNotifications","addAppdelegateHeaderModification","withAppDelegateModifications","configOuter","config","modResults","contents","headerPath","modRequest","projectRoot","headerContent","read","write"],"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 w/ newlines and ensure a newline at the end.\n\nconst addImport = (stringContents: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <testiosapp-Swift.h>\n `;\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 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(stringContents);\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 return config;\n });\n};\n"],"mappings":"AAAA,SAAuBA,eAAe,QAAQ,sBAAsB;AACpE,SAASC,4BAA4B,QAAQ,sCAAsC;AAEnF,SACEC,gCAAgC,EAChCC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,2CAA2C,EAC3CC,8DAA8D,EAC9DC,0D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CAAwC,CAACZ,cAAc,CAAC;IACzEA,cAAc,GACZU,mDAAmD,CAACV,cAAc,CAAC;IACrEA,cAAc,GACZW,mDAAmD,CAACX,cAAc,CAAC;IAErEgB,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGlB,cAAc;IAC3C,OAAOgB,MAAM;EACf,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,88 @@
1
+ import { withXcodeProject } from '@expo/config-plugins';
2
+ import fs from 'fs';
3
+ import xcode from 'xcode';
4
+ import { DEFAULT_BUNDLE_VERSION, LOCAL_PATH_TO_CIO_NSE_FILES } from '../helpers/constants/ios';
5
+ const addNotificationServiceExtensionFile = async options => {
6
+ const {
7
+ iosPath,
8
+ appName
9
+ } = options;
10
+ const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
11
+ const xcodeProject = xcode.project(projPath);
12
+ xcodeProject.parse(async function (err) {
13
+ if (err) {
14
+ throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
15
+ }
16
+ fs.mkdirSync(`${iosPath}/${appName}`, {
17
+ recursive: true
18
+ });
19
+ const file = 'PushNotification.swift';
20
+ const getTargetFile = filename => `${iosPath}/${appName}/${filename}`;
21
+ const targetFile = getTargetFile(file);
22
+ fs.copyFileSync(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
23
+
24
+ // Create new PBXGroup for the extension
25
+ const extGroup = xcodeProject.addPbxGroup([file], appName, appName);
26
+
27
+ // Add the new PBXGroup to the top level group. This makes the
28
+ // files / folder appear in the file explorer in Xcode.
29
+ const groups = xcodeProject.hash.project.objects['PBXGroup'];
30
+ Object.keys(groups).forEach(key => {
31
+ if (groups[key].name === undefined) {
32
+ xcodeProject.addToPbxGroup(extGroup.uuid, key);
33
+ }
34
+ });
35
+
36
+ // WORK AROUND for codeProject.addTarget BUG
37
+ // Xcode projects don't contain these if there is only one target
38
+ // An upstream fix should be made to the code referenced in this link:
39
+ // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
40
+ const projObjects = xcodeProject.hash.project.objects;
41
+ projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
42
+ projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
43
+ fs.writeFileSync(projPath, xcodeProject.writeSync());
44
+ });
45
+ };
46
+ export const withCioAppdelegateXcodeProject = (configOuter, props) => {
47
+ return withXcodeProject(configOuter, async config => {
48
+ const {
49
+ modRequest,
50
+ ios,
51
+ version: bundleShortVersion
52
+ } = config;
53
+ const {
54
+ appleTeamId,
55
+ iosDeploymentTarget
56
+ } = props;
57
+ if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js.');
58
+ const {
59
+ projectName,
60
+ platformProjectRoot
61
+ } = modRequest;
62
+ const {
63
+ bundleIdentifier,
64
+ buildNumber
65
+ } = ios;
66
+ if (bundleShortVersion === undefined) {
67
+ throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js');
68
+ }
69
+ if (bundleIdentifier === undefined) {
70
+ throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js');
71
+ }
72
+ if (projectName === undefined) {
73
+ throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js');
74
+ }
75
+ const options = {
76
+ appleTeamId,
77
+ bundleIdentifier,
78
+ bundleShortVersion,
79
+ bundleVersion: buildNumber ?? DEFAULT_BUNDLE_VERSION,
80
+ iosPath: platformProjectRoot,
81
+ appName: projectName,
82
+ iosDeploymentTarget
83
+ };
84
+ await addNotificationServiceExtensionFile(options);
85
+ return config;
86
+ });
87
+ };
88
+ //# sourceMappingURL=withAppDelegateXcodeProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withXcodeProject","fs","xcode","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","addNotificationServiceExtensionFile","options","iosPath","appName","projPath","xcodeProject","project","parse","err","Error","JSON","stringify","mkdirSync","recursive","file","getTargetFile","filename","targetFile","copyFileSync","extGroup","addPbxGroup","groups","hash","objects","Object","keys","forEach","key","name","undefined","addToPbxGroup","uuid","projObjects","writeFileSync","writeSync","withCioAppdelegateXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion"],"sources":["withAppDelegateXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport fs from 'fs';\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';\n\nconst addNotificationServiceExtensionFile = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n const { iosPath, appName } = 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 fs.mkdirSync(`${iosPath}/${appName}`, {\n recursive: true,\n });\n\n const file = 'PushNotification.swift';\n\n const getTargetFile = (filename: string) =>\n `${iosPath}/${appName}/${filename}`;\n\n const targetFile = getTargetFile(file);\n fs.copyFileSync(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup([file], appName, appName);\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 fs.writeFileSync(projPath, xcodeProject.writeSync());\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 addNotificationServiceExtensionFile(options);\n\n return config;\n });\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AACrE,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,KAAK,MAAM,OAAO;AAEzB,SACEC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AAGjC,MAAMC,mCAAmC,GAAG,MAC1CC,OAAmC,IAChC;EACH,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGF,OAAO;EAEpC,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CAACC,OAAO,CAAC;IAElD,OAAOqC,MAAM;EACf,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { withAppDelegateModifications } from './withAppDelegateModifications';
2
+ import { withCioAppdelegateXcodeProject } from './withAppDelegateXcodeProject';
3
+ import { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';
4
+ import { withCioXcodeProject } from './withXcodeProject';
5
+ export function withCIOIos(config, props) {
6
+ config = withCioNotificationsXcodeProject(config, props);
7
+ config = withAppDelegateModifications(config, props);
8
+ config = withCioXcodeProject(config, props);
9
+ config = withCioAppdelegateXcodeProject(config, props);
10
+ return config;
11
+ }
12
+ //# sourceMappingURL=withCIOIos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withAppDelegateModifications","withCioAppdelegateXcodeProject","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","props"],"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 config = withCioNotificationsXcodeProject(config, props);\n config = withAppDelegateModifications(config, props);\n config = withCioXcodeProject(config, props);\n config = withCioAppdelegateXcodeProject(config, props);\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,8BAA8B,QAAQ,+BAA+B;AAC9E,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,OAAO,SAASC,UAAU,CACxBC,MAAkB,EAClBC,KAAiC,EACjC;EACAD,MAAM,GAAGH,gCAAgC,CAACG,MAAM,EAAEC,KAAK,CAAC;EACxDD,MAAM,GAAGL,4BAA4B,CAACK,MAAM,EAAEC,KAAK,CAAC;EACpDD,MAAM,GAAGF,mBAAmB,CAACE,MAAM,EAAEC,KAAK,CAAC;EAC3CD,MAAM,GAAGJ,8BAA8B,CAACI,MAAM,EAAEC,KAAK,CAAC;EAEtD,OAAOD,MAAM;AACf"}