munim-bluetooth 0.3.21 → 0.3.23

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 (41) hide show
  1. package/lib/commonjs/index.js +9 -7
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/module/index.js +10 -8
  4. package/lib/module/index.js.map +1 -1
  5. package/lib/typescript/src/index.d.ts.map +1 -1
  6. package/nitrogen/generated/android/MunimBluetoothOnLoad.cpp +26 -16
  7. package/nitrogen/generated/android/MunimBluetoothOnLoad.hpp +13 -4
  8. package/nitrogen/generated/android/c++/JAdvertisingDataTypes.hpp +1 -1
  9. package/nitrogen/generated/android/c++/JAdvertisingOptions.hpp +1 -1
  10. package/nitrogen/generated/android/c++/JCharacteristicValue.hpp +1 -1
  11. package/nitrogen/generated/android/c++/JGATTCharacteristic.hpp +1 -1
  12. package/nitrogen/generated/android/c++/JGATTService.hpp +1 -1
  13. package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.cpp +38 -44
  14. package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.hpp +19 -22
  15. package/nitrogen/generated/android/c++/JScanMode.hpp +1 -1
  16. package/nitrogen/generated/android/c++/JScanOptions.hpp +1 -1
  17. package/nitrogen/generated/android/c++/JServiceDataEntry.hpp +1 -1
  18. package/nitrogen/generated/android/c++/JWriteType.hpp +1 -1
  19. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec.kt +1 -1
  20. package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.hpp +9 -9
  21. package/nitrogen/generated/ios/MunimBluetoothAutolinking.mm +1 -1
  22. package/nitrogen/generated/ios/MunimBluetoothAutolinking.swift +9 -27
  23. package/nitrogen/generated/ios/swift/AdvertisingDataTypes.swift +24 -4
  24. package/nitrogen/generated/ios/swift/AdvertisingOptions.swift +0 -1
  25. package/nitrogen/generated/ios/swift/CharacteristicValue.swift +0 -1
  26. package/nitrogen/generated/ios/swift/Func_void.swift +0 -1
  27. package/nitrogen/generated/ios/swift/Func_void_AdvertisingDataTypes.swift +0 -1
  28. package/nitrogen/generated/ios/swift/Func_void_CharacteristicValue.swift +0 -1
  29. package/nitrogen/generated/ios/swift/Func_void_bool.swift +0 -1
  30. package/nitrogen/generated/ios/swift/Func_void_double.swift +0 -1
  31. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +0 -1
  32. package/nitrogen/generated/ios/swift/Func_void_std__vector_GATTService_.swift +0 -1
  33. package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +0 -1
  34. package/nitrogen/generated/ios/swift/GATTCharacteristic.swift +0 -1
  35. package/nitrogen/generated/ios/swift/GATTService.swift +0 -1
  36. package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec.swift +2 -5
  37. package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec_cxx.swift +0 -1
  38. package/nitrogen/generated/ios/swift/ScanOptions.swift +0 -1
  39. package/nitrogen/generated/ios/swift/ServiceDataEntry.swift +0 -1
  40. package/package.json +4 -4
  41. package/src/index.ts +21 -7
@@ -30,16 +30,18 @@ var _reactNativeNitroModules = require("react-native-nitro-modules");
30
30
  var _reactNative = require("react-native");
31
31
  const MunimBluetooth = _reactNativeNitroModules.NitroModules.createHybridObject('MunimBluetooth');
32
32
 
33
- // Event Emitter for Bluetooth events
34
- const {
35
- MunimBluetoothEventEmitter
36
- } = _reactNative.NativeModules;
37
- console.log('[munim-bluetooth] Checking for event emitter...', MunimBluetoothEventEmitter ? 'FOUND' : 'NOT FOUND');
33
+ // Android emits through DeviceEventEmitter from the Nitro module itself.
34
+ // iOS exposes a dedicated RCTEventEmitter module.
35
+ const nativeEventModule = _reactNative.Platform.OS === 'ios' ? _reactNative.NativeModules.MunimBluetoothEventEmitter : null;
36
+ console.log('[munim-bluetooth] Checking for event emitter...', _reactNative.Platform.OS === 'android' ? 'USING_DEVICE_EVENT_EMITTER' : nativeEventModule ? 'FOUND' : 'NOT FOUND');
38
37
  console.log('[munim-bluetooth] Available NativeModules:', Object.keys(_reactNative.NativeModules).filter(key => key.includes('Bluetooth') || key.includes('Munim')));
39
38
  let eventEmitter = null;
