ilabs-flir 2.4.0 → 2.4.2

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.
@@ -145,7 +145,9 @@ class FlirModule(private val reactContext: ReactApplicationContext) : ReactConte
145
145
  palettes.forEach { result.pushString(it) }
146
146
  promise?.resolve(result)
147
147
  } catch (e: Throwable) {
148
- promise?.reject("ERR_FLIR_PALETTES", e)
148
+ try {
149
+ promise?.reject("ERR_FLIR_PALETTES", e)
150
+ } catch (ignored: Exception) {}
149
151
  }
150
152
  }
151
153
 
@@ -163,7 +165,9 @@ class FlirModule(private val reactContext: ReactApplicationContext) : ReactConte
163
165
  }
164
166
  promise?.resolve(result)
165
167
  } catch (e: Throwable) {
166
- promise?.reject("ERR_FLIR_PALETTE_ICONS", e)
168
+ try {
169
+ promise?.reject("ERR_FLIR_PALETTE_ICONS", e)
170
+ } catch (ignored: Exception) {}
167
171
  }
168
172
  }
169
173
 
@@ -345,17 +349,26 @@ class FlirModule(private val reactContext: ReactApplicationContext) : ReactConte
345
349
 
346
350
  @ReactMethod
347
351
  fun captureRadiometricSnapshot(path: String, promise: Promise?) {
352
+ val snapshotPromise = promise
353
+ var settled = java.util.concurrent.atomic.AtomicBoolean(false)
354
+
348
355
  try {
349
356
  FlirManager.captureRadiometricSnapshot(path, object : FlirSdkManager.SnapshotCallback {
350
357
  override fun onSnapshotSaved(savedPath: String) {
351
- promise?.resolve(savedPath)
358
+ if (settled.compareAndSet(false, true)) {
359
+ snapshotPromise?.resolve(savedPath)
360
+ }
352
361
  }
353
362
  override fun onSnapshotError(message: String) {
354
- promise?.reject("ERR_RADIOMETRIC_SAVE", message)
363
+ if (settled.compareAndSet(false, true)) {
364
+ snapshotPromise?.reject("ERR_RADIOMETRIC_SAVE", message)
365
+ }
355
366
  }
356
367
  })
357
368
  } catch (e: Exception) {
358
- promise?.reject("ERR_RADIOMETRIC_TRIGGER", e.message)
369
+ if (settled.compareAndSet(false, true)) {
370
+ promise?.reject("ERR_RADIOMETRIC_TRIGGER", e.message)
371
+ }
359
372
  }
360
373
  }
361
374
 
@@ -409,7 +422,9 @@ class FlirModule(private val reactContext: ReactApplicationContext) : ReactConte
409
422
  result.putBoolean("initialized", false)
410
423
  result.putString("error", e.message ?: "Unknown error")
411
424
  result.putString("errorType", e.javaClass.simpleName)
412
- promise?.resolve(result)
425
+ try {
426
+ promise?.resolve(result)
427
+ } catch (ignored: Exception) {}
413
428
  }
414
429
  }
415
430
 
@@ -83,7 +83,7 @@ public class FlirSdkManager {
83
83
  void onSnapshotError(String message);
84
84
  }
85
85
 
86
- private SnapshotCallback snapshotCallback;
86
+ private volatile SnapshotCallback snapshotCallback;
87
87
 
88
88
  private FlirSdkManager(Context context) {
89
89
  this.context = context.getApplicationContext();
@@ -470,11 +470,13 @@ public class FlirSdkManager {
470
470
  Log.i(TAG, "[SNAPSHOT] ✅ Success: Radiometric snapshot saved");
471
471
  if (snapshotCallback != null) {
472
472
  snapshotCallback.onSnapshotSaved(snapshotPath);
473
+ snapshotCallback = null;
473
474
  }
474
475
  } catch (java.io.IOException e) {
475
476
  Log.e(TAG, "Failed to save radiometric snapshot", e);
476
477
  if (snapshotCallback != null) {
477
478
  snapshotCallback.onSnapshotError(e.getMessage());
479
+ snapshotCallback = null;
478
480
  }
479
481
  }
480
482
  }
@@ -757,7 +757,7 @@ extension FlirManager: FLIRStreamDelegate {
757
757
  // 2. Save Radiometric Snapshot if requested
758
758
  if let path = snapshotPath {
759
759
  do {
760
- try thermalImage.save(to: path)
760
+ try thermalImage.save(as: path)
761
761
  NSLog("[FlirManager] Radiometric snapshot saved to: \(path)")
762
762
  } catch {
763
763
  NSLog("[FlirManager] Failed to save radiometric snapshot: \(error)")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ilabs-flir",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
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",