@talkjs/core 0.0.1 → 0.0.3
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 +2 -2
- package/dist/talkSession.d.ts +14 -10
- package/dist/talkSession.js +3199 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ yarn add @talkjs/core
|
|
|
23
23
|
Import it into the component where you want to use it:
|
|
24
24
|
|
|
25
25
|
```js
|
|
26
|
-
import {
|
|
26
|
+
import { getTalkSession } from "@talkjs/core";
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
Then add the following code to create the session, users and conversation:
|
|
@@ -33,7 +33,7 @@ Then add the following code to create the session, users and conversation:
|
|
|
33
33
|
const appId = "<APP_ID>";
|
|
34
34
|
const userId = "alice";
|
|
35
35
|
|
|
36
|
-
const session =
|
|
36
|
+
const session = getTalkSession({ appId, userId });
|
|
37
37
|
session.currentUser.createIfNotExists({ name: "Alice" });
|
|
38
38
|
|
|
39
39
|
const conversation = session.conversation("my_conversation");
|
package/dist/talkSession.d.ts
CHANGED
|
@@ -841,6 +841,17 @@ declare interface GenericFileMetadata {
|
|
|
841
841
|
filename: string;
|
|
842
842
|
}
|
|
843
843
|
|
|
844
|
+
/**
|
|
845
|
+
* Returns a TalkSession option for the specified App ID and User ID.
|
|
846
|
+
*
|
|
847
|
+
* @remarks
|
|
848
|
+
* Backed by a registry, so calling this function twice with the same app and user returns the same session object both times.
|
|
849
|
+
* A new session will be created if the old one encountered an error or got garbage collected.
|
|
850
|
+
*
|
|
851
|
+
* The `token` and `tokenFetcher` properties are ignored if there is already a session for that user in the registry.
|
|
852
|
+
*/
|
|
853
|
+
export declare function getTalkSession(options: TalkSessionOptions): TalkSession;
|
|
854
|
+
|
|
844
855
|
/**
|
|
845
856
|
* A FileBlock variant for an image attachment, with additional image-specific metadata.
|
|
846
857
|
*
|
|
@@ -1715,9 +1726,9 @@ export declare interface SetUserParams {
|
|
|
1715
1726
|
pushTokens?: Record<string, true | null> | null;
|
|
1716
1727
|
}
|
|
1717
1728
|
|
|
1718
|
-
export declare
|
|
1729
|
+
export declare interface TalkSession {
|
|
1719
1730
|
readonly currentUser: UserRef;
|
|
1720
|
-
|
|
1731
|
+
onError(handler: (error: Error) => void): () => void;
|
|
1721
1732
|
/**
|
|
1722
1733
|
* Get a reference to a user
|
|
1723
1734
|
*
|
|
@@ -1734,12 +1745,6 @@ export declare class TalkSession {
|
|
|
1734
1745
|
* @public
|
|
1735
1746
|
*/
|
|
1736
1747
|
conversation(id: string): ConversationRef;
|
|
1737
|
-
/**
|
|
1738
|
-
* Disconnects the websocket
|
|
1739
|
-
*
|
|
1740
|
-
* @public
|
|
1741
|
-
*/
|
|
1742
|
-
destroy(): void;
|
|
1743
1748
|
/**
|
|
1744
1749
|
* Upload a generic file without any additional metadata.
|
|
1745
1750
|
*
|
|
@@ -1802,12 +1807,11 @@ export declare class TalkSession {
|
|
|
1802
1807
|
uploadVoice(data: Blob, metadata: VoiceRecordingFileMetadata): Promise<FileToken>;
|
|
1803
1808
|
}
|
|
1804
1809
|
|
|
1805
|
-
declare interface TalkSessionOptions {
|
|
1810
|
+
export declare interface TalkSessionOptions {
|
|
1806
1811
|
appId: string;
|
|
1807
1812
|
userId: string;
|
|
1808
1813
|
token?: string;
|
|
1809
1814
|
tokenFetcher?: () => string | Promise<string>;
|
|
1810
|
-
onError?: (error: Error) => void;
|
|
1811
1815
|
}
|
|
1812
1816
|
|
|
1813
1817
|
/**
|