40
- if (MunimBluetoothEventEmitter) {
39
+ if (_reactNative.Platform.OS === 'android') {
40
+ eventEmitter = _reactNative.DeviceEventEmitter;
41
+ console.log('[munim-bluetooth] Using DeviceEventEmitter on Android');
42
+ } else if (nativeEventModule) {
41
43
  try {
42
- eventEmitter = new _reactNative.NativeEventEmitter(MunimBluetoothEventEmitter);
44
+ eventEmitter = new _reactNative.NativeEventEmitter(nativeEventModule);
43
45
  console.log('[munim-bluetooth] Event emitter initialized successfully');
44
46
  } catch (error) {
45
47
  console.error('[munim-bluetooth] Failed to initialize event emitter:', error);
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeNitroModules","require","_reactNative","MunimBluetooth","NitroModules","createHybridObject","MunimBluetoothEventEmitter","NativeModules","console","log","Object","keys","filter","key","includes","eventEmitter","NativeEventEmitter","error","warn","startAdvertising","options","updateAdvertisingData","advertisingData","getAdvertisingData","stopAdvertising","setServices","services","isBluetoothEnabled","requestBluetoothPermission","startScan","stopScan","connect","deviceId","disconnect","discoverServices","readCharacteristic","serviceUUID","characteristicUUID","writeCharacteristic","value","writeType","subscribeToCharacteristic","unsubscribeFromCharacteristic","getConnectedDevices","readRSSI","addDeviceFoundListener","callback","subscription","addListener","remove","addEventListener","eventName","removeListeners","count","_default","exports","default"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAUA,MAAME,cAAc,GAClBC,qCAAY,CAACC,kBAAkB,CAAqB,gBAAgB,CAAC;;AAEvE;AACA,MAAM;EAAEC;AAA2B,CAAC,GAAGC,0BAAa;AAEpDC,OAAO,CAACC,GAAG,CACT,iDAAiD,EACjDH,0BAA0B,GAA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AAM6B,YAAY,GAAGhC,YAAY,CAACiC,WAAW,CAACG,SAAS,EAAEL,QAAQ,CAAC;EAClE,OAAO,MAAMC,YAAY,CAACE,MAAM,CAAC,CAAC;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASD,WAAWA,CAACG,SAAiB,EAAQ;EACnD,OAAOhD,cAAc,CAAC6C,WAAW,CAACG,SAAS,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAACC,KAAa,EAAQ;EACnD,OAAOlD,cAAc,CAACiD,eAAe,CAACC,KAAK,CAAC;AAC9C;;AAEA;AAUA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACe;EACb;EACArC,gBAAgB;EAChBK,eAAe;EACfH,qBAAqB;EACrBE,kBAAkB;EAClBE,WAAW;EACX;EACAE,kBAAkB;EAClBC,0BAA0B;EAC1BC,SAAS;EACTC,QAAQ;EACRC,OAAO;EACPE,UAAU;EACVC,gBAAgB;EAChBC,kBAAkB;EAClBG,mBAAmB;EACnBG,yBAAyB;EACzBC,6BAA6B;EAC7BC,mBAAmB;EACnBC,QAAQ;EACR;EACAC,sBAAsB;EACtBK,gBAAgB;EAChBF,WAAW;EACXI;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeNitroModules","require","_reactNative","MunimBluetooth","NitroModules","createHybridObject","nativeEventModule","Platform","OS","NativeModules","MunimBluetoothEventEmitter","console","log","Object","keys","filter","key","includes","eventEmitter","DeviceEventEmitter","NativeEventEmitter","error","warn","startAdvertising","options","updateAdvertisingData","advertisingData","getAdvertisingData","stopAdvertising","setServices","services","isBluetoothEnabled","requestBluetoothPermission","startScan","stopScan","connect","deviceId","disconnect","discoverServices","readCharacteristic","serviceUUID","characteristicUUID","writeCharacteristic","value","writeType","subscribeToCharacteristic","unsubscribeFromCharacteristic","getConnectedDevices","readRSSI","addDeviceFoundListener","callback","subscription","addListener","remove","addEventListener","eventName","removeListeners","count","_default","exports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B;EACzBC,6BAA6B;EAC7BC,mBAAmB;EACnBC,QAAQ;EACR;EACAC,sBAAsB;EACtBK,gBAAgB;EAChBF,WAAW;EACXI;AACF,CAAC","ignoreList":[]}
@@ -1,19 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  import { NitroModules } from 'react-native-nitro-modules';
4
- import { NativeEventEmitter, NativeModules } from 'react-native';
4
+ import { DeviceEventEmitter, NativeEventEmitter, NativeModules, Platform } from 'react-native';
5
5
  const MunimBluetooth = NitroModules.createHybridObject('MunimBluetooth');
6
6
 
7
- // Event Emitter for Bluetooth events
8
- const {
9
- MunimBluetoothEventEmitter
10
- } = NativeModules;
11
- console.log('[munim-bluetooth] Checking for event emitter...', MunimBluetoothEventEmitter ? 'FOUND' : 'NOT FOUND');
7
+ // Android emits through DeviceEventEmitter from the Nitro module itself.
8
+ // iOS exposes a dedicated RCTEventEmitter module.
9
+ const nativeEventModule = Platform.OS === 'ios' ? NativeModules.MunimBluetoothEventEmitter : null;
10
+ console.log('[munim-bluetooth] Checking for event emitter...', Platform.OS === 'android' ? 'USING_DEVICE_EVENT_EMITTER' : nativeEventModule ? 'FOUND' : 'NOT FOUND');
12
11
  console.log('[munim-bluetooth] Available NativeModules:', Object.keys(NativeModules).filter(key => key.includes('Bluetooth') || key.includes('Munim')));
13
12
  let eventEmitter = null;
14
- if (MunimBluetoothEventEmitter) {
13
+ if (Platform.OS === 'android') {
14
+ eventEmitter = DeviceEventEmitter;
15
+ console.log('[munim-bluetooth] Using DeviceEventEmitter on Android');
16
+ } else if (nativeEventModule) {
15
17
  try {
16
- eventEmitter = new NativeEventEmitter(MunimBluetoothEventEmitter);
18
+ eventEmitter = new NativeEventEmitter(nativeEventModule);
17
19
  console.log('[munim-bluetooth] Event emitter initialized successfully');
18
20
  } catch (error) {
19
21
  console.error('[munim-bluetooth] Failed to initialize event emitter:', error);
@@ -1 +1 @@
1
- {"version":3,"names":["NitroModules","NativeEventEmitter","NativeModules","MunimBluetooth","createHybridObject","MunimBluetoothEventEmitter","console","log","Object","keys","filter","key","includes","eventEmitter","error","warn","startAdvertising","options","updateAdvertisingData","advertisingData","getAdvertisingData","stopAdvertising","setServices","services","isBluetoothEnabled","requestBluetoothPermission","startScan","stopScan","connect","deviceId","disconnect","discoverServices","readCharacteristic","serviceUUID","characteristicUUID","writeCharacteristic","value","writeType","subscribeToCharacteristic","unsubscribeFromCharacteristic","getConnectedDevices","readRSSI","addDeviceFoundListener","callback","subscription","addListener","remove","addEventListener","eventName","removeListeners","count"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AACzD,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAUhE,MAAMC,cAAc,GAClBH,YAAY,CAACI,kBAAkB,CAAqB,gBAAgB,CAAC;;AAEvE;AACA,MAAM;EAAEC;AAA2B,CAAC,GAAGH,aAAa;AAEpDI,OAAO,CAACC,GAAG,CACT,iDAAiD,EACjDF,0BAA0B,GAAG,OAAO,GAAG,WACzC,CAAC;AACDC,OAAO,CAACC,GAAG,CACT,4CAA4C,EAC5CC,MAAM,CAACC,IAAI,CAACP,aAAa,CAAC,CAACQ,MAAM,CAC9BC,GAAG,IAAKA,GAAG,CAACC,QAAQ,CAAC,WAAW,CAAC,IAAID,GAAG,CAACC,QAAQ,CAAC,OAAO,CAC5D,CACF,CAAC;AAED,IAAIC,YAAuC,GAAG,IAAI;AAElD,IAAIR,0BAA0B,EAAE;EAC9B,IAAI;IACFQ,YAAY,GAAG,IAAIZ,kBAAkB,CAACI,0BAA0B,CAAC;IACjEC,OAAO,CAACC,GAAG,CAAC,0DAA0D,CAAC;EACzE,CAAC,CAAC,OAAOO,KAAK,EAAE;IACdR,OAAO,CAACQ,KAAK,CACX,uDAAuD,EACvDA,KACF,CAAC;EACH;AACF,CAAC,MAAM;EACLR,OAAO,CAACS,IAAI,CACV,2GACF,CAAC;EACDT,OAAO,CAACS,IAAI,CACV,mGACF,CAAC;AACH;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ACAE,kBAAkB;EAClBC,0BAA0B;EAC1BC,SAAS;EACTC,QAAQ;EACRC,OAAO;EACPE,UAAU;EACVC,gBAAgB;EAChBC,kBAAkB;EAClBG,mBAAmB;EACnBG,yBAAyB;EACzBC,6BAA6B;EAC7BC,mBAAmB;EACnBC,QAAQ;EACR;EACAC,sBAAsB;EACtBK,gBAAgB;EAChBF,WAAW;EACXI;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["NitroModules","DeviceEventEmitter","NativeEventEmitter","NativeModules","Platform","MunimBluetooth","createHybridObject","nativeEventModule","OS","MunimBluetoothEventEmitter","console","log","Object","keys","filter","key","includes","eventEmitter","error","warn","startAdvertising","options","updateAdvertisingData","advertisingData","getAdvertisingData","stopAdvertising","setServices","services","isBluetoothEnabled","requestBluetoothPermission","startScan","stopScan","connect","deviceId","disconnect","discoverServices","readCharacteristic","serviceUUID","characteristicUUID","writeCharacteristic","value","writeType","subscribeToCharacteristic","unsubscribeFromCharacteristic","getConnectedDevices","readRSSI","addDeviceFoundListener","callback","subscription","addListener","remove","addEventListener","eventName","removeListeners","count"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AACzD,SACEC,kBAAkB,EAClBC,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,QACH,cAAc;AAUrB,MAAMC,cAAc,GAClBL,YAAY,CAACM,kBAAkB,CAAqB,gBAAgB,CAAC;;AAEvE;AACA;AACA,MAAMC,iBAAiB,GACrBH,QAAQ,CAACI,EAAE,KAAK,KAAK,GAAGL,aAAa,CAACM,0BAA0B,GAAG,IAAI;AAEzEC,OAAO,CAACC,GAAG,CACT,iDAAiD,EACjDP,QAAQ,CAACI,EAAE,KAAK,SAAS,GACrB,4BAA4B,GAC5BD,iBAAiB,GACf,OAAO,GACP,WACR,CAAC;AACDG,OAAO,CAACC,GAAG,CACT,4CAA4C,EAC5CC,MAAM,CAACC,IAAI,CAACV,aAAa,CAAC,CAACW,MA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AiB,EACjBL,QAA6B,EACjB;EACZ,IAAI,CAAC9B,YAAY,EAAE;IACjBP,OAAO,CAACS,IAAI,CACV,qEACF,CAAC;IACD,OAAO,MAAM,CAAC,CAAC;EACjB;EAEA,MAAM6B,YAAY,GAAG/B,YAAY,CAACgC,WAAW,CAACG,SAAS,EAAEL,QAAQ,CAAC;EAClE,OAAO,MAAMC,YAAY,CAACE,MAAM,CAAC,CAAC;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASD,WAAWA,CAACG,SAAiB,EAAQ;EACnD,OAAO/C,cAAc,CAAC4C,WAAW,CAACG,SAAS,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACC,KAAa,EAAQ;EACnD,OAAOjD,cAAc,CAACgD,eAAe,CAACC,KAAK,CAAC;AAC9C;;AAEA;;AAUA;AACA,eAAe;EACb;EACAlC,gBAAgB;EAChBK,eAAe;EACfH,qBAAqB;EACrBE,kBAAkB;EAClBE,WAAW;EACX;EACAE,kBAAkB;EAClBC,0BAA0B;EAC1BC,SAAS;EACTC,QAAQ;EACRC,OAAO;EACPE,UAAU;EACVC,gBAAgB;EAChBC,kBAAkB;EAClBG,mBAAmB;EACnBG,yBAAyB;EACzBC,6BAA6B;EAC7BC,mBAAmB;EACnBC,QAAQ;EACR;EACAC,sBAAsB;EACtBK,gBAAgB;EAChBF,WAAW;EACXI;AACF,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,WAAW,EACX,mBAAmB,EACpB,MAAM,+BAA+B,CAAA;AA0CtC;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAA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"}
@@ -21,24 +21,34 @@
21
21
  namespace margelo::nitro::munimbluetooth {
22
22
 
23
23
  int initialize(JavaVM* vm) {
24
+ return facebook::jni::initialize(vm, []() {
25
+ ::margelo::nitro::munimbluetooth::registerAllNatives();
26
+ });
27
+ }
28
+
29
+ struct JHybridMunimBluetoothSpecImpl: public jni::JavaClass<JHybridMunimBluetoothSpecImpl, JHybridMunimBluetoothSpec::JavaPart> {
30
+ static constexpr auto kJavaDescriptor = "Lcom/munimbluetooth/HybridMunimBluetooth;";
31
+ static std::shared_ptr<JHybridMunimBluetoothSpec> create() {
32
+ static const auto constructorFn = javaClassStatic()->getConstructor<JHybridMunimBluetoothSpecImpl::javaobject()>();
33
+ jni::local_ref<JHybridMunimBluetoothSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
34
+ return javaPart->getJHybridMunimBluetoothSpec();
35
+ }
36
+ };
37
+
38
+ void registerAllNatives() {
24
39
  using namespace margelo::nitro;
25
40
  using namespace margelo::nitro::munimbluetooth;
26
- using namespace facebook;
27
-
28
- return facebook::jni::initialize(vm, [] {
29
- // Register native JNI methods
30
- margelo::nitro::munimbluetooth::JHybridMunimBluetoothSpec::registerNatives();
31
-
32
- // Register Nitro Hybrid Objects
33
- HybridObjectRegistry::registerHybridObjectConstructor(
34
- "MunimBluetooth",
35
- []() -> std::shared_ptr<HybridObject> {
36
- static DefaultConstructableObject<JHybridMunimBluetoothSpec::javaobject> object("com/munimbluetooth/HybridMunimBluetooth");
37
- auto instance = object.create();
38
- return instance->cthis()->shared();
39
- }
40
- );
41
- });
41
+
42
+ // Register native JNI methods
43
+ margelo::nitro::munimbluetooth::JHybridMunimBluetoothSpec::CxxPart::registerNatives();
44
+
45
+ // Register Nitro Hybrid Objects
46
+ HybridObjectRegistry::registerHybridObjectConstructor(
47
+ "MunimBluetooth",
48
+ []() -> std::shared_ptr<HybridObject> {
49
+ return JHybridMunimBluetoothSpecImpl::create();
50
+ }
51
+ );
42
52
  }
43
53
 
44
54
  } // namespace margelo::nitro::munimbluetooth
@@ -6,20 +6,29 @@
6
6
  ///
7
7
 
8
8
  #include <jni.h>
9
+ #include <functional>
9
10
  #include <NitroModules/NitroDefines.hpp>
10
11
 
11
12
  namespace margelo::nitro::munimbluetooth {
12
13
 
14
+ [[deprecated("Use registerNatives() instead.")]]
15
+ int initialize(JavaVM* vm);
16
+
13
17
  /**
14
- * Initializes the native (C++) part of MunimBluetooth, and autolinks all Hybrid Objects.
15
- * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`).
18
+ * Register the native (C++) part of MunimBluetooth, and autolinks all Hybrid Objects.
19
+ * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
20
+ * inside a `facebook::jni::initialize(vm, ...)` call.
16
21
  * Example:
17
22
  * ```cpp (cpp-adapter.cpp)
18
23
  * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
19
- * return margelo::nitro::munimbluetooth::initialize(vm);
24
+ * return facebook::jni::initialize(vm, []() {
25
+ * // register all MunimBluetooth HybridObjects
26
+ * margelo::nitro::munimbluetooth::registerNatives();
27
+ * // any other custom registrations go here.
28
+ * });
20
29
  * }
21
30
  * ```
22
31
  */
23
- int initialize(JavaVM* vm);
32
+ void registerAllNatives();
24
33
 
25
34
  } // namespace margelo::nitro::munimbluetooth
@@ -25,7 +25,7 @@ namespace margelo::nitro::munimbluetooth {
25
25
  */
26
26
  struct JAdvertisingDataTypes final: public jni::JavaClass<JAdvertisingDataTypes> {
27
27
  public:
28
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/AdvertisingDataTypes;";
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/AdvertisingDataTypes;";
29
29
 
30
30
  public:
31
31
  /**
@@ -27,7 +27,7 @@ namespace margelo::nitro::munimbluetooth {
27
27
  */
28
28
  struct JAdvertisingOptions final: public jni::JavaClass<JAdvertisingOptions> {
29
29
  public:
30
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/AdvertisingOptions;";
30
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/AdvertisingOptions;";
31
31
 
32
32
  public:
33
33
  /**
@@ -21,7 +21,7 @@ namespace margelo::nitro::munimbluetooth {
21
21
  */
22
22
  struct JCharacteristicValue final: public jni::JavaClass<JCharacteristicValue> {
23
23
  public:
24
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/CharacteristicValue;";
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/CharacteristicValue;";
25
25
 
26
26
  public:
27
27
  /**
@@ -23,7 +23,7 @@ namespace margelo::nitro::munimbluetooth {
23
23
  */
24
24
  struct JGATTCharacteristic final: public jni::JavaClass<JGATTCharacteristic> {
25
25
  public:
26
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/GATTCharacteristic;";
26
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/GATTCharacteristic;";
27
27
 
28
28
  public:
29
29
  /**
@@ -25,7 +25,7 @@ namespace margelo::nitro::munimbluetooth {
25
25
  */
26
26
  struct JGATTService final: public jni::JavaClass<JGATTService> {
27
27
  public:
28
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/GATTService;";
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/GATTService;";
29
29
 
30
30
  public:
31
31
  /**
@@ -53,37 +53,31 @@ namespace margelo::nitro::munimbluetooth { enum class WriteType; }
53
53
 
54
54
  namespace margelo::nitro::munimbluetooth {
55
55
 
56
- jni::local_ref<JHybridMunimBluetoothSpec::jhybriddata> JHybridMunimBluetoothSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
57
- return makeCxxInstance(jThis);
58
- }
59
-
60
- void JHybridMunimBluetoothSpec::registerNatives() {
61
- registerHybrid({
62
- makeNativeMethod("initHybrid", JHybridMunimBluetoothSpec::initHybrid),
63
- });
56
+ std::shared_ptr<JHybridMunimBluetoothSpec> JHybridMunimBluetoothSpec::JavaPart::getJHybridMunimBluetoothSpec() {
57
+ auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
58
+ auto castHybridObject = std::dynamic_pointer_cast<JHybridMunimBluetoothSpec>(hybridObject);
59
+ if (castHybridObject == nullptr) [[unlikely]] {
60
+ throw std::runtime_error("Failed to downcast JHybridObject to JHybridMunimBluetoothSpec!");
61
+ }
62
+ return castHybridObject;
64
63
  }
65
64
 
66
- size_t JHybridMunimBluetoothSpec::getExternalMemorySize() noexcept {
67
- static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
68
- return method(_javaPart);
65
+ jni::local_ref<JHybridMunimBluetoothSpec::CxxPart::jhybriddata> JHybridMunimBluetoothSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
66
+ return makeCxxInstance(jThis);
69
67
  }
70
68
 
71
- bool JHybridMunimBluetoothSpec::equals(const std::shared_ptr<HybridObject>& other) {
72
- if (auto otherCast = std::dynamic_pointer_cast<JHybridMunimBluetoothSpec>(other)) {
73
- return _javaPart == otherCast->_javaPart;
69
+ std::shared_ptr<JHybridObject> JHybridMunimBluetoothSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
70
+ auto castJavaPart = jni::dynamic_ref_cast<JHybridMunimBluetoothSpec::JavaPart>(javaPart);
71
+ if (castJavaPart == nullptr) [[unlikely]] {
72
+ throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridMunimBluetoothSpec::JavaPart!");
74
73
  }
75
- return false;
76
- }
77
-
78
- void JHybridMunimBluetoothSpec::dispose() noexcept {
79
- static const auto method = javaClassStatic()->getMethod<void()>("dispose");
80
- method(_javaPart);
74
+ return std::make_shared<JHybridMunimBluetoothSpec>(castJavaPart);
81
75
  }
82
76
 
83
- std::string JHybridMunimBluetoothSpec::toString() {
84
- static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
85
- auto javaString = method(_javaPart);
86
- return javaString->toStdString();
77
+ void JHybridMunimBluetoothSpec::CxxPart::registerNatives() {
78
+ registerHybrid({
79
+ makeNativeMethod("initHybrid", JHybridMunimBluetoothSpec::CxxPart::initHybrid),
80
+ });
87
81
  }
88
82
 
89
83
  // Properties
@@ -91,15 +85,15 @@ namespace margelo::nitro::munimbluetooth {
91
85
 
92
86
  // Methods
93
87
  void JHybridMunimBluetoothSpec::startAdvertising(const AdvertisingOptions& options) {
94
- static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JAdvertisingOptions> /* options */)>("startAdvertising");
88
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JAdvertisingOptions> /* options */)>("startAdvertising");
95
89
  method(_javaPart, JAdvertisingOptions::fromCpp(options));
96
90
  }
97
91
  void JHybridMunimBluetoothSpec::updateAdvertisingData(const AdvertisingDataTypes& advertisingData) {
98
- static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JAdvertisingDataTypes> /* advertisingData */)>("updateAdvertisingData");
92
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JAdvertisingDataTypes> /* advertisingData */)>("updateAdvertisingData");
99
93
  method(_javaPart, JAdvertisingDataTypes::fromCpp(advertisingData));
100
94
  }
101
95
  std::shared_ptr<Promise<AdvertisingDataTypes>> JHybridMunimBluetoothSpec::getAdvertisingData() {
102
- static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getAdvertisingData");
96
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getAdvertisingData");
103
97
  auto __result = method(_javaPart);
104
98
  return [&]() {
105
99
  auto __promise = Promise<AdvertisingDataTypes>::create();
@@ -115,11 +109,11 @@ namespace margelo::nitro::munimbluetooth {
115
109
  }();
116
110
  }
117
111
  void JHybridMunimBluetoothSpec::stopAdvertising() {
118
- static const auto method = javaClassStatic()->getMethod<void()>("stopAdvertising");
112
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("stopAdvertising");
119
113
  method(_javaPart);
120
114
  }
121
115
  void JHybridMunimBluetoothSpec::setServices(const std::vector<GATTService>& services) {
122
- static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JGATTService>> /* services */)>("setServices");
116
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JGATTService>> /* services */)>("setServices");
123
117
  method(_javaPart, [&]() {
124
118
  size_t __size = services.size();
125
119
  jni::local_ref<jni::JArrayClass<JGATTService>> __array = jni::JArrayClass<JGATTService>::newArray(__size);
@@ -132,7 +126,7 @@ namespace margelo::nitro::munimbluetooth {
132
126
  }());
133
127
  }
134
128
  std::shared_ptr<Promise<bool>> JHybridMunimBluetoothSpec::isBluetoothEnabled() {
135
- static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("isBluetoothEnabled");
129
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("isBluetoothEnabled");
136
130
  auto __result = method(_javaPart);
137
131
  return [&]() {
138
132
  auto __promise = Promise<bool>::create();
@@ -148,7 +142,7 @@ namespace margelo::nitro::munimbluetooth {
148
142
  }();
149
143
  }
150
144
  std::shared_ptr<Promise<bool>> JHybridMunimBluetoothSpec::requestBluetoothPermission() {
151
- static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("requestBluetoothPermission");
145
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("requestBluetoothPermission");
152
146
  auto __result = method(_javaPart);
153
147
  return [&]() {
154
148
  auto __promise = Promise<bool>::create();
@@ -164,15 +158,15 @@ namespace margelo::nitro::munimbluetooth {
164
158
  }();
165
159
  }
166
160
  void JHybridMunimBluetoothSpec::startScan(const std::optional<ScanOptions>& options) {
167
- static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JScanOptions> /* options */)>("startScan");
161
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JScanOptions> /* options */)>("startScan");
168
162
  method(_javaPart, options.has_value() ? JScanOptions::fromCpp(options.value()) : nullptr);
169
163
  }
170
164
  void JHybridMunimBluetoothSpec::stopScan() {
171
- static const auto method = javaClassStatic()->getMethod<void()>("stopScan");
165
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("stopScan");
172
166
  method(_javaPart);
173
167
  }
174
168
  std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::connect(const std::string& deviceId) {
175
- static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("connect");
169
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("connect");
176
170
  auto __result = method(_javaPart, jni::make_jstring(deviceId));
177
171
  return [&]() {
178
172
  auto __promise = Promise<void>::create();
@@ -187,11 +181,11 @@ namespace margelo::nitro::munimbluetooth {
187
181
  }();
188
182
  }
189
183
  void JHybridMunimBluetoothSpec::disconnect(const std::string& deviceId) {
190
- static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */)>("disconnect");
184
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */)>("disconnect");
191
185
  method(_javaPart, jni::make_jstring(deviceId));
192
186
  }
193
187
  std::shared_ptr<Promise<std::vector<GATTService>>> JHybridMunimBluetoothSpec::discoverServices(const std::string& deviceId) {
194
- static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("discoverServices");
188
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("discoverServices");
195
189
  auto __result = method(_javaPart, jni::make_jstring(deviceId));
196
190
  return [&]() {
197
191
  auto __promise = Promise<std::vector<GATTService>>::create();
@@ -216,7 +210,7 @@ namespace margelo::nitro::munimbluetooth {
216
210
  }();
217
211
  }
218
212
  std::shared_ptr<Promise<CharacteristicValue>> JHybridMunimBluetoothSpec::readCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) {
219
- static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("readCharacteristic");
213
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("readCharacteristic");
220
214
  auto __result = method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID));
221
215
  return [&]() {
222
216
  auto __promise = Promise<CharacteristicValue>::create();
@@ -232,7 +226,7 @@ namespace margelo::nitro::munimbluetooth {
232
226
  }();
233
227
  }
234
228
  std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::writeCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID, const std::string& value, std::optional<WriteType> writeType) {
235
- static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */, jni::alias_ref<jni::JString> /* value */, jni::alias_ref<JWriteType> /* writeType */)>("writeCharacteristic");
229
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */, jni::alias_ref<jni::JString> /* value */, jni::alias_ref<JWriteType> /* writeType */)>("writeCharacteristic");
236
230
  auto __result = method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID), jni::make_jstring(value), writeType.has_value() ? JWriteType::fromCpp(writeType.value()) : nullptr);
237
231
  return [&]() {
238
232
  auto __promise = Promise<void>::create();
@@ -247,15 +241,15 @@ namespace margelo::nitro::munimbluetooth {
247
241
  }();
248
242
  }
249
243
  void JHybridMunimBluetoothSpec::subscribeToCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) {
250
- static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("subscribeToCharacteristic");
244
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("subscribeToCharacteristic");
251
245
  method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID));
252
246
  }
