@poolse/native 3.4.0 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,7 +35,7 @@ class PoolseCallsModule : Module() {
35
35
  override fun definition() = ModuleDefinition {
36
36
  Name("PoolseCalls")
37
37
 
38
- Events("onCallState", "onCallAction", "onPictureInPicture")
38
+ Events("onCallState", "onCallAction", "onPictureInPicture", "onNotificationAction")
39
39
 
40
40
  // <CallVideoView>: renders a participant's (or our own) camera.
41
41
  View(PoolseCallVideoView::class) {
@@ -57,10 +57,12 @@ class PoolseCallsModule : Module() {
57
57
  OnStartObserving {
58
58
  CallCore.listener = { snapshot -> sendEvent("onCallState", mapOf("snapshot" to snapshot)) }
59
59
  CallPictureInPicture.listener = { active -> sendEvent("onPictureInPicture", mapOf("active" to active)) }
60
+ MessageNotifications.actionListener = { event -> sendEvent("onNotificationAction", event) }
60
61
  }
61
62
  OnStopObserving {
62
63
  CallCore.listener = null
63
64
  CallPictureInPicture.listener = null
65
+ MessageNotifications.actionListener = null
64
66
  }
65
67
 
66
68
  // Picture-in-picture: armed while a video call shows someone. Android
@@ -174,6 +176,13 @@ class PoolseCallsModule : Module() {
174
176
  if (conversationId != null) context?.let { MessageNotifications.clear(it, conversationId) }
175
177
  }
176
178
 
179
+ // Reply / Mark as read done from a notification while JS was not
180
+ // listening (usually: the app was not running). Oldest first, once.
181
+ Function("takeNotificationActions") {
182
+ context?.let(MessageNotifications::takePendingActions) ?: emptyList()
183
+ }
184
+ Function("observeNotificationActions") { on: Boolean -> MessageNotifications.actionsObserved = on }
185
+
177
186
  // While a call rings or runs the app may sit over the lock screen.
178
187
  Function("setShowOnLockscreen") { enabled: Boolean ->
179
188
  CallLockscreen.set(appContext.currentActivity, enabled)
package/dist/index.cjs CHANGED
@@ -117,6 +117,27 @@ function conversationOfNotification(data) {
117
117
  if (type !== "message" && type !== "call_missed") return null;
118
118
  return typeof data["conversation_id"] === "string" ? data["conversation_id"] : null;
119
119
  }
120
+ function onNotificationAction(cb) {
121
+ if (!native?.takeNotificationActions) return () => void 0;
122
+ const sub = native.addListener("onNotificationAction", cb);
123
+ if (actionObservers++ === 0) native.observeNotificationActions?.(true);
124
+ let removed = false;
125
+ return () => {
126
+ if (removed) return;
127
+ removed = true;
128
+ sub.remove();
129
+ if (--actionObservers === 0) native?.observeNotificationActions?.(false);
130
+ };
131
+ }
132
+ var actionObservers = 0;
133
+ function onNotificationReply(cb) {
134
+ return onNotificationAction((result) => {
135
+ if (result.action === "reply") cb(result);
136
+ });
137
+ }
138
+ function takeNotificationActions() {
139
+ return native?.takeNotificationActions?.() ?? [];
140
+ }
120
141
  function getVoipToken() {
121
142
  return native?.getVoipToken?.() ?? null;
122
143
  }
@@ -186,6 +207,8 @@ exports.nativeCallsAvailable = nativeCallsAvailable;
186
207
  exports.onCallAction = onCallAction;
187
208
  exports.onCallFinished = onCallFinished;
188
209
  exports.onCallState = onCallState;
210
+ exports.onNotificationAction = onNotificationAction;
211
+ exports.onNotificationReply = onNotificationReply;
189
212
  exports.onPictureInPicture = onPictureInPicture;
190
213
  exports.onRingEnded = onRingEnded;
191
214
  exports.onVoipToken = onVoipToken;
@@ -207,5 +230,6 @@ exports.startScreenShare = startScreenShare;
207
230
  exports.stopScreenShare = stopScreenShare;
208
231
  exports.switchCamera = switchCamera;
209
232
  exports.takeCallAction = takeCallAction;
233
+ exports.takeNotificationActions = takeNotificationActions;
210
234
  //# sourceMappingURL=index.cjs.map
211
235
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["requireOptionalNativeModule","requireNativeViewManager","createElement","View"],"mappings":";;;;;;;AA+MA,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,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Y,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\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 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: '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// ── 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":";;;;;;;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,YAAY,CAAA,IAAK,OAAA,CAAQ,OAAA,EAAQ;AAC/F;AAEO,SAAS,IAAA,CAC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,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"]}
package/dist/index.d.cts CHANGED
@@ -138,6 +138,37 @@ interface CallAction {
138
138
  callId: string | null;
139
139
  media: 'audio' | 'video';
140
140
  }
141
+ /**
142
+ * A Reply or Mark as read the user did from a chat notification, after
143
+ * the native core sent it (or gave up). The server has already posted
144
+ * the reply and marked the conversation read; use this to refresh what
145
+ * the app shows (insert the message, drop the unread count) without
146
+ * waiting for the socket, or to tell the user a reply did not go out.
147
+ */
148
+ interface NotificationActionResult {
149
+ action: 'reply' | 'mark_read';
150
+ conversationId: string;
151
+ /** Whether the server accepted it. */
152
+ ok: boolean;
153
+ /** Reply only: what the user typed. */
154
+ text?: string;
155
+ /** Reply only: the idempotency id sent with it — the message's id once posted. */
156
+ clientId?: string;
157
+ /** Reply, `ok` only: the posted message's id (equals `clientId`). */
158
+ messageId?: string;
159
+ /**
160
+ * When not `ok`: the server's error code (`unauthorized`,
161
+ * `device_signed_out`, `user_blocked`, `forbidden`, `not_found`,
162
+ * `mau_cap_exceeded`, `validation_failed`, `rate_limited`), or
163
+ * `network`, `no_grant` (the push carried no reply grant),
164
+ * `not_configured` (never `configure`d), `http_<status>`.
165
+ */
166
+ error?: string;
167
+ /** The HTTP status when the server answered with an error. */
168
+ status?: number;
169
+ /** When it finished, epoch ms. */
170
+ at: number;
171
+ }
141
172
  /** True when the native call core is present in this build. */
142
173
  declare const nativeCallsAvailable: boolean;
143
174
  /** Configure once, before any call can arrive. No secrets — just the API origin. */
@@ -289,6 +320,22 @@ declare function shouldPresentMessage(data: Record<string, unknown> | undefined
289
320
  * through `takeCallAction` / `onCallAction` (type `open`).
290
321
  */
291
322
  declare function conversationOfNotification(data: Record<string, unknown> | undefined | null): string | null;
323
+ /**
324
+ * Reply and Mark as read from a chat notification are handled natively —
325
+ * from the lock screen, with the app closed — using the grant the push
326
+ * carried and the API origin given to `configure` (which persists it).
327
+ * This fires once each finishes while the app is running. Read the ones
328
+ * that finished while it was not with `takeNotificationActions` on mount.
329
+ */
330
+ declare function onNotificationAction(cb: (result: NotificationActionResult) => void): Unsubscribe;
331
+ /** `onNotificationAction`, replies only. */
332
+ declare function onNotificationReply(cb: (result: NotificationActionResult) => void): Unsubscribe;
333
+ /**
334
+ * The notification actions that finished while no `onNotificationAction`
335
+ * listener was attached (usually: the app was not running), oldest
336
+ * first, each returned once. Up to the last 50 are kept.
337
+ */
338
+ declare function takeNotificationActions(): NotificationActionResult[];
292
339
  /**
293
340
  * iOS: the current PushKit VoIP token, registered natively at launch.
294
341
  * `null` until iOS issues one, and always on Android (FCM carries rings).
@@ -342,4 +389,4 @@ interface CallVideoViewProps extends ViewProps {
342
389
  */
343
390
  declare function CallVideoView(props: CallVideoViewProps): ReactElement | null;
344
391
 
345
- export { type AudioOutput, type AudioOutputKind, type CallAction, CallVideoView, type CallVideoViewProps, type ConfigureOptions, type ConnectionQuality, 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, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, ringIntoCall, screenShareSupported, setActiveConversation, setAudioOutput, setCamera, setMuted, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction };
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 };
package/dist/index.d.ts CHANGED
@@ -138,6 +138,37 @@ interface CallAction {
138
138
  callId: string | null;
139
139
  media: 'audio' | 'video';
140
140
  }
141
+ /**
142
+ * A Reply or Mark as read the user did from a chat notification, after
143
+ * the native core sent it (or gave up). The server has already posted
144
+ * the reply and marked the conversation read; use this to refresh what
145
+ * the app shows (insert the message, drop the unread count) without
146
+ * waiting for the socket, or to tell the user a reply did not go out.
147
+ */
148
+ interface NotificationActionResult {
149
+ action: 'reply' | 'mark_read';
150
+ conversationId: string;
151
+ /** Whether the server accepted it. */
152
+ ok: boolean;
153
+ /** Reply only: what the user typed. */
154
+ text?: string;
155
+ /** Reply only: the idempotency id sent with it — the message's id once posted. */
156
+ clientId?: string;
157
+ /** Reply, `ok` only: the posted message's id (equals `clientId`). */
158
+ messageId?: string;
159
+ /**
160
+ * When not `ok`: the server's error code (`unauthorized`,
161
+ * `device_signed_out`, `user_blocked`, `forbidden`, `not_found`,
162
+ * `mau_cap_exceeded`, `validation_failed`, `rate_limited`), or
163
+ * `network`, `no_grant` (the push carried no reply grant),
164
+ * `not_configured` (never `configure`d), `http_<status>`.
165
+ */
166
+ error?: string;
167
+ /** The HTTP status when the server answered with an error. */
168
+ status?: number;
169
+ /** When it finished, epoch ms. */
170
+ at: number;
171
+ }
141
172
  /** True when the native call core is present in this build. */
142
173
  declare const nativeCallsAvailable: boolean;
143
174
  /** Configure once, before any call can arrive. No secrets — just the API origin. */
@@ -289,6 +320,22 @@ declare function shouldPresentMessage(data: Record<string, unknown> | undefined
289
320
  * through `takeCallAction` / `onCallAction` (type `open`).
290
321
  */
291
322
  declare function conversationOfNotification(data: Record<string, unknown> | undefined | null): string | null;
323
+ /**
324
+ * Reply and Mark as read from a chat notification are handled natively —
325
+ * from the lock screen, with the app closed — using the grant the push
326
+ * carried and the API origin given to `configure` (which persists it).
327
+ * This fires once each finishes while the app is running. Read the ones
328
+ * that finished while it was not with `takeNotificationActions` on mount.
329
+ */
330
+ declare function onNotificationAction(cb: (result: NotificationActionResult) => void): Unsubscribe;
331
+ /** `onNotificationAction`, replies only. */
332
+ declare function onNotificationReply(cb: (result: NotificationActionResult) => void): Unsubscribe;
333
+ /**
334
+ * The notification actions that finished while no `onNotificationAction`
335
+ * listener was attached (usually: the app was not running), oldest
336
+ * first, each returned once. Up to the last 50 are kept.
337
+ */
338
+ declare function takeNotificationActions(): NotificationActionResult[];
292
339
  /**
293
340
  * iOS: the current PushKit VoIP token, registered natively at launch.
294
341
  * `null` until iOS issues one, and always on Android (FCM carries rings).
@@ -342,4 +389,4 @@ interface CallVideoViewProps extends ViewProps {
342
389
  */
343
390
  declare function CallVideoView(props: CallVideoViewProps): ReactElement | null;
344
391
 
345
- export { type AudioOutput, type AudioOutputKind, type CallAction, CallVideoView, type CallVideoViewProps, type ConfigureOptions, type ConnectionQuality, 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, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, ringIntoCall, screenShareSupported, setActiveConversation, setAudioOutput, setCamera, setMuted, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction };
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 };
package/dist/index.js CHANGED
@@ -115,6 +115,27 @@ function conversationOfNotification(data) {
115
115
  if (type !== "message" && type !== "call_missed") return null;
116
116
  return typeof data["conversation_id"] === "string" ? data["conversation_id"] : null;
117
117
  }
118
+ function onNotificationAction(cb) {
119
+ if (!native?.takeNotificationActions) return () => void 0;
120
+ const sub = native.addListener("onNotificationAction", cb);
121
+ if (actionObservers++ === 0) native.observeNotificationActions?.(true);
122
+ let removed = false;
123
+ return () => {
124
+ if (removed) return;
125
+ removed = true;
126
+ sub.remove();
127
+ if (--actionObservers === 0) native?.observeNotificationActions?.(false);
128
+ };
129
+ }
130
+ var actionObservers = 0;
131
+ function onNotificationReply(cb) {
132
+ return onNotificationAction((result) => {
133
+ if (result.action === "reply") cb(result);
134
+ });
135
+ }
136
+ function takeNotificationActions() {
137
+ return native?.takeNotificationActions?.() ?? [];
138
+ }
118
139
  function getVoipToken() {
119
140
  return native?.getVoipToken?.() ?? null;
120
141
  }
@@ -167,6 +188,6 @@ function CallVideoView(props) {
167
188
  return createElement(Native, props);
168
189
  }
169
190
 
170
- export { CallVideoView, answer, answerWaiting, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, nativeCallsAvailable, onCallAction, onCallFinished, onCallState, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, ringIntoCall, screenShareSupported, setActiveConversation, setAudioOutput, setCamera, setMuted, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction };
191
+ export { CallVideoView, 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 };
171
192
  //# sourceMappingURL=index.js.map
172
193
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;AA+MA,IAAM,M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,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,GAAc,wBAAA,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,OAAO,aAAA,CAAc,MAAM,IAAI,CAAA;AAAA,EACjC;AACA,EAAA,OAAO,aAAA,CAAc,QAAQ,KAAK,CAAA;AACpC","file":"index.js","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\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 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: '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// ── 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":[],"mappings":";;;;;AAqPA,IAAM,MAAA,GAAS,4BAA+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,c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BAAA,GAAqC;AACnD,EAAA,OAAO,MAAA,EAAQ,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,GAAc,wBAAA,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,OAAO,aAAA,CAAc,MAAM,IAAI,CAAA;AAAA,EACjC;AACA,EAAA,OAAO,aAAA,CAAc,QAAQ,KAAK,CAAA;AACpC","file":"index.js","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"]}