@talkjs/core 1.1.1 → 1.2.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/README.md +10 -5
- package/dist/talkSession.cjs +1 -1
- package/dist/talkSession.d.ts +99 -2
- package/dist/talkSession.js +545 -464
- package/package.json +1 -1
package/dist/talkSession.d.ts
CHANGED
|
@@ -381,6 +381,19 @@ export declare interface ConversationRef {
|
|
|
381
381
|
* The snapshot is null if you are not a participant in the conversation (including when the conversation doesn't exist)
|
|
382
382
|
*/
|
|
383
383
|
subscribeMessages(onSnapshot?: (snapshot: MessageSnapshot[] | null, loadedAll: boolean) => void): MessageSubscription;
|
|
384
|
+
/**
|
|
385
|
+
* Subscribes to the participants in the conversation.
|
|
386
|
+
*
|
|
387
|
+
* @remarks
|
|
388
|
+
* Initially, you will be subscribed to the 10 participants who joined most recently, and any new participants.
|
|
389
|
+
* Call `loadMore` to load additional older participants.
|
|
390
|
+
*
|
|
391
|
+
* Whenever `Subscription.state.type` is "active" and a participant is created, edited, deleted, or you load more participants, `onSnapshot` will fire and `Subscription.state.latestSnapshot` will be updated.
|
|
392
|
+
* `loadedAll` is true when the snapshot contains all the participants in the conversation.
|
|
393
|
+
*
|
|
394
|
+
* The snapshot is null if you are not a participant in the conversation (including when the conversation doesn't exist)
|
|
395
|
+
*/
|
|
396
|
+
subscribeParticipants(onSnapshot?: (snapshot: ParticipantSnapshot[] | null, loadedAll: boolean) => void): ParticipantSubscription;
|
|
384
397
|
/**
|
|
385
398
|
* Subscribes to the conversation.
|
|
386
399
|
*
|
|
@@ -1245,7 +1258,7 @@ export declare interface MessageSnapshot {
|
|
|
1245
1258
|
* Get a MessageSubscription by calling {@link ConversationRef.subscribeMessages}
|
|
1246
1259
|
*
|
|
1247
1260
|
* The subscription is 'windowed'. It includes all messages since a certain point in time.
|
|
1248
|
-
* By default, you subscribe to the 30 most recent messages, and any new messages are sent after you subscribe.
|
|
1261
|
+
* By default, you subscribe to the 30 most recent messages, and any new messages that are sent after you subscribe.
|
|
1249
1262
|
*
|
|
1250
1263
|
* You can expand this window by calling {@link MessageSubscription.loadMore}, which extends the window further into the past.
|
|
1251
1264
|
*
|
|
@@ -1291,7 +1304,7 @@ export declare interface MessageSubscription {
|
|
|
1291
1304
|
* @remarks
|
|
1292
1305
|
* Calling `loadMore` multiple times in parallel will still only load one page of messages.
|
|
1293
1306
|
*
|
|
1294
|
-
* @param count - The number of additional messages to load. Must be between 1 and 100
|
|
1307
|
+
* @param count - The number of additional messages to load. Must be between 1 and 100. Default 30.
|
|
1295
1308
|
* @returns A promise that resolves once the additional messages have loaded
|
|
1296
1309
|
*/
|
|
1297
1310
|
loadMore(count?: number): Promise<void>;
|
|
@@ -1304,6 +1317,24 @@ export declare interface MessageSubscription {
|
|
|
1304
1317
|
unsubscribe(): void;
|
|
1305
1318
|
}
|
|
1306
1319
|
|
|
1320
|
+
/**
|
|
1321
|
+
* The state of a participants subscription when it is actively listening for changes
|
|
1322
|
+
*
|
|
1323
|
+
* @public
|
|
1324
|
+
*/
|
|
1325
|
+
export declare interface ParticipantActiveState {
|
|
1326
|
+
type: "active";
|
|
1327
|
+
/**
|
|
1328
|
+
* The most recently received snapshot for the participants, or `null` if you are not a participant in that conversation.
|
|
1329
|
+
*/
|
|
1330
|
+
latestSnapshot: ParticipantSnapshot[] | null;
|
|
1331
|
+
/**
|
|
1332
|
+
* True if `latestSnapshot` contains all participants in the conversation.
|
|
1333
|
+
* Use {@link ParticipantSubscription.loadMore} to load more.
|
|
1334
|
+
*/
|
|
1335
|
+
loadedAll: boolean;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1307
1338
|
/**
|
|
1308
1339
|
* References a given user's participation in a conversation.
|
|
1309
1340
|
*
|
|
@@ -1413,6 +1444,72 @@ export declare interface ParticipantSnapshot {
|
|
|
1413
1444
|
joinedAt: number;
|
|
1414
1445
|
}
|
|
1415
1446
|
|
|
1447
|
+
/**
|
|
1448
|
+
* A subscription to the participants in a specific conversation.
|
|
1449
|
+
*
|
|
1450
|
+
* @remarks
|
|
1451
|
+
* Get a ParticipantSubscription by calling {@link ConversationRef.subscribeParticipants}
|
|
1452
|
+
*
|
|
1453
|
+
* The subscription is 'windowed'. It includes everyone who joined since a certain point in time.
|
|
1454
|
+
* By default, you subscribe to the 10 most recent participants, and any participants who joined after you subscribe.
|
|
1455
|
+
*
|
|
1456
|
+
* You can expand this window by calling {@link ParticipantSubscription.loadMore}, which extends the window further into the past.
|
|
1457
|
+
*
|
|
1458
|
+
* @public
|
|
1459
|
+
*/
|
|
1460
|
+
export declare interface ParticipantSubscription {
|
|
1461
|
+
/**
|
|
1462
|
+
* The current state of the subscription
|
|
1463
|
+
*
|
|
1464
|
+
* @remarks
|
|
1465
|
+
* An object with the following fields:
|
|
1466
|
+
*
|
|
1467
|
+
* `type` is one of "pending", "active", "unsubscribed", or "error".
|
|
1468
|
+
*
|
|
1469
|
+
* When `type` is "active", includes `latestSnapshot` and `loadedAll`.
|
|
1470
|
+
*
|
|
1471
|
+
* - `latestSnapshot: ParticipantSnapshot[] | null` the current state of the participants in the window, or null if you're not a participant in the conversation
|
|
1472
|
+
*
|
|
1473
|
+
* - `loadedAll: boolean` true when `latestSnapshot` contains all the participants in the conversation
|
|
1474
|
+
*
|
|
1475
|
+
* When `type` is "error", includes the `error` field. It is a JS `Error` object explaining what caused the subscription to be terminated.
|
|
1476
|
+
*/
|
|
1477
|
+
state: PendingState | ParticipantActiveState | UnsubscribedState | ErrorState;
|
|
1478
|
+
/**
|
|
1479
|
+
* Resolves when the subscription starts receiving updates from the server.
|
|
1480
|
+
*
|
|
1481
|
+
* @remarks
|
|
1482
|
+
* Wait for this promise if you want to perform some action as soon as the subscription is active.
|
|
1483
|
+
*
|
|
1484
|
+
* The promise rejects if the subscription is terminated before it connects.
|
|
1485
|
+
*/
|
|
1486
|
+
connected: Promise<ParticipantActiveState>;
|
|
1487
|
+
/**
|
|
1488
|
+
* Resolves when the subscription permanently stops receiving updates from the server.
|
|
1489
|
+
*
|
|
1490
|
+
* @remarks
|
|
1491
|
+
* This is either because you unsubscribed or because the subscription encountered an unrecoverable error.
|
|
1492
|
+
*/
|
|
1493
|
+
terminated: Promise<UnsubscribedState | ErrorState>;
|
|
1494
|
+
/**
|
|
1495
|
+
* Expand the window to include older participants
|
|
1496
|
+
*
|
|
1497
|
+
* @remarks
|
|
1498
|
+
* Calling `loadMore` multiple times in parallel will still only load one page of participants.
|
|
1499
|
+
*
|
|
1500
|
+
* @param count - The number of additional participants to load. Must be between 1 and 50. Default 10.
|
|
1501
|
+
* @returns A promise that resolves once the additional participants have loaded
|
|
1502
|
+
*/
|
|
1503
|
+
loadMore(count?: number): Promise<void>;
|
|
1504
|
+
/**
|
|
1505
|
+
* Unsubscribe from this resource and stop receiving updates.
|
|
1506
|
+
*
|
|
1507
|
+
* @remarks
|
|
1508
|
+
* If the subscription is already in the "unsubscribed" or "error" state, this is a no-op.
|
|
1509
|
+
*/
|
|
1510
|
+
unsubscribe(): void;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1416
1513
|
/**
|
|
1417
1514
|
* The state of a subscription before it has connected to the server
|
|
1418
1515
|
*
|