@poolse/native 3.10.1 → 3.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  Formerly `@poolse/react-native-calls` (0.x).
4
4
 
5
+ ## [3.10.3] - 2026-11-26
6
+
7
+ No changes; released with the other packages.
8
+
9
+ ## [3.10.2] - 2026-11-23
10
+
11
+ ### Added
12
+
13
+ - Shared screen size (CL4): `snapshot.screenShare` (`{ userId,
14
+ externalId, width, height }` of the first remote sharer, null when
15
+ none) and `participants[].screenWidth` / `screenHeight`, from the
16
+ publisher's track info on both cores, so phones can line up screen
17
+ drawings instead of assuming 16:9. Type `ScreenShareInfo`.
18
+
5
19
  ## [3.10.1] - 2026-11-23
6
20
 
7
21
  ### Added
package/README.md CHANGED
@@ -94,6 +94,8 @@ The full API:
94
94
  - Screen sharing: `screenShareSupported`, `startScreenShare`, `stopScreenShare`,
95
95
  `snapshot.screenSharing` (yours) and `participants[].screenSharing`; draw a
96
96
  shared screen with `<CallVideoView participantId source="screen" fit="contain" />`.
97
+ `snapshot.screenShare` names who shares and the screen's `width`/`height`
98
+ (also `participants[].screenWidth` / `screenHeight`).
97
99
  iOS needs the `screenShare` plugin option.
98
100
  - Video: `<CallVideoView participantId | local mirror fit pictureInPicture />`,
99
101
  `setPictureInPictureEnabled`, `isInPictureInPicture`,
