ilabs-flir 2.1.402 → 2.2.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.
@@ -509,6 +509,8 @@ import ThermalSDK
509
509
  connectedDeviceName = identity.deviceId()
510
510
  _isConnected = true
511
511
 
512
+ FlirLogger.log(.connection, "[Flir-BRIDGE-CONNECTION] Connected to: \(identity.deviceId())")
513
+
512
514
  // Get camera info if available
513
515
  if let remoteControl = cam.getRemoteControl(),
514
516
  let cameraInfo = try? remoteControl.getCameraInformation() {
@@ -542,8 +544,10 @@ import ThermalSDK
542
544
  communicationType: self.communicationInterfaceName(identity.communicationInterface()),
543
545
  isEmulator: identity.communicationInterface() == .emulator
544
546
  )
545
- self.delegate?.onDeviceConnected(deviceInfo)
547
+
548
+ // Emit connected state (matches Android emitDeviceState("connected"))
546
549
  self.emitStateChange("connected")
550
+ self.delegate?.onDeviceConnected(deviceInfo)
547
551
  }
548
552
 
549
553
  } catch {
@@ -97,7 +97,9 @@ static BOOL flir_isPreferSdkRotation(void) {
97
97
  @property(nonatomic, copy) RCTPromiseRejectBlock connectReject;
98
98
  @end
99
99
 
100
- @implementation FlirModule
100
+ @implementation FlirModule {
101
+ NSInteger _listenerCount;
102
+ }
101
103
 
102
104
  RCT_EXPORT_MODULE(FlirModule);
103
105
 
@@ -107,6 +109,7 @@ RCT_EXPORT_MODULE(FlirModule);
107
109
 
108
110
  - (instancetype)init {
109
111
  if (self = [super init]) {
112
+ _listenerCount = 0;
110
113
  // Wire up delegate
111
114
  id manager = flir_manager_shared();
112
115
  if (manager) {
@@ -127,6 +130,9 @@ RCT_EXPORT_MODULE(FlirModule);
127
130
  }
128
131
 
129
132
  RCT_EXPORT_METHOD(addListener : (NSString *)eventName) {
133
+ _listenerCount++;
134
+ NSLog(@"[FlirModule] addListener: %@ (count: %ld)", eventName, (long)_listenerCount);
135
+
130
136
  // When FlirDevicesFound listener is added, immediately emit current device list
131
137
  // This handles the case where discovery happened before React Native mounted
132
138
  if ([eventName isEqualToString:@"FlirDevicesFound"]) {
@@ -145,7 +151,9 @@ RCT_EXPORT_METHOD(addListener : (NSString *)eventName) {
145
151
  }
146
152
 
147
153
  RCT_EXPORT_METHOD(removeListeners : (NSInteger)count) {
148
- // Required for RCTEventEmitter
154
+ _listenerCount -= count;
155
+ if (_listenerCount < 0) _listenerCount = 0;
156
+ NSLog(@"[FlirModule] removeListeners: %ld (remaining: %ld)", (long)count, (long)_listenerCount);
149
157
  }
150
158
 
151
159
  + (void)emitBatteryUpdateWithLevel:(NSInteger)level charging:(BOOL)charging {
@@ -424,9 +432,15 @@ RCT_EXPORT_METHOD(isPreferSdkRotation : (RCTPromiseResolveBlock)
424
432
  }
425
433
  }
426
434
 
427
- NSLog(@"[FlirModule] onDevicesFound - emitting FlirDevicesFound with %lu devices", (unsigned long)arr.count);
428
- [self sendEventWithName:@"FlirDevicesFound"
429
- body:@{@"devices" : arr, @"count" : @(arr.count)}];
435
+ NSLog(@"[FlirModule] onDevicesFound - %lu devices, listenerCount: %ld", (unsigned long)arr.count, (long)_listenerCount);
436
+
437
+ if (_listenerCount > 0) {
438
+ NSLog(@"[FlirModule] emitting FlirDevicesFound event");
439
+ [self sendEventWithName:@"FlirDevicesFound"
440
+ body:@{@"devices" : arr, @"count" : @(arr.count)}];
441
+ } else {
442
+ NSLog(@"[FlirModule] ⚠️ No listeners registered yet - devices will be re-emitted when listener is added");
443
+ }
430
444
  }
431
445
 
432
446
  - (void)onDeviceConnected:(id)device {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ilabs-flir",
3
- "version": "2.1.402",
3
+ "version": "2.2.001",
4
4
  "description": "FLIR Thermal SDK for React Native - iOS & Android (bundled at compile time via postinstall)",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",