@poolse/native 3.7.0 → 3.8.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.
- package/CHANGELOG.md +32 -0
- package/README.md +61 -1
- package/android/src/main/java/dev/poolse/callcore/CallServers.kt +72 -0
- package/android/src/main/java/dev/poolse/callcore/Ports.kt +8 -0
- package/android/src/main/java/dev/poolse/callcore/RoutedHttpPort.kt +74 -0
- package/android/src/main/java/dev/poolse/callcore/android/AndroidRingSurface.kt +3 -3
- package/android/src/main/java/dev/poolse/callcore/android/CallCore.kt +110 -14
- package/android/src/main/java/dev/poolse/callcore/android/CallMessagingService.kt +4 -0
- package/android/src/main/java/dev/poolse/callcore/android/IncomingCallActivity.kt +1 -1
- package/android/src/main/java/dev/poolse/callcore/android/MessageActionWorker.kt +35 -12
- package/android/src/main/java/dev/poolse/callcore/android/MessageNotifications.kt +142 -48
- package/android/src/main/java/dev/poolse/callcore/android/MissedCallNotification.kt +8 -0
- package/android/src/main/java/dev/poolse/callcore/android/PoolseIncomingCall.kt +16 -0
- package/android/src/main/java/dev/poolse/callcore/android/RingBundle.kt +6 -0
- package/android/src/main/java/dev/poolse/callcore/android/ServerRegistry.kt +107 -0
- package/android/src/main/java/expo/modules/poolsecalls/PoolseCallsModule.kt +56 -7
- package/dist/index.cjs +68 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +91 -8
- package/dist/index.d.ts +91 -8
- package/dist/index.js +64 -25
- package/dist/index.js.map +1 -1
- package/ios/Core/CallServers.swift +89 -0
- package/ios/Core/Ports.swift +10 -1
- package/ios/Core/RoutedHttpPort.swift +83 -0
- package/ios/Module/PoolseCallsModule.swift +48 -8
- package/ios/Platform/CallCore.swift +116 -11
- package/ios/Platform/CallKitController.swift +4 -1
- package/ios/Platform/MessageNotifications.swift +76 -23
- package/ios/Platform/ServerRegistry.swift +90 -0
- package/ios/Platform/VoipPush.swift +5 -1
- package/package.json +1 -1
- package/src/index.ts +187 -30
package/dist/index.d.cts
CHANGED
|
@@ -80,6 +80,17 @@ interface Snapshot {
|
|
|
80
80
|
videoPaused?: boolean;
|
|
81
81
|
/** You are sharing your screen. Absent before 3.2. */
|
|
82
82
|
screenSharing?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* The server (workspace) this call runs on — the `id` given to
|
|
85
|
+
* `addServer`, or `DEFAULT_SERVER_ID` for the one `configure` set.
|
|
86
|
+
* Absent before 3.8.
|
|
87
|
+
*/
|
|
88
|
+
serverId?: string | null;
|
|
89
|
+
/**
|
|
90
|
+
* That workspace's name: the ring push's `workspace_name`, else the
|
|
91
|
+
* server's `name`. Absent before 3.8.
|
|
92
|
+
*/
|
|
93
|
+
workspaceName?: string | null;
|
|
83
94
|
}
|
|
84
95
|
/** `good` covers good and excellent; `unknown` until the SFU has measured. */
|
|
85
96
|
type ConnectionQuality = 'good' | 'poor' | 'lost' | 'unknown';
|
|
@@ -91,6 +102,10 @@ interface WaitingCall {
|
|
|
91
102
|
conversationName: string | null;
|
|
92
103
|
callerName: string | null;
|
|
93
104
|
media: 'audio' | 'video';
|
|
105
|
+
/** The server (workspace) it rings from — may differ from the current call's. Absent before 3.8. */
|
|
106
|
+
serverId?: string | null;
|
|
107
|
+
/** That workspace's name ("Ana · Acme"). Absent before 3.8. */
|
|
108
|
+
workspaceName?: string | null;
|
|
94
109
|
}
|
|
95
110
|
/** One place call audio can play. */
|
|
96
111
|
interface AudioOutput {
|
|
@@ -166,6 +181,35 @@ interface PlaceOptions {
|
|
|
166
181
|
media: 'audio' | 'video';
|
|
167
182
|
/** The user's session token — authorizes placing/joining (CALL_CONTRACT.md §3.2). */
|
|
168
183
|
sessionToken: string;
|
|
184
|
+
/**
|
|
185
|
+
* The server (workspace) the session token belongs to — an `addServer`
|
|
186
|
+
* id. Leave it out for the default server (`configure`'s).
|
|
187
|
+
*/
|
|
188
|
+
serverId?: string;
|
|
189
|
+
}
|
|
190
|
+
/** The server `configure(apiBaseUrl)` sets; what everything defaults to. */
|
|
191
|
+
declare const DEFAULT_SERVER_ID = "default";
|
|
192
|
+
/**
|
|
193
|
+
* One server (workspace) the app is signed in to. No secrets: rings
|
|
194
|
+
* carry their own grant, and place / join take the session token.
|
|
195
|
+
*/
|
|
196
|
+
interface CallServer {
|
|
197
|
+
/**
|
|
198
|
+
* Your id for it, 1–64 of `A–Z a–z 0–9 . _ : -` — what `serverId`
|
|
199
|
+
* says everywhere (snapshots, notification taps and actions).
|
|
200
|
+
*/
|
|
201
|
+
id: string;
|
|
202
|
+
/** Its API origin, as for `configure`. */
|
|
203
|
+
apiBaseUrl: string;
|
|
204
|
+
/**
|
|
205
|
+
* The poolse tenant this sign-in belongs to (`tenant_id` of `me` or of
|
|
206
|
+
* the registered device). Pushes carry it: it is how a ring or a
|
|
207
|
+
* notification finds its server. Needed as soon as two servers are
|
|
208
|
+
* added; without it a push goes to the default server.
|
|
209
|
+
*/
|
|
210
|
+
tenantId?: string;
|
|
211
|
+
/** The workspace's name — shown when a push carries none ("Ana · Acme"). */
|
|
212
|
+
name?: string;
|
|
169
213
|
}
|
|
170
214
|
/**
|
|
171
215
|
* What the user tapped on a missed-call notification: the notification
|
|
@@ -177,6 +221,8 @@ interface CallAction {
|
|
|
177
221
|
conversationId: string;
|
|
178
222
|
callId: string | null;
|
|
179
223
|
media: 'audio' | 'video';
|
|
224
|
+
/** The server (workspace) it belongs to — open that one. Absent before 3.8. */
|
|
225
|
+
serverId?: string | null;
|
|
180
226
|
}
|
|
181
227
|
/**
|
|
182
228
|
* A Reply or Mark as read the user did from a chat notification, after
|
|
@@ -188,6 +234,8 @@ interface CallAction {
|
|
|
188
234
|
interface NotificationActionResult {
|
|
189
235
|
action: 'reply' | 'mark_read';
|
|
190
236
|
conversationId: string;
|
|
237
|
+
/** The server (workspace) the conversation is on. Absent before 3.8. */
|
|
238
|
+
serverId?: string;
|
|
191
239
|
/** Whether the server accepted it. */
|
|
192
240
|
ok: boolean;
|
|
193
241
|
/** Reply only: what the user typed. */
|
|
@@ -211,15 +259,48 @@ interface NotificationActionResult {
|
|
|
211
259
|
}
|
|
212
260
|
/** True when the native call core is present in this build. */
|
|
213
261
|
declare const nativeCallsAvailable: boolean;
|
|
214
|
-
/**
|
|
215
|
-
|
|
262
|
+
/**
|
|
263
|
+
* Configure once, before any call can arrive. No secrets — just the API
|
|
264
|
+
* origin, which becomes the default server (`DEFAULT_SERVER_ID`).
|
|
265
|
+
*
|
|
266
|
+
* `configure(options)` sets the options alone, for an app whose servers
|
|
267
|
+
* all come from `addServer`.
|
|
268
|
+
*/
|
|
269
|
+
declare function configure(apiBaseUrlOrOptions: string | ConfigureOptions, options?: ConfigureOptions): Promise<void>;
|
|
270
|
+
/**
|
|
271
|
+
* Sign the call core in to one more server (workspace) — or update one
|
|
272
|
+
* (same `id`). Rings from it ring here, answered and declined on that
|
|
273
|
+
* server; its chat notifications post (Android) and act (Reply, Mark as
|
|
274
|
+
* read) against it. Persisted: a closed app woken by its push finds it.
|
|
275
|
+
*
|
|
276
|
+
* Register the device's push tokens with that server too (the SDK's
|
|
277
|
+
* `devices.register`, per client): this only tells the core where it is.
|
|
278
|
+
* Calls `configure` with default options first if it never ran.
|
|
279
|
+
*/
|
|
280
|
+
declare function addServer(server: CallServer): Promise<void>;
|
|
281
|
+
/**
|
|
282
|
+
* Signed out of one server: the core forgets it and takes its
|
|
283
|
+
* notifications down; the others are untouched. A call in progress on
|
|
284
|
+
* it carries on to its end. Unregister its push tokens with that server
|
|
285
|
+
* yourself (before signing out there).
|
|
286
|
+
*/
|
|
287
|
+
declare function removeServer(id: string): Promise<void>;
|
|
288
|
+
/** The servers the core knows, in the order they were added (`configure`'s is `default`). */
|
|
289
|
+
declare function listServers(): CallServer[];
|
|
290
|
+
/**
|
|
291
|
+
* The server a notification (its data) belongs to, by its `tenant_id` —
|
|
292
|
+
* the same rule the core routes rings and actions by. Use it on a tapped
|
|
293
|
+
* iOS notification to open the right workspace. `null` with no server.
|
|
294
|
+
*/
|
|
295
|
+
declare function serverOfNotification(data: Record<string, unknown> | undefined | null): string | null;
|
|
216
296
|
/** The current snapshot — safe to read at any moment, including cold answer and before configure. */
|
|
217
297
|
declare function getCallState(): Snapshot | null;
|
|
218
298
|
type Unsubscribe = () => void;
|
|
219
299
|
/** Subscribe to call state. Fires a full snapshot on every change. */
|
|
220
300
|
declare function onCallState(cb: (snapshot: Snapshot | null) => void): Unsubscribe;
|
|
221
301
|
declare function place(conversationId: string, options: PlaceOptions): Promise<void>;
|
|
222
|
-
|
|
302
|
+
/** `serverId`: the server the session token is for — leave it out for the default one. */
|
|
303
|
+
declare function join(callId: string, conversationId: string | null, sessionToken: string, serverId?: string): Promise<void>;
|
|
223
304
|
interface StartRoomResult {
|
|
224
305
|
/** The room's call id — what the Join banner and `call:*` events carry. */
|
|
225
306
|
callId: string;
|
|
@@ -343,9 +424,10 @@ declare function onCallAction(cb: (action: CallAction) => void): Unsubscribe;
|
|
|
343
424
|
* Tell the core which conversation is on screen (`null` when none, and
|
|
344
425
|
* when the app goes to the background). Its messages are not notified —
|
|
345
426
|
* the user is reading them — and opening it clears the notifications
|
|
346
|
-
* already shown for it.
|
|
427
|
+
* already shown for it. Signed in to several servers, pass the one it is
|
|
428
|
+
* on (`serverId`); without it, the conversation id alone decides.
|
|
347
429
|
*/
|
|
348
|
-
declare function setActiveConversation(conversationId: string | null): void;
|
|
430
|
+
declare function setActiveConversation(conversationId: string | null, serverId?: string): void;
|
|
349
431
|
/**
|
|
350
432
|
* For the app's notification handler (expo-notifications'
|
|
351
433
|
* `setNotificationHandler`): `false` for a chat notification of the
|
|
@@ -357,13 +439,14 @@ declare function shouldPresentMessage(data: Record<string, unknown> | undefined
|
|
|
357
439
|
* The conversation a tapped notification belongs to — a chat message
|
|
358
440
|
* (`type: 'message'`) or a missed call (`call_missed`) — from its data.
|
|
359
441
|
* iOS hands the tap to your notification library; Android delivers it
|
|
360
|
-
* through `takeCallAction` / `onCallAction` (type `open`).
|
|
442
|
+
* through `takeCallAction` / `onCallAction` (type `open`). Its server:
|
|
443
|
+
* `serverOfNotification`.
|
|
361
444
|
*/
|
|
362
445
|
declare function conversationOfNotification(data: Record<string, unknown> | undefined | null): string | null;
|
|
363
446
|
/**
|
|
364
447
|
* Reply and Mark as read from a chat notification are handled natively —
|
|
365
448
|
* from the lock screen, with the app closed — using the grant the push
|
|
366
|
-
* carried and
|
|
449
|
+
* carried and its server's API origin (`configure` / `addServer`, persisted).
|
|
367
450
|
* This fires once each finishes while the app is running. Read the ones
|
|
368
451
|
* that finished while it was not with `takeNotificationActions` on mount.
|
|
369
452
|
*/
|
|
@@ -429,4 +512,4 @@ interface CallVideoViewProps extends ViewProps {
|
|
|
429
512
|
*/
|
|
430
513
|
declare function CallVideoView(props: CallVideoViewProps): ReactElement | null;
|
|
431
514
|
|
|
432
|
-
export { type AudioOutput, type AudioOutputKind, type CallAction, CallVideoView, type CallVideoViewProps, type ConfigureOptions, type ConnectionQuality, type IncomingCallOptions, type NotificationActionResult, type PlaceOptions, type RingIntoCallOptions, type Snapshot, type StartRoomResult, type Unsubscribe, type VoipToken, type WaitingCall, answer, answerWaiting, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, nativeCallsAvailable, onCallAction, onCallFinished, onCallState, onNotificationAction, onNotificationReply, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, ringIntoCall, screenShareSupported, setActiveConversation, setAudioOutput, setCamera, setMuted, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction, takeNotificationActions };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -80,6 +80,17 @@ interface Snapshot {
|
|
|
80
80
|
videoPaused?: boolean;
|
|
81
81
|
/** You are sharing your screen. Absent before 3.2. */
|
|
82
82
|
screenSharing?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* The server (workspace) this call runs on — the `id` given to
|
|
85
|
+
* `addServer`, or `DEFAULT_SERVER_ID` for the one `configure` set.
|
|
86
|
+
* Absent before 3.8.
|
|
87
|
+
*/
|
|
88
|
+
serverId?: string | null;
|
|
89
|
+
/**
|
|
90
|
+
* That workspace's name: the ring push's `workspace_name`, else the
|
|
91
|
+
* server's `name`. Absent before 3.8.
|
|
92
|
+
*/
|
|
93
|
+
workspaceName?: string | null;
|
|
83
94
|
}
|
|
84
95
|
/** `good` covers good and excellent; `unknown` until the SFU has measured. */
|
|
85
96
|
type ConnectionQuality = 'good' | 'poor' | 'lost' | 'unknown';
|
|
@@ -91,6 +102,10 @@ interface WaitingCall {
|
|
|
91
102
|
conversationName: string | null;
|
|
92
103
|
callerName: string | null;
|
|
93
104
|
media: 'audio' | 'video';
|
|
105
|
+
/** The server (workspace) it rings from — may differ from the current call's. Absent before 3.8. */
|
|
106
|
+
serverId?: string | null;
|
|
107
|
+
/** That workspace's name ("Ana · Acme"). Absent before 3.8. */
|
|
108
|
+
workspaceName?: string | null;
|
|
94
109
|
}
|
|
95
110
|
/** One place call audio can play. */
|
|
96
111
|
interface AudioOutput {
|
|
@@ -166,6 +181,35 @@ interface PlaceOptions {
|
|
|
166
181
|
media: 'audio' | 'video';
|
|
167
182
|
/** The user's session token — authorizes placing/joining (CALL_CONTRACT.md §3.2). */
|
|
168
183
|
sessionToken: string;
|
|
184
|
+
/**
|
|
185
|
+
* The server (workspace) the session token belongs to — an `addServer`
|
|
186
|
+
* id. Leave it out for the default server (`configure`'s).
|
|
187
|
+
*/
|
|
188
|
+
serverId?: string;
|
|
189
|
+
}
|
|
190
|
+
/** The server `configure(apiBaseUrl)` sets; what everything defaults to. */
|
|
191
|
+
declare const DEFAULT_SERVER_ID = "default";
|
|
192
|
+
/**
|
|
193
|
+
* One server (workspace) the app is signed in to. No secrets: rings
|
|
194
|
+
* carry their own grant, and place / join take the session token.
|
|
195
|
+
*/
|
|
196
|
+
interface CallServer {
|
|
197
|
+
/**
|
|
198
|
+
* Your id for it, 1–64 of `A–Z a–z 0–9 . _ : -` — what `serverId`
|
|
199
|
+
* says everywhere (snapshots, notification taps and actions).
|
|
200
|
+
*/
|
|
201
|
+
id: string;
|
|
202
|
+
/** Its API origin, as for `configure`. */
|
|
203
|
+
apiBaseUrl: string;
|
|
204
|
+
/**
|
|
205
|
+
* The poolse tenant this sign-in belongs to (`tenant_id` of `me` or of
|
|
206
|
+
* the registered device). Pushes carry it: it is how a ring or a
|
|
207
|
+
* notification finds its server. Needed as soon as two servers are
|
|
208
|
+
* added; without it a push goes to the default server.
|
|
209
|
+
*/
|
|
210
|
+
tenantId?: string;
|
|
211
|
+
/** The workspace's name — shown when a push carries none ("Ana · Acme"). */
|
|
212
|
+
name?: string;
|
|
169
213
|
}
|
|
170
214
|
/**
|
|
171
215
|
* What the user tapped on a missed-call notification: the notification
|
|
@@ -177,6 +221,8 @@ interface CallAction {
|
|
|
177
221
|
conversationId: string;
|
|
178
222
|
callId: string | null;
|
|
179
223
|
media: 'audio' | 'video';
|
|
224
|
+
/** The server (workspace) it belongs to — open that one. Absent before 3.8. */
|
|
225
|
+
serverId?: string | null;
|
|
180
226
|
}
|
|
181
227
|
/**
|
|
182
228
|
* A Reply or Mark as read the user did from a chat notification, after
|
|
@@ -188,6 +234,8 @@ interface CallAction {
|
|
|
188
234
|
interface NotificationActionResult {
|
|
189
235
|
action: 'reply' | 'mark_read';
|
|
190
236
|
conversationId: string;
|
|
237
|
+
/** The server (workspace) the conversation is on. Absent before 3.8. */
|
|
238
|
+
serverId?: string;
|
|
191
239
|
/** Whether the server accepted it. */
|
|
192
240
|
ok: boolean;
|
|
193
241
|
/** Reply only: what the user typed. */
|
|
@@ -211,15 +259,48 @@ interface NotificationActionResult {
|
|
|
211
259
|
}
|
|
212
260
|
/** True when the native call core is present in this build. */
|
|
213
261
|
declare const nativeCallsAvailable: boolean;
|
|
214
|
-
/**
|
|
215
|
-
|
|
262
|
+
/**
|
|
263
|
+
* Configure once, before any call can arrive. No secrets — just the API
|
|
264
|
+
* origin, which becomes the default server (`DEFAULT_SERVER_ID`).
|
|
265
|
+
*
|
|
266
|
+
* `configure(options)` sets the options alone, for an app whose servers
|
|
267
|
+
* all come from `addServer`.
|
|
268
|
+
*/
|
|
269
|
+
declare function configure(apiBaseUrlOrOptions: string | ConfigureOptions, options?: ConfigureOptions): Promise<void>;
|
|
270
|
+
/**
|
|
271
|
+
* Sign the call core in to one more server (workspace) — or update one
|
|
272
|
+
* (same `id`). Rings from it ring here, answered and declined on that
|
|
273
|
+
* server; its chat notifications post (Android) and act (Reply, Mark as
|
|
274
|
+
* read) against it. Persisted: a closed app woken by its push finds it.
|
|
275
|
+
*
|
|
276
|
+
* Register the device's push tokens with that server too (the SDK's
|
|
277
|
+
* `devices.register`, per client): this only tells the core where it is.
|
|
278
|
+
* Calls `configure` with default options first if it never ran.
|
|
279
|
+
*/
|
|
280
|
+
declare function addServer(server: CallServer): Promise<void>;
|
|
281
|
+
/**
|
|
282
|
+
* Signed out of one server: the core forgets it and takes its
|
|
283
|
+
* notifications down; the others are untouched. A call in progress on
|
|
284
|
+
* it carries on to its end. Unregister its push tokens with that server
|
|
285
|
+
* yourself (before signing out there).
|
|
286
|
+
*/
|
|
287
|
+
declare function removeServer(id: string): Promise<void>;
|
|
288
|
+
/** The servers the core knows, in the order they were added (`configure`'s is `default`). */
|
|
289
|
+
declare function listServers(): CallServer[];
|
|
290
|
+
/**
|
|
291
|
+
* The server a notification (its data) belongs to, by its `tenant_id` —
|
|
292
|
+
* the same rule the core routes rings and actions by. Use it on a tapped
|
|
293
|
+
* iOS notification to open the right workspace. `null` with no server.
|
|
294
|
+
*/
|
|
295
|
+
declare function serverOfNotification(data: Record<string, unknown> | undefined | null): string | null;
|
|
216
296
|
/** The current snapshot — safe to read at any moment, including cold answer and before configure. */
|
|
217
297
|
declare function getCallState(): Snapshot | null;
|
|
218
298
|
type Unsubscribe = () => void;
|
|
219
299
|
/** Subscribe to call state. Fires a full snapshot on every change. */
|
|
220
300
|
declare function onCallState(cb: (snapshot: Snapshot | null) => void): Unsubscribe;
|
|
221
301
|
declare function place(conversationId: string, options: PlaceOptions): Promise<void>;
|
|
222
|
-
|
|
302
|
+
/** `serverId`: the server the session token is for — leave it out for the default one. */
|
|
303
|
+
declare function join(callId: string, conversationId: string | null, sessionToken: string, serverId?: string): Promise<void>;
|
|
223
304
|
interface StartRoomResult {
|
|
224
305
|
/** The room's call id — what the Join banner and `call:*` events carry. */
|
|
225
306
|
callId: string;
|
|
@@ -343,9 +424,10 @@ declare function onCallAction(cb: (action: CallAction) => void): Unsubscribe;
|
|
|
343
424
|
* Tell the core which conversation is on screen (`null` when none, and
|
|
344
425
|
* when the app goes to the background). Its messages are not notified —
|
|
345
426
|
* the user is reading them — and opening it clears the notifications
|
|
346
|
-
* already shown for it.
|
|
427
|
+
* already shown for it. Signed in to several servers, pass the one it is
|
|
428
|
+
* on (`serverId`); without it, the conversation id alone decides.
|
|
347
429
|
*/
|
|
348
|
-
declare function setActiveConversation(conversationId: string | null): void;
|
|
430
|
+
declare function setActiveConversation(conversationId: string | null, serverId?: string): void;
|
|
349
431
|
/**
|
|
350
432
|
* For the app's notification handler (expo-notifications'
|
|
351
433
|
* `setNotificationHandler`): `false` for a chat notification of the
|
|
@@ -357,13 +439,14 @@ declare function shouldPresentMessage(data: Record<string, unknown> | undefined
|
|
|
357
439
|
* The conversation a tapped notification belongs to — a chat message
|
|
358
440
|
* (`type: 'message'`) or a missed call (`call_missed`) — from its data.
|
|
359
441
|
* iOS hands the tap to your notification library; Android delivers it
|
|
360
|
-
* through `takeCallAction` / `onCallAction` (type `open`).
|
|
442
|
+
* through `takeCallAction` / `onCallAction` (type `open`). Its server:
|
|
443
|
+
* `serverOfNotification`.
|
|
361
444
|
*/
|
|
362
445
|
declare function conversationOfNotification(data: Record<string, unknown> | undefined | null): string | null;
|
|
363
446
|
/**
|
|
364
447
|
* Reply and Mark as read from a chat notification are handled natively —
|
|
365
448
|
* from the lock screen, with the app closed — using the grant the push
|
|
366
|
-
* carried and
|
|
449
|
+
* carried and its server's API origin (`configure` / `addServer`, persisted).
|
|
367
450
|
* This fires once each finishes while the app is running. Read the ones
|
|
368
451
|
* that finished while it was not with `takeNotificationActions` on mount.
|
|
369
452
|
*/
|
|
@@ -429,4 +512,4 @@ interface CallVideoViewProps extends ViewProps {
|
|
|
429
512
|
*/
|
|
430
513
|
declare function CallVideoView(props: CallVideoViewProps): ReactElement | null;
|
|
431
514
|
|
|
432
|
-
export { type AudioOutput, type AudioOutputKind, type CallAction, CallVideoView, type CallVideoViewProps, type ConfigureOptions, type ConnectionQuality, type IncomingCallOptions, type NotificationActionResult, type PlaceOptions, type RingIntoCallOptions, type Snapshot, type StartRoomResult, type Unsubscribe, type VoipToken, type WaitingCall, answer, answerWaiting, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, nativeCallsAvailable, onCallAction, onCallFinished, onCallState, onNotificationAction, onNotificationReply, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, ringIntoCall, screenShareSupported, setActiveConversation, setAudioOutput, setCamera, setMuted, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction, takeNotificationActions };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -3,12 +3,49 @@ import { View } from 'react-native';
|
|
|
3
3
|
import { requireOptionalNativeModule, requireNativeViewManager } from 'expo-modules-core';
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
|
+
var DEFAULT_SERVER_ID = "default";
|
|
6
7
|
var native = requireOptionalNativeModule("PoolseCalls");
|
|
7
8
|
var nativeCallsAvailable = native != null;
|
|
8
9
|
var apiOrigin = null;
|
|
9
|
-
async function configure(
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
async function configure(apiBaseUrlOrOptions, options) {
|
|
11
|
+
if (typeof apiBaseUrlOrOptions !== "string") {
|
|
12
|
+
await native?.configure("", apiBaseUrlOrOptions ?? null);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
apiOrigin = apiBaseUrlOrOptions.replace(/\/+$/, "");
|
|
16
|
+
await native?.configure(apiBaseUrlOrOptions, options ?? null);
|
|
17
|
+
}
|
|
18
|
+
var SERVER_ID = /^[A-Za-z0-9._:-]{1,64}$/;
|
|
19
|
+
async function addServer(server) {
|
|
20
|
+
if (!SERVER_ID.test(server.id))
|
|
21
|
+
throw new Error(`addServer: invalid id ${JSON.stringify(server.id)}.`);
|
|
22
|
+
if (!/^https?:\/\/[^\s]+$/.test(server.apiBaseUrl))
|
|
23
|
+
throw new Error("addServer: apiBaseUrl must be http(s).");
|
|
24
|
+
const entry = { id: server.id, apiBaseUrl: server.apiBaseUrl.replace(/\/+$/, "") };
|
|
25
|
+
if (server.tenantId) entry.tenantId = server.tenantId;
|
|
26
|
+
if (server.name) entry.name = server.name;
|
|
27
|
+
if (server.id === DEFAULT_SERVER_ID) apiOrigin = entry.apiBaseUrl;
|
|
28
|
+
await native?.addServer?.(entry);
|
|
29
|
+
}
|
|
30
|
+
async function removeServer(id) {
|
|
31
|
+
if (id === DEFAULT_SERVER_ID) apiOrigin = null;
|
|
32
|
+
await native?.removeServer?.(id);
|
|
33
|
+
}
|
|
34
|
+
function listServers() {
|
|
35
|
+
return native?.listServers?.() ?? [];
|
|
36
|
+
}
|
|
37
|
+
function serverOfNotification(data) {
|
|
38
|
+
const tenant = data && typeof data["tenant_id"] === "string" ? data["tenant_id"] : null;
|
|
39
|
+
if (native?.serverForTenant) return native.serverForTenant(tenant);
|
|
40
|
+
return apiOrigin ? DEFAULT_SERVER_ID : null;
|
|
41
|
+
}
|
|
42
|
+
function originOf(serverId) {
|
|
43
|
+
if (!serverId || serverId === DEFAULT_SERVER_ID) {
|
|
44
|
+
if (apiOrigin) return apiOrigin;
|
|
45
|
+
}
|
|
46
|
+
const id = serverId ?? DEFAULT_SERVER_ID;
|
|
47
|
+
const server = listServers().find((s) => s.id === id);
|
|
48
|
+
return server?.apiBaseUrl ?? null;
|
|
12
49
|
}
|
|
13
50
|
function getCallState() {
|
|
14
51
|
return native?.getCallState().snapshot ?? null;
|
|
@@ -19,39 +56,38 @@ function onCallState(cb) {
|
|
|
19
56
|
return () => sub.remove();
|
|
20
57
|
}
|
|
21
58
|
function place(conversationId, options) {
|
|
22
|
-
return native?.place(conversationId, options.media, options.sessionToken) ?? Promise.resolve();
|
|
59
|
+
return native?.place(conversationId, options.media, options.sessionToken, options.serverId ?? null) ?? Promise.resolve();
|
|
23
60
|
}
|
|
24
|
-
function join(callId, conversationId, sessionToken) {
|
|
25
|
-
return native?.join(callId, conversationId, sessionToken) ?? Promise.resolve();
|
|
61
|
+
function join(callId, conversationId, sessionToken, serverId) {
|
|
62
|
+
return native?.join(callId, conversationId, sessionToken, serverId ?? null) ?? Promise.resolve();
|
|
26
63
|
}
|
|
27
64
|
async function startRoom(conversationId, options) {
|
|
28
65
|
if (!native) throw new Error("The native call core is not in this build.");
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
);
|
|
66
|
+
const origin = originOf(options.serverId);
|
|
67
|
+
if (!origin) throw new Error("Call configure() (or addServer) before startRoom().");
|
|
68
|
+
const res = await fetch(`${origin}/v1/conversations/${encodeURIComponent(conversationId)}/room`, {
|
|
69
|
+
method: "POST",
|
|
70
|
+
headers: {
|
|
71
|
+
authorization: `Bearer ${options.sessionToken}`,
|
|
72
|
+
"content-type": "application/json"
|
|
73
|
+
},
|
|
74
|
+
body: JSON.stringify({ media: options.media })
|
|
75
|
+
});
|
|
41
76
|
const body = await res.json().catch(() => null);
|
|
42
77
|
const callId = body?.call?.id;
|
|
43
78
|
if (!res.ok || !callId) {
|
|
44
79
|
throw new Error(body?.error?.message ?? `Couldn't start the room (${res.status}).`);
|
|
45
80
|
}
|
|
46
|
-
await native.join(callId, conversationId, options.sessionToken);
|
|
81
|
+
await native.join(callId, conversationId, options.sessionToken, options.serverId ?? null);
|
|
47
82
|
return { callId, created: body?.created === true };
|
|
48
83
|
}
|
|
49
84
|
async function ringIntoCall(people) {
|
|
50
85
|
if (!native?.callControl) throw new Error("This build cannot ring people into a call.");
|
|
51
|
-
if (!apiOrigin) throw new Error("Call configure() before ringIntoCall().");
|
|
52
86
|
const control = await native.callControl();
|
|
53
87
|
if (!control) throw new Error("There is no call in progress.");
|
|
54
|
-
const
|
|
88
|
+
const origin = control.apiBaseUrl || originOf(control.serverId);
|
|
89
|
+
if (!origin) throw new Error("Call configure() before ringIntoCall().");
|
|
90
|
+
const res = await fetch(`${origin}/v1/calls/${encodeURIComponent(control.callId)}/ring`, {
|
|
55
91
|
method: "POST",
|
|
56
92
|
headers: {
|
|
57
93
|
authorization: `Bearer ${control.controlToken}`,
|
|
@@ -101,13 +137,16 @@ function onCallAction(cb) {
|
|
|
101
137
|
return () => sub.remove();
|
|
102
138
|
}
|
|
103
139
|
var activeConversation = null;
|
|
104
|
-
|
|
140
|
+
var activeServer = null;
|
|
141
|
+
function setActiveConversation(conversationId, serverId) {
|
|
105
142
|
activeConversation = conversationId;
|
|
106
|
-
|
|
143
|
+
activeServer = conversationId ? serverId ?? null : null;
|
|
144
|
+
native?.setActiveConversation?.(conversationId, activeServer);
|
|
107
145
|
}
|
|
108
146
|
function shouldPresentMessage(data) {
|
|
109
147
|
if (!data || data["type"] !== "message") return true;
|
|
110
|
-
|
|
148
|
+
if (data["conversation_id"] !== activeConversation) return true;
|
|
149
|
+
return activeServer != null && serverOfNotification(data) !== activeServer;
|
|
111
150
|
}
|
|
112
151
|
function conversationOfNotification(data) {
|
|
113
152
|
if (!data) return null;
|
|
@@ -188,6 +227,6 @@ function CallVideoView(props) {
|
|
|
188
227
|
return createElement(Native, props);
|
|
189
228
|
}
|
|
190
229
|
|
|
191
|
-
export { CallVideoView, answer, answerWaiting, canUseFullScreenIntent, configure, conversationOfNotification, decline, declineWaiting, getCallState, getVoipToken, hangUp, isInPictureInPicture, join, nativeCallsAvailable, onCallAction, onCallFinished, onCallState, onNotificationAction, onNotificationReply, onPictureInPicture, onRingEnded, onVoipToken, openFullScreenIntentSettings, pictureInPictureSupported, place, ringIntoCall, screenShareSupported, setActiveConversation, setAudioOutput, setCamera, setMuted, setPictureInPictureEnabled, setShowOnLockscreen, setSpeaker, shouldPresentMessage, startRoom, startScreenShare, stopScreenShare, switchCamera, takeCallAction, takeNotificationActions };
|
|
230
|
+
export { CallVideoView, DEFAULT_SERVER_ID, 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 };
|
|
192
231
|
//# sourceMappingURL=index.js.map
|
|
193
232
|
//# sourceMappingURL=index.js.map
|