react-native-smallcase-gateway 6.0.0-rc.7 → 6.0.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.
- package/CHANGELOG.md +103 -0
- package/android/build.gradle +2 -2
- package/android/gradle.properties +18 -4
- package/android/src/main/java/com/reactnativesmallcasegateway/SCGatewayBridgeEmitter.kt +112 -0
- package/android/src/main/java/com/reactnativesmallcasegateway/SCLoansBridgeEmitter.kt +117 -0
- package/android/src/main/java/com/reactnativesmallcasegateway/SmallcaseGatewayModule.kt +9 -10
- package/android/src/main/java/com/reactnativesmallcasegateway/SmallcaseGatewayPackage.kt +5 -1
- package/ios/SCGatewayBridgeEmitter.m +20 -0
- package/ios/SCGatewayEmitter.swift +117 -0
- package/ios/SCLoansBridgeEmitter.m +20 -0
- package/ios/SCLoansEmitter.swift +115 -0
- package/ios/SmallcaseGateway-Bridging-Header.h +7 -0
- package/ios/SmallcaseGateway.m +20 -4
- package/lib/commonjs/SCGatewayEventEmitter.js +107 -0
- package/lib/commonjs/SCGatewayEventEmitter.js.map +1 -0
- package/lib/commonjs/SCLoansEventEmitter.js +103 -0
- package/lib/commonjs/SCLoansEventEmitter.js.map +1 -0
- package/lib/commonjs/SmallcaseGateway.js +1 -6
- package/lib/commonjs/SmallcaseGateway.js.map +1 -1
- package/lib/commonjs/index.js +27 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/SCGatewayEventEmitter.js +102 -0
- package/lib/module/SCGatewayEventEmitter.js.map +1 -0
- package/lib/module/SCLoansEventEmitter.js +98 -0
- package/lib/module/SCLoansEventEmitter.js.map +1 -0
- package/lib/module/SmallcaseGateway.js +1 -6
- package/lib/module/SmallcaseGateway.js.map +1 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/package.json +9 -3
- package/react-native-smallcase-gateway.podspec +2 -2
- package/src/SCGatewayEventEmitter.js +121 -0
- package/src/SCLoansEventEmitter.js +116 -0
- package/src/SmallcaseGateway.js +2 -13
- package/src/index.js +3 -1
- package/types/index.d.ts +45 -2
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import React
|
|
3
|
+
import Loans
|
|
4
|
+
|
|
5
|
+
@objc(SCLoansEmitter)
|
|
6
|
+
class SCLoansEmitter: RCTEventEmitter {
|
|
7
|
+
|
|
8
|
+
private static var shared: SCLoansEmitter?
|
|
9
|
+
|
|
10
|
+
private var notificationObserver: NSObjectProtocol?
|
|
11
|
+
|
|
12
|
+
private var isListening: Bool {
|
|
13
|
+
return notificationObserver != nil
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override init() {
|
|
17
|
+
super.init()
|
|
18
|
+
SCLoansEmitter.shared = self
|
|
19
|
+
print("SCLoansEmitter: Initialized.")
|
|
20
|
+
startListening()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
deinit {
|
|
24
|
+
print("SCLoansEmitter: Deinitializing.")
|
|
25
|
+
stopListening()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override func supportedEvents() -> [String]! {
|
|
29
|
+
return [ScLoan.scLoansNotificationName.rawValue]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
override func startObserving() {
|
|
33
|
+
super.startObserving()
|
|
34
|
+
print("SCLoansEmitter: startObserving called.")
|
|
35
|
+
startListening()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
override func stopObserving() {
|
|
39
|
+
super.stopObserving()
|
|
40
|
+
print("SCLoansEmitter: stopObserving called.")
|
|
41
|
+
stopListening()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
45
|
+
return true
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@objc func startListening(
|
|
49
|
+
_ resolve: RCTPromiseResolveBlock? = nil,
|
|
50
|
+
rejecter reject: RCTPromiseRejectBlock? = nil
|
|
51
|
+
) {
|
|
52
|
+
print("SCLoansEmitter: Starting to listen for notifications.")
|
|
53
|
+
|
|
54
|
+
guard !isListening else {
|
|
55
|
+
print("SCLoansEmitter: Already listening.")
|
|
56
|
+
resolve?("Already listening")
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
DispatchQueue.main.async { [weak self] in
|
|
61
|
+
guard let self = self else {
|
|
62
|
+
reject?("START_LISTENING_FAILED", "Self deallocated", nil)
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
self.stopListening()
|
|
67
|
+
|
|
68
|
+
self.notificationObserver = NotificationCenter.default.addObserver(
|
|
69
|
+
forName: ScLoan.scLoansNotificationName,
|
|
70
|
+
object: nil,
|
|
71
|
+
queue: .main
|
|
72
|
+
) { [weak self] notification in
|
|
73
|
+
self?.processScLoansNotification(notification)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
resolve?("Started listening to SCLoans events")
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@objc func stopListening(
|
|
81
|
+
_ resolve: RCTPromiseResolveBlock? = nil,
|
|
82
|
+
rejecter reject: RCTPromiseRejectBlock? = nil
|
|
83
|
+
) {
|
|
84
|
+
print("SCLoansEmitter: Stopping listening for notifications.")
|
|
85
|
+
|
|
86
|
+
guard isListening, let observer = notificationObserver else {
|
|
87
|
+
print("SCLoansEmitter: Not listening or no observer, no action needed.")
|
|
88
|
+
resolve?("Not listening")
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
NotificationCenter.default.removeObserver(observer)
|
|
93
|
+
notificationObserver = nil
|
|
94
|
+
|
|
95
|
+
print("SCLoansEmitter: Stopped listening.")
|
|
96
|
+
resolve?("Stopped listening to SCLoans events")
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private func processScLoansNotification(_ notification: Notification) {
|
|
100
|
+
let userInfo = notification.userInfo ?? [:]
|
|
101
|
+
|
|
102
|
+
print("SCLoansEmitter: Received notification with userInfo keys: \(userInfo.keys)")
|
|
103
|
+
|
|
104
|
+
guard let jsonString = userInfo[ScLoanNotification.strigifiedPayloadKey] as? String else {
|
|
105
|
+
print(
|
|
106
|
+
"SCLoansEmitter: No stringified payload found with key '\(ScLoanNotification.strigifiedPayloadKey)'"
|
|
107
|
+
)
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
print("SCLoansEmitter: Received JSON string: \(jsonString).")
|
|
112
|
+
sendEvent(withName: ScLoan.scLoansNotificationName.rawValue, body: jsonString)
|
|
113
|
+
print("SCLoansEmitter: Emitted event '\(ScLoan.scLoansNotificationName)' with JSON string.")
|
|
114
|
+
}
|
|
115
|
+
}
|
package/ios/SmallcaseGateway.m
CHANGED
|
@@ -30,8 +30,8 @@ RCT_REMAP_METHOD(getSdkVersion,
|
|
|
30
30
|
RCT_REMAP_METHOD(setConfigEnvironment,
|
|
31
31
|
envName:(NSString *)envName
|
|
32
32
|
gateway:(NSString *)gateway
|
|
33
|
-
isLeprechaunActive: (BOOL
|
|
34
|
-
isAmoEnabled: (BOOL
|
|
33
|
+
isLeprechaunActive: (BOOL)isLeprechaunActive
|
|
34
|
+
isAmoEnabled: (BOOL)isAmoEnabled
|
|
35
35
|
preProvidedBrokers: (NSArray *)preProvidedBrokers
|
|
36
36
|
setConfigEnvironmentWithResolver:(RCTPromiseResolveBlock)resolve
|
|
37
37
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
@@ -383,9 +383,25 @@ RCT_REMAP_METHOD(launchSmallplugWithBranding,
|
|
|
383
383
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
384
384
|
{
|
|
385
385
|
dispatch_async(dispatch_get_main_queue(), ^(void) {
|
|
386
|
+
|
|
387
|
+
NSString* (^processColorValue)(NSString*, NSString*) = ^NSString*(NSString *color, NSString *defaultColor) {
|
|
388
|
+
if (color == nil || color.length < 6) {
|
|
389
|
+
return defaultColor;
|
|
390
|
+
}
|
|
391
|
+
if ([color hasPrefix:@"#"]) {
|
|
392
|
+
return [color substringFromIndex:1];
|
|
393
|
+
}
|
|
394
|
+
return color;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
NSString *processedHeaderColor = processColorValue(headerColor, @"2F363F");
|
|
398
|
+
NSString *processedBackIconColor = processColorValue(backIconColor, @"ffffff");
|
|
399
|
+
|
|
400
|
+
double finalHeaderOpacity = headerOpacity != nil ? [headerOpacity doubleValue] : 1.0;
|
|
401
|
+
double finalBackIconOpacity = backIconOpacity != nil ? [backIconOpacity doubleValue] : 1.0;
|
|
386
402
|
|
|
387
403
|
SmallplugData *smallplugData = [[SmallplugData alloc] init:targetEndpoint :params];
|
|
388
|
-
SmallplugUiConfig *smallplugUiConfig = [[SmallplugUiConfig alloc] initWithSmallplugHeaderColor:
|
|
404
|
+
SmallplugUiConfig *smallplugUiConfig = [[SmallplugUiConfig alloc] initWithSmallplugHeaderColor:processedHeaderColor headerColorOpacity:@(finalHeaderOpacity) backIconColor:processedBackIconColor backIconColorOpacity:@(finalBackIconOpacity)];
|
|
389
405
|
|
|
390
406
|
[SCGateway.shared launchSmallPlugWithPresentingController:[[[UIApplication sharedApplication] keyWindow] rootViewController] smallplugData:smallplugData smallplugUiConfig:smallplugUiConfig completion:^(id smallplugResponse, NSError * error) {
|
|
391
407
|
|
|
@@ -480,7 +496,7 @@ RCT_EXPORT_METHOD(triggerLeadGen: (NSDictionary *)userParams utmParams:(NSDictio
|
|
|
480
496
|
RCT_REMAP_METHOD(triggerLeadGenWithLoginCta,
|
|
481
497
|
userParams: (NSDictionary *)userParams
|
|
482
498
|
utmParams:(NSDictionary *)utmParams
|
|
483
|
-
showLoginCta:(BOOL
|
|
499
|
+
showLoginCta:(BOOL)showLoginCta
|
|
484
500
|
leadGenGenWithResolver: (RCTPromiseResolveBlock)resolve
|
|
485
501
|
rejecter:(RCTPromiseRejectBlock)reject
|
|
486
502
|
) {
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.SCGatewayEventTypes = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object} GatewayEvent
|
|
10
|
+
* @property {string} type - Event type
|
|
11
|
+
* @property {any} data - Event payload data
|
|
12
|
+
* @property {number} timestamp - Event timestamp
|
|
13
|
+
*
|
|
14
|
+
* @typedef {Object} GatewayEventSubscription
|
|
15
|
+
* @property {() => void} remove - Method to unsubscribe from gateway events
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const nativeModule = _reactNative.NativeModules.SCGatewayBridgeEmitter;
|
|
20
|
+
const SCGatewayEventTypes = exports.SCGatewayEventTypes = {
|
|
21
|
+
ANALYTICS_EVENT: 'scgateway_analytics_event',
|
|
22
|
+
SUPER_PROPERTIES_UPDATED: 'scgateway_super_properties_updated',
|
|
23
|
+
USER_RESET: 'scgateway_user_reset',
|
|
24
|
+
USER_IDENTIFY: 'scgateway_user_identify'
|
|
25
|
+
};
|
|
26
|
+
const SCGatewayNotificationEvent = 'scg_notification';
|
|
27
|
+
class SCGatewayEvents {
|
|
28
|
+
constructor() {
|
|
29
|
+
this.eventEmitter = null;
|
|
30
|
+
this.subscriptions = [];
|
|
31
|
+
this.initialize();
|
|
32
|
+
}
|
|
33
|
+
get isInitialized() {
|
|
34
|
+
return this.eventEmitter !== null;
|
|
35
|
+
}
|
|
36
|
+
initialize() {
|
|
37
|
+
if (nativeModule) {
|
|
38
|
+
this.eventEmitter = new _reactNative.NativeEventEmitter(nativeModule);
|
|
39
|
+
} else {
|
|
40
|
+
console.warn('[SCGatewayEvents] Native module not available');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ===== GATEWAY EVENT METHODS =====
|
|
45
|
+
/**
|
|
46
|
+
* Subscribe to Gateway Events
|
|
47
|
+
* @param {(event: GatewayEvent) => void} callback - Callback function to handle gateway events
|
|
48
|
+
* @returns {GatewayEventSubscription} subscription - Subscription object with remove() method
|
|
49
|
+
*/
|
|
50
|
+
subscribeToGatewayEvents(callback) {
|
|
51
|
+
if (!this.isInitialized) {
|
|
52
|
+
console.warn('[SCGatewayEvents] Event emitter not initialized');
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (typeof callback !== 'function') {
|
|
56
|
+
console.warn('[SCGatewayEvents] Invalid callback provided for subscription');
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const subscription = this.eventEmitter.addListener(SCGatewayNotificationEvent, jsonString => {
|
|
60
|
+
if (!jsonString) {
|
|
61
|
+
console.warn('[SCGatewayEvents] Received null/undefined event data');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
let eventData;
|
|
65
|
+
try {
|
|
66
|
+
eventData = JSON.parse(jsonString);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.warn('[SCGatewayEvents] Failed to parse event JSON:', error, 'Raw data:', jsonString);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (!eventData.type) {
|
|
72
|
+
console.warn('[SCGatewayEvents] Dropping event - missing event type:', eventData);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const normalizedEvent = {
|
|
76
|
+
type: eventData.type,
|
|
77
|
+
data: eventData.data,
|
|
78
|
+
timestamp: eventData.timestamp || Date.now()
|
|
79
|
+
};
|
|
80
|
+
callback(normalizedEvent);
|
|
81
|
+
});
|
|
82
|
+
this.subscriptions.push(subscription);
|
|
83
|
+
return subscription;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Unsubscribe from Gateway Events
|
|
88
|
+
* @param {GatewayEventSubscription} subscription - Subscription returned from subscribeToGatewayEvents
|
|
89
|
+
*/
|
|
90
|
+
unsubscribeFromGatewayEvents(subscription) {
|
|
91
|
+
if (subscription && typeof subscription.remove === 'function') {
|
|
92
|
+
subscription.remove();
|
|
93
|
+
this.subscriptions = this.subscriptions.filter(sub => sub !== subscription);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
cleanup() {
|
|
97
|
+
this.subscriptions.forEach(subscription => {
|
|
98
|
+
if (subscription && typeof subscription.remove === 'function') {
|
|
99
|
+
subscription.remove();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
this.subscriptions = [];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const scGatewayEventManager = new SCGatewayEvents();
|
|
106
|
+
var _default = exports.default = scGatewayEventManager;
|
|
107
|
+
//# sourceMappingURL=SCGatewayEventEmitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","nativeModule","NativeModules","SCGatewayBridgeEmitter","SCGatewayEventTypes","exports","ANALYTICS_EVENT","SUPER_PROPERTIES_UPDATED","USER_RESET","USER_IDENTIFY","SCGatewayNotificationEvent","SCGatewayEvents","constructor","eventEmitter","subscriptions","initialize","isInitialized","NativeEventEmitter","console","warn","subscribeToGatewayEvents","callback","subscription","addListener","jsonString","eventData","JSON","parse","error","type","normalizedEvent","data","timestamp","Date","now","push","unsubscribeFromGatewayEvents","remove","filter","sub","cleanup","forEach","scGatewayEventManager","_default","default"],"sources":["SCGatewayEventEmitter.js"],"sourcesContent":["import {\n NativeEventEmitter,\n NativeModules,\n Platform\n} from 'react-native';\n\n/**\n * @typedef {Object} GatewayEvent\n * @property {string} type - Event type\n * @property {any} data - Event payload data\n * @property {number} timestamp - Event timestamp\n *\n * @typedef {Object} GatewayEventSubscription\n * @property {() => void} remove - Method to unsubscribe from gateway events\n *\n */\n\nconst nativeModule = NativeModules.SCGatewayBridgeEmitter;\n\nexport const SCGatewayEventTypes = {\n ANALYTICS_EVENT: 'scgateway_analytics_event',\n SUPER_PROPERTIES_UPDATED: 'scgateway_super_properties_updated',\n USER_RESET: 'scgateway_user_reset',\n USER_IDENTIFY: 'scgateway_user_identify',\n};\n\nconst SCGatewayNotificationEvent = 'scg_notification';\n\nclass SCGatewayEvents {\n constructor() {\n this.eventEmitter = null;\n this.subscriptions = [];\n this.initialize();\n }\n\n get isInitialized() {\n return this.eventEmitter !== null;\n }\n\n initialize() {\n if (nativeModule) {\n this.eventEmitter = new NativeEventEmitter(nativeModule);\n } else {\n console.warn('[SCGatewayEvents] Native module not available');\n }\n }\n\n // ===== GATEWAY EVENT METHODS =====\n /**\n * Subscribe to Gateway Events\n * @param {(event: GatewayEvent) => void} callback - Callback function to handle gateway events\n * @returns {GatewayEventSubscription} subscription - Subscription object with remove() method\n */\n subscribeToGatewayEvents(callback) {\n if (!this.isInitialized) {\n console.warn('[SCGatewayEvents] Event emitter not initialized');\n return null;\n }\n\n if (typeof callback !== 'function') {\n console.warn('[SCGatewayEvents] Invalid callback provided for subscription');\n return null;\n }\n\n const subscription = this.eventEmitter.addListener(SCGatewayNotificationEvent, (jsonString) => {\n if (!jsonString) {\n console.warn('[SCGatewayEvents] Received null/undefined event data');\n return;\n }\n\n let eventData;\n try {\n eventData = JSON.parse(jsonString);\n } catch (error) {\n console.warn('[SCGatewayEvents] Failed to parse event JSON:', error, 'Raw data:', jsonString);\n return;\n }\n\n if (!eventData.type) {\n console.warn('[SCGatewayEvents] Dropping event - missing event type:', eventData);\n return;\n }\n\n const normalizedEvent = {\n type: eventData.type,\n data: eventData.data,\n timestamp: eventData.timestamp || Date.now()\n };\n\n callback(normalizedEvent);\n });\n\n this.subscriptions.push(subscription);\n\n return subscription;\n }\n\n /**\n * Unsubscribe from Gateway Events\n * @param {GatewayEventSubscription} subscription - Subscription returned from subscribeToGatewayEvents\n */\n unsubscribeFromGatewayEvents(subscription) {\n if (subscription && typeof subscription.remove === 'function') {\n subscription.remove();\n this.subscriptions = this.subscriptions.filter(sub => sub !== subscription);\n }\n }\n\n cleanup() {\n this.subscriptions.forEach(subscription => {\n if (subscription && typeof subscription.remove === 'function') {\n subscription.remove();\n }\n });\n this.subscriptions = [];\n }\n}\n\nconst scGatewayEventManager = new SCGatewayEvents();\n\nexport default scGatewayEventManager;"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,YAAY,GAAGC,0BAAa,CAACC,sBAAsB;AAElD,MAAMC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG;EAC/BE,eAAe,EAAE,2BAA2B;EAC5CC,wBAAwB,EAAE,oCAAoC;EAC9DC,UAAU,EAAE,sBAAsB;EAClCC,aAAa,EAAE;AACnB,CAAC;AAED,MAAMC,0BAA0B,GAAG,kBAAkB;AAErD,MAAMC,eAAe,CAAC;EAClBC,WAAWA,CAAA,EAAG;IACV,IAAI,CAACC,YAAY,GAAG,IAAI;IACxB,IAAI,CAACC,aAAa,GAAG,EAAE;IACvB,IAAI,CAACC,UAAU,CAAC,CAAC;EACrB;EAEA,IAAIC,aAAaA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACH,YAAY,KAAK,IAAI;EACrC;EAEAE,UAAUA,CAAA,EAAG;IACT,IAAId,YAAY,EAAE;MACd,IAAI,CAACY,YAAY,GAAG,IAAII,+BAAkB,CAAChB,YAAY,CAAC;IAC5D,CAAC,MAAM;MACHiB,OAAO,CAACC,IAAI,CAAC,+CAA+C,CAAC;IACjE;EACJ;;EAEA;EACA;AACJ;AACA;AACA;AACA;EACIC,wBAAwBA,CAACC,QAAQ,EAAE;IAC/B,IAAI,CAAC,IAAI,CAACL,aAAa,EAAE;MACrBE,OAAO,CAACC,IAAI,CAAC,iDAAiD,CAAC;MAC/D,OAAO,IAAI;IACf;IAEA,IAAI,OAAOE,QAAQ,KAAK,UAAU,EAAE;MAChCH,OAAO,CAACC,IAAI,CAAC,8DAA8D,CAAC;MAC5E,OAAO,IAAI;IACf;IAEA,MAAMG,YAAY,GAAG,IAAI,CAACT,YAAY,CAACU,WAAW,CAACb,0BAA0B,EAAGc,UAAU,IAAK;MAC3F,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AC;IACF,IAAI,CAACvB,aAAa,GAAG,EAAE;EAC3B;AACJ;AAEA,MAAM4B,qBAAqB,GAAG,IAAI/B,eAAe,CAAC,CAAC;AAAC,IAAAgC,QAAA,GAAAtC,OAAA,CAAAuC,OAAA,GAErCF,qBAAqB","ignoreList":[]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.SCLoansEventTypes = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object} LoansEvent
|
|
10
|
+
* @property {string} type - Event type
|
|
11
|
+
* @property {number} timestamp - Event timestamp
|
|
12
|
+
*
|
|
13
|
+
* @typedef {Object} LoansEventSubscription
|
|
14
|
+
* @property {() => void} remove - Method to unsubscribe from loans events
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const nativeModule = _reactNative.NativeModules.SCLoansBridgeEmitter;
|
|
18
|
+
const SCLoansEventTypes = exports.SCLoansEventTypes = {
|
|
19
|
+
ANALYTICS_EVENT: 'scloans_analytics_event',
|
|
20
|
+
SUPER_PROPERTIES_UPDATED: 'scloans_super_properties_updated'
|
|
21
|
+
};
|
|
22
|
+
const SCLoansNotificationEvent = 'scloans_notification';
|
|
23
|
+
class SCLoansEvents {
|
|
24
|
+
constructor() {
|
|
25
|
+
this.eventEmitter = null;
|
|
26
|
+
this.subscriptions = [];
|
|
27
|
+
this.initialize();
|
|
28
|
+
}
|
|
29
|
+
get isInitialized() {
|
|
30
|
+
return this.eventEmitter !== null;
|
|
31
|
+
}
|
|
32
|
+
initialize() {
|
|
33
|
+
if (nativeModule) {
|
|
34
|
+
this.eventEmitter = new _reactNative.NativeEventEmitter(nativeModule);
|
|
35
|
+
} else {
|
|
36
|
+
console.warn('[SCLoansEvents] Native module not available');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ===== LOANS EVENT METHODS =====
|
|
41
|
+
/**
|
|
42
|
+
* Subscribe to Loans Events
|
|
43
|
+
* @param {(event: LoansEvent) => void} callback - Callback function to handle loans events
|
|
44
|
+
* @returns {LoansEventSubscription} subscription - Subscription object with remove() method
|
|
45
|
+
*/
|
|
46
|
+
subscribeToLoansEvent(callback) {
|
|
47
|
+
if (!this.isInitialized) {
|
|
48
|
+
console.warn('[SCLoansEvents] Event emitter not initialized');
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
if (typeof callback !== 'function') {
|
|
52
|
+
console.warn('[SCLoansEvents] Invalid callback provided for subscription');
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const subscription = this.eventEmitter.addListener(SCLoansNotificationEvent, jsonString => {
|
|
56
|
+
if (!jsonString) {
|
|
57
|
+
console.warn('[SCLoansEvents] Received null/undefined event data');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
let eventData;
|
|
61
|
+
try {
|
|
62
|
+
eventData = JSON.parse(jsonString);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.warn('[SCLoansEvents] Failed to parse event JSON:', error, 'Raw data:', jsonString);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!eventData.type) {
|
|
68
|
+
console.warn('[SCLoansEvents] Dropping event - missing event type:', eventData);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const normalizedEvent = {
|
|
72
|
+
type: eventData.type,
|
|
73
|
+
data: eventData.data,
|
|
74
|
+
timestamp: eventData.timestamp || Date.now()
|
|
75
|
+
};
|
|
76
|
+
callback(normalizedEvent);
|
|
77
|
+
});
|
|
78
|
+
this.subscriptions.push(subscription);
|
|
79
|
+
return subscription;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Unsubscribe from Loans Events
|
|
84
|
+
* @param {LoansEventSubscription} subscription - Subscription returned from subscribeToLoansEvents
|
|
85
|
+
*/
|
|
86
|
+
unsubscribeFromLoansEvent(subscription) {
|
|
87
|
+
if (subscription && typeof subscription.remove === 'function') {
|
|
88
|
+
subscription.remove();
|
|
89
|
+
this.subscriptions = this.subscriptions.filter(sub => sub !== subscription);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
cleanup() {
|
|
93
|
+
this.subscriptions.forEach(subscription => {
|
|
94
|
+
if (subscription && typeof subscription.remove === 'function') {
|
|
95
|
+
subscription.remove();
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
this.subscriptions = [];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const scLoansEventManager = new SCLoansEvents();
|
|
102
|
+
var _default = exports.default = scLoansEventManager;
|
|
103
|
+
//# sourceMappingURL=SCLoansEventEmitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","nativeModule","NativeModules","SCLoansBridgeEmitter","SCLoansEventTypes","exports","ANALYTICS_EVENT","SUPER_PROPERTIES_UPDATED","SCLoansNotificationEvent","SCLoansEvents","constructor","eventEmitter","subscriptions","initialize","isInitialized","NativeEventEmitter","console","warn","subscribeToLoansEvent","callback","subscription","addListener","jsonString","eventData","JSON","parse","error","type","normalizedEvent","data","timestamp","Date","now","push","unsubscribeFromLoansEvent","remove","filter","sub","cleanup","forEach","scLoansEventManager","_default","default"],"sources":["SCLoansEventEmitter.js"],"sourcesContent":["import {\n NativeEventEmitter,\n NativeModules,\n Platform\n} from 'react-native';\n\n/**\n * @typedef {Object} LoansEvent\n * @property {string} type - Event type\n * @property {number} timestamp - Event timestamp\n *\n * @typedef {Object} LoansEventSubscription\n * @property {() => void} remove - Method to unsubscribe from loans events\n */\n\nconst nativeModule = NativeModules.SCLoansBridgeEmitter;\n\nexport const SCLoansEventTypes = {\n ANALYTICS_EVENT: 'scloans_analytics_event',\n SUPER_PROPERTIES_UPDATED: 'scloans_super_properties_updated',\n};\n\nconst SCLoansNotificationEvent = 'scloans_notification';\nclass SCLoansEvents {\n constructor() {\n this.eventEmitter = null;\n this.subscriptions = [];\n this.initialize();\n }\n\n get isInitialized() {\n return this.eventEmitter !== null;\n }\n\n initialize() {\n if (nativeModule) {\n this.eventEmitter = new NativeEventEmitter(nativeModule);\n } else {\n console.warn('[SCLoansEvents] Native module not available');\n }\n }\n\n // ===== LOANS EVENT METHODS =====\n /**\n * Subscribe to Loans Events\n * @param {(event: LoansEvent) => void} callback - Callback function to handle loans events\n * @returns {LoansEventSubscription} subscription - Subscription object with remove() method\n */\n subscribeToLoansEvent(callback) {\n if (!this.isInitialized) {\n console.warn('[SCLoansEvents] Event emitter not initialized');\n return null;\n }\n\n if (typeof callback !== 'function') {\n console.warn('[SCLoansEvents] Invalid callback provided for subscription');\n return null;\n }\n\n const subscription = this.eventEmitter.addListener(SCLoansNotificationEvent, (jsonString) => {\n if (!jsonString) {\n console.warn('[SCLoansEvents] Received null/undefined event data');\n return;\n }\n\n let eventData;\n try {\n eventData = JSON.parse(jsonString);\n } catch (error) {\n console.warn('[SCLoansEvents] Failed to parse event JSON:', error, 'Raw data:', jsonString);\n return;\n }\n\n if (!eventData.type) {\n console.warn('[SCLoansEvents] Dropping event - missing event type:', eventData);\n return;\n }\n\n const normalizedEvent = {\n type: eventData.type,\n data: eventData.data,\n timestamp: eventData.timestamp || Date.now()\n };\n\n callback(normalizedEvent);\n });\n\n this.subscriptions.push(subscription);\n\n return subscription;\n }\n\n /**\n * Unsubscribe from Loans Events\n * @param {LoansEventSubscription} subscription - Subscription returned from subscribeToLoansEvents\n */\n unsubscribeFromLoansEvent(subscription) {\n if (subscription && typeof subscription.remove === 'function') {\n subscription.remove();\n this.subscriptions = this.subscriptions.filter(sub => sub !== subscription);\n }\n }\n\n cleanup() {\n this.subscriptions.forEach(subscription => {\n if (subscription && typeof subscription.remove === 'function') {\n subscription.remove();\n }\n });\n this.subscriptions = [];\n }\n}\n\nconst scLoansEventManager = new SCLoansEvents();\n\nexport default scLoansEvent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AAAC,IAAAgC,QAAA,GAAApC,OAAA,CAAAqC,OAAA,GAEjCF,mBAAmB","ignoreList":[]}
|
|
@@ -133,12 +133,7 @@ const launchSmallplugWithBranding = async (targetEndpoint, params, headerColor,
|
|
|
133
133
|
const safeHeaderOpacity = typeof headerOpacity === 'number' ? headerOpacity : 1;
|
|
134
134
|
const safeBackIconColor = typeof backIconColor === 'string' ? backIconColor : (0, _util.platformSpecificColorHex)('FFFFFF');
|
|
135
135
|
const safeBackIconOpacity = typeof backIconOpacity === 'number' ? backIconOpacity : 1;
|
|
136
|
-
return
|
|
137
|
-
headerColor: safeHeaderColor,
|
|
138
|
-
headerOpacity: safeHeaderOpacity,
|
|
139
|
-
backIconColor: safeBackIconColor,
|
|
140
|
-
backIconOpacity: safeBackIconOpacity
|
|
141
|
-
}) : SmallcaseGatewayNative.launchSmallplugWithBranding(safeEndpoint, safeParams, safeHeaderColor, safeHeaderOpacity, safeBackIconColor, safeBackIconOpacity);
|
|
136
|
+
return SmallcaseGatewayNative.launchSmallplugWithBranding(safeEndpoint, safeParams, safeHeaderColor, safeHeaderOpacity, safeBackIconColor, safeBackIconOpacity);
|
|
142
137
|
};
|
|
143
138
|
|
|
144
139
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_constants","_util","_package","SmallcaseGateway","SmallcaseGatewayNative","NativeModules","defaultBrokerList","setConfigEnvironment","envConfig","safeConfig","safeObject","setHybridSdkVersion","version","brokerList","gatewayName","isLeprechaun","isAmoEnabled","environmentName","safeIsLeprechaun","Boolean","safeIsAmoEnabled","safeBrokerList","Array","isArray","safeGatewayName","safeEnvName","ENV","PROD","init","sdkToken","safeToken","triggerTransaction","transactionId","utmParams","safeUtm","safeId","length","triggerMfTransaction","console","warn","safeTransactionId","launchSmallplug","targetEndpoint","params","safeEndpoint","safeParams","launchSmallplugWithBranding","headerColor","headerOpacity","backIconColor","backIconOpacity","safeHeaderColor","platformSpecificColorHex","safeHeaderOpacity","safeBackIconColor","safeBackIconOpacity","Platform","OS","logoutUser","showOrders","triggerLeadGen","userDetails","triggerLeadGenWithStatus","triggerLeadGenWithLoginCta","showLoginCta","safeShowLoginCta","archiveSmallcase","iscid","safeIscid","getSdkVersion","_default","exports","default"],"sources":["SmallcaseGateway.js"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\nimport { ENV } from './constants';\nimport { safeObject, platformSpecificColorHex } from './util';\nimport { version } from '../package.json';\nconst { SmallcaseGateway: SmallcaseGatewayNative } = NativeModules;\n\n/**\n *\n * @typedef {Object} envConfig\n * @property {string} gatewayName - unique name on consumer\n * @property {boolean} isLeprechaun - leprechaun mode toggle\n * @property {boolean} isAmoEnabled - support AMO (subject to broker support)\n * @property {Array<string>} brokerList - list of broker names\n * @property {'production' | 'staging' | 'development'} environmentName - environment name\n *\n * @typedef {Object} transactionRes\n * @property {string} data - response data\n * @property {boolean} success - success flag\n * @property {Number} [errorCode] - error code\n * @property {string} transaction - transaction name\n *\n * @typedef {Object} userDetails\n * @property {String} name - name of user\n * @property {String} email - email of user\n * @property {String} contact - contact of user\n * @property {String} pinCode - pin-code of user\n *\n * @typedef {Object} SmallplugUiConfig\n * @property {String} headerColor - color of the header background\n * @property {Number} headerOpacity - opacity of the header background\n * @property {String} backIconColor - color of the back icon\n * @property {Number} backIconOpacity - opacity of the back icon\n *\n */\n\nlet defaultBrokerList = [];\n\n/**\n * configure the sdk with\n * @param {envConfig} envConfig\n */\nconst setConfigEnvironment = async (envConfig) => {\n const safeConfig = safeObject(envConfig);\n\n await SmallcaseGatewayNative.setHybridSdkVersion(version);\n\n const {\n brokerList,\n gatewayName,\n isLeprechaun,\n isAmoEnabled,\n environmentName,\n } = safeConfig;\n\n const safeIsLeprechaun = Boolean(isLeprechaun);\n const safeIsAmoEnabled = Boolean(isAmoEnabled);\n const safeBrokerList = Array.isArray(brokerList) ? brokerList : [];\n const safeGatewayName = typeof gatewayName === 'string' ? gatewayName : '';\n const safeEnvName =\n typeof environmentName === 'string' ? environmentName : ENV.PROD;\n\n defaultBrokerList = safeBrokerList;\n\n await SmallcaseGatewayNative.setConfigEnvironment(\n safeEnvName,\n safeGatewayName,\n safeIsLeprechaun,\n safeIsAmoEnabled,\n safeBrokerList\n );\n};\n\n/**\n * initialize sdk with a session\n *\n * note: this must be called after `setConfigEnvironment()`\n * @param {string} sdkToken\n */\nconst init = async (sdkToken) => {\n const safeToken = typeof sdkToken === 'string' ? sdkToken : '';\n return SmallcaseGatewayNative.init(safeToken);\n};\n\n/**\n * triggers a transaction with a transaction id\n *\n * @param {string} transactionId\n * @param {Object} [utmParams]\n * @param {Array<string>} [brokerList]\n * @returns {Promise<transactionRes>}\n */\nconst triggerTransaction = async (transactionId, utmParams, brokerList) => {\n const safeUtm = safeObject(utmParams);\n const safeId = typeof transactionId === 'string' ? transactionId : '';\n\n const safeBrokerList =\n Array.isArray(brokerList) && brokerList.length\n ? brokerList\n : defaultBrokerList;\n\n return SmallcaseGatewayNative.triggerTransaction(\n safeId,\n safeUtm,\n safeBrokerList\n );\n};\n\n/**\n * triggers a transaction with a transaction id\n * @deprecated triggerMfTransaction will be removed soon. Please use triggerTransaction.\n * @param {string} transactionId\n * @returns {Promise<transactionRes>}\n */\nconst triggerMfTransaction = async (transactionId) => {\n console.warn(\n 'Calling deprecated function! triggerMfTransaction will be removed soon. Please use triggerTransaction.'\n );\n const safeTransactionId =\n typeof transactionId === 'string' ? transactionId : '';\n\n return SmallcaseGatewayNative.triggerMfTransaction(safeTransactionId);\n};\n\n/**\n * launches smallcases module\n *\n * @param {string} targetEndpoint\n * @param {string} params\n */\nconst launchSmallplug = async (targetEndpoint, params) => {\n const safeEndpoint = typeof targetEndpoint === 'string' ? targetEndpoint : '';\n const safeParams = typeof params === 'string' ? params : '';\n\n return SmallcaseGatewayNative.launchSmallplug(safeEndpoint, safeParams);\n};\n\n/**\n * launches smallcases module\n *\n * @param {string} targetEndpoint\n * @param {string} params\n * @param {string} headerColor\n * @param {number} headerOpacity\n * @param {string} backIconColor\n * @param {number} backIconOpacity\n */\nconst launchSmallplugWithBranding = async (\n targetEndpoint,\n params,\n headerColor,\n headerOpacity,\n backIconColor,\n backIconOpacity\n) => {\n const safeEndpoint = typeof targetEndpoint === 'string' ? targetEndpoint : '';\n const safeParams = typeof params === 'string' ? params : '';\n const safeHeaderColor =\n typeof headerColor === 'string'\n ? headerColor\n : platformSpecificColorHex('2F363F');\n const safeHeaderOpacity =\n typeof headerOpacity === 'number' ? headerOpacity : 1;\n const safeBackIconColor =\n typeof backIconColor === 'string'\n ? backIconColor\n : platformSpecificColorHex('FFFFFF');\n const safeBackIconOpacity =\n typeof backIconOpacity === 'number' ? backIconOpacity : 1;\n\n return Platform.OS === 'android'\n ? SmallcaseGatewayNative.launchSmallplugWithBranding(\n safeEndpoint,\n safeParams,\n {\n headerColor: safeHeaderColor,\n headerOpacity: safeHeaderOpacity,\n backIconColor: safeBackIconColor,\n backIconOpacity: safeBackIconOpacity,\n }\n )\n : SmallcaseGatewayNative.launchSmallplugWithBranding(\n safeEndpoint,\n safeParams,\n safeHeaderColor,\n safeHeaderOpacity,\n safeBackIconColor,\n safeBackIconOpacity\n );\n};\n\n/**\n * Logs the user out and removes the web session.\n *\n * This promise will be rejected if logout was unsuccessful\n *\n * @returns {Promise}\n */\nconst logoutUser = async () => {\n return SmallcaseGatewayNative.logoutUser();\n};\n\n/**\n * This will display a list of all the orders that a user recently placed.\n * This includes pending, successful, and failed orders.\n * @returns\n */\nconst showOrders = async () => {\n return SmallcaseGatewayNative.showOrders();\n};\n\n/**\n * triggers the lead gen flow\n *\n * @param {userDetails} [userDetails]\n * @param {Object} [utmParams]\n */\nconst triggerLeadGen = (userDetails, utmParams) => {\n const safeParams = safeObject(userDetails);\n const safeUtm = safeObject(utmParams);\n\n return SmallcaseGatewayNative.triggerLeadGen(safeParams, safeUtm);\n};\n\n/**\n * triggers the lead gen flow\n *\n * @param {userDetails} [userDetails]\n * * @returns {Promise}\n */\nconst triggerLeadGenWithStatus = async (userDetails) => {\n const safeParams = safeObject(userDetails);\n\n return SmallcaseGatewayNative.triggerLeadGenWithStatus(safeParams);\n};\n\n/**\n * triggers the lead gen flow with an option of \"login here\" cta\n *\n * @param {userDetails} [userDetails]\n * @param {Object} [utmParams]\n * @param {boolean} [showLoginCta]\n * @returns {Promise}\n */\nconst triggerLeadGenWithLoginCta = async (\n userDetails,\n utmParams,\n showLoginCta\n) => {\n const safeParams = safeObject(userDetails);\n const safeUtm = safeObject(utmParams);\n const safeShowLoginCta = Boolean(showLoginCta);\n\n return SmallcaseGatewayNative.triggerLeadGenWithLoginCta(\n safeParams,\n safeUtm,\n safeShowLoginCta\n );\n};\n\n/**\n * Marks a smallcase as archived\n *\n * @param {String} iscid\n */\nconst archiveSmallcase = async (iscid) => {\n const safeIscid = typeof iscid === 'string' ? iscid : '';\n\n return SmallcaseGatewayNative.archiveSmallcase(safeIscid);\n};\n\n/**\n * Returns the native android/ios and react-native sdk version\n * (internal-tracking)\n * @returns {Promise}\n */\nconst getSdkVersion = async () => {\n return SmallcaseGatewayNative.getSdkVersion(version);\n};\n\nconst SmallcaseGateway = {\n init,\n logoutUser,\n triggerLeadGen,\n triggerLeadGenWithStatus,\n triggerLeadGenWithLoginCta,\n archiveSmallcase,\n triggerTransaction,\n triggerMfTransaction,\n setConfigEnvironment,\n launchSmallplug,\n launchSmallplugWithBranding,\n getSdkVersion,\n showOrders,\n};\n\nexport default SmallcaseGateway;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,MAAM;EAAEI,gBAAgB,EAAEC;AAAuB,CAAC,GAAGC,0BAAa;;AAElE;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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AAC;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEarE,gBAAgB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_constants","_util","_package","SmallcaseGateway","SmallcaseGatewayNative","NativeModules","defaultBrokerList","setConfigEnvironment","envConfig","safeConfig","safeObject","setHybridSdkVersion","version","brokerList","gatewayName","isLeprechaun","isAmoEnabled","environmentName","safeIsLeprechaun","Boolean","safeIsAmoEnabled","safeBrokerList","Array","isArray","safeGatewayName","safeEnvName","ENV","PROD","init","sdkToken","safeToken","triggerTransaction","transactionId","utmParams","safeUtm","safeId","length","triggerMfTransaction","console","warn","safeTransactionId","launchSmallplug","targetEndpoint","params","safeEndpoint","safeParams","launchSmallplugWithBranding","headerColor","headerOpacity","backIconColor","backIconOpacity","safeHeaderColor","platformSpecificColorHex","safeHeaderOpacity","safeBackIconColor","safeBackIconOpacity","logoutUser","showOrders","triggerLeadGen","userDetails","triggerLeadGenWithStatus","triggerLeadGenWithLoginCta","showLoginCta","safeShowLoginCta","archiveSmallcase","iscid","safeIscid","getSdkVersion","_default","exports","default"],"sources":["SmallcaseGateway.js"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\nimport { ENV } from './constants';\nimport { safeObject, platformSpecificColorHex } from './util';\nimport { version } from '../package.json';\nconst { SmallcaseGateway: SmallcaseGatewayNative } = NativeModules;\n\n/**\n *\n * @typedef {Object} envConfig\n * @property {string} gatewayName - unique name on consumer\n * @property {boolean} isLeprechaun - leprechaun mode toggle\n * @property {boolean} isAmoEnabled - support AMO (subject to broker support)\n * @property {Array<string>} brokerList - list of broker names\n * @property {'production' | 'staging' | 'development'} environmentName - environment name\n *\n * @typedef {Object} transactionRes\n * @property {string} data - response data\n * @property {boolean} success - success flag\n * @property {Number} [errorCode] - error code\n * @property {string} transaction - transaction name\n *\n * @typedef {Object} userDetails\n * @property {String} name - name of user\n * @property {String} email - email of user\n * @property {String} contact - contact of user\n * @property {String} pinCode - pin-code of user\n *\n * @typedef {Object} SmallplugUiConfig\n * @property {String} headerColor - color of the header background\n * @property {Number} headerOpacity - opacity of the header background\n * @property {String} backIconColor - color of the back icon\n * @property {Number} backIconOpacity - opacity of the back icon\n *\n */\n\nlet defaultBrokerList = [];\n\n/**\n * configure the sdk with\n * @param {envConfig} envConfig\n */\nconst setConfigEnvironment = async (envConfig) => {\n const safeConfig = safeObject(envConfig);\n\n await SmallcaseGatewayNative.setHybridSdkVersion(version);\n\n const {\n brokerList,\n gatewayName,\n isLeprechaun,\n isAmoEnabled,\n environmentName,\n } = safeConfig;\n\n const safeIsLeprechaun = Boolean(isLeprechaun);\n const safeIsAmoEnabled = Boolean(isAmoEnabled);\n const safeBrokerList = Array.isArray(brokerList) ? brokerList : [];\n const safeGatewayName = typeof gatewayName === 'string' ? gatewayName : '';\n const safeEnvName =\n typeof environmentName === 'string' ? environmentName : ENV.PROD;\n\n defaultBrokerList = safeBrokerList;\n\n await SmallcaseGatewayNative.setConfigEnvironment(\n safeEnvName,\n safeGatewayName,\n safeIsLeprechaun,\n safeIsAmoEnabled,\n safeBrokerList\n );\n};\n\n/**\n * initialize sdk with a session\n *\n * note: this must be called after `setConfigEnvironment()`\n * @param {string} sdkToken\n */\nconst init = async (sdkToken) => {\n const safeToken = typeof sdkToken === 'string' ? sdkToken : '';\n return SmallcaseGatewayNative.init(safeToken);\n};\n\n/**\n * triggers a transaction with a transaction id\n *\n * @param {string} transactionId\n * @param {Object} [utmParams]\n * @param {Array<string>} [brokerList]\n * @returns {Promise<transactionRes>}\n */\nconst triggerTransaction = async (transactionId, utmParams, brokerList) => {\n const safeUtm = safeObject(utmParams);\n const safeId = typeof transactionId === 'string' ? transactionId : '';\n\n const safeBrokerList =\n Array.isArray(brokerList) && brokerList.length\n ? brokerList\n : defaultBrokerList;\n\n return SmallcaseGatewayNative.triggerTransaction(\n safeId,\n safeUtm,\n safeBrokerList\n );\n};\n\n/**\n * triggers a transaction with a transaction id\n * @deprecated triggerMfTransaction will be removed soon. Please use triggerTransaction.\n * @param {string} transactionId\n * @returns {Promise<transactionRes>}\n */\nconst triggerMfTransaction = async (transactionId) => {\n console.warn(\n 'Calling deprecated function! triggerMfTransaction will be removed soon. Please use triggerTransaction.'\n );\n const safeTransactionId =\n typeof transactionId === 'string' ? transactionId : '';\n\n return SmallcaseGatewayNative.triggerMfTransaction(safeTransactionId);\n};\n\n/**\n * launches smallcases module\n *\n * @param {string} targetEndpoint\n * @param {string} params\n */\nconst launchSmallplug = async (targetEndpoint, params) => {\n const safeEndpoint = typeof targetEndpoint === 'string' ? targetEndpoint : '';\n const safeParams = typeof params === 'string' ? params : '';\n\n return SmallcaseGatewayNative.launchSmallplug(safeEndpoint, safeParams);\n};\n\n/**\n * launches smallcases module\n *\n * @param {string} targetEndpoint\n * @param {string} params\n * @param {string} headerColor\n * @param {number} headerOpacity\n * @param {string} backIconColor\n * @param {number} backIconOpacity\n */\nconst launchSmallplugWithBranding = async (\n targetEndpoint,\n params,\n headerColor,\n headerOpacity,\n backIconColor,\n backIconOpacity\n) => {\n const safeEndpoint = typeof targetEndpoint === 'string' ? targetEndpoint : '';\n const safeParams = typeof params === 'string' ? params : '';\n const safeHeaderColor =\n typeof headerColor === 'string'\n ? headerColor\n : platformSpecificColorHex('2F363F');\n const safeHeaderOpacity =\n typeof headerOpacity === 'number' ? headerOpacity : 1;\n const safeBackIconColor =\n typeof backIconColor === 'string'\n ? backIconColor\n : platformSpecificColorHex('FFFFFF');\n const safeBackIconOpacity =\n typeof backIconOpacity === 'number' ? backIconOpacity : 1;\n\nreturn SmallcaseGatewayNative.launchSmallplugWithBranding(\n safeEndpoint,\n safeParams,\n safeHeaderColor,\n safeHeaderOpacity,\n safeBackIconColor,\n safeBackIconOpacity\n );\n};\n\n/**\n * Logs the user out and removes the web session.\n *\n * This promise will be rejected if logout was unsuccessful\n *\n * @returns {Promise}\n */\nconst logoutUser = async () => {\n return SmallcaseGatewayNative.logoutUser();\n};\n\n/**\n * This will display a list of all the orders that a user recently placed.\n * This includes pending, successful, and failed orders.\n * @returns\n */\nconst showOrders = async () => {\n return SmallcaseGatewayNative.showOrders();\n};\n\n/**\n * triggers the lead gen flow\n *\n * @param {userDetails} [userDetails]\n * @param {Object} [utmParams]\n */\nconst triggerLeadGen = (userDetails, utmParams) => {\n const safeParams = safeObject(userDetails);\n const safeUtm = safeObject(utmParams);\n\n return SmallcaseGatewayNative.triggerLeadGen(safeParams, safeUtm);\n};\n\n/**\n * triggers the lead gen flow\n *\n * @param {userDetails} [userDetails]\n * * @returns {Promise}\n */\nconst triggerLeadGenWithStatus = async (userDetails) => {\n const safeParams = safeObject(userDetails);\n\n return SmallcaseGatewayNative.triggerLeadGenWithStatus(safeParams);\n};\n\n/**\n * triggers the lead gen flow with an option of \"login here\" cta\n *\n * @param {userDetails} [userDetails]\n * @param {Object} [utmParams]\n * @param {boolean} [showLoginCta]\n * @returns {Promise}\n */\nconst triggerLeadGenWithLoginCta = async (\n userDetails,\n utmParams,\n showLoginCta\n) => {\n const safeParams = safeObject(userDetails);\n const safeUtm = safeObject(utmParams);\n const safeShowLoginCta = Boolean(showLoginCta);\n\n return SmallcaseGatewayNative.triggerLeadGenWithLoginCta(\n safeParams,\n safeUtm,\n safeShowLoginCta\n );\n};\n\n/**\n * Marks a smallcase as archived\n *\n * @param {String} iscid\n */\nconst archiveSmallcase = async (iscid) => {\n const safeIscid = typeof iscid === 'string' ? iscid : '';\n\n return SmallcaseGatewayNative.archiveSmallcase(safeIscid);\n};\n\n/**\n * Returns the native android/ios and react-native sdk version\n * (internal-tracking)\n * @returns {Promise}\n */\nconst getSdkVersion = async () => {\n return SmallcaseGatewayNative.getSdkVersion(version);\n};\n\nconst SmallcaseGateway = {\n init,\n logoutUser,\n triggerLeadGen,\n triggerLeadGenWithStatus,\n triggerLeadGenWithLoginCta,\n archiveSmallcase,\n triggerTransaction,\n triggerMfTransaction,\n setConfigEnvironment,\n launchSmallplug,\n launchSmallplugWithBranding,\n getSdkVersion,\n showOrders,\n};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;EAC1BG,gBAAgB;EAChBjC,kBAAkB;EAClBM,oBAAoB;EACpB9B,oBAAoB;EACpBkC,eAAe;EACfK,2BAA2B;EAC3BqB,aAAa;EACbV;AACF,CAAC;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEanE,gBAAgB","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "SCGatewayEventManager", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _SCGatewayEventEmitter.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "SCGatewayEventTypes", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _SCGatewayEventEmitter.SCGatewayEventTypes;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "SCLoansEventManager", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _SCLoansEventEmitter.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "SCLoansEventTypes", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _SCLoansEventEmitter.SCLoansEventTypes;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
6
30
|
Object.defineProperty(exports, "ScLoan", {
|
|
7
31
|
enumerable: true,
|
|
8
32
|
get: function () {
|
|
@@ -12,7 +36,10 @@ Object.defineProperty(exports, "ScLoan", {
|
|
|
12
36
|
exports.default = void 0;
|
|
13
37
|
var _SmallcaseGateway = _interopRequireDefault(require("./SmallcaseGateway"));
|
|
14
38
|
var _ScLoan = _interopRequireDefault(require("./ScLoan"));
|
|
39
|
+
var _SCGatewayEventEmitter = _interopRequireWildcard(require("./SCGatewayEventEmitter"));
|
|
40
|
+
var _SCLoansEventEmitter = _interopRequireWildcard(require("./SCLoansEventEmitter"));
|
|
15
41
|
var _constants = require("./constants");
|
|
42
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
43
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
44
|
var _default = exports.default = {
|
|
18
45
|
..._SmallcaseGateway.default,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_SmallcaseGateway","_interopRequireDefault","require","_ScLoan","_constants","e","__esModule","default","_default","exports","SmallcaseGateway","ENV","ERROR_MSG","TRANSACTION_TYPE"],"sources":["index.js"],"sourcesContent":["import SmallcaseGateway from \"./SmallcaseGateway\";\nimport ScLoan from \"./ScLoan\";\nimport { ENV, TRANSACTION_TYPE, ERROR_MSG } from \"./constants\";\n\nexport { ScLoan }\nexport default { ...SmallcaseGateway, ENV, ERROR_MSG, TRANSACTION_TYPE };\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_SmallcaseGateway","_interopRequireDefault","require","_ScLoan","_SCGatewayEventEmitter","_interopRequireWildcard","_SCLoansEventEmitter","_constants","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_default","exports","SmallcaseGateway","ENV","ERROR_MSG","TRANSACTION_TYPE"],"sources":["index.js"],"sourcesContent":["import SmallcaseGateway from \"./SmallcaseGateway\";\nimport ScLoan from \"./ScLoan\";\nimport scGatewayEventManager, { SCGatewayEventTypes } from './SCGatewayEventEmitter';\nimport scLoansEventManager, { SCLoansEventTypes } from './SCLoansEventEmitter';\nimport { ENV, TRANSACTION_TYPE, ERROR_MSG } from \"./constants\";\n\nexport { ScLoan, scGatewayEventManager as SCGatewayEventManager, scLoansEventManager as SCLoansEventManager, SCGatewayEventTypes, SCLoansEventTypes }\nexport default { ...SmallcaseGateway, ENV, ERROR_MSG, TRANSACTION_TYPE };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,sBAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,oBAAA,GAAAD,uBAAA,CAAAH,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AAA+D,SAAAG,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAAA,SAAAR,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAK,UAAA,GAAAL,CAAA,KAAAU,OAAA,EAAAV,CAAA;AAAA,IAAAmB,QAAA,GAAAC,OAAA,CAAAV,OAAA,GAGhD;EAAE,GAAGW,yBAAgB;EAAEC,GAAG,EAAHA,cAAG;EAAEC,SAAS,EAATA,oBAAS;EAAEC,gBAAgB,EAAhBA;AAAiB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {Object} GatewayEvent
|
|
5
|
+
* @property {string} type - Event type
|
|
6
|
+
* @property {any} data - Event payload data
|
|
7
|
+
* @property {number} timestamp - Event timestamp
|
|
8
|
+
*
|
|
9
|
+
* @typedef {Object} GatewayEventSubscription
|
|
10
|
+
* @property {() => void} remove - Method to unsubscribe from gateway events
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const nativeModule = NativeModules.SCGatewayBridgeEmitter;
|
|
15
|
+
export const SCGatewayEventTypes = {
|
|
16
|
+
ANALYTICS_EVENT: 'scgateway_analytics_event',
|
|
17
|
+
SUPER_PROPERTIES_UPDATED: 'scgateway_super_properties_updated',
|
|
18
|
+
USER_RESET: 'scgateway_user_reset',
|
|
19
|
+
USER_IDENTIFY: 'scgateway_user_identify'
|
|
20
|
+
};
|
|
21
|
+
const SCGatewayNotificationEvent = 'scg_notification';
|
|
22
|
+
class SCGatewayEvents {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.eventEmitter = null;
|
|
25
|
+
this.subscriptions = [];
|
|
26
|
+
this.initialize();
|
|
27
|
+
}
|
|
28
|
+
get isInitialized() {
|
|
29
|
+
return this.eventEmitter !== null;
|
|
30
|
+
}
|
|
31
|
+
initialize() {
|
|
32
|
+
if (nativeModule) {
|
|
33
|
+
this.eventEmitter = new NativeEventEmitter(nativeModule);
|
|
34
|
+
} else {
|
|
35
|
+
console.warn('[SCGatewayEvents] Native module not available');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ===== GATEWAY EVENT METHODS =====
|
|
40
|
+
/**
|
|
41
|
+
* Subscribe to Gateway Events
|
|
42
|
+
* @param {(event: GatewayEvent) => void} callback - Callback function to handle gateway events
|
|
43
|
+
* @returns {GatewayEventSubscription} subscription - Subscription object with remove() method
|
|
44
|
+
*/
|
|
45
|
+
subscribeToGatewayEvents(callback) {
|
|
46
|
+
if (!this.isInitialized) {
|
|
47
|
+
console.warn('[SCGatewayEvents] Event emitter not initialized');
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
if (typeof callback !== 'function') {
|
|
51
|
+
console.warn('[SCGatewayEvents] Invalid callback provided for subscription');
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const subscription = this.eventEmitter.addListener(SCGatewayNotificationEvent, jsonString => {
|
|
55
|
+
if (!jsonString) {
|
|
56
|
+
console.warn('[SCGatewayEvents] Received null/undefined event data');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
let eventData;
|
|
60
|
+
try {
|
|
61
|
+
eventData = JSON.parse(jsonString);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.warn('[SCGatewayEvents] Failed to parse event JSON:', error, 'Raw data:', jsonString);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!eventData.type) {
|
|
67
|
+
console.warn('[SCGatewayEvents] Dropping event - missing event type:', eventData);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const normalizedEvent = {
|
|
71
|
+
type: eventData.type,
|
|
72
|
+
data: eventData.data,
|
|
73
|
+
timestamp: eventData.timestamp || Date.now()
|
|
74
|
+
};
|
|
75
|
+
callback(normalizedEvent);
|
|
76
|
+
});
|
|
77
|
+
this.subscriptions.push(subscription);
|
|
78
|
+
return subscription;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Unsubscribe from Gateway Events
|
|
83
|
+
* @param {GatewayEventSubscription} subscription - Subscription returned from subscribeToGatewayEvents
|
|
84
|
+
*/
|
|
85
|
+
unsubscribeFromGatewayEvents(subscription) {
|
|
86
|
+
if (subscription && typeof subscription.remove === 'function') {
|
|
87
|
+
subscription.remove();
|
|
88
|
+
this.subscriptions = this.subscriptions.filter(sub => sub !== subscription);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
cleanup() {
|
|
92
|
+
this.subscriptions.forEach(subscription => {
|
|
93
|
+
if (subscription && typeof subscription.remove === 'function') {
|
|
94
|
+
subscription.remove();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
this.subscriptions = [];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const scGatewayEventManager = new SCGatewayEvents();
|
|
101
|
+
export default scGatewayEventManager;
|
|
102
|
+
//# sourceMappingURL=SCGatewayEventEmitter.js.map
|