@poolse/sdk 2.7.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +49 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -2
- package/dist/index.d.ts +34 -2
- package/dist/index.js +49 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -560,6 +560,13 @@ interface CallBusy {
|
|
|
560
560
|
/** Who is busy. */
|
|
561
561
|
userId: string;
|
|
562
562
|
}
|
|
563
|
+
/** The other side ended a call that was already connected. */
|
|
564
|
+
interface CallEnded {
|
|
565
|
+
callId: string;
|
|
566
|
+
conversationId: string;
|
|
567
|
+
/** Who hung up. */
|
|
568
|
+
userId: string;
|
|
569
|
+
}
|
|
563
570
|
/** The caller hung up before anyone answered. */
|
|
564
571
|
interface CallCancelled {
|
|
565
572
|
callId: string;
|
|
@@ -605,6 +612,7 @@ declare class CallsResource {
|
|
|
605
612
|
private readonly declined;
|
|
606
613
|
private readonly busy;
|
|
607
614
|
private readonly cancelled;
|
|
615
|
+
private readonly ended;
|
|
608
616
|
private bound;
|
|
609
617
|
constructor(getChannel: () => Channel);
|
|
610
618
|
/**
|
|
@@ -628,6 +636,18 @@ declare class CallsResource {
|
|
|
628
636
|
* does it for you.
|
|
629
637
|
*/
|
|
630
638
|
markBusy(call: IncomingCall): Promise<void>;
|
|
639
|
+
/**
|
|
640
|
+
* End a call that is already connected.
|
|
641
|
+
*
|
|
642
|
+
* Distinct from {@link cancel}, which withdraws an unanswered invite.
|
|
643
|
+
* Without this a connected call has no end signal, so hanging up
|
|
644
|
+
* leaves the other side sitting in the room with a call screen it has
|
|
645
|
+
* no reason to close.
|
|
646
|
+
*/
|
|
647
|
+
hangUp(call: {
|
|
648
|
+
callId: string;
|
|
649
|
+
conversationId: string;
|
|
650
|
+
}): Promise<void>;
|
|
631
651
|
/** Withdraw an invite you placed — hung up before anyone answered. */
|
|
632
652
|
cancel(call: OutgoingCall): Promise<void>;
|
|
633
653
|
/** Somebody is ringing you. */
|
|
@@ -638,6 +658,8 @@ declare class CallsResource {
|
|
|
638
658
|
onDeclined(fn: (call: CallDeclined) => void): Unsubscribe$2;
|
|
639
659
|
/** The person you called is already on another call. */
|
|
640
660
|
onBusy(fn: (call: CallBusy) => void): Unsubscribe$2;
|
|
661
|
+
/** The other side ended a connected call. */
|
|
662
|
+
onEnded(fn: (call: CallEnded) => void): Unsubscribe$2;
|
|
641
663
|
/** An inbound ring was withdrawn before you answered. */
|
|
642
664
|
onCancelled(fn: (call: CallCancelled) => void): Unsubscribe$2;
|
|
643
665
|
/**
|
|
@@ -684,6 +706,16 @@ declare class VoiceRoom {
|
|
|
684
706
|
/** Candidates that landed before their offer/answer did. */
|
|
685
707
|
private readonly pendingIce;
|
|
686
708
|
private readonly roster;
|
|
709
|
+
/**
|
|
710
|
+
* How many callers currently hold this room open.
|
|
711
|
+
*
|
|
712
|
+
* `PoolseRealtime` hands out ONE room per conversation, so a call
|
|
713
|
+
* screen and an always-on voice bar for the same conversation share
|
|
714
|
+
* this instance — which is correct, since a user is in one audio
|
|
715
|
+
* session, not two. Without counting, whichever of them tore down
|
|
716
|
+
* first would cut the audio out from under the other.
|
|
717
|
+
*/
|
|
718
|
+
private holders;
|
|
687
719
|
private speakingTimer;
|
|
688
720
|
private stopSpeakingDetection;
|
|
689
721
|
private readonly statusListeners;
|
|
@@ -1462,8 +1494,8 @@ declare class AuthError extends ApiError {
|
|
|
1462
1494
|
declare function isWebRtcAvailable(): boolean;
|
|
1463
1495
|
declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
|
|
1464
1496
|
|
|
1465
|
-
declare const version = "2.
|
|
1497
|
+
declare const version = "2.8.1";
|
|
1466
1498
|
|
|
1467
1499
|
declare function safeUuid(): string;
|
|
1468
1500
|
|
|
1469
|
-
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallDeclined, CallsResource, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IncomingCall, type IsoDateTime, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
|
1501
|
+
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallDeclined, type CallEnded, CallsResource, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IncomingCall, type IsoDateTime, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -560,6 +560,13 @@ interface CallBusy {
|
|
|
560
560
|
/** Who is busy. */
|
|
561
561
|
userId: string;
|
|
562
562
|
}
|
|
563
|
+
/** The other side ended a call that was already connected. */
|
|
564
|
+
interface CallEnded {
|
|
565
|
+
callId: string;
|
|
566
|
+
conversationId: string;
|
|
567
|
+
/** Who hung up. */
|
|
568
|
+
userId: string;
|
|
569
|
+
}
|
|
563
570
|
/** The caller hung up before anyone answered. */
|
|
564
571
|
interface CallCancelled {
|
|
565
572
|
callId: string;
|
|
@@ -605,6 +612,7 @@ declare class CallsResource {
|
|
|
605
612
|
private readonly declined;
|
|
606
613
|
private readonly busy;
|
|
607
614
|
private readonly cancelled;
|
|
615
|
+
private readonly ended;
|
|
608
616
|
private bound;
|
|
609
617
|
constructor(getChannel: () => Channel);
|
|
610
618
|
/**
|
|
@@ -628,6 +636,18 @@ declare class CallsResource {
|
|
|
628
636
|
* does it for you.
|
|
629
637
|
*/
|
|
630
638
|
markBusy(call: IncomingCall): Promise<void>;
|
|
639
|
+
/**
|
|
640
|
+
* End a call that is already connected.
|
|
641
|
+
*
|
|
642
|
+
* Distinct from {@link cancel}, which withdraws an unanswered invite.
|
|
643
|
+
* Without this a connected call has no end signal, so hanging up
|
|
644
|
+
* leaves the other side sitting in the room with a call screen it has
|
|
645
|
+
* no reason to close.
|
|
646
|
+
*/
|
|
647
|
+
hangUp(call: {
|
|
648
|
+
callId: string;
|
|
649
|
+
conversationId: string;
|
|
650
|
+
}): Promise<void>;
|
|
631
651
|
/** Withdraw an invite you placed — hung up before anyone answered. */
|
|
632
652
|
cancel(call: OutgoingCall): Promise<void>;
|
|
633
653
|
/** Somebody is ringing you. */
|
|
@@ -638,6 +658,8 @@ declare class CallsResource {
|
|
|
638
658
|
onDeclined(fn: (call: CallDeclined) => void): Unsubscribe$2;
|
|
639
659
|
/** The person you called is already on another call. */
|
|
640
660
|
onBusy(fn: (call: CallBusy) => void): Unsubscribe$2;
|
|
661
|
+
/** The other side ended a connected call. */
|
|
662
|
+
onEnded(fn: (call: CallEnded) => void): Unsubscribe$2;
|
|
641
663
|
/** An inbound ring was withdrawn before you answered. */
|
|
642
664
|
onCancelled(fn: (call: CallCancelled) => void): Unsubscribe$2;
|
|
643
665
|
/**
|
|
@@ -684,6 +706,16 @@ declare class VoiceRoom {
|
|
|
684
706
|
/** Candidates that landed before their offer/answer did. */
|
|
685
707
|
private readonly pendingIce;
|
|
686
708
|
private readonly roster;
|
|
709
|
+
/**
|
|
710
|
+
* How many callers currently hold this room open.
|
|
711
|
+
*
|
|
712
|
+
* `PoolseRealtime` hands out ONE room per conversation, so a call
|
|
713
|
+
* screen and an always-on voice bar for the same conversation share
|
|
714
|
+
* this instance — which is correct, since a user is in one audio
|
|
715
|
+
* session, not two. Without counting, whichever of them tore down
|
|
716
|
+
* first would cut the audio out from under the other.
|
|
717
|
+
*/
|
|
718
|
+
private holders;
|
|
687
719
|
private speakingTimer;
|
|
688
720
|
private stopSpeakingDetection;
|
|
689
721
|
private readonly statusListeners;
|
|
@@ -1462,8 +1494,8 @@ declare class AuthError extends ApiError {
|
|
|
1462
1494
|
declare function isWebRtcAvailable(): boolean;
|
|
1463
1495
|
declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
|
|
1464
1496
|
|
|
1465
|
-
declare const version = "2.
|
|
1497
|
+
declare const version = "2.8.1";
|
|
1466
1498
|
|
|
1467
1499
|
declare function safeUuid(): string;
|
|
1468
1500
|
|
|
1469
|
-
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallDeclined, CallsResource, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IncomingCall, type IsoDateTime, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
|
1501
|
+
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallDeclined, type CallEnded, CallsResource, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IncomingCall, type IsoDateTime, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
package/dist/index.js
CHANGED
|
@@ -112,6 +112,7 @@ var CallsResource = class {
|
|
|
112
112
|
declined = /* @__PURE__ */ new Set();
|
|
113
113
|
busy = /* @__PURE__ */ new Set();
|
|
114
114
|
cancelled = /* @__PURE__ */ new Set();
|
|
115
|
+
ended = /* @__PURE__ */ new Set();
|
|
115
116
|
bound = false;
|
|
116
117
|
constructor(getChannel) {
|
|
117
118
|
this.getChannel = getChannel;
|
|
@@ -164,6 +165,20 @@ var CallsResource = class {
|
|
|
164
165
|
caller_user_id: call.callerUserId
|
|
165
166
|
});
|
|
166
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* End a call that is already connected.
|
|
170
|
+
*
|
|
171
|
+
* Distinct from {@link cancel}, which withdraws an unanswered invite.
|
|
172
|
+
* Without this a connected call has no end signal, so hanging up
|
|
173
|
+
* leaves the other side sitting in the room with a call screen it has
|
|
174
|
+
* no reason to close.
|
|
175
|
+
*/
|
|
176
|
+
async hangUp(call) {
|
|
177
|
+
await this.request("call:hangup", {
|
|
178
|
+
call_id: call.callId,
|
|
179
|
+
conversation_id: call.conversationId
|
|
180
|
+
});
|
|
181
|
+
}
|
|
167
182
|
/** Withdraw an invite you placed — hung up before anyone answered. */
|
|
168
183
|
async cancel(call) {
|
|
169
184
|
await this.request("call:cancel", {
|
|
@@ -196,6 +211,12 @@ var CallsResource = class {
|
|
|
196
211
|
this.busy.add(fn);
|
|
197
212
|
return () => this.busy.delete(fn);
|
|
198
213
|
}
|
|
214
|
+
/** The other side ended a connected call. */
|
|
215
|
+
onEnded(fn) {
|
|
216
|
+
this.bind();
|
|
217
|
+
this.ended.add(fn);
|
|
218
|
+
return () => this.ended.delete(fn);
|
|
219
|
+
}
|
|
199
220
|
/** An inbound ring was withdrawn before you answered. */
|
|
200
221
|
onCancelled(fn) {
|
|
201
222
|
this.bind();
|
|
@@ -243,6 +264,14 @@ var CallsResource = class {
|
|
|
243
264
|
};
|
|
244
265
|
this.busy.forEach((l) => l(call));
|
|
245
266
|
});
|
|
267
|
+
channel.on("call:ended", (p) => {
|
|
268
|
+
const call = {
|
|
269
|
+
callId: p.call_id,
|
|
270
|
+
conversationId: p.conversation_id,
|
|
271
|
+
userId: p.user_id
|
|
272
|
+
};
|
|
273
|
+
this.ended.forEach((l) => l(call));
|
|
274
|
+
});
|
|
246
275
|
channel.on("call:cancelled", (p) => {
|
|
247
276
|
const call = {
|
|
248
277
|
callId: p.call_id,
|
|
@@ -316,6 +345,16 @@ var VoiceRoom = class {
|
|
|
316
345
|
/** Candidates that landed before their offer/answer did. */
|
|
317
346
|
pendingIce = /* @__PURE__ */ new Map();
|
|
318
347
|
roster = /* @__PURE__ */ new Map();
|
|
348
|
+
/**
|
|
349
|
+
* How many callers currently hold this room open.
|
|
350
|
+
*
|
|
351
|
+
* `PoolseRealtime` hands out ONE room per conversation, so a call
|
|
352
|
+
* screen and an always-on voice bar for the same conversation share
|
|
353
|
+
* this instance — which is correct, since a user is in one audio
|
|
354
|
+
* session, not two. Without counting, whichever of them tore down
|
|
355
|
+
* first would cut the audio out from under the other.
|
|
356
|
+
*/
|
|
357
|
+
holders = 0;
|
|
319
358
|
speakingTimer = null;
|
|
320
359
|
stopSpeakingDetection = null;
|
|
321
360
|
statusListeners = /* @__PURE__ */ new Set();
|
|
@@ -354,11 +393,16 @@ var VoiceRoom = class {
|
|
|
354
393
|
// ── lifecycle ──────────────────────────────────────────────────────
|
|
355
394
|
/** Acquire the mic, join the channel, and start negotiating. */
|
|
356
395
|
async join() {
|
|
357
|
-
if (this.channel)
|
|
396
|
+
if (this.channel) {
|
|
397
|
+
this.holders += 1;
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
this.holders += 1;
|
|
358
401
|
this.setStatus("connecting");
|
|
359
402
|
try {
|
|
360
403
|
this.localStream = await this.webrtc.getUserMedia();
|
|
361
404
|
} catch (err) {
|
|
405
|
+
this.holders = Math.max(0, this.holders - 1);
|
|
362
406
|
this.setStatus("error");
|
|
363
407
|
this.emitError(new Error(`microphone unavailable: ${String(err)}`));
|
|
364
408
|
throw err;
|
|
@@ -387,6 +431,8 @@ var VoiceRoom = class {
|
|
|
387
431
|
}
|
|
388
432
|
/** Announce departure, then drop every peer connection and the mic. */
|
|
389
433
|
leave() {
|
|
434
|
+
if (this.holders > 0) this.holders -= 1;
|
|
435
|
+
if (this.holders > 0) return;
|
|
390
436
|
this.channel?.push("voice:leave", {});
|
|
391
437
|
this.teardown();
|
|
392
438
|
this.setStatus("idle");
|
|
@@ -607,6 +653,7 @@ var VoiceRoom = class {
|
|
|
607
653
|
this.pendingIce.delete(peerId);
|
|
608
654
|
}
|
|
609
655
|
teardown() {
|
|
656
|
+
this.holders = 0;
|
|
610
657
|
for (const peerId of [...this.peers.keys()]) this.closePeer(peerId);
|
|
611
658
|
if (this.speakingTimer) clearInterval(this.speakingTimer);
|
|
612
659
|
this.speakingTimer = null;
|
|
@@ -1831,7 +1878,7 @@ var Poolse = class {
|
|
|
1831
1878
|
};
|
|
1832
1879
|
|
|
1833
1880
|
// src/version.ts
|
|
1834
|
-
var version = "2.
|
|
1881
|
+
var version = "2.8.1";
|
|
1835
1882
|
|
|
1836
1883
|
export { ApiError, AttachmentHandle, AttachmentsResource, AuthError, CallsResource, ConversationChannel, ConversationHandle, ConversationMessages, ConversationsResource, DevicesResource, MeResource, MessageHandle, MessagesResource, NetworkError, POOLSE_API_URL, Poolse, PoolseError, PoolseRealtime, RateLimitedError, UserChannel, UsersResource, VoiceRoom, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
|
1837
1884
|
//# sourceMappingURL=index.js.map
|