@qusaieilouti99/call-manager 0.1.31 → 0.1.32

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 (24) hide show
  1. package/android/src/main/java/com/margelo/nitro/qusaieilouti99/callmanager/CallManager.kt +11 -9
  2. package/lib/module/index.js +1 -1
  3. package/lib/module/index.js.map +1 -1
  4. package/lib/typescript/src/CallManager.nitro.d.ts +1 -1
  5. package/lib/typescript/src/CallManager.nitro.d.ts.map +1 -1
  6. package/lib/typescript/src/index.d.ts +1 -1
  7. package/lib/typescript/src/index.d.ts.map +1 -1
  8. package/nitrogen/generated/android/c++/JFunc_void_CallEventType_std__string.hpp +77 -0
  9. package/nitrogen/generated/android/c++/JHybridCallManagerSpec.cpp +4 -4
  10. package/nitrogen/generated/android/c++/JHybridCallManagerSpec.hpp +1 -1
  11. package/nitrogen/generated/android/kotlin/com/margelo/nitro/qusaieilouti99/callmanager/{Func_void_std__string.kt → Func_void_CallEventType_std__string.kt} +14 -14
  12. package/nitrogen/generated/android/kotlin/com/margelo/nitro/qusaieilouti99/callmanager/HybridCallManagerSpec.kt +3 -3
  13. package/nitrogen/generated/android/qusaieilouti99_callmanagerOnLoad.cpp +2 -2
  14. package/nitrogen/generated/ios/CallManager-Swift-Cxx-Bridge.cpp +5 -5
  15. package/nitrogen/generated/ios/CallManager-Swift-Cxx-Bridge.hpp +15 -12
  16. package/nitrogen/generated/ios/c++/HybridCallManagerSpecSwift.hpp +2 -2
  17. package/nitrogen/generated/ios/swift/{Func_void_std__string.swift → Func_void_CallEventType_std__string.swift} +11 -11
  18. package/nitrogen/generated/ios/swift/HybridCallManagerSpec.swift +1 -1
  19. package/nitrogen/generated/ios/swift/HybridCallManagerSpec_cxx.swift +5 -5
  20. package/nitrogen/generated/shared/c++/HybridCallManagerSpec.hpp +1 -1
  21. package/package.json +1 -1
  22. package/src/CallManager.nitro.ts +1 -2
  23. package/src/index.tsx +2 -3
  24. package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +0 -75
@@ -5,6 +5,9 @@ import com.facebook.proguard.annotations.DoNotStrip
5
5
  @DoNotStrip
6
6
  class CallManager : HybridCallManagerSpec() {
7
7
 
8
+ // Store the current listener so we can remove it
9
+ private var currentListener: ((CallEventType, String) -> Unit)? = null
10
+
8
11
  override fun endCall(callId: String) {
9
12
  CallEngine.endCall(CallEngine.appContext ?: return, callId)
10
13
  }
@@ -29,18 +32,17 @@ class CallManager : HybridCallManagerSpec() {
29
32
  }
30
33
 
31
34
  override fun addListener(
32
- event: CallEventType,
33
- listener: (payload: String) -> Unit
35
+ listener: (event: CallEventType, payload: String) -> Unit
34
36
  ): () -> Unit {
35
- // Register the event handler for this event type
36
- val handler: (CallEventType, String) -> Unit = { type, payload ->
37
- if (type == event) listener(payload)
38
- }
39
- CallEngine.setEventHandler(handler)
37
+ // Register the single listener for all events
38
+ currentListener = listener
39
+ CallEngine.setEventHandler(listener)
40
40
  // Return a remove function
41
41
  return {
42
- // Remove the handler (set to null or implement a more advanced listener registry)
43
- CallEngine.setEventHandler(null)
42
+ if (currentListener === listener) {
43
+ CallEngine.setEventHandler(null)
44
+ currentListener = null
45
+ }
44
46
  }
45
47
  }
46
48
  }
@@ -12,6 +12,6 @@ export const setAudioRoute = CallManagerHybridObject.setAudioRoute;
12
12
  export const keepScreenAwake = CallManagerHybridObject.keepScreenAwake;
13
13
 
14
14
  // Event emitter: addListener returns a remove function
15
- export const addCallManagerListener = (event, listener) => CallManagerHybridObject.addListener(event, listener);
15
+ export const addCallManagerListener = listener => CallManagerHybridObject.addListener(listener);
16
16
  export { CallEventType };
