@poolse/native 3.8.0 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +127 -9
  3. package/android/src/main/AndroidManifest.xml +4 -0
  4. package/android/src/main/java/dev/poolse/callcore/CallCoreRuntime.kt +8 -0
  5. package/android/src/main/java/dev/poolse/callcore/Ports.kt +47 -1
  6. package/android/src/main/java/dev/poolse/callcore/android/AndroidRingSurface.kt +3 -3
  7. package/android/src/main/java/dev/poolse/callcore/android/CallCore.kt +112 -10
  8. package/android/src/main/java/dev/poolse/callcore/android/CallHttpClient.kt +3 -0
  9. package/android/src/main/java/dev/poolse/callcore/android/CallMessagingService.kt +21 -1
  10. package/android/src/main/java/dev/poolse/callcore/android/CallVideo.kt +14 -0
  11. package/android/src/main/java/dev/poolse/callcore/android/EscalationNotification.kt +475 -0
  12. package/android/src/main/java/dev/poolse/callcore/android/IncomingCallActivity.kt +9 -4
  13. package/android/src/main/java/dev/poolse/callcore/android/MeetingNotification.kt +127 -0
  14. package/android/src/main/java/dev/poolse/callcore/android/PoolseIncomingCall.kt +9 -0
  15. package/android/src/main/java/dev/poolse/callcore/android/RingBundle.kt +9 -0
  16. package/android/src/main/java/dev/poolse/callcore/android/SnapshotJson.kt +23 -0
  17. package/android/src/main/java/expo/modules/poolsecalls/PoolseCallsModule.kt +17 -1
  18. package/android/src/main/livekit/java/dev/poolse/callcore/livekit/LiveKitMediaPort.kt +174 -11
  19. package/dist/index.cjs +33 -0
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +197 -23
  22. package/dist/index.d.ts +197 -23
  23. package/dist/index.js +26 -1
  24. package/dist/index.js.map +1 -1
  25. package/ios/Core/CallCoreRuntime.swift +8 -0
  26. package/ios/Core/CallHttpClient.swift +11 -1
  27. package/ios/Core/Ports.swift +47 -2
  28. package/ios/Core/SnapshotEncoding.swift +39 -4
  29. package/ios/Module/PoolseCallsModule.swift +28 -1
  30. package/ios/Platform/CallCore.swift +68 -2
  31. package/ios/Platform/CallKitController.swift +1 -1
  32. package/ios/Platform/EscalationNotifications.swift +195 -0
  33. package/ios/Platform/LiveKitMediaPort.swift +178 -15
  34. package/ios/Platform/MessageNotifications.swift +60 -1
  35. package/ios/Platform/VoipPush.swift +11 -2
  36. package/package.json +1 -1
  37. package/src/index.ts +231 -23
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["requireOptionalNativeModule","requireNativeViewManager","createElement","View"],"mappings":";;;;;;;AAwNO,IAAM,iBAAA,GAAoB;AA2IjC,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,C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GAAA,GAAM,OAAO,WAAA,CAAY,oBAAA,EAAsB,CAAC,OAAA,KAAY,EAAA,CAAG,OAAA,CAAQ,MAAM,CAAC,CAAA;AACpF,EAAA,OAAO,MAAM,IAAI,MAAA,EAAO;AAC1B;AA2BA,IAAI,WAAA;AAGJ,SAAS,eAAA,GAA0D;AACjE,EAAA,IAAI,WAAA,KAAgB,QAAW,OAAO,WAAA;AACtC,EAAA,WAAA,GAAc,IAAA;AACd,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,IAAI;AACF,MAAA,WAAA,GAAcC,wCAAA,CAA2C,eAAe,iBAAiB,CAAA;AAAA,IAC3F,CAAA,CAAA,MAAQ;AACN,MAAA,WAAA,GAAc,IAAA;AAAA,IAChB;AAAA,EACF;AACA,EAAA,OAAO,WAAA;AACT;AAQO,SAAS,cAAc,KAAA,EAAgD;AAC5E,EAAA,MAAM,SAAS,eAAA,EAAgB;AAC/B,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM;AAAA,MACJ,aAAA,EAAe,EAAA;AAAA,MACf,KAAA,EAAO,EAAA;AAAA,MACP,MAAA,EAAQ,EAAA;AAAA,MACR,GAAA,EAAK,EAAA;AAAA,MACL,MAAA,EAAQ,EAAA;AAAA,MACR,gBAAA,EAAkB,IAAA;AAAA,MAClB,GAAG;AAAA,KACL,GAAI,KAAA;AACJ,IAAA,OAAOC,mBAAA,CAAcC,kBAAM,IAAI,CAAA;AAAA,EACjC;AACA,EAAA,OAAOD,mBAAA,CAAc,QAAQ,KAAK,CAAA;AACpC","file":"index.cjs","sourcesContent":["// @poolse/native — the React Native face of the native\n// call core (CALL_CONTRACT.md §8). A thin, typed surface over the native\n// module: commands in, one snapshot event out. All call logic lives in\n// the native cores; nothing here decides anything about a call.\n//\n// On a platform or build without the native module (Expo Go, web,\n// unlinked), every command is a safe no-op and the state stays idle —\n// so a host can render against this unconditionally.\nimport { createElement, type ComponentType, type ReactElement } from 'react';\nimport { View, type ViewProps } from 'react-native';\nimport { requireNativeViewManager, requireOptionalNativeModule } from 'expo-modules-core';\n\n/**\n * A call's complete state. `null` means idle — no call. After a call\n * ends the snapshot stays `phase: 'ended'` (with `reason`) for ~2.5 s,\n * then becomes `null`.\n */\nexport interface Snapshot {\n cv: 1;\n callId: string;\n conversationId: string;\n conversationName: string | null;\n direction: 'incoming' | 'outgoing' | 'joined';\n /**\n * `room` — rings nobody, joined and left at will (`startRoom`); `call`\n * otherwise. Known once the server answered: a room being joined reads\n * `call` while `connecting`. Absent before 0.9.0: treat as `call`.\n */\n kind?: 'call' | 'room';\n media: 'audio' | 'video';\n phase: 'ringing_in' | 'ringing_out' | 'connecting' | 'active' | 'reconnecting' | 'ended';\n reason?:\n | 'left'\n | 'finished'\n | 'declined_all'\n | 'busy_all'\n | 'no_answer'\n | 'cancelled'\n | 'connection_lost'\n | 'failed';\n /** REMOTE participants only; `userId` is the LiveKit identity. */\n participants: Array<{\n userId: string;\n externalId: string;\n speaking: boolean;\n muted: boolean;\n /** True only with a published, subscribed, unmuted camera track (show video, not avatar). */\n cameraOn: boolean;\n /**\n * Sharing their screen: draw it with `<CallVideoView source=\"screen\">`,\n * large and with `fit=\"contain\"`. Absent before 3.2.\n */\n screenSharing?: boolean;\n /**\n * Their link to the call: `lost` while they have dropped and are\n * coming back (show \"Reconnecting…\"), `poor` for a weak signal.\n * Absent before 0.11.0.\n */\n connectionQuality?: ConnectionQuality;\n }>;\n /** The kind of output playing now — the short answer to \"where is the audio\". */\n audioRoute: AudioOutputKind;\n /**\n * Every output the call can play through right now: always the phone\n * (earpiece, or wired headphones in its place) and the speaker, plus\n * each connected Bluetooth / USB device by its own name. Empty until\n * the call's audio is up. Pass an `id` to `setAudioOutput`.\n */\n audioOutputs: AudioOutput[];\n /** The `audioOutputs` entry playing now; null before audio is up. */\n audioOutputId: string | null;\n mutedSelf: boolean;\n /** True only while the local camera track is actually published and enabled. */\n cameraOn: boolean;\n /**\n * A second call ringing while this one is in progress (call waiting).\n * Offer `answerWaiting` (\"End & answer\" — this call ends) and\n * `declineWaiting` (its caller hears busy). If this call ends first,\n * the waiting one simply becomes the ringing call. null when none;\n * absent before 0.10.0.\n */\n waiting?: WaitingCall | null;\n /** Facing of the published local camera; absent when the camera is off. */\n cameraFacing?: 'front' | 'back';\n /**\n * Your own link to the call. `poor` / `lost`: show a \"weak connection\"\n * hint; `phase: 'reconnecting'` is the hard version of the same thing.\n * Absent before 0.11.0.\n */\n connectionQuality?: ConnectionQuality;\n /**\n * Incoming video is switched off because your connection could not\n * carry it — the audio keeps going, and video comes back by itself\n * once the link has been good for a few seconds. Participants read\n * `cameraOn: false` meanwhile. Absent before 0.11.0.\n */\n videoPaused?: boolean;\n /** You are sharing your screen. Absent before 3.2. */\n screenSharing?: boolean;\n /**\n * 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\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}\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 notification: the notification\n * itself (`open` the conversation) or its Call back button (`call_back`\n * — place a call on the conversation with `media`).\n */\nexport interface CallAction {\n type: 'open' | 'call_back';\n conversationId: string;\n callId: string | null;\n media: 'audio' | 'video';\n /** The server (workspace) it belongs to — open that one. Absent before 3.8. */\n serverId?: string | null;\n}\n\n/**\n * A Reply or Mark as read the user did from a chat notification, after\n * the native core sent it (or gave up). The server has already posted\n * the reply and marked the conversation read; use this to refresh what\n * the app shows (insert the message, drop the unread count) without\n * waiting for the socket, or to tell the user a reply did not go out.\n */\nexport interface NotificationActionResult {\n action: 'reply' | 'mark_read';\n conversationId: string;\n /** 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 only: what the user typed. */\n text?: string;\n /** Reply only: the idempotency id sent with it — the message's id once posted. */\n clientId?: string;\n /** Reply, `ok` only: the posted message's id (equals `clientId`). */\n messageId?: string;\n /**\n * When not `ok`: the server's error code (`unauthorized`,\n * `device_signed_out`, `user_blocked`, `forbidden`, `not_found`,\n * `mau_cap_exceeded`, `validation_failed`, `rate_limited`), or\n * `network`, `no_grant` (the push carried no reply grant),\n * `not_configured` (never `configure`d), `http_<status>`.\n */\n error?: string;\n /** The HTTP status when the server answered with an error. */\n status?: number;\n /** When it finished, epoch ms. */\n at: number;\n}\n\ntype NativeSnapshot = { snapshot: Snapshot | null };\n\ninterface PoolseCallsNative {\n configure(apiBaseUrl: string, options: ConfigureOptions | null): Promise<void>;\n 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 setAudioOutput?(id: string): void;\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}\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\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/** Route call audio to the loudspeaker (`true`) or back to earpiece / headset (`false`). */\nexport const setSpeaker = (on: boolean): void => native?.setSpeaker(on);\n\n/**\n * Play call audio through one of `snapshot.audioOutputs`. The choice\n * holds for the rest of the call, until that device disconnects or a new\n * headset / Bluetooth device connects (which takes over, as in the\n * phone's own dialer). Without a choice a connected headset wins, then\n * the earpiece for voice calls or the speaker for video.\n */\nexport function setAudioOutput(id: string): void {\n if (native?.setAudioOutput) native.setAudioOutput(id);\n else native?.setSpeaker(id === 'speaker'); // an older native build\n}\n\n/**\n * Socket forwarding for an open app: a `call:ring_ended` seen on the\n * socket. Idempotent with the push path — the core dedupes.\n */\nexport const onRingEnded = (callId: string, reason: string): void =>\n native?.onRingEnded(callId, reason);\n\n/**\n * Socket forwarding: `call:finished`. Pass the payload's `reason`\n * (`finished` | `declined_all` | `no_answer` | `cancelled`) so an\n * unanswered caller sees \"Declined\"/\"No answer\", not \"Call ended\".\n * Idempotent with the `finished` push.\n */\nexport const onCallFinished = (callId: string, reason?: string): void =>\n native?.onCallFinished(callId, reason ?? null);\n\n/**\n * Android 14+: whether the app may show the full-screen ring over the\n * lock screen. `true` on older Android and where the module is absent.\n */\nexport const canUseFullScreenIntent = (): boolean => native?.canUseFullScreenIntent() ?? true;\n\n/** Open the system screen where the user grants full-screen intents (falls back to notification settings). */\nexport const openFullScreenIntentSettings = (): void => native?.openFullScreenIntentSettings();\n\n/**\n * Android: let the app show over the lock screen while a call rings or\n * runs — answering must never demand an unlock. Turn it off when the\n * call ends. The activity re-applies it when the core relaunches it for\n * a call (`poolse_launch_call`), given the host's MainActivity hook.\n * No-op on iOS, where CallKit owns the lock screen.\n */\nexport function setShowOnLockscreen(enabled: boolean): void {\n try {\n native?.setShowOnLockscreen?.(enabled);\n } catch {\n // Never let a window flag take a call down.\n }\n}\n\n// ── missed-call notifications (Android) ─────────────────────────────────\n\n/**\n * Android: the missed-call notification action the app was LAUNCHED\n * with, once — read it on mount. `null` when the app opened any other\n * way. The native core posts that notification itself from the push,\n * so it works with the app closed.\n *\n * iOS shows missed calls as an ordinary alert push (to the token you\n * register with `kind: 'alert'`); read its taps with your notification\n * library — its `type` is `call_missed`, the category\n * `poolse_missed_call`, the Call back action `call_back`.\n */\nexport function takeCallAction(): CallAction | null {\n return native?.takeCallAction?.() ?? null;\n}\n\n/** Android: a missed-call notification tapped while the app is running. */\nexport function onCallAction(cb: (action: CallAction) => void): Unsubscribe {\n if (!native || !native.takeCallAction) return () => undefined;\n const sub = native.addListener('onCallAction', cb);\n return () => sub.remove();\n}\n\n// ── chat notifications ─────────────────────────────────────────────────\n\nlet activeConversation: string | null = null;\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 * The notification actions that finished while no `onNotificationAction`\n * listener was attached (usually: the app was not running), oldest\n * first, each returned once. Up to the last 50 are kept.\n */\nexport function takeNotificationActions(): NotificationActionResult[] {\n return native?.takeNotificationActions?.() ?? [];\n}\n\n// ── VoIP push (iOS) ───────────────────────────────────────────────────\n\n/**\n * iOS: the current PushKit VoIP token, registered natively at launch.\n * `null` until iOS issues one, and always on Android (FCM carries rings).\n */\nexport function getVoipToken(): VoipToken | null {\n return native?.getVoipToken?.() ?? null;\n}\n\n/** iOS: fires whenever PushKit issues (or rotates) the VoIP token. No-op on Android. */\nexport function onVoipToken(cb: (token: VoipToken) => void): Unsubscribe {\n if (!native || !native.getVoipToken) return () => undefined;\n const sub = native.addListener('onVoipToken', cb);\n return () => sub.remove();\n}\n\n// ── picture-in-picture ────────────────────────────────────────────────\n\n/**\n * Arm picture-in-picture: while on, leaving the app keeps the call's\n * video in a floating window. Turn it on only while a video call shows\n * someone's picture, and off otherwise.\n *\n * iOS (15+) floats the `<CallVideoView pictureInPicture>` that is on\n * screen — mark the main remote picture. Android (8+) floats the whole\n * app: draw a compact layout while `isInPictureInPicture()` (see\n * `onPictureInPicture`). The app needs `android:supportsPictureInPicture`\n * on its activity.\n */\nexport function setPictureInPictureEnabled(on: boolean): void {\n native?.setPictureInPictureEnabled?.(on);\n}\n\n/** Whether the floating window is open right now. */\nexport function isInPictureInPicture(): boolean {\n return native?.isInPictureInPicture?.() ?? false;\n}\n\n/** Whether this device can float a call at all. */\nexport function pictureInPictureSupported(): boolean {\n return native?.pictureInPictureSupported?.() ?? false;\n}\n\n/** Fires when the floating window opens (`true`) and closes (`false`). */\nexport function onPictureInPicture(cb: (active: boolean) => void): Unsubscribe {\n if (!native?.setPictureInPictureEnabled) return () => undefined;\n const sub = native.addListener('onPictureInPicture', (payload) => cb(payload.active));\n return () => sub.remove();\n}\n\n// ── video ─────────────────────────────────────────────────────────────\n\nexport interface CallVideoViewProps extends ViewProps {\n /** Remote participant's userId (LiveKit identity). Omit with local=true for self view. */\n participantId?: string;\n local?: boolean;\n /** default: true for local front camera, false otherwise */\n mirror?: boolean;\n /** default 'cover' */\n fit?: 'cover' | 'contain';\n /**\n * `camera` (default), or `screen`: the participant's shared screen\n * (with `local`, your own). A screen is never mirrored; draw it with\n * `fit=\"contain\"` so nothing is cropped.\n */\n source?: 'camera' | 'screen';\n /**\n * iOS: this remote picture is the one picture-in-picture floats when\n * the app is left (`setPictureInPictureEnabled`). Mark one at a time.\n */\n pictureInPicture?: boolean;\n}\n\ntype NativeVideoProps = CallVideoViewProps;\n\nlet nativeVideo: ComponentType<NativeVideoProps> | null | undefined;\n\n/** Resolved lazily (first render) and only when the native module exists. */\nfunction nativeVideoView(): ComponentType<NativeVideoProps> | null {\n if (nativeVideo !== undefined) return nativeVideo;\n nativeVideo = null;\n if (native) {\n try {\n nativeVideo = requireNativeViewManager<NativeVideoProps>('PoolseCalls', 'PoolseCallVideo');\n } catch {\n nativeVideo = null; // an older native build without the view\n }\n }\n return nativeVideo;\n}\n\n/**\n * A participant's camera (or, with `local`, your own), rendered natively\n * by the call core. Shows nothing (stays transparent) while that camera\n * is off — draw the avatar from the snapshot's `cameraOn` underneath.\n * Without the native module it renders an empty View.\n */\nexport function CallVideoView(props: CallVideoViewProps): ReactElement | null {\n const Native = nativeVideoView();\n if (!Native) {\n const {\n participantId: _p,\n local: _l,\n mirror: _m,\n fit: _f,\n source: _s,\n pictureInPicture: _pip,\n ...rest\n } = props;\n return createElement(View, rest);\n }\n return createElement(Native, props);\n}\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["requireOptionalNativeModule","requireNativeViewManager","createElement","View"],"mappings":";;;;;;;AAgTO,IAAM,iBAAA,GAAoB;AA8JjC,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,E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AAA,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\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 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}\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// ── 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
@@ -20,8 +20,20 @@ interface Snapshot {
20
20
  kind?: 'call' | 'room';
21
21
  media: 'audio' | 'video';
22
22
  phase: 'ringing_in' | 'ringing_out' | 'connecting' | 'active' | 'reconnecting' | 'ended';
23
- reason?: 'left' | 'finished' | 'declined_all' | 'busy_all' | 'no_answer' | 'cancelled' | 'connection_lost' | 'failed';
24
- /** REMOTE participants only; `userId` is the LiveKit identity. */
23
+ reason?: 'left' | 'finished' | 'declined_all' | 'busy_all' | 'no_answer' | 'cancelled' | 'connection_lost' | 'failed'
24
+ /**
25
+ * You took this call on another of your devices (`moveCallHere`
26
+ * there): it goes on without this one. Say "Moved to your other
27
+ * device", not "Call ended". Absent before 3.10.
28
+ */
29
+ | 'moved';
30
+ /**
31
+ * REMOTE people only; `userId` is the LiveKit identity. poolse's
32
+ * transcript assistant (`poolse:…`, kind agent) and the recorder
33
+ * (LiveKit Egress, `EG_…`) are never listed — nor counted when the core
34
+ * ends a call left alone. Phone (SIP) participants are listed. Agents
35
+ * invited into the call are listed with `isAgent` (last), never counted.
36
+ */
25
37
  participants: Array<{
26
38
  userId: string;
27
39
  externalId: string;
@@ -40,6 +52,16 @@ interface Snapshot {
40
52
  * Absent before 0.11.0.
41
53
  */
42
54
  connectionQuality?: ConnectionQuality;
55
+ /**
56
+ * An agent in the call (server docs/AGENTS_IN_CALLS.md): show it with
57
+ * the Agent badge, named `agentLabel` — never as a person, never with
58
+ * a camera placeholder. Absent for people and before 3.10.
59
+ */
60
+ isAgent?: boolean;
61
+ /** "Scout", or "Jasir's agent" for one attending on someone's behalf. */
62
+ agentLabel?: string | null;
63
+ /** `notetaker` (silent) | `assistant` (answers when named) | `delegate`. */
64
+ agentMode?: 'notetaker' | 'assistant' | 'delegate' | null;
43
65
  }>;
44
66
  /** The kind of output playing now — the short answer to "where is the audio". */
45
67
  audioRoute: AudioOutputKind;
@@ -91,6 +113,69 @@ interface Snapshot {
91
113
  * server's `name`. Absent before 3.8.
92
114
  */
93
115
  workspaceName?: string | null;
116
+ /**
117
+ * Whether the server lets you publish. `false` while recording consent
118
+ * is required and you have not accepted (docs/RECORDING.md §5): you
119
+ * still hear and see the call, but nothing of yours goes out. Your
120
+ * `mutedSelf` / camera choices are kept and come back as they were once
121
+ * it turns `true` again (the core republishes by itself; call
122
+ * `republish()` from ConsentPrompt's `onAccepted` too). Absent before 3.9.
123
+ */
124
+ canPublish?: boolean;
125
+ /**
126
+ * The call's recording state as the server last told this core (on
127
+ * answer / join / place and each reconnect) — enough to show the
128
+ * indicator at once. Live changes arrive on the conversation socket
129
+ * (`recording:*`). null: not known (a server without recording).
130
+ * Absent before 3.9.
131
+ */
132
+ recording?: CallRecordingState | null;
133
+ /** The live transcript's state, the same way (`transcript:*` on the socket). Absent before 3.9. */
134
+ transcription?: CallTranscriptionState | null;
135
+ /**
136
+ * `meeting`: a scheduled meeting rang this device as it started (the
137
+ * push's `ring_type`), so the ring reads "Weekly sync is starting" and
138
+ * the call screen should name the meeting. `call` otherwise. Absent
139
+ * before 3.10.
140
+ */
141
+ ringType?: 'call' | 'meeting';
142
+ /** The meeting's title for a `meeting` ring; null otherwise. Absent before 3.10. */
143
+ meetingTitle?: string | null;
144
+ /** Noise suppression on the microphone (on by default; `setNoiseSuppression`). Absent before 3.10. */
145
+ noiseSuppression?: boolean;
146
+ /** Background blur on the camera (`setBackgroundBlur`). Absent before 3.10. */
147
+ backgroundBlur?: boolean;
148
+ /**
149
+ * This call was taken over by your other device (`moveCallHere`
150
+ * there); the end that follows has `reason: 'moved'`. Absent before 3.10.
151
+ */
152
+ movedElsewhere?: boolean;
153
+ }
154
+ /** The CallSummary's `recording` object, as the server sent it (docs/CALL_CONTRACT.md §4.2). */
155
+ interface CallRecordingState {
156
+ /** This server can record (LiveKit Egress). */
157
+ available: boolean;
158
+ active: boolean;
159
+ id: string | null;
160
+ mode: 'video' | 'audio' | null;
161
+ started_at: string | null;
162
+ started_by_user_id: string | null;
163
+ auto: boolean;
164
+ /** You may not publish until you accept. */
165
+ consent_required: boolean;
166
+ /** poolse user ids. */
167
+ consent?: {
168
+ accepted: string[];
169
+ declined: string[];
170
+ };
171
+ }
172
+ /** The CallSummary's `transcription` object, as the server sent it. */
173
+ interface CallTranscriptionState {
174
+ available: boolean;
175
+ active: boolean;
176
+ id: string | null;
177
+ status: 'live' | 'stopped' | 'ready' | null;
178
+ language: string | null;
94
179
  }
95
180
  /** `good` covers good and excellent; `unknown` until the SFU has measured. */
96
181
  type ConnectionQuality = 'good' | 'poor' | 'lost' | 'unknown';
@@ -106,6 +191,10 @@ interface WaitingCall {
106
191
  serverId?: string | null;
107
192
  /** That workspace's name ("Ana · Acme"). Absent before 3.8. */
108
193
  workspaceName?: string | null;
194
+ /** `meeting` when a scheduled meeting is starting rather than a person calling. Absent before 3.10. */
195
+ ringType?: 'call' | 'meeting';
196
+ /** The meeting's title for a `meeting` ring. Absent before 3.10. */
197
+ meetingTitle?: string | null;
109
198
  }
110
199
  /** One place call audio can play. */
111
200
  interface AudioOutput {
@@ -212,33 +301,46 @@ interface CallServer {
212
301
  name?: string;
213
302
  }
214
303
  /**
215
- * What the user tapped on a missed-call notification: the notification
216
- * itself (`open` the conversation) or its Call back button (`call_back`
217
- * — place a call on the conversation with `media`).
304
+ * What the user tapped on a missed-call or meeting notification: the
305
+ * notification itself (`open` the conversation), a missed call's Call
306
+ * back (`call_back` — place a call on the conversation with `media`), or
307
+ * a starting meeting's Join (`join_meeting` — join the room `callId` in
308
+ * the conversation, e.g. `poolse.rooms.start(conversationId, media)`,
309
+ * which joins what is live).
218
310
  */
219
311
  interface CallAction {
220
- type: 'open' | 'call_back';
312
+ type: 'open' | 'call_back' | 'join_meeting';
221
313
  conversationId: string;
222
314
  callId: string | null;
223
315
  media: 'audio' | 'video';
224
316
  /** The server (workspace) it belongs to — open that one. Absent before 3.8. */
225
317
  serverId?: string | null;
318
+ /** A meeting notice's scheduled meeting; null for missed calls. Absent before 3.10. */
319
+ scheduledMeetingId?: string | null;
226
320
  }
227
321
  /**
228
- * A Reply or Mark as read the user did from a chat notification, after
229
- * the native core sent it (or gave up). The server has already posted
230
- * the reply and marked the conversation read; use this to refresh what
231
- * the app shows (insert the message, drop the unread count) without
232
- * waiting for the socket, or to tell the user a reply did not go out.
322
+ * A Reply or Mark as read the user did from a chat notification — or an
323
+ * answer to an agent's question (`escalation`: Approve / Decline / Answer
324
+ * on an `agent_escalation` push) — after the native core sent it (or gave
325
+ * up). The server has already posted the reply and marked the
326
+ * conversation read, or passed the answer to the agent in the call; use
327
+ * this to refresh what the app shows without waiting for the socket, or
328
+ * to tell the user it did not go out.
233
329
  */
234
330
  interface NotificationActionResult {
235
- action: 'reply' | 'mark_read';
331
+ action: 'reply' | 'mark_read' | 'escalation';
332
+ /** The conversation (for `escalation`: the call's; `""` when the push had none). */
236
333
  conversationId: string;
334
+ /** `escalation` only: which question, and how it was answered. Absent before 3.10. */
335
+ escalationId?: string;
336
+ decision?: 'approve' | 'decline' | 'answer';
337
+ /** `escalation` only: the call the agent is in. */
338
+ callId?: string | null;
237
339
  /** The server (workspace) the conversation is on. Absent before 3.8. */
238
340
  serverId?: string;
239
341
  /** Whether the server accepted it. */
240
342
  ok: boolean;
241
- /** Reply only: what the user typed. */
343
+ /** Reply (and an escalation's `answer`): what the user typed. */
242
344
  text?: string;
243
345
  /** Reply only: the idempotency id sent with it — the message's id once posted. */
244
346
  clientId?: string;
@@ -249,7 +351,8 @@ interface NotificationActionResult {
249
351
  * `device_signed_out`, `user_blocked`, `forbidden`, `not_found`,
250
352
  * `mau_cap_exceeded`, `validation_failed`, `rate_limited`), or
251
353
  * `network`, `no_grant` (the push carried no reply grant),
252
- * `not_configured` (never `configure`d), `http_<status>`.
354
+ * `not_configured` (never `configure`d), `http_<status>`. An
355
+ * escalation: `not_pending`, `expired`, `invalid_token`, `no_token`.
253
356
  */
254
357
  error?: string;
255
358
  /** The HTTP status when the server answered with an error. */
@@ -301,6 +404,25 @@ declare function onCallState(cb: (snapshot: Snapshot | null) => void): Unsubscri
301
404
  declare function place(conversationId: string, options: PlaceOptions): Promise<void>;
302
405
  /** `serverId`: the server the session token is for — leave it out for the default one. */
303
406
  declare function join(callId: string, conversationId: string | null, sessionToken: string, serverId?: string): Promise<void>;
407
+ /** What {@link moveCallHere} needs besides the call id. */
408
+ interface MoveCallOptions {
409
+ conversationId: string;
410
+ /** The user's session token on the call's server. */
411
+ sessionToken: string;
412
+ /** The call's server (an `addServer` id); leave it out for the default one. */
413
+ serverId?: string;
414
+ }
415
+ /**
416
+ * "Move call to this device" (CL11): take a call you are on elsewhere
417
+ * — your desktop, your other phone — over to this one without hanging
418
+ * up. This device joins the same call; the server lets one device per
419
+ * person carry it (CALL_CONTRACT.md §9), so the other one is let go and
420
+ * its snapshot ends with `reason: 'moved'`. Offer it from the Join
421
+ * banner when `liveCalls` says you are already in the call.
422
+ *
423
+ * The camera follows the call's media on this device; mute starts off.
424
+ */
425
+ declare function moveCallHere(callId: string, options: MoveCallOptions): Promise<void>;
304
426
  interface StartRoomResult {
305
427
  /** The room's call id — what the Join banner and `call:*` events carry. */
306
428
  callId: string;
@@ -369,6 +491,33 @@ declare const screenShareSupported: () => boolean;
369
491
  */
370
492
  declare const startScreenShare: () => Promise<boolean>;
371
493
  declare const stopScreenShare: () => void;
494
+ /**
495
+ * Whether noise suppression can be switched. On by default on both
496
+ * platforms; the snapshot's `noiseSuppression` says what is in effect.
497
+ */
498
+ declare const noiseSuppressionSupported: () => boolean;
499
+ /**
500
+ * Noise suppression on or off, for this and later calls (until the app
501
+ * restarts). Android: WebRTC's noise suppression on the microphone
502
+ * (echo cancellation stays on; the mic track is republished, a short
503
+ * gap). iOS: Apple's voice processing does echo cancellation and noise
504
+ * suppression as one, so off bypasses both — offer "off" for
505
+ * headphones only. Returns false when the build can't.
506
+ */
507
+ declare const setNoiseSuppression: (on: boolean) => boolean;
508
+ /**
509
+ * Whether this build can blur the background behind you. iOS 15+: yes
510
+ * (Vision person segmentation). Android: not yet — it needs an ML Kit
511
+ * segmentation model, planned as a later addition. Hide the toggle when
512
+ * false.
513
+ */
514
+ declare const backgroundBlurSupported: () => boolean;
515
+ /**
516
+ * Blur the background on your camera, kept across camera flips and
517
+ * calls. A no-op returning false where unsupported. Background
518
+ * pictures (replacement) are not offered on native yet.
519
+ */
520
+ declare const setBackgroundBlur: (on: boolean) => boolean;
372
521
  /** Route call audio to the loudspeaker (`true`) or back to earpiece / headset (`false`). */
373
522
  declare const setSpeaker: (on: boolean) => void;
374
523
  /**
@@ -379,6 +528,20 @@ declare const setSpeaker: (on: boolean) => void;
379
528
  * the earpiece for voice calls or the speaker for video.
380
529
  */
381
530
  declare function setAudioOutput(id: string): void;
531
+ /**
532
+ * Recording consent accepted (ConsentPrompt's `onAccepted`): publish the
533
+ * mic and camera again as the user last had them. The core also does it
534
+ * by itself once the server lets this participant publish; calling it
535
+ * early, or twice, is harmless — nothing goes out while
536
+ * `snapshot.canPublish` is false.
537
+ */
538
+ declare const republish: () => void;
539
+ /**
540
+ * `snapshot.canPublish` changed (and once at subscribe time with the
541
+ * current value, while a call is up). `true` when no call is up or the
542
+ * native build predates it.
543
+ */
544
+ declare function onCanPublishChange(cb: (canPublish: boolean) => void): Unsubscribe;
382
545
  /**
383
546
  * Socket forwarding for an open app: a `call:ring_ended` seen on the
384
547
  * socket. Idempotent with the push path — the core dedupes.
@@ -407,18 +570,22 @@ declare const openFullScreenIntentSettings: () => void;
407
570
  */
408
571
  declare function setShowOnLockscreen(enabled: boolean): void;
409
572
  /**
410
- * Android: the missed-call notification action the app was LAUNCHED
411
- * with, once — read it on mount. `null` when the app opened any other
412
- * way. The native core posts that notification itself from the push,
413
- * so it works with the app closed.
573
+ * The notification action the app was LAUNCHED with, once — read it on
574
+ * mount. `null` when the app opened any other way.
575
+ *
576
+ * Android: missed calls and meeting notices (`starting` with Join, and
577
+ * the brief; server docs/MEETINGS.md §11.3), both posted by the native
578
+ * core from the push so they work with the app closed.
414
579
  *
415
- * iOS shows missed calls as an ordinary alert push (to the token you
416
- * register with `kind: 'alert'`); read its taps with your notification
417
- * library — its `type` is `call_missed`, the category
580
+ * iOS: meeting notices (the alert push's category `poolse_meeting`, Join
581
+ * `poolse_meeting_join`), whose tap and Join arrive here as `open` /
582
+ * `join_meeting`. Missed calls there are an ordinary alert push (to the
583
+ * token you register with `kind: 'alert'`); read its taps with your
584
+ * notification library — its `type` is `call_missed`, the category
418
585
  * `poolse_missed_call`, the Call back action `call_back`.
419
586
  */
420
587
  declare function takeCallAction(): CallAction | null;
421
- /** Android: a missed-call notification tapped while the app is running. */
588
+ /** A missed-call (Android) or meeting notification (both) tapped while the app is running. */
422
589
  declare function onCallAction(cb: (action: CallAction) => void): Unsubscribe;
423
590
  /**
424
591
  * Tell the core which conversation is on screen (`null` when none, and
@@ -453,6 +620,13 @@ declare function conversationOfNotification(data: Record<string, unknown> | unde
453
620
  declare function onNotificationAction(cb: (result: NotificationActionResult) => void): Unsubscribe;
454
621
  /** `onNotificationAction`, replies only. */
455
622
  declare function onNotificationReply(cb: (result: NotificationActionResult) => void): Unsubscribe;
623
+ /**
624
+ * `onNotificationAction`, agent escalations only (AG16): Approve / Decline
625
+ * / Answer on an `agent_escalation` push, answered natively from the lock
626
+ * screen. Feed `ok` ones to `poolse.escalations.list()` (or let
627
+ * `agent:escalation` do it) so an open card updates.
628
+ */
629
+ declare function onEscalationAction(cb: (result: NotificationActionResult) => void): Unsubscribe;
456
630
  /**
457
631
  * The notification actions that finished while no `onNotificationAction`
458
632
  * listener was attached (usually: the app was not running), oldest
@@ -512,4 +686,4 @@ interface CallVideoViewProps extends ViewProps {
512
686
  */
513
687
  declare function CallVideoView(props: CallVideoViewProps): ReactElement | null;
514
688
 
515
- export { type AudioOutput, type AudioOutputKind, type CallAction, type CallServer, CallVideoView, type CallVideoViewProps, type ConfigureOptions, type ConnectionQuality, DEFAULT_SERVER_ID, type IncomingCallOptions, type NotificationActionResult, type PlaceOptions, type RingIntoCallOptions, type Snapshot, type StartRoomResult, type Unsubscribe, type VoipToken, type WaitingCall, addServer, answer, answerWaiting, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, listServers, nativeCallsAvailable, onCallAction, onCallFinished, onCallState, onNotificationAction, onNotificationReply, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, removeServer, ringIntoCall, screenShareSupported, serverOfNotification, setActiveConversation, setAudioOutput, setCamera, setMuted, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction, takeNotificationActions };
689
+ export { type AudioOutput, type AudioOutputKind, type CallAction, 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 RingIntoCallOptions, type Snapshot, type StartRoomResult, type Unsubscribe, type VoipToken, type WaitingCall, addServer, answer, answerWaiting, backgroundBlurSupported, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, listServers, moveCallHere, nativeCallsAvailable, noiseSuppressionSupported, onCallAction, onCallFinished, onCallState, onCanPublishChange, onEscalationAction, onNotificationAction, onNotificationReply, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, removeServer, republish, ringIntoCall, screenShareSupported, serverOfNotification, setActiveConversation, setAudioOutput, setBackgroundBlur, setCamera, setMuted, setNoiseSuppression, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction, takeNotificationActions };