@poolse/native 3.6.2 → 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +119 -7
- package/android/src/main/java/dev/poolse/callcore/Ports.kt +2 -0
- package/android/src/main/java/dev/poolse/callcore/android/AndroidRingSurface.kt +30 -2
- package/android/src/main/java/dev/poolse/callcore/android/CallCore.kt +59 -6
- package/android/src/main/java/dev/poolse/callcore/android/CallMessagingService.kt +7 -0
- package/android/src/main/java/dev/poolse/callcore/android/IncomingCallActivity.kt +112 -12
- package/android/src/main/java/dev/poolse/callcore/android/IncomingCallLook.kt +107 -0
- package/android/src/main/java/dev/poolse/callcore/android/PoolseIncomingCall.kt +98 -0
- package/android/src/main/java/dev/poolse/callcore/android/RingBundle.kt +3 -0
- package/android/src/main/java/expo/modules/poolsecalls/PoolseCallsModule.kt +5 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.js.map +1 -1
- package/ios/Module/PoolseCallsModule.swift +2 -0
- package/ios/Platform/CallKitController.swift +12 -0
- package/ios/Platform/CallRingtone.swift +86 -0
- package/package.json +1 -1
- package/plugin/bundledSound.js +86 -0
- package/plugin/index.js +14 -0
- package/plugin/withIncomingCall.js +74 -0
- package/plugin/withRingback.js +6 -80
- package/plugin/withRingtone.js +101 -0
- package/src/index.ts +41 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
package dev.poolse.callcore.android
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.content.Intent
|
|
5
|
+
import android.graphics.Color
|
|
6
|
+
import android.util.Log
|
|
7
|
+
import java.net.URLEncoder
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* How the full-screen incoming call looks, or which activity replaces it.
|
|
11
|
+
*
|
|
12
|
+
* Each field comes from `configure({ incomingCall })` (persisted) or, when
|
|
13
|
+
* that leaves it out, from the config plugin's `incomingCall` option
|
|
14
|
+
* (application meta-data `dev.poolse.calls.incoming_*`), so a ring that
|
|
15
|
+
* wakes a closed app looks the same before any JS runs.
|
|
16
|
+
*/
|
|
17
|
+
data class IncomingCallLook(
|
|
18
|
+
/** The glow, the pulsing ring and the initials disc. */
|
|
19
|
+
val accentColor: Int = DEFAULT_ACCENT,
|
|
20
|
+
/** Whether [accentColor] was set by the app (the notification is tinted only then). */
|
|
21
|
+
val accentFromApp: Boolean = false,
|
|
22
|
+
val backgroundColor: Int = DEFAULT_BACKGROUND,
|
|
23
|
+
/**
|
|
24
|
+
* `https://cdn.example.com/avatars/{externalId}.jpg` — `{externalId}`
|
|
25
|
+
* (the caller's id in the app) and `{userId}` (the poolse user id) are
|
|
26
|
+
* filled in, URL-encoded. A push's own `caller_avatar_url` wins.
|
|
27
|
+
*/
|
|
28
|
+
val avatarUrlTemplate: String? = null,
|
|
29
|
+
/** Fully qualified class of the app's own ring activity, launched instead of the built-in one. */
|
|
30
|
+
val activityClass: String? = null,
|
|
31
|
+
) {
|
|
32
|
+
/** The caller's picture URL from the template, or null when a placeholder it needs is missing. */
|
|
33
|
+
fun avatarUrlFor(externalId: String?, userId: String?): String? {
|
|
34
|
+
val template = avatarUrlTemplate ?: return null
|
|
35
|
+
var url: String = template
|
|
36
|
+
for ((key, value) in listOf("{externalId}" to externalId, "{userId}" to userId)) {
|
|
37
|
+
if (!url.contains(key)) continue
|
|
38
|
+
val v = value?.ifEmpty { null } ?: return null
|
|
39
|
+
url = url.replace(key, URLEncoder.encode(v, "UTF-8").replace("+", "%20"))
|
|
40
|
+
}
|
|
41
|
+
return url.takeIf { it.startsWith("https://") || it.startsWith("http://") }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The app's activity as an explicit intent, or null (unset, or not in the manifest). */
|
|
45
|
+
internal fun customActivityIntent(context: Context): Intent? {
|
|
46
|
+
val name = activityClass ?: return null
|
|
47
|
+
val intent = Intent().setClassName(context.packageName, name)
|
|
48
|
+
if (context.packageManager.resolveActivity(intent, 0) == null) {
|
|
49
|
+
Log.w(TAG, "incomingCall.activity $name is not declared in the manifest — using the built-in screen")
|
|
50
|
+
return null
|
|
51
|
+
}
|
|
52
|
+
return intent
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
companion object {
|
|
56
|
+
val DEFAULT_ACCENT = Color.parseColor("#5B54E8")
|
|
57
|
+
val DEFAULT_BACKGROUND = Color.parseColor("#0B0B14")
|
|
58
|
+
private const val TAG = "PoolseIncomingCall"
|
|
59
|
+
|
|
60
|
+
internal const val META_ACCENT = "dev.poolse.calls.incoming_accent_color"
|
|
61
|
+
internal const val META_BACKGROUND = "dev.poolse.calls.incoming_background_color"
|
|
62
|
+
internal const val META_AVATAR = "dev.poolse.calls.incoming_avatar_url"
|
|
63
|
+
internal const val META_ACTIVITY = "dev.poolse.calls.incoming_activity"
|
|
64
|
+
|
|
65
|
+
/** `#RRGGBB`, `#AARRGGBB` or a colour name; null when unset or unreadable. */
|
|
66
|
+
internal fun parseColor(value: String?): Int? =
|
|
67
|
+
value?.ifEmpty { null }?.let { runCatching { Color.parseColor(it) }.getOrNull() }
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* aapt stores a meta-data value written as `#RRGGBB` as a colour INT,
|
|
71
|
+
* not the string — read both.
|
|
72
|
+
*/
|
|
73
|
+
private fun manifestColor(context: Context, name: String): Int? = runCatching {
|
|
74
|
+
val meta = context.packageManager
|
|
75
|
+
.getApplicationInfo(context.packageName, android.content.pm.PackageManager.GET_META_DATA)
|
|
76
|
+
.metaData ?: return null
|
|
77
|
+
when (val v = meta.get(name)) {
|
|
78
|
+
is Int -> v
|
|
79
|
+
is String -> parseColor(v)
|
|
80
|
+
else -> null
|
|
81
|
+
}
|
|
82
|
+
}.getOrNull()
|
|
83
|
+
|
|
84
|
+
/** Runtime values first, then the plugin's meta-data, then the built-in look. */
|
|
85
|
+
internal fun resolve(
|
|
86
|
+
context: Context,
|
|
87
|
+
accentColor: String?,
|
|
88
|
+
backgroundColor: String?,
|
|
89
|
+
avatarUrl: String?,
|
|
90
|
+
activity: String?,
|
|
91
|
+
): IncomingCallLook {
|
|
92
|
+
fun pick(runtime: String?, meta: String) = runtime?.ifEmpty { null } ?: CallCore.manifestValue(context, meta)
|
|
93
|
+
fun color(runtime: String?, meta: String) = parseColor(runtime) ?: manifestColor(context, meta)
|
|
94
|
+
val accent = color(accentColor, META_ACCENT)
|
|
95
|
+
val activityName = pick(activity, META_ACTIVITY)?.let {
|
|
96
|
+
if (it.startsWith(".")) context.packageName + it else it
|
|
97
|
+
}
|
|
98
|
+
return IncomingCallLook(
|
|
99
|
+
accentColor = accent ?: DEFAULT_ACCENT,
|
|
100
|
+
accentFromApp = accent != null,
|
|
101
|
+
backgroundColor = color(backgroundColor, META_BACKGROUND) ?: DEFAULT_BACKGROUND,
|
|
102
|
+
avatarUrlTemplate = pick(avatarUrl, META_AVATAR),
|
|
103
|
+
activityClass = activityName,
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
package dev.poolse.callcore.android
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.content.Intent
|
|
6
|
+
import dev.poolse.callcore.RingContext
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* For an app that replaces the built-in full-screen ring with its own
|
|
10
|
+
* activity (`incomingCall.activity`). That activity is launched by the
|
|
11
|
+
* ring notification's full-screen intent and heads-up tap with these
|
|
12
|
+
* extras, and answers or declines through the functions below — the same
|
|
13
|
+
* single entry point the built-in screen and the notification use.
|
|
14
|
+
*
|
|
15
|
+
* ```kotlin
|
|
16
|
+
* class RingActivity : Activity() {
|
|
17
|
+
* private var answered = false
|
|
18
|
+
* private val closed = object : BroadcastReceiver() {
|
|
19
|
+
* override fun onReceive(c: Context, i: Intent) {
|
|
20
|
+
* if (!answered && i.getStringExtra(PoolseIncomingCall.EXTRA_CALL_ID) ==
|
|
21
|
+
* intent.getStringExtra(PoolseIncomingCall.EXTRA_CALL_ID)) finish()
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* override fun onCreate(b: Bundle?) {
|
|
25
|
+
* super.onCreate(b)
|
|
26
|
+
* setShowWhenLocked(true); setTurnScreenOn(true)
|
|
27
|
+
* if (!PoolseIncomingCall.isLive(this, intent)) return finish()
|
|
28
|
+
* ContextCompat.registerReceiver(this, closed,
|
|
29
|
+
* IntentFilter(PoolseIncomingCall.ACTION_RING_CLOSED), ContextCompat.RECEIVER_NOT_EXPORTED)
|
|
30
|
+
* // … draw it from the EXTRA_* values …
|
|
31
|
+
* answerButton.setOnClickListener {
|
|
32
|
+
* answered = PoolseIncomingCall.answer(this, intent)
|
|
33
|
+
* if (!answered) finish() // else finish in onStop, once the app is in front
|
|
34
|
+
* }
|
|
35
|
+
* declineButton.setOnClickListener { PoolseIncomingCall.decline(this, intent); finish() }
|
|
36
|
+
* }
|
|
37
|
+
* override fun onStop() { super.onStop(); if (answered) finish() }
|
|
38
|
+
* override fun onDestroy() { runCatching { unregisterReceiver(closed) }; super.onDestroy() }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
object PoolseIncomingCall {
|
|
43
|
+
const val EXTRA_CALL_ID = AndroidRingSurface.EXTRA_CALL_ID
|
|
44
|
+
const val EXTRA_CONVERSATION_ID = "poolse_conversation_id"
|
|
45
|
+
/** The conversation's name (a group's title), when it has one. */
|
|
46
|
+
const val EXTRA_CONVERSATION_NAME = "poolse_conversation_name"
|
|
47
|
+
const val EXTRA_CALLER_NAME = "poolse_caller_name"
|
|
48
|
+
/** The caller's picture: the push's `caller_avatar_url`, else `incomingCall.avatarUrl` filled in. */
|
|
49
|
+
const val EXTRA_CALLER_AVATAR_URL = "poolse_caller_avatar_url"
|
|
50
|
+
/** `audio` | `video`. */
|
|
51
|
+
const val EXTRA_MEDIA = "poolse_media"
|
|
52
|
+
/** Epoch ms the ring gives up at. */
|
|
53
|
+
const val EXTRA_RING_DEADLINE = "poolse_ring_deadline"
|
|
54
|
+
/** Package-local broadcast with [EXTRA_CALL_ID]: that ring is over (cancelled, answered elsewhere, timed out). */
|
|
55
|
+
const val ACTION_RING_CLOSED = AndroidRingSurface.ACTION_RING_CLOSED
|
|
56
|
+
|
|
57
|
+
/** True while the ring in [intent] can still be answered. */
|
|
58
|
+
@JvmStatic
|
|
59
|
+
fun isLive(context: Context, intent: Intent): Boolean {
|
|
60
|
+
val ring = ringOf(intent) ?: return false
|
|
61
|
+
return CallCore.getOrNull(context)?.isRingLive(ring) ?: false
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Answer the ring in [intent] and bring the app forward from [activity]
|
|
66
|
+
* (only a foreground activity may). Returns whether the app was started;
|
|
67
|
+
* finish [activity] once it is covered (onStop), not at once — finishing
|
|
68
|
+
* immediately dropped the launch on some OEMs.
|
|
69
|
+
*/
|
|
70
|
+
@JvmStatic
|
|
71
|
+
fun answer(activity: Activity, intent: Intent): Boolean {
|
|
72
|
+
val ring = ringOf(intent) ?: return false
|
|
73
|
+
val core = CallCore.getOrNull(activity) ?: return false
|
|
74
|
+
if (!core.isRingLive(ring)) return false
|
|
75
|
+
return core.onUserAnswer(ring, activity)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Decline the ring in [intent]. */
|
|
79
|
+
@JvmStatic
|
|
80
|
+
fun decline(context: Context, intent: Intent) {
|
|
81
|
+
val ring = ringOf(intent) ?: return
|
|
82
|
+
CallCore.getOrNull(context)?.onUserDecline(ring)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
internal fun ringOf(intent: Intent): RingContext? =
|
|
86
|
+
intent.getBundleExtra(AndroidRingSurface.EXTRA_RING)?.toRingContext()
|
|
87
|
+
|
|
88
|
+
/** The ring as extras: the opaque bundle the functions above read, plus plain values to draw. */
|
|
89
|
+
internal fun fill(intent: Intent, ring: RingContext): Intent = intent
|
|
90
|
+
.putExtra(AndroidRingSurface.EXTRA_RING, ring.toBundle())
|
|
91
|
+
.putExtra(EXTRA_CALL_ID, ring.callId)
|
|
92
|
+
.putExtra(EXTRA_CONVERSATION_ID, ring.conversationId)
|
|
93
|
+
.putExtra(EXTRA_CONVERSATION_NAME, ring.conversationName)
|
|
94
|
+
.putExtra(EXTRA_CALLER_NAME, ring.callerName)
|
|
95
|
+
.putExtra(EXTRA_CALLER_AVATAR_URL, ring.callerAvatarUrl)
|
|
96
|
+
.putExtra(EXTRA_MEDIA, ring.media)
|
|
97
|
+
.putExtra(EXTRA_RING_DEADLINE, ring.ringDeadlineEpochMs)
|
|
98
|
+
}
|
|
@@ -16,6 +16,7 @@ internal fun RingContext.toBundle(): Bundle = Bundle().apply {
|
|
|
16
16
|
putString(K_MEDIA, media)
|
|
17
17
|
putString(K_GRANT, grant)
|
|
18
18
|
putLong(K_DEADLINE, ringDeadlineEpochMs)
|
|
19
|
+
putString(K_AVATAR, callerAvatarUrl)
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
internal fun Bundle.toRingContext(): RingContext? {
|
|
@@ -30,6 +31,7 @@ internal fun Bundle.toRingContext(): RingContext? {
|
|
|
30
31
|
media = getString(K_MEDIA) ?: "audio",
|
|
31
32
|
grant = grant,
|
|
32
33
|
ringDeadlineEpochMs = getLong(K_DEADLINE),
|
|
34
|
+
callerAvatarUrl = getString(K_AVATAR),
|
|
33
35
|
)
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -40,3 +42,4 @@ private const val K_CALLER_NAME = "callerName"
|
|
|
40
42
|
private const val K_MEDIA = "media"
|
|
41
43
|
private const val K_GRANT = "grant"
|
|
42
44
|
private const val K_DEADLINE = "ringDeadline"
|
|
45
|
+
private const val K_AVATAR = "callerAvatarUrl"
|
|
@@ -85,6 +85,11 @@ class PoolseCallsModule : Module() {
|
|
|
85
85
|
apiBaseUrl,
|
|
86
86
|
options?.get("smallIcon") as? String,
|
|
87
87
|
options?.get("ringback") as? String,
|
|
88
|
+
options?.get("ringtone") as? String,
|
|
89
|
+
(options?.get("incomingCall") as? Map<*, *>)
|
|
90
|
+
?.entries
|
|
91
|
+
?.associate { (k, v) -> k.toString() to (v as? String) }
|
|
92
|
+
?: emptyMap(),
|
|
88
93
|
)
|
|
89
94
|
// Materialise the core now, so a call already in flight (cold
|
|
90
95
|
// answer) is visible to the first getCallState.
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["requireOptionalNativeModule","requireNativeViewManager","createElement","View"],"mappings":";;;;;;;AAqPA,IAAM,MAAA,GAASA,4CAA+C,aAAa,CAAA;AAGpE,IAAM,uBAAuB,MAAA,IAAU;AAG9C,IAAI,SAAA,GAA2B,IAAA;AAG/B,eAAsB,SAAA,CAAU,YAAoB,OAAA,EAA2C;AAC7F,EAAA,SAAA,GAAY,UAAA,CAAW,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AACzC,EAAA,MAAM,MAAA,EAAQ,SAAA,CAAU,UAAA,EAAY,OAAA,IAAW,IAAI,CAAA;AACrD;AAGO,SAAS,YAAA,GAAgC;AAC9C,EAAA,OAAO,MAAA,EAAQ,YAAA,EAAa,CAAE,QAAA,IAAY,IAAA;AAC5C;AAKO,SAAS,YAAY,EAAA,EAAsD;AAChF,EAAA,IAAI,CAAC,MAAA,EAAQ,OAAO,MAAM,MAAA;AAC1B,EAAA,MAAM,GAAA,GAAM,OAAO,WAAA,CAAY,aAAA,EAAe,CAAC,OAAA,KAAY,EAAA,CAAG,OAAA,CAAQ,QAAQ,CAAC,CAAA;AAC/E,EAAA,OAAO,MAAM,IAAI,MAAA,EAAO;AAC1B;AAEO,SAAS,KAAA,CAAM,gBAAwB,OAAA,EAAsC;AAClF,EAAA,OAAO,MAAA,EAAQ,MAAM,cAAA,EAAgB,OAAA,CAAQ,OAAO,OAAA,CAAQ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,6BAA4B,IAAK,KAAA;AAClD;AAGO,SAAS,mBAAmB,EAAA,EAA4C;AAC7E,EAAA,IAAI,CAAC,MAAA,EAAQ,0BAAA,EAA4B,OAAO,MAAM,MAAA;AACtD,EAAA,MAAM,GAAA,GAAM,OAAO,WAAA,CAAY,oBAAA,EAAsB,CAAC,OAAA,KAAY,EAAA,CAAG,OAAA,CAAQ,MAAM,CAAC,CAAA;AACpF,EAAA,OAAO,MAAM,IAAI,MAAA,EAAO;AAC1B;AA2BA,IAAI,WAAA;AAGJ,SAAS,eAAA,GAA0D;AACjE,EAAA,IAAI,WAAA,KAAgB,QAAW,OAAO,WAAA;AACtC,EAAA,WAAA,GAAc,IAAA;AACd,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,IAAI;AACF,MAAA,WAAA,GAAcC,wCAAA,CAA2C,eAAe,iBAAiB,CAAA;AAAA,IAC3F,CAAA,CAAA,MAAQ;AACN,MAAA,WAAA,GAAc,IAAA;AAAA,IAChB;AAAA,EACF;AACA,EAAA,OAAO,WAAA;AACT;AAQO,SAAS,cAAc,KAAA,EAAgD;AAC5E,EAAA,MAAM,SAAS,eAAA,EAAgB;AAC/B,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM;AAAA,MACJ,aAAA,EAAe,EAAA;AAAA,MACf,KAAA,EAAO,EAAA;AAAA,MACP,MAAA,EAAQ,EAAA;AAAA,MACR,GAAA,EAAK,EAAA;AAAA,MACL,MAAA,EAAQ,EAAA;AAAA,MACR,gBAAA,EAAkB,IAAA;AAAA,MAClB,GAAG;AAAA,KACL,GAAI,KAAA;AACJ,IAAA,OAAOC,mBAAA,CAAcC,kBAAM,IAAI,CAAA;AAAA,EACjC;AACA,EAAA,OAAOD,mBAAA,CAAc,QAAQ,KAAK,CAAA;AACpC","file":"index.cjs","sourcesContent":["// @poolse/native — the React Native face of the native\n// call core (CALL_CONTRACT.md §8). A thin, typed surface over the native\n// module: commands in, one snapshot event out. All call logic lives in\n// the native cores; nothing here decides anything about a call.\n//\n// On a platform or build without the native module (Expo Go, web,\n// unlinked), every command is a safe no-op and the state stays idle —\n// so a host can render against this unconditionally.\nimport { createElement, type ComponentType, type ReactElement } from 'react';\nimport { View, type ViewProps } from 'react-native';\nimport { requireNativeViewManager, requireOptionalNativeModule } from 'expo-modules-core';\n\n/**\n * A call's complete state. `null` means idle — no call. After a call\n * ends the snapshot stays `phase: 'ended'` (with `reason`) for ~2.5 s,\n * then becomes `null`.\n */\nexport interface Snapshot {\n cv: 1;\n callId: string;\n conversationId: string;\n conversationName: string | null;\n direction: 'incoming' | 'outgoing' | 'joined';\n /**\n * `room` — rings nobody, joined and left at will (`startRoom`); `call`\n * otherwise. Known once the server answered: a room being joined reads\n * `call` while `connecting`. Absent before 0.9.0: treat as `call`.\n */\n kind?: 'call' | 'room';\n media: 'audio' | 'video';\n phase: 'ringing_in' | 'ringing_out' | 'connecting' | 'active' | 'reconnecting' | 'ended';\n reason?:\n | 'left'\n | 'finished'\n | 'declined_all'\n | 'busy_all'\n | 'no_answer'\n | 'cancelled'\n | 'connection_lost'\n | 'failed';\n /** REMOTE participants only; `userId` is the LiveKit identity. */\n participants: Array<{\n userId: string;\n externalId: string;\n speaking: boolean;\n muted: boolean;\n /** True only with a published, subscribed, unmuted camera track (show video, not avatar). */\n cameraOn: boolean;\n /**\n * Sharing their screen: draw it with `<CallVideoView source=\"screen\">`,\n * large and with `fit=\"contain\"`. Absent before 3.2.\n */\n screenSharing?: boolean;\n /**\n * Their link to the call: `lost` while they have dropped and are\n * coming back (show \"Reconnecting…\"), `poor` for a weak signal.\n * Absent before 0.11.0.\n */\n connectionQuality?: ConnectionQuality;\n }>;\n /** The kind of output playing now — the short answer to \"where is the audio\". */\n audioRoute: AudioOutputKind;\n /**\n * Every output the call can play through right now: always the phone\n * (earpiece, or wired headphones in its place) and the speaker, plus\n * each connected Bluetooth / USB device by its own name. Empty until\n * the call's audio is up. Pass an `id` to `setAudioOutput`.\n */\n audioOutputs: AudioOutput[];\n /** The `audioOutputs` entry playing now; null before audio is up. */\n audioOutputId: string | null;\n mutedSelf: boolean;\n /** True only while the local camera track is actually published and enabled. */\n cameraOn: boolean;\n /**\n * A second call ringing while this one is in progress (call waiting).\n * Offer `answerWaiting` (\"End & answer\" — this call ends) and\n * `declineWaiting` (its caller hears busy). If this call ends first,\n * the waiting one simply becomes the ringing call. null when none;\n * absent before 0.10.0.\n */\n waiting?: WaitingCall | null;\n /** Facing of the published local camera; absent when the camera is off. */\n cameraFacing?: 'front' | 'back';\n /**\n * Your own link to the call. `poor` / `lost`: show a \"weak connection\"\n * hint; `phase: 'reconnecting'` is the hard version of the same thing.\n * Absent before 0.11.0.\n */\n connectionQuality?: ConnectionQuality;\n /**\n * Incoming video is switched off because your connection could not\n * carry it — the audio keeps going, and video comes back by itself\n * once the link has been good for a few seconds. Participants read\n * `cameraOn: false` meanwhile. Absent before 0.11.0.\n */\n videoPaused?: boolean;\n /** You are sharing your screen. Absent before 3.2. */\n screenSharing?: boolean;\n}\n\n/** `good` covers good and excellent; `unknown` until the SFU has measured. */\nexport type ConnectionQuality = 'good' | 'poor' | 'lost' | 'unknown';\n\nexport type AudioOutputKind = 'earpiece' | 'speaker' | 'bluetooth' | 'headset';\n\n/** The call waiting beside the current one. */\nexport interface WaitingCall {\n callId: string;\n conversationId: string | null;\n conversationName: string | null;\n callerName: string | null;\n media: 'audio' | 'video';\n}\n\n/** One place call audio can play. */\nexport interface AudioOutput {\n /** Opaque; stable while the device stays connected. */\n id: string;\n kind: AudioOutputKind;\n /**\n * The device's own name for Bluetooth/USB (\"AirPods Pro\"); a plain\n * English default for built-ins (\"iPhone\"/\"Phone\", \"Speaker\",\n * \"Headphones\") — relabel those by `kind` to localise.\n */\n name: string;\n}\n\nexport interface ConfigureOptions {\n /** Drawable resource NAME for the call notification's small icon. */\n smallIcon?: string;\n /** Ringback tone: raw resource NAME (Android); main-bundle sound name, mp3/caf/wav (iOS). */\n ringback?: string;\n /**\n * iOS: the APNs environment of this build's `aps-environment`\n * entitlement. Echoed back with the VoIP token so the server pushes to\n * the right gateway. Ignored on Android.\n */\n apnsEnvironment?: 'production' | 'sandbox';\n}\n\n/** The iOS PushKit (VoIP) token and the APNs environment it belongs to. */\nexport interface VoipToken {\n /** Hex-encoded PushKit token. */\n token: string;\n environment: 'production' | 'sandbox' | string;\n}\n\nexport interface PlaceOptions {\n media: 'audio' | 'video';\n /** The user's session token — authorizes placing/joining (CALL_CONTRACT.md §3.2). */\n sessionToken: string;\n}\n\n/**\n * What the user tapped on a missed-call notification: the notification\n * itself (`open` the conversation) or its Call back button (`call_back`\n * — place a call on the conversation with `media`).\n */\nexport interface CallAction {\n type: 'open' | 'call_back';\n conversationId: string;\n callId: string | null;\n media: 'audio' | 'video';\n}\n\n/**\n * A Reply or Mark as read the user did from a chat notification, after\n * the native core sent it (or gave up). The server has already posted\n * the reply and marked the conversation read; use this to refresh what\n * the app shows (insert the message, drop the unread count) without\n * waiting for the socket, or to tell the user a reply did not go out.\n */\nexport interface NotificationActionResult {\n action: 'reply' | 'mark_read';\n conversationId: string;\n /** Whether the server accepted it. */\n ok: boolean;\n /** Reply only: what the user typed. */\n text?: string;\n /** Reply only: the idempotency id sent with it — the message's id once posted. */\n clientId?: string;\n /** Reply, `ok` only: the posted message's id (equals `clientId`). */\n messageId?: string;\n /**\n * When not `ok`: the server's error code (`unauthorized`,\n * `device_signed_out`, `user_blocked`, `forbidden`, `not_found`,\n * `mau_cap_exceeded`, `validation_failed`, `rate_limited`), or\n * `network`, `no_grant` (the push carried no reply grant),\n * `not_configured` (never `configure`d), `http_<status>`.\n */\n error?: string;\n /** The HTTP status when the server answered with an error. */\n status?: number;\n /** When it finished, epoch ms. */\n at: number;\n}\n\ntype NativeSnapshot = { snapshot: Snapshot | null };\n\ninterface PoolseCallsNative {\n configure(apiBaseUrl: string, options: ConfigureOptions | null): Promise<void>;\n getCallState(): NativeSnapshot;\n place(conversationId: string, media: string, sessionToken: string): Promise<void>;\n join(callId: string, conversationId: string | null, sessionToken: string): Promise<void>;\n answer(): void;\n decline(): void;\n hangUp(): void;\n answerWaiting?(callId: string | null): void;\n declineWaiting?(callId: string | null): void;\n setMuted(muted: boolean): void;\n setCamera(on: boolean): void;\n switchCamera(): void;\n screenShareSupported?(): boolean;\n startScreenShare?(): Promise<boolean>;\n stopScreenShare?(): void;\n setSpeaker(on: boolean): void;\n setAudioOutput?(id: string): void;\n callControl?(): Promise<{ callId: string; controlToken: string } | null>;\n setPictureInPictureEnabled?(on: boolean): void;\n isInPictureInPicture?(): boolean;\n pictureInPictureSupported?(): boolean;\n onRingEnded(callId: string, reason: string): void;\n onCallFinished(callId: string, reason: string | null): void;\n canUseFullScreenIntent(): boolean;\n openFullScreenIntentSettings(): void;\n setShowOnLockscreen?(enabled: boolean): void;\n getVoipToken?(): VoipToken | null;\n takeCallAction?(): CallAction | null;\n setActiveConversation?(conversationId: string | null): void;\n takeNotificationActions?(): NotificationActionResult[];\n observeNotificationActions?(on: boolean): void;\n addListener(event: 'onCallState', cb: (payload: NativeSnapshot) => void): { remove(): void };\n addListener(event: 'onVoipToken', cb: (payload: VoipToken) => void): { remove(): void };\n addListener(event: 'onCallAction', cb: (payload: CallAction) => void): { remove(): void };\n addListener(\n event: 'onNotificationAction',\n cb: (payload: NotificationActionResult) => void,\n ): { remove(): void };\n addListener(\n event: 'onPictureInPicture',\n cb: (payload: { active: boolean }) => void,\n ): { remove(): void };\n}\n\nconst native = requireOptionalNativeModule<PoolseCallsNative>('PoolseCalls');\n\n/** True when the native call core is present in this build. */\nexport const nativeCallsAvailable = native != null;\n\n// Kept for startRoom, the one command that talks to the server from JS.\nlet apiOrigin: string | null = null;\n\n/** Configure once, before any call can arrive. No secrets — just the API origin. */\nexport async function configure(apiBaseUrl: string, options?: ConfigureOptions): Promise<void> {\n apiOrigin = apiBaseUrl.replace(/\\/+$/, '');\n await native?.configure(apiBaseUrl, options ?? null);\n}\n\n/** The current snapshot — safe to read at any moment, including cold answer and before configure. */\nexport function getCallState(): Snapshot | null {\n return native?.getCallState().snapshot ?? null;\n}\n\nexport type Unsubscribe = () => void;\n\n/** Subscribe to call state. Fires a full snapshot on every change. */\nexport function onCallState(cb: (snapshot: Snapshot | null) => void): Unsubscribe {\n if (!native) return () => undefined;\n const sub = native.addListener('onCallState', (payload) => cb(payload.snapshot));\n return () => sub.remove();\n}\n\nexport function place(conversationId: string, options: PlaceOptions): Promise<void> {\n return native?.place(conversationId, options.media, options.sessionToken) ?? Promise.resolve();\n}\n\nexport function join(\n callId: string,\n conversationId: string | null,\n sessionToken: string,\n): Promise<void> {\n return native?.join(callId, conversationId, sessionToken) ?? Promise.resolve();\n}\n\nexport interface StartRoomResult {\n /** The room's call id — what the Join banner and `call:*` events carry. */\n callId: string;\n /** False when something was live already (a room, or a ringing call) and this joined it. */\n created: boolean;\n}\n\n/**\n * Start the conversation's room — a call that rings nobody (CALL_CONTRACT.md\n * §5.6) — or join whatever is live there, then carry it on the native\n * core like any joined call: CallKit / the call service, so it keeps\n * going with the phone locked, and the same audio routing as a call.\n *\n * Others in the conversation see it through the Join banner and join it\n * with `join`. Leaving (`hangUp`) never ends it for them; it ends once\n * it has been empty for a short grace. `media: 'video'` makes it a video\n * room. Rejects when the server refuses (not a member, no SFU) or\n * before `configure`.\n */\nexport async function startRoom(\n conversationId: string,\n options: PlaceOptions,\n): Promise<StartRoomResult> {\n if (!native) throw new Error('The native call core is not in this build.');\n if (!apiOrigin) throw new Error('Call configure() before startRoom().');\n const res = await fetch(\n `${apiOrigin}/v1/conversations/${encodeURIComponent(conversationId)}/room`,\n {\n method: 'POST',\n headers: {\n authorization: `Bearer ${options.sessionToken}`,\n 'content-type': 'application/json',\n },\n body: JSON.stringify({ media: options.media }),\n },\n );\n const body = (await res.json().catch(() => null)) as {\n created?: boolean;\n call?: { id?: string };\n error?: { message?: string };\n } | null;\n const callId = body?.call?.id;\n if (!res.ok || !callId) {\n throw new Error(body?.error?.message ?? `Couldn't start the room (${res.status}).`);\n }\n // The core joins with its own request: it owns the session from here,\n // exactly as when the room is joined from the banner.\n await native.join(callId, conversationId, options.sessionToken);\n return { callId, created: body?.created === true };\n}\n\n/** Who to ring into the call — poolse user ids, your app's own (external) ids, or both. */\nexport interface RingIntoCallOptions {\n userIds?: string[];\n externalIds?: string[];\n}\n\n/**\n * Ring more of the conversation's members into the call you are on\n * (\"Add people\"). Each is rung as on a fresh call — their phone rings,\n * CallKit / full-screen — and answering puts them in this call.\n *\n * Resolves with the poolse user ids actually rung: anyone already in\n * the call, still ringing, or not a member of the conversation is\n * skipped. Rejects with no call in progress, while nobody has answered\n * yet (the call's own ring is still out), or when the server refuses.\n */\nexport async function ringIntoCall(people: RingIntoCallOptions): Promise<string[]> {\n if (!native?.callControl) throw new Error('This build cannot ring people into a call.');\n if (!apiOrigin) throw new Error('Call configure() before ringIntoCall().');\n const control = await native.callControl();\n if (!control) throw new Error('There is no call in progress.');\n const res = await fetch(`${apiOrigin}/v1/calls/${encodeURIComponent(control.callId)}/ring`, {\n method: 'POST',\n headers: {\n authorization: `Bearer ${control.controlToken}`,\n 'content-type': 'application/json',\n },\n body: JSON.stringify({\n user_ids: people.userIds ?? [],\n external_ids: people.externalIds ?? [],\n }),\n });\n const body = (await res.json().catch(() => null)) as {\n rung_user_ids?: string[];\n error?: { message?: string };\n } | null;\n if (!res.ok) throw new Error(body?.error?.message ?? `Couldn't ring them (${res.status}).`);\n return body?.rung_user_ids ?? [];\n}\n\nexport const answer = (): void => native?.answer();\nexport const decline = (): void => native?.decline();\nexport const hangUp = (): void => native?.hangUp();\n\n/**\n * Call waiting: end the current call and answer `snapshot.waiting`.\n * Pass its `callId`: a tap on a card for a call that is no longer the\n * one waiting is then ignored instead of answering a different call.\n */\nexport const answerWaiting = (callId?: string): void => native?.answerWaiting?.(callId ?? null);\n\n/** Call waiting: turn `snapshot.waiting` away — its caller hears busy. */\nexport const declineWaiting = (callId?: string): void => native?.declineWaiting?.(callId ?? null);\nexport const setMuted = (muted: boolean): void => native?.setMuted(muted);\nexport const setCamera = (on: boolean): void => native?.setCamera(on);\nexport const switchCamera = (): void => native?.switchCamera();\n\n/**\n * Whether this build can share the screen in a call: Android with the\n * LiveKit media engine; iOS when the app was built with the config\n * plugin's `screenShare` option (the broadcast extension). Every build\n * shows other people's screens.\n */\nexport const screenShareSupported = (): boolean => native?.screenShareSupported?.() ?? false;\n\n/**\n * Share the screen. Android asks the user first (the system's \"Start\n * recording or casting?\" prompt) and resolves `false` when they say no.\n * iOS shows the system's broadcast sheet and resolves `true` once it is\n * up; the user still has to tap Start Broadcast. Either way it resolves\n * `false` when the build cannot share, and `snapshot.screenSharing`\n * turns true only once the screen is actually going out. Stopping from\n * the system notification (Android) or the status bar (iOS) ends it the\n * same way.\n */\nexport const startScreenShare = async (): Promise<boolean> =>\n (await native?.startScreenShare?.()) ?? false;\n\nexport const stopScreenShare = (): void => native?.stopScreenShare?.();\n/** Route call audio to the loudspeaker (`true`) or back to earpiece / headset (`false`). */\nexport const setSpeaker = (on: boolean): void => native?.setSpeaker(on);\n\n/**\n * Play call audio through one of `snapshot.audioOutputs`. The choice\n * holds for the rest of the call, until that device disconnects or a new\n * headset / Bluetooth device connects (which takes over, as in the\n * phone's own dialer). Without a choice a connected headset wins, then\n * the earpiece for voice calls or the speaker for video.\n */\nexport function setAudioOutput(id: string): void {\n if (native?.setAudioOutput) native.setAudioOutput(id);\n else native?.setSpeaker(id === 'speaker'); // an older native build\n}\n\n/**\n * Socket forwarding for an open app: a `call:ring_ended` seen on the\n * socket. Idempotent with the push path — the core dedupes.\n */\nexport const onRingEnded = (callId: string, reason: string): void =>\n native?.onRingEnded(callId, reason);\n\n/**\n * Socket forwarding: `call:finished`. Pass the payload's `reason`\n * (`finished` | `declined_all` | `no_answer` | `cancelled`) so an\n * unanswered caller sees \"Declined\"/\"No answer\", not \"Call ended\".\n * Idempotent with the `finished` push.\n */\nexport const onCallFinished = (callId: string, reason?: string): void =>\n native?.onCallFinished(callId, reason ?? null);\n\n/**\n * Android 14+: whether the app may show the full-screen ring over the\n * lock screen. `true` on older Android and where the module is absent.\n */\nexport const canUseFullScreenIntent = (): boolean => native?.canUseFullScreenIntent() ?? true;\n\n/** Open the system screen where the user grants full-screen intents (falls back to notification settings). */\nexport const openFullScreenIntentSettings = (): void => native?.openFullScreenIntentSettings();\n\n/**\n * Android: let the app show over the lock screen while a call rings or\n * runs — answering must never demand an unlock. Turn it off when the\n * call ends. The activity re-applies it when the core relaunches it for\n * a call (`poolse_launch_call`), given the host's MainActivity hook.\n * No-op on iOS, where CallKit owns the lock screen.\n */\nexport function setShowOnLockscreen(enabled: boolean): void {\n try {\n native?.setShowOnLockscreen?.(enabled);\n } catch {\n // Never let a window flag take a call down.\n }\n}\n\n// ── missed-call notifications (Android) ─────────────────────────────────\n\n/**\n * Android: the missed-call notification action the app was LAUNCHED\n * with, once — read it on mount. `null` when the app opened any other\n * way. The native core posts that notification itself from the push,\n * so it works with the app closed.\n *\n * iOS shows missed calls as an ordinary alert push (to the token you\n * register with `kind: 'alert'`); read its taps with your notification\n * library — its `type` is `call_missed`, the category\n * `poolse_missed_call`, the Call back action `call_back`.\n */\nexport function takeCallAction(): CallAction | null {\n return native?.takeCallAction?.() ?? null;\n}\n\n/** Android: a missed-call notification tapped while the app is running. */\nexport function onCallAction(cb: (action: CallAction) => void): Unsubscribe {\n if (!native || !native.takeCallAction) return () => undefined;\n const sub = native.addListener('onCallAction', cb);\n return () => sub.remove();\n}\n\n// ── chat notifications ─────────────────────────────────────────────────\n\nlet activeConversation: string | null = null;\n\n/**\n * Tell the core which conversation is on screen (`null` when none, and\n * when the app goes to the background). Its messages are not notified —\n * the user is reading them — and opening it clears the notifications\n * already shown for it.\n */\nexport function setActiveConversation(conversationId: string | null): void {\n activeConversation = conversationId;\n native?.setActiveConversation?.(conversationId);\n}\n\n/**\n * For the app's notification handler (expo-notifications'\n * `setNotificationHandler`): `false` for a chat notification of the\n * conversation on screen, which must not pop over the chat itself.\n * Android never asks — the core skips those natively.\n */\nexport function shouldPresentMessage(data: Record<string, unknown> | undefined | null): boolean {\n if (!data || data['type'] !== 'message') return true;\n return data['conversation_id'] !== activeConversation;\n}\n\n/**\n * The conversation a tapped notification belongs to — a chat message\n * (`type: 'message'`) or a missed call (`call_missed`) — from its data.\n * iOS hands the tap to your notification library; Android delivers it\n * through `takeCallAction` / `onCallAction` (type `open`).\n */\nexport function conversationOfNotification(\n data: Record<string, unknown> | undefined | null,\n): string | null {\n if (!data) return null;\n const type = data['type'];\n if (type !== 'message' && type !== 'call_missed') return null;\n return typeof data['conversation_id'] === 'string' ? data['conversation_id'] : null;\n}\n\n/**\n * Reply and Mark as read from a chat notification are handled natively —\n * from the lock screen, with the app closed — using the grant the push\n * carried and the API origin given to `configure` (which persists it).\n * This fires once each finishes while the app is running. Read the ones\n * that finished while it was not with `takeNotificationActions` on mount.\n */\nexport function onNotificationAction(cb: (result: NotificationActionResult) => void): Unsubscribe {\n if (!native?.takeNotificationActions) return () => undefined;\n const sub = native.addListener('onNotificationAction', cb);\n if (actionObservers++ === 0) native.observeNotificationActions?.(true);\n let removed = false;\n return () => {\n if (removed) return;\n removed = true;\n sub.remove();\n if (--actionObservers === 0) native?.observeNotificationActions?.(false);\n };\n}\n\n// Native queues results until someone listens for them specifically.\nlet actionObservers = 0;\n\n/** `onNotificationAction`, replies only. */\nexport function onNotificationReply(cb: (result: NotificationActionResult) => void): Unsubscribe {\n return onNotificationAction((result) => {\n if (result.action === 'reply') cb(result);\n });\n}\n\n/**\n * The notification actions that finished while no `onNotificationAction`\n * listener was attached (usually: the app was not running), oldest\n * first, each returned once. Up to the last 50 are kept.\n */\nexport function takeNotificationActions(): NotificationActionResult[] {\n return native?.takeNotificationActions?.() ?? [];\n}\n\n// ── VoIP push (iOS) ───────────────────────────────────────────────────\n\n/**\n * iOS: the current PushKit VoIP token, registered natively at launch.\n * `null` until iOS issues one, and always on Android (FCM carries rings).\n */\nexport function getVoipToken(): VoipToken | null {\n return native?.getVoipToken?.() ?? null;\n}\n\n/** iOS: fires whenever PushKit issues (or rotates) the VoIP token. No-op on Android. */\nexport function onVoipToken(cb: (token: VoipToken) => void): Unsubscribe {\n if (!native || !native.getVoipToken) return () => undefined;\n const sub = native.addListener('onVoipToken', cb);\n return () => sub.remove();\n}\n\n// ── picture-in-picture ────────────────────────────────────────────────\n\n/**\n * Arm picture-in-picture: while on, leaving the app keeps the call's\n * video in a floating window. Turn it on only while a video call shows\n * someone's picture, and off otherwise.\n *\n * iOS (15+) floats the `<CallVideoView pictureInPicture>` that is on\n * screen — mark the main remote picture. Android (8+) floats the whole\n * app: draw a compact layout while `isInPictureInPicture()` (see\n * `onPictureInPicture`). The app needs `android:supportsPictureInPicture`\n * on its activity.\n */\nexport function setPictureInPictureEnabled(on: boolean): void {\n native?.setPictureInPictureEnabled?.(on);\n}\n\n/** Whether the floating window is open right now. */\nexport function isInPictureInPicture(): boolean {\n return native?.isInPictureInPicture?.() ?? false;\n}\n\n/** Whether this device can float a call at all. */\nexport function pictureInPictureSupported(): boolean {\n return native?.pictureInPictureSupported?.() ?? false;\n}\n\n/** Fires when the floating window opens (`true`) and closes (`false`). */\nexport function onPictureInPicture(cb: (active: boolean) => void): Unsubscribe {\n if (!native?.setPictureInPictureEnabled) return () => undefined;\n const sub = native.addListener('onPictureInPicture', (payload) => cb(payload.active));\n return () => sub.remove();\n}\n\n// ── video ─────────────────────────────────────────────────────────────\n\nexport interface CallVideoViewProps extends ViewProps {\n /** Remote participant's userId (LiveKit identity). Omit with local=true for self view. */\n participantId?: string;\n local?: boolean;\n /** default: true for local front camera, false otherwise */\n mirror?: boolean;\n /** default 'cover' */\n fit?: 'cover' | 'contain';\n /**\n * `camera` (default), or `screen`: the participant's shared screen\n * (with `local`, your own). A screen is never mirrored; draw it with\n * `fit=\"contain\"` so nothing is cropped.\n */\n source?: 'camera' | 'screen';\n /**\n * iOS: this remote picture is the one picture-in-picture floats when\n * the app is left (`setPictureInPictureEnabled`). Mark one at a time.\n */\n pictureInPicture?: boolean;\n}\n\ntype NativeVideoProps = CallVideoViewProps;\n\nlet nativeVideo: ComponentType<NativeVideoProps> | null | undefined;\n\n/** Resolved lazily (first render) and only when the native module exists. */\nfunction nativeVideoView(): ComponentType<NativeVideoProps> | null {\n if (nativeVideo !== undefined) return nativeVideo;\n nativeVideo = null;\n if (native) {\n try {\n nativeVideo = requireNativeViewManager<NativeVideoProps>('PoolseCalls', 'PoolseCallVideo');\n } catch {\n nativeVideo = null; // an older native build without the view\n }\n }\n return nativeVideo;\n}\n\n/**\n * A participant's camera (or, with `local`, your own), rendered natively\n * by the call core. Shows nothing (stays transparent) while that camera\n * is off — draw the avatar from the snapshot's `cameraOn` underneath.\n * Without the native module it renders an empty View.\n */\nexport function CallVideoView(props: CallVideoViewProps): ReactElement | null {\n const Native = nativeVideoView();\n if (!Native) {\n const {\n participantId: _p,\n local: _l,\n mirror: _m,\n fit: _f,\n source: _s,\n pictureInPicture: _pip,\n ...rest\n } = props;\n return createElement(View, rest);\n }\n return createElement(Native, props);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["requireOptionalNativeModule","requireNativeViewManager","createElement","View"],"mappings":";;;;;;;AA8RA,IAAM,MAAA,GAASA,4CAA+C,aAAa,CAAA;AAGpE,IAAM,uBAAuB,MAAA,IAAU;AAG9C,IAAI,SAAA,GAA2B,IAAA;AAG/B,eAAsB,SAAA,CAAU,YAAoB,OAAA,EAA2C;AAC7F,EAAA,SAAA,GAAY,UAAA,CAAW,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AACzC,EAAA,MAAM,MAAA,EAAQ,SAAA,CAAU,UAAA,EAAY,OAAA,IAAW,IAAI,CAAA;AACrD;AAGO,SAAS,YAAA,GAAgC;AAC9C,EAAA,OAAO,MAAA,EAAQ,YAAA,EAAa,CAAE,QAAA,IAAY,IAAA;AAC5C;AAKO,SAAS,YAAY,EAAA,EAAsD;AAChF,EAAA,IAAI,CAAC,MAAA,EAAQ,OAAO,MAAM,M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A,MACR,gBAAA,EAAkB,IAAA;AAAA,MAClB,GAAG;AAAA,KACL,GAAI,KAAA;AACJ,IAAA,OAAOC,mBAAA,CAAcC,kBAAM,IAAI,CAAA;AAAA,EACjC;AACA,EAAA,OAAOD,mBAAA,CAAc,QAAQ,KAAK,CAAA;AACpC","file":"index.cjs","sourcesContent":["// @poolse/native — the React Native face of the native\n// call core (CALL_CONTRACT.md §8). A thin, typed surface over the native\n// module: commands in, one snapshot event out. All call logic lives in\n// the native cores; nothing here decides anything about a call.\n//\n// On a platform or build without the native module (Expo Go, web,\n// unlinked), every command is a safe no-op and the state stays idle —\n// so a host can render against this unconditionally.\nimport { createElement, type ComponentType, type ReactElement } from 'react';\nimport { View, type ViewProps } from 'react-native';\nimport { requireNativeViewManager, requireOptionalNativeModule } from 'expo-modules-core';\n\n/**\n * A call's complete state. `null` means idle — no call. After a call\n * ends the snapshot stays `phase: 'ended'` (with `reason`) for ~2.5 s,\n * then becomes `null`.\n */\nexport interface Snapshot {\n cv: 1;\n callId: string;\n conversationId: string;\n conversationName: string | null;\n direction: 'incoming' | 'outgoing' | 'joined';\n /**\n * `room` — rings nobody, joined and left at will (`startRoom`); `call`\n * otherwise. Known once the server answered: a room being joined reads\n * `call` while `connecting`. Absent before 0.9.0: treat as `call`.\n */\n kind?: 'call' | 'room';\n media: 'audio' | 'video';\n phase: 'ringing_in' | 'ringing_out' | 'connecting' | 'active' | 'reconnecting' | 'ended';\n reason?:\n | 'left'\n | 'finished'\n | 'declined_all'\n | 'busy_all'\n | 'no_answer'\n | 'cancelled'\n | 'connection_lost'\n | 'failed';\n /** REMOTE participants only; `userId` is the LiveKit identity. */\n participants: Array<{\n userId: string;\n externalId: string;\n speaking: boolean;\n muted: boolean;\n /** True only with a published, subscribed, unmuted camera track (show video, not avatar). */\n cameraOn: boolean;\n /**\n * Sharing their screen: draw it with `<CallVideoView source=\"screen\">`,\n * large and with `fit=\"contain\"`. Absent before 3.2.\n */\n screenSharing?: boolean;\n /**\n * Their link to the call: `lost` while they have dropped and are\n * coming back (show \"Reconnecting…\"), `poor` for a weak signal.\n * Absent before 0.11.0.\n */\n connectionQuality?: ConnectionQuality;\n }>;\n /** The kind of output playing now — the short answer to \"where is the audio\". */\n audioRoute: AudioOutputKind;\n /**\n * Every output the call can play through right now: always the phone\n * (earpiece, or wired headphones in its place) and the speaker, plus\n * each connected Bluetooth / USB device by its own name. Empty until\n * the call's audio is up. Pass an `id` to `setAudioOutput`.\n */\n audioOutputs: AudioOutput[];\n /** The `audioOutputs` entry playing now; null before audio is up. */\n audioOutputId: string | null;\n mutedSelf: boolean;\n /** True only while the local camera track is actually published and enabled. */\n cameraOn: boolean;\n /**\n * A second call ringing while this one is in progress (call waiting).\n * Offer `answerWaiting` (\"End & answer\" — this call ends) and\n * `declineWaiting` (its caller hears busy). If this call ends first,\n * the waiting one simply becomes the ringing call. null when none;\n * absent before 0.10.0.\n */\n waiting?: WaitingCall | null;\n /** Facing of the published local camera; absent when the camera is off. */\n cameraFacing?: 'front' | 'back';\n /**\n * Your own link to the call. `poor` / `lost`: show a \"weak connection\"\n * hint; `phase: 'reconnecting'` is the hard version of the same thing.\n * Absent before 0.11.0.\n */\n connectionQuality?: ConnectionQuality;\n /**\n * Incoming video is switched off because your connection could not\n * carry it — the audio keeps going, and video comes back by itself\n * once the link has been good for a few seconds. Participants read\n * `cameraOn: false` meanwhile. Absent before 0.11.0.\n */\n videoPaused?: boolean;\n /** You are sharing your screen. Absent before 3.2. */\n screenSharing?: boolean;\n}\n\n/** `good` covers good and excellent; `unknown` until the SFU has measured. */\nexport type ConnectionQuality = 'good' | 'poor' | 'lost' | 'unknown';\n\nexport type AudioOutputKind = 'earpiece' | 'speaker' | 'bluetooth' | 'headset';\n\n/** The call waiting beside the current one. */\nexport interface WaitingCall {\n callId: string;\n conversationId: string | null;\n conversationName: string | null;\n callerName: string | null;\n media: 'audio' | 'video';\n}\n\n/** One place call audio can play. */\nexport interface AudioOutput {\n /** Opaque; stable while the device stays connected. */\n id: string;\n kind: AudioOutputKind;\n /**\n * The device's own name for Bluetooth/USB (\"AirPods Pro\"); a plain\n * English default for built-ins (\"iPhone\"/\"Phone\", \"Speaker\",\n * \"Headphones\") — relabel those by `kind` to localise.\n */\n name: string;\n}\n\nexport interface ConfigureOptions {\n /** Drawable resource NAME for the call notification's small icon. */\n smallIcon?: string;\n /** Ringback tone: raw resource NAME (Android); main-bundle sound name, mp3/caf/wav (iOS). */\n ringback?: string;\n /**\n * Incoming ringtone, overriding the config plugin's `ringtone` (leave it\n * out to use the plugin's, or the system ringtone without one).\n * Android: raw resource NAME (`ring` for `res/raw/ring.ogg`), played by\n * the module. iOS: a main-bundle sound CallKit plays — `ring.caf`, or the\n * base name looked up as caf/aiff/aif/wav; 30 s or shorter. Persisted, so\n * a ring that wakes a closed app uses it too. A name that is not in the\n * app rings with the system ringtone.\n */\n ringtone?: string;\n /**\n * Android: the full-screen incoming-call screen. Each field overrides the\n * config plugin's `incomingCall` option; leave one out to keep the\n * plugin's (or the built-in) value. Persisted for closed-app rings.\n * Ignored on iOS, where CallKit draws the call screen.\n */\n incomingCall?: IncomingCallOptions;\n /**\n * iOS: the APNs environment of this build's `aps-environment`\n * entitlement. Echoed back with the VoIP token so the server pushes to\n * the right gateway. Ignored on Android.\n */\n apnsEnvironment?: 'production' | 'sandbox';\n}\n\n/** Android's full-screen incoming call: its look, or the app's own activity instead. */\nexport interface IncomingCallOptions {\n /** `#RRGGBB` / `#AARRGGBB`: the glow, the pulsing ring and the initials disc (and the notification tint). */\n accentColor?: string;\n /** `#RRGGBB`: the screen's ground. A light one switches the text to dark. Default `#0B0B14`. */\n backgroundColor?: string;\n /**\n * The caller's picture, as a URL template: `{externalId}` (your app's id\n * for the caller) and `{userId}` (the poolse user id) are filled in,\n * URL-encoded — e.g. `https://cdn.example.com/avatars/{externalId}.jpg`.\n * Loaded off the main thread; the initials show until it loads, or if it\n * fails. A ring push's own `caller_avatar_url` wins over the template.\n */\n avatarUrl?: string;\n /**\n * Fully qualified class name of your own Activity (declared in your\n * manifest) to launch instead of the built-in screen. It receives the\n * `PoolseIncomingCall.EXTRA_*` extras and answers / declines through\n * `dev.poolse.callcore.android.PoolseIncomingCall` (see the README).\n * A leading `.` is relative to the application id.\n */\n activity?: string;\n}\n\n/** The iOS PushKit (VoIP) token and the APNs environment it belongs to. */\nexport interface VoipToken {\n /** Hex-encoded PushKit token. */\n token: string;\n environment: 'production' | 'sandbox' | string;\n}\n\nexport interface PlaceOptions {\n media: 'audio' | 'video';\n /** The user's session token — authorizes placing/joining (CALL_CONTRACT.md §3.2). */\n sessionToken: string;\n}\n\n/**\n * What the user tapped on a missed-call notification: the notification\n * itself (`open` the conversation) or its Call back button (`call_back`\n * — place a call on the conversation with `media`).\n */\nexport interface CallAction {\n type: 'open' | 'call_back';\n conversationId: string;\n callId: string | null;\n media: 'audio' | 'video';\n}\n\n/**\n * A Reply or Mark as read the user did from a chat notification, after\n * the native core sent it (or gave up). The server has already posted\n * the reply and marked the conversation read; use this to refresh what\n * the app shows (insert the message, drop the unread count) without\n * waiting for the socket, or to tell the user a reply did not go out.\n */\nexport interface NotificationActionResult {\n action: 'reply' | 'mark_read';\n conversationId: string;\n /** Whether the server accepted it. */\n ok: boolean;\n /** Reply only: what the user typed. */\n text?: string;\n /** Reply only: the idempotency id sent with it — the message's id once posted. */\n clientId?: string;\n /** Reply, `ok` only: the posted message's id (equals `clientId`). */\n messageId?: string;\n /**\n * When not `ok`: the server's error code (`unauthorized`,\n * `device_signed_out`, `user_blocked`, `forbidden`, `not_found`,\n * `mau_cap_exceeded`, `validation_failed`, `rate_limited`), or\n * `network`, `no_grant` (the push carried no reply grant),\n * `not_configured` (never `configure`d), `http_<status>`.\n */\n error?: string;\n /** The HTTP status when the server answered with an error. */\n status?: number;\n /** When it finished, epoch ms. */\n at: number;\n}\n\ntype NativeSnapshot = { snapshot: Snapshot | null };\n\ninterface PoolseCallsNative {\n configure(apiBaseUrl: string, options: ConfigureOptions | null): Promise<void>;\n getCallState(): NativeSnapshot;\n place(conversationId: string, media: string, sessionToken: string): Promise<void>;\n join(callId: string, conversationId: string | null, sessionToken: string): Promise<void>;\n answer(): void;\n decline(): void;\n hangUp(): void;\n answerWaiting?(callId: string | null): void;\n declineWaiting?(callId: string | null): void;\n setMuted(muted: boolean): void;\n setCamera(on: boolean): void;\n switchCamera(): void;\n screenShareSupported?(): boolean;\n startScreenShare?(): Promise<boolean>;\n stopScreenShare?(): void;\n setSpeaker(on: boolean): void;\n setAudioOutput?(id: string): void;\n callControl?(): Promise<{ callId: string; controlToken: string } | null>;\n setPictureInPictureEnabled?(on: boolean): void;\n isInPictureInPicture?(): boolean;\n pictureInPictureSupported?(): boolean;\n onRingEnded(callId: string, reason: string): void;\n onCallFinished(callId: string, reason: string | null): void;\n canUseFullScreenIntent(): boolean;\n openFullScreenIntentSettings(): void;\n setShowOnLockscreen?(enabled: boolean): void;\n getVoipToken?(): VoipToken | null;\n takeCallAction?(): CallAction | null;\n setActiveConversation?(conversationId: string | null): void;\n takeNotificationActions?(): NotificationActionResult[];\n observeNotificationActions?(on: boolean): void;\n addListener(event: 'onCallState', cb: (payload: NativeSnapshot) => void): { remove(): void };\n addListener(event: 'onVoipToken', cb: (payload: VoipToken) => void): { remove(): void };\n addListener(event: 'onCallAction', cb: (payload: CallAction) => void): { remove(): void };\n addListener(\n event: 'onNotificationAction',\n cb: (payload: NotificationActionResult) => void,\n ): { remove(): void };\n addListener(\n event: 'onPictureInPicture',\n cb: (payload: { active: boolean }) => void,\n ): { remove(): void };\n}\n\nconst native = requireOptionalNativeModule<PoolseCallsNative>('PoolseCalls');\n\n/** True when the native call core is present in this build. */\nexport const nativeCallsAvailable = native != null;\n\n// Kept for startRoom, the one command that talks to the server from JS.\nlet apiOrigin: string | null = null;\n\n/** Configure once, before any call can arrive. No secrets — just the API origin. */\nexport async function configure(apiBaseUrl: string, options?: ConfigureOptions): Promise<void> {\n apiOrigin = apiBaseUrl.replace(/\\/+$/, '');\n await native?.configure(apiBaseUrl, options ?? null);\n}\n\n/** The current snapshot — safe to read at any moment, including cold answer and before configure. */\nexport function getCallState(): Snapshot | null {\n return native?.getCallState().snapshot ?? null;\n}\n\nexport type Unsubscribe = () => void;\n\n/** Subscribe to call state. Fires a full snapshot on every change. */\nexport function onCallState(cb: (snapshot: Snapshot | null) => void): Unsubscribe {\n if (!native) return () => undefined;\n const sub = native.addListener('onCallState', (payload) => cb(payload.snapshot));\n return () => sub.remove();\n}\n\nexport function place(conversationId: string, options: PlaceOptions): Promise<void> {\n return native?.place(conversationId, options.media, options.sessionToken) ?? Promise.resolve();\n}\n\nexport function join(\n callId: string,\n conversationId: string | null,\n sessionToken: string,\n): Promise<void> {\n return native?.join(callId, conversationId, sessionToken) ?? Promise.resolve();\n}\n\nexport interface StartRoomResult {\n /** The room's call id — what the Join banner and `call:*` events carry. */\n callId: string;\n /** False when something was live already (a room, or a ringing call) and this joined it. */\n created: boolean;\n}\n\n/**\n * Start the conversation's room — a call that rings nobody (CALL_CONTRACT.md\n * §5.6) — or join whatever is live there, then carry it on the native\n * core like any joined call: CallKit / the call service, so it keeps\n * going with the phone locked, and the same audio routing as a call.\n *\n * Others in the conversation see it through the Join banner and join it\n * with `join`. Leaving (`hangUp`) never ends it for them; it ends once\n * it has been empty for a short grace. `media: 'video'` makes it a video\n * room. Rejects when the server refuses (not a member, no SFU) or\n * before `configure`.\n */\nexport async function startRoom(\n conversationId: string,\n options: PlaceOptions,\n): Promise<StartRoomResult> {\n if (!native) throw new Error('The native call core is not in this build.');\n if (!apiOrigin) throw new Error('Call configure() before startRoom().');\n const res = await fetch(\n `${apiOrigin}/v1/conversations/${encodeURIComponent(conversationId)}/room`,\n {\n method: 'POST',\n headers: {\n authorization: `Bearer ${options.sessionToken}`,\n 'content-type': 'application/json',\n },\n body: JSON.stringify({ media: options.media }),\n },\n );\n const body = (await res.json().catch(() => null)) as {\n created?: boolean;\n call?: { id?: string };\n error?: { message?: string };\n } | null;\n const callId = body?.call?.id;\n if (!res.ok || !callId) {\n throw new Error(body?.error?.message ?? `Couldn't start the room (${res.status}).`);\n }\n // The core joins with its own request: it owns the session from here,\n // exactly as when the room is joined from the banner.\n await native.join(callId, conversationId, options.sessionToken);\n return { callId, created: body?.created === true };\n}\n\n/** Who to ring into the call — poolse user ids, your app's own (external) ids, or both. */\nexport interface RingIntoCallOptions {\n userIds?: string[];\n externalIds?: string[];\n}\n\n/**\n * Ring more of the conversation's members into the call you are on\n * (\"Add people\"). Each is rung as on a fresh call — their phone rings,\n * CallKit / full-screen — and answering puts them in this call.\n *\n * Resolves with the poolse user ids actually rung: anyone already in\n * the call, still ringing, or not a member of the conversation is\n * skipped. Rejects with no call in progress, while nobody has answered\n * yet (the call's own ring is still out), or when the server refuses.\n */\nexport async function ringIntoCall(people: RingIntoCallOptions): Promise<string[]> {\n if (!native?.callControl) throw new Error('This build cannot ring people into a call.');\n if (!apiOrigin) throw new Error('Call configure() before ringIntoCall().');\n const control = await native.callControl();\n if (!control) throw new Error('There is no call in progress.');\n const res = await fetch(`${apiOrigin}/v1/calls/${encodeURIComponent(control.callId)}/ring`, {\n method: 'POST',\n headers: {\n authorization: `Bearer ${control.controlToken}`,\n 'content-type': 'application/json',\n },\n body: JSON.stringify({\n user_ids: people.userIds ?? [],\n external_ids: people.externalIds ?? [],\n }),\n });\n const body = (await res.json().catch(() => null)) as {\n rung_user_ids?: string[];\n error?: { message?: string };\n } | null;\n if (!res.ok) throw new Error(body?.error?.message ?? `Couldn't ring them (${res.status}).`);\n return body?.rung_user_ids ?? [];\n}\n\nexport const answer = (): void => native?.answer();\nexport const decline = (): void => native?.decline();\nexport const hangUp = (): void => native?.hangUp();\n\n/**\n * Call waiting: end the current call and answer `snapshot.waiting`.\n * Pass its `callId`: a tap on a card for a call that is no longer the\n * one waiting is then ignored instead of answering a different call.\n */\nexport const answerWaiting = (callId?: string): void => native?.answerWaiting?.(callId ?? null);\n\n/** Call waiting: turn `snapshot.waiting` away — its caller hears busy. */\nexport const declineWaiting = (callId?: string): void => native?.declineWaiting?.(callId ?? null);\nexport const setMuted = (muted: boolean): void => native?.setMuted(muted);\nexport const setCamera = (on: boolean): void => native?.setCamera(on);\nexport const switchCamera = (): void => native?.switchCamera();\n\n/**\n * Whether this build can share the screen in a call: Android with the\n * LiveKit media engine; iOS when the app was built with the config\n * plugin's `screenShare` option (the broadcast extension). Every build\n * shows other people's screens.\n */\nexport const screenShareSupported = (): boolean => native?.screenShareSupported?.() ?? false;\n\n/**\n * Share the screen. Android asks the user first (the system's \"Start\n * recording or casting?\" prompt) and resolves `false` when they say no.\n * iOS shows the system's broadcast sheet and resolves `true` once it is\n * up; the user still has to tap Start Broadcast. Either way it resolves\n * `false` when the build cannot share, and `snapshot.screenSharing`\n * turns true only once the screen is actually going out. Stopping from\n * the system notification (Android) or the status bar (iOS) ends it the\n * same way.\n */\nexport const startScreenShare = async (): Promise<boolean> =>\n (await native?.startScreenShare?.()) ?? false;\n\nexport const stopScreenShare = (): void => native?.stopScreenShare?.();\n/** Route call audio to the loudspeaker (`true`) or back to earpiece / headset (`false`). */\nexport const setSpeaker = (on: boolean): void => native?.setSpeaker(on);\n\n/**\n * Play call audio through one of `snapshot.audioOutputs`. The choice\n * holds for the rest of the call, until that device disconnects or a new\n * headset / Bluetooth device connects (which takes over, as in the\n * phone's own dialer). Without a choice a connected headset wins, then\n * the earpiece for voice calls or the speaker for video.\n */\nexport function setAudioOutput(id: string): void {\n if (native?.setAudioOutput) native.setAudioOutput(id);\n else native?.setSpeaker(id === 'speaker'); // an older native build\n}\n\n/**\n * Socket forwarding for an open app: a `call:ring_ended` seen on the\n * socket. Idempotent with the push path — the core dedupes.\n */\nexport const onRingEnded = (callId: string, reason: string): void =>\n native?.onRingEnded(callId, reason);\n\n/**\n * Socket forwarding: `call:finished`. Pass the payload's `reason`\n * (`finished` | `declined_all` | `no_answer` | `cancelled`) so an\n * unanswered caller sees \"Declined\"/\"No answer\", not \"Call ended\".\n * Idempotent with the `finished` push.\n */\nexport const onCallFinished = (callId: string, reason?: string): void =>\n native?.onCallFinished(callId, reason ?? null);\n\n/**\n * Android 14+: whether the app may show the full-screen ring over the\n * lock screen. `true` on older Android and where the module is absent.\n */\nexport const canUseFullScreenIntent = (): boolean => native?.canUseFullScreenIntent() ?? true;\n\n/** Open the system screen where the user grants full-screen intents (falls back to notification settings). */\nexport const openFullScreenIntentSettings = (): void => native?.openFullScreenIntentSettings();\n\n/**\n * Android: let the app show over the lock screen while a call rings or\n * runs — answering must never demand an unlock. Turn it off when the\n * call ends. The activity re-applies it when the core relaunches it for\n * a call (`poolse_launch_call`), given the host's MainActivity hook.\n * No-op on iOS, where CallKit owns the lock screen.\n */\nexport function setShowOnLockscreen(enabled: boolean): void {\n try {\n native?.setShowOnLockscreen?.(enabled);\n } catch {\n // Never let a window flag take a call down.\n }\n}\n\n// ── missed-call notifications (Android) ─────────────────────────────────\n\n/**\n * Android: the missed-call notification action the app was LAUNCHED\n * with, once — read it on mount. `null` when the app opened any other\n * way. The native core posts that notification itself from the push,\n * so it works with the app closed.\n *\n * iOS shows missed calls as an ordinary alert push (to the token you\n * register with `kind: 'alert'`); read its taps with your notification\n * library — its `type` is `call_missed`, the category\n * `poolse_missed_call`, the Call back action `call_back`.\n */\nexport function takeCallAction(): CallAction | null {\n return native?.takeCallAction?.() ?? null;\n}\n\n/** Android: a missed-call notification tapped while the app is running. */\nexport function onCallAction(cb: (action: CallAction) => void): Unsubscribe {\n if (!native || !native.takeCallAction) return () => undefined;\n const sub = native.addListener('onCallAction', cb);\n return () => sub.remove();\n}\n\n// ── chat notifications ─────────────────────────────────────────────────\n\nlet activeConversation: string | null = null;\n\n/**\n * Tell the core which conversation is on screen (`null` when none, and\n * when the app goes to the background). Its messages are not notified —\n * the user is reading them — and opening it clears the notifications\n * already shown for it.\n */\nexport function setActiveConversation(conversationId: string | null): void {\n activeConversation = conversationId;\n native?.setActiveConversation?.(conversationId);\n}\n\n/**\n * For the app's notification handler (expo-notifications'\n * `setNotificationHandler`): `false` for a chat notification of the\n * conversation on screen, which must not pop over the chat itself.\n * Android never asks — the core skips those natively.\n */\nexport function shouldPresentMessage(data: Record<string, unknown> | undefined | null): boolean {\n if (!data || data['type'] !== 'message') return true;\n return data['conversation_id'] !== activeConversation;\n}\n\n/**\n * The conversation a tapped notification belongs to — a chat message\n * (`type: 'message'`) or a missed call (`call_missed`) — from its data.\n * iOS hands the tap to your notification library; Android delivers it\n * through `takeCallAction` / `onCallAction` (type `open`).\n */\nexport function conversationOfNotification(\n data: Record<string, unknown> | undefined | null,\n): string | null {\n if (!data) return null;\n const type = data['type'];\n if (type !== 'message' && type !== 'call_missed') return null;\n return typeof data['conversation_id'] === 'string' ? data['conversation_id'] : null;\n}\n\n/**\n * Reply and Mark as read from a chat notification are handled natively —\n * from the lock screen, with the app closed — using the grant the push\n * carried and the API origin given to `configure` (which persists it).\n * This fires once each finishes while the app is running. Read the ones\n * that finished while it was not with `takeNotificationActions` on mount.\n */\nexport function onNotificationAction(cb: (result: NotificationActionResult) => void): Unsubscribe {\n if (!native?.takeNotificationActions) return () => undefined;\n const sub = native.addListener('onNotificationAction', cb);\n if (actionObservers++ === 0) native.observeNotificationActions?.(true);\n let removed = false;\n return () => {\n if (removed) return;\n removed = true;\n sub.remove();\n if (--actionObservers === 0) native?.observeNotificationActions?.(false);\n };\n}\n\n// Native queues results until someone listens for them specifically.\nlet actionObservers = 0;\n\n/** `onNotificationAction`, replies only. */\nexport function onNotificationReply(cb: (result: NotificationActionResult) => void): Unsubscribe {\n return onNotificationAction((result) => {\n if (result.action === 'reply') cb(result);\n });\n}\n\n/**\n * The notification actions that finished while no `onNotificationAction`\n * listener was attached (usually: the app was not running), oldest\n * first, each returned once. Up to the last 50 are kept.\n */\nexport function takeNotificationActions(): NotificationActionResult[] {\n return native?.takeNotificationActions?.() ?? [];\n}\n\n// ── VoIP push (iOS) ───────────────────────────────────────────────────\n\n/**\n * iOS: the current PushKit VoIP token, registered natively at launch.\n * `null` until iOS issues one, and always on Android (FCM carries rings).\n */\nexport function getVoipToken(): VoipToken | null {\n return native?.getVoipToken?.() ?? null;\n}\n\n/** iOS: fires whenever PushKit issues (or rotates) the VoIP token. No-op on Android. */\nexport function onVoipToken(cb: (token: VoipToken) => void): Unsubscribe {\n if (!native || !native.getVoipToken) return () => undefined;\n const sub = native.addListener('onVoipToken', cb);\n return () => sub.remove();\n}\n\n// ── picture-in-picture ────────────────────────────────────────────────\n\n/**\n * Arm picture-in-picture: while on, leaving the app keeps the call's\n * video in a floating window. Turn it on only while a video call shows\n * someone's picture, and off otherwise.\n *\n * iOS (15+) floats the `<CallVideoView pictureInPicture>` that is on\n * screen — mark the main remote picture. Android (8+) floats the whole\n * app: draw a compact layout while `isInPictureInPicture()` (see\n * `onPictureInPicture`). The app needs `android:supportsPictureInPicture`\n * on its activity.\n */\nexport function setPictureInPictureEnabled(on: boolean): void {\n native?.setPictureInPictureEnabled?.(on);\n}\n\n/** Whether the floating window is open right now. */\nexport function isInPictureInPicture(): boolean {\n return native?.isInPictureInPicture?.() ?? false;\n}\n\n/** Whether this device can float a call at all. */\nexport function pictureInPictureSupported(): boolean {\n return native?.pictureInPictureSupported?.() ?? false;\n}\n\n/** Fires when the floating window opens (`true`) and closes (`false`). */\nexport function onPictureInPicture(cb: (active: boolean) => void): Unsubscribe {\n if (!native?.setPictureInPictureEnabled) return () => undefined;\n const sub = native.addListener('onPictureInPicture', (payload) => cb(payload.active));\n return () => sub.remove();\n}\n\n// ── video ─────────────────────────────────────────────────────────────\n\nexport interface CallVideoViewProps extends ViewProps {\n /** Remote participant's userId (LiveKit identity). Omit with local=true for self view. */\n participantId?: string;\n local?: boolean;\n /** default: true for local front camera, false otherwise */\n mirror?: boolean;\n /** default 'cover' */\n fit?: 'cover' | 'contain';\n /**\n * `camera` (default), or `screen`: the participant's shared screen\n * (with `local`, your own). A screen is never mirrored; draw it with\n * `fit=\"contain\"` so nothing is cropped.\n */\n source?: 'camera' | 'screen';\n /**\n * iOS: this remote picture is the one picture-in-picture floats when\n * the app is left (`setPictureInPictureEnabled`). Mark one at a time.\n */\n pictureInPicture?: boolean;\n}\n\ntype NativeVideoProps = CallVideoViewProps;\n\nlet nativeVideo: ComponentType<NativeVideoProps> | null | undefined;\n\n/** Resolved lazily (first render) and only when the native module exists. */\nfunction nativeVideoView(): ComponentType<NativeVideoProps> | null {\n if (nativeVideo !== undefined) return nativeVideo;\n nativeVideo = null;\n if (native) {\n try {\n nativeVideo = requireNativeViewManager<NativeVideoProps>('PoolseCalls', 'PoolseCallVideo');\n } catch {\n nativeVideo = null; // an older native build without the view\n }\n }\n return nativeVideo;\n}\n\n/**\n * A participant's camera (or, with `local`, your own), rendered natively\n * by the call core. Shows nothing (stays transparent) while that camera\n * is off — draw the avatar from the snapshot's `cameraOn` underneath.\n * Without the native module it renders an empty View.\n */\nexport function CallVideoView(props: CallVideoViewProps): ReactElement | null {\n const Native = nativeVideoView();\n if (!Native) {\n const {\n participantId: _p,\n local: _l,\n mirror: _m,\n fit: _f,\n source: _s,\n pictureInPicture: _pip,\n ...rest\n } = props;\n return createElement(View, rest);\n }\n return createElement(Native, props);\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -109,6 +109,23 @@ interface ConfigureOptions {
|
|
|
109
109
|
smallIcon?: string;
|
|
110
110
|
/** Ringback tone: raw resource NAME (Android); main-bundle sound name, mp3/caf/wav (iOS). */
|
|
111
111
|
ringback?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Incoming ringtone, overriding the config plugin's `ringtone` (leave it
|
|
114
|
+
* out to use the plugin's, or the system ringtone without one).
|
|
115
|
+
* Android: raw resource NAME (`ring` for `res/raw/ring.ogg`), played by
|
|
116
|
+
* the module. iOS: a main-bundle sound CallKit plays — `ring.caf`, or the
|
|
117
|
+
* base name looked up as caf/aiff/aif/wav; 30 s or shorter. Persisted, so
|
|
118
|
+
* a ring that wakes a closed app uses it too. A name that is not in the
|
|
119
|
+
* app rings with the system ringtone.
|
|
120
|
+
*/
|
|
121
|
+
ringtone?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Android: the full-screen incoming-call screen. Each field overrides the
|
|
124
|
+
* config plugin's `incomingCall` option; leave one out to keep the
|
|
125
|
+
* plugin's (or the built-in) value. Persisted for closed-app rings.
|
|
126
|
+
* Ignored on iOS, where CallKit draws the call screen.
|
|
127
|
+
*/
|
|
128
|
+
incomingCall?: IncomingCallOptions;
|
|
112
129
|
/**
|
|
113
130
|
* iOS: the APNs environment of this build's `aps-environment`
|
|
114
131
|
* entitlement. Echoed back with the VoIP token so the server pushes to
|
|
@@ -116,6 +133,29 @@ interface ConfigureOptions {
|
|
|
116
133
|
*/
|
|
117
134
|
apnsEnvironment?: 'production' | 'sandbox';
|
|
118
135
|
}
|
|
136
|
+
/** Android's full-screen incoming call: its look, or the app's own activity instead. */
|
|
137
|
+
interface IncomingCallOptions {
|
|
138
|
+
/** `#RRGGBB` / `#AARRGGBB`: the glow, the pulsing ring and the initials disc (and the notification tint). */
|
|
139
|
+
accentColor?: string;
|
|
140
|
+
/** `#RRGGBB`: the screen's ground. A light one switches the text to dark. Default `#0B0B14`. */
|
|
141
|
+
backgroundColor?: string;
|
|
142
|
+
/**
|
|
143
|
+
* The caller's picture, as a URL template: `{externalId}` (your app's id
|
|
144
|
+
* for the caller) and `{userId}` (the poolse user id) are filled in,
|
|
145
|
+
* URL-encoded — e.g. `https://cdn.example.com/avatars/{externalId}.jpg`.
|
|
146
|
+
* Loaded off the main thread; the initials show until it loads, or if it
|
|
147
|
+
* fails. A ring push's own `caller_avatar_url` wins over the template.
|
|
148
|
+
*/
|
|
149
|
+
avatarUrl?: string;
|
|
150
|
+
/**
|
|
151
|
+
* Fully qualified class name of your own Activity (declared in your
|
|
152
|
+
* manifest) to launch instead of the built-in screen. It receives the
|
|
153
|
+
* `PoolseIncomingCall.EXTRA_*` extras and answers / declines through
|
|
154
|
+
* `dev.poolse.callcore.android.PoolseIncomingCall` (see the README).
|
|
155
|
+
* A leading `.` is relative to the application id.
|
|
156
|
+
*/
|
|
157
|
+
activity?: string;
|
|
158
|
+
}
|
|
119
159
|
/** The iOS PushKit (VoIP) token and the APNs environment it belongs to. */
|
|
120
160
|
interface VoipToken {
|
|
121
161
|
/** Hex-encoded PushKit token. */
|
|
@@ -389,4 +429,4 @@ interface CallVideoViewProps extends ViewProps {
|
|
|
389
429
|
*/
|
|
390
430
|
declare function CallVideoView(props: CallVideoViewProps): ReactElement | null;
|
|
391
431
|
|
|
392
|
-
export { type AudioOutput, type AudioOutputKind, type CallAction, CallVideoView, type CallVideoViewProps, type ConfigureOptions, type ConnectionQuality, type NotificationActionResult, type PlaceOptions, type RingIntoCallOptions, type Snapshot, type StartRoomResult, type Unsubscribe, type VoipToken, type WaitingCall, answer, answerWaiting, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, nativeCallsAvailable, onCallAction, onCallFinished, onCallState, onNotificationAction, onNotificationReply, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, ringIntoCall, screenShareSupported, setActiveConversation, setAudioOutput, setCamera, setMuted, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction, takeNotificationActions };
|
|
432
|
+
export { type AudioOutput, type AudioOutputKind, type CallAction, CallVideoView, type CallVideoViewProps, type ConfigureOptions, type ConnectionQuality, type IncomingCallOptions, type NotificationActionResult, type PlaceOptions, type RingIntoCallOptions, type Snapshot, type StartRoomResult, type Unsubscribe, type VoipToken, type WaitingCall, answer, answerWaiting, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, nativeCallsAvailable, onCallAction, onCallFinished, onCallState, onNotificationAction, onNotificationReply, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, ringIntoCall, screenShareSupported, setActiveConversation, setAudioOutput, setCamera, setMuted, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction, takeNotificationActions };
|
package/dist/index.d.ts
CHANGED
|
@@ -109,6 +109,23 @@ interface ConfigureOptions {
|
|
|
109
109
|
smallIcon?: string;
|
|
110
110
|
/** Ringback tone: raw resource NAME (Android); main-bundle sound name, mp3/caf/wav (iOS). */
|
|
111
111
|
ringback?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Incoming ringtone, overriding the config plugin's `ringtone` (leave it
|
|
114
|
+
* out to use the plugin's, or the system ringtone without one).
|
|
115
|
+
* Android: raw resource NAME (`ring` for `res/raw/ring.ogg`), played by
|
|
116
|
+
* the module. iOS: a main-bundle sound CallKit plays — `ring.caf`, or the
|
|
117
|
+
* base name looked up as caf/aiff/aif/wav; 30 s or shorter. Persisted, so
|
|
118
|
+
* a ring that wakes a closed app uses it too. A name that is not in the
|
|
119
|
+
* app rings with the system ringtone.
|
|
120
|
+
*/
|
|
121
|
+
ringtone?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Android: the full-screen incoming-call screen. Each field overrides the
|
|
124
|
+
* config plugin's `incomingCall` option; leave one out to keep the
|
|
125
|
+
* plugin's (or the built-in) value. Persisted for closed-app rings.
|
|
126
|
+
* Ignored on iOS, where CallKit draws the call screen.
|
|
127
|
+
*/
|
|
128
|
+
incomingCall?: IncomingCallOptions;
|
|
112
129
|
/**
|
|
113
130
|
* iOS: the APNs environment of this build's `aps-environment`
|
|
114
131
|
* entitlement. Echoed back with the VoIP token so the server pushes to
|
|
@@ -116,6 +133,29 @@ interface ConfigureOptions {
|
|
|
116
133
|
*/
|
|
117
134
|
apnsEnvironment?: 'production' | 'sandbox';
|
|
118
135
|
}
|
|
136
|
+
/** Android's full-screen incoming call: its look, or the app's own activity instead. */
|
|
137
|
+
interface IncomingCallOptions {
|
|
138
|
+
/** `#RRGGBB` / `#AARRGGBB`: the glow, the pulsing ring and the initials disc (and the notification tint). */
|
|
139
|
+
accentColor?: string;
|
|
140
|
+
/** `#RRGGBB`: the screen's ground. A light one switches the text to dark. Default `#0B0B14`. */
|
|
141
|
+
backgroundColor?: string;
|
|
142
|
+
/**
|
|
143
|
+
* The caller's picture, as a URL template: `{externalId}` (your app's id
|
|
144
|
+
* for the caller) and `{userId}` (the poolse user id) are filled in,
|
|
145
|
+
* URL-encoded — e.g. `https://cdn.example.com/avatars/{externalId}.jpg`.
|
|
146
|
+
* Loaded off the main thread; the initials show until it loads, or if it
|
|
147
|
+
* fails. A ring push's own `caller_avatar_url` wins over the template.
|
|
148
|
+
*/
|
|
149
|
+
avatarUrl?: string;
|
|
150
|
+
/**
|
|
151
|
+
* Fully qualified class name of your own Activity (declared in your
|
|
152
|
+
* manifest) to launch instead of the built-in screen. It receives the
|
|
153
|
+
* `PoolseIncomingCall.EXTRA_*` extras and answers / declines through
|
|
154
|
+
* `dev.poolse.callcore.android.PoolseIncomingCall` (see the README).
|
|
155
|
+
* A leading `.` is relative to the application id.
|
|
156
|
+
*/
|
|
157
|
+
activity?: string;
|
|
158
|
+
}
|
|
119
159
|
/** The iOS PushKit (VoIP) token and the APNs environment it belongs to. */
|
|
120
160
|
interface VoipToken {
|
|
121
161
|
/** Hex-encoded PushKit token. */
|
|
@@ -389,4 +429,4 @@ interface CallVideoViewProps extends ViewProps {
|
|
|
389
429
|
*/
|
|
390
430
|
declare function CallVideoView(props: CallVideoViewProps): ReactElement | null;
|
|
391
431
|
|
|
392
|
-
export { type AudioOutput, type AudioOutputKind, type CallAction, CallVideoView, type CallVideoViewProps, type ConfigureOptions, type ConnectionQuality, type NotificationActionResult, type PlaceOptions, type RingIntoCallOptions, type Snapshot, type StartRoomResult, type Unsubscribe, type VoipToken, type WaitingCall, answer, answerWaiting, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, nativeCallsAvailable, onCallAction, onCallFinished, onCallState, onNotificationAction, onNotificationReply, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, ringIntoCall, screenShareSupported, setActiveConversation, setAudioOutput, setCamera, setMuted, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction, takeNotificationActions };
|
|
432
|
+
export { type AudioOutput, type AudioOutputKind, type CallAction, CallVideoView, type CallVideoViewProps, type ConfigureOptions, type ConnectionQuality, type IncomingCallOptions, type NotificationActionResult, type PlaceOptions, type RingIntoCallOptions, type Snapshot, type StartRoomResult, type Unsubscribe, type VoipToken, type WaitingCall, answer, answerWaiting, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, nativeCallsAvailable, onCallAction, onCallFinished, onCallState, onNotificationAction, onNotificationReply, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, ringIntoCall, screenShareSupported, setActiveConversation, setAudioOutput, setCamera, setMuted, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction, takeNotificationActions };
|