@@ -215,6 +217,8 @@ topics and messages as the web and desktop (`poolse.reaction`,
215
217
  import { callData } from '@poolse/native';
216
218
  const reactions = useCallReactions(callData);
217
219
  const { state, annotations } = useScreenAnnotations(callData, sharerUserId);
220
+ // snapshot.screenShare: { userId, externalId, width, height } — size the
221
+ // overlay to the screen's aspect inside the contain-fitted view.
218
222
  <CallVideoView participantId={sharerUserId} source="screen" fit="contain" />
219
223
  <AnnotationOverlay state={state} annotations={annotations} drawing={penOn} />
220
224
  ```
@@ -410,6 +410,10 @@ class CallCore private constructor(context: Context) {
410
410
  put("muted", it.muted)
411
411
  put("cameraOn", it.cameraOn)
412
412
  put("screenSharing", it.screenSharing)
413
+ if (it.screenSharing && it.screenWidth != null && it.screenHeight != null) {
414
+ put("screenWidth", it.screenWidth)
415
+ put("screenHeight", it.screenHeight)
416
+ }
413
417
  put("connectionQuality", it.connectionQuality)
414
418
  if (it.isAgent) {
415
419
  put("isAgent", true)
@@ -904,6 +908,9 @@ data class MediaParticipant(
904
908
  val cameraOn: Boolean = false,
905
909
  /** True with a published, subscribed, unmuted screen share — a screen to draw. */
906
910
  val screenSharing: Boolean = false,
911
+ /** The shared screen's size in pixels as published; null while unknown or not sharing. */
912
+ val screenWidth: Int? = null,
913
+ val screenHeight: Int? = null,
907
914
  /** The host app's own id for the user, when the SFU carries it; else the identity. */
908
915
  val externalId: String = identity,
909
916
  /** Their link to the SFU: `good` | `poor` | `lost` (dropped, coming back) | `unknown`. */
@@ -47,6 +47,19 @@ internal fun MachineState.toSnapshot(
47
47
  put("connectionQuality", connectionQuality)
48
48
  put("videoPaused", videoPaused)
49
49
  put("screenSharing", screenSharing)
50
+ // Who shares a screen (the first remote sharer) and its size, for
51
+ // lining up screen drawings (CL4); null when nobody else shares.
52
+ put(
53
+ "screenShare",
54
+ participants.firstOrNull { it["screenSharing"] == true }?.let { p ->
55
+ mapOf(
56
+ "userId" to p["userId"],
57
+ "externalId" to p["externalId"],
58
+ "width" to p["screenWidth"],
59
+ "height" to p["screenHeight"],
60
+ )
61
+ },
62
+ )
50
63
  put("audioOutputs", audioOutputs)
51
64
  put("audioOutputId", audioOutputId)
52
65
  // false: listen-only until the server lets go (docs/RECORDING.md §5).
@@ -455,6 +455,11 @@ class LiveKitMediaPort(
455
455
  return pub.track as? VideoTrack
456
456
  }
457
457
 
458
+ /** The shared screen's size as its publisher announced it (the SFU's track info); null while unknown. */
459
+ private fun screenDimensions(p: Participant): Track.Dimensions? =
460
+ p.getTrackPublication(Track.Source.SCREEN_SHARE)?.dimensions
461
+ ?.takeIf { it.width > 0 && it.height > 0 }
462
+
458
463
  private fun reportLocalScreen(r: Room) {
459
464
  if (room !== r) return
460
465
  events.onLocalScreen(localScreenTrack(r) != null)
@@ -725,6 +730,7 @@ class LiveKitMediaPort(
725
730
  events.onParticipants(
726
731
  agentRows.let { agentList -> people(room).map {
727
732
  val identity = it.identity?.value ?: ""
733
+ val screen = if (remoteScreen(it) != null) screenDimensions(it) else null
728
734
  MediaParticipant(
729
735
  identity = identity,
730
736
  speaking = it.isSpeaking,
@@ -733,6 +739,8 @@ class LiveKitMediaPort(
733
739
  // published, subscribed and unmuted.
734
740
  cameraOn = remoteCamera(it) != null,
735
741
  screenSharing = remoteScreen(it) != null,
742
+ screenWidth = screen?.width,
743
+ screenHeight = screen?.height,
736
744
  connectionQuality = wire(it.connectionQuality),
737
745
  externalId = externalIdOf(it) ?: identity,
738
746
  )
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["requireOptionalNativeModule","requireNativeViewManager","createElement","View"],"mappings":";;;;;;;AA2TO,IAAM,iBAAA,GAAoB;AAqKjC,IAAM,MAAA,GAASA,4CAA+C,aAAa,CAAA;AAGpE,IAAM,uBAAuB,MAAA,IAAU;AAG9C,IAAI,SAAA,GAA2B,IAAA;AAS/B,eAAsB,SAAA,CACpB,qBACA,OAAA,EACe;AACf,EAAA,IAAI,OAAO,wBAAwB,QAAA,EAAU;AAC3C,IAAA,MAAM,MAAA,EAAQ,SAAA,CAAU,EAAA,EAAI,mBAAA,IAAuB,IAAI,CAAA;AACvD,IAAA;AAAA,EACF;AACA,EAAA,SAAA,GAAY,mBAAA,CAAoB,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AAClD,EAAA,MAAM,MAAA,EAAQ,SAAA,CAAU,mBAAA,EAAqB,OAAA,IAAW,IAAI,CAAA;AAC9D;AAIA,IAAM,SAAA,GAAY,yBAAA;AAYlB,eAAsB,UAAU,MAAA,EAAmC;AACjE,EAAA,IAAI,CAAC,SAAA,CAAU,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;AAChC,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,MAAA,CAAO,UAAA,CAAW,OAAO,OAAA,KAAY,WAAW,OAAA,GAAU,IAAA,CAAK,SAAA,CAAU,OAAO,CAAC,CAAA;AAAA,EAChG,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;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 /**\n * You took this call on another of your devices (`moveCallHere`\n * there): it goes on without this one. Say \"Moved to your other\n * device\", not \"Call ended\". Absent before 3.10.\n */\n | 'moved';\n /**\n * REMOTE people only; `userId` is the LiveKit identity. poolse's\n * transcript assistant (`poolse:…`, kind agent) and the recorder\n * (LiveKit Egress, `EG_…`) are never listed — nor counted when the core\n * ends a call left alone. Phone (SIP) participants are listed. Agents\n * invited into the call are listed with `isAgent` (last), never counted.\n */\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 * An agent in the call (server docs/AGENTS_IN_CALLS.md): show it with\n * the Agent badge, named `agentLabel` — never as a person, never with\n * a camera placeholder. Absent for people and before 3.10.\n */\n isAgent?: boolean;\n /** \"Scout\", or \"Jasir's agent\" for one attending on someone's behalf. */\n agentLabel?: string | null;\n /** `notetaker` (silent) | `assistant` (answers when named) | `delegate`. */\n agentMode?: 'notetaker' | 'assistant' | 'delegate' | null;\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 * The server (workspace) this call runs on — the `id` given to\n * `addServer`, or `DEFAULT_SERVER_ID` for the one `configure` set.\n * Absent before 3.8.\n */\n serverId?: string | null;\n /**\n * That workspace's name: the ring push's `workspace_name`, else the\n * server's `name`. Absent before 3.8.\n */\n workspaceName?: string | null;\n /**\n * Whether the server lets you publish. `false` while recording consent\n * is required and you have not accepted (docs/RECORDING.md §5): you\n * still hear and see the call, but nothing of yours goes out. Your\n * `mutedSelf` / camera choices are kept and come back as they were once\n * it turns `true` again (the core republishes by itself; call\n * `republish()` from ConsentPrompt's `onAccepted` too). Absent before 3.9.\n */\n canPublish?: boolean;\n /**\n * The call's recording state as the server last told this core (on\n * answer / join / place and each reconnect) — enough to show the\n * indicator at once. Live changes arrive on the conversation socket\n * (`recording:*`). null: not known (a server without recording).\n * Absent before 3.9.\n */\n recording?: CallRecordingState | null;\n /** The live transcript's state, the same way (`transcript:*` on the socket). Absent before 3.9. */\n transcription?: CallTranscriptionState | null;\n /**\n * `meeting`: a scheduled meeting rang this device as it started (the\n * push's `ring_type`), so the ring reads \"Weekly sync is starting\" and\n * the call screen should name the meeting. `call` otherwise. Absent\n * before 3.10.\n */\n ringType?: 'call' | 'meeting';\n /** The meeting's title for a `meeting` ring; null otherwise. Absent before 3.10. */\n meetingTitle?: string | null;\n /** Noise suppression on the microphone (on by default; `setNoiseSuppression`). Absent before 3.10. */\n noiseSuppression?: boolean;\n /** Background blur on the camera (`setBackgroundBlur`). Absent before 3.10. */\n backgroundBlur?: boolean;\n /**\n * This call was taken over by your other device (`moveCallHere`\n * there); the end that follows has `reason: 'moved'`. Absent before 3.10.\n */\n movedElsewhere?: boolean;\n /**\n * The breakout room the call's media is in (`moveToRoom`,\n * MEETINGS.md §5); null in the call's main room. `roomId` is the\n * split's `<split id>.<n>`. Absent before 3.11.\n */\n breakout?: { roomId: string; name: string | null } | null;\n /**\n * Your own identity in the media room — your poolse user id — once\n * connected; what `callData.getSelfId()` answers. Absent before 3.11.\n */\n selfIdentity?: string | null;\n}\n\n/** The CallSummary's `recording` object, as the server sent it (docs/CALL_CONTRACT.md §4.2). */\nexport interface CallRecordingState {\n /** This server can record (LiveKit Egress). */\n available: boolean;\n active: boolean;\n id: string | null;\n mode: 'video' | 'audio' | null;\n started_at: string | null;\n started_by_user_id: string | null;\n auto: boolean;\n /** You may not publish until you accept. */\n consent_required: boolean;\n /** poolse user ids. */\n consent?: { accepted: string[]; declined: string[] };\n}\n\n/** The CallSummary's `transcription` object, as the server sent it. */\nexport interface CallTranscriptionState {\n available: boolean;\n active: boolean;\n id: string | null;\n status: 'live' | 'stopped' | 'ready' | null;\n language: string | null;\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 /** The server (workspace) it rings from — may differ from the current call's. Absent before 3.8. */\n serverId?: string | null;\n /** That workspace's name (\"Ana · Acme\"). Absent before 3.8. */\n workspaceName?: string | null;\n /** `meeting` when a scheduled meeting is starting rather than a person calling. Absent before 3.10. */\n ringType?: 'call' | 'meeting';\n /** The meeting's title for a `meeting` ring. Absent before 3.10. */\n meetingTitle?: string | null;\n}\n\n/** One place call audio can play. */\nexport interface AudioOutput {\n /** Opaque; stable while the device stays connected. */\n id: string;\n kind: AudioOutputKind;\n /**\n * The device's own name for Bluetooth/USB (\"AirPods Pro\"); a plain\n * English default for built-ins (\"iPhone\"/\"Phone\", \"Speaker\",\n * \"Headphones\") — relabel those by `kind` to localise.\n */\n name: string;\n}\n\nexport interface ConfigureOptions {\n /** Drawable resource NAME for the call notification's small icon. */\n smallIcon?: string;\n /** Ringback tone: raw resource NAME (Android); main-bundle sound name, mp3/caf/wav (iOS). */\n ringback?: string;\n /**\n * Incoming ringtone, overriding the config plugin's `ringtone` (leave it\n * out to use the plugin's, or the system ringtone without one).\n * Android: raw resource NAME (`ring` for `res/raw/ring.ogg`), played by\n * the module. iOS: a main-bundle sound CallKit plays — `ring.caf`, or the\n * base name looked up as caf/aiff/aif/wav; 30 s or shorter. Persisted, so\n * a ring that wakes a closed app uses it too. A name that is not in the\n * app rings with the system ringtone.\n */\n ringtone?: string;\n /**\n * Android: the full-screen incoming-call screen. Each field overrides the\n * config plugin's `incomingCall` option; leave one out to keep the\n * plugin's (or the built-in) value. Persisted for closed-app rings.\n * Ignored on iOS, where CallKit draws the call screen.\n */\n incomingCall?: IncomingCallOptions;\n /**\n * iOS: the APNs environment of this build's `aps-environment`\n * entitlement. Echoed back with the VoIP token so the server pushes to\n * the right gateway. Ignored on Android.\n */\n apnsEnvironment?: 'production' | 'sandbox';\n}\n\n/** Android's full-screen incoming call: its look, or the app's own activity instead. */\nexport interface IncomingCallOptions {\n /** `#RRGGBB` / `#AARRGGBB`: the glow, the pulsing ring and the initials disc (and the notification tint). */\n accentColor?: string;\n /** `#RRGGBB`: the screen's ground. A light one switches the text to dark. Default `#0B0B14`. */\n backgroundColor?: string;\n /**\n * The caller's picture, as a URL template: `{externalId}` (your app's id\n * for the caller) and `{userId}` (the poolse user id) are filled in,\n * URL-encoded — e.g. `https://cdn.example.com/avatars/{externalId}.jpg`.\n * Loaded off the main thread; the initials show until it loads, or if it\n * fails. A ring push's own `caller_avatar_url` wins over the template.\n */\n avatarUrl?: string;\n /**\n * Fully qualified class name of your own Activity (declared in your\n * manifest) to launch instead of the built-in screen. It receives the\n * `PoolseIncomingCall.EXTRA_*` extras and answers / declines through\n * `dev.poolse.callcore.android.PoolseIncomingCall` (see the README).\n * A leading `.` is relative to the application id.\n */\n activity?: string;\n}\n\n/** The iOS PushKit (VoIP) token and the APNs environment it belongs to. */\nexport interface VoipToken {\n /** Hex-encoded PushKit token. */\n token: string;\n environment: 'production' | 'sandbox' | string;\n}\n\nexport interface PlaceOptions {\n media: 'audio' | 'video';\n /** The user's session token — authorizes placing/joining (CALL_CONTRACT.md §3.2). */\n sessionToken: string;\n /**\n * The server (workspace) the session token belongs to — an `addServer`\n * id. Leave it out for the default server (`configure`'s).\n */\n serverId?: string;\n}\n\n/** The server `configure(apiBaseUrl)` sets; what everything defaults to. */\nexport const DEFAULT_SERVER_ID = 'default';\n\n/**\n * One server (workspace) the app is signed in to. No secrets: rings\n * carry their own grant, and place / join take the session token.\n */\nexport interface CallServer {\n /**\n * Your id for it, 1–64 of `A–Z a–z 0–9 . _ : -` — what `serverId`\n * says everywhere (snapshots, notification taps and actions).\n */\n id: string;\n /** Its API origin, as for `configure`. */\n apiBaseUrl: string;\n /**\n * The poolse tenant this sign-in belongs to (`tenant_id` of `me` or of\n * the registered device). Pushes carry it: it is how a ring or a\n * notification finds its server. Needed as soon as two servers are\n * added; without it a push goes to the default server.\n */\n tenantId?: string;\n /** The workspace's name — shown when a push carries none (\"Ana · Acme\"). */\n name?: string;\n}\n\n/**\n * What the user tapped on a missed-call or meeting notification: the\n * notification itself (`open` the conversation), a missed call's Call\n * back (`call_back` — place a call on the conversation with `media`), or\n * a starting meeting's Join (`join_meeting` — join the room `callId` in\n * the conversation, e.g. `poolse.rooms.start(conversationId, media)`,\n * which joins what is live).\n */\nexport interface CallAction {\n type: 'open' | 'call_back' | 'join_meeting';\n conversationId: string;\n callId: string | null;\n media: 'audio' | 'video';\n /** The server (workspace) it belongs to — open that one. Absent before 3.8. */\n serverId?: string | null;\n /** A meeting notice's scheduled meeting; null for missed calls. Absent before 3.10. */\n scheduledMeetingId?: string | null;\n}\n\n/**\n * A Reply or Mark as read the user did from a chat notification — or an\n * answer to an agent's question (`escalation`: Approve / Decline / Answer\n * on an `agent_escalation` push) — after the native core sent it (or gave\n * up). The server has already posted the reply and marked the\n * conversation read, or passed the answer to the agent in the call; use\n * this to refresh what the app shows without waiting for the socket, or\n * to tell the user it did not go out.\n */\nexport interface NotificationActionResult {\n action: 'reply' | 'mark_read' | 'escalation';\n /** The conversation (for `escalation`: the call's; `\"\"` when the push had none). */\n conversationId: string;\n /** `escalation` only: which question, and how it was answered. Absent before 3.10. */\n escalationId?: string;\n decision?: 'approve' | 'decline' | 'answer';\n /** `escalation` only: the call the agent is in. */\n callId?: string | null;\n /** The server (workspace) the conversation is on. Absent before 3.8. */\n serverId?: string;\n /** Whether the server accepted it. */\n ok: boolean;\n /** Reply (and an escalation's `answer`): 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>`. An\n * escalation: `not_pending`, `expired`, `invalid_token`, `no_token`.\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 addServer?(server: CallServer): Promise<void>;\n removeServer?(id: string): Promise<void>;\n listServers?(): CallServer[];\n serverForTenant?(tenantId: string | null): string | null;\n getCallState(): NativeSnapshot;\n place(\n conversationId: string,\n media: string,\n sessionToken: string,\n serverId: string | null,\n ): Promise<void>;\n join(\n callId: string,\n conversationId: string | null,\n sessionToken: string,\n serverId: string | null,\n ): 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 noiseSuppressionSupported?(): boolean;\n setNoiseSuppression?(on: boolean): boolean;\n backgroundBlurSupported?(): boolean;\n setBackgroundBlur?(on: boolean): boolean;\n setAudioOutput?(id: string): void;\n republish?(): void;\n publishData?(\n topic: string,\n data: string,\n options: { reliable?: boolean; base64?: boolean; to?: string[] } | null,\n ): Promise<boolean>;\n moveToRoom?(session: string): Promise<boolean>;\n callControl?(): Promise<{\n callId: string;\n controlToken: string;\n serverId?: string | null;\n apiBaseUrl?: string | null;\n } | 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, serverId: 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 addListener(event: 'onCallData', cb: (payload: CallDataMessage) => void): { 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/**\n * Configure once, before any call can arrive. No secrets — just the API\n * origin, which becomes the default server (`DEFAULT_SERVER_ID`).\n *\n * `configure(options)` sets the options alone, for an app whose servers\n * all come from `addServer`.\n */\nexport async function configure(\n apiBaseUrlOrOptions: string | ConfigureOptions,\n options?: ConfigureOptions,\n): Promise<void> {\n if (typeof apiBaseUrlOrOptions !== 'string') {\n await native?.configure('', apiBaseUrlOrOptions ?? null);\n return;\n }\n apiOrigin = apiBaseUrlOrOptions.replace(/\\/+$/, '');\n await native?.configure(apiBaseUrlOrOptions, options ?? null);\n}\n\n// ── several servers (workspaces) ──────────────────────────────────────\n\nconst SERVER_ID = /^[A-Za-z0-9._:-]{1,64}$/;\n\n/**\n * Sign the call core in to one more server (workspace) — or update one\n * (same `id`). Rings from it ring here, answered and declined on that\n * server; its chat notifications post (Android) and act (Reply, Mark as\n * read) against it. Persisted: a closed app woken by its push finds it.\n *\n * Register the device's push tokens with that server too (the SDK's\n * `devices.register`, per client): this only tells the core where it is.\n * Calls `configure` with default options first if it never ran.\n */\nexport async function addServer(server: CallServer): Promise<void> {\n if (!SERVER_ID.test(server.id))\n throw new Error(`addServer: invalid id ${JSON.stringify(server.id)}.`);\n if (!/^https?:\\/\\/[^\\s]+$/.test(server.apiBaseUrl))\n throw new Error('addServer: apiBaseUrl must be http(s).');\n const entry: CallServer = { id: server.id, apiBaseUrl: server.apiBaseUrl.replace(/\\/+$/, '') };\n if (server.tenantId) entry.tenantId = server.tenantId;\n if (server.name) entry.name = server.name;\n if (server.id === DEFAULT_SERVER_ID) apiOrigin = entry.apiBaseUrl;\n await native?.addServer?.(entry);\n}\n\n/**\n * Signed out of one server: the core forgets it and takes its\n * notifications down; the others are untouched. A call in progress on\n * it carries on to its end. Unregister its push tokens with that server\n * yourself (before signing out there).\n */\nexport async function removeServer(id: string): Promise<void> {\n if (id === DEFAULT_SERVER_ID) apiOrigin = null;\n await native?.removeServer?.(id);\n}\n\n/** The servers the core knows, in the order they were added (`configure`'s is `default`). */\nexport function listServers(): CallServer[] {\n return native?.listServers?.() ?? [];\n}\n\n/**\n * The server a notification (its data) belongs to, by its `tenant_id` —\n * the same rule the core routes rings and actions by. Use it on a tapped\n * iOS notification to open the right workspace. `null` with no server.\n */\nexport function serverOfNotification(\n data: Record<string, unknown> | undefined | null,\n): string | null {\n const tenant = data && typeof data['tenant_id'] === 'string' ? data['tenant_id'] : null;\n if (native?.serverForTenant) return native.serverForTenant(tenant);\n return apiOrigin ? DEFAULT_SERVER_ID : null;\n}\n\n/** The API origin of `serverId` (the default server when absent). */\nfunction originOf(serverId: string | null | undefined): string | null {\n if (!serverId || serverId === DEFAULT_SERVER_ID) {\n if (apiOrigin) return apiOrigin;\n }\n const id = serverId ?? DEFAULT_SERVER_ID;\n const server = listServers().find((s) => s.id === id);\n return server?.apiBaseUrl ?? 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 (\n native?.place(conversationId, options.media, options.sessionToken, options.serverId ?? null) ??\n Promise.resolve()\n );\n}\n\n/** `serverId`: the server the session token is for — leave it out for the default one. */\nexport function join(\n callId: string,\n conversationId: string | null,\n sessionToken: string,\n serverId?: string,\n): Promise<void> {\n return native?.join(callId, conversationId, sessionToken, serverId ?? null) ?? Promise.resolve();\n}\n\n/** What {@link moveCallHere} needs besides the call id. */\nexport interface MoveCallOptions {\n conversationId: string;\n /** The user's session token on the call's server. */\n sessionToken: string;\n /** The call's server (an `addServer` id); leave it out for the default one. */\n serverId?: string;\n}\n\n/**\n * \"Move call to this device\" (CL11): take a call you are on elsewhere\n * — your desktop, your other phone — over to this one without hanging\n * up. This device joins the same call; the server lets one device per\n * person carry it (CALL_CONTRACT.md §9), so the other one is let go and\n * its snapshot ends with `reason: 'moved'`. Offer it from the Join\n * banner when `liveCalls` says you are already in the call.\n *\n * The camera follows the call's media on this device; mute starts off.\n */\nexport function moveCallHere(callId: string, options: MoveCallOptions): Promise<void> {\n return join(callId, options.conversationId, options.sessionToken, options.serverId);\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 const origin = originOf(options.serverId);\n if (!origin) throw new Error('Call configure() (or addServer) before startRoom().');\n const res = await fetch(`${origin}/v1/conversations/${encodeURIComponent(conversationId)}/room`, {\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 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, options.serverId ?? null);\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 const control = await native.callControl();\n if (!control) throw new Error('There is no call in progress.');\n // The call's own server: it may be another workspace than the default.\n const origin = control.apiBaseUrl || originOf(control.serverId);\n if (!origin) throw new Error('Call configure() before ringIntoCall().');\n const res = await fetch(`${origin}/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// ── capture processing (CL7) ──────────────────────────────────────────\n\n/**\n * Whether noise suppression can be switched. On by default on both\n * platforms; the snapshot's `noiseSuppression` says what is in effect.\n */\nexport const noiseSuppressionSupported = (): boolean =>\n native?.noiseSuppressionSupported?.() ?? false;\n\n/**\n * Noise suppression on or off, for this and later calls (until the app\n * restarts). Android: WebRTC's noise suppression on the microphone\n * (echo cancellation stays on; the mic track is republished, a short\n * gap). iOS: Apple's voice processing does echo cancellation and noise\n * suppression as one, so off bypasses both — offer \"off\" for\n * headphones only. Returns false when the build can't.\n */\nexport const setNoiseSuppression = (on: boolean): boolean =>\n native?.setNoiseSuppression?.(on) ?? false;\n\n/**\n * Whether this build can blur the background behind you. iOS 15+: yes\n * (Vision person segmentation). Android: not yet — it needs an ML Kit\n * segmentation model, planned as a later addition. Hide the toggle when\n * false.\n */\nexport const backgroundBlurSupported = (): boolean => native?.backgroundBlurSupported?.() ?? false;\n\n/**\n * Blur the background on your camera, kept across camera flips and\n * calls. A no-op returning false where unsupported. Background\n * pictures (replacement) are not offered on native yet.\n */\nexport const setBackgroundBlur = (on: boolean): boolean => native?.setBackgroundBlur?.(on) ?? false;\n\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 * Recording consent accepted (ConsentPrompt's `onAccepted`): publish the\n * mic and camera again as the user last had them. The core also does it\n * by itself once the server lets this participant publish; calling it\n * early, or twice, is harmless — nothing goes out while\n * `snapshot.canPublish` is false.\n */\nexport const republish = (): void => native?.republish?.();\n\n/**\n * `snapshot.canPublish` changed (and once at subscribe time with the\n * current value, while a call is up). `true` when no call is up or the\n * native build predates it.\n */\nexport function onCanPublishChange(cb: (canPublish: boolean) => void): Unsubscribe {\n let last: boolean | null = null;\n const check = (snapshot: Snapshot | null): void => {\n const now = snapshot?.canPublish ?? true;\n if (now === last) return;\n const first = last === null;\n last = now;\n if (!first || snapshot) cb(now);\n };\n check(getCallState());\n return onCallState(check);\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 and meeting notifications ───────────────────────────────\n\n/**\n * The notification action the app was LAUNCHED with, once — read it on\n * mount. `null` when the app opened any other way.\n *\n * Android: missed calls and meeting notices (`starting` with Join, and\n * the brief; server docs/MEETINGS.md §11.3), both posted by the native\n * core from the push so they work with the app closed.\n *\n * iOS: meeting notices (the alert push's category `poolse_meeting`, Join\n * `poolse_meeting_join`), whose tap and Join arrive here as `open` /\n * `join_meeting`. Missed calls there are an ordinary alert push (to the\n * token you register with `kind: 'alert'`); read its taps with your\n * notification 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/** A missed-call (Android) or meeting notification (both) 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;\nlet activeServer: 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. Signed in to several servers, pass the one it is\n * on (`serverId`); without it, the conversation id alone decides.\n */\nexport function setActiveConversation(conversationId: string | null, serverId?: string): void {\n activeConversation = conversationId;\n activeServer = conversationId ? (serverId ?? null) : null;\n native?.setActiveConversation?.(conversationId, activeServer);\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 if (data['conversation_id'] !== activeConversation) return true;\n return activeServer != null && serverOfNotification(data) !== activeServer;\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`). Its server:\n * `serverOfNotification`.\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 its server's API origin (`configure` / `addServer`, persisted).\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 * `onNotificationAction`, agent escalations only (AG16): Approve / Decline\n * / Answer on an `agent_escalation` push, answered natively from the lock\n * screen. Feed `ok` ones to `poolse.escalations.list()` (or let\n * `agent:escalation` do it) so an open card updates.\n */\nexport function onEscalationAction(cb: (result: NotificationActionResult) => void): Unsubscribe {\n return onNotificationAction((result) => {\n if (result.action === 'escalation') 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// ── data channel (CL4, CL6) ───────────────────────────────────────────\n\n/**\n * The most one data-channel message may carry, in bytes — the same cap\n * as the web SDK's `CALL_DATA_MAX_BYTES`, under LiveKit's ~15 KiB packet.\n */\nexport const CALL_DATA_MAX_BYTES = 14_000;\n\n/** One message from someone in the call's room. */\nexport interface CallDataMessage {\n topic: string;\n /** The bytes, base64. */\n payload: string;\n /** The bytes as UTF-8 text; null when they are not text. */\n text: string | null;\n /** Who sent it (their poolse user id); null when the server did. */\n fromIdentity: string | null;\n fromName: string | null;\n}\n\nexport interface PublishDataOptions {\n /** Default true. `false` for what is stale a moment later (a moving pointer). */\n reliable?: boolean;\n /** `data` is base64 bytes rather than text. */\n base64?: boolean;\n /** Only these people (poolse user ids); everyone in the room when left out. */\n to?: string[];\n}\n\n/** UTF-8 length of `s`, without TextEncoder (not on every Hermes). */\nfunction utf8Length(s: string): number {\n let n = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) n += 1;\n else if (c < 0x800) n += 2;\n else if (c >= 0xd800 && c <= 0xdbff && i + 1 < s.length) {\n n += 4;\n i++;\n } else n += 3;\n }\n return n;\n}\n\n/**\n * Send `data` under `topic` to everyone in the call's room over LiveKit's\n * data channel, through the SFU, never stored (CL4, CL6). Web, desktop\n * and phones share topics and formats: `poolse.reaction`,\n * `poolse.annotate` (see {@link callData} for JSON). Resolves false with\n * no call connected, over {@link CALL_DATA_MAX_BYTES}, or on a build\n * without it.\n */\nexport async function publishData(\n topic: string,\n data: string,\n options: PublishDataOptions = {},\n): Promise<boolean> {\n if (!native?.publishData || !topic) return false;\n const size = options.base64 ? Math.floor((data.length * 3) / 4) : utf8Length(data);\n if (size > CALL_DATA_MAX_BYTES) return false;\n try {\n return await native.publishData(topic, data, {\n reliable: options.reliable ?? true,\n base64: options.base64 ?? false,\n ...(options.to ? { to: options.to } : {}),\n });\n } catch {\n return false;\n }\n}\n\n/** Every data-channel message others send in the call's room (yours are not echoed). */\nexport function onCallData(cb: (message: CallDataMessage) => void): Unsubscribe {\n if (!native?.publishData) return () => undefined;\n const sub = native.addListener('onCallData', cb);\n return () => sub.remove();\n}\n\ntype DataListener = (\n message: unknown,\n from: { userId: string | null; name: string | null },\n) => void;\nconst dataListeners = new Map<string, Set<DataListener>>();\nlet dataSub: Unsubscribe | null = null;\n\n/**\n * The native call's data channel in the shape @poolse/sdk's\n * `CallDataChannel` takes — JSON messages by topic — so the SDK's\n * `CallReactions` and `ScreenAnnotations` (and @poolse/react's\n * `useCallReactions` / `useScreenAnnotations`) run on phones exactly as\n * on the web and desktop, and interoperate with them:\n *\n * import { callData } from '@poolse/native';\n * const { reactions, send } = useCallReactions(callData);\n * const { state } = useScreenAnnotations(callData, sharerUserId);\n * <AnnotationOverlay state={state} />\n *\n * One process-wide object; it follows whichever call is live.\n */\nexport const callData = {\n getSelfId(): string | null {\n return getCallState()?.selfIdentity ?? null;\n },\n sendData(\n topic: string,\n message: unknown,\n opts: { reliable?: boolean; to?: string[] } = {},\n ): Promise<boolean> {\n let text: string;\n try {\n text = JSON.stringify(message);\n } catch {\n return Promise.resolve(false);\n }\n return publishData(topic, text, opts);\n },\n onData(topic: string, fn: DataListener): Unsubscribe {\n let set = dataListeners.get(topic);\n if (!set) {\n set = new Set();\n dataListeners.set(topic, set);\n }\n set.add(fn);\n dataSub ??= onCallData((m) => {\n const listeners = dataListeners.get(m.topic);\n if (!listeners?.size || m.text == null) return;\n let parsed: unknown;\n try {\n parsed = JSON.parse(m.text);\n } catch {\n return;\n }\n const from = { userId: m.fromIdentity, name: m.fromName };\n for (const l of [...listeners]) l(parsed, from);\n });\n return () => {\n set.delete(fn);\n if (set.size === 0) dataListeners.delete(topic);\n if (dataListeners.size === 0 && dataSub) {\n dataSub();\n dataSub = null;\n }\n };\n },\n};\n\n// ── breakout rooms (CL5) ──────────────────────────────────────────────\n\n/**\n * What {@link moveToRoom} takes: the session bundle `POST\n * /v1/breakouts/:room/join` or `POST /v1/calls/:id/breakouts/return`\n * answers with (@poolse/sdk's `meetingsLive.breakouts.join` /\n * `returnToMain`), or its JSON text.\n */\nexport interface RoomSessionBundle {\n call: { id: string };\n livekit: { url: string; token: string };\n control_token: string;\n breakout?: { room_id: string; name: string | null } | null;\n}\n\n/**\n * Breakout rooms (MEETINGS.md §5): move the call you are on into another\n * of its rooms — your breakout room, or back to the main room — without\n * hanging up. CallKit / the Android call service keep the call; only\n * the media swaps rooms, mute and camera as they were, and\n * `snapshot.breakout` says where you are. If the new room can't be\n * joined, the media goes back to the room it came from.\n *\n * Resolves false with no call connected (or still connecting), for\n * another call's session, or on a build without it. @poolse/react-native's\n * `useNativeBreakouts` does this for you as the split opens and closes.\n */\nexport async function moveToRoom(session: RoomSessionBundle | string): Promise<boolean> {\n if (!native?.moveToRoom) return false;\n try {\n return await native.moveToRoom(typeof session === 'string' ? session : JSON.stringify(session));\n } catch {\n return false;\n }\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":";;;;;;;AAkVO,IAAM,iBAAA,GAAoB;AAqKjC,IAAM,MAAA,GAASA,4CAA+C,aAAa,CAAA;AAGpE,IAAM,uBAAuB,MAAA,IAAU;AAG9C,IAAI,SAAA,GAA2B,IAAA;AAS/B,eAAsB,SAAA,CACpB,qBACA,OAAA,EACe;AACf,EAAA,IAAI,OAAO,wBAAwB,QAAA,EAAU;AAC3C,IAAA,MAAM,MAAA,EAAQ,SAAA,CAAU,EAAA,EAAI,mBAAA,IAAuB,IAAI,CAAA;AACvD,IAAA;AAAA,EACF;AACA,EAAA,SAAA,GAAY,mBAAA,CAAoB,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AAClD,EAAA,MAAM,MAAA,EAAQ,SAAA,CAAU,mBAAA,EAAqB,OAAA,IAAW,IAAI,CAAA;AAC9D;AAIA,IAAM,SAAA,GAAY,yBAAA;AAYlB,eAAsB,UAAU,MAAA,EAAmC;AACjE,EAAA,IAAI,CAAC,SAAA,CAAU,IAAA,CAAK,MAAA,CAAO,EAAE,CAAA;AAC3B,IAAA,MAAM,IAAI,MAAM,CAAA,sBAAA,EAAyB,IAAA,CAAK,UAAU,MAAA,CAAO,EAAE,CAAC,CAAA,CAAA,CAAG,CAAA;AACvE,EAAA,IAAI,CAAC,qBAAA,CAAsB,IAAA,CAAK,MAAA,CAAO,UAAU,CAAA;AAC/C,IAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAC1D,EAAA,MAAM,KAAA,GAAoB,EAAE,EAAA,EAAI,MAAA,CAAO,EAAA,EAAI,UAAA,EAAY,MAAA,CAAO,UAAA,CAAW,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA,EAAE;AAC7F,EAAA,IAAI,MAAA,CAAO,QAAA,EAAU,KAAA,CAAM,QAAA,GAAW,MAAA,CAAO,QAAA;AAC7C,EA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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 */\n/** `Snapshot.screenShare`: a remote participant's shared screen. */\nexport interface ScreenShareInfo {\n /** The sharer's LiveKit identity (their `participants[].userId`). */\n userId: string;\n externalId: string;\n width: number | null;\n height: number | null;\n}\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 /**\n * You took this call on another of your devices (`moveCallHere`\n * there): it goes on without this one. Say \"Moved to your other\n * device\", not \"Call ended\". Absent before 3.10.\n */\n | 'moved';\n /**\n * REMOTE people only; `userId` is the LiveKit identity. poolse's\n * transcript assistant (`poolse:…`, kind agent) and the recorder\n * (LiveKit Egress, `EG_…`) are never listed — nor counted when the core\n * ends a call left alone. Phone (SIP) participants are listed. Agents\n * invited into the call are listed with `isAgent` (last), never counted.\n */\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 * The shared screen's size in pixels as its publisher announced it;\n * present only while `screenSharing` and once known. Absent before 3.11.\n */\n screenWidth?: number;\n screenHeight?: number;\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 * An agent in the call (server docs/AGENTS_IN_CALLS.md): show it with\n * the Agent badge, named `agentLabel` — never as a person, never with\n * a camera placeholder. Absent for people and before 3.10.\n */\n isAgent?: boolean;\n /** \"Scout\", or \"Jasir's agent\" for one attending on someone's behalf. */\n agentLabel?: string | null;\n /** `notetaker` (silent) | `assistant` (answers when named) | `delegate`. */\n agentMode?: 'notetaker' | 'assistant' | 'delegate' | null;\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 * Who else shares a screen (the first remote sharer) and its size in\n * pixels, so screen drawings line up with what is shown (CL4): fit the\n * overlay to a `width`:`height` box inside the `fit=\"contain\"` view.\n * `width`/`height` are null until the sharer's size is known. null when\n * nobody else shares (yours is `screenSharing`); absent before 3.11.\n */\n screenShare?: ScreenShareInfo | null;\n /**\n * The server (workspace) this call runs on — the `id` given to\n * `addServer`, or `DEFAULT_SERVER_ID` for the one `configure` set.\n * Absent before 3.8.\n */\n serverId?: string | null;\n /**\n * That workspace's name: the ring push's `workspace_name`, else the\n * server's `name`. Absent before 3.8.\n */\n workspaceName?: string | null;\n /**\n * Whether the server lets you publish. `false` while recording consent\n * is required and you have not accepted (docs/RECORDING.md §5): you\n * still hear and see the call, but nothing of yours goes out. Your\n * `mutedSelf` / camera choices are kept and come back as they were once\n * it turns `true` again (the core republishes by itself; call\n * `republish()` from ConsentPrompt's `onAccepted` too). Absent before 3.9.\n */\n canPublish?: boolean;\n /**\n * The call's recording state as the server last told this core (on\n * answer / join / place and each reconnect) — enough to show the\n * indicator at once. Live changes arrive on the conversation socket\n * (`recording:*`). null: not known (a server without recording).\n * Absent before 3.9.\n */\n recording?: CallRecordingState | null;\n /** The live transcript's state, the same way (`transcript:*` on the socket). Absent before 3.9. */\n transcription?: CallTranscriptionState | null;\n /**\n * `meeting`: a scheduled meeting rang this device as it started (the\n * push's `ring_type`), so the ring reads \"Weekly sync is starting\" and\n * the call screen should name the meeting. `call` otherwise. Absent\n * before 3.10.\n */\n ringType?: 'call' | 'meeting';\n /** The meeting's title for a `meeting` ring; null otherwise. Absent before 3.10. */\n meetingTitle?: string | null;\n /** Noise suppression on the microphone (on by default; `setNoiseSuppression`). Absent before 3.10. */\n noiseSuppression?: boolean;\n /** Background blur on the camera (`setBackgroundBlur`). Absent before 3.10. */\n backgroundBlur?: boolean;\n /**\n * This call was taken over by your other device (`moveCallHere`\n * there); the end that follows has `reason: 'moved'`. Absent before 3.10.\n */\n movedElsewhere?: boolean;\n /**\n * The breakout room the call's media is in (`moveToRoom`,\n * MEETINGS.md §5); null in the call's main room. `roomId` is the\n * split's `<split id>.<n>`. Absent before 3.11.\n */\n breakout?: { roomId: string; name: string | null } | null;\n /**\n * Your own identity in the media room — your poolse user id — once\n * connected; what `callData.getSelfId()` answers. Absent before 3.11.\n */\n selfIdentity?: string | null;\n}\n\n/** The CallSummary's `recording` object, as the server sent it (docs/CALL_CONTRACT.md §4.2). */\nexport interface CallRecordingState {\n /** This server can record (LiveKit Egress). */\n available: boolean;\n active: boolean;\n id: string | null;\n mode: 'video' | 'audio' | null;\n started_at: string | null;\n started_by_user_id: string | null;\n auto: boolean;\n /** You may not publish until you accept. */\n consent_required: boolean;\n /** poolse user ids. */\n consent?: { accepted: string[]; declined: string[] };\n}\n\n/** The CallSummary's `transcription` object, as the server sent it. */\nexport interface CallTranscriptionState {\n available: boolean;\n active: boolean;\n id: string | null;\n status: 'live' | 'stopped' | 'ready' | null;\n language: string | null;\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 /** The server (workspace) it rings from — may differ from the current call's. Absent before 3.8. */\n serverId?: string | null;\n /** That workspace's name (\"Ana · Acme\"). Absent before 3.8. */\n workspaceName?: string | null;\n /** `meeting` when a scheduled meeting is starting rather than a person calling. Absent before 3.10. */\n ringType?: 'call' | 'meeting';\n /** The meeting's title for a `meeting` ring. Absent before 3.10. */\n meetingTitle?: string | null;\n}\n\n/** One place call audio can play. */\nexport interface AudioOutput {\n /** Opaque; stable while the device stays connected. */\n id: string;\n kind: AudioOutputKind;\n /**\n * The device's own name for Bluetooth/USB (\"AirPods Pro\"); a plain\n * English default for built-ins (\"iPhone\"/\"Phone\", \"Speaker\",\n * \"Headphones\") — relabel those by `kind` to localise.\n */\n name: string;\n}\n\nexport interface ConfigureOptions {\n /** Drawable resource NAME for the call notification's small icon. */\n smallIcon?: string;\n /** Ringback tone: raw resource NAME (Android); main-bundle sound name, mp3/caf/wav (iOS). */\n ringback?: string;\n /**\n * Incoming ringtone, overriding the config plugin's `ringtone` (leave it\n * out to use the plugin's, or the system ringtone without one).\n * Android: raw resource NAME (`ring` for `res/raw/ring.ogg`), played by\n * the module. iOS: a main-bundle sound CallKit plays — `ring.caf`, or the\n * base name looked up as caf/aiff/aif/wav; 30 s or shorter. Persisted, so\n * a ring that wakes a closed app uses it too. A name that is not in the\n * app rings with the system ringtone.\n */\n ringtone?: string;\n /**\n * Android: the full-screen incoming-call screen. Each field overrides the\n * config plugin's `incomingCall` option; leave one out to keep the\n * plugin's (or the built-in) value. Persisted for closed-app rings.\n * Ignored on iOS, where CallKit draws the call screen.\n */\n incomingCall?: IncomingCallOptions;\n /**\n * iOS: the APNs environment of this build's `aps-environment`\n * entitlement. Echoed back with the VoIP token so the server pushes to\n * the right gateway. Ignored on Android.\n */\n apnsEnvironment?: 'production' | 'sandbox';\n}\n\n/** Android's full-screen incoming call: its look, or the app's own activity instead. */\nexport interface IncomingCallOptions {\n /** `#RRGGBB` / `#AARRGGBB`: the glow, the pulsing ring and the initials disc (and the notification tint). */\n accentColor?: string;\n /** `#RRGGBB`: the screen's ground. A light one switches the text to dark. Default `#0B0B14`. */\n backgroundColor?: string;\n /**\n * The caller's picture, as a URL template: `{externalId}` (your app's id\n * for the caller) and `{userId}` (the poolse user id) are filled in,\n * URL-encoded — e.g. `https://cdn.example.com/avatars/{externalId}.jpg`.\n * Loaded off the main thread; the initials show until it loads, or if it\n * fails. A ring push's own `caller_avatar_url` wins over the template.\n */\n avatarUrl?: string;\n /**\n * Fully qualified class name of your own Activity (declared in your\n * manifest) to launch instead of the built-in screen. It receives the\n * `PoolseIncomingCall.EXTRA_*` extras and answers / declines through\n * `dev.poolse.callcore.android.PoolseIncomingCall` (see the README).\n * A leading `.` is relative to the application id.\n */\n activity?: string;\n}\n\n/** The iOS PushKit (VoIP) token and the APNs environment it belongs to. */\nexport interface VoipToken {\n /** Hex-encoded PushKit token. */\n token: string;\n environment: 'production' | 'sandbox' | string;\n}\n\nexport interface PlaceOptions {\n media: 'audio' | 'video';\n /** The user's session token — authorizes placing/joining (CALL_CONTRACT.md §3.2). */\n sessionToken: string;\n /**\n * The server (workspace) the session token belongs to — an `addServer`\n * id. Leave it out for the default server (`configure`'s).\n */\n serverId?: string;\n}\n\n/** The server `configure(apiBaseUrl)` sets; what everything defaults to. */\nexport const DEFAULT_SERVER_ID = 'default';\n\n/**\n * One server (workspace) the app is signed in to. No secrets: rings\n * carry their own grant, and place / join take the session token.\n */\nexport interface CallServer {\n /**\n * Your id for it, 1–64 of `A–Z a–z 0–9 . _ : -` — what `serverId`\n * says everywhere (snapshots, notification taps and actions).\n */\n id: string;\n /** Its API origin, as for `configure`. */\n apiBaseUrl: string;\n /**\n * The poolse tenant this sign-in belongs to (`tenant_id` of `me` or of\n * the registered device). Pushes carry it: it is how a ring or a\n * notification finds its server. Needed as soon as two servers are\n * added; without it a push goes to the default server.\n */\n tenantId?: string;\n /** The workspace's name — shown when a push carries none (\"Ana · Acme\"). */\n name?: string;\n}\n\n/**\n * What the user tapped on a missed-call or meeting notification: the\n * notification itself (`open` the conversation), a missed call's Call\n * back (`call_back` — place a call on the conversation with `media`), or\n * a starting meeting's Join (`join_meeting` — join the room `callId` in\n * the conversation, e.g. `poolse.rooms.start(conversationId, media)`,\n * which joins what is live).\n */\nexport interface CallAction {\n type: 'open' | 'call_back' | 'join_meeting';\n conversationId: string;\n callId: string | null;\n media: 'audio' | 'video';\n /** The server (workspace) it belongs to — open that one. Absent before 3.8. */\n serverId?: string | null;\n /** A meeting notice's scheduled meeting; null for missed calls. Absent before 3.10. */\n scheduledMeetingId?: string | null;\n}\n\n/**\n * A Reply or Mark as read the user did from a chat notification — or an\n * answer to an agent's question (`escalation`: Approve / Decline / Answer\n * on an `agent_escalation` push) — after the native core sent it (or gave\n * up). The server has already posted the reply and marked the\n * conversation read, or passed the answer to the agent in the call; use\n * this to refresh what the app shows without waiting for the socket, or\n * to tell the user it did not go out.\n */\nexport interface NotificationActionResult {\n action: 'reply' | 'mark_read' | 'escalation';\n /** The conversation (for `escalation`: the call's; `\"\"` when the push had none). */\n conversationId: string;\n /** `escalation` only: which question, and how it was answered. Absent before 3.10. */\n escalationId?: string;\n decision?: 'approve' | 'decline' | 'answer';\n /** `escalation` only: the call the agent is in. */\n callId?: string | null;\n /** The server (workspace) the conversation is on. Absent before 3.8. */\n serverId?: string;\n /** Whether the server accepted it. */\n ok: boolean;\n /** Reply (and an escalation's `answer`): 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>`. An\n * escalation: `not_pending`, `expired`, `invalid_token`, `no_token`.\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 addServer?(server: CallServer): Promise<void>;\n removeServer?(id: string): Promise<void>;\n listServers?(): CallServer[];\n serverForTenant?(tenantId: string | null): string | null;\n getCallState(): NativeSnapshot;\n place(\n conversationId: string,\n media: string,\n sessionToken: string,\n serverId: string | null,\n ): Promise<void>;\n join(\n callId: string,\n conversationId: string | null,\n sessionToken: string,\n serverId: string | null,\n ): 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 noiseSuppressionSupported?(): boolean;\n setNoiseSuppression?(on: boolean): boolean;\n backgroundBlurSupported?(): boolean;\n setBackgroundBlur?(on: boolean): boolean;\n setAudioOutput?(id: string): void;\n republish?(): void;\n publishData?(\n topic: string,\n data: string,\n options: { reliable?: boolean; base64?: boolean; to?: string[] } | null,\n ): Promise<boolean>;\n moveToRoom?(session: string): Promise<boolean>;\n callControl?(): Promise<{\n callId: string;\n controlToken: string;\n serverId?: string | null;\n apiBaseUrl?: string | null;\n } | 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, serverId: 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 addListener(event: 'onCallData', cb: (payload: CallDataMessage) => void): { 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/**\n * Configure once, before any call can arrive. No secrets — just the API\n * origin, which becomes the default server (`DEFAULT_SERVER_ID`).\n *\n * `configure(options)` sets the options alone, for an app whose servers\n * all come from `addServer`.\n */\nexport async function configure(\n apiBaseUrlOrOptions: string | ConfigureOptions,\n options?: ConfigureOptions,\n): Promise<void> {\n if (typeof apiBaseUrlOrOptions !== 'string') {\n await native?.configure('', apiBaseUrlOrOptions ?? null);\n return;\n }\n apiOrigin = apiBaseUrlOrOptions.replace(/\\/+$/, '');\n await native?.configure(apiBaseUrlOrOptions, options ?? null);\n}\n\n// ── several servers (workspaces) ──────────────────────────────────────\n\nconst SERVER_ID = /^[A-Za-z0-9._:-]{1,64}$/;\n\n/**\n * Sign the call core in to one more server (workspace) — or update one\n * (same `id`). Rings from it ring here, answered and declined on that\n * server; its chat notifications post (Android) and act (Reply, Mark as\n * read) against it. Persisted: a closed app woken by its push finds it.\n *\n * Register the device's push tokens with that server too (the SDK's\n * `devices.register`, per client): this only tells the core where it is.\n * Calls `configure` with default options first if it never ran.\n */\nexport async function addServer(server: CallServer): Promise<void> {\n if (!SERVER_ID.test(server.id))\n throw new Error(`addServer: invalid id ${JSON.stringify(server.id)}.`);\n if (!/^https?:\\/\\/[^\\s]+$/.test(server.apiBaseUrl))\n throw new Error('addServer: apiBaseUrl must be http(s).');\n const entry: CallServer = { id: server.id, apiBaseUrl: server.apiBaseUrl.replace(/\\/+$/, '') };\n if (server.tenantId) entry.tenantId = server.tenantId;\n if (server.name) entry.name = server.name;\n if (server.id === DEFAULT_SERVER_ID) apiOrigin = entry.apiBaseUrl;\n await native?.addServer?.(entry);\n}\n\n/**\n * Signed out of one server: the core forgets it and takes its\n * notifications down; the others are untouched. A call in progress on\n * it carries on to its end. Unregister its push tokens with that server\n * yourself (before signing out there).\n */\nexport async function removeServer(id: string): Promise<void> {\n if (id === DEFAULT_SERVER_ID) apiOrigin = null;\n await native?.removeServer?.(id);\n}\n\n/** The servers the core knows, in the order they were added (`configure`'s is `default`). */\nexport function listServers(): CallServer[] {\n return native?.listServers?.() ?? [];\n}\n\n/**\n * The server a notification (its data) belongs to, by its `tenant_id` —\n * the same rule the core routes rings and actions by. Use it on a tapped\n * iOS notification to open the right workspace. `null` with no server.\n */\nexport function serverOfNotification(\n data: Record<string, unknown> | undefined | null,\n): string | null {\n const tenant = data && typeof data['tenant_id'] === 'string' ? data['tenant_id'] : null;\n if (native?.serverForTenant) return native.serverForTenant(tenant);\n return apiOrigin ? DEFAULT_SERVER_ID : null;\n}\n\n/** The API origin of `serverId` (the default server when absent). */\nfunction originOf(serverId: string | null | undefined): string | null {\n if (!serverId || serverId === DEFAULT_SERVER_ID) {\n if (apiOrigin) return apiOrigin;\n }\n const id = serverId ?? DEFAULT_SERVER_ID;\n const server = listServers().find((s) => s.id === id);\n return server?.apiBaseUrl ?? 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 (\n native?.place(conversationId, options.media, options.sessionToken, options.serverId ?? null) ??\n Promise.resolve()\n );\n}\n\n/** `serverId`: the server the session token is for — leave it out for the default one. */\nexport function join(\n callId: string,\n conversationId: string | null,\n sessionToken: string,\n serverId?: string,\n): Promise<void> {\n return native?.join(callId, conversationId, sessionToken, serverId ?? null) ?? Promise.resolve();\n}\n\n/** What {@link moveCallHere} needs besides the call id. */\nexport interface MoveCallOptions {\n conversationId: string;\n /** The user's session token on the call's server. */\n sessionToken: string;\n /** The call's server (an `addServer` id); leave it out for the default one. */\n serverId?: string;\n}\n\n/**\n * \"Move call to this device\" (CL11): take a call you are on elsewhere\n * — your desktop, your other phone — over to this one without hanging\n * up. This device joins the same call; the server lets one device per\n * person carry it (CALL_CONTRACT.md §9), so the other one is let go and\n * its snapshot ends with `reason: 'moved'`. Offer it from the Join\n * banner when `liveCalls` says you are already in the call.\n *\n * The camera follows the call's media on this device; mute starts off.\n */\nexport function moveCallHere(callId: string, options: MoveCallOptions): Promise<void> {\n return join(callId, options.conversationId, options.sessionToken, options.serverId);\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 const origin = originOf(options.serverId);\n if (!origin) throw new Error('Call configure() (or addServer) before startRoom().');\n const res = await fetch(`${origin}/v1/conversations/${encodeURIComponent(conversationId)}/room`, {\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 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, options.serverId ?? null);\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 const control = await native.callControl();\n if (!control) throw new Error('There is no call in progress.');\n // The call's own server: it may be another workspace than the default.\n const origin = control.apiBaseUrl || originOf(control.serverId);\n if (!origin) throw new Error('Call configure() before ringIntoCall().');\n const res = await fetch(`${origin}/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// ── capture processing (CL7) ──────────────────────────────────────────\n\n/**\n * Whether noise suppression can be switched. On by default on both\n * platforms; the snapshot's `noiseSuppression` says what is in effect.\n */\nexport const noiseSuppressionSupported = (): boolean =>\n native?.noiseSuppressionSupported?.() ?? false;\n\n/**\n * Noise suppression on or off, for this and later calls (until the app\n * restarts). Android: WebRTC's noise suppression on the microphone\n * (echo cancellation stays on; the mic track is republished, a short\n * gap). iOS: Apple's voice processing does echo cancellation and noise\n * suppression as one, so off bypasses both — offer \"off\" for\n * headphones only. Returns false when the build can't.\n */\nexport const setNoiseSuppression = (on: boolean): boolean =>\n native?.setNoiseSuppression?.(on) ?? false;\n\n/**\n * Whether this build can blur the background behind you. iOS 15+: yes\n * (Vision person segmentation). Android: not yet — it needs an ML Kit\n * segmentation model, planned as a later addition. Hide the toggle when\n * false.\n */\nexport const backgroundBlurSupported = (): boolean => native?.backgroundBlurSupported?.() ?? false;\n\n/**\n * Blur the background on your camera, kept across camera flips and\n * calls. A no-op returning false where unsupported. Background\n * pictures (replacement) are not offered on native yet.\n */\nexport const setBackgroundBlur = (on: boolean): boolean => native?.setBackgroundBlur?.(on) ?? false;\n\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 * Recording consent accepted (ConsentPrompt's `onAccepted`): publish the\n * mic and camera again as the user last had them. The core also does it\n * by itself once the server lets this participant publish; calling it\n * early, or twice, is harmless — nothing goes out while\n * `snapshot.canPublish` is false.\n */\nexport const republish = (): void => native?.republish?.();\n\n/**\n * `snapshot.canPublish` changed (and once at subscribe time with the\n * current value, while a call is up). `true` when no call is up or the\n * native build predates it.\n */\nexport function onCanPublishChange(cb: (canPublish: boolean) => void): Unsubscribe {\n let last: boolean | null = null;\n const check = (snapshot: Snapshot | null): void => {\n const now = snapshot?.canPublish ?? true;\n if (now === last) return;\n const first = last === null;\n last = now;\n if (!first || snapshot) cb(now);\n };\n check(getCallState());\n return onCallState(check);\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 and meeting notifications ───────────────────────────────\n\n/**\n * The notification action the app was LAUNCHED with, once — read it on\n * mount. `null` when the app opened any other way.\n *\n * Android: missed calls and meeting notices (`starting` with Join, and\n * the brief; server docs/MEETINGS.md §11.3), both posted by the native\n * core from the push so they work with the app closed.\n *\n * iOS: meeting notices (the alert push's category `poolse_meeting`, Join\n * `poolse_meeting_join`), whose tap and Join arrive here as `open` /\n * `join_meeting`. Missed calls there are an ordinary alert push (to the\n * token you register with `kind: 'alert'`); read its taps with your\n * notification 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/** A missed-call (Android) or meeting notification (both) 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;\nlet activeServer: 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. Signed in to several servers, pass the one it is\n * on (`serverId`); without it, the conversation id alone decides.\n */\nexport function setActiveConversation(conversationId: string | null, serverId?: string): void {\n activeConversation = conversationId;\n activeServer = conversationId ? (serverId ?? null) : null;\n native?.setActiveConversation?.(conversationId, activeServer);\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 if (data['conversation_id'] !== activeConversation) return true;\n return activeServer != null && serverOfNotification(data) !== activeServer;\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`). Its server:\n * `serverOfNotification`.\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 its server's API origin (`configure` / `addServer`, persisted).\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 * `onNotificationAction`, agent escalations only (AG16): Approve / Decline\n * / Answer on an `agent_escalation` push, answered natively from the lock\n * screen. Feed `ok` ones to `poolse.escalations.list()` (or let\n * `agent:escalation` do it) so an open card updates.\n */\nexport function onEscalationAction(cb: (result: NotificationActionResult) => void): Unsubscribe {\n return onNotificationAction((result) => {\n if (result.action === 'escalation') 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// ── data channel (CL4, CL6) ───────────────────────────────────────────\n\n/**\n * The most one data-channel message may carry, in bytes — the same cap\n * as the web SDK's `CALL_DATA_MAX_BYTES`, under LiveKit's ~15 KiB packet.\n */\nexport const CALL_DATA_MAX_BYTES = 14_000;\n\n/** One message from someone in the call's room. */\nexport interface CallDataMessage {\n topic: string;\n /** The bytes, base64. */\n payload: string;\n /** The bytes as UTF-8 text; null when they are not text. */\n text: string | null;\n /** Who sent it (their poolse user id); null when the server did. */\n fromIdentity: string | null;\n fromName: string | null;\n}\n\nexport interface PublishDataOptions {\n /** Default true. `false` for what is stale a moment later (a moving pointer). */\n reliable?: boolean;\n /** `data` is base64 bytes rather than text. */\n base64?: boolean;\n /** Only these people (poolse user ids); everyone in the room when left out. */\n to?: string[];\n}\n\n/** UTF-8 length of `s`, without TextEncoder (not on every Hermes). */\nfunction utf8Length(s: string): number {\n let n = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) n += 1;\n else if (c < 0x800) n += 2;\n else if (c >= 0xd800 && c <= 0xdbff && i + 1 < s.length) {\n n += 4;\n i++;\n } else n += 3;\n }\n return n;\n}\n\n/**\n * Send `data` under `topic` to everyone in the call's room over LiveKit's\n * data channel, through the SFU, never stored (CL4, CL6). Web, desktop\n * and phones share topics and formats: `poolse.reaction`,\n * `poolse.annotate` (see {@link callData} for JSON). Resolves false with\n * no call connected, over {@link CALL_DATA_MAX_BYTES}, or on a build\n * without it.\n */\nexport async function publishData(\n topic: string,\n data: string,\n options: PublishDataOptions = {},\n): Promise<boolean> {\n if (!native?.publishData || !topic) return false;\n const size = options.base64 ? Math.floor((data.length * 3) / 4) : utf8Length(data);\n if (size > CALL_DATA_MAX_BYTES) return false;\n try {\n return await native.publishData(topic, data, {\n reliable: options.reliable ?? true,\n base64: options.base64 ?? false,\n ...(options.to ? { to: options.to } : {}),\n });\n } catch {\n return false;\n }\n}\n\n/** Every data-channel message others send in the call's room (yours are not echoed). */\nexport function onCallData(cb: (message: CallDataMessage) => void): Unsubscribe {\n if (!native?.publishData) return () => undefined;\n const sub = native.addListener('onCallData', cb);\n return () => sub.remove();\n}\n\ntype DataListener = (\n message: unknown,\n from: { userId: string | null; name: string | null },\n) => void;\nconst dataListeners = new Map<string, Set<DataListener>>();\nlet dataSub: Unsubscribe | null = null;\n\n/**\n * The native call's data channel in the shape @poolse/sdk's\n * `CallDataChannel` takes — JSON messages by topic — so the SDK's\n * `CallReactions` and `ScreenAnnotations` (and @poolse/react's\n * `useCallReactions` / `useScreenAnnotations`) run on phones exactly as\n * on the web and desktop, and interoperate with them:\n *\n * import { callData } from '@poolse/native';\n * const { reactions, send } = useCallReactions(callData);\n * const { state } = useScreenAnnotations(callData, sharerUserId);\n * <AnnotationOverlay state={state} />\n *\n * One process-wide object; it follows whichever call is live.\n */\nexport const callData = {\n getSelfId(): string | null {\n return getCallState()?.selfIdentity ?? null;\n },\n sendData(\n topic: string,\n message: unknown,\n opts: { reliable?: boolean; to?: string[] } = {},\n ): Promise<boolean> {\n let text: string;\n try {\n text = JSON.stringify(message);\n } catch {\n return Promise.resolve(false);\n }\n return publishData(topic, text, opts);\n },\n onData(topic: string, fn: DataListener): Unsubscribe {\n let set = dataListeners.get(topic);\n if (!set) {\n set = new Set();\n dataListeners.set(topic, set);\n }\n set.add(fn);\n dataSub ??= onCallData((m) => {\n const listeners = dataListeners.get(m.topic);\n if (!listeners?.size || m.text == null) return;\n let parsed: unknown;\n try {\n parsed = JSON.parse(m.text);\n } catch {\n return;\n }\n const from = { userId: m.fromIdentity, name: m.fromName };\n for (const l of [...listeners]) l(parsed, from);\n });\n return () => {\n set.delete(fn);\n if (set.size === 0) dataListeners.delete(topic);\n if (dataListeners.size === 0 && dataSub) {\n dataSub();\n dataSub = null;\n }\n };\n },\n};\n\n// ── breakout rooms (CL5) ──────────────────────────────────────────────\n\n/**\n * What {@link moveToRoom} takes: the session bundle `POST\n * /v1/breakouts/:room/join` or `POST /v1/calls/:id/breakouts/return`\n * answers with (@poolse/sdk's `meetingsLive.breakouts.join` /\n * `returnToMain`), or its JSON text.\n */\nexport interface RoomSessionBundle {\n call: { id: string };\n livekit: { url: string; token: string };\n control_token: string;\n breakout?: { room_id: string; name: string | null } | null;\n}\n\n/**\n * Breakout rooms (MEETINGS.md §5): move the call you are on into another\n * of its rooms — your breakout room, or back to the main room — without\n * hanging up. CallKit / the Android call service keep the call; only\n * the media swaps rooms, mute and camera as they were, and\n * `snapshot.breakout` says where you are. If the new room can't be\n * joined, the media goes back to the room it came from.\n *\n * Resolves false with no call connected (or still connecting), for\n * another call's session, or on a build without it. @poolse/react-native's\n * `useNativeBreakouts` does this for you as the split opens and closes.\n */\nexport async function moveToRoom(session: RoomSessionBundle | string): Promise<boolean> {\n if (!native?.moveToRoom) return false;\n try {\n return await native.moveToRoom(typeof session === 'string' ? session : JSON.stringify(session));\n } catch {\n return false;\n }\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
@@ -6,6 +6,14 @@ import { ViewProps } from 'react-native';
6
6
  * ends the snapshot stays `phase: 'ended'` (with `reason`) for ~2.5 s,
7
7
  * then becomes `null`.
8
8
  */
9
+ /** `Snapshot.screenShare`: a remote participant's shared screen. */
10
+ interface ScreenShareInfo {
11
+ /** The sharer's LiveKit identity (their `participants[].userId`). */
12
+ userId: string;
13
+ externalId: string;
14
+ width: number | null;
15
+ height: number | null;
16
+ }
9
17
  interface Snapshot {
10
18
  cv: 1;
11
19
  callId: string;
@@ -46,6 +54,12 @@ interface Snapshot {
46
54
  * large and with `fit="contain"`. Absent before 3.2.
47
55
  */
48
56
  screenSharing?: boolean;
57
+ /**
58
+ * The shared screen's size in pixels as its publisher announced it;
59
+ * present only while `screenSharing` and once known. Absent before 3.11.
60
+ */
61
+ screenWidth?: number;
62
+ screenHeight?: number;
49
63
  /**
50
64
  * Their link to the call: `lost` while they have dropped and are
51
65
  * coming back (show "Reconnecting…"), `poor` for a weak signal.
@@ -102,6 +116,14 @@ interface Snapshot {
102
116
  videoPaused?: boolean;
103
117
  /** You are sharing your screen. Absent before 3.2. */
104
118
  screenSharing?: boolean;
119
+ /**
120
+ * Who else shares a screen (the first remote sharer) and its size in
121
+ * pixels, so screen drawings line up with what is shown (CL4): fit the
122
+ * overlay to a `width`:`height` box inside the `fit="contain"` view.
123
+ * `width`/`height` are null until the sharer's size is known. null when
124
+ * nobody else shares (yours is `screenSharing`); absent before 3.11.
125
+ */
126
+ screenShare?: ScreenShareInfo | null;
105
127
  /**
106
128
  * The server (workspace) this call runs on — the `id` given to
107
129
  * `addServer`, or `DEFAULT_SERVER_ID` for the one `configure` set.
@@ -794,4 +816,4 @@ interface CallVideoViewProps extends ViewProps {
794
816
  */
795
817
  declare function CallVideoView(props: CallVideoViewProps): ReactElement | null;
796
818
 
797
- export { type AudioOutput, type AudioOutputKind, CALL_DATA_MAX_BYTES, type CallAction, type CallDataMessage, type CallRecordingState, type CallServer, type CallTranscriptionState, CallVideoView, type CallVideoViewProps, type ConfigureOptions, type ConnectionQuality, DEFAULT_SERVER_ID, type IncomingCallOptions, type MoveCallOptions, type NotificationActionResult, type PlaceOptions, type PublishDataOptions, type RingIntoCallOptions, type RoomSessionBundle, type Snapshot, type StartRoomResult, type Unsubscribe, type VoipToken, type WaitingCall, addServer, answer, answerWaiting, backgroundBlurSupported, callData, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, listServers, moveCallHere, moveToRoom, nativeCallsAvailable, noiseSuppressionSupported, onCallAction, onCallData, onCallFinished, onCallState, onCanPublishChange, onEscalationAction, onNotificationAction, onNotificationReply, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, publishData, removeServer, republish, ringIntoCall, screenShareSupported, serverOfNotification, setActiveConversation, setAudioOutput, setBackgroundBlur, setCamera, setMuted, setNoiseSuppression, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction, takeNotificationActions };
819
+ export { type AudioOutput, type AudioOutputKind, CALL_DATA_MAX_BYTES, type CallAction, type CallDataMessage, type CallRecordingState, type CallServer, type CallTranscriptionState, CallVideoView, type CallVideoViewProps, type ConfigureOptions, type ConnectionQuality, DEFAULT_SERVER_ID, type IncomingCallOptions, type MoveCallOptions, type NotificationActionResult, type PlaceOptions, type PublishDataOptions, type RingIntoCallOptions, type RoomSessionBundle, type ScreenShareInfo, type Snapshot, type StartRoomResult, type Unsubscribe, type VoipToken, type WaitingCall, addServer, answer, answerWaiting, backgroundBlurSupported, callData, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, listServers, moveCallHere, moveToRoom, nativeCallsAvailable, noiseSuppressionSupported, onCallAction, onCallData, onCallFinished, onCallState, onCanPublishChange, onEscalationAction, onNotificationAction, onNotificationReply, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, publishData, removeServer, republish, ringIntoCall, screenShareSupported, serverOfNotification, setActiveConversation, setAudioOutput, setBackgroundBlur, setCamera, setMuted, setNoiseSuppression, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction, takeNotificationActions };
package/dist/index.d.ts CHANGED
@@ -6,6 +6,14 @@ import { ViewProps } from 'react-native';
6
6
  * ends the snapshot stays `phase: 'ended'` (with `reason`) for ~2.5 s,
7
7
  * then becomes `null`.
8
8
  */
9
+ /** `Snapshot.screenShare`: a remote participant's shared screen. */
10
+ interface ScreenShareInfo {
11
+ /** The sharer's LiveKit identity (their `participants[].userId`). */
12
+ userId: string;
13
+ externalId: string;
14
+ width: number | null;
15
+ height: number | null;
16
+ }
9
17
  interface Snapshot {
10
18
  cv: 1;
11
19
  callId: string;
@@ -46,6 +54,12 @@ interface Snapshot {
46
54
  * large and with `fit="contain"`. Absent before 3.2.
47
55
  */
48
56
  screenSharing?: boolean;
57
+ /**
58
+ * The shared screen's size in pixels as its publisher announced it;
59
+ * present only while `screenSharing` and once known. Absent before 3.11.
60
+ */
61
+ screenWidth?: number;
62
+ screenHeight?: number;
49
63
  /**
50
64
  * Their link to the call: `lost` while they have dropped and are
51
65
  * coming back (show "Reconnecting…"), `poor` for a weak signal.
@@ -102,6 +116,14 @@ interface Snapshot {
102
116
  videoPaused?: boolean;
103
117
  /** You are sharing your screen. Absent before 3.2. */
104
118
  screenSharing?: boolean;
119
+ /**
120
+ * Who else shares a screen (the first remote sharer) and its size in
121
+ * pixels, so screen drawings line up with what is shown (CL4): fit the
122
+ * overlay to a `width`:`height` box inside the `fit="contain"` view.
123
+ * `width`/`height` are null until the sharer's size is known. null when
124
+ * nobody else shares (yours is `screenSharing`); absent before 3.11.
125
+ */
126
+ screenShare?: ScreenShareInfo | null;
105
127
  /**
106
128
  * The server (workspace) this call runs on — the `id` given to
107
129
  * `addServer`, or `DEFAULT_SERVER_ID` for the one `configure` set.
@@ -794,4 +816,4 @@ interface CallVideoViewProps extends ViewProps {
794
816
  */
795
817
  declare function CallVideoView(props: CallVideoViewProps): ReactElement | null;
796
818
 
797
- export { type AudioOutput, type AudioOutputKind, CALL_DATA_MAX_BYTES, type CallAction, type CallDataMessage, type CallRecordingState, type CallServer, type CallTranscriptionState, CallVideoView, type CallVideoViewProps, type ConfigureOptions, type ConnectionQuality, DEFAULT_SERVER_ID, type IncomingCallOptions, type MoveCallOptions, type NotificationActionResult, type PlaceOptions, type PublishDataOptions, type RingIntoCallOptions, type RoomSessionBundle, type Snapshot, type StartRoomResult, type Unsubscribe, type VoipToken, type WaitingCall, addServer, answer, answerWaiting, backgroundBlurSupported, callData, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, listServers, moveCallHere, moveToRoom, nativeCallsAvailable, noiseSuppressionSupported, onCallAction, onCallData, onCallFinished, onCallState, onCanPublishChange, onEscalationAction, onNotificationAction, onNotificationReply, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, publishData, removeServer, republish, ringIntoCall, screenShareSupported, serverOfNotification, setActiveConversation, setAudioOutput, setBackgroundBlur, setCamera, setMuted, setNoiseSuppression, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction, takeNotificationActions };
819
+ export { type AudioOutput, type AudioOutputKind, CALL_DATA_MAX_BYTES, type CallAction, type CallDataMessage, type CallRecordingState, type CallServer, type CallTranscriptionState, CallVideoView, type CallVideoViewProps, type ConfigureOptions, type ConnectionQuality, DEFAULT_SERVER_ID, type IncomingCallOptions, type MoveCallOptions, type NotificationActionResult, type PlaceOptions, type PublishDataOptions, type RingIntoCallOptions, type RoomSessionBundle, type ScreenShareInfo, type Snapshot, type StartRoomResult, type Unsubscribe, type VoipToken, type WaitingCall, addServer, answer, answerWaiting, backgroundBlurSupported, callData, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, listServers, moveCallHere, moveToRoom, nativeCallsAvailable, noiseSuppressionSupported, onCallAction, onCallData, onCallFinished, onCallState, onCanPublishChange, onEscalationAction, onNotificationAction, onNotificationReply, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, publishData, removeServer, republish, ringIntoCall, screenShareSupported, serverOfNotification, setActiveConversation, setAudioOutput, setBackgroundBlur, setCamera, setMuted, setNoiseSuppression, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction, takeNotificationActions };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;AA2TO,IAAM,iBAAA,GAAoB;AAqKjC,IAAM,MAAA,GAAS,4BAA+C,aAAa,CAAA;AAGpE,IAAM,uBAAuB,MAAA,IAAU;AAG9C,IAAI,SAAA,GAA2B,IAAA;AAS/B,eAAsB,SAAA,CACpB,qBACA,OAAA,EACe;AACf,EAAA,IAAI,OAAO,wBAAwB,QAAA,EAAU;AAC3C,IAAA,MAAM,MAAA,EAAQ,SAAA,CAAU,EAAA,EAAI,mBAAA,IAAuB,IAAI,CAAA;AACvD,IAAA;AAAA,EACF;AACA,EAAA,SAAA,GAAY,mBAAA,CAAoB,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AAClD,EAAA,MAAM,MAAA,EAAQ,SAAA,CAAU,mBAAA,EAAqB,OAAA,IAAW,IAAI,CAAA;AAC9D;AAIA,IAAM,SAAA,GAAY,yBAAA;AAYlB,eAAsB,UAAU,MAAA,EAAmC;AACjE,EAAA,IAAI,CAAC,SAAA,CAAU,IAAA,CAAK,MAAA,CAAO,EAAE,CAAA;AAC3B,IAAA,MAAM,IAAI,MAAM,CAAA,sBAAA,EAAyB,IAAA,CAAK,UAAU,MAAA,CAAO,EA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CAAU,OAAO,CAAC,CAAA;AAAA,EAChG,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;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 /**\n * You took this call on another of your devices (`moveCallHere`\n * there): it goes on without this one. Say \"Moved to your other\n * device\", not \"Call ended\". Absent before 3.10.\n */\n | 'moved';\n /**\n * REMOTE people only; `userId` is the LiveKit identity. poolse's\n * transcript assistant (`poolse:…`, kind agent) and the recorder\n * (LiveKit Egress, `EG_…`) are never listed — nor counted when the core\n * ends a call left alone. Phone (SIP) participants are listed. Agents\n * invited into the call are listed with `isAgent` (last), never counted.\n */\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 * An agent in the call (server docs/AGENTS_IN_CALLS.md): show it with\n * the Agent badge, named `agentLabel` — never as a person, never with\n * a camera placeholder. Absent for people and before 3.10.\n */\n isAgent?: boolean;\n /** \"Scout\", or \"Jasir's agent\" for one attending on someone's behalf. */\n agentLabel?: string | null;\n /** `notetaker` (silent) | `assistant` (answers when named) | `delegate`. */\n agentMode?: 'notetaker' | 'assistant' | 'delegate' | null;\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 * The server (workspace) this call runs on — the `id` given to\n * `addServer`, or `DEFAULT_SERVER_ID` for the one `configure` set.\n * Absent before 3.8.\n */\n serverId?: string | null;\n /**\n * That workspace's name: the ring push's `workspace_name`, else the\n * server's `name`. Absent before 3.8.\n */\n workspaceName?: string | null;\n /**\n * Whether the server lets you publish. `false` while recording consent\n * is required and you have not accepted (docs/RECORDING.md §5): you\n * still hear and see the call, but nothing of yours goes out. Your\n * `mutedSelf` / camera choices are kept and come back as they were once\n * it turns `true` again (the core republishes by itself; call\n * `republish()` from ConsentPrompt's `onAccepted` too). Absent before 3.9.\n */\n canPublish?: boolean;\n /**\n * The call's recording state as the server last told this core (on\n * answer / join / place and each reconnect) — enough to show the\n * indicator at once. Live changes arrive on the conversation socket\n * (`recording:*`). null: not known (a server without recording).\n * Absent before 3.9.\n */\n recording?: CallRecordingState | null;\n /** The live transcript's state, the same way (`transcript:*` on the socket). Absent before 3.9. */\n transcription?: CallTranscriptionState | null;\n /**\n * `meeting`: a scheduled meeting rang this device as it started (the\n * push's `ring_type`), so the ring reads \"Weekly sync is starting\" and\n * the call screen should name the meeting. `call` otherwise. Absent\n * before 3.10.\n */\n ringType?: 'call' | 'meeting';\n /** The meeting's title for a `meeting` ring; null otherwise. Absent before 3.10. */\n meetingTitle?: string | null;\n /** Noise suppression on the microphone (on by default; `setNoiseSuppression`). Absent before 3.10. */\n noiseSuppression?: boolean;\n /** Background blur on the camera (`setBackgroundBlur`). Absent before 3.10. */\n backgroundBlur?: boolean;\n /**\n * This call was taken over by your other device (`moveCallHere`\n * there); the end that follows has `reason: 'moved'`. Absent before 3.10.\n */\n movedElsewhere?: boolean;\n /**\n * The breakout room the call's media is in (`moveToRoom`,\n * MEETINGS.md §5); null in the call's main room. `roomId` is the\n * split's `<split id>.<n>`. Absent before 3.11.\n */\n breakout?: { roomId: string; name: string | null } | null;\n /**\n * Your own identity in the media room — your poolse user id — once\n * connected; what `callData.getSelfId()` answers. Absent before 3.11.\n */\n selfIdentity?: string | null;\n}\n\n/** The CallSummary's `recording` object, as the server sent it (docs/CALL_CONTRACT.md §4.2). */\nexport interface CallRecordingState {\n /** This server can record (LiveKit Egress). */\n available: boolean;\n active: boolean;\n id: string | null;\n mode: 'video' | 'audio' | null;\n started_at: string | null;\n started_by_user_id: string | null;\n auto: boolean;\n /** You may not publish until you accept. */\n consent_required: boolean;\n /** poolse user ids. */\n consent?: { accepted: string[]; declined: string[] };\n}\n\n/** The CallSummary's `transcription` object, as the server sent it. */\nexport interface CallTranscriptionState {\n available: boolean;\n active: boolean;\n id: string | null;\n status: 'live' | 'stopped' | 'ready' | null;\n language: string | null;\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 /** The server (workspace) it rings from — may differ from the current call's. Absent before 3.8. */\n serverId?: string | null;\n /** That workspace's name (\"Ana · Acme\"). Absent before 3.8. */\n workspaceName?: string | null;\n /** `meeting` when a scheduled meeting is starting rather than a person calling. Absent before 3.10. */\n ringType?: 'call' | 'meeting';\n /** The meeting's title for a `meeting` ring. Absent before 3.10. */\n meetingTitle?: string | null;\n}\n\n/** One place call audio can play. */\nexport interface AudioOutput {\n /** Opaque; stable while the device stays connected. */\n id: string;\n kind: AudioOutputKind;\n /**\n * The device's own name for Bluetooth/USB (\"AirPods Pro\"); a plain\n * English default for built-ins (\"iPhone\"/\"Phone\", \"Speaker\",\n * \"Headphones\") — relabel those by `kind` to localise.\n */\n name: string;\n}\n\nexport interface ConfigureOptions {\n /** Drawable resource NAME for the call notification's small icon. */\n smallIcon?: string;\n /** Ringback tone: raw resource NAME (Android); main-bundle sound name, mp3/caf/wav (iOS). */\n ringback?: string;\n /**\n * Incoming ringtone, overriding the config plugin's `ringtone` (leave it\n * out to use the plugin's, or the system ringtone without one).\n * Android: raw resource NAME (`ring` for `res/raw/ring.ogg`), played by\n * the module. iOS: a main-bundle sound CallKit plays — `ring.caf`, or the\n * base name looked up as caf/aiff/aif/wav; 30 s or shorter. Persisted, so\n * a ring that wakes a closed app uses it too. A name that is not in the\n * app rings with the system ringtone.\n */\n ringtone?: string;\n /**\n * Android: the full-screen incoming-call screen. Each field overrides the\n * config plugin's `incomingCall` option; leave one out to keep the\n * plugin's (or the built-in) value. Persisted for closed-app rings.\n * Ignored on iOS, where CallKit draws the call screen.\n */\n incomingCall?: IncomingCallOptions;\n /**\n * iOS: the APNs environment of this build's `aps-environment`\n * entitlement. Echoed back with the VoIP token so the server pushes to\n * the right gateway. Ignored on Android.\n */\n apnsEnvironment?: 'production' | 'sandbox';\n}\n\n/** Android's full-screen incoming call: its look, or the app's own activity instead. */\nexport interface IncomingCallOptions {\n /** `#RRGGBB` / `#AARRGGBB`: the glow, the pulsing ring and the initials disc (and the notification tint). */\n accentColor?: string;\n /** `#RRGGBB`: the screen's ground. A light one switches the text to dark. Default `#0B0B14`. */\n backgroundColor?: string;\n /**\n * The caller's picture, as a URL template: `{externalId}` (your app's id\n * for the caller) and `{userId}` (the poolse user id) are filled in,\n * URL-encoded — e.g. `https://cdn.example.com/avatars/{externalId}.jpg`.\n * Loaded off the main thread; the initials show until it loads, or if it\n * fails. A ring push's own `caller_avatar_url` wins over the template.\n */\n avatarUrl?: string;\n /**\n * Fully qualified class name of your own Activity (declared in your\n * manifest) to launch instead of the built-in screen. It receives the\n * `PoolseIncomingCall.EXTRA_*` extras and answers / declines through\n * `dev.poolse.callcore.android.PoolseIncomingCall` (see the README).\n * A leading `.` is relative to the application id.\n */\n activity?: string;\n}\n\n/** The iOS PushKit (VoIP) token and the APNs environment it belongs to. */\nexport interface VoipToken {\n /** Hex-encoded PushKit token. */\n token: string;\n environment: 'production' | 'sandbox' | string;\n}\n\nexport interface PlaceOptions {\n media: 'audio' | 'video';\n /** The user's session token — authorizes placing/joining (CALL_CONTRACT.md §3.2). */\n sessionToken: string;\n /**\n * The server (workspace) the session token belongs to — an `addServer`\n * id. Leave it out for the default server (`configure`'s).\n */\n serverId?: string;\n}\n\n/** The server `configure(apiBaseUrl)` sets; what everything defaults to. */\nexport const DEFAULT_SERVER_ID = 'default';\n\n/**\n * One server (workspace) the app is signed in to. No secrets: rings\n * carry their own grant, and place / join take the session token.\n */\nexport interface CallServer {\n /**\n * Your id for it, 1–64 of `A–Z a–z 0–9 . _ : -` — what `serverId`\n * says everywhere (snapshots, notification taps and actions).\n */\n id: string;\n /** Its API origin, as for `configure`. */\n apiBaseUrl: string;\n /**\n * The poolse tenant this sign-in belongs to (`tenant_id` of `me` or of\n * the registered device). Pushes carry it: it is how a ring or a\n * notification finds its server. Needed as soon as two servers are\n * added; without it a push goes to the default server.\n */\n tenantId?: string;\n /** The workspace's name — shown when a push carries none (\"Ana · Acme\"). */\n name?: string;\n}\n\n/**\n * What the user tapped on a missed-call or meeting notification: the\n * notification itself (`open` the conversation), a missed call's Call\n * back (`call_back` — place a call on the conversation with `media`), or\n * a starting meeting's Join (`join_meeting` — join the room `callId` in\n * the conversation, e.g. `poolse.rooms.start(conversationId, media)`,\n * which joins what is live).\n */\nexport interface CallAction {\n type: 'open' | 'call_back' | 'join_meeting';\n conversationId: string;\n callId: string | null;\n media: 'audio' | 'video';\n /** The server (workspace) it belongs to — open that one. Absent before 3.8. */\n serverId?: string | null;\n /** A meeting notice's scheduled meeting; null for missed calls. Absent before 3.10. */\n scheduledMeetingId?: string | null;\n}\n\n/**\n * A Reply or Mark as read the user did from a chat notification — or an\n * answer to an agent's question (`escalation`: Approve / Decline / Answer\n * on an `agent_escalation` push) — after the native core sent it (or gave\n * up). The server has already posted the reply and marked the\n * conversation read, or passed the answer to the agent in the call; use\n * this to refresh what the app shows without waiting for the socket, or\n * to tell the user it did not go out.\n */\nexport interface NotificationActionResult {\n action: 'reply' | 'mark_read' | 'escalation';\n /** The conversation (for `escalation`: the call's; `\"\"` when the push had none). */\n conversationId: string;\n /** `escalation` only: which question, and how it was answered. Absent before 3.10. */\n escalationId?: string;\n decision?: 'approve' | 'decline' | 'answer';\n /** `escalation` only: the call the agent is in. */\n callId?: string | null;\n /** The server (workspace) the conversation is on. Absent before 3.8. */\n serverId?: string;\n /** Whether the server accepted it. */\n ok: boolean;\n /** Reply (and an escalation's `answer`): 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>`. An\n * escalation: `not_pending`, `expired`, `invalid_token`, `no_token`.\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 addServer?(server: CallServer): Promise<void>;\n removeServer?(id: string): Promise<void>;\n listServers?(): CallServer[];\n serverForTenant?(tenantId: string | null): string | null;\n getCallState(): NativeSnapshot;\n place(\n conversationId: string,\n media: string,\n sessionToken: string,\n serverId: string | null,\n ): Promise<void>;\n join(\n callId: string,\n conversationId: string | null,\n sessionToken: string,\n serverId: string | null,\n ): 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 noiseSuppressionSupported?(): boolean;\n setNoiseSuppression?(on: boolean): boolean;\n backgroundBlurSupported?(): boolean;\n setBackgroundBlur?(on: boolean): boolean;\n setAudioOutput?(id: string): void;\n republish?(): void;\n publishData?(\n topic: string,\n data: string,\n options: { reliable?: boolean; base64?: boolean; to?: string[] } | null,\n ): Promise<boolean>;\n moveToRoom?(session: string): Promise<boolean>;\n callControl?(): Promise<{\n callId: string;\n controlToken: string;\n serverId?: string | null;\n apiBaseUrl?: string | null;\n } | 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, serverId: 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 addListener(event: 'onCallData', cb: (payload: CallDataMessage) => void): { 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/**\n * Configure once, before any call can arrive. No secrets — just the API\n * origin, which becomes the default server (`DEFAULT_SERVER_ID`).\n *\n * `configure(options)` sets the options alone, for an app whose servers\n * all come from `addServer`.\n */\nexport async function configure(\n apiBaseUrlOrOptions: string | ConfigureOptions,\n options?: ConfigureOptions,\n): Promise<void> {\n if (typeof apiBaseUrlOrOptions !== 'string') {\n await native?.configure('', apiBaseUrlOrOptions ?? null);\n return;\n }\n apiOrigin = apiBaseUrlOrOptions.replace(/\\/+$/, '');\n await native?.configure(apiBaseUrlOrOptions, options ?? null);\n}\n\n// ── several servers (workspaces) ──────────────────────────────────────\n\nconst SERVER_ID = /^[A-Za-z0-9._:-]{1,64}$/;\n\n/**\n * Sign the call core in to one more server (workspace) — or update one\n * (same `id`). Rings from it ring here, answered and declined on that\n * server; its chat notifications post (Android) and act (Reply, Mark as\n * read) against it. Persisted: a closed app woken by its push finds it.\n *\n * Register the device's push tokens with that server too (the SDK's\n * `devices.register`, per client): this only tells the core where it is.\n * Calls `configure` with default options first if it never ran.\n */\nexport async function addServer(server: CallServer): Promise<void> {\n if (!SERVER_ID.test(server.id))\n throw new Error(`addServer: invalid id ${JSON.stringify(server.id)}.`);\n if (!/^https?:\\/\\/[^\\s]+$/.test(server.apiBaseUrl))\n throw new Error('addServer: apiBaseUrl must be http(s).');\n const entry: CallServer = { id: server.id, apiBaseUrl: server.apiBaseUrl.replace(/\\/+$/, '') };\n if (server.tenantId) entry.tenantId = server.tenantId;\n if (server.name) entry.name = server.name;\n if (server.id === DEFAULT_SERVER_ID) apiOrigin = entry.apiBaseUrl;\n await native?.addServer?.(entry);\n}\n\n/**\n * Signed out of one server: the core forgets it and takes its\n * notifications down; the others are untouched. A call in progress on\n * it carries on to its end. Unregister its push tokens with that server\n * yourself (before signing out there).\n */\nexport async function removeServer(id: string): Promise<void> {\n if (id === DEFAULT_SERVER_ID) apiOrigin = null;\n await native?.removeServer?.(id);\n}\n\n/** The servers the core knows, in the order they were added (`configure`'s is `default`). */\nexport function listServers(): CallServer[] {\n return native?.listServers?.() ?? [];\n}\n\n/**\n * The server a notification (its data) belongs to, by its `tenant_id` —\n * the same rule the core routes rings and actions by. Use it on a tapped\n * iOS notification to open the right workspace. `null` with no server.\n */\nexport function serverOfNotification(\n data: Record<string, unknown> | undefined | null,\n): string | null {\n const tenant = data && typeof data['tenant_id'] === 'string' ? data['tenant_id'] : null;\n if (native?.serverForTenant) return native.serverForTenant(tenant);\n return apiOrigin ? DEFAULT_SERVER_ID : null;\n}\n\n/** The API origin of `serverId` (the default server when absent). */\nfunction originOf(serverId: string | null | undefined): string | null {\n if (!serverId || serverId === DEFAULT_SERVER_ID) {\n if (apiOrigin) return apiOrigin;\n }\n const id = serverId ?? DEFAULT_SERVER_ID;\n const server = listServers().find((s) => s.id === id);\n return server?.apiBaseUrl ?? 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 (\n native?.place(conversationId, options.media, options.sessionToken, options.serverId ?? null) ??\n Promise.resolve()\n );\n}\n\n/** `serverId`: the server the session token is for — leave it out for the default one. */\nexport function join(\n callId: string,\n conversationId: string | null,\n sessionToken: string,\n serverId?: string,\n): Promise<void> {\n return native?.join(callId, conversationId, sessionToken, serverId ?? null) ?? Promise.resolve();\n}\n\n/** What {@link moveCallHere} needs besides the call id. */\nexport interface MoveCallOptions {\n conversationId: string;\n /** The user's session token on the call's server. */\n sessionToken: string;\n /** The call's server (an `addServer` id); leave it out for the default one. */\n serverId?: string;\n}\n\n/**\n * \"Move call to this device\" (CL11): take a call you are on elsewhere\n * — your desktop, your other phone — over to this one without hanging\n * up. This device joins the same call; the server lets one device per\n * person carry it (CALL_CONTRACT.md §9), so the other one is let go and\n * its snapshot ends with `reason: 'moved'`. Offer it from the Join\n * banner when `liveCalls` says you are already in the call.\n *\n * The camera follows the call's media on this device; mute starts off.\n */\nexport function moveCallHere(callId: string, options: MoveCallOptions): Promise<void> {\n return join(callId, options.conversationId, options.sessionToken, options.serverId);\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 const origin = originOf(options.serverId);\n if (!origin) throw new Error('Call configure() (or addServer) before startRoom().');\n const res = await fetch(`${origin}/v1/conversations/${encodeURIComponent(conversationId)}/room`, {\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 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, options.serverId ?? null);\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 const control = await native.callControl();\n if (!control) throw new Error('There is no call in progress.');\n // The call's own server: it may be another workspace than the default.\n const origin = control.apiBaseUrl || originOf(control.serverId);\n if (!origin) throw new Error('Call configure() before ringIntoCall().');\n const res = await fetch(`${origin}/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// ── capture processing (CL7) ──────────────────────────────────────────\n\n/**\n * Whether noise suppression can be switched. On by default on both\n * platforms; the snapshot's `noiseSuppression` says what is in effect.\n */\nexport const noiseSuppressionSupported = (): boolean =>\n native?.noiseSuppressionSupported?.() ?? false;\n\n/**\n * Noise suppression on or off, for this and later calls (until the app\n * restarts). Android: WebRTC's noise suppression on the microphone\n * (echo cancellation stays on; the mic track is republished, a short\n * gap). iOS: Apple's voice processing does echo cancellation and noise\n * suppression as one, so off bypasses both — offer \"off\" for\n * headphones only. Returns false when the build can't.\n */\nexport const setNoiseSuppression = (on: boolean): boolean =>\n native?.setNoiseSuppression?.(on) ?? false;\n\n/**\n * Whether this build can blur the background behind you. iOS 15+: yes\n * (Vision person segmentation). Android: not yet — it needs an ML Kit\n * segmentation model, planned as a later addition. Hide the toggle when\n * false.\n */\nexport const backgroundBlurSupported = (): boolean => native?.backgroundBlurSupported?.() ?? false;\n\n/**\n * Blur the background on your camera, kept across camera flips and\n * calls. A no-op returning false where unsupported. Background\n * pictures (replacement) are not offered on native yet.\n */\nexport const setBackgroundBlur = (on: boolean): boolean => native?.setBackgroundBlur?.(on) ?? false;\n\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 * Recording consent accepted (ConsentPrompt's `onAccepted`): publish the\n * mic and camera again as the user last had them. The core also does it\n * by itself once the server lets this participant publish; calling it\n * early, or twice, is harmless — nothing goes out while\n * `snapshot.canPublish` is false.\n */\nexport const republish = (): void => native?.republish?.();\n\n/**\n * `snapshot.canPublish` changed (and once at subscribe time with the\n * current value, while a call is up). `true` when no call is up or the\n * native build predates it.\n */\nexport function onCanPublishChange(cb: (canPublish: boolean) => void): Unsubscribe {\n let last: boolean | null = null;\n const check = (snapshot: Snapshot | null): void => {\n const now = snapshot?.canPublish ?? true;\n if (now === last) return;\n const first = last === null;\n last = now;\n if (!first || snapshot) cb(now);\n };\n check(getCallState());\n return onCallState(check);\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 and meeting notifications ───────────────────────────────\n\n/**\n * The notification action the app was LAUNCHED with, once — read it on\n * mount. `null` when the app opened any other way.\n *\n * Android: missed calls and meeting notices (`starting` with Join, and\n * the brief; server docs/MEETINGS.md §11.3), both posted by the native\n * core from the push so they work with the app closed.\n *\n * iOS: meeting notices (the alert push's category `poolse_meeting`, Join\n * `poolse_meeting_join`), whose tap and Join arrive here as `open` /\n * `join_meeting`. Missed calls there are an ordinary alert push (to the\n * token you register with `kind: 'alert'`); read its taps with your\n * notification 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/** A missed-call (Android) or meeting notification (both) 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;\nlet activeServer: 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. Signed in to several servers, pass the one it is\n * on (`serverId`); without it, the conversation id alone decides.\n */\nexport function setActiveConversation(conversationId: string | null, serverId?: string): void {\n activeConversation = conversationId;\n activeServer = conversationId ? (serverId ?? null) : null;\n native?.setActiveConversation?.(conversationId, activeServer);\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 if (data['conversation_id'] !== activeConversation) return true;\n return activeServer != null && serverOfNotification(data) !== activeServer;\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`). Its server:\n * `serverOfNotification`.\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 its server's API origin (`configure` / `addServer`, persisted).\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 * `onNotificationAction`, agent escalations only (AG16): Approve / Decline\n * / Answer on an `agent_escalation` push, answered natively from the lock\n * screen. Feed `ok` ones to `poolse.escalations.list()` (or let\n * `agent:escalation` do it) so an open card updates.\n */\nexport function onEscalationAction(cb: (result: NotificationActionResult) => void): Unsubscribe {\n return onNotificationAction((result) => {\n if (result.action === 'escalation') 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// ── data channel (CL4, CL6) ───────────────────────────────────────────\n\n/**\n * The most one data-channel message may carry, in bytes — the same cap\n * as the web SDK's `CALL_DATA_MAX_BYTES`, under LiveKit's ~15 KiB packet.\n */\nexport const CALL_DATA_MAX_BYTES = 14_000;\n\n/** One message from someone in the call's room. */\nexport interface CallDataMessage {\n topic: string;\n /** The bytes, base64. */\n payload: string;\n /** The bytes as UTF-8 text; null when they are not text. */\n text: string | null;\n /** Who sent it (their poolse user id); null when the server did. */\n fromIdentity: string | null;\n fromName: string | null;\n}\n\nexport interface PublishDataOptions {\n /** Default true. `false` for what is stale a moment later (a moving pointer). */\n reliable?: boolean;\n /** `data` is base64 bytes rather than text. */\n base64?: boolean;\n /** Only these people (poolse user ids); everyone in the room when left out. */\n to?: string[];\n}\n\n/** UTF-8 length of `s`, without TextEncoder (not on every Hermes). */\nfunction utf8Length(s: string): number {\n let n = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) n += 1;\n else if (c < 0x800) n += 2;\n else if (c >= 0xd800 && c <= 0xdbff && i + 1 < s.length) {\n n += 4;\n i++;\n } else n += 3;\n }\n return n;\n}\n\n/**\n * Send `data` under `topic` to everyone in the call's room over LiveKit's\n * data channel, through the SFU, never stored (CL4, CL6). Web, desktop\n * and phones share topics and formats: `poolse.reaction`,\n * `poolse.annotate` (see {@link callData} for JSON). Resolves false with\n * no call connected, over {@link CALL_DATA_MAX_BYTES}, or on a build\n * without it.\n */\nexport async function publishData(\n topic: string,\n data: string,\n options: PublishDataOptions = {},\n): Promise<boolean> {\n if (!native?.publishData || !topic) return false;\n const size = options.base64 ? Math.floor((data.length * 3) / 4) : utf8Length(data);\n if (size > CALL_DATA_MAX_BYTES) return false;\n try {\n return await native.publishData(topic, data, {\n reliable: options.reliable ?? true,\n base64: options.base64 ?? false,\n ...(options.to ? { to: options.to } : {}),\n });\n } catch {\n return false;\n }\n}\n\n/** Every data-channel message others send in the call's room (yours are not echoed). */\nexport function onCallData(cb: (message: CallDataMessage) => void): Unsubscribe {\n if (!native?.publishData) return () => undefined;\n const sub = native.addListener('onCallData', cb);\n return () => sub.remove();\n}\n\ntype DataListener = (\n message: unknown,\n from: { userId: string | null; name: string | null },\n) => void;\nconst dataListeners = new Map<string, Set<DataListener>>();\nlet dataSub: Unsubscribe | null = null;\n\n/**\n * The native call's data channel in the shape @poolse/sdk's\n * `CallDataChannel` takes — JSON messages by topic — so the SDK's\n * `CallReactions` and `ScreenAnnotations` (and @poolse/react's\n * `useCallReactions` / `useScreenAnnotations`) run on phones exactly as\n * on the web and desktop, and interoperate with them:\n *\n * import { callData } from '@poolse/native';\n * const { reactions, send } = useCallReactions(callData);\n * const { state } = useScreenAnnotations(callData, sharerUserId);\n * <AnnotationOverlay state={state} />\n *\n * One process-wide object; it follows whichever call is live.\n */\nexport const callData = {\n getSelfId(): string | null {\n return getCallState()?.selfIdentity ?? null;\n },\n sendData(\n topic: string,\n message: unknown,\n opts: { reliable?: boolean; to?: string[] } = {},\n ): Promise<boolean> {\n let text: string;\n try {\n text = JSON.stringify(message);\n } catch {\n return Promise.resolve(false);\n }\n return publishData(topic, text, opts);\n },\n onData(topic: string, fn: DataListener): Unsubscribe {\n let set = dataListeners.get(topic);\n if (!set) {\n set = new Set();\n dataListeners.set(topic, set);\n }\n set.add(fn);\n dataSub ??= onCallData((m) => {\n const listeners = dataListeners.get(m.topic);\n if (!listeners?.size || m.text == null) return;\n let parsed: unknown;\n try {\n parsed = JSON.parse(m.text);\n } catch {\n return;\n }\n const from = { userId: m.fromIdentity, name: m.fromName };\n for (const l of [...listeners]) l(parsed, from);\n });\n return () => {\n set.delete(fn);\n if (set.size === 0) dataListeners.delete(topic);\n if (dataListeners.size === 0 && dataSub) {\n dataSub();\n dataSub = null;\n }\n };\n },\n};\n\n// ── breakout rooms (CL5) ──────────────────────────────────────────────\n\n/**\n * What {@link moveToRoom} takes: the session bundle `POST\n * /v1/breakouts/:room/join` or `POST /v1/calls/:id/breakouts/return`\n * answers with (@poolse/sdk's `meetingsLive.breakouts.join` /\n * `returnToMain`), or its JSON text.\n */\nexport interface RoomSessionBundle {\n call: { id: string };\n livekit: { url: string; token: string };\n control_token: string;\n breakout?: { room_id: string; name: string | null } | null;\n}\n\n/**\n * Breakout rooms (MEETINGS.md §5): move the call you are on into another\n * of its rooms — your breakout room, or back to the main room — without\n * hanging up. CallKit / the Android call service keep the call; only\n * the media swaps rooms, mute and camera as they were, and\n * `snapshot.breakout` says where you are. If the new room can't be\n * joined, the media goes back to the room it came from.\n *\n * Resolves false with no call connected (or still connecting), for\n * another call's session, or on a build without it. @poolse/react-native's\n * `useNativeBreakouts` does this for you as the split opens and closes.\n */\nexport async function moveToRoom(session: RoomSessionBundle | string): Promise<boolean> {\n if (!native?.moveToRoom) return false;\n try {\n return await native.moveToRoom(typeof session === 'string' ? session : JSON.stringify(session));\n } catch {\n return false;\n }\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":";;;;;AAkVO,IAAM,iBAAA,GAAoB;AAqKjC,IAAM,MAAA,GAAS,4BAA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,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 */\n/** `Snapshot.screenShare`: a remote participant's shared screen. */\nexport interface ScreenShareInfo {\n /** The sharer's LiveKit identity (their `participants[].userId`). */\n userId: string;\n externalId: string;\n width: number | null;\n height: number | null;\n}\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 /**\n * You took this call on another of your devices (`moveCallHere`\n * there): it goes on without this one. Say \"Moved to your other\n * device\", not \"Call ended\". Absent before 3.10.\n */\n | 'moved';\n /**\n * REMOTE people only; `userId` is the LiveKit identity. poolse's\n * transcript assistant (`poolse:…`, kind agent) and the recorder\n * (LiveKit Egress, `EG_…`) are never listed — nor counted when the core\n * ends a call left alone. Phone (SIP) participants are listed. Agents\n * invited into the call are listed with `isAgent` (last), never counted.\n */\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 * The shared screen's size in pixels as its publisher announced it;\n * present only while `screenSharing` and once known. Absent before 3.11.\n */\n screenWidth?: number;\n screenHeight?: number;\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 * An agent in the call (server docs/AGENTS_IN_CALLS.md): show it with\n * the Agent badge, named `agentLabel` — never as a person, never with\n * a camera placeholder. Absent for people and before 3.10.\n */\n isAgent?: boolean;\n /** \"Scout\", or \"Jasir's agent\" for one attending on someone's behalf. */\n agentLabel?: string | null;\n /** `notetaker` (silent) | `assistant` (answers when named) | `delegate`. */\n agentMode?: 'notetaker' | 'assistant' | 'delegate' | null;\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 * Who else shares a screen (the first remote sharer) and its size in\n * pixels, so screen drawings line up with what is shown (CL4): fit the\n * overlay to a `width`:`height` box inside the `fit=\"contain\"` view.\n * `width`/`height` are null until the sharer's size is known. null when\n * nobody else shares (yours is `screenSharing`); absent before 3.11.\n */\n screenShare?: ScreenShareInfo | null;\n /**\n * The server (workspace) this call runs on — the `id` given to\n * `addServer`, or `DEFAULT_SERVER_ID` for the one `configure` set.\n * Absent before 3.8.\n */\n serverId?: string | null;\n /**\n * That workspace's name: the ring push's `workspace_name`, else the\n * server's `name`. Absent before 3.8.\n */\n workspaceName?: string | null;\n /**\n * Whether the server lets you publish. `false` while recording consent\n * is required and you have not accepted (docs/RECORDING.md §5): you\n * still hear and see the call, but nothing of yours goes out. Your\n * `mutedSelf` / camera choices are kept and come back as they were once\n * it turns `true` again (the core republishes by itself; call\n * `republish()` from ConsentPrompt's `onAccepted` too). Absent before 3.9.\n */\n canPublish?: boolean;\n /**\n * The call's recording state as the server last told this core (on\n * answer / join / place and each reconnect) — enough to show the\n * indicator at once. Live changes arrive on the conversation socket\n * (`recording:*`). null: not known (a server without recording).\n * Absent before 3.9.\n */\n recording?: CallRecordingState | null;\n /** The live transcript's state, the same way (`transcript:*` on the socket). Absent before 3.9. */\n transcription?: CallTranscriptionState | null;\n /**\n * `meeting`: a scheduled meeting rang this device as it started (the\n * push's `ring_type`), so the ring reads \"Weekly sync is starting\" and\n * the call screen should name the meeting. `call` otherwise. Absent\n * before 3.10.\n */\n ringType?: 'call' | 'meeting';\n /** The meeting's title for a `meeting` ring; null otherwise. Absent before 3.10. */\n meetingTitle?: string | null;\n /** Noise suppression on the microphone (on by default; `setNoiseSuppression`). Absent before 3.10. */\n noiseSuppression?: boolean;\n /** Background blur on the camera (`setBackgroundBlur`). Absent before 3.10. */\n backgroundBlur?: boolean;\n /**\n * This call was taken over by your other device (`moveCallHere`\n * there); the end that follows has `reason: 'moved'`. Absent before 3.10.\n */\n movedElsewhere?: boolean;\n /**\n * The breakout room the call's media is in (`moveToRoom`,\n * MEETINGS.md §5); null in the call's main room. `roomId` is the\n * split's `<split id>.<n>`. Absent before 3.11.\n */\n breakout?: { roomId: string; name: string | null } | null;\n /**\n * Your own identity in the media room — your poolse user id — once\n * connected; what `callData.getSelfId()` answers. Absent before 3.11.\n */\n selfIdentity?: string | null;\n}\n\n/** The CallSummary's `recording` object, as the server sent it (docs/CALL_CONTRACT.md §4.2). */\nexport interface CallRecordingState {\n /** This server can record (LiveKit Egress). */\n available: boolean;\n active: boolean;\n id: string | null;\n mode: 'video' | 'audio' | null;\n started_at: string | null;\n started_by_user_id: string | null;\n auto: boolean;\n /** You may not publish until you accept. */\n consent_required: boolean;\n /** poolse user ids. */\n consent?: { accepted: string[]; declined: string[] };\n}\n\n/** The CallSummary's `transcription` object, as the server sent it. */\nexport interface CallTranscriptionState {\n available: boolean;\n active: boolean;\n id: string | null;\n status: 'live' | 'stopped' | 'ready' | null;\n language: string | null;\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 /** The server (workspace) it rings from — may differ from the current call's. Absent before 3.8. */\n serverId?: string | null;\n /** That workspace's name (\"Ana · Acme\"). Absent before 3.8. */\n workspaceName?: string | null;\n /** `meeting` when a scheduled meeting is starting rather than a person calling. Absent before 3.10. */\n ringType?: 'call' | 'meeting';\n /** The meeting's title for a `meeting` ring. Absent before 3.10. */\n meetingTitle?: string | null;\n}\n\n/** One place call audio can play. */\nexport interface AudioOutput {\n /** Opaque; stable while the device stays connected. */\n id: string;\n kind: AudioOutputKind;\n /**\n * The device's own name for Bluetooth/USB (\"AirPods Pro\"); a plain\n * English default for built-ins (\"iPhone\"/\"Phone\", \"Speaker\",\n * \"Headphones\") — relabel those by `kind` to localise.\n */\n name: string;\n}\n\nexport interface ConfigureOptions {\n /** Drawable resource NAME for the call notification's small icon. */\n smallIcon?: string;\n /** Ringback tone: raw resource NAME (Android); main-bundle sound name, mp3/caf/wav (iOS). */\n ringback?: string;\n /**\n * Incoming ringtone, overriding the config plugin's `ringtone` (leave it\n * out to use the plugin's, or the system ringtone without one).\n * Android: raw resource NAME (`ring` for `res/raw/ring.ogg`), played by\n * the module. iOS: a main-bundle sound CallKit plays — `ring.caf`, or the\n * base name looked up as caf/aiff/aif/wav; 30 s or shorter. Persisted, so\n * a ring that wakes a closed app uses it too. A name that is not in the\n * app rings with the system ringtone.\n */\n ringtone?: string;\n /**\n * Android: the full-screen incoming-call screen. Each field overrides the\n * config plugin's `incomingCall` option; leave one out to keep the\n * plugin's (or the built-in) value. Persisted for closed-app rings.\n * Ignored on iOS, where CallKit draws the call screen.\n */\n incomingCall?: IncomingCallOptions;\n /**\n * iOS: the APNs environment of this build's `aps-environment`\n * entitlement. Echoed back with the VoIP token so the server pushes to\n * the right gateway. Ignored on Android.\n */\n apnsEnvironment?: 'production' | 'sandbox';\n}\n\n/** Android's full-screen incoming call: its look, or the app's own activity instead. */\nexport interface IncomingCallOptions {\n /** `#RRGGBB` / `#AARRGGBB`: the glow, the pulsing ring and the initials disc (and the notification tint). */\n accentColor?: string;\n /** `#RRGGBB`: the screen's ground. A light one switches the text to dark. Default `#0B0B14`. */\n backgroundColor?: string;\n /**\n * The caller's picture, as a URL template: `{externalId}` (your app's id\n * for the caller) and `{userId}` (the poolse user id) are filled in,\n * URL-encoded — e.g. `https://cdn.example.com/avatars/{externalId}.jpg`.\n * Loaded off the main thread; the initials show until it loads, or if it\n * fails. A ring push's own `caller_avatar_url` wins over the template.\n */\n avatarUrl?: string;\n /**\n * Fully qualified class name of your own Activity (declared in your\n * manifest) to launch instead of the built-in screen. It receives the\n * `PoolseIncomingCall.EXTRA_*` extras and answers / declines through\n * `dev.poolse.callcore.android.PoolseIncomingCall` (see the README).\n * A leading `.` is relative to the application id.\n */\n activity?: string;\n}\n\n/** The iOS PushKit (VoIP) token and the APNs environment it belongs to. */\nexport interface VoipToken {\n /** Hex-encoded PushKit token. */\n token: string;\n environment: 'production' | 'sandbox' | string;\n}\n\nexport interface PlaceOptions {\n media: 'audio' | 'video';\n /** The user's session token — authorizes placing/joining (CALL_CONTRACT.md §3.2). */\n sessionToken: string;\n /**\n * The server (workspace) the session token belongs to — an `addServer`\n * id. Leave it out for the default server (`configure`'s).\n */\n serverId?: string;\n}\n\n/** The server `configure(apiBaseUrl)` sets; what everything defaults to. */\nexport const DEFAULT_SERVER_ID = 'default';\n\n/**\n * One server (workspace) the app is signed in to. No secrets: rings\n * carry their own grant, and place / join take the session token.\n */\nexport interface CallServer {\n /**\n * Your id for it, 1–64 of `A–Z a–z 0–9 . _ : -` — what `serverId`\n * says everywhere (snapshots, notification taps and actions).\n */\n id: string;\n /** Its API origin, as for `configure`. */\n apiBaseUrl: string;\n /**\n * The poolse tenant this sign-in belongs to (`tenant_id` of `me` or of\n * the registered device). Pushes carry it: it is how a ring or a\n * notification finds its server. Needed as soon as two servers are\n * added; without it a push goes to the default server.\n */\n tenantId?: string;\n /** The workspace's name — shown when a push carries none (\"Ana · Acme\"). */\n name?: string;\n}\n\n/**\n * What the user tapped on a missed-call or meeting notification: the\n * notification itself (`open` the conversation), a missed call's Call\n * back (`call_back` — place a call on the conversation with `media`), or\n * a starting meeting's Join (`join_meeting` — join the room `callId` in\n * the conversation, e.g. `poolse.rooms.start(conversationId, media)`,\n * which joins what is live).\n */\nexport interface CallAction {\n type: 'open' | 'call_back' | 'join_meeting';\n conversationId: string;\n callId: string | null;\n media: 'audio' | 'video';\n /** The server (workspace) it belongs to — open that one. Absent before 3.8. */\n serverId?: string | null;\n /** A meeting notice's scheduled meeting; null for missed calls. Absent before 3.10. */\n scheduledMeetingId?: string | null;\n}\n\n/**\n * A Reply or Mark as read the user did from a chat notification — or an\n * answer to an agent's question (`escalation`: Approve / Decline / Answer\n * on an `agent_escalation` push) — after the native core sent it (or gave\n * up). The server has already posted the reply and marked the\n * conversation read, or passed the answer to the agent in the call; use\n * this to refresh what the app shows without waiting for the socket, or\n * to tell the user it did not go out.\n */\nexport interface NotificationActionResult {\n action: 'reply' | 'mark_read' | 'escalation';\n /** The conversation (for `escalation`: the call's; `\"\"` when the push had none). */\n conversationId: string;\n /** `escalation` only: which question, and how it was answered. Absent before 3.10. */\n escalationId?: string;\n decision?: 'approve' | 'decline' | 'answer';\n /** `escalation` only: the call the agent is in. */\n callId?: string | null;\n /** The server (workspace) the conversation is on. Absent before 3.8. */\n serverId?: string;\n /** Whether the server accepted it. */\n ok: boolean;\n /** Reply (and an escalation's `answer`): 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>`. An\n * escalation: `not_pending`, `expired`, `invalid_token`, `no_token`.\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 addServer?(server: CallServer): Promise<void>;\n removeServer?(id: string): Promise<void>;\n listServers?(): CallServer[];\n serverForTenant?(tenantId: string | null): string | null;\n getCallState(): NativeSnapshot;\n place(\n conversationId: string,\n media: string,\n sessionToken: string,\n serverId: string | null,\n ): Promise<void>;\n join(\n callId: string,\n conversationId: string | null,\n sessionToken: string,\n serverId: string | null,\n ): 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 noiseSuppressionSupported?(): boolean;\n setNoiseSuppression?(on: boolean): boolean;\n backgroundBlurSupported?(): boolean;\n setBackgroundBlur?(on: boolean): boolean;\n setAudioOutput?(id: string): void;\n republish?(): void;\n publishData?(\n topic: string,\n data: string,\n options: { reliable?: boolean; base64?: boolean; to?: string[] } | null,\n ): Promise<boolean>;\n moveToRoom?(session: string): Promise<boolean>;\n callControl?(): Promise<{\n callId: string;\n controlToken: string;\n serverId?: string | null;\n apiBaseUrl?: string | null;\n } | 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, serverId: 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 addListener(event: 'onCallData', cb: (payload: CallDataMessage) => void): { 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/**\n * Configure once, before any call can arrive. No secrets — just the API\n * origin, which becomes the default server (`DEFAULT_SERVER_ID`).\n *\n * `configure(options)` sets the options alone, for an app whose servers\n * all come from `addServer`.\n */\nexport async function configure(\n apiBaseUrlOrOptions: string | ConfigureOptions,\n options?: ConfigureOptions,\n): Promise<void> {\n if (typeof apiBaseUrlOrOptions !== 'string') {\n await native?.configure('', apiBaseUrlOrOptions ?? null);\n return;\n }\n apiOrigin = apiBaseUrlOrOptions.replace(/\\/+$/, '');\n await native?.configure(apiBaseUrlOrOptions, options ?? null);\n}\n\n// ── several servers (workspaces) ──────────────────────────────────────\n\nconst SERVER_ID = /^[A-Za-z0-9._:-]{1,64}$/;\n\n/**\n * Sign the call core in to one more server (workspace) — or update one\n * (same `id`). Rings from it ring here, answered and declined on that\n * server; its chat notifications post (Android) and act (Reply, Mark as\n * read) against it. Persisted: a closed app woken by its push finds it.\n *\n * Register the device's push tokens with that server too (the SDK's\n * `devices.register`, per client): this only tells the core where it is.\n * Calls `configure` with default options first if it never ran.\n */\nexport async function addServer(server: CallServer): Promise<void> {\n if (!SERVER_ID.test(server.id))\n throw new Error(`addServer: invalid id ${JSON.stringify(server.id)}.`);\n if (!/^https?:\\/\\/[^\\s]+$/.test(server.apiBaseUrl))\n throw new Error('addServer: apiBaseUrl must be http(s).');\n const entry: CallServer = { id: server.id, apiBaseUrl: server.apiBaseUrl.replace(/\\/+$/, '') };\n if (server.tenantId) entry.tenantId = server.tenantId;\n if (server.name) entry.name = server.name;\n if (server.id === DEFAULT_SERVER_ID) apiOrigin = entry.apiBaseUrl;\n await native?.addServer?.(entry);\n}\n\n/**\n * Signed out of one server: the core forgets it and takes its\n * notifications down; the others are untouched. A call in progress on\n * it carries on to its end. Unregister its push tokens with that server\n * yourself (before signing out there).\n */\nexport async function removeServer(id: string): Promise<void> {\n if (id === DEFAULT_SERVER_ID) apiOrigin = null;\n await native?.removeServer?.(id);\n}\n\n/** The servers the core knows, in the order they were added (`configure`'s is `default`). */\nexport function listServers(): CallServer[] {\n return native?.listServers?.() ?? [];\n}\n\n/**\n * The server a notification (its data) belongs to, by its `tenant_id` —\n * the same rule the core routes rings and actions by. Use it on a tapped\n * iOS notification to open the right workspace. `null` with no server.\n */\nexport function serverOfNotification(\n data: Record<string, unknown> | undefined | null,\n): string | null {\n const tenant = data && typeof data['tenant_id'] === 'string' ? data['tenant_id'] : null;\n if (native?.serverForTenant) return native.serverForTenant(tenant);\n return apiOrigin ? DEFAULT_SERVER_ID : null;\n}\n\n/** The API origin of `serverId` (the default server when absent). */\nfunction originOf(serverId: string | null | undefined): string | null {\n if (!serverId || serverId === DEFAULT_SERVER_ID) {\n if (apiOrigin) return apiOrigin;\n }\n const id = serverId ?? DEFAULT_SERVER_ID;\n const server = listServers().find((s) => s.id === id);\n return server?.apiBaseUrl ?? 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 (\n native?.place(conversationId, options.media, options.sessionToken, options.serverId ?? null) ??\n Promise.resolve()\n );\n}\n\n/** `serverId`: the server the session token is for — leave it out for the default one. */\nexport function join(\n callId: string,\n conversationId: string | null,\n sessionToken: string,\n serverId?: string,\n): Promise<void> {\n return native?.join(callId, conversationId, sessionToken, serverId ?? null) ?? Promise.resolve();\n}\n\n/** What {@link moveCallHere} needs besides the call id. */\nexport interface MoveCallOptions {\n conversationId: string;\n /** The user's session token on the call's server. */\n sessionToken: string;\n /** The call's server (an `addServer` id); leave it out for the default one. */\n serverId?: string;\n}\n\n/**\n * \"Move call to this device\" (CL11): take a call you are on elsewhere\n * — your desktop, your other phone — over to this one without hanging\n * up. This device joins the same call; the server lets one device per\n * person carry it (CALL_CONTRACT.md §9), so the other one is let go and\n * its snapshot ends with `reason: 'moved'`. Offer it from the Join\n * banner when `liveCalls` says you are already in the call.\n *\n * The camera follows the call's media on this device; mute starts off.\n */\nexport function moveCallHere(callId: string, options: MoveCallOptions): Promise<void> {\n return join(callId, options.conversationId, options.sessionToken, options.serverId);\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 const origin = originOf(options.serverId);\n if (!origin) throw new Error('Call configure() (or addServer) before startRoom().');\n const res = await fetch(`${origin}/v1/conversations/${encodeURIComponent(conversationId)}/room`, {\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 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, options.serverId ?? null);\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 const control = await native.callControl();\n if (!control) throw new Error('There is no call in progress.');\n // The call's own server: it may be another workspace than the default.\n const origin = control.apiBaseUrl || originOf(control.serverId);\n if (!origin) throw new Error('Call configure() before ringIntoCall().');\n const res = await fetch(`${origin}/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// ── capture processing (CL7) ──────────────────────────────────────────\n\n/**\n * Whether noise suppression can be switched. On by default on both\n * platforms; the snapshot's `noiseSuppression` says what is in effect.\n */\nexport const noiseSuppressionSupported = (): boolean =>\n native?.noiseSuppressionSupported?.() ?? false;\n\n/**\n * Noise suppression on or off, for this and later calls (until the app\n * restarts). Android: WebRTC's noise suppression on the microphone\n * (echo cancellation stays on; the mic track is republished, a short\n * gap). iOS: Apple's voice processing does echo cancellation and noise\n * suppression as one, so off bypasses both — offer \"off\" for\n * headphones only. Returns false when the build can't.\n */\nexport const setNoiseSuppression = (on: boolean): boolean =>\n native?.setNoiseSuppression?.(on) ?? false;\n\n/**\n * Whether this build can blur the background behind you. iOS 15+: yes\n * (Vision person segmentation). Android: not yet — it needs an ML Kit\n * segmentation model, planned as a later addition. Hide the toggle when\n * false.\n */\nexport const backgroundBlurSupported = (): boolean => native?.backgroundBlurSupported?.() ?? false;\n\n/**\n * Blur the background on your camera, kept across camera flips and\n * calls. A no-op returning false where unsupported. Background\n * pictures (replacement) are not offered on native yet.\n */\nexport const setBackgroundBlur = (on: boolean): boolean => native?.setBackgroundBlur?.(on) ?? false;\n\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 * Recording consent accepted (ConsentPrompt's `onAccepted`): publish the\n * mic and camera again as the user last had them. The core also does it\n * by itself once the server lets this participant publish; calling it\n * early, or twice, is harmless — nothing goes out while\n * `snapshot.canPublish` is false.\n */\nexport const republish = (): void => native?.republish?.();\n\n/**\n * `snapshot.canPublish` changed (and once at subscribe time with the\n * current value, while a call is up). `true` when no call is up or the\n * native build predates it.\n */\nexport function onCanPublishChange(cb: (canPublish: boolean) => void): Unsubscribe {\n let last: boolean | null = null;\n const check = (snapshot: Snapshot | null): void => {\n const now = snapshot?.canPublish ?? true;\n if (now === last) return;\n const first = last === null;\n last = now;\n if (!first || snapshot) cb(now);\n };\n check(getCallState());\n return onCallState(check);\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 and meeting notifications ───────────────────────────────\n\n/**\n * The notification action the app was LAUNCHED with, once — read it on\n * mount. `null` when the app opened any other way.\n *\n * Android: missed calls and meeting notices (`starting` with Join, and\n * the brief; server docs/MEETINGS.md §11.3), both posted by the native\n * core from the push so they work with the app closed.\n *\n * iOS: meeting notices (the alert push's category `poolse_meeting`, Join\n * `poolse_meeting_join`), whose tap and Join arrive here as `open` /\n * `join_meeting`. Missed calls there are an ordinary alert push (to the\n * token you register with `kind: 'alert'`); read its taps with your\n * notification 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/** A missed-call (Android) or meeting notification (both) 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;\nlet activeServer: 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. Signed in to several servers, pass the one it is\n * on (`serverId`); without it, the conversation id alone decides.\n */\nexport function setActiveConversation(conversationId: string | null, serverId?: string): void {\n activeConversation = conversationId;\n activeServer = conversationId ? (serverId ?? null) : null;\n native?.setActiveConversation?.(conversationId, activeServer);\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 if (data['conversation_id'] !== activeConversation) return true;\n return activeServer != null && serverOfNotification(data) !== activeServer;\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`). Its server:\n * `serverOfNotification`.\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 its server's API origin (`configure` / `addServer`, persisted).\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 * `onNotificationAction`, agent escalations only (AG16): Approve / Decline\n * / Answer on an `agent_escalation` push, answered natively from the lock\n * screen. Feed `ok` ones to `poolse.escalations.list()` (or let\n * `agent:escalation` do it) so an open card updates.\n */\nexport function onEscalationAction(cb: (result: NotificationActionResult) => void): Unsubscribe {\n return onNotificationAction((result) => {\n if (result.action === 'escalation') 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// ── data channel (CL4, CL6) ───────────────────────────────────────────\n\n/**\n * The most one data-channel message may carry, in bytes — the same cap\n * as the web SDK's `CALL_DATA_MAX_BYTES`, under LiveKit's ~15 KiB packet.\n */\nexport const CALL_DATA_MAX_BYTES = 14_000;\n\n/** One message from someone in the call's room. */\nexport interface CallDataMessage {\n topic: string;\n /** The bytes, base64. */\n payload: string;\n /** The bytes as UTF-8 text; null when they are not text. */\n text: string | null;\n /** Who sent it (their poolse user id); null when the server did. */\n fromIdentity: string | null;\n fromName: string | null;\n}\n\nexport interface PublishDataOptions {\n /** Default true. `false` for what is stale a moment later (a moving pointer). */\n reliable?: boolean;\n /** `data` is base64 bytes rather than text. */\n base64?: boolean;\n /** Only these people (poolse user ids); everyone in the room when left out. */\n to?: string[];\n}\n\n/** UTF-8 length of `s`, without TextEncoder (not on every Hermes). */\nfunction utf8Length(s: string): number {\n let n = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) n += 1;\n else if (c < 0x800) n += 2;\n else if (c >= 0xd800 && c <= 0xdbff && i + 1 < s.length) {\n n += 4;\n i++;\n } else n += 3;\n }\n return n;\n}\n\n/**\n * Send `data` under `topic` to everyone in the call's room over LiveKit's\n * data channel, through the SFU, never stored (CL4, CL6). Web, desktop\n * and phones share topics and formats: `poolse.reaction`,\n * `poolse.annotate` (see {@link callData} for JSON). Resolves false with\n * no call connected, over {@link CALL_DATA_MAX_BYTES}, or on a build\n * without it.\n */\nexport async function publishData(\n topic: string,\n data: string,\n options: PublishDataOptions = {},\n): Promise<boolean> {\n if (!native?.publishData || !topic) return false;\n const size = options.base64 ? Math.floor((data.length * 3) / 4) : utf8Length(data);\n if (size > CALL_DATA_MAX_BYTES) return false;\n try {\n return await native.publishData(topic, data, {\n reliable: options.reliable ?? true,\n base64: options.base64 ?? false,\n ...(options.to ? { to: options.to } : {}),\n });\n } catch {\n return false;\n }\n}\n\n/** Every data-channel message others send in the call's room (yours are not echoed). */\nexport function onCallData(cb: (message: CallDataMessage) => void): Unsubscribe {\n if (!native?.publishData) return () => undefined;\n const sub = native.addListener('onCallData', cb);\n return () => sub.remove();\n}\n\ntype DataListener = (\n message: unknown,\n from: { userId: string | null; name: string | null },\n) => void;\nconst dataListeners = new Map<string, Set<DataListener>>();\nlet dataSub: Unsubscribe | null = null;\n\n/**\n * The native call's data channel in the shape @poolse/sdk's\n * `CallDataChannel` takes — JSON messages by topic — so the SDK's\n * `CallReactions` and `ScreenAnnotations` (and @poolse/react's\n * `useCallReactions` / `useScreenAnnotations`) run on phones exactly as\n * on the web and desktop, and interoperate with them:\n *\n * import { callData } from '@poolse/native';\n * const { reactions, send } = useCallReactions(callData);\n * const { state } = useScreenAnnotations(callData, sharerUserId);\n * <AnnotationOverlay state={state} />\n *\n * One process-wide object; it follows whichever call is live.\n */\nexport const callData = {\n getSelfId(): string | null {\n return getCallState()?.selfIdentity ?? null;\n },\n sendData(\n topic: string,\n message: unknown,\n opts: { reliable?: boolean; to?: string[] } = {},\n ): Promise<boolean> {\n let text: string;\n try {\n text = JSON.stringify(message);\n } catch {\n return Promise.resolve(false);\n }\n return publishData(topic, text, opts);\n },\n onData(topic: string, fn: DataListener): Unsubscribe {\n let set = dataListeners.get(topic);\n if (!set) {\n set = new Set();\n dataListeners.set(topic, set);\n }\n set.add(fn);\n dataSub ??= onCallData((m) => {\n const listeners = dataListeners.get(m.topic);\n if (!listeners?.size || m.text == null) return;\n let parsed: unknown;\n try {\n parsed = JSON.parse(m.text);\n } catch {\n return;\n }\n const from = { userId: m.fromIdentity, name: m.fromName };\n for (const l of [...listeners]) l(parsed, from);\n });\n return () => {\n set.delete(fn);\n if (set.size === 0) dataListeners.delete(topic);\n if (dataListeners.size === 0 && dataSub) {\n dataSub();\n dataSub = null;\n }\n };\n },\n};\n\n// ── breakout rooms (CL5) ──────────────────────────────────────────────\n\n/**\n * What {@link moveToRoom} takes: the session bundle `POST\n * /v1/breakouts/:room/join` or `POST /v1/calls/:id/breakouts/return`\n * answers with (@poolse/sdk's `meetingsLive.breakouts.join` /\n * `returnToMain`), or its JSON text.\n */\nexport interface RoomSessionBundle {\n call: { id: string };\n livekit: { url: string; token: string };\n control_token: string;\n breakout?: { room_id: string; name: string | null } | null;\n}\n\n/**\n * Breakout rooms (MEETINGS.md §5): move the call you are on into another\n * of its rooms — your breakout room, or back to the main room — without\n * hanging up. CallKit / the Android call service keep the call; only\n * the media swaps rooms, mute and camera as they were, and\n * `snapshot.breakout` says where you are. If the new room can't be\n * joined, the media goes back to the room it came from.\n *\n * Resolves false with no call connected (or still connecting), for\n * another call's session, or on a build without it. @poolse/react-native's\n * `useNativeBreakouts` does this for you as the split opens and closes.\n */\nexport async function moveToRoom(session: RoomSessionBundle | string): Promise<boolean> {\n if (!native?.moveToRoom) return false;\n try {\n return await native.moveToRoom(typeof session === 'string' ? session : JSON.stringify(session));\n } catch {\n return false;\n }\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"]}
@@ -11,6 +11,10 @@ public struct SnapshotParticipant: Equatable {
11
11
  public var cameraOn: Bool
12
12
  /// True with a published, subscribed, unmuted screen share.
13
13
  public var screenSharing: Bool
14
+ /// The shared screen's size in pixels as published (nil while unknown or
15
+ /// not sharing): phones line screen drawings up against it.
16
+ public var screenWidth: Int?
17
+ public var screenHeight: Int?
14
18
  /// Their link to the SFU: `good` | `poor` | `lost` (dropped, coming
15
19
  /// back — "Reconnecting…") | `unknown`.
16
20
  public var connectionQuality: String
@@ -24,7 +28,8 @@ public struct SnapshotParticipant: Equatable {
24
28
 
25
29
  public init(userId: String, externalId: String, speaking: Bool, muted: Bool, cameraOn: Bool,
26
30
  connectionQuality: String = "unknown", screenSharing: Bool = false,
27
- isAgent: Bool = false, agentLabel: String? = nil, agentMode: String? = nil) {
31
+ isAgent: Bool = false, agentLabel: String? = nil, agentMode: String? = nil,
32
+ screenWidth: Int? = nil, screenHeight: Int? = nil) {
28
33
  self.userId = userId
29
34
  self.externalId = externalId
30
35
  self.speaking = speaking
@@ -35,6 +40,8 @@ public struct SnapshotParticipant: Equatable {
35
40
  self.isAgent = isAgent
36
41
  self.agentLabel = agentLabel
37
42
  self.agentMode = agentMode
43
+ self.screenWidth = screenWidth
44
+ self.screenHeight = screenHeight
38
45
  }
39
46
 
40
47
  public var dictionary: [String: Any] {
@@ -42,6 +49,10 @@ public struct SnapshotParticipant: Equatable {
42
49
  "userId": userId, "externalId": externalId, "speaking": speaking, "muted": muted, "cameraOn": cameraOn,
43
50
  "connectionQuality": connectionQuality, "screenSharing": screenSharing,
44
51
  ]
52
+ if screenSharing, let w = screenWidth, let h = screenHeight {
53
+ d["screenWidth"] = w
54
+ d["screenHeight"] = h
55
+ }
45
56
  if isAgent {
46
57
  d["isAgent"] = true
47
58
  d["agentLabel"] = agentLabel ?? NSNull()
@@ -142,6 +153,15 @@ public extension MachineState {
142
153
  "recording": jsonObject(recording),
143
154
  "transcription": jsonObject(transcription),
144
155
  ]
156
+ // Who shares a screen (the first remote sharer) and its size, for
157
+ // lining up screen drawings (CL4); null when nobody else shares.
158
+ out["screenShare"] = participants.first(where: { $0.screenSharing }).map { p -> Any in
159
+ [
160
+ "userId": p.userId, "externalId": p.externalId,
161
+ "width": p.screenWidth.map { $0 as Any } ?? NSNull(),
162
+ "height": p.screenHeight.map { $0 as Any } ?? NSNull(),
163
+ ] as [String: Any]
164
+ } ?? NSNull()
145
165
  // The call waiting beside this one: null when none.
146
166
  if let w = self.waiting {
147
167
  out["waiting"] = [
@@ -787,6 +787,14 @@ final class LiveKitMediaPort: NSObject, MediaPort {
787
787
  return pub.track as? VideoTrack
788
788
  }
789
789
 
790
+ /// The shared screen's size as its publisher announced it (the SFU's
791
+ /// track info); nil while unknown.
792
+ private func screenDimensions(_ p: RemoteParticipant) -> (width: Int, height: Int)? {
793
+ guard let pub = p.trackPublications.values.first(where: { $0.source == .screenShareVideo }),
794
+ let d = pub.dimensions, d.width > 0, d.height > 0 else { return nil }
795
+ return (Int(d.width), Int(d.height))
796
+ }
797
+
790
798
  /// `front` | `back` of the published local camera, or nil when none.
791
799
  func cameraFacing() -> String? {
792
800
  guard let r = room, let track = localCameraTrack(r) else { return nil }
@@ -998,6 +1006,7 @@ final class LiveKitMediaPort: NSObject, MediaPort {
998
1006
  }
999
1007
  let roster = people(r).map { p -> SnapshotParticipant in
1000
1008
  let identity = p.identity?.stringValue ?? ""
1009
+ let screen = remoteScreen(p) != nil ? screenDimensions(p) : nil
1001
1010
  return SnapshotParticipant(
1002
1011
  userId: identity,
1003
1012
  externalId: externalId(p) ?? identity,
@@ -1005,7 +1014,9 @@ final class LiveKitMediaPort: NSObject, MediaPort {
1005
1014
  muted: !p.isMicrophoneEnabled(),
1006
1015
  cameraOn: remoteCamera(p) != nil,
1007
1016
  connectionQuality: Self.wire(p.connectionQuality),
1008
- screenSharing: remoteScreen(p) != nil
1017
+ screenSharing: remoteScreen(p) != nil,
1018
+ screenWidth: screen?.width,
1019
+ screenHeight: screen?.height
1009
1020
  )
1010
1021
  }
1011
1022
  events?.onParticipants(roster + agentRows)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poolse/native",
3
- "version": "3.10.1",
3
+ "version": "3.10.3",
4
4
  "description": "Native call core for poolse — Kotlin/Swift calling engine with a thin React Native bridge. Ring, answer and carry audio with the app killed and the phone locked.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
package/src/index.ts CHANGED
@@ -15,6 +15,15 @@ import { requireNativeViewManager, requireOptionalNativeModule } from 'expo-modu
15
15
  * ends the snapshot stays `phase: 'ended'` (with `reason`) for ~2.5 s,
16
16
  * then becomes `null`.
17
17
  */
18
+ /** `Snapshot.screenShare`: a remote participant's shared screen. */
19
+ export interface ScreenShareInfo {
20
+ /** The sharer's LiveKit identity (their `participants[].userId`). */
21
+ userId: string;
22
+ externalId: string;
23
+ width: number | null;
24
+ height: number | null;
25
+ }
26
+
18
27
  export interface Snapshot {
19
28
  cv: 1;
20
29
  callId: string;
@@ -63,6 +72,12 @@ export interface Snapshot {
63
72
  * large and with `fit="contain"`. Absent before 3.2.
64
73
  */
65
74
  screenSharing?: boolean;
75
+ /**
76
+ * The shared screen's size in pixels as its publisher announced it;
77
+ * present only while `screenSharing` and once known. Absent before 3.11.
78
+ */
79
+ screenWidth?: number;
80
+ screenHeight?: number;
66
81
  /**
67
82
  * Their link to the call: `lost` while they have dropped and are
68
83
  * coming back (show "Reconnecting…"), `poor` for a weak signal.
@@ -119,6 +134,14 @@ export interface Snapshot {
119
134
  videoPaused?: boolean;
120
135
  /** You are sharing your screen. Absent before 3.2. */
121
136
  screenSharing?: boolean;
137
+ /**
138
+ * Who else shares a screen (the first remote sharer) and its size in
139
+ * pixels, so screen drawings line up with what is shown (CL4): fit the
140
+ * overlay to a `width`:`height` box inside the `fit="contain"` view.
141
+ * `width`/`height` are null until the sharer's size is known. null when
142
+ * nobody else shares (yours is `screenSharing`); absent before 3.11.
143
+ */
144
+ screenShare?: ScreenShareInfo | null;
122
145
  /**
123
146
  * The server (workspace) this call runs on — the `id` given to
124
147
  * `addServer`, or `DEFAULT_SERVER_ID` for the one `configure` set.