react-native-ble-nitro 1.9.3 → 1.10.0

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.
Files changed (113) hide show
  1. package/README.md +23 -0
  2. package/android/src/main/java/com/margelo/nitro/co/zyke/ble/BleNitroBleManager.kt +4 -0
  3. package/ios/BleNitroBleManager.swift +38 -3
  4. package/lib/commonjs/manager.d.ts +8 -0
  5. package/lib/commonjs/manager.d.ts.map +1 -1
  6. package/lib/commonjs/manager.js +11 -0
  7. package/lib/commonjs/manager.js.map +1 -1
  8. package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts +1 -0
  9. package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts.map +1 -1
  10. package/lib/manager.d.ts +8 -0
  11. package/lib/manager.js +10 -0
  12. package/lib/specs/NativeBleNitro.nitro.d.ts +1 -0
  13. package/nitrogen/generated/android/BleNitro+autolinking.cmake +3 -1
  14. package/nitrogen/generated/android/BleNitro+autolinking.gradle +1 -1
  15. package/nitrogen/generated/android/BleNitroOnLoad.cpp +3 -3
  16. package/nitrogen/generated/android/BleNitroOnLoad.hpp +1 -1
  17. package/nitrogen/generated/android/c++/JAndroidScanMode.hpp +5 -6
  18. package/nitrogen/generated/android/c++/JBLEDevice.hpp +8 -4
  19. package/nitrogen/generated/android/c++/JBLEState.hpp +7 -8
  20. package/nitrogen/generated/android/c++/JFunc_void_BLEState.hpp +3 -2
  21. package/nitrogen/generated/android/c++/JFunc_void_bool_double_std__string.hpp +3 -2
  22. package/nitrogen/generated/android/c++/JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string.hpp +3 -3
  23. package/nitrogen/generated/android/c++/JFunc_void_bool_std__string.hpp +3 -2
  24. package/nitrogen/generated/android/c++/JFunc_void_bool_std__string_std__string.hpp +3 -2
  25. package/nitrogen/generated/android/c++/JFunc_void_std__optional_std__variant_nitro__NullType__BLEDevice___std__optional_std__variant_nitro__NullType__std__string__.hpp +91 -0
  26. package/nitrogen/generated/android/c++/JFunc_void_std__string_bool_std__string.hpp +3 -2
  27. package/nitrogen/generated/android/c++/JFunc_void_std__string_std__shared_ptr_ArrayBuffer_.hpp +3 -3
  28. package/nitrogen/generated/android/c++/JFunc_void_std__vector_BLEDevice_.hpp +5 -4
  29. package/nitrogen/generated/android/c++/JHybridNativeBleNitroFactorySpec.cpp +15 -4
  30. package/nitrogen/generated/android/c++/JHybridNativeBleNitroFactorySpec.hpp +3 -1
  31. package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.cpp +31 -9
  32. package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.hpp +5 -2
  33. package/nitrogen/generated/android/c++/JManufacturerData.hpp +8 -4
  34. package/nitrogen/generated/android/c++/JManufacturerDataEntry.hpp +6 -3
  35. package/nitrogen/generated/android/c++/JOperationResult.hpp +6 -2
  36. package/nitrogen/generated/android/c++/JScanFilter.hpp +8 -3
  37. package/nitrogen/generated/android/c++/JVariant_NullType_BLEDevice.cpp +26 -0
  38. package/nitrogen/generated/android/c++/JVariant_NullType_BLEDevice.hpp +79 -0
  39. package/nitrogen/generated/android/c++/JVariant_NullType_String.cpp +26 -0
  40. package/nitrogen/generated/android/c++/JVariant_NullType_String.hpp +70 -0
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/AndroidScanMode.kt +3 -1
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BLEDevice.kt +34 -25
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BLEState.kt +3 -1
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BleNitroOnLoad.kt +1 -1
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_BLEState.kt +1 -2
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_bool_double_std__string.kt +1 -2
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_bool_std__shared_ptr_ArrayBuffer__std__string.kt +2 -3
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_bool_std__string.kt +1 -2
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_bool_std__string_std__string.kt +1 -2
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/{Func_void_std__optional_BLEDevice__std__optional_std__string_.kt → Func_void_std__optional_std__variant_nitro__NullType__BLEDevice___std__optional_std__variant_nitro__NullType__std__string__.kt} +11 -12
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__string_bool_std__string.kt +1 -2
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__string_std__shared_ptr_ArrayBuffer_.kt +2 -3
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__vector_BLEDevice_.kt +1 -2
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridNativeBleNitroFactorySpec.kt +8 -3
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridNativeBleNitroSpec.kt +17 -5
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ManufacturerData.kt +16 -7
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ManufacturerDataEntry.kt +20 -11
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/OperationResult.kt +19 -10
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ScanFilter.kt +25 -16
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Variant_NullType_BLEDevice.kt +59 -0
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Variant_NullType_String.kt +59 -0
  62. package/nitrogen/generated/ios/BleNitro+autolinking.rb +2 -2
  63. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.cpp +6 -5
  64. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.hpp +99 -27
  65. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Umbrella.hpp +3 -3
  66. package/nitrogen/generated/ios/BleNitroAutolinking.mm +1 -1
  67. package/nitrogen/generated/ios/BleNitroAutolinking.swift +13 -15
  68. package/nitrogen/generated/ios/c++/HybridNativeBleNitroFactorySpecSwift.cpp +1 -1
  69. package/nitrogen/generated/ios/c++/HybridNativeBleNitroFactorySpecSwift.hpp +10 -3
  70. package/nitrogen/generated/ios/c++/HybridNativeBleNitroSpecSwift.cpp +1 -1
  71. package/nitrogen/generated/ios/c++/HybridNativeBleNitroSpecSwift.hpp +19 -4
  72. package/nitrogen/generated/ios/swift/AndroidScanMode.swift +1 -1
  73. package/nitrogen/generated/ios/swift/BLEDevice.swift +15 -63
  74. package/nitrogen/generated/ios/swift/BLEState.swift +1 -1
  75. package/nitrogen/generated/ios/swift/Func_void.swift +1 -2
  76. package/nitrogen/generated/ios/swift/Func_void_BLEState.swift +1 -2
  77. package/nitrogen/generated/ios/swift/Func_void_bool_double_std__string.swift +1 -2
  78. package/nitrogen/generated/ios/swift/Func_void_bool_std__shared_ptr_ArrayBuffer__std__string.swift +1 -2
  79. package/nitrogen/generated/ios/swift/Func_void_bool_std__string.swift +1 -2
  80. package/nitrogen/generated/ios/swift/Func_void_bool_std__string_std__string.swift +1 -2
  81. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +1 -2
  82. package/nitrogen/generated/ios/swift/Func_void_std__optional_std__variant_nitro__NullType__BLEDevice___std__optional_std__variant_nitro__NullType__std__string__.swift +84 -0
  83. package/nitrogen/generated/ios/swift/Func_void_std__string_bool_std__string.swift +1 -2
  84. package/nitrogen/generated/ios/swift/Func_void_std__string_std__shared_ptr_ArrayBuffer_.swift +1 -2
  85. package/nitrogen/generated/ios/swift/Func_void_std__vector_BLEDevice_.swift +1 -2
  86. package/nitrogen/generated/ios/swift/HybridNativeBleNitroFactorySpec.swift +10 -4
  87. package/nitrogen/generated/ios/swift/HybridNativeBleNitroFactorySpec_cxx.swift +18 -3
  88. package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec.swift +12 -5
  89. package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec_cxx.swift +59 -12
  90. package/nitrogen/generated/ios/swift/ManufacturerData.swift +3 -15
  91. package/nitrogen/generated/ios/swift/ManufacturerDataEntry.swift +5 -17
  92. package/nitrogen/generated/ios/swift/OperationResult.swift +12 -30
  93. package/nitrogen/generated/ios/swift/ScanFilter.swift +9 -39
  94. package/nitrogen/generated/ios/swift/Variant_NullType_BLEDevice.swift +18 -0
  95. package/nitrogen/generated/ios/swift/Variant_NullType_String.swift +18 -0
  96. package/nitrogen/generated/shared/c++/AndroidScanMode.hpp +1 -1
  97. package/nitrogen/generated/shared/c++/BLEDevice.hpp +31 -23
  98. package/nitrogen/generated/shared/c++/BLEState.hpp +1 -1
  99. package/nitrogen/generated/shared/c++/HybridNativeBleNitroFactorySpec.cpp +1 -1
  100. package/nitrogen/generated/shared/c++/HybridNativeBleNitroFactorySpec.hpp +1 -1
  101. package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.cpp +2 -1
  102. package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.hpp +5 -4
  103. package/nitrogen/generated/shared/c++/ManufacturerData.hpp +13 -5
  104. package/nitrogen/generated/shared/c++/ManufacturerDataEntry.hpp +17 -10
  105. package/nitrogen/generated/shared/c++/OperationResult.hpp +16 -8
  106. package/nitrogen/generated/shared/c++/ScanFilter.hpp +22 -14
  107. package/package.json +10 -10
  108. package/plugin/build/withBleNitro.d.ts +8 -0
  109. package/plugin/build/withBleNitro.js +4 -1
  110. package/src/manager.ts +13 -2
  111. package/src/specs/NativeBleNitro.nitro.ts +1 -0
  112. package/nitrogen/generated/android/c++/JFunc_void_std__optional_BLEDevice__std__optional_std__string_.hpp +0 -86
  113. package/nitrogen/generated/ios/swift/Func_void_std__optional_BLEDevice__std__optional_std__string_.swift +0 -54