253
247
  void JHybridMunimBluetoothSpec::unsubscribeFromCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) {
254
- static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("unsubscribeFromCharacteristic");
248
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("unsubscribeFromCharacteristic");
255
249
  method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID));
256
250
  }
257
251
  std::shared_ptr<Promise<std::vector<std::string>>> JHybridMunimBluetoothSpec::getConnectedDevices() {
258
- static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getConnectedDevices");
252
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getConnectedDevices");
259
253
  auto __result = method(_javaPart);
260
254
  return [&]() {
261
255
  auto __promise = Promise<std::vector<std::string>>::create();
@@ -280,7 +274,7 @@ namespace margelo::nitro::munimbluetooth {
280
274
  }();
281
275
  }
282
276
  std::shared_ptr<Promise<double>> JHybridMunimBluetoothSpec::readRSSI(const std::string& deviceId) {
283
- static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("readRSSI");
277
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("readRSSI");
284
278
  auto __result = method(_javaPart, jni::make_jstring(deviceId));
285
279
  return [&]() {
286
280
  auto __promise = Promise<double>::create();
@@ -296,11 +290,11 @@ namespace margelo::nitro::munimbluetooth {
296
290
  }();
297
291
  }
298
292
  void JHybridMunimBluetoothSpec::addListener(const std::string& eventName) {
299
- static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* eventName */)>("addListener");
293
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* eventName */)>("addListener");
300
294
  method(_javaPart, jni::make_jstring(eventName));
301
295
  }
