@attentive-mobile/attentive-react-native-sdk 2.0.0-beta.4 → 2.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +146 -10
- package/android/build.gradle +4 -1
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/kotlin/com/attentivereactnativesdk/AttentiveNotificationStore.kt +60 -0
- package/android/src/main/kotlin/com/attentivereactnativesdk/AttentivePushHelper.kt +101 -0
- package/android/src/main/kotlin/com/attentivereactnativesdk/AttentiveReactNativeSdkModule.kt +192 -134
- package/android/src/test/kotlin/com/attentivereactnativesdk/AttentiveNotificationStoreTest.kt +103 -0
- package/ios/AttentiveReactNativeSdk.mm +49 -2
- package/ios/AttentiveReactNativeSdk.xcodeproj/project.xcworkspace/xcuserdata/zheref.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Bridging/ATTNNativeSDK.swift +35 -28
- package/lib/commonjs/NativeAttentiveReactNativeSdk.js +1 -1
- package/lib/commonjs/NativeAttentiveReactNativeSdk.js.map +1 -1
- package/lib/commonjs/eventTypes.js.map +1 -1
- package/lib/commonjs/index.js +64 -10
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeAttentiveReactNativeSdk.js +2 -2
- package/lib/module/NativeAttentiveReactNativeSdk.js.map +1 -1
- package/lib/module/eventTypes.js.map +1 -1
- package/lib/module/index.js +64 -12
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/NativeAttentiveReactNativeSdk.d.ts +21 -2
- package/lib/typescript/NativeAttentiveReactNativeSdk.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +55 -10
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +9 -4
- package/src/NativeAttentiveReactNativeSdk.ts +79 -53
- package/src/index.tsx +65 -11
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
RCT_EXPORT_MODULE()
|
|
23
23
|
|
|
24
24
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
25
|
-
// New Architecture implementation with flattened parameters
|
|
25
|
+
// New Architecture implementation with flattened parameters.
|
|
26
|
+
// Initialize is invoked only from TypeScript (e.g. Bonni App); native must not auto-initialize.
|
|
26
27
|
- (void)initialize:(NSString *)attentiveDomain
|
|
27
28
|
mode:(NSString *)mode
|
|
28
29
|
skipFatigueOnCreatives:(BOOL)skipFatigueOnCreatives
|
|
@@ -189,7 +190,8 @@ customIdentifiers:(NSDictionary *)customIdentifiers {
|
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
#else
|
|
192
|
-
// Old Architecture implementation with dictionary parameters
|
|
193
|
+
// Old Architecture implementation with dictionary parameters.
|
|
194
|
+
// Initialize is invoked only from TypeScript (e.g. Bonni App); native must not auto-initialize.
|
|
193
195
|
- (void)initialize:(NSDictionary*)configuration {
|
|
194
196
|
_sdk = [[ATTNNativeSDK alloc] initWithDomain:configuration[@"attentiveDomain"]
|
|
195
197
|
mode:configuration[@"mode"]
|
|
@@ -311,6 +313,19 @@ customIdentifiers:(NSDictionary *)customIdentifiers {
|
|
|
311
313
|
authorizationStatus:(NSString *)authorizationStatus {
|
|
312
314
|
[_sdk handlePushOpenFromRN:userInfo authorizationStatus:authorizationStatus];
|
|
313
315
|
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* iOS stub for getInitialPushNotification.
|
|
319
|
+
*
|
|
320
|
+
* On iOS, the killed-state push-open event is tracked natively in
|
|
321
|
+
* AppDelegate.userNotificationCenter(_:didReceive:withCompletionHandler:) via
|
|
322
|
+
* AttentiveSDKManager.shared, so there is no pending payload to return here.
|
|
323
|
+
* Resolves with nil so callers on both platforms can share the same code path.
|
|
324
|
+
*/
|
|
325
|
+
- (void)getInitialPushNotification:(RCTPromiseResolveBlock)resolve
|
|
326
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
327
|
+
resolve(nil);
|
|
328
|
+
}
|
|
314
329
|
#endif
|
|
315
330
|
|
|
316
331
|
|
|
@@ -335,6 +350,38 @@ customIdentifiers:(NSDictionary *)customIdentifiers {
|
|
|
335
350
|
}
|
|
336
351
|
return UNAuthorizationStatusNotDetermined;
|
|
337
352
|
}
|
|
353
|
+
|
|
354
|
+
// Helper to convert UNAuthorizationStatus to string for getPushAuthorizationStatus
|
|
355
|
+
- (NSString *)authorizationStatusToRNString:(UNAuthorizationStatus)status {
|
|
356
|
+
switch (status) {
|
|
357
|
+
case UNAuthorizationStatusAuthorized:
|
|
358
|
+
return @"authorized";
|
|
359
|
+
case UNAuthorizationStatusDenied:
|
|
360
|
+
return @"denied";
|
|
361
|
+
case UNAuthorizationStatusNotDetermined:
|
|
362
|
+
return @"notDetermined";
|
|
363
|
+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 120000
|
|
364
|
+
case UNAuthorizationStatusProvisional:
|
|
365
|
+
return @"provisional";
|
|
366
|
+
#endif
|
|
367
|
+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000
|
|
368
|
+
case UNAuthorizationStatusEphemeral:
|
|
369
|
+
return @"ephemeral";
|
|
370
|
+
#endif
|
|
371
|
+
default:
|
|
372
|
+
return @"notDetermined";
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
- (void)getPushAuthorizationStatus:(RCTPromiseResolveBlock)resolve
|
|
377
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
378
|
+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
379
|
+
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
|
|
380
|
+
NSString *status = [self authorizationStatusToRNString:settings.authorizationStatus];
|
|
381
|
+
resolve(status);
|
|
382
|
+
}];
|
|
383
|
+
}
|
|
384
|
+
|
|
338
385
|
- (void)triggerCreative:(NSString *)creativeId {
|
|
339
386
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
340
387
|
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
|
|
Binary file
|
|
@@ -381,57 +381,64 @@ struct DebugEvent {
|
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
/**
|
|
384
|
-
*
|
|
385
|
-
* This method accepts userInfo dictionary instead of UNNotificationResponse, making it callable from React Native.
|
|
384
|
+
* React Native bridge entry point for foreground push tracking.
|
|
386
385
|
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
386
|
+
* **Important — iOS limitation**: The Attentive iOS SDK requires a `UNNotificationResponse`
|
|
387
|
+
* object for `handleForegroundPush`, which is an opaque system type that cannot be
|
|
388
|
+
* serialised across the React Native bridge. Calling this method from JS therefore
|
|
389
|
+
* **cannot invoke the native SDK** and is a no-op.
|
|
389
390
|
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
391
|
+
* The correct solution for iOS is to call
|
|
392
|
+
* `AttentiveSDKManager.shared.handleForegroundPush(response:authorizationStatus:)`
|
|
393
|
+
* directly from the host app's `UNUserNotificationCenterDelegate` implementation
|
|
394
|
+
* (i.e. `AppDelegate.userNotificationCenter(_:didReceive:withCompletionHandler:)`).
|
|
395
|
+
* Bonni's `AppDelegate.swift` already does this, so foreground push events are tracked
|
|
396
|
+
* correctly via the native path — this RN bridge variant is intentionally unused on iOS.
|
|
397
|
+
*
|
|
398
|
+
* @param userInfo The notification payload dictionary (unused on iOS).
|
|
399
|
+
* @param authorizationStatus Current push authorization status string (unused on iOS).
|
|
392
400
|
*/
|
|
393
401
|
@objc(handleForegroundPushFromRN:authorizationStatus:)
|
|
394
402
|
public func handleForegroundPushFromRN(_ userInfo: [String: Any], authorizationStatus: String) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
// This is a workaround that logs the limitation
|
|
399
|
-
print("[AttentiveSDK] handleForegroundPush called from React Native (limited functionality)")
|
|
400
|
-
print("[AttentiveSDK] For full functionality, implement in native AppDelegate")
|
|
403
|
+
// iOS: no-op — tracking is performed natively via AttentiveSDKManager in AppDelegate.
|
|
404
|
+
// The UNNotificationResponse required by the iOS SDK cannot cross the RN bridge.
|
|
405
|
+
print("[AttentiveSDK] handleForegroundPushFromRN: iOS push tracking is handled natively via AttentiveSDKManager in AppDelegate. This RN bridge call is a no-op on iOS.")
|
|
401
406
|
|
|
402
407
|
if debuggingEnabled {
|
|
403
|
-
showDebugInfo(event: "Foreground Push (
|
|
408
|
+
showDebugInfo(event: "Foreground Push (RN bridge — iOS no-op)", data: [
|
|
404
409
|
"authorizationStatus": authorizationStatus,
|
|
405
410
|
"userInfo": userInfo,
|
|
406
|
-
"note": "
|
|
411
|
+
"note": "iOS: tracked via AppDelegate → AttentiveSDKManager. UNNotificationResponse not available from RN bridge."
|
|
407
412
|
])
|
|
408
413
|
}
|
|
409
414
|
}
|
|
410
415
|
|
|
411
416
|
/**
|
|
412
|
-
*
|
|
413
|
-
* This method accepts userInfo dictionary instead of UNNotificationResponse, making it callable from React Native.
|
|
417
|
+
* React Native bridge entry point for push-open tracking (background/inactive tap).
|
|
414
418
|
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
419
|
+
* **Important — iOS limitation**: The Attentive iOS SDK requires a `UNNotificationResponse`
|
|
420
|
+
* object for `handlePushOpen`, which cannot be serialised across the React Native bridge.
|
|
421
|
+
* Calling this method from JS is therefore a **no-op on iOS**.
|
|
417
422
|
*
|
|
418
|
-
*
|
|
419
|
-
*
|
|
423
|
+
* The correct solution is to call
|
|
424
|
+
* `AttentiveSDKManager.shared.handlePushOpen(response:authorizationStatus:)` directly
|
|
425
|
+
* from `AppDelegate.userNotificationCenter(_:didReceive:withCompletionHandler:)`.
|
|
426
|
+
* Bonni's `AppDelegate.swift` already does this via the native path.
|
|
427
|
+
*
|
|
428
|
+
* @param userInfo The notification payload dictionary (unused on iOS).
|
|
429
|
+
* @param authorizationStatus Current push authorization status string (unused on iOS).
|
|
420
430
|
*/
|
|
421
431
|
@objc(handlePushOpenFromRN:authorizationStatus:)
|
|
422
432
|
public func handlePushOpenFromRN(_ userInfo: [String: Any], authorizationStatus: String) {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
// This is a workaround that logs the limitation
|
|
427
|
-
print("[AttentiveSDK] handlePushOpen called from React Native (limited functionality)")
|
|
428
|
-
print("[AttentiveSDK] For full functionality, implement in native AppDelegate")
|
|
433
|
+
// iOS: no-op — tracking is performed natively via AttentiveSDKManager in AppDelegate.
|
|
434
|
+
// The UNNotificationResponse required by the iOS SDK cannot cross the RN bridge.
|
|
435
|
+
print("[AttentiveSDK] handlePushOpenFromRN: iOS push tracking is handled natively via AttentiveSDKManager in AppDelegate. This RN bridge call is a no-op on iOS.")
|
|
429
436
|
|
|
430
437
|
if debuggingEnabled {
|
|
431
|
-
showDebugInfo(event: "Push Open (
|
|
438
|
+
showDebugInfo(event: "Push Open (RN bridge — iOS no-op)", data: [
|
|
432
439
|
"authorizationStatus": authorizationStatus,
|
|
433
440
|
"userInfo": userInfo,
|
|
434
|
-
"note": "
|
|
441
|
+
"note": "iOS: tracked via AppDelegate → AttentiveSDKManager. UNNotificationResponse not available from RN bridge."
|
|
435
442
|
])
|
|
436
443
|
}
|
|
437
444
|
}
|
|
@@ -8,7 +8,7 @@ var _reactNative = require("react-native");
|
|
|
8
8
|
// Try to load via TurboModule first (new architecture)
|
|
9
9
|
// Fall back to NativeModules for old architecture
|
|
10
10
|
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
11
|
-
const AttentiveReactNativeSdkModule = isTurboModuleEnabled ? _reactNative.TurboModuleRegistry.get(
|
|
11
|
+
const AttentiveReactNativeSdkModule = isTurboModuleEnabled ? _reactNative.TurboModuleRegistry.get('AttentiveReactNativeSdk') : _reactNative.NativeModules.AttentiveReactNativeSdk;
|
|
12
12
|
var _default = AttentiveReactNativeSdkModule;
|
|
13
13
|
exports.default = _default;
|
|
14
14
|
//# sourceMappingURL=NativeAttentiveReactNativeSdk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","isTurboModuleEnabled","global","__turboModuleProxy","AttentiveReactNativeSdkModule","TurboModuleRegistry","get","NativeModules","AttentiveReactNativeSdk","_default","exports","default"],"sourceRoot":"../../src","sources":["NativeAttentiveReactNativeSdk.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","isTurboModuleEnabled","global","__turboModuleProxy","AttentiveReactNativeSdkModule","TurboModuleRegistry","get","NativeModules","AttentiveReactNativeSdk","_default","exports","default"],"sourceRoot":"../../src","sources":["NativeAttentiveReactNativeSdk.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAwKA;AACA;AACA,MAAMC,oBAAoB,GAAIC,MAAM,CAASC,kBAAkB,IAAI,IAAI;AAEvE,MAAMC,6BAA6B,GAAGH,oBAAoB,GACtDI,gCAAmB,CAACC,GAAG,CAAO,yBAAyB,CAAC,GACxDC,0BAAa,CAACC,uBAAuB;AAAA,IAAAC,QAAA,GAE1BL,6BAA6B;AAAAM,OAAA,CAAAC,OAAA,GAAAF,QAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["eventTypes.tsx"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["eventTypes.tsx"],"mappings":"","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.clearUser = clearUser;
|
|
7
7
|
exports.destroyCreative = destroyCreative;
|
|
8
8
|
exports.exportDebugLogs = exportDebugLogs;
|
|
9
|
+
exports.getInitialPushNotification = getInitialPushNotification;
|
|
10
|
+
exports.getPushAuthorizationStatus = getPushAuthorizationStatus;
|
|
9
11
|
exports.handleForegroundNotification = handleForegroundNotification;
|
|
10
12
|
exports.handleForegroundPush = handleForegroundPush;
|
|
11
13
|
exports.handlePushOpen = handlePushOpen;
|
|
@@ -37,7 +39,12 @@ const AttentiveReactNativeSdk = _NativeAttentiveReactNativeSdk.default ? _Native
|
|
|
37
39
|
});
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
|
-
* Initialize the Attentive SDK with the provided configuration
|
|
42
|
+
* Initialize the Attentive SDK with the provided configuration.
|
|
43
|
+
* This is the only supported entry point: the app (e.g. Bonni) must call this from TypeScript
|
|
44
|
+
* once at startup; the call is forwarded to the native module on each platform (iOS/Android),
|
|
45
|
+
* which then initializes the platform Attentive SDK. Native code must not initialize the SDK
|
|
46
|
+
* on its own (e.g. in Application onCreate or AppDelegate).
|
|
47
|
+
*
|
|
41
48
|
* @param configuration - Configuration object for the Attentive SDK
|
|
42
49
|
*/
|
|
43
50
|
function initialize(configuration) {
|
|
@@ -130,13 +137,13 @@ function exportDebugLogs() {
|
|
|
130
137
|
}
|
|
131
138
|
|
|
132
139
|
// =============================================================================
|
|
133
|
-
// Push Notification Methods (iOS
|
|
140
|
+
// Push Notification Methods (iOS and Android)
|
|
134
141
|
// =============================================================================
|
|
135
142
|
|
|
136
143
|
/**
|
|
137
144
|
* Request push notification permission from the user.
|
|
138
145
|
* On iOS, this will trigger the system permission dialog.
|
|
139
|
-
* On Android
|
|
146
|
+
* On Android 13+, this requests POST_NOTIFICATIONS; on older versions, no-op.
|
|
140
147
|
*
|
|
141
148
|
* @example
|
|
142
149
|
* ```typescript
|
|
@@ -150,12 +157,30 @@ function registerForPushNotifications() {
|
|
|
150
157
|
AttentiveReactNativeSdk.registerForPushNotifications();
|
|
151
158
|
}
|
|
152
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Get the current push notification authorization status.
|
|
162
|
+
* On Android, uses the SDK's native check (POST_NOTIFICATIONS on API 33+).
|
|
163
|
+
* On iOS, uses UNUserNotificationCenter notification settings.
|
|
164
|
+
*
|
|
165
|
+
* @returns Promise resolving to 'authorized' | 'denied' | 'notDetermined' (and on iOS possibly 'provisional' | 'ephemeral')
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* import { getPushAuthorizationStatus, handleRegularOpen } from 'attentive-react-native-sdk';
|
|
170
|
+
*
|
|
171
|
+
* getPushAuthorizationStatus().then((status) => handleRegularOpen(status));
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
function getPushAuthorizationStatus() {
|
|
175
|
+
return AttentiveReactNativeSdk.getPushAuthorizationStatus();
|
|
176
|
+
}
|
|
177
|
+
|
|
153
178
|
/**
|
|
154
179
|
* Register the device token received from APNs/FCM with the Attentive backend.
|
|
155
180
|
* Call this from your AppDelegate's didRegisterForRemoteNotificationsWithDeviceToken.
|
|
156
181
|
*
|
|
157
182
|
* On iOS, the token should be the hex-encoded string representation of the device token Data.
|
|
158
|
-
* On Android,
|
|
183
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
159
184
|
*
|
|
160
185
|
* @param token - The device token as a hex-encoded string
|
|
161
186
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -178,7 +203,7 @@ function registerDeviceToken(token, authorizationStatus) {
|
|
|
178
203
|
*
|
|
179
204
|
* On iOS, this will register the device token with the Attentive SDK and invoke the callback
|
|
180
205
|
* after the registration completes (success or failure).
|
|
181
|
-
* On Android,
|
|
206
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
182
207
|
*
|
|
183
208
|
* @param token - The hex-encoded device token string from APNs
|
|
184
209
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -225,7 +250,7 @@ function registerDeviceTokenWithCallback(token, authorizationStatus, callback) {
|
|
|
225
250
|
*
|
|
226
251
|
* On iOS, this will notify the Attentive SDK that the app was opened directly
|
|
227
252
|
* (not from a push notification tap).
|
|
228
|
-
* On Android,
|
|
253
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
229
254
|
*
|
|
230
255
|
* @param authorizationStatus - Current push authorization status
|
|
231
256
|
*
|
|
@@ -268,7 +293,7 @@ function handleRegularOpen(authorizationStatus) {
|
|
|
268
293
|
*
|
|
269
294
|
* On iOS, this will track the push open event and handle the notification appropriately
|
|
270
295
|
* based on whether the app was in the foreground, background, or not running.
|
|
271
|
-
* On Android,
|
|
296
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
272
297
|
*
|
|
273
298
|
* @param userInfo - The notification payload from the push notification
|
|
274
299
|
* @param applicationState - The app state when the notification was opened ('active', 'inactive', 'background')
|
|
@@ -295,7 +320,7 @@ function handlePushOpened(userInfo, applicationState, authorizationStatus) {
|
|
|
295
320
|
* Call this from your notification handler when a notification is received while the app is active.
|
|
296
321
|
*
|
|
297
322
|
* On iOS, this allows the Attentive SDK to track the notification event.
|
|
298
|
-
* On Android,
|
|
323
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
299
324
|
*
|
|
300
325
|
* @param userInfo - The notification payload from the push notification
|
|
301
326
|
*
|
|
@@ -323,7 +348,7 @@ function handleForegroundNotification(userInfo) {
|
|
|
323
348
|
* ```
|
|
324
349
|
*
|
|
325
350
|
* On iOS, this properly tracks foreground push notifications.
|
|
326
|
-
* On Android,
|
|
351
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
327
352
|
*
|
|
328
353
|
* @param userInfo - The notification payload from the push notification
|
|
329
354
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -356,7 +381,7 @@ function handleForegroundPush(userInfo, authorizationStatus) {
|
|
|
356
381
|
* ```
|
|
357
382
|
*
|
|
358
383
|
* On iOS, this properly tracks push notification opens.
|
|
359
|
-
* On Android,
|
|
384
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
360
385
|
*
|
|
361
386
|
* @param userInfo - The notification payload from the push notification
|
|
362
387
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -376,4 +401,33 @@ function handleForegroundPush(userInfo, authorizationStatus) {
|
|
|
376
401
|
function handlePushOpen(userInfo, authorizationStatus) {
|
|
377
402
|
AttentiveReactNativeSdk.handlePushOpen(userInfo, authorizationStatus);
|
|
378
403
|
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Returns the push notification payload that launched the app from a killed state
|
|
407
|
+
* (i.e. the user tapped an FCM notification while the app was not running) and clears
|
|
408
|
+
* it so it is only delivered once.
|
|
409
|
+
*
|
|
410
|
+
* **Android only.** On iOS, use `PushNotificationIOS.getInitialNotification()` to
|
|
411
|
+
* achieve the same result — the Attentive iOS SDK event is tracked natively in
|
|
412
|
+
* `AppDelegate.userNotificationCenter(_:didReceive:withCompletionHandler:)` via
|
|
413
|
+
* `AttentiveSDKManager.shared`.
|
|
414
|
+
*
|
|
415
|
+
* Call this once at app startup (after `initialize()`) to detect and handle the
|
|
416
|
+
* killed-state push-open scenario:
|
|
417
|
+
*
|
|
418
|
+
* ```typescript
|
|
419
|
+
* const initial = await getInitialPushNotification()
|
|
420
|
+
* if (initial) {
|
|
421
|
+
* const authStatus = await getPushAuthorizationStatus()
|
|
422
|
+
* handlePushOpen(initial as PushNotificationUserInfo, authStatus)
|
|
423
|
+
* }
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* @returns A promise that resolves to the notification data object, or `null` if the
|
|
427
|
+
* app was not launched via a push notification tap.
|
|
428
|
+
*/
|
|
429
|
+
async function getInitialPushNotification() {
|
|
430
|
+
const result = await AttentiveReactNativeSdk.getInitialPushNotification();
|
|
431
|
+
return result;
|
|
432
|
+
}
|
|
379
433
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_NativeAttentiveReactNativeSdk","_interopRequireDefault","obj","__esModule","default","LINKING_ERROR","Platform","select","ios","AttentiveReactNativeSdk","NativeAttentiveReactNativeSdkModule","Proxy","get","Error","initialize","configuration","attentiveDomain","mode","skipFatigueOnCreatives","enableDebugger","triggerCreative","creativeId","destroyCreative","updateDomain","domain","identify","identifiers","phone","email","klaviyoId","shopifyId","clientUserId","customIdentifiers","clearUser","recordAddToCartEvent","attrs","items","deeplink","recordProductViewEvent","recordPurchaseEvent","orderId","cartId","cartCoupon","recordCustomEvent","type","properties","invokeAttentiveDebugHelper","exportDebugLogs","registerForPushNotifications","registerDeviceToken","token","authorizationStatus","registerDeviceTokenWithCallback","callback","handleRegularOpen","console","log","handlePushOpened","userInfo","applicationState","handleForegroundNotification","handleForegroundPush","handlePushOpen"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_NativeAttentiveReactNativeSdk","_interopRequireDefault","obj","__esModule","default","LINKING_ERROR","Platform","select","ios","AttentiveReactNativeSdk","NativeAttentiveReactNativeSdkModule","Proxy","get","Error","initialize","configuration","attentiveDomain","mode","skipFatigueOnCreatives","enableDebugger","triggerCreative","creativeId","destroyCreative","updateDomain","domain","identify","identifiers","phone","email","klaviyoId","shopifyId","clientUserId","customIdentifiers","clearUser","recordAddToCartEvent","attrs","items","deeplink","recordProductViewEvent","recordPurchaseEvent","orderId","cartId","cartCoupon","recordCustomEvent","type","properties","invokeAttentiveDebugHelper","exportDebugLogs","registerForPushNotifications","getPushAuthorizationStatus","registerDeviceToken","token","authorizationStatus","registerDeviceTokenWithCallback","callback","handleRegularOpen","console","log","handlePushOpened","userInfo","applicationState","handleForegroundNotification","handleForegroundPush","handlePushOpen","getInitialPushNotification","result"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"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BAA0B,CAAC,CAAC;AAC7D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,mBAAmBA,CAC1BC,KAAa,EACbC,mBAA4C,EACtC;EACN3C,uBAAuB,CAACyC,mBAAmB,CAACC,KAAK,EAAEC,mBAAmB,CAAC;AACzE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,+BAA+BA,CACtCF,KAAa,EACbC,mBAA4C,EAC5CE,QAKS,EACH;EACN7C,uBAAuB,CAAC4C,+BAA+B,CACrDF,KAAK,EACLC,mBAAmB,EACnBE,QACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAACH,mBAA4C,EAAQ;EAC7EI,OAAO,CAACC,GAAG,CAAC,6DAA6D,CAAC;EAC1ED,OAAO,CAACC,GAAG,CAAC,4BAA4BL,mBAAmB,EAAE,CAAC;EAC9DI,OAAO,CAACC,GAAG,CACT,mEACF,CAAC;EAEDhD,uBAAuB,CAAC8C,iBAAiB,CAACH,mBAAmB,CAAC;EAE9DI,OAAO,CAACC,GAAG,CAAC,mDAAmD,CAAC;AAClE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CACvBC,QAAkC,EAClCC,gBAAkC,EAClCR,mBAA4C,EACtC;EACN3C,uBAAuB,CAACiD,gBAAgB,CACtCC,QAAQ,EACRC,gBAAgB,EAChBR,mBACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASS,4BAA4BA,CACnCF,QAAkC,EAC5B;EACNlD,uBAAuB,CAACoD,4BAA4B,CAACF,QAAkB,CAAC;AAC1E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,oBAAoBA,CAC3BH,QAAkC,EAClCP,mBAA4C,EACtC;EACN3C,uBAAuB,CAACqD,oBAAoB,CAC1CH,QAAQ,EACRP,mBACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASW,cAAcA,CACrBJ,QAAkC,EAClCP,mBAA4C,EACtC;EACN3C,uBAAuB,CAACsD,cAAc,CACpCJ,QAAQ,EACRP,mBACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeY,0BAA0BA,CAAA,EAA2C;EAClF,MAAMC,MAAM,GAAG,MAAMxD,uBAAuB,CAACuD,0BAA0B,CAAC,CAAC;EACzE,OAAOC,MAAM;AACf","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TurboModuleRegistry, NativeModules } from
|
|
1
|
+
import { TurboModuleRegistry, NativeModules } from 'react-native';
|
|
2
2
|
// Try to load via TurboModule first (new architecture)
|
|
3
3
|
// Fall back to NativeModules for old architecture
|
|
4
4
|
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
5
|
-
const AttentiveReactNativeSdkModule = isTurboModuleEnabled ? TurboModuleRegistry.get(
|
|
5
|
+
const AttentiveReactNativeSdkModule = isTurboModuleEnabled ? TurboModuleRegistry.get('AttentiveReactNativeSdk') : NativeModules.AttentiveReactNativeSdk;
|
|
6
6
|
export default AttentiveReactNativeSdkModule;
|
|
7
7
|
//# sourceMappingURL=NativeAttentiveReactNativeSdk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","NativeModules","isTurboModuleEnabled","global","__turboModuleProxy","AttentiveReactNativeSdkModule","get","AttentiveReactNativeSdk"],"sourceRoot":"../../src","sources":["NativeAttentiveReactNativeSdk.ts"],"mappings":"AACA,SAASA,mBAAmB,EAAEC,aAAa,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","NativeModules","isTurboModuleEnabled","global","__turboModuleProxy","AttentiveReactNativeSdkModule","get","AttentiveReactNativeSdk"],"sourceRoot":"../../src","sources":["NativeAttentiveReactNativeSdk.ts"],"mappings":"AACA,SAASA,mBAAmB,EAAEC,aAAa,QAAQ,cAAc;AAwKjE;AACA;AACA,MAAMC,oBAAoB,GAAIC,MAAM,CAASC,kBAAkB,IAAI,IAAI;AAEvE,MAAMC,6BAA6B,GAAGH,oBAAoB,GACtDF,mBAAmB,CAACM,GAAG,CAAO,yBAAyB,CAAC,GACxDL,aAAa,CAACM,uBAAuB;AAEzC,eAAeF,6BAA6B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["eventTypes.tsx"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["eventTypes.tsx"],"mappings":"","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -11,7 +11,12 @@ const AttentiveReactNativeSdk = NativeAttentiveReactNativeSdkModule ? NativeAtte
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Initialize the Attentive SDK with the provided configuration
|
|
14
|
+
* Initialize the Attentive SDK with the provided configuration.
|
|
15
|
+
* This is the only supported entry point: the app (e.g. Bonni) must call this from TypeScript
|
|
16
|
+
* once at startup; the call is forwarded to the native module on each platform (iOS/Android),
|
|
17
|
+
* which then initializes the platform Attentive SDK. Native code must not initialize the SDK
|
|
18
|
+
* on its own (e.g. in Application onCreate or AppDelegate).
|
|
19
|
+
*
|
|
15
20
|
* @param configuration - Configuration object for the Attentive SDK
|
|
16
21
|
*/
|
|
17
22
|
function initialize(configuration) {
|
|
@@ -104,13 +109,13 @@ function exportDebugLogs() {
|
|
|
104
109
|
}
|
|
105
110
|
|
|
106
111
|
// =============================================================================
|
|
107
|
-
// Push Notification Methods (iOS
|
|
112
|
+
// Push Notification Methods (iOS and Android)
|
|
108
113
|
// =============================================================================
|
|
109
114
|
|
|
110
115
|
/**
|
|
111
116
|
* Request push notification permission from the user.
|
|
112
117
|
* On iOS, this will trigger the system permission dialog.
|
|
113
|
-
* On Android
|
|
118
|
+
* On Android 13+, this requests POST_NOTIFICATIONS; on older versions, no-op.
|
|
114
119
|
*
|
|
115
120
|
* @example
|
|
116
121
|
* ```typescript
|
|
@@ -124,12 +129,30 @@ function registerForPushNotifications() {
|
|
|
124
129
|
AttentiveReactNativeSdk.registerForPushNotifications();
|
|
125
130
|
}
|
|
126
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Get the current push notification authorization status.
|
|
134
|
+
* On Android, uses the SDK's native check (POST_NOTIFICATIONS on API 33+).
|
|
135
|
+
* On iOS, uses UNUserNotificationCenter notification settings.
|
|
136
|
+
*
|
|
137
|
+
* @returns Promise resolving to 'authorized' | 'denied' | 'notDetermined' (and on iOS possibly 'provisional' | 'ephemeral')
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* import { getPushAuthorizationStatus, handleRegularOpen } from 'attentive-react-native-sdk';
|
|
142
|
+
*
|
|
143
|
+
* getPushAuthorizationStatus().then((status) => handleRegularOpen(status));
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
function getPushAuthorizationStatus() {
|
|
147
|
+
return AttentiveReactNativeSdk.getPushAuthorizationStatus();
|
|
148
|
+
}
|
|
149
|
+
|
|
127
150
|
/**
|
|
128
151
|
* Register the device token received from APNs/FCM with the Attentive backend.
|
|
129
152
|
* Call this from your AppDelegate's didRegisterForRemoteNotificationsWithDeviceToken.
|
|
130
153
|
*
|
|
131
154
|
* On iOS, the token should be the hex-encoded string representation of the device token Data.
|
|
132
|
-
* On Android,
|
|
155
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
133
156
|
*
|
|
134
157
|
* @param token - The device token as a hex-encoded string
|
|
135
158
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -152,7 +175,7 @@ function registerDeviceToken(token, authorizationStatus) {
|
|
|
152
175
|
*
|
|
153
176
|
* On iOS, this will register the device token with the Attentive SDK and invoke the callback
|
|
154
177
|
* after the registration completes (success or failure).
|
|
155
|
-
* On Android,
|
|
178
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
156
179
|
*
|
|
157
180
|
* @param token - The hex-encoded device token string from APNs
|
|
158
181
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -199,7 +222,7 @@ function registerDeviceTokenWithCallback(token, authorizationStatus, callback) {
|
|
|
199
222
|
*
|
|
200
223
|
* On iOS, this will notify the Attentive SDK that the app was opened directly
|
|
201
224
|
* (not from a push notification tap).
|
|
202
|
-
* On Android,
|
|
225
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
203
226
|
*
|
|
204
227
|
* @param authorizationStatus - Current push authorization status
|
|
205
228
|
*
|
|
@@ -242,7 +265,7 @@ function handleRegularOpen(authorizationStatus) {
|
|
|
242
265
|
*
|
|
243
266
|
* On iOS, this will track the push open event and handle the notification appropriately
|
|
244
267
|
* based on whether the app was in the foreground, background, or not running.
|
|
245
|
-
* On Android,
|
|
268
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
246
269
|
*
|
|
247
270
|
* @param userInfo - The notification payload from the push notification
|
|
248
271
|
* @param applicationState - The app state when the notification was opened ('active', 'inactive', 'background')
|
|
@@ -269,7 +292,7 @@ function handlePushOpened(userInfo, applicationState, authorizationStatus) {
|
|
|
269
292
|
* Call this from your notification handler when a notification is received while the app is active.
|
|
270
293
|
*
|
|
271
294
|
* On iOS, this allows the Attentive SDK to track the notification event.
|
|
272
|
-
* On Android,
|
|
295
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
273
296
|
*
|
|
274
297
|
* @param userInfo - The notification payload from the push notification
|
|
275
298
|
*
|
|
@@ -297,7 +320,7 @@ function handleForegroundNotification(userInfo) {
|
|
|
297
320
|
* ```
|
|
298
321
|
*
|
|
299
322
|
* On iOS, this properly tracks foreground push notifications.
|
|
300
|
-
* On Android,
|
|
323
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
301
324
|
*
|
|
302
325
|
* @param userInfo - The notification payload from the push notification
|
|
303
326
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -330,7 +353,7 @@ function handleForegroundPush(userInfo, authorizationStatus) {
|
|
|
330
353
|
* ```
|
|
331
354
|
*
|
|
332
355
|
* On iOS, this properly tracks push notification opens.
|
|
333
|
-
* On Android,
|
|
356
|
+
* On Android, registers the FCM token when provided by the host app.
|
|
334
357
|
*
|
|
335
358
|
* @param userInfo - The notification payload from the push notification
|
|
336
359
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -350,7 +373,36 @@ function handleForegroundPush(userInfo, authorizationStatus) {
|
|
|
350
373
|
function handlePushOpen(userInfo, authorizationStatus) {
|
|
351
374
|
AttentiveReactNativeSdk.handlePushOpen(userInfo, authorizationStatus);
|
|
352
375
|
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Returns the push notification payload that launched the app from a killed state
|
|
379
|
+
* (i.e. the user tapped an FCM notification while the app was not running) and clears
|
|
380
|
+
* it so it is only delivered once.
|
|
381
|
+
*
|
|
382
|
+
* **Android only.** On iOS, use `PushNotificationIOS.getInitialNotification()` to
|
|
383
|
+
* achieve the same result — the Attentive iOS SDK event is tracked natively in
|
|
384
|
+
* `AppDelegate.userNotificationCenter(_:didReceive:withCompletionHandler:)` via
|
|
385
|
+
* `AttentiveSDKManager.shared`.
|
|
386
|
+
*
|
|
387
|
+
* Call this once at app startup (after `initialize()`) to detect and handle the
|
|
388
|
+
* killed-state push-open scenario:
|
|
389
|
+
*
|
|
390
|
+
* ```typescript
|
|
391
|
+
* const initial = await getInitialPushNotification()
|
|
392
|
+
* if (initial) {
|
|
393
|
+
* const authStatus = await getPushAuthorizationStatus()
|
|
394
|
+
* handlePushOpen(initial as PushNotificationUserInfo, authStatus)
|
|
395
|
+
* }
|
|
396
|
+
* ```
|
|
397
|
+
*
|
|
398
|
+
* @returns A promise that resolves to the notification data object, or `null` if the
|
|
399
|
+
* app was not launched via a push notification tap.
|
|
400
|
+
*/
|
|
401
|
+
async function getInitialPushNotification() {
|
|
402
|
+
const result = await AttentiveReactNativeSdk.getInitialPushNotification();
|
|
403
|
+
return result;
|
|
404
|
+
}
|
|
353
405
|
export { initialize, triggerCreative, destroyCreative, updateDomain, identify, clearUser, recordAddToCartEvent, recordProductViewEvent, recordPurchaseEvent, recordCustomEvent, invokeAttentiveDebugHelper, exportDebugLogs,
|
|
354
|
-
// Push Notification Methods
|
|
355
|
-
registerForPushNotifications, registerDeviceToken, registerDeviceTokenWithCallback, handleRegularOpen, handlePushOpened, handleForegroundNotification, handleForegroundPush, handlePushOpen };
|
|
406
|
+
// Push Notification Methods
|
|
407
|
+
registerForPushNotifications, getPushAuthorizationStatus, registerDeviceToken, registerDeviceTokenWithCallback, handleRegularOpen, handlePushOpened, handleForegroundNotification, handleForegroundPush, handlePushOpen, getInitialPushNotification };
|
|
356
408
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","NativeAttentiveReactNativeSdkModule","LINKING_ERROR","select","ios","default","AttentiveReactNativeSdk","Proxy","get","Error","initialize","configuration","attentiveDomain","mode","skipFatigueOnCreatives","enableDebugger","triggerCreative","creativeId","destroyCreative","updateDomain","domain","identify","identifiers","phone","email","klaviyoId","shopifyId","clientUserId","customIdentifiers","clearUser","recordAddToCartEvent","attrs","items","deeplink","recordProductViewEvent","recordPurchaseEvent","orderId","cartId","cartCoupon","recordCustomEvent","type","properties","invokeAttentiveDebugHelper","exportDebugLogs","registerForPushNotifications","registerDeviceToken","token","authorizationStatus","registerDeviceTokenWithCallback","callback","handleRegularOpen","console","log","handlePushOpened","userInfo","applicationState","handleForegroundNotification","handleForegroundPush","handlePushOpen"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAcvC,OAAOC,mCAAmC,MAEnC,iCAAiC;AAExC,MAAMC,aAAa,
|
|
1
|
+
{"version":3,"names":["Platform","NativeAttentiveReactNativeSdkModule","LINKING_ERROR","select","ios","default","AttentiveReactNativeSdk","Proxy","get","Error","initialize","configuration","attentiveDomain","mode","skipFatigueOnCreatives","enableDebugger","triggerCreative","creativeId","destroyCreative","updateDomain","domain","identify","identifiers","phone","email","klaviyoId","shopifyId","clientUserId","customIdentifiers","clearUser","recordAddToCartEvent","attrs","items","deeplink","recordProductViewEvent","recordPurchaseEvent","orderId","cartId","cartCoupon","recordCustomEvent","type","properties","invokeAttentiveDebugHelper","exportDebugLogs","registerForPushNotifications","getPushAuthorizationStatus","registerDeviceToken","token","authorizationStatus","registerDeviceTokenWithCallback","callback","handleRegularOpen","console","log","handlePushOpened","userInfo","applicationState","handleForegroundNotification","handleForegroundPush","handlePushOpen","getInitialPushNotification","result"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAcvC,OAAOC,mCAAmC,MAEnC,iCAAiC;AAExC,MAAMC,aAAa,GACjB,qFAAqF,GACrFF,QAAQ,CAACG,MAAM,CAAC;EACdC,GAAG,EAAE,gCAAgC;EACrCC,OAAO,EAAE;AACX,CAAC,CAAC,GACF,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,uBAAuB,GAC3BL,mCAAmC,GAC/BA,mCAAmC,GACnC,IAAIM,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CACG;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASQ,UAAUA,CAACC,aAAwC,EAAE;EAC5DL,uBAAuB,CAACI,UAAU,CAChCC,aAAa,CAACC,eAAe,EAC7BD,aAAa,CAACE,IAAI,EAClBF,aAAa,CAACG,sBAAsB,IAAI,KAAK,EAC7CH,aAAa,CAACI,cAAc,IAAI,KAClC,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAACC,UAAmB,EAAE;EAC5CX,uBAAuB,CAACU,eAAe,CAACC,UAAU,CAAC;AACrD;;AAEA;AACA;AACA;AACA,SAASC,eAAeA,CAAA,EAAG;EACzBZ,uBAAuB,CAACY,eAAe,CAAC,CAAC;AAC3C;;AAEA;AACA;AACA;AACA;AACA,SAASC,YAAYA,CAACC,MAAc,EAAE;EACpCd,uBAAuB,CAACa,YAAY,CAACC,MAAM,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACA,SAASC,QAAQA,CAACC,WAA4B,EAAE;EAC9ChB,uBAAuB,CAACe,QAAQ,CAC9BC,WAAW,CAACC,KAAK,EACjBD,WAAW,CAACE,KAAK,EACjBF,WAAW,CAACG,SAAS,EACrBH,WAAW,CAACI,SAAS,EACrBJ,WAAW,CAACK,YAAY,EACxBL,WAAW,CAACM,iBACd,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASC,SAASA,CAAA,EAAG;EACnBvB,uBAAuB,CAACuB,SAAS,CAAC,CAAC;AACrC;;AAEA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAACC,KAAgB,EAAE;EAC9CzB,uBAAuB,CAACwB,oBAAoB,CAACC,KAAK,CAACC,KAAK,EAAED,KAAK,CAACE,QAAQ,CAAC;AAC3E;;AAEA;AACA;AACA;AACA;AACA,SAASC,sBAAsBA,CAACH,KAAkB,EAAE;EAClDzB,uBAAuB,CAAC4B,sBAAsB,CAACH,KAAK,CAACC,KAAK,EAAED,KAAK,CAACE,QAAQ,CAAC;AAC7E;;AAEA;AACA;AACA;AACA;AACA,SAASE,mBAAmBA,CAACJ,KAAe,EAAE;EAC5CzB,uBAAuB,CAAC6B,mBAAmB,CACzCJ,KAAK,CAACC,KAAK,EACXD,KAAK,CAACK,OAAO,EACbL,KAAK,CAACM,MAAM,EACZN,KAAK,CAACO,UACR,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAACR,KAAkB,EAAE;EAC7CzB,uBAAuB,CAACiC,iBAAiB,CAACR,KAAK,CAACS,IAAI,EAAET,KAAK,CAACU,UAAU,CAAC;AACzE;;AAEA;AACA;AACA;AACA,SAASC,0BAA0BA,CAAA,EAAG;EACpCpC,uBAAuB,CAACoC,0BAA0B,CAAC,CAAC;AACtD;;AAEA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAAA,EAAoB;EAC1C,OAAOrC,uBAAuB,CAACqC,eAAe,CAAC,CAAC;AAClD;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,4BAA4BA,CAAA,EAAS;EAC5CtC,uBAAuB,CAACsC,4BAA4B,CAAC,CAAC;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,0BAA0BA,CAAA,EAAqC;EACtE,OAAOvC,uBAAuB,CAACuC,0BAA0B,CAAC,CAAC;AAC7D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,mBAAmBA,CAC1BC,KAAa,EACbC,mBAA4C,EACtC;EACN1C,uBAAuB,CAACwC,mBAAmB,CAACC,KAAK,EAAEC,mBAAmB,CAAC;AACzE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,+BAA+BA,CACtCF,KAAa,EACbC,mBAA4C,EAC5CE,QAKS,EACH;EACN5C,uBAAuB,CAAC2C,+BAA+B,CACrDF,KAAK,EACLC,mBAAmB,EACnBE,QACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAACH,mBAA4C,EAAQ;EAC7EI,OAAO,CAACC,GAAG,CAAC,6DAA6D,CAAC;EAC1ED,OAAO,CAACC,GAAG,CAAC,4BAA4BL,mBAAmB,EAAE,CAAC;EAC9DI,OAAO,CAACC,GAAG,CACT,mEACF,CAAC;EAED/C,uBAAuB,CAAC6C,iBAAiB,CAACH,mBAAmB,CAAC;EAE9DI,OAAO,CAACC,GAAG,CAAC,mDAAmD,CAAC;AAClE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CACvBC,QAAkC,EAClCC,gBAAkC,EAClCR,mBAA4C,EACtC;EACN1C,uBAAuB,CAACgD,gBAAgB,CACtCC,QAAQ,EACRC,gBAAgB,EAChBR,mBACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASS,4BAA4BA,CACnCF,QAAkC,EAC5B;EACNjD,uBAAuB,CAACmD,4BAA4B,CAACF,QAAkB,CAAC;AAC1E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,oBAAoBA,CAC3BH,QAAkC,EAClCP,mBAA4C,EACtC;EACN1C,uBAAuB,CAACoD,oBAAoB,CAC1CH,QAAQ,EACRP,mBACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASW,cAAcA,CACrBJ,QAAkC,EAClCP,mBAA4C,EACtC;EACN1C,uBAAuB,CAACqD,cAAc,CACpCJ,QAAQ,EACRP,mBACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeY,0BAA0BA,CAAA,EAA2C;EAClF,MAAMC,MAAM,GAAG,MAAMvD,uBAAuB,CAACsD,0BAA0B,CAAC,CAAC;EACzE,OAAOC,MAAM;AACf;AAEA,SACEnD,UAAU,EACVM,eAAe,EACfE,eAAe,EACfC,YAAY,EACZE,QAAQ,EACRQ,SAAS,EACTC,oBAAoB,EACpBI,sBAAsB,EACtBC,mBAAmB,EACnBI,iBAAiB,EACjBG,0BAA0B,EAC1BC,eAAe;AACf;AACAC,4BAA4B,EAC5BC,0BAA0B,EAC1BC,mBAAmB,EACnBG,+BAA+B,EAC/BE,iBAAiB,EACjBG,gBAAgB,EAChBG,4BAA4B,EAC5BC,oBAAoB,EACpBC,cAAc,EACdC,0BAA0B","ignoreList":[]}
|