@@ -2,7 +2,7 @@
2
2
  /// ManufacturerDataEntry.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2026 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -22,9 +22,13 @@
22
22
  #else
23
23
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
24
  #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
25
31
 
26
- // Forward declaration of `ArrayBuffer` to properly resolve imports.
27
- namespace NitroModules { class ArrayBuffer; }
28
32
 
29
33
  #include <string>
30
34
  #include <NitroModules/ArrayBuffer.hpp>
@@ -34,7 +38,7 @@ namespace margelo::nitro::co::zyke::ble {
34
38
  /**
35
39
  * A struct which can be represented as a JavaScript object (ManufacturerDataEntry).
36
40
  */
37
- struct ManufacturerDataEntry {
41
+ struct ManufacturerDataEntry final {
38
42
  public:
39
43
  std::string id SWIFT_PRIVATE;
40
44
  std::shared_ptr<ArrayBuffer> data SWIFT_PRIVATE;
@@ -42,6 +46,9 @@ namespace margelo::nitro::co::zyke::ble {
42
46
  public:
43
47
  ManufacturerDataEntry() = default;
44
48
  explicit ManufacturerDataEntry(std::string id, std::shared_ptr<ArrayBuffer> data): id(id), data(data) {}
49
+
50
+ public:
51
+ friend bool operator==(const ManufacturerDataEntry& lhs, const ManufacturerDataEntry& rhs) = default;
45
52
  };
46
53
 
47
54
  } // namespace margelo::nitro::co::zyke::ble
@@ -54,14 +61,14 @@ namespace margelo::nitro {
54
61
  static inline margelo::nitro::co::zyke::ble::ManufacturerDataEntry fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
55
62
  jsi::Object obj = arg.asObject(runtime);
56
63
  return margelo::nitro::co::zyke::ble::ManufacturerDataEntry(
57
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "id")),
58
- JSIConverter<std::shared_ptr<ArrayBuffer>>::fromJSI(runtime, obj.getProperty(runtime, "data"))
64
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))),
65
+ JSIConverter<std::shared_ptr<ArrayBuffer>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data")))
59
66
  );
60
67
  }
61
68
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::co::zyke::ble::ManufacturerDataEntry& arg) {
62
69
  jsi::Object obj(runtime);
63
- obj.setProperty(runtime, "id", JSIConverter<std::string>::toJSI(runtime, arg.id));
64
- obj.setProperty(runtime, "data", JSIConverter<std::shared_ptr<ArrayBuffer>>::toJSI(runtime, arg.data));
70
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter<std::string>::toJSI(runtime, arg.id));
71
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "data"), JSIConverter<std::shared_ptr<ArrayBuffer>>::toJSI(runtime, arg.data));
65
72
  return obj;
66
73
  }
67
74
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -72,8 +79,8 @@ namespace margelo::nitro {
72
79
  if (!nitro::isPlainObject(runtime, obj)) {
73
80
  return false;
74
81
  }
75
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "id"))) return false;
76
- if (!JSIConverter<std::shared_ptr<ArrayBuffer>>::canConvert(runtime, obj.getProperty(runtime, "data"))) return false;
82
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id")))) return false;
83
+ if (!JSIConverter<std::shared_ptr<ArrayBuffer>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data")))) return false;
77
84
  return true;
78
85
  }
79
86
  };
@@ -2,7 +2,7 @@
2
2
  /// OperationResult.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2026 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -22,6 +22,11 @@
22
22
  #else
23
23
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
24
  #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
25
30
 
26
31
 
27
32
 
@@ -33,7 +38,7 @@ namespace margelo::nitro::co::zyke::ble {
33
38
  /**
34
39
  * A struct which can be represented as a JavaScript object (OperationResult).
35
40
  */
36
- struct OperationResult {
41
+ struct OperationResult final {
37
42
  public:
38
43
  bool success SWIFT_PRIVATE;
39
44
  std::optional<std::string> error SWIFT_PRIVATE;
@@ -41,6 +46,9 @@ namespace margelo::nitro::co::zyke::ble {
41
46
  public:
42
47
  OperationResult() = default;
43
48
  explicit OperationResult(bool success, std::optional<std::string> error): success(success), error(error) {}
49
+
50
+ public:
51
+ friend bool operator==(const OperationResult& lhs, const OperationResult& rhs) = default;
44
52
  };
45
53
 
46
54
  } // namespace margelo::nitro::co::zyke::ble
@@ -53,14 +61,14 @@ namespace margelo::nitro {
53
61
  static inline margelo::nitro::co::zyke::ble::OperationResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
54
62
  jsi::Object obj = arg.asObject(runtime);
55
63
  return margelo::nitro::co::zyke::ble::OperationResult(
56
- JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "success")),
57
- JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "error"))
64
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "success"))),
65
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "error")))
58
66
  );
59
67
  }
60
68
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::co::zyke::ble::OperationResult& arg) {
61
69
  jsi::Object obj(runtime);
62
- obj.setProperty(runtime, "success", JSIConverter<bool>::toJSI(runtime, arg.success));
63
- obj.setProperty(runtime, "error", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.error));
70
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "success"), JSIConverter<bool>::toJSI(runtime, arg.success));
71
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "error"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.error));
64
72
  return obj;
65
73
  }
66
74
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -71,8 +79,8 @@ namespace margelo::nitro {
71
79
  if (!nitro::isPlainObject(runtime, obj)) {
72
80
  return false;
73
81
  }
74
- if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "success"))) return false;
75
- if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "error"))) return false;
82
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "success")))) return false;
83
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "error")))) return false;
76
84
  return true;
77
85
  }
78
86
  };
@@ -2,7 +2,7 @@
2
2
  /// ScanFilter.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2026 Marc Rousavy @ Margelo
5
+ /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -22,6 +22,11 @@
22
22
  #else
23
23
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
24
  #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
25
30
 
26
31
  // Forward declaration of `AndroidScanMode` to properly resolve imports.
27
32
  namespace margelo::nitro::co::zyke::ble { enum class AndroidScanMode; }