302
296
  void JHybridMunimBluetoothSpec::removeListeners(double count) {
303
- static const auto method = javaClassStatic()->getMethod<void(double /* count */)>("removeListeners");
297
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* count */)>("removeListeners");
304
298
  method(_javaPart, count);
305
299
  }
306
300
 
@@ -18,34 +18,33 @@ namespace margelo::nitro::munimbluetooth {
18
18
 
19
19
  using namespace facebook;
20
20
 
21
- class JHybridMunimBluetoothSpec: public jni::HybridClass<JHybridMunimBluetoothSpec, JHybridObject>,
22
- public virtual HybridMunimBluetoothSpec {
21
+ class JHybridMunimBluetoothSpec: public virtual HybridMunimBluetoothSpec, public virtual JHybridObject {
23
22
  public:
24
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec;";
25
- static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
26
- static void registerNatives();
27
-
28
- protected:
29
- // C++ constructor (called from Java via `initHybrid()`)
30
- explicit JHybridMunimBluetoothSpec(jni::alias_ref<jhybridobject> jThis) :
31
- HybridObject(HybridMunimBluetoothSpec::TAG),
32
- HybridBase(jThis),
33
- _javaPart(jni::make_global(jThis)) {}
23
+ struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec;";
25
+ std::shared_ptr<JHybridMunimBluetoothSpec> getJHybridMunimBluetoothSpec();
26
+ };
27
+ struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec$CxxPart;";
29
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
30
+ static void registerNatives();
31
+ using HybridBase::HybridBase;
32
+ protected:
33
+ std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
34
+ };
34
35
 
35
36
  public:
37
+ explicit JHybridMunimBluetoothSpec(const jni::local_ref<JHybridMunimBluetoothSpec::JavaPart>& javaPart):
38
+ HybridObject(HybridMunimBluetoothSpec::TAG),
39
+ JHybridObject(javaPart),
40
+ _javaPart(jni::make_global(javaPart)) {}
36
41
  ~JHybridMunimBluetoothSpec() override {
37
42
  // Hermes GC can destroy JS objects on a non-JNI Thread.
38
43
  jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
39
44
  }
40
45
 
41
46
  public:
42
- size_t getExternalMemorySize() noexcept override;
43
- bool equals(const std::shared_ptr<HybridObject>& other) override;
44
- void dispose() noexcept override;
45
- std::string toString() override;
46
-
47
- public:
48
- inline const jni::global_ref<JHybridMunimBluetoothSpec::javaobject>& getJavaPart() const noexcept {
47
+ inline const jni::global_ref<JHybridMunimBluetoothSpec::JavaPart>& getJavaPart() const noexcept {
49
48
  return _javaPart;
50
49
  }
51
50
 
@@ -77,9 +76,7 @@ namespace margelo::nitro::munimbluetooth {
77
76
  void removeListeners(double count) override;
78
77
 
79
78
  private:
80
- friend HybridBase;
81
- using HybridBase::HybridBase;
82
- jni::global_ref<JHybridMunimBluetoothSpec::javaobject> _javaPart;
79
+ jni::global_ref<JHybridMunimBluetoothSpec::JavaPart> _javaPart;
83
80
  };
84
81
 
85
82
  } // namespace margelo::nitro::munimbluetooth
@@ -19,7 +19,7 @@ namespace margelo::nitro::munimbluetooth {
19
19
  */
20
20
  struct JScanMode final: public jni::JavaClass<JScanMode> {
21
21
  public:
22
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/ScanMode;";
22
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/ScanMode;";
23
23
 
24
24
  public:
25
25
  /**
@@ -25,7 +25,7 @@ namespace margelo::nitro::munimbluetooth {
25
25
  */
26
26
  struct JScanOptions final: public jni::JavaClass<JScanOptions> {
27
27
  public:
28
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/ScanOptions;";
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/ScanOptions;";
29
29
 
30
30
  public:
31
31
  /**
@@ -21,7 +21,7 @@ namespace margelo::nitro::munimbluetooth {
21
21
  */
22
22
  struct JServiceDataEntry final: public jni::JavaClass<JServiceDataEntry> {
23
23
  public:
24
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/ServiceDataEntry;";
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/ServiceDataEntry;";
25
25
 
26
26
  public:
27
27
  /**
@@ -19,7 +19,7 @@ namespace margelo::nitro::munimbluetooth {
19
19
  */
20
20
  struct JWriteType final: public jni::JavaClass<JWriteType> {
21
21
  public:
22
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/WriteType;";
22
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/WriteType;";
23
23
 
24
24
  public:
25
25
  /**
@@ -26,7 +26,7 @@ import com.margelo.nitro.core.HybridObject
26
26
  )
27
27
  abstract class HybridMunimBluetoothSpec: HybridObject() {
28
28
  // Properties
29
-
29
+
30
30
 
31
31
  // Methods
32
32
  @DoNotStrip
@@ -80,7 +80,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
80
80
  return optional.has_value();
81
81
  }
82
82
  inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
83
- return *optional;
83
+ return optional.value();
84
84
  }
85
85
 
86
86
  // pragma MARK: std::optional<double>
@@ -95,7 +95,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
95
95
  return optional.has_value();
96
96
  }
97
97
  inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
98
- return *optional;
98
+ return optional.value();
99
99
  }
100
100
 
101
101
  // pragma MARK: std::optional<std::vector<std::string>>
@@ -110,7 +110,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
110
110
  return optional.has_value();
111
111
  }
112
112
  inline std::vector<std::string> get_std__optional_std__vector_std__string__(const std::optional<std::vector<std::string>>& optional) noexcept {
113
- return *optional;
113
+ return optional.value();
114
114
  }
115
115
 
116
116
  // pragma MARK: std::vector<ServiceDataEntry>
@@ -136,7 +136,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
136
136
  return optional.has_value();
137
137
  }
138
138
  inline std::vector<ServiceDataEntry> get_std__optional_std__vector_ServiceDataEntry__(const std::optional<std::vector<ServiceDataEntry>>& optional) noexcept {
139
- return *optional;
139
+ return optional.value();
140
140
  }
141
141
 
142
142
  // pragma MARK: std::optional<AdvertisingDataTypes>
@@ -151,7 +151,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
151
151
  return optional.has_value();
152
152
  }
153
153
  inline AdvertisingDataTypes get_std__optional_AdvertisingDataTypes_(const std::optional<AdvertisingDataTypes>& optional) noexcept {
154
- return *optional;
154
+ return optional.value();
155
155
  }
156
156
 
157
157
  // pragma MARK: std::shared_ptr<Promise<AdvertisingDataTypes>>
@@ -278,7 +278,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
278
278
  return optional.has_value();
279
279
  }
280
280
  inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
281
- return *optional;
281
+ return optional.value();
282
282
  }
283
283
 
284
284
  // pragma MARK: std::optional<ScanMode>
@@ -293,7 +293,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
293
293
  return optional.has_value();
294
294
  }
295
295
  inline ScanMode get_std__optional_ScanMode_(const std::optional<ScanMode>& optional) noexcept {
296
- return *optional;
296
+ return optional.value();
297
297
  }
298
298
 
299
299
  // pragma MARK: std::optional<ScanOptions>
@@ -308,7 +308,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
308
308
  return optional.has_value();
309
309
  }
310
310
  inline ScanOptions get_std__optional_ScanOptions_(const std::optional<ScanOptions>& optional) noexcept {
311
- return *optional;
311
+ return optional.value();
312
312
  }
313
313
 
314
314
  // pragma MARK: std::shared_ptr<Promise<void>>
@@ -425,7 +425,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
425
425
  return optional.has_value();
426
426
  }
427
427
  inline WriteType get_std__optional_WriteType_(const std::optional<WriteType>& optional) noexcept {
428
- return *optional;
428
+ return optional.value();
429
429
  }
430
430
 
431
431
  // pragma MARK: std::shared_ptr<Promise<std::vector<std::string>>>
@@ -24,7 +24,7 @@
24
24
  HybridObjectRegistry::registerHybridObjectConstructor(
25
25
  "MunimBluetooth",
26
26
  []() -> std::shared_ptr<HybridObject> {
27
- std::shared_ptr<HybridMunimBluetoothSpec> hybridObject = MunimBluetooth::MunimBluetoothAutolinking::AutolinkedMunimBluetooth::create();
27
+ std::shared_ptr<HybridMunimBluetoothSpec> hybridObject = MunimBluetooth::MunimBluetoothAutolinking::createMunimBluetooth();
28
28
  return hybridObject;
29
29
  }
30
30
  );
@@ -12,33 +12,15 @@ import NitroModules
12
12
  public final class MunimBluetoothAutolinking {
13
13
  public typealias bridge = margelo.nitro.munimbluetooth.bridge.swift
14
14
 
15
- private protocol AutolinkedClass {
16
- associatedtype T
17
- /**
18
- * Creates an instance of the Swift class that implements the HybridObject's spec,
19
- * and wraps it in a Swift class that can directly interop with C++.
20
- *
21
- * This is generated by Nitrogen and will initialize the class specified
22
- * in the `"autolinking"` property of `nitro.json`.
23
- */
24
- static func create() -> T
25
- /**
26
- * Returns whether this concrete implementation is also
27
- * conforming to the `RecyclableView` protocol, or not.
28
- */
29
- static var isRecyclableHybridView: Bool { get }
15
+ public static func createMunimBluetooth() -> bridge.std__shared_ptr_HybridMunimBluetoothSpec_ {
16
+ let hybridObject = HybridMunimBluetooth()
17
+ return { () -> bridge.std__shared_ptr_HybridMunimBluetoothSpec_ in
18
+ let __cxxWrapped = hybridObject.getCxxWrapper()
19
+ return __cxxWrapped.getCxxPart()
20
+ }()
30
21
  }
31
-
32
- public final class AutolinkedMunimBluetooth: AutolinkedClass {
33
- public static func create() -> bridge.std__shared_ptr_HybridMunimBluetoothSpec_ {
34
- let hybridObject = HybridMunimBluetooth()
35
- return { () -> bridge.std__shared_ptr_HybridMunimBluetoothSpec_ in
36
- let __cxxWrapped = hybridObject.getCxxWrapper()
37
- return __cxxWrapped.getCxxPart()
38
- }()
39
- }
40
- public static var isRecyclableHybridView: Bool {
41
- return HybridMunimBluetooth.self is any RecyclableView.Type
42
- }
22
+
23
+ public static func isMunimBluetoothRecyclable() -> Bool {
24
+ return HybridMunimBluetooth.self is any RecyclableView.Type
43
25
  }
44
26
  }
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -205,7 +204,14 @@ public extension AdvertisingDataTypes {
205
204
 
206
205
  @inline(__always)
207
206
  var flags: Double? {
208
- return self.__flags.value
207
+ return { () -> Double? in
208
+ if bridge.has_value_std__optional_double_(self.__flags) {
209
+ let __unwrapped = bridge.get_std__optional_double_(self.__flags)
210
+ return __unwrapped
211
+ } else {
212
+ return nil
213
+ }
214
+ }()
209
215
  }
210
216
 
211
217
  @inline(__always)
@@ -306,7 +312,14 @@ public extension AdvertisingDataTypes {
306
312
 
307
313
  @inline(__always)
308
314
  var txPowerLevel: Double? {
309
- return self.__txPowerLevel.value
315
+ return { () -> Double? in
316
+ if bridge.has_value_std__optional_double_(self.__txPowerLevel) {
317
+ let __unwrapped = bridge.get_std__optional_double_(self.__txPowerLevel)
318
+ return __unwrapped
319
+ } else {
320
+ return nil
321
+ }
322
+ }()
310
323
  }
311
324
 
312
325
  @inline(__always)
@@ -371,7 +384,14 @@ public extension AdvertisingDataTypes {
371
384
 
372
385
  @inline(__always)
373
386
  var appearance: Double? {
374
- return self.__appearance.value
387
+ return { () -> Double? in
388
+ if bridge.has_value_std__optional_double_(self.__appearance) {
389
+ let __unwrapped = bridge.get_std__optional_double_(self.__appearance)
390
+ return __unwrapped
391
+ } else {
392
+ return nil
393
+ }
394
+ }()
375
395
  }
376
396
 
377
397
  @inline(__always)
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /// See ``HybridMunimBluetoothSpec``
@@ -44,11 +43,9 @@ public extension HybridMunimBluetoothSpec_protocol {
44
43
  }
45
44
 
46
45
  /// See ``HybridMunimBluetoothSpec``
47
- open class HybridMunimBluetoothSpec_base: NSObject {
46
+ open class HybridMunimBluetoothSpec_base {
48
47
  private weak var cxxWrapper: HybridMunimBluetoothSpec_cxx? = nil
49
- public override init() {
50
- super.init()
51
- }
48
+ public init() { }
52
49
  public func getCxxWrapper() -> HybridMunimBluetoothSpec_cxx {
53
50
  #if DEBUG
54
51
  guard self is any HybridMunimBluetoothSpec else {
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
@@ -5,7 +5,6 @@
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- import Foundation
9
8
  import NitroModules
10
9
 
11
10
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "munim-bluetooth",
3
- "version": "0.3.21",
3
+ "version": "0.3.23",
4
4
  "description": "A comprehensive React Native library for all your Bluetooth Low Energy (BLE) needs, supporting both peripheral and central roles with Expo support",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
@@ -85,12 +85,12 @@
85
85
  "@semantic-release/git": "^10.0.1",
86
86
  "@types/jest": "^29.5.14",
87
87
  "@types/react": "19.2.8",
88
- "nitrogen": "0.35.2",
88
+ "conventional-changelog-conventionalcommits": "^9.1.0",
89
+ "nitrogen": "^0.35.2",
89
90
  "react": "19.2.3",
90
91
  "react-native": "0.83.1",
91
92
  "react-native-builder-bob": "^0.40.17",
92
- "react-native-nitro-modules": "0.35.2",
93
- "conventional-changelog-conventionalcommits": "^9.1.0",
93
+ "react-native-nitro-modules": "^0.35.2",
94
94
  "semantic-release": "^25.0.2",
95
95
  "typescript": "^5.8.3"
96
96
  },
package/src/index.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import { NitroModules } from 'react-native-nitro-modules'
2
- import { NativeEventEmitter, NativeModules } from 'react-native'
2
+ import {
3
+ DeviceEventEmitter,
4
+ NativeEventEmitter,
5
+ NativeModules,
6
+ Platform,
7
+ } from 'react-native'
3
8
  import type {
4
9
  MunimBluetooth as MunimBluetoothSpec,
5
10
  AdvertisingDataTypes,
@@ -12,12 +17,18 @@ import type {
12
17
  const MunimBluetooth =
13
18
  NitroModules.createHybridObject<MunimBluetoothSpec>('MunimBluetooth')
14
19
 
15
- // Event Emitter for Bluetooth events
16
- const { MunimBluetoothEventEmitter } = NativeModules
20
+ // Android emits through DeviceEventEmitter from the Nitro module itself.
21
+ // iOS exposes a dedicated RCTEventEmitter module.
22
+ const nativeEventModule =
23
+ Platform.OS === 'ios' ? NativeModules.MunimBluetoothEventEmitter : null
17
24
 
18
25
  console.log(
19
26
  '[munim-bluetooth] Checking for event emitter...',
20
- MunimBluetoothEventEmitter ? 'FOUND' : 'NOT FOUND'
27
+ Platform.OS === 'android'
28
+ ? 'USING_DEVICE_EVENT_EMITTER'
29
+ : nativeEventModule
30
+ ? 'FOUND'
31
+ : 'NOT FOUND'
21
32
  )
22
33
  console.log(
23
34
  '[munim-bluetooth] Available NativeModules:',
@@ -26,11 +37,14 @@ console.log(
26
37
  )
27
38
  )
28
39
 
29
- let eventEmitter: NativeEventEmitter | null = null
40
+ let eventEmitter: Pick<NativeEventEmitter, 'addListener'> | null = null
30
41
 
31
- if (MunimBluetoothEventEmitter) {
42
+ if (Platform.OS === 'android') {
43
+ eventEmitter = DeviceEventEmitter
44
+ console.log('[munim-bluetooth] Using DeviceEventEmitter on Android')
45
+ } else if (nativeEventModule) {
32
46
  try {
33
- eventEmitter = new NativeEventEmitter(MunimBluetoothEventEmitter)
47
+ eventEmitter = new NativeEventEmitter(nativeEventModule)
34
48
  console.log('[munim-bluetooth] Event emitter initialized successfully')
35
49
  } catch (error) {
36
50
  console.error(