@talkjs/core 1.4.2 → 1.5.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 +7 -0
- package/dist/talkSession.cjs +1 -1
- package/dist/talkSession.d.ts +162 -13
- package/dist/talkSession.js +352 -295
- package/package.json +1 -1
package/dist/talkSession.d.ts
CHANGED
|
@@ -342,6 +342,7 @@ export declare interface ConversationRef {
|
|
|
342
342
|
*
|
|
343
343
|
* @param user - Specifies which participant in the conversation you want to reference. Either the user's ID, or a reference to that user.
|
|
344
344
|
* @returns A {@linkcode ParticipantRef} for that user's participation in this conversation
|
|
345
|
+
* @throws If the user is not a UserRef or a non-empty string
|
|
345
346
|
* @public
|
|
346
347
|
*/
|
|
347
348
|
participant(user: string | UserRef): ParticipantRef;
|
|
@@ -352,8 +353,9 @@ export declare interface ConversationRef {
|
|
|
352
353
|
* Use this if you need to fetch, delete, or edit a specific message in this conversation, and you know its message ID.
|
|
353
354
|
* To fetch the most recent messages in this conversation, use {@link ConversationRef.subscribeMessages} instead.
|
|
354
355
|
*
|
|
355
|
-
* @param id - The ID of the
|
|
356
|
-
* @returns A {@linkcode
|
|
356
|
+
* @param id - The ID of the message that you want to reference
|
|
357
|
+
* @returns A {@linkcode MessageRef} for the message with that ID in this conversation
|
|
358
|
+
* @throws If the id is not a string or is an empty string
|
|
357
359
|
* @public
|
|
358
360
|
*/
|
|
359
361
|
message(id: string): MessageRef;
|
|
@@ -701,8 +703,7 @@ export declare interface CreateConversationParams {
|
|
|
701
703
|
*/
|
|
702
704
|
welcomeMessages?: string[];
|
|
703
705
|
/**
|
|
704
|
-
* Custom metadata
|
|
705
|
-
* This value acts as a patch. Remove specific properties by setting them to `null`.
|
|
706
|
+
* Custom metadata to set on the conversation.
|
|
706
707
|
* Default = no custom metadata
|
|
707
708
|
*/
|
|
708
709
|
custom?: Record<string, string>;
|
|
@@ -812,7 +813,7 @@ export declare interface CreateUserParams {
|
|
|
812
813
|
export declare interface CustomEmojiNode {
|
|
813
814
|
type: "customEmoji";
|
|
814
815
|
/**
|
|
815
|
-
* The name of the custom emoji to show.
|
|
816
|
+
* The name (including colons at the start and end) of the custom emoji to show.
|
|
816
817
|
*/
|
|
817
818
|
text: string;
|
|
818
819
|
}
|
|
@@ -831,7 +832,7 @@ export declare interface CustomEmojiNode {
|
|
|
831
832
|
*/
|
|
832
833
|
export declare interface EditMessageParams {
|
|
833
834
|
/**
|
|
834
|
-
* Custom metadata
|
|
835
|
+
* Custom metadata to set on the message.
|
|
835
836
|
* This value acts as a patch. Remove specific properties by setting them to `null`.
|
|
836
837
|
* Default = no custom metadata
|
|
837
838
|
*/
|
|
@@ -860,7 +861,7 @@ export declare interface EditMessageParams {
|
|
|
860
861
|
*/
|
|
861
862
|
export declare interface EditTextMessageParams {
|
|
862
863
|
/**
|
|
863
|
-
* Custom metadata
|
|
864
|
+
* Custom metadata to set on the message.
|
|
864
865
|
* This value acts as a patch. Remove specific properties by setting them to `null`.
|
|
865
866
|
* Default = no custom metadata
|
|
866
867
|
*/
|
|
@@ -1206,7 +1207,7 @@ export declare interface MentionNode {
|
|
|
1206
1207
|
export declare interface MessageActiveState {
|
|
1207
1208
|
type: "active";
|
|
1208
1209
|
/**
|
|
1209
|
-
* The most recently received snapshot for the
|
|
1210
|
+
* The most recently received snapshot for the messages, or `null` if you're not a participant in the conversation.
|
|
1210
1211
|
*/
|
|
1211
1212
|
latestSnapshot: MessageSnapshot[] | null;
|
|
1212
1213
|
/**
|
|
@@ -1240,6 +1241,31 @@ export declare interface MessageRef {
|
|
|
1240
1241
|
* Immutable: if you want to reference a message from a different conversation, get a new MessageRef from that conversation.
|
|
1241
1242
|
*/
|
|
1242
1243
|
readonly conversationId: string;
|
|
1244
|
+
/**
|
|
1245
|
+
* Get a reference to a specific emoji reaction on this message
|
|
1246
|
+
*
|
|
1247
|
+
* @remarks
|
|
1248
|
+
* If you call `.reaction` with an invalid emoji, it will still succeed and you will still get a `ReactionRef`.
|
|
1249
|
+
* However, the TalkJS server will reject any calls that use an invalid emoji.
|
|
1250
|
+
*
|
|
1251
|
+
* In the future, this will also be used to fetch a full list of people who used that specific reaction on the message.
|
|
1252
|
+
*
|
|
1253
|
+
* @example Reacting to the message with a Unicode emoji
|
|
1254
|
+
* ```ts
|
|
1255
|
+
* MessageRef.reaction("🚀").add()
|
|
1256
|
+
* ```
|
|
1257
|
+
*
|
|
1258
|
+
* @example Removing your custom emoji reaction from the message
|
|
1259
|
+
* ```ts
|
|
1260
|
+
* MessageRef.reaction(":cat-roomba:").remove()
|
|
1261
|
+
* ```
|
|
1262
|
+
*
|
|
1263
|
+
* @param emoji - The emoji for the reaction you want to reference. a single Unicode emoji like "🚀" or a custom emoji like ":cat_roomba:". Custom emoji can be up to 50 characters long.
|
|
1264
|
+
* @returns A {@linkcode ReactionRef} for the reaction with that emoji on this message
|
|
1265
|
+
* @throws If the emoji is not a string or is an empty string
|
|
1266
|
+
* @public
|
|
1267
|
+
*/
|
|
1268
|
+
reaction(emoji: string): ReactionRef;
|
|
1243
1269
|
/**
|
|
1244
1270
|
* Fetches a snapshot of the message.
|
|
1245
1271
|
*
|
|
@@ -1256,7 +1282,7 @@ export declare interface MessageRef {
|
|
|
1256
1282
|
*/
|
|
1257
1283
|
edit(params: string | EditTextMessageParams | EditMessageParams): Promise<void>;
|
|
1258
1284
|
/**
|
|
1259
|
-
* Deletes this message, or does nothing if
|
|
1285
|
+
* Deletes this message, or does nothing if the message does not exist.
|
|
1260
1286
|
*
|
|
1261
1287
|
* @remarks
|
|
1262
1288
|
* Deleting a nonexistent message is treated as success, and the promise will resolve.
|
|
@@ -1337,6 +1363,13 @@ export declare interface MessageSnapshot {
|
|
|
1337
1363
|
* The main body of the message, as a list of blocks that are rendered top-to-bottom.
|
|
1338
1364
|
*/
|
|
1339
1365
|
content: ContentBlock[];
|
|
1366
|
+
/**
|
|
1367
|
+
* All the emoji reactions that have been added to this message.
|
|
1368
|
+
*
|
|
1369
|
+
* @remarks
|
|
1370
|
+
* There can be up to 50 different reactions on each message.
|
|
1371
|
+
*/
|
|
1372
|
+
reactions: ReactionSnapshot[];
|
|
1340
1373
|
}
|
|
1341
1374
|
|
|
1342
1375
|
/**
|
|
@@ -1607,6 +1640,116 @@ export declare interface PendingState {
|
|
|
1607
1640
|
type: "pending";
|
|
1608
1641
|
}
|
|
1609
1642
|
|
|
1643
|
+
/**
|
|
1644
|
+
* References a specific emoji reaction on a message.
|
|
1645
|
+
*
|
|
1646
|
+
* @remarks
|
|
1647
|
+
* Used in all Data API operations affecting that emoji reaction, such as adding or removing the reaction.
|
|
1648
|
+
* Created via {@link MessageRef.reaction}.
|
|
1649
|
+
*
|
|
1650
|
+
* @public
|
|
1651
|
+
*/
|
|
1652
|
+
export declare interface ReactionRef {
|
|
1653
|
+
/**
|
|
1654
|
+
* Which emoji the reaction is using.
|
|
1655
|
+
*
|
|
1656
|
+
* @remarks
|
|
1657
|
+
* Either a single Unicode emoji, or the name of a custom emoji with a colon at the start and end.
|
|
1658
|
+
* This is not validated until you send a request to the server.
|
|
1659
|
+
* Since custom emoji are configured in the frontend, there are no checks to make sure a custom emoji actually exists.
|
|
1660
|
+
*
|
|
1661
|
+
* Immutable: if you want to use a different emoji, get a new ReactionRef instead.
|
|
1662
|
+
*
|
|
1663
|
+
* @example Unicode emoji
|
|
1664
|
+
* "👍"
|
|
1665
|
+
*
|
|
1666
|
+
* @example Custom emoji
|
|
1667
|
+
* ":cat-roomba:"
|
|
1668
|
+
*/
|
|
1669
|
+
readonly emoji: string;
|
|
1670
|
+
/**
|
|
1671
|
+
* The ID of the message that this is a reaction to.
|
|
1672
|
+
*
|
|
1673
|
+
* @remarks
|
|
1674
|
+
* Immutable: if you want to react to a different message, get a new ReactionRef instead.
|
|
1675
|
+
*/
|
|
1676
|
+
readonly messageId: string;
|
|
1677
|
+
/**
|
|
1678
|
+
* The ID of the conversation the message belongs to.
|
|
1679
|
+
*
|
|
1680
|
+
* @remarks
|
|
1681
|
+
* Immutable: if you want to reference a message from a different conversation, get a new MessageRef from that conversation and call `.reaction` on that MessageRef.
|
|
1682
|
+
*/
|
|
1683
|
+
readonly conversationId: string;
|
|
1684
|
+
/**
|
|
1685
|
+
* Adds this emoji reaction onto the message, from the current user.
|
|
1686
|
+
*
|
|
1687
|
+
* @returns A promise that resolves when the operation completes. The promise will reject if the request is invalid, the message doesn't exist, there are already 50 different reactions on this message, or if you do not have permission to use emoji reactions on that message.
|
|
1688
|
+
*/
|
|
1689
|
+
add(): Promise<void>;
|
|
1690
|
+
/**
|
|
1691
|
+
* Removes this emoji reaction from the message, from the current user.
|
|
1692
|
+
*
|
|
1693
|
+
* @returns A promise that resolves when the operation completes. The promise will reject if the request is invalid, the message doesn't exist, or you do not have permission to use emoji reactions on that message.
|
|
1694
|
+
*/
|
|
1695
|
+
remove(): Promise<void>;
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
/**
|
|
1699
|
+
* A summary of a single emoji reaction on a message.
|
|
1700
|
+
*
|
|
1701
|
+
* @public
|
|
1702
|
+
*/
|
|
1703
|
+
export declare interface ReactionSnapshot {
|
|
1704
|
+
/**
|
|
1705
|
+
* Which emoji the users reacted with.
|
|
1706
|
+
*
|
|
1707
|
+
* @remarks
|
|
1708
|
+
* Either a single Unicode emoji, or the name of a custom emoji with a colon at the start and end.
|
|
1709
|
+
* Since custom emoji are defined in the frontend, they are not validated by the TalkJS server.
|
|
1710
|
+
* The UI should ignore reactions that use unrecognised custom emoji.
|
|
1711
|
+
*
|
|
1712
|
+
* NOTE: In unicode, it is possible to have multiple emoji that look identical but are represented differently.
|
|
1713
|
+
* For example, `"👍" !== "👍️"` because the second emoji includes a {@link https://en.wikipedia.org/wiki/Variation_Selectors_(Unicode_block) | variation selector 16 codepoint}.
|
|
1714
|
+
* This codepoint forces the character to appear as an emoji.
|
|
1715
|
+
*
|
|
1716
|
+
* TalkJS normalises all emoji reactions to be "fully qualified" {@link https://unicode.org/Public/emoji/16.0/emoji-test.txt | according to this list}.
|
|
1717
|
+
* This prevents a message having multiple separate 👍 reactions.
|
|
1718
|
+
*
|
|
1719
|
+
* Be careful when processing the `emoji` property, as this normalisation might break equality checks:
|
|
1720
|
+
*
|
|
1721
|
+
* ```ts
|
|
1722
|
+
* // Emoji has unnecessary variation selector 16
|
|
1723
|
+
* const sent = "👍"
|
|
1724
|
+
*
|
|
1725
|
+
* // React with thumbs up,
|
|
1726
|
+
* await message.reaction(emoji).add()
|
|
1727
|
+
*
|
|
1728
|
+
* // Fetch the reaction
|
|
1729
|
+
* const snapshot = await message.get();
|
|
1730
|
+
* const received = snapshot.reactions[0].emoji;
|
|
1731
|
+
*
|
|
1732
|
+
* // Fails because TalkJS removed the variation selector
|
|
1733
|
+
* assert sent === received;
|
|
1734
|
+
* ```
|
|
1735
|
+
*
|
|
1736
|
+
* @example Unicode emoji
|
|
1737
|
+
* "👍"
|
|
1738
|
+
*
|
|
1739
|
+
* @example Custom emoji
|
|
1740
|
+
* ":cat-roomba:"
|
|
1741
|
+
*/
|
|
1742
|
+
emoji: string;
|
|
1743
|
+
/**
|
|
1744
|
+
* The number of times this emoji has been added to the message.
|
|
1745
|
+
*/
|
|
1746
|
+
count: number;
|
|
1747
|
+
/**
|
|
1748
|
+
* Whether the current user has reacted to the message with this emoji.
|
|
1749
|
+
*/
|
|
1750
|
+
currentUserReacted: boolean;
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1610
1753
|
/**
|
|
1611
1754
|
* A snapshot of a message's attributes at a given moment in time, used in {@link MessageSnapshot.referencedMessage}.
|
|
1612
1755
|
*
|
|
@@ -1679,6 +1822,10 @@ export declare interface ReferencedMessageSnapshot {
|
|
|
1679
1822
|
* The main body of the message, as a list of blocks that are rendered top-to-bottom.
|
|
1680
1823
|
*/
|
|
1681
1824
|
content: ContentBlock[];
|
|
1825
|
+
/**
|
|
1826
|
+
* All the emoji reactions that have been added to this message.
|
|
1827
|
+
*/
|
|
1828
|
+
reactions: ReactionSnapshot[];
|
|
1682
1829
|
}
|
|
1683
1830
|
|
|
1684
1831
|
export declare function registerPolyfills({ WebSocket }: {
|
|
@@ -1747,7 +1894,7 @@ export declare interface SendFileBlock {
|
|
|
1747
1894
|
*/
|
|
1748
1895
|
export declare interface SendMessageParams {
|
|
1749
1896
|
/**
|
|
1750
|
-
* Custom metadata
|
|
1897
|
+
* Custom metadata to set on the message.
|
|
1751
1898
|
* Default = no custom metadata
|
|
1752
1899
|
*/
|
|
1753
1900
|
custom?: Record<string, string>;
|
|
@@ -1779,7 +1926,7 @@ export declare interface SendMessageParams {
|
|
|
1779
1926
|
*/
|
|
1780
1927
|
export declare interface SendTextMessageParams {
|
|
1781
1928
|
/**
|
|
1782
|
-
* Custom metadata
|
|
1929
|
+
* Custom metadata to set on the message.
|
|
1783
1930
|
* Default = no custom metadata
|
|
1784
1931
|
*/
|
|
1785
1932
|
custom?: Record<string, string>;
|
|
@@ -1858,7 +2005,7 @@ export declare interface SetParticipantParams {
|
|
|
1858
2005
|
access?: "ReadWrite" | "Read" | null;
|
|
1859
2006
|
/**
|
|
1860
2007
|
* When the participant should be notified about new messages in this conversation.
|
|
1861
|
-
* Default =
|
|
2008
|
+
* Default = true.
|
|
1862
2009
|
*
|
|
1863
2010
|
* @remarks
|
|
1864
2011
|
* `false` means no notifications, `true` means notifications for all messages, and `"MentionsOnly"` means that the user will only be notified when they are mentioned with an `@`.
|
|
@@ -1990,6 +2137,7 @@ export declare interface TalkSession {
|
|
|
1990
2137
|
*
|
|
1991
2138
|
* @param id - The ID of the user that you want to reference
|
|
1992
2139
|
* @returns A {@linkcode UserRef} for the user with that ID
|
|
2140
|
+
* @throws If the id is not a string or is an empty string
|
|
1993
2141
|
* @public
|
|
1994
2142
|
*/
|
|
1995
2143
|
user(id: string): UserRef;
|
|
@@ -2022,6 +2170,7 @@ export declare interface TalkSession {
|
|
|
2022
2170
|
*
|
|
2023
2171
|
* @param id - The ID of the conversation that you want to reference
|
|
2024
2172
|
* @returns A {@linkcode ConversationRef} for the conversation with that ID
|
|
2173
|
+
* @throws If the id is not a string or is an empty string
|
|
2025
2174
|
* @public
|
|
2026
2175
|
*/
|
|
2027
2176
|
conversation(id: string): ConversationRef;
|
|
@@ -2251,7 +2400,7 @@ export declare type TypingSnapshot = FewTypingSnapshot | ManyTypingSnapshot;
|
|
|
2251
2400
|
* Get a TypingSubscription by calling {@link ConversationRef.subscribeTyping}.
|
|
2252
2401
|
*
|
|
2253
2402
|
* When there are "many" people typing (meaning you received {@link ManyTypingSnapshot}), the next update you receive will be {@link FewTypingSnapshot} once enough people stop typing.
|
|
2254
|
-
* Until then, your {@link ManyTypingSnapshot} is still valid and
|
|
2403
|
+
* Until then, your {@link ManyTypingSnapshot} is still valid and does not need to changed, so `onSnapshot` will not be called.
|
|
2255
2404
|
*
|
|
2256
2405
|
* @public
|
|
2257
2406
|
*/
|