react-native-userleap 4.1.0 → 4.1.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/android/build.gradle
CHANGED
|
@@ -85,6 +85,6 @@ dependencies {
|
|
|
85
85
|
if (findProject(':userleap-android-sdk') != null) {
|
|
86
86
|
implementation project(':userleap-android-sdk')
|
|
87
87
|
} else {
|
|
88
|
-
implementation ("com.userleap:userleap-android-sdk:2.27.
|
|
88
|
+
implementation ("com.userleap:userleap-android-sdk:2.27.2") // update this version on android updates
|
|
89
89
|
}
|
|
90
90
|
}
|
package/ios/UserLeapBindings.h
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#import <UserLeapKit/UserLeapKit.h>
|
|
2
2
|
#import <UserLeapKit/UserLeapKit-Swift.h>
|
|
3
3
|
|
|
4
|
+
#import <React/RCTInvalidating.h>
|
|
4
5
|
#import <RNUserLeapBindingsSpec/RNUserLeapBindingsSpec.h>
|
|
5
6
|
|
|
6
|
-
@interface UserLeapBindings : NativeUserLeapBindingsSpecBase <NativeUserLeapBindingsSpec, _SGRNExtractor>
|
|
7
|
+
@interface UserLeapBindings : NativeUserLeapBindingsSpecBase <NativeUserLeapBindingsSpec, _SGRNExtractor, RCTInvalidating>
|
|
7
8
|
@end
|
package/ios/UserLeapBindings.mm
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#import "UserLeapBindings.h"
|
|
2
2
|
#import <React/RCTUtils.h>
|
|
3
|
+
#import <ReactCommon/CallInvoker.h>
|
|
4
|
+
#import <os/lock.h>
|
|
3
5
|
// Legacy Paper includes gated on RCT_REMOVE_LEGACY_ARCH: these classes are removed on RN 0.85+.
|
|
4
6
|
#ifndef RCT_REMOVE_LEGACY_ARCH
|
|
5
7
|
#import <React/RCTTextView.h>
|
|
@@ -16,7 +18,9 @@
|
|
|
16
18
|
#import <RNUserLeapBindingsSpec/RNUserLeapBindingsSpec.h>
|
|
17
19
|
|
|
18
20
|
@implementation UserLeapBindings {
|
|
21
|
+
os_unfair_lock _lock; // guards _alive and _jsInvoker (shared_ptr copy isn't atomic); never held across an emit
|
|
19
22
|
BOOL _alive;
|
|
23
|
+
std::shared_ptr<facebook::react::CallInvoker> _jsInvoker;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
+ (BOOL)requiresMainQueueSetup
|
|
@@ -27,16 +31,25 @@
|
|
|
27
31
|
- (instancetype)init
|
|
28
32
|
{
|
|
29
33
|
if (self = [super init]) {
|
|
34
|
+
_lock = OS_UNFAIR_LOCK_INIT;
|
|
30
35
|
_alive = YES;
|
|
31
|
-
// emitOnSprigEvent is a safe no-op when JS has no listener, so eager subscription is fine.
|
|
32
36
|
[self subscribeToSdkEvents];
|
|
33
37
|
}
|
|
34
38
|
return self;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
// Deterministic teardown hook: stop delivering before the runtime is destroyed.
|
|
42
|
+
- (void)invalidate
|
|
38
43
|
{
|
|
44
|
+
os_unfair_lock_lock(&_lock);
|
|
39
45
|
_alive = NO;
|
|
46
|
+
os_unfair_lock_unlock(&_lock);
|
|
47
|
+
[self unsubscribeFromSdkEvents];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
- (void)dealloc
|
|
51
|
+
{
|
|
52
|
+
// Backstop; -invalidate is the real teardown path.
|
|
40
53
|
[self unsubscribeFromSdkEvents];
|
|
41
54
|
}
|
|
42
55
|
|
|
@@ -433,11 +446,26 @@ surveyStateCallback:(RCTResponseSenderBlock)surveyStateCallback
|
|
|
433
446
|
|
|
434
447
|
[sdk registerEventListenerFor:eventType listener:^(NSDictionary<NSString *,id> * _Nonnull data) {
|
|
435
448
|
__strong __typeof(weakSelf) strongSelf = weakSelf;
|
|
436
|
-
|
|
437
|
-
|
|
449
|
+
if (!strongSelf) return;
|
|
450
|
+
|
|
451
|
+
// Snapshot liveness + invoker under the lock; bail if torn down.
|
|
452
|
+
std::shared_ptr<facebook::react::CallInvoker> invoker;
|
|
453
|
+
os_unfair_lock_lock(&strongSelf->_lock);
|
|
454
|
+
if (strongSelf->_alive) { invoker = strongSelf->_jsInvoker; }
|
|
455
|
+
os_unfair_lock_unlock(&strongSelf->_lock);
|
|
456
|
+
if (!invoker) return;
|
|
457
|
+
|
|
438
458
|
NSDictionary *payload = [strongSelf normalizePayloadForEvent:name data:data];
|
|
439
459
|
NSString *json = [strongSelf jsonStringFromDictionary:payload];
|
|
440
|
-
|
|
460
|
+
|
|
461
|
+
// Emit on the JS thread so it can't race runtime teardown; dropped if already invalidated.
|
|
462
|
+
invoker->invokeAsync([strongSelf, name, json]() {
|
|
463
|
+
os_unfair_lock_lock(&strongSelf->_lock);
|
|
464
|
+
BOOL alive = strongSelf->_alive;
|
|
465
|
+
os_unfair_lock_unlock(&strongSelf->_lock);
|
|
466
|
+
if (!alive) return;
|
|
467
|
+
[strongSelf emitOnSprigEvent:@{@"name": name, @"json": json}];
|
|
468
|
+
});
|
|
441
469
|
}];
|
|
442
470
|
}
|
|
443
471
|
}
|
|
@@ -453,6 +481,10 @@ surveyStateCallback:(RCTResponseSenderBlock)surveyStateCallback
|
|
|
453
481
|
|
|
454
482
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
455
483
|
{
|
|
484
|
+
// Capture the JS CallInvoker so event callbacks can marshal emits onto the JS thread.
|
|
485
|
+
os_unfair_lock_lock(&_lock);
|
|
486
|
+
_jsInvoker = params.jsInvoker;
|
|
487
|
+
os_unfair_lock_unlock(&_lock);
|
|
456
488
|
return std::make_shared<facebook::react::NativeUserLeapBindingsSpecJSI>(params);
|
|
457
489
|
}
|
|
458
490
|
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
|
|
|
18
18
|
s.source_files = "ios/**/*.{h,c,m,mm,swift}"
|
|
19
19
|
s.requires_arc = true
|
|
20
20
|
|
|
21
|
-
s.dependency "UserLeapKit", "4.33.
|
|
21
|
+
s.dependency "UserLeapKit", "4.33.1"
|
|
22
22
|
|
|
23
23
|
# New Architecture: wires up the React-Codegen dependency and header search
|
|
24
24
|
# paths so the generated RNUserLeapBindingsSpec (Obj-C++) resolves.
|