@@ -35,7 +40,7 @@ namespace margelo::nitro::co::zyke::ble {
35
40
  /**
36
41
  * A struct which can be represented as a JavaScript object (ScanFilter).
37
42
  */
38
- struct ScanFilter {
43
+ struct ScanFilter final {
39
44
  public:
40
45
  std::vector<std::string> serviceUUIDs SWIFT_PRIVATE;
41
46
  double rssiThreshold SWIFT_PRIVATE;
@@ -45,6 +50,9 @@ namespace margelo::nitro::co::zyke::ble {
45
50
  public:
46
51
  ScanFilter() = default;
47
52
  explicit ScanFilter(std::vector<std::string> serviceUUIDs, double rssiThreshold, bool allowDuplicates, AndroidScanMode androidScanMode): serviceUUIDs(serviceUUIDs), rssiThreshold(rssiThreshold), allowDuplicates(allowDuplicates), androidScanMode(androidScanMode) {}
53
+
54
+ public:
55
+ friend bool operator==(const ScanFilter& lhs, const ScanFilter& rhs) = default;
48
56
  };
49
57
 
50
58
  } // namespace margelo::nitro::co::zyke::ble
@@ -57,18 +65,18 @@ namespace margelo::nitro {
57
65
  static inline margelo::nitro::co::zyke::ble::ScanFilter fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
58
66
  jsi::Object obj = arg.asObject(runtime);
59
67
  return margelo::nitro::co::zyke::ble::ScanFilter(
60
- JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "serviceUUIDs")),
61
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "rssiThreshold")),
62
- JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "allowDuplicates")),
63
- JSIConverter<margelo::nitro::co::zyke::ble::AndroidScanMode>::fromJSI(runtime, obj.getProperty(runtime, "androidScanMode"))
68
+ JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs"))),
69
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssiThreshold"))),
70
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowDuplicates"))),
71
+ JSIConverter<margelo::nitro::co::zyke::ble::AndroidScanMode>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "androidScanMode")))
64
72
  );
65
73
  }
66
74
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::co::zyke::ble::ScanFilter& arg) {
67
75
  jsi::Object obj(runtime);
68
- obj.setProperty(runtime, "serviceUUIDs", JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.serviceUUIDs));
69
- obj.setProperty(runtime, "rssiThreshold", JSIConverter<double>::toJSI(runtime, arg.rssiThreshold));
70
- obj.setProperty(runtime, "allowDuplicates", JSIConverter<bool>::toJSI(runtime, arg.allowDuplicates));
71
- obj.setProperty(runtime, "androidScanMode", JSIConverter<margelo::nitro::co::zyke::ble::AndroidScanMode>::toJSI(runtime, arg.androidScanMode));
76
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.serviceUUIDs));
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "rssiThreshold"), JSIConverter<double>::toJSI(runtime, arg.rssiThreshold));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "allowDuplicates"), JSIConverter<bool>::toJSI(runtime, arg.allowDuplicates));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "androidScanMode"), JSIConverter<margelo::nitro::co::zyke::ble::AndroidScanMode>::toJSI(runtime, arg.androidScanMode));
72
80
  return obj;
73
81
  }
74
82
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -79,10 +87,10 @@ namespace margelo::nitro {
79
87
  if (!nitro::isPlainObject(runtime, obj)) {
80
88
  return false;
81
89
  }
82
- if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, "serviceUUIDs"))) return false;
83
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "rssiThreshold"))) return false;
84
- if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "allowDuplicates"))) return false;
85
- if (!JSIConverter<margelo::nitro::co::zyke::ble::AndroidScanMode>::canConvert(runtime, obj.getProperty(runtime, "androidScanMode"))) return false;
90
+ if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs")))) return false;
91
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssiThreshold")))) return false;
92
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowDuplicates")))) return false;
93
+ if (!JSIConverter<margelo::nitro::co::zyke::ble::AndroidScanMode>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "androidScanMode")))) return false;
86
94
  return true;
87
95
  }
88
96
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ble-nitro",
3
- "version": "1.9.3",
3
+ "version": "1.10.0",
4
4
  "description": "High-performance React Native BLE library built on Nitro Modules",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -84,20 +84,20 @@
84
84
  "react-native-nitro-modules": "*"
85
85
  },
86
86
  "devDependencies": {
87
- "@expo/config-plugins": "^54.0.2",
87
+ "@expo/config-plugins": "^54.0.4",
88
88
  "@types/jest": "^29.5.0",
89
- "@types/node": "^20.19.21",
89
+ "@types/node": "^20.19.30",
90
90
  "@types/react": "^19.2.2",
91
91
  "@typescript-eslint/eslint-plugin": "^6.21.0",
92
92
  "@typescript-eslint/parser": "^6.21.0",
93
- "eslint": "^8.0.0",
94
- "expo-module-scripts": "^5.0.7",
93
+ "eslint": "^8.57.1",
94
+ "expo-module-scripts": "^5.0.8",
95
95
  "jest": "^29.0.0",
96
- "nitrogen": "^0.30.0",
97
- "react-native": "^0.81.4",
98
- "react-native-nitro-modules": "^0.30.0",
99
- "rimraf": "^6.0.1",
100
- "ts-jest": "^29.4.5",
96
+ "nitrogen": "^0.33.9",
97
+ "react-native": "^0.83.2",
98
+ "react-native-nitro-modules": "^0.33.9",
99
+ "rimraf": "^6.1.3",
100
+ "ts-jest": "^29.4.6",
101
101
  "typescript": "^5.9.3"
102
102
  },
103
103
  "files": [
@@ -28,6 +28,14 @@ export interface BleNitroPluginProps {
28
28
  * @default "Allow $(PRODUCT_NAME) to advertise bluetooth devices"
29
29
  */
30
30
  androidAdvertisingEnabled?: boolean;
31
+ /**
32
+ * iOS only: Enables lazy-initialisation for CBCentralManager until first BLE API call.
33
+ * Prevents the Bluetooth permission dialog from appearing at app launch.
34
+ * Note: When used with a restoreStateIdentifier, state restoration will be
35
+ * delayed until the first BLE API call.
36
+ * @default false
37
+ */
38
+ iOSLazyInit?: boolean;
31
39
  }
32
40
  export declare const withBleNitroAndroid: ConfigPlugin<BleNitroPluginProps>;
33
41
  export declare const withBleNitroIOS: ConfigPlugin<BleNitroPluginProps>;
@@ -64,12 +64,15 @@ const withBleNitroAndroid = (config, props = {}) => {
64
64
  };
65
65
  exports.withBleNitroAndroid = withBleNitroAndroid;
66
66
  const withBleNitroIOS = (config, props = {}) => {
67
- const { modes, bluetoothAlwaysPermission = 'Allow $(PRODUCT_NAME) to connect to bluetooth devices' } = props;
67
+ const { modes, bluetoothAlwaysPermission = 'Allow $(PRODUCT_NAME) to connect to bluetooth devices', iOSLazyInit, } = props;
68
68
  return (0, config_plugins_1.withInfoPlist)(config, (config) => {
69
69
  // Add NSBluetoothAlwaysUsageDescription
70
70
  if (bluetoothAlwaysPermission !== false) {
71
71
  config.modResults.NSBluetoothAlwaysUsageDescription = bluetoothAlwaysPermission;
72
72
  }
73
+ if (iOSLazyInit) {
74
+ config.modResults.BLENitroLazyInit = true;
75
+ }
73
76
  // Add background modes if specified
74
77
  if (modes && modes.length > 0) {
75
78
  const backgroundModes = modes.map(mode => `bluetooth-${mode}`);
package/src/manager.ts CHANGED
@@ -155,7 +155,17 @@ export class BleNitroManager {
155
155
  }
156
156
 
157
157
  /**
158
- *
158
+ * Explicitly initializes BLE on iOS.
159
+ * Call this to trigger the Bluetooth permission dialog at a specific moment
160
+ * when using lazy iOS initialization.
161
+ * No-op on Android.
162
+ */
163
+ public iosLazyInit(): void {
164
+ this.Instance.iosLazyInit();
165
+ }
166
+
167
+ /**
168
+ *
159
169
  * Registers callback and returns restored peripheral state in it. Not working from 1.7.x upwards for singleton implementation!
160
170
  * @deprecated This method is deprecated and will be removed in 2.x, use onRestoredState option in BleNitroManageroptions instead!
161
171
  */
@@ -310,7 +320,7 @@ export class BleNitroManager {
310
320
  * @param scanTimeout Optional timeout for the scan in milliseconds (default: 5000ms)
311
321
  * @returns Promise resolving deviceId when connected
312
322
  */
313
- public findAndConnect(deviceId: string, options?: { scanTimeout?: number, autoConnectAndroid?: boolean, onDisconnect?: DisconnectEventCallback }): Promise<string> {
323
+ public findAndConnect(deviceId: string, options?: { scanTimeout?: number, autoConnectAndroid?: boolean, onDisconnect?: DisconnectEventCallback, onFound?: (device: BLEDevice) => void }): Promise<string> {
314
324
  const isConnected = this.isConnected(deviceId);
315
325
  if (isConnected) {
316
326
  return Promise.resolve(deviceId);
@@ -327,6 +337,7 @@ export class BleNitroManager {
327
337
  if (device.id === deviceId) {
328
338
  this.stopScan();
329
339
  clearTimeout(timeoutScan);
340
+ options?.onFound?.(device);
330
341
  this.connect(deviceId, options?.onDisconnect, options?.autoConnectAndroid).then(async (connectedDeviceId) => {
331
342
  resolve(connectedDeviceId);
332
343
  }).catch((error) => {
@@ -73,6 +73,7 @@ export interface NativeBleNitro extends HybridObject<{ ios: 'swift'; android: 'k
73
73
  // ios only
74
74
  restoreStateIdentifier?: string;
75
75
  setRestoreStateCallback(callback: RestoreCallback): void;
76
+ iosLazyInit(): void;
76
77
 
77
78
  // Scanning operations
78
79
  startScan(filter: ScanFilter, callback: ScanCallback): void;
@@ -1,86 +0,0 @@
1
- ///
2
- /// JFunc_void_std__optional_BLEDevice__std__optional_std__string_.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2026 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #include <fbjni/fbjni.h>
11
- #include <functional>
12
-
13
- #include "BLEDevice.hpp"
14
- #include <optional>
15
- #include <string>
16
- #include <functional>
17
- #include "JBLEDevice.hpp"
18
- #include "ManufacturerData.hpp"
19
- #include "JManufacturerData.hpp"
20
- #include "ManufacturerDataEntry.hpp"
21
- #include <vector>
22
- #include "JManufacturerDataEntry.hpp"
23
- #include <NitroModules/ArrayBuffer.hpp>
24
- #include <NitroModules/JArrayBuffer.hpp>
25
- #include <NitroModules/JUnit.hpp>
26
-
27
- namespace margelo::nitro::co::zyke::ble {
28
-
29
- using namespace facebook;
30
-
31
- /**
32
- * Represents the Java/Kotlin callback `(device: BLEDevice?, error: String?) -> Unit`.
33
- * This can be passed around between C++ and Java/Kotlin.
34
- */
35
- struct JFunc_void_std__optional_BLEDevice__std__optional_std__string_: public jni::JavaClass<JFunc_void_std__optional_BLEDevice__std__optional_std__string_> {
36
- public:
37
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/co/zyke/ble/Func_void_std__optional_BLEDevice__std__optional_std__string_;";
38
-
39
- public:
40
- /**
41
- * Invokes the function this `JFunc_void_std__optional_BLEDevice__std__optional_std__string_` instance holds through JNI.
42
- */
43
- void invoke(const std::optional<BLEDevice>& device, const std::optional<std::string>& error) const {
44
- static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JBLEDevice> /* device */, jni::alias_ref<jni::JString> /* error */)>("invoke");
45
- method(self(), device.has_value() ? JBLEDevice::fromCpp(device.value()) : nullptr, error.has_value() ? jni::make_jstring(error.value()) : nullptr);
46
- }
47
- };
48
-
49
- /**
50
- * An implementation of Func_void_std__optional_BLEDevice__std__optional_std__string_ that is backed by a C++ implementation (using `std::function<...>`)
51
- */
52
- struct JFunc_void_std__optional_BLEDevice__std__optional_std__string__cxx final: public jni::HybridClass<JFunc_void_std__optional_BLEDevice__std__optional_std__string__cxx, JFunc_void_std__optional_BLEDevice__std__optional_std__string_> {
53
- public:
54
- static jni::local_ref<JFunc_void_std__optional_BLEDevice__std__optional_std__string_::javaobject> fromCpp(const std::function<void(const std::optional<BLEDevice>& /* device */, const std::optional<std::string>& /* error */)>& func) {
55
- return JFunc_void_std__optional_BLEDevice__std__optional_std__string__cxx::newObjectCxxArgs(func);
56
- }
57
-
58
- public:
59
- /**
60
- * Invokes the C++ `std::function<...>` this `JFunc_void_std__optional_BLEDevice__std__optional_std__string__cxx` instance holds.
61
- */
62
- void invoke_cxx(jni::alias_ref<JBLEDevice> device, jni::alias_ref<jni::JString> error) {
63
- _func(device != nullptr ? std::make_optional(device->toCpp()) : std::nullopt, error != nullptr ? std::make_optional(error->toStdString()) : std::nullopt);
64
- }
65
-
66
- public:
67
- [[nodiscard]]
68
- inline const std::function<void(const std::optional<BLEDevice>& /* device */, const std::optional<std::string>& /* error */)>& getFunction() const {
69
- return _func;
70
- }
71
-
72
- public:
73
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/co/zyke/ble/Func_void_std__optional_BLEDevice__std__optional_std__string__cxx;";
74
- static void registerNatives() {
75
- registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__optional_BLEDevice__std__optional_std__string__cxx::invoke_cxx)});
76
- }
77
-
78
- private:
79
- explicit JFunc_void_std__optional_BLEDevice__std__optional_std__string__cxx(const std::function<void(const std::optional<BLEDevice>& /* device */, const std::optional<std::string>& /* error */)>& func): _func(func) { }
80
-
81
- private:
82
- friend HybridBase;
83
- std::function<void(const std::optional<BLEDevice>& /* device */, const std::optional<std::string>& /* error */)> _func;
84
- };
85
-
86
- } // namespace margelo::nitro::co::zyke::ble
@@ -1,54 +0,0 @@
1
- ///
2
- /// Func_void_std__optional_BLEDevice__std__optional_std__string_.swift
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2026 Marc Rousavy @ Margelo
6
- ///
7
-
8
- import NitroModules
9
-
10
-
11
- /**
12
- * Wraps a Swift `(_ device: BLEDevice?, _ error: String?) -> Void` as a class.
13
- * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
- */
15
- public final class Func_void_std__optional_BLEDevice__std__optional_std__string_ {
16
- public typealias bridge = margelo.nitro.co.zyke.ble.bridge.swift
17
-
18
- private let closure: (_ device: BLEDevice?, _ error: String?) -> Void
19
-
20
- public init(_ closure: @escaping (_ device: BLEDevice?, _ error: String?) -> Void) {
21
- self.closure = closure
22
- }
23
-
24
- @inline(__always)
25
- public func call(device: bridge.std__optional_BLEDevice_, error: bridge.std__optional_std__string_) -> Void {
26
- self.closure(device.value, { () -> String? in
27
- if bridge.has_value_std__optional_std__string_(error) {
28
- let __unwrapped = bridge.get_std__optional_std__string_(error)
29
- return String(__unwrapped)
30
- } else {
31
- return nil
32
- }
33
- }())
34
- }
35
-
36
- /**
37
- * Casts this instance to a retained unsafe raw pointer.
38
- * This acquires one additional strong reference on the object!
39
- */
40
- @inline(__always)
41
- public func toUnsafe() -> UnsafeMutableRawPointer {
42
- return Unmanaged.passRetained(self).toOpaque()
43
- }
44
-
45
- /**
46
- * Casts an unsafe pointer to a `Func_void_std__optional_BLEDevice__std__optional_std__string_`.
47
- * The pointer has to be a retained opaque `Unmanaged<Func_void_std__optional_BLEDevice__std__optional_std__string_>`.
48
- * This removes one strong reference from the object!
49
- */
50
- @inline(__always)
51
- public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__optional_BLEDevice__std__optional_std__string_ {
52
- return Unmanaged<Func_void_std__optional_BLEDevice__std__optional_std__string_>.fromOpaque(pointer).takeRetainedValue()
53
- }
54
- }