17
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NitroModules","CallEventType","CallManagerHybridObject","createHybridObject","endCall","silenceRingtone","getAudioDevices","setAudioRoute","keepScreenAwake","addCallManagerListener","event","listener","addListener"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAEzD,SAASC,aAAa,QAAQ,oBAAiB;AAE/C,MAAMC,uBAAuB,GAC3BF,YAAY,CAACG,kBAAkB,CAAc,aAAa,CAAC;;AAE7D;AACA,OAAO,MAAMC,OAAO,GAAGF,uBAAuB,CAACE,OAAO;AACtD,OAAO,MAAMC,eAAe,GAAGH,uBAAuB,CAACG,eAAe;AAEtE,OAAO,MAAMC,eAAe,GAAGJ,uBAAuB,CAACI,eAAe;AACtE,OAAO,MAAMC,aAAa,GAAGL,uBAAuB,CAACK,aAAa;AAClE,OAAO,MAAMC,eAAe,GAAGN,uBAAuB,CAACM,eAAe;;AAEtE;AACA,OAAO,MAAMC,sBAAsB,GAAGA,CACpCC,KAAoB,EACpBC,QAAmC,KACpBT,uBAAuB,CAACU,WAAW,CAACF,KAAK,EAAEC,QAAQ,CAAC;AAErE,SAASV,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["NitroModules","CallEventType","CallManagerHybridObject","createHybridObject","endCall","silenceRingtone","getAudioDevices","setAudioRoute","keepScreenAwake","addCallManagerListener","listener","addListener"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAEzD,SAASC,aAAa,QAAQ,oBAAiB;AAE/C,MAAMC,uBAAuB,GAC3BF,YAAY,CAACG,kBAAkB,CAAc,aAAa,CAAC;;AAE7D;AACA,OAAO,MAAMC,OAAO,GAAGF,uBAAuB,CAACE,OAAO;AACtD,OAAO,MAAMC,eAAe,GAAGH,uBAAuB,CAACG,eAAe;AAEtE,OAAO,MAAMC,eAAe,GAAGJ,uBAAuB,CAACI,eAAe;AACtE,OAAO,MAAMC,aAAa,GAAGL,uBAAuB,CAACK,aAAa;AAClE,OAAO,MAAMC,eAAe,GAAGN,uBAAuB,CAACM,eAAe;;AAEtE;AACA,OAAO,MAAMC,sBAAsB,GACjCC,QAAyD,IAC1CR,uBAAuB,CAACS,WAAW,CAACD,QAAQ,CAAC;AAE9D,SAAST,aAAa","ignoreList":[]}
@@ -9,6 +9,6 @@ export interface CallManager extends HybridObject<{
9
9
  getAudioDevices(): string[];
10
10
  setAudioRoute(route: string): void;
11
11
  keepScreenAwake(keepAwake: boolean): void;
12
- addListener(event: CallEventType, listener: (payload: string) => void): () => void;
12
+ addListener(listener: (event: CallEventType, payload: string) => void): () => void;
13
13
  }
14
14
  //# sourceMappingURL=CallManager.nitro.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CallManager.nitro.d.ts","sourceRoot":"","sources":["../../../src/CallManager.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,WAAW,WAAY,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IAEpF,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,IAAI,IAAI,CAAC;IAGxB,eAAe,IAAI,MAAM,EAAE,CAAC;IAC5B,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,eAAe,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAG1C,WAAW,CACT,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAClC,MAAM,IAAI,CAAC;CACf"}
1
+ {"version":3,"file":"CallManager.nitro.d.ts","sourceRoot":"","sources":["../../../src/CallManager.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,WAAW,WAAY,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IAEpF,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,IAAI,IAAI,CAAC;IAGxB,eAAe,IAAI,MAAM,EAAE,CAAC;IAC5B,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,eAAe,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAG1C,WAAW,CACT,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GACxD,MAAM,IAAI,CAAC;CACf"}
@@ -4,6 +4,6 @@ export declare const silenceRingtone: () => void;
4
4
  export declare const getAudioDevices: () => string[];
5
5
  export declare const setAudioRoute: (route: string) => void;
6
6
  export declare const keepScreenAwake: (keepAwake: boolean) => void;
7
- export declare const addCallManagerListener: (event: CallEventType, listener: (payload: string) => void) => () => void;
7
+ export declare const addCallManagerListener: (listener: (event: CallEventType, payload: string) => void) => () => void;
8
8
  export { CallEventType };
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD,eAAO,MAAM,OAAO,0BAAkC,CAAC;AACvD,eAAO,MAAM,eAAe,YAA0C,CAAC;AAEvE,eAAO,MAAM,eAAe,gBAA0C,CAAC;AACvE,eAAO,MAAM,aAAa,yBAAwC,CAAC;AACnE,eAAO,MAAM,eAAe,8BAA0C,CAAC;AAGvE,eAAO,MAAM,sBAAsB,GACjC,OAAO,aAAa,EACpB,UAAU,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,KAClC,MAAM,IAA4D,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD,eAAO,MAAM,OAAO,0BAAkC,CAAC;AACvD,eAAO,MAAM,eAAe,YAA0C,CAAC;AAEvE,eAAO,MAAM,eAAe,gBAA0C,CAAC;AACvE,eAAO,MAAM,aAAa,yBAAwC,CAAC;AACnE,eAAO,MAAM,eAAe,8BAA0C,CAAC;AAGvE,eAAO,MAAM,sBAAsB,GACjC,UAAU,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,KACxD,MAAM,IAAqD,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,77 @@
1
+ ///
2
+ /// JFunc_void_CallEventType_std__string.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include <functional>
14
+ #include "CallEventType.hpp"
15
+ #include <string>
16
+ #include "JCallEventType.hpp"
17
+
18
+ namespace margelo::nitro::qusaieilouti99_callmanager {
19
+
20
+ using namespace facebook;
21
+
22
+ /**
23
+ * Represents the Java/Kotlin callback `(event: CallEventType, payload: String) -> Unit`.
24
+ * This can be passed around between C++ and Java/Kotlin.
25
+ */
26
+ struct JFunc_void_CallEventType_std__string: public jni::JavaClass<JFunc_void_CallEventType_std__string> {
27
+ public:
28
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/qusaieilouti99/callmanager/Func_void_CallEventType_std__string;";
29
+
30
+ public:
31
+ /**
32
+ * Invokes the function this `JFunc_void_CallEventType_std__string` instance holds through JNI.
33
+ */
34
+ void invoke(CallEventType event, const std::string& payload) const {
35
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JCallEventType> /* event */, jni::alias_ref<jni::JString> /* payload */)>("invoke");
36
+ method(self(), JCallEventType::fromCpp(event), jni::make_jstring(payload));
37
+ }
38
+ };
39
+
40
+ /**
41
+ * An implementation of Func_void_CallEventType_std__string that is backed by a C++ implementation (using `std::function<...>`)
42
+ */
43
+ struct JFunc_void_CallEventType_std__string_cxx final: public jni::HybridClass<JFunc_void_CallEventType_std__string_cxx, JFunc_void_CallEventType_std__string> {
44
+ public:
45
+ static jni::local_ref<JFunc_void_CallEventType_std__string::javaobject> fromCpp(const std::function<void(CallEventType /* event */, const std::string& /* payload */)>& func) {
46
+ return JFunc_void_CallEventType_std__string_cxx::newObjectCxxArgs(func);
47
+ }
48
+
49
+ public:
50
+ /**
51
+ * Invokes the C++ `std::function<...>` this `JFunc_void_CallEventType_std__string_cxx` instance holds.
52
+ */
53
+ void invoke_cxx(jni::alias_ref<JCallEventType> event, jni::alias_ref<jni::JString> payload) {
54
+ _func(event->toCpp(), payload->toStdString());
55
+ }
56
+
57
+ public:
58
+ [[nodiscard]]
59
+ inline const std::function<void(CallEventType /* event */, const std::string& /* payload */)>& getFunction() const {
60
+ return _func;
61
+ }
62
+
63
+ public:
64
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/qusaieilouti99/callmanager/Func_void_CallEventType_std__string_cxx;";
65
+ static void registerNatives() {
66
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_CallEventType_std__string_cxx::invoke_cxx)});
67
+ }
68
+
69
+ private:
70
+ explicit JFunc_void_CallEventType_std__string_cxx(const std::function<void(CallEventType /* event */, const std::string& /* payload */)>& func): _func(func) { }
71
+
72
+ private:
73
+ friend HybridBase;
74
+ std::function<void(CallEventType /* event */, const std::string& /* payload */)> _func;
75
+ };
76
+
77
+ } // namespace margelo::nitro::qusaieilouti99_callmanager
@@ -15,8 +15,8 @@ namespace margelo::nitro::qusaieilouti99_callmanager { enum class CallEventType;
15
15
  #include <functional>
16
16
  #include "JFunc_void.hpp"
17
17
  #include "CallEventType.hpp"
18
+ #include "JFunc_void_CallEventType_std__string.hpp"
18
19
  #include "JCallEventType.hpp"
19
- #include "JFunc_void_std__string.hpp"
20
20
 
21
21
  namespace margelo::nitro::qusaieilouti99_callmanager {
22
22
 
@@ -69,9 +69,9 @@ namespace margelo::nitro::qusaieilouti99_callmanager {
69
69
  static const auto method = javaClassStatic()->getMethod<void(jboolean /* keepAwake */)>("keepScreenAwake");
70
70
  method(_javaPart, keepAwake);
71
71
  }
72
- std::function<void()> JHybridCallManagerSpec::addListener(CallEventType event, const std::function<void(const std::string& /* payload */)>& listener) {
73
- static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>(jni::alias_ref<JCallEventType> /* event */, jni::alias_ref<JFunc_void_std__string::javaobject> /* listener */)>("addListener_cxx");
74
- auto __result = method(_javaPart, JCallEventType::fromCpp(event), JFunc_void_std__string_cxx::fromCpp(listener));
72
+ std::function<void()> JHybridCallManagerSpec::addListener(const std::function<void(CallEventType /* event */, const std::string& /* payload */)>& listener) {
73
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>(jni::alias_ref<JFunc_void_CallEventType_std__string::javaobject> /* listener */)>("addListener_cxx");
74
+ auto __result = method(_javaPart, JFunc_void_CallEventType_std__string_cxx::fromCpp(listener));
75
75
  return [&]() -> std::function<void()> {
76
76
  if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
77
77
  auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
@@ -56,7 +56,7 @@ namespace margelo::nitro::qusaieilouti99_callmanager {
56
56
  std::vector<std::string> getAudioDevices() override;
57
57
  void setAudioRoute(const std::string& route) override;
58
58
  void keepScreenAwake(bool keepAwake) override;
59
- std::function<void()> addListener(CallEventType event, const std::function<void(const std::string& /* payload */)>& listener) override;
59
+ std::function<void()> addListener(const std::function<void(CallEventType /* event */, const std::string& /* payload */)>& listener) override;
60
60
 
61
61
  private:
62
62
  friend HybridBase;
@@ -1,5 +1,5 @@
1
1
  ///
2
- /// Func_void_std__string.kt
2
+ /// Func_void_CallEventType_std__string.kt
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © 2025 Marc Rousavy @ Margelo
@@ -14,25 +14,25 @@ import com.margelo.nitro.core.*
14
14
  import dalvik.annotation.optimization.FastNative
15
15
 
16
16
  /**
17
- * Represents the JavaScript callback `(payload: string) => void`.
17
+ * Represents the JavaScript callback `(event: enum, payload: string) => void`.
18
18
  * This can be either implemented in C++ (in which case it might be a callback coming from JS),
19
19
  * or in Kotlin/Java (in which case it is a native callback).
20
20
  */
21
21
  @DoNotStrip
22
22
  @Keep
23
23
  @Suppress("ClassName", "RedundantUnitReturnType")
24
- fun interface Func_void_std__string: (String) -> Unit {
24
+ fun interface Func_void_CallEventType_std__string: (CallEventType, String) -> Unit {
25
25
  /**
26
26
  * Call the given JS callback.
27
27
  * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
28
28
  */
29
29
  @DoNotStrip
30
30
  @Keep
31
- override fun invoke(payload: String): Unit
31
+ override fun invoke(event: CallEventType, payload: String): Unit
32
32
  }
33
33
 
34
34
  /**
35
- * Represents the JavaScript callback `(payload: string) => void`.
35
+ * Represents the JavaScript callback `(event: enum, payload: string) => void`.
36
36
  * This is implemented in C++, via a `std::function<...>`.
37
37
  * The callback might be coming from JS.
38
38
  */
@@ -43,7 +43,7 @@ fun interface Func_void_std__string: (String) -> Unit {
43
43
  "RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
44
44
  "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
45
45
  )
46
- class Func_void_std__string_cxx: Func_void_std__string {
46
+ class Func_void_CallEventType_std__string_cxx: Func_void_CallEventType_std__string {
47
47
  @DoNotStrip
48
48
  @Keep
49
49
  private val mHybridData: HybridData
@@ -56,25 +56,25 @@ class Func_void_std__string_cxx: Func_void_std__string {
56
56
 
57
57
  @DoNotStrip
58
58
  @Keep
59
- override fun invoke(payload: String): Unit
60
- = invoke_cxx(payload)
59
+ override fun invoke(event: CallEventType, payload: String): Unit
60
+ = invoke_cxx(event,payload)
61
61
 
62
62
  @FastNative
63
- private external fun invoke_cxx(payload: String): Unit
63
+ private external fun invoke_cxx(event: CallEventType, payload: String): Unit
64
64
  }
65
65
 
66
66
  /**
67
- * Represents the JavaScript callback `(payload: string) => void`.
68
- * This is implemented in Java/Kotlin, via a `(String) -> Unit`.
67
+ * Represents the JavaScript callback `(event: enum, payload: string) => void`.
68
+ * This is implemented in Java/Kotlin, via a `(CallEventType, String) -> Unit`.
69
69
  * The callback is always coming from native.
70
70
  */
71
71
  @DoNotStrip
72
72
  @Keep
73
73
  @Suppress("ClassName", "RedundantUnitReturnType", "unused")
74
- class Func_void_std__string_java(private val function: (String) -> Unit): Func_void_std__string {
74
+ class Func_void_CallEventType_std__string_java(private val function: (CallEventType, String) -> Unit): Func_void_CallEventType_std__string {
75
75
  @DoNotStrip
76
76
  @Keep
77
- override fun invoke(payload: String): Unit {
78
- return this.function(payload)
77
+ override fun invoke(event: CallEventType, payload: String): Unit {
78
+ return this.function(event, payload)
79
79
  }
80
80
  }
@@ -60,12 +60,12 @@ abstract class HybridCallManagerSpec: HybridObject() {
60
60
  @Keep
61
61
  abstract fun keepScreenAwake(keepAwake: Boolean): Unit
62
62
 
63
- abstract fun addListener(event: CallEventType, listener: (payload: String) -> Unit): () -> Unit
63
+ abstract fun addListener(listener: (event: CallEventType, payload: String) -> Unit): () -> Unit
64
64
 
65
65
  @DoNotStrip
66
66
  @Keep
67
- private fun addListener_cxx(event: CallEventType, listener: Func_void_std__string): Func_void {
68
- val __result = addListener(event, listener)
67
+ private fun addListener_cxx(listener: Func_void_CallEventType_std__string): Func_void {
68
+ val __result = addListener(listener)
69
69
  return Func_void_java(__result)
70
70
  }
71
71
 
@@ -17,7 +17,7 @@
17
17
 
18
18
  #include "JHybridCallManagerSpec.hpp"
19
19
  #include "JFunc_void.hpp"
20
- #include "JFunc_void_std__string.hpp"
20
+ #include "JFunc_void_CallEventType_std__string.hpp"
21
21
  #include <NitroModules/JNISharedPtr.hpp>
22
22
  #include <NitroModules/DefaultConstructableObject.hpp>
23
23
 
@@ -32,7 +32,7 @@ int initialize(JavaVM* vm) {
32
32
  // Register native JNI methods
33
33
  margelo::nitro::qusaieilouti99_callmanager::JHybridCallManagerSpec::registerNatives();
34
34
  margelo::nitro::qusaieilouti99_callmanager::JFunc_void_cxx::registerNatives();
35
- margelo::nitro::qusaieilouti99_callmanager::JFunc_void_std__string_cxx::registerNatives();
35
+ margelo::nitro::qusaieilouti99_callmanager::JFunc_void_CallEventType_std__string_cxx::registerNatives();
36
36
 
37
37
  // Register Nitro Hybrid Objects
38
38
  HybridObjectRegistry::registerHybridObjectConstructor(
@@ -21,11 +21,11 @@ namespace margelo::nitro::qusaieilouti99_callmanager::bridge::swift {
21
21
  };
22
22
  }
23
23
 
24
- // pragma MARK: std::function<void(const std::string& /* payload */)>
25
- Func_void_std__string create_Func_void_std__string(void* _Nonnull swiftClosureWrapper) {
26
- auto swiftClosure = CallManager::Func_void_std__string::fromUnsafe(swiftClosureWrapper);
27
- return [swiftClosure = std::move(swiftClosure)](const std::string& payload) mutable -> void {
28
- swiftClosure.call(payload);
24
+ // pragma MARK: std::function<void(CallEventType /* event */, const std::string& /* payload */)>
25
+ Func_void_CallEventType_std__string create_Func_void_CallEventType_std__string(void* _Nonnull swiftClosureWrapper) {
26
+ auto swiftClosure = CallManager::Func_void_CallEventType_std__string::fromUnsafe(swiftClosureWrapper);
27
+ return [swiftClosure = std::move(swiftClosure)](CallEventType event, const std::string& payload) mutable -> void {
28
+ swiftClosure.call(static_cast<int>(event), payload);
29
29
  };
30
30
  }
31
31
 
@@ -8,6 +8,8 @@
8
8
  #pragma once
9
9
 
10
10
  // Forward declarations of C++ defined types
11
+ // Forward declaration of `CallEventType` to properly resolve imports.
12
+ namespace margelo::nitro::qusaieilouti99_callmanager { enum class CallEventType; }
11
13
  // Forward declaration of `HybridCallManagerSpec` to properly resolve imports.
12
14
  namespace margelo::nitro::qusaieilouti99_callmanager { class HybridCallManagerSpec; }
13
15
 
@@ -16,6 +18,7 @@ namespace margelo::nitro::qusaieilouti99_callmanager { class HybridCallManagerSp
16
18
  namespace CallManager { class HybridCallManagerSpec_cxx; }
17
19
 
18
20
  // Include C++ defined types
21
+ #include "CallEventType.hpp"
19
22
  #include "HybridCallManagerSpec.hpp"
20
23
  #include <NitroModules/Result.hpp>
21
24
  #include <exception>
@@ -63,26 +66,26 @@ namespace margelo::nitro::qusaieilouti99_callmanager::bridge::swift {
63
66
  return Func_void_Wrapper(std::move(value));
64
67
  }
65
68
 
66
- // pragma MARK: std::function<void(const std::string& /* payload */)>
69
+ // pragma MARK: std::function<void(CallEventType /* event */, const std::string& /* payload */)>
67
70
  /**
68
- * Specialized version of `std::function<void(const std::string&)>`.
71
+ * Specialized version of `std::function<void(CallEventType, const std::string&)>`.
69
72
  */
70
- using Func_void_std__string = std::function<void(const std::string& /* payload */)>;
73
+ using Func_void_CallEventType_std__string = std::function<void(CallEventType /* event */, const std::string& /* payload */)>;
71
74
  /**
72
- * Wrapper class for a `std::function<void(const std::string& / * payload * /)>`, this can be used from Swift.
75
+ * Wrapper class for a `std::function<void(CallEventType / * event * /, const std::string& / * payload * /)>`, this can be used from Swift.
73
76
  */
74
- class Func_void_std__string_Wrapper final {
77
+ class Func_void_CallEventType_std__string_Wrapper final {
75
78
  public:
76
- explicit Func_void_std__string_Wrapper(std::function<void(const std::string& /* payload */)>&& func): _function(std::make_unique<std::function<void(const std::string& /* payload */)>>(std::move(func))) {}
77
- inline void call(std::string payload) const {
78
- _function->operator()(payload);
79
+ explicit Func_void_CallEventType_std__string_Wrapper(std::function<void(CallEventType /* event */, const std::string& /* payload */)>&& func): _function(std::make_unique<std::function<void(CallEventType /* event */, const std::string& /* payload */)>>(std::move(func))) {}
80
+ inline void call(int event, std::string payload) const {
81
+ _function->operator()(static_cast<CallEventType>(event), payload);
79
82
  }
80
83
  private:
81
- std::unique_ptr<std::function<void(const std::string& /* payload */)>> _function;
84
+ std::unique_ptr<std::function<void(CallEventType /* event */, const std::string& /* payload */)>> _function;
82
85
  } SWIFT_NONCOPYABLE;
83
- Func_void_std__string create_Func_void_std__string(void* _Nonnull swiftClosureWrapper);
84
- inline Func_void_std__string_Wrapper wrap_Func_void_std__string(Func_void_std__string value) {
85
- return Func_void_std__string_Wrapper(std::move(value));
86
+ Func_void_CallEventType_std__string create_Func_void_CallEventType_std__string(void* _Nonnull swiftClosureWrapper);
87
+ inline Func_void_CallEventType_std__string_Wrapper wrap_Func_void_CallEventType_std__string(Func_void_CallEventType_std__string value) {
88
+ return Func_void_CallEventType_std__string_Wrapper(std::move(value));
86
89
  }
87
90
 
88
91
  // pragma MARK: std::shared_ptr<margelo::nitro::qusaieilouti99_callmanager::HybridCallManagerSpec>
@@ -91,8 +91,8 @@ namespace margelo::nitro::qusaieilouti99_callmanager {
91
91
  std::rethrow_exception(__result.error());
92
92
  }
93
93
  }
94
- inline std::function<void()> addListener(CallEventType event, const std::function<void(const std::string& /* payload */)>& listener) override {
95
- auto __result = _swiftPart.addListener(static_cast<int>(event), listener);
94
+ inline std::function<void()> addListener(const std::function<void(CallEventType /* event */, const std::string& /* payload */)>& listener) override {
95
+ auto __result = _swiftPart.addListener(listener);
96
96
  if (__result.hasError()) [[unlikely]] {
97
97
  std::rethrow_exception(__result.error());
98
98
  }
@@ -1,5 +1,5 @@
1
1
  ///
2
- /// Func_void_std__string.swift
2
+ /// Func_void_CallEventType_std__string.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © 2025 Marc Rousavy @ Margelo
@@ -8,21 +8,21 @@
8
8
  import NitroModules
9
9
 
10
10
  /**
11
- * Wraps a Swift `(_ payload: String) -> Void` as a class.
11
+ * Wraps a Swift `(_ event: CallEventType, _ payload: String) -> Void` as a class.
12
12
  * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
13
  */
14
- public final class Func_void_std__string {
14
+ public final class Func_void_CallEventType_std__string {
15
15
  public typealias bridge = margelo.nitro.qusaieilouti99_callmanager.bridge.swift
16
16
 
17
- private let closure: (_ payload: String) -> Void
17
+ private let closure: (_ event: CallEventType, _ payload: String) -> Void
18
18
 
19
- public init(_ closure: @escaping (_ payload: String) -> Void) {
19
+ public init(_ closure: @escaping (_ event: CallEventType, _ payload: String) -> Void) {
20
20
  self.closure = closure
21
21
  }
22
22
 
23
23
  @inline(__always)
24
- public func call(payload: std.string) -> Void {
25
- self.closure(String(payload))
24
+ public func call(event: Int32, payload: std.string) -> Void {
25
+ self.closure(margelo.nitro.qusaieilouti99_callmanager.CallEventType(rawValue: event)!, String(payload))
26
26
  }
27
27
 
28
28
  /**
@@ -35,12 +35,12 @@ public final class Func_void_std__string {
35
35
  }
36
36
 
37
37
  /**
38
- * Casts an unsafe pointer to a `Func_void_std__string`.
39
- * The pointer has to be a retained opaque `Unmanaged<Func_void_std__string>`.
38
+ * Casts an unsafe pointer to a `Func_void_CallEventType_std__string`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_CallEventType_std__string>`.
40
40
  * This removes one strong reference from the object!
41
41
  */
42
42
  @inline(__always)
43
- public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string {
44
- return Unmanaged<Func_void_std__string>.fromOpaque(pointer).takeRetainedValue()
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_CallEventType_std__string {
44
+ return Unmanaged<Func_void_CallEventType_std__string>.fromOpaque(pointer).takeRetainedValue()
45
45
  }
46
46
  }
@@ -19,7 +19,7 @@ public protocol HybridCallManagerSpec_protocol: HybridObject {
19
19
  func getAudioDevices() throws -> [String]
20
20
  func setAudioRoute(route: String) throws -> Void
21
21
  func keepScreenAwake(keepAwake: Bool) throws -> Void
22
- func addListener(event: CallEventType, listener: @escaping (_ payload: String) -> Void) throws -> () -> Void
22
+ func addListener(listener: @escaping (_ event: CallEventType, _ payload: String) -> Void) throws -> () -> Void
23
23
  }
24
24
 
25
25
  /// See ``HybridCallManagerSpec``
@@ -163,12 +163,12 @@ public class HybridCallManagerSpec_cxx {
163
163
  }
164
164
 
165
165
  @inline(__always)
166
- public final func addListener(event: Int32, listener: bridge.Func_void_std__string) -> bridge.Result_std__function_void____ {
166
+ public final func addListener(listener: bridge.Func_void_CallEventType_std__string) -> bridge.Result_std__function_void____ {
167
167
  do {
168
- let __result = try self.__implementation.addListener(event: margelo.nitro.qusaieilouti99_callmanager.CallEventType(rawValue: event)!, listener: { () -> (String) -> Void in
169
- let __wrappedFunction = bridge.wrap_Func_void_std__string(listener)
170
- return { (__payload: String) -> Void in
171
- __wrappedFunction.call(std.string(__payload))
168
+ let __result = try self.__implementation.addListener(listener: { () -> (CallEventType, String) -> Void in
169
+ let __wrappedFunction = bridge.wrap_Func_void_CallEventType_std__string(listener)
170
+ return { (__event: CallEventType, __payload: String) -> Void in
171
+ __wrappedFunction.call(__event.rawValue, std.string(__payload))
172
172
  }
173
173
  }())
174
174
  let __resultCpp = { () -> bridge.Func_void in
@@ -57,7 +57,7 @@ namespace margelo::nitro::qusaieilouti99_callmanager {
57
57
  virtual std::vector<std::string> getAudioDevices() = 0;
58
58
  virtual void setAudioRoute(const std::string& route) = 0;
59
59
  virtual void keepScreenAwake(bool keepAwake) = 0;
60
- virtual std::function<void()> addListener(CallEventType event, const std::function<void(const std::string& /* payload */)>& listener) = 0;
60
+ virtual std::function<void()> addListener(const std::function<void(CallEventType /* event */, const std::string& /* payload */)>& listener) = 0;
61
61
 
62
62
  protected:
63
63
  // Hybrid Setup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qusaieilouti99/call-manager",
3
- "version": "0.1.31",
3
+ "version": "0.1.32",
4
4
  "description": "Call manager",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -13,7 +13,6 @@ export interface CallManager extends HybridObject<{ ios: 'swift'; android: 'kotl
13
13
 
14
14
  // Event emitter: addListener returns a remove function
15
15
  addListener(
16
- event: CallEventType,
17
- listener: (payload: string) => void
16
+ listener: (event: CallEventType, payload: string) => void
18
17
  ): () => void;
19
18
  }
package/src/index.tsx CHANGED
@@ -15,8 +15,7 @@ export const keepScreenAwake = CallManagerHybridObject.keepScreenAwake;
15
15
 
16
16
  // Event emitter: addListener returns a remove function
17
17
  export const addCallManagerListener = (
18
- event: CallEventType,
19
- listener: (payload: string) => void
20
- ): () => void => CallManagerHybridObject.addListener(event, listener);
18
+ listener: (event: CallEventType, payload: string) => void
19
+ ): () => void => CallManagerHybridObject.addListener(listener);
21
20
 
22
21
  export { CallEventType };
@@ -1,75 +0,0 @@
1
- ///
2
- /// JFunc_void_std__string.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #include <fbjni/fbjni.h>
11
- #include <functional>
12
-
13
- #include <functional>
14
- #include <string>
15
-
16
- namespace margelo::nitro::qusaieilouti99_callmanager {
17
-
18
- using namespace facebook;
19
-
20
- /**
21
- * Represents the Java/Kotlin callback `(payload: String) -> Unit`.
22
- * This can be passed around between C++ and Java/Kotlin.
23
- */
24
- struct JFunc_void_std__string: public jni::JavaClass<JFunc_void_std__string> {
25
- public:
26
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/qusaieilouti99/callmanager/Func_void_std__string;";
27
-
28
- public:
29
- /**
30
- * Invokes the function this `JFunc_void_std__string` instance holds through JNI.
31
- */
32
- void invoke(const std::string& payload) const {
33
- static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* payload */)>("invoke");
34
- method(self(), jni::make_jstring(payload));
35
- }
36
- };
37
-
38
- /**
39
- * An implementation of Func_void_std__string that is backed by a C++ implementation (using `std::function<...>`)
40
- */
41
- struct JFunc_void_std__string_cxx final: public jni::HybridClass<JFunc_void_std__string_cxx, JFunc_void_std__string> {
42
- public:
43
- static jni::local_ref<JFunc_void_std__string::javaobject> fromCpp(const std::function<void(const std::string& /* payload */)>& func) {
44
- return JFunc_void_std__string_cxx::newObjectCxxArgs(func);
45
- }
46
-
47
- public:
48
- /**
49
- * Invokes the C++ `std::function<...>` this `JFunc_void_std__string_cxx` instance holds.
50
- */
51
- void invoke_cxx(jni::alias_ref<jni::JString> payload) {
52
- _func(payload->toStdString());
53
- }
54
-
55
- public:
56
- [[nodiscard]]
57
- inline const std::function<void(const std::string& /* payload */)>& getFunction() const {
58
- return _func;
59
- }
60
-
61
- public:
62
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/qusaieilouti99/callmanager/Func_void_std__string_cxx;";
63
- static void registerNatives() {
64
- registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__string_cxx::invoke_cxx)});
65
- }
66
-
67
- private:
68
- explicit JFunc_void_std__string_cxx(const std::function<void(const std::string& /* payload */)>& func): _func(func) { }
69
-
70
- private:
71
- friend HybridBase;
72
- std::function<void(const std::string& /* payload */)> _func;
73
- };
74
-
75
- } // namespace margelo::nitro::qusaieilouti99_callmanager