@towns-labs/react-sdk 2.0.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/README.md +69 -0
- package/dist/esm/TownsSyncProvider.jsx +39 -0
- package/dist/esm/TownsSyncProvider.jsx.map +1 -0
- package/dist/esm/connectTowns.js +45 -0
- package/dist/esm/connectTowns.js.map +1 -0
- package/dist/esm/index.js +35 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internals/TownsSyncContext.js +4 -0
- package/dist/esm/internals/TownsSyncContext.js.map +1 -0
- package/dist/esm/internals/useAction.js +58 -0
- package/dist/esm/internals/useAction.js.map +1 -0
- package/dist/esm/internals/useTownsSync.js +5 -0
- package/dist/esm/internals/useTownsSync.js.map +1 -0
- package/dist/esm/internals/utils.js +10 -0
- package/dist/esm/internals/utils.js.map +1 -0
- package/dist/esm/useAdminRedact.js +43 -0
- package/dist/esm/useAdminRedact.js.map +1 -0
- package/dist/esm/useAgentConnection.js +128 -0
- package/dist/esm/useAgentConnection.js.map +1 -0
- package/dist/esm/useChannel.js +18 -0
- package/dist/esm/useChannel.js.map +1 -0
- package/dist/esm/useCreateChannel.js +24 -0
- package/dist/esm/useCreateChannel.js.map +1 -0
- package/dist/esm/useCreateDm.js +22 -0
- package/dist/esm/useCreateDm.js.map +1 -0
- package/dist/esm/useCreateGdm.js +22 -0
- package/dist/esm/useCreateGdm.js.map +1 -0
- package/dist/esm/useCreateSpace.js +22 -0
- package/dist/esm/useCreateSpace.js.map +1 -0
- package/dist/esm/useDm.js +16 -0
- package/dist/esm/useDm.js.map +1 -0
- package/dist/esm/useGdm.js +16 -0
- package/dist/esm/useGdm.js.map +1 -0
- package/dist/esm/useJoinSpace.js +23 -0
- package/dist/esm/useJoinSpace.js.map +1 -0
- package/dist/esm/useMember.js +36 -0
- package/dist/esm/useMember.js.map +1 -0
- package/dist/esm/useMemberList.js +17 -0
- package/dist/esm/useMemberList.js.map +1 -0
- package/dist/esm/useMyMember.js +71 -0
- package/dist/esm/useMyMember.js.map +1 -0
- package/dist/esm/useObservable.js +56 -0
- package/dist/esm/useObservable.js.map +1 -0
- package/dist/esm/useReactions.js +17 -0
- package/dist/esm/useReactions.js.map +1 -0
- package/dist/esm/useRedact.js +43 -0
- package/dist/esm/useRedact.js.map +1 -0
- package/dist/esm/useScrollback.js +27 -0
- package/dist/esm/useScrollback.js.map +1 -0
- package/dist/esm/useSendMessage.js +31 -0
- package/dist/esm/useSendMessage.js.map +1 -0
- package/dist/esm/useSendReaction.js +33 -0
- package/dist/esm/useSendReaction.js.map +1 -0
- package/dist/esm/useSpace.js +28 -0
- package/dist/esm/useSpace.js.map +1 -0
- package/dist/esm/useSyncAgent.jsx +20 -0
- package/dist/esm/useSyncAgent.jsx.map +1 -0
- package/dist/esm/useThreads.js +19 -0
- package/dist/esm/useThreads.js.map +1 -0
- package/dist/esm/useTimeline.js +32 -0
- package/dist/esm/useTimeline.js.map +1 -0
- package/dist/esm/useTowns.js +16 -0
- package/dist/esm/useTowns.js.map +1 -0
- package/dist/esm/useTownsAuthStatus.js +30 -0
- package/dist/esm/useTownsAuthStatus.js.map +1 -0
- package/dist/esm/useUserDms.js +36 -0
- package/dist/esm/useUserDms.js.map +1 -0
- package/dist/esm/useUserGdms.js +27 -0
- package/dist/esm/useUserGdms.js.map +1 -0
- package/dist/esm/useUserSpaces.js +27 -0
- package/dist/esm/useUserSpaces.js.map +1 -0
- package/dist/esm/utils.js +17 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/types/TownsSyncProvider.d.ts +23 -0
- package/dist/types/TownsSyncProvider.d.ts.map +1 -0
- package/dist/types/connectTowns.d.ts +29 -0
- package/dist/types/connectTowns.d.ts.map +1 -0
- package/dist/types/index.d.ts +35 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/internals/TownsSyncContext.d.ts +11 -0
- package/dist/types/internals/TownsSyncContext.d.ts.map +1 -0
- package/dist/types/internals/useAction.d.ts +38 -0
- package/dist/types/internals/useAction.d.ts.map +1 -0
- package/dist/types/internals/useTownsSync.d.ts +8 -0
- package/dist/types/internals/useTownsSync.d.ts.map +1 -0
- package/dist/types/internals/utils.d.ts +3 -0
- package/dist/types/internals/utils.d.ts.map +1 -0
- package/dist/types/useAdminRedact.d.ts +42 -0
- package/dist/types/useAdminRedact.d.ts.map +1 -0
- package/dist/types/useAgentConnection.d.ts +83 -0
- package/dist/types/useAgentConnection.d.ts.map +1 -0
- package/dist/types/useChannel.d.ts +12 -0
- package/dist/types/useChannel.d.ts.map +1 -0
- package/dist/types/useCreateChannel.d.ts +23 -0
- package/dist/types/useCreateChannel.d.ts.map +1 -0
- package/dist/types/useCreateDm.d.ts +28 -0
- package/dist/types/useCreateDm.d.ts.map +1 -0
- package/dist/types/useCreateGdm.d.ts +31 -0
- package/dist/types/useCreateGdm.d.ts.map +1 -0
- package/dist/types/useCreateSpace.d.ts +29 -0
- package/dist/types/useCreateSpace.d.ts.map +1 -0
- package/dist/types/useDm.d.ts +11 -0
- package/dist/types/useDm.d.ts.map +1 -0
- package/dist/types/useGdm.d.ts +11 -0
- package/dist/types/useGdm.d.ts.map +1 -0
- package/dist/types/useJoinSpace.d.ts +24 -0
- package/dist/types/useJoinSpace.d.ts.map +1 -0
- package/dist/types/useMember.d.ts +30 -0
- package/dist/types/useMember.d.ts.map +1 -0
- package/dist/types/useMemberList.d.ts +11 -0
- package/dist/types/useMemberList.d.ts.map +1 -0
- package/dist/types/useMyMember.d.ts +83 -0
- package/dist/types/useMyMember.d.ts.map +1 -0
- package/dist/types/useObservable.d.ts +59 -0
- package/dist/types/useObservable.d.ts.map +1 -0
- package/dist/types/useReactions.d.ts +10 -0
- package/dist/types/useReactions.d.ts.map +1 -0
- package/dist/types/useRedact.d.ts +42 -0
- package/dist/types/useRedact.d.ts.map +1 -0
- package/dist/types/useScrollback.d.ts +27 -0
- package/dist/types/useScrollback.d.ts.map +1 -0
- package/dist/types/useSendMessage.d.ts +32 -0
- package/dist/types/useSendMessage.d.ts.map +1 -0
- package/dist/types/useSendReaction.d.ts +32 -0
- package/dist/types/useSendReaction.d.ts.map +1 -0
- package/dist/types/useSpace.d.ts +22 -0
- package/dist/types/useSpace.d.ts.map +1 -0
- package/dist/types/useSyncAgent.d.ts +12 -0
- package/dist/types/useSyncAgent.d.ts.map +1 -0
- package/dist/types/useThreads.d.ts +11 -0
- package/dist/types/useThreads.d.ts.map +1 -0
- package/dist/types/useTimeline.d.ts +24 -0
- package/dist/types/useTimeline.d.ts.map +1 -0
- package/dist/types/useTowns.d.ts +14 -0
- package/dist/types/useTowns.d.ts.map +1 -0
- package/dist/types/useTownsAuthStatus.d.ts +26 -0
- package/dist/types/useTownsAuthStatus.d.ts.map +1 -0
- package/dist/types/useUserDms.d.ts +41 -0
- package/dist/types/useUserDms.d.ts.map +1 -0
- package/dist/types/useUserGdms.d.ts +32 -0
- package/dist/types/useUserGdms.d.ts.map +1 -0
- package/dist/types/useUserSpaces.d.ts +32 -0
- package/dist/types/useUserSpaces.d.ts.map +1 -0
- package/dist/types/utils.d.ts +3 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +75 -0
- package/src/connectTowns.ts +63 -0
- package/src/index.ts +34 -0
- package/src/internals/TownsSyncContext.ts +12 -0
- package/src/internals/useAction.ts +84 -0
- package/src/internals/useTownsSync.ts +4 -0
- package/src/internals/utils.ts +11 -0
- package/src/useAdminRedact.ts +45 -0
- package/src/useAgentConnection.ts +143 -0
- package/src/useChannel.ts +27 -0
- package/src/useCreateChannel.ts +30 -0
- package/src/useCreateDm.ts +25 -0
- package/src/useCreateGdm.ts +25 -0
- package/src/useCreateSpace.ts +25 -0
- package/src/useDm.ts +17 -0
- package/src/useGdm.ts +17 -0
- package/src/useJoinSpace.ts +26 -0
- package/src/useMember.ts +45 -0
- package/src/useMemberList.ts +21 -0
- package/src/useMyMember.ts +83 -0
- package/src/useObservable.ts +129 -0
- package/src/useReactions.ts +21 -0
- package/src/useRedact.ts +45 -0
- package/src/useScrollback.ts +31 -0
- package/src/useSendMessage.ts +35 -0
- package/src/useSendReaction.ts +39 -0
- package/src/useSpace.ts +30 -0
- package/src/useThreads.ts +22 -0
- package/src/useTimeline.ts +35 -0
- package/src/useTowns.ts +22 -0
- package/src/useTownsAuthStatus.ts +32 -0
- package/src/useUserDms.ts +38 -0
- package/src/useUserGdms.ts +29 -0
- package/src/useUserSpaces.ts +29 -0
- package/src/utils.ts +28 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Spaces } from '@towns-labs/sdk';
|
|
2
|
+
import { type ActionConfig } from './internals/useAction';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to join a space.
|
|
5
|
+
* @param config - Configuration options for the action.
|
|
6
|
+
* @returns The joinSpace action and the status of the action.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useJoinSpace: (config?: ActionConfig<Spaces["joinSpace"]>) => {
|
|
9
|
+
data: void | undefined;
|
|
10
|
+
error: Error | undefined;
|
|
11
|
+
isPending: boolean;
|
|
12
|
+
isSuccess: boolean;
|
|
13
|
+
isError: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Action to join a space.
|
|
16
|
+
* @param spaceId - The id of the space to join.
|
|
17
|
+
* @param signer - The signer to use to join the space.
|
|
18
|
+
* @param opts - Options for the join action.
|
|
19
|
+
*/
|
|
20
|
+
joinSpace: (spaceId: string, signer: import("ethers").Signer, opts?: {
|
|
21
|
+
skipMintMembership?: boolean;
|
|
22
|
+
} | undefined) => Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=useJoinSpace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useJoinSpace.d.ts","sourceRoot":"","sources":["../../src/useJoinSpace.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,uBAAuB,CAAA;AAGpE;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;;;;;;IAK/D;;;;;OAKG;;;;CAIV,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Member } from '@towns-labs/sdk';
|
|
2
|
+
import type { ObservableConfig } from './useObservable';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get data from a specific member of a Space, GDM, Channel, or DM.
|
|
5
|
+
* @param props - The streamId and userId of the member to get data from.
|
|
6
|
+
* @param config - Configuration options for the observable.
|
|
7
|
+
* @returns The Member data.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useMember: (props: {
|
|
10
|
+
streamId: string;
|
|
11
|
+
userId: string;
|
|
12
|
+
}, config?: ObservableConfig.FromObservable<Member>) => {
|
|
13
|
+
error: Error | undefined;
|
|
14
|
+
status: "loading" | "loaded" | "error";
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
isError: boolean;
|
|
17
|
+
isLoaded: boolean;
|
|
18
|
+
userId: string;
|
|
19
|
+
streamId: string;
|
|
20
|
+
initialized: boolean;
|
|
21
|
+
username: string;
|
|
22
|
+
isUsernameConfirmed: boolean;
|
|
23
|
+
isUsernameEncrypted: boolean;
|
|
24
|
+
displayName: string;
|
|
25
|
+
isDisplayNameEncrypted: boolean | undefined;
|
|
26
|
+
ensAddress: string | undefined;
|
|
27
|
+
nft: import("@towns-labs/sdk").NftModel | undefined;
|
|
28
|
+
membership: import("@towns-labs/proto").MembershipOp | undefined;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=useMember.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMember.d.ts","sourceRoot":"","sources":["../../src/useMember.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAIxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIvD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAClB,OAAO;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC3C,SAAS,gBAAgB,CAAC,cAAc,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;CA4BnD,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MembersModel } from '@towns-labs/sdk';
|
|
2
|
+
import { type ObservableConfig } from './useObservable';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the members userIds of a Space, GDM, Channel, or DM.
|
|
5
|
+
* Used with useMember to get data from a specific member.
|
|
6
|
+
* @param streamId - The id of the stream to get the members of.
|
|
7
|
+
* @param config - Configuration options for the observable.
|
|
8
|
+
* @returns The MembersModel of the stream, containing the userIds of the members.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useMemberList: (streamId: string, config?: ObservableConfig.FromData<MembersModel>) => import("./useObservable").ObservableValue<MembersModel>;
|
|
11
|
+
//# sourceMappingURL=useMemberList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMemberList.d.ts","sourceRoot":"","sources":["../../src/useMemberList.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,iBAAiB,CAAA;AAItE;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACtB,UAAU,MAAM,EAChB,SAAS,gBAAgB,CAAC,QAAQ,CAAC,YAAY,CAAC,4DAKnD,CAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Member, Myself } from '@towns-labs/sdk';
|
|
2
|
+
import { type ActionConfig } from './internals/useAction';
|
|
3
|
+
import { type ObservableConfig } from './useObservable';
|
|
4
|
+
/**
|
|
5
|
+
* Hook to get the data of the current user in a stream.
|
|
6
|
+
* @param streamId - The id of the stream to get the current user of.
|
|
7
|
+
* @param config - Configuration options for the observable.
|
|
8
|
+
* @returns The MemberModel of the current user.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useMyMember: (streamId: string, config?: ObservableConfig.FromObservable<Member>) => {
|
|
11
|
+
id: string;
|
|
12
|
+
userId: string;
|
|
13
|
+
streamId: string;
|
|
14
|
+
initialized: boolean;
|
|
15
|
+
username: string;
|
|
16
|
+
isUsernameConfirmed: boolean;
|
|
17
|
+
isUsernameEncrypted: boolean;
|
|
18
|
+
displayName: string;
|
|
19
|
+
isDisplayNameEncrypted?: boolean;
|
|
20
|
+
ensAddress?: string;
|
|
21
|
+
nft?: import("@towns-labs/sdk").NftModel;
|
|
22
|
+
membership?: import("@towns-labs/proto").MembershipOp;
|
|
23
|
+
appAddress?: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Hook to set the ENS address of the current user in a stream.
|
|
27
|
+
* You should be validating if the ENS address belongs to the user before setting it.
|
|
28
|
+
* @param streamId - The id of the stream to set the ENS address of.
|
|
29
|
+
* @param config - Configuration options for the action.
|
|
30
|
+
* @returns The `setEnsAddress` action and its loading state.
|
|
31
|
+
*/
|
|
32
|
+
export declare const useSetEnsAddress: (streamId: string, config?: ActionConfig<Myself["setEnsAddress"]>) => {
|
|
33
|
+
data: void | undefined;
|
|
34
|
+
error: Error | undefined;
|
|
35
|
+
isPending: boolean;
|
|
36
|
+
isSuccess: boolean;
|
|
37
|
+
isError: boolean;
|
|
38
|
+
setEnsAddress: (ensAddress: `0x${string}`) => Promise<void>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Hook to set the username of the current user in a stream.
|
|
42
|
+
* @param streamId - The id of the stream to set the username of.
|
|
43
|
+
* @param config - Configuration options for the action.
|
|
44
|
+
* @returns The `setUsername` action and its loading state.
|
|
45
|
+
*/
|
|
46
|
+
export declare const useSetUsername: (streamId: string, config?: ActionConfig<Myself["setUsername"]>) => {
|
|
47
|
+
data: void | undefined;
|
|
48
|
+
error: Error | undefined;
|
|
49
|
+
isPending: boolean;
|
|
50
|
+
isSuccess: boolean;
|
|
51
|
+
isError: boolean;
|
|
52
|
+
setUsername: (username: string) => Promise<void>;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Hook to set the display name of the current user in a stream.
|
|
56
|
+
* @param streamId - The id of the stream to set the display name of.
|
|
57
|
+
* @param config - Configuration options for the action.
|
|
58
|
+
* @returns The `setDisplayName` action and its loading state.
|
|
59
|
+
*/
|
|
60
|
+
export declare const useSetDisplayName: (streamId: string, config?: ActionConfig<Myself["setDisplayName"]>) => {
|
|
61
|
+
data: void | undefined;
|
|
62
|
+
error: Error | undefined;
|
|
63
|
+
isPending: boolean;
|
|
64
|
+
isSuccess: boolean;
|
|
65
|
+
isError: boolean;
|
|
66
|
+
setDisplayName: (displayName: string) => Promise<void>;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Hook to set the NFT of the current user in a stream.
|
|
70
|
+
* You should be validating if the NFT belongs to the user before setting it.
|
|
71
|
+
* @param streamId - The id of the stream to set the NFT of.
|
|
72
|
+
* @param config - Configuration options for the action.
|
|
73
|
+
* @returns The `setNft` action and its loading state.
|
|
74
|
+
*/
|
|
75
|
+
export declare const useSetNft: (streamId: string, config?: ActionConfig<Myself["setNft"]>) => {
|
|
76
|
+
data: void | undefined;
|
|
77
|
+
error: Error | undefined;
|
|
78
|
+
isPending: boolean;
|
|
79
|
+
isSuccess: boolean;
|
|
80
|
+
isError: boolean;
|
|
81
|
+
setNft: (nft: import("@towns-labs/sdk").NftModel) => Promise<void>;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=useMyMember.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMyMember.d.ts","sourceRoot":"","sources":["../../src/useMyMember.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAa,MAAM,iBAAiB,CAAA;AAEhE,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,iBAAiB,CAAA;AAMtE;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,MAAM,EAAE,SAAS,gBAAgB,CAAC,cAAc,CAAC,MAAM,CAAC;;;;;;;;;;;;;;CAO7F,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GACzB,UAAU,MAAM,EAChB,SAAS,YAAY,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;;;;;;;CAMjD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,EAAE,SAAS,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;;;;;;;CAK5F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC1B,UAAU,MAAM,EAChB,SAAS,YAAY,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;;;;;;;CAMlD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,UAAU,MAAM,EAAE,SAAS,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;;;;;;;CAKlF,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type Observable, type PersistedModel } from '@towns-labs/sdk';
|
|
2
|
+
export declare namespace ObservableConfig {
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for an observable.
|
|
5
|
+
* It can be used to configure the behavior of the `useObservable` hook.
|
|
6
|
+
*/
|
|
7
|
+
type FromObservable<Observable_> = Observable_ extends Observable<infer Data> ? FromData<Data> : never;
|
|
8
|
+
/**
|
|
9
|
+
* Create configuration options for an observable from the data type.
|
|
10
|
+
* It can be used to configure the behavior of the `useObservable` hook.
|
|
11
|
+
*/
|
|
12
|
+
type FromData<Data> = Data extends PersistedModel<infer UnwrappedData> ? {
|
|
13
|
+
/**
|
|
14
|
+
* Trigger the update immediately, without waiting for the first update.
|
|
15
|
+
* @defaultValue true
|
|
16
|
+
*/
|
|
17
|
+
fireImmediately?: boolean;
|
|
18
|
+
/** Callback function to be called when the data is updated. */
|
|
19
|
+
onUpdate?: (data: UnwrappedData) => void;
|
|
20
|
+
/** Callback function to be called when an error occurs. */
|
|
21
|
+
onError?: (error: Error) => void;
|
|
22
|
+
} : {
|
|
23
|
+
/**
|
|
24
|
+
* Trigger the update immediately, without waiting for the first update.
|
|
25
|
+
* @defaultValue true
|
|
26
|
+
*/
|
|
27
|
+
fireImmediately?: boolean;
|
|
28
|
+
/** Callback function to be called when the data is updated. */
|
|
29
|
+
onUpdate?: (data: Data) => void;
|
|
30
|
+
/** Callback function to be called when an error occurs. */
|
|
31
|
+
onError?: (error: Error) => void;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The value returned by the useObservable hook.
|
|
36
|
+
* If the observable is a PersistedModel, it will include error and status information.
|
|
37
|
+
*/
|
|
38
|
+
export type ObservableValue<T> = {
|
|
39
|
+
/** The data of the model. */
|
|
40
|
+
data: T;
|
|
41
|
+
/** If the model is in an error state, this will be the error. */
|
|
42
|
+
error: Error | undefined;
|
|
43
|
+
/** The status of the model. */
|
|
44
|
+
status: 'loading' | 'loaded' | 'error';
|
|
45
|
+
/** True if the model is in a loading state. */
|
|
46
|
+
isLoading: boolean;
|
|
47
|
+
/** True if the model is in an error state. */
|
|
48
|
+
isError: boolean;
|
|
49
|
+
/** True if the data is loaded. */
|
|
50
|
+
isLoaded: boolean;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* This hook subscribes to an observable and returns the value of the observable.
|
|
54
|
+
* @param observable - The observable to subscribe to.
|
|
55
|
+
* @param config - Configuration options for the observable.
|
|
56
|
+
* @returns The value of the observable.
|
|
57
|
+
*/
|
|
58
|
+
export declare function useObservable<Model, Data = Model extends PersistedModel<infer UnwrappedData> ? UnwrappedData : Model>(observable: Observable<Model>, config?: ObservableConfig.FromData<Model>): ObservableValue<Data>;
|
|
59
|
+
//# sourceMappingURL=useObservable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useObservable.d.ts","sourceRoot":"","sources":["../../src/useObservable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAItE,yBAAiB,gBAAgB,CAAC;IAC9B;;;OAGG;IACH,KAAY,cAAc,CAAC,WAAW,IAClC,WAAW,SAAS,UAAU,CAAC,MAAM,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;IAKvE;;;OAGG;IACH,KAAY,QAAQ,CAAC,IAAI,IACrB,IAAI,SAAS,cAAc,CAAC,MAAM,aAAa,CAAC,GAC1C;QACI;;;WAGG;QACH,eAAe,CAAC,EAAE,OAAO,CAAA;QACzB,+DAA+D;QAC/D,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAA;QAExC,2DAA2D;QAC3D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;KACnC,GACD;QACI;;;WAGG;QACH,eAAe,CAAC,EAAE,OAAO,CAAA;QACzB,+DAA+D;QAC/D,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;QAE/B,2DAA2D;QAC3D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;KACnC,CAAA;CACd;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC7B,6BAA6B;IAC7B,IAAI,EAAE,CAAC,CAAA;IACP,iEAAiE;IACjE,KAAK,EAAE,KAAK,GAAG,SAAS,CAAA;IACxB,+BAA+B;IAC/B,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;IACtC,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAA;IAClB,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAA;IAChB,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAA;CACpB,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CACzB,KAAK,EACL,IAAI,GAAG,KAAK,SAAS,cAAc,CAAC,MAAM,aAAa,CAAC,GAAG,aAAa,GAAG,KAAK,EAClF,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAmDjG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MessageReactions } from '@towns-labs/sdk';
|
|
2
|
+
import { type ObservableConfig } from './useObservable';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the reactions of a specific stream.
|
|
5
|
+
* @param streamId - The id of the stream to get the reactions of.
|
|
6
|
+
* @param config - Configuration options for the observable.
|
|
7
|
+
* @returns The reactions of the stream as a map from the message eventId to the reaction.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useReactions: (streamId: string, config?: ObservableConfig.FromData<Record<string, MessageReactions>>) => import("./useObservable").ObservableValue<Record<string, MessageReactions>>;
|
|
10
|
+
//# sourceMappingURL=useReactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReactions.d.ts","sourceRoot":"","sources":["../../src/useReactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAiB,MAAM,iBAAiB,CAAA;AAEjE,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,iBAAiB,CAAA;AAGtE;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACrB,UAAU,MAAM,EAChB,SAAS,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,gFAOvE,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type Channel } from '@towns-labs/sdk';
|
|
2
|
+
import { type ActionConfig } from './internals/useAction';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to redact your own message in a channel stream.
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ### Redact a message
|
|
8
|
+
*
|
|
9
|
+
* You can use `redact` to redact a message in a stream.
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { useRedact } from '@towns-labs/react-sdk'
|
|
12
|
+
*
|
|
13
|
+
* const { redact } = useRedact(streamId)
|
|
14
|
+
* redact({ eventId: messageEventId })
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ### Redact a message reaction
|
|
18
|
+
*
|
|
19
|
+
* You can also use `redact` to redact a message reaction in a stream.
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { useRedact } from '@towns-labs/react-sdk'
|
|
22
|
+
*
|
|
23
|
+
* const { redact } = useRedact(streamId)
|
|
24
|
+
* redact({ eventId: reactionEventId })
|
|
25
|
+
* ```
|
|
26
|
+
* @param streamId - The id of the stream to redact the message in.
|
|
27
|
+
* @param config - Configuration options for the action.
|
|
28
|
+
* @returns The `redact` action and its loading state.
|
|
29
|
+
*/
|
|
30
|
+
export declare const useRedact: (streamId: string, config?: ActionConfig<Channel["redact"]>) => {
|
|
31
|
+
data: {
|
|
32
|
+
eventId: string;
|
|
33
|
+
} | undefined;
|
|
34
|
+
error: Error | undefined;
|
|
35
|
+
isPending: boolean;
|
|
36
|
+
isSuccess: boolean;
|
|
37
|
+
isError: boolean;
|
|
38
|
+
redact: (eventId: string, reason?: string | undefined) => Promise<{
|
|
39
|
+
eventId: string;
|
|
40
|
+
}>;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=useRedact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRedact.d.ts","sourceRoot":"","sources":["../../src/useRedact.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,uBAAuB,CAAA;AAIpE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,SAAS,GAAI,UAAU,MAAM,EAAE,SAAS,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;;;;;;;;;;;CAUnF,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type MessageTimeline } from '@towns-labs/sdk';
|
|
2
|
+
import { type ActionConfig } from './internals/useAction';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the scrollback action for a stream.
|
|
5
|
+
*
|
|
6
|
+
* Scrollback is the action of getting miniblocks from a stream before a certain point in time.
|
|
7
|
+
* Getting miniblocks means that new events that are possibly new messages, reactions and so on are fetched.
|
|
8
|
+
*
|
|
9
|
+
* @param streamId - The id of the stream to get the scrollback action for.
|
|
10
|
+
* @param config - Configuration options for the action.
|
|
11
|
+
* @returns The `scrollback` action and its loading state.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useScrollback: (streamId: string, config?: ActionConfig<MessageTimeline["scrollback"]>) => {
|
|
14
|
+
data: {
|
|
15
|
+
terminus: boolean;
|
|
16
|
+
fromInclusiveMiniblockNum: bigint;
|
|
17
|
+
} | undefined;
|
|
18
|
+
error: Error | undefined;
|
|
19
|
+
isPending: boolean;
|
|
20
|
+
isSuccess: boolean;
|
|
21
|
+
isError: boolean;
|
|
22
|
+
scrollback: () => Promise<{
|
|
23
|
+
terminus: boolean;
|
|
24
|
+
fromInclusiveMiniblockNum: bigint;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=useScrollback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScrollback.d.ts","sourceRoot":"","sources":["../../src/useScrollback.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,iBAAiB,CAAA;AAErE,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,uBAAuB,CAAA;AAIpE;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,GACtB,UAAU,MAAM,EAChB,SAAS,YAAY,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;;;;;;;;;;;;;CAUvD,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Channel } from '@towns-labs/sdk';
|
|
2
|
+
import { type ActionConfig } from './internals/useAction';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to send a message to a stream. Can be used to send a message to a channel or a dm/group dm.
|
|
5
|
+
* @param streamId - The id of the stream to send the message to.
|
|
6
|
+
* @param config - Configuration options for the action.
|
|
7
|
+
* @returns The sendMessage action and the status of the action.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useSendMessage: (streamId: string, config?: ActionConfig<Channel["sendMessage"]>) => {
|
|
10
|
+
data: {
|
|
11
|
+
eventId: string;
|
|
12
|
+
} | undefined;
|
|
13
|
+
error: Error | undefined;
|
|
14
|
+
isPending: boolean;
|
|
15
|
+
isSuccess: boolean;
|
|
16
|
+
isError: boolean;
|
|
17
|
+
/** Sends a message to the stream.
|
|
18
|
+
* @param message - The message to send.
|
|
19
|
+
* @param options - Additional options for the message.
|
|
20
|
+
* @returns The event id of the message.
|
|
21
|
+
*/
|
|
22
|
+
sendMessage: (message: string, options?: {
|
|
23
|
+
threadId?: string;
|
|
24
|
+
replyId?: string;
|
|
25
|
+
mentions?: import("@towns-labs/proto").PlainMessage<import("@towns-labs/proto").ChannelMessage_Post_Mention>[];
|
|
26
|
+
attachments?: import("@towns-labs/proto").PlainMessage<import("@towns-labs/proto").ChannelMessage_Post_Attachment>[];
|
|
27
|
+
appClientAddress?: string;
|
|
28
|
+
} | undefined) => Promise<{
|
|
29
|
+
eventId: string;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=useSendMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSendMessage.d.ts","sourceRoot":"","sources":["../../src/useSendMessage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAiB,MAAM,iBAAiB,CAAA;AAExD,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,uBAAuB,CAAA;AAIpE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACvB,UAAU,MAAM,EAGhB,SAAS,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;;;;;;;;IAQzC;;;;OAIG;;;;;;;;;;CAIV,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Channel } from '@towns-labs/sdk';
|
|
2
|
+
import { type ActionConfig } from './internals/useAction';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to send a reaction to a message in a stream.
|
|
5
|
+
*
|
|
6
|
+
* Reaction can be any string value, including emojis.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { useSendReaction } from '@towns-labs/react-sdk'
|
|
11
|
+
*
|
|
12
|
+
* const { sendReaction } = useSendReaction('stream-id')
|
|
13
|
+
* sendReaction(messageEventId, '🔥')
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param streamId - The id of the stream to send the reaction to.
|
|
17
|
+
* @param config - Configuration options for the action.
|
|
18
|
+
* @returns The `sendReaction` action and its loading state.
|
|
19
|
+
*/
|
|
20
|
+
export declare const useSendReaction: (streamId: string, config?: ActionConfig<Channel["sendReaction"]>) => {
|
|
21
|
+
data: {
|
|
22
|
+
eventId: string;
|
|
23
|
+
} | undefined;
|
|
24
|
+
error: Error | undefined;
|
|
25
|
+
isPending: boolean;
|
|
26
|
+
isSuccess: boolean;
|
|
27
|
+
isError: boolean;
|
|
28
|
+
sendReaction: (refEventId: string, reaction: string) => Promise<{
|
|
29
|
+
eventId: string;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=useSendReaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSendReaction.d.ts","sourceRoot":"","sources":["../../src/useSendReaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,uBAAuB,CAAA;AAIpE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,GACxB,UAAU,MAAM,EAChB,SAAS,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;;;;;;;;;;;CAYjD,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Space } from '@towns-labs/sdk';
|
|
2
|
+
import { type ObservableConfig } from './useObservable';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get data about a space.
|
|
5
|
+
* You can use this hook to get space metadata and ids of channels in the space.
|
|
6
|
+
* @param spaceId - The id of the space to get data about.
|
|
7
|
+
* @param config - Configuration options for the observable.
|
|
8
|
+
* @returns The SpaceModel data.
|
|
9
|
+
* @example
|
|
10
|
+
* You can use this hook to display the data about a space:
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { useSpace } from '@towns-labs/react-sdk'
|
|
14
|
+
*
|
|
15
|
+
* const Space = ({ spaceId }: { spaceId: string }) => {
|
|
16
|
+
* const { data: space } = useSpace(spaceId)
|
|
17
|
+
* return <div>{space.metadata?.name || 'Unnamed Space'}</div>
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare const useSpace: (spaceId: string, config?: ObservableConfig.FromObservable<Space>) => import("./useObservable").ObservableValue<import("@towns-labs/sdk").SpaceModel>;
|
|
22
|
+
//# sourceMappingURL=useSpace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSpace.d.ts","sourceRoot":"","sources":["../../src/useSpace.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,iBAAiB,CAAA;AAEtE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,QAAQ,GAAI,SAAS,MAAM,EAAE,SAAS,gBAAgB,CAAC,cAAc,CAAC,KAAK,CAAC,oFAIxF,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to get the sync agent from the TownsSyncProvider.
|
|
3
|
+
*
|
|
4
|
+
* You can use it to interact with the sync agent for more advanced usage.
|
|
5
|
+
*
|
|
6
|
+
* Throws an error if no sync agent is set in the TownsSyncProvider.
|
|
7
|
+
*
|
|
8
|
+
* @returns The sync agent in use, set in TownsSyncProvider.
|
|
9
|
+
* @throws If no sync agent is set, use TownsSyncProvider to set one or use useAgentConnection to check if connected.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useSyncAgent: () => import("@towns-labs/sdk").SyncAgent;
|
|
12
|
+
//# sourceMappingURL=useSyncAgent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSyncAgent.d.ts","sourceRoot":"","sources":["../../src/useSyncAgent.tsx"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,2CAUxB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TimelinesMap } from '@towns-labs/sdk';
|
|
2
|
+
import { type ObservableConfig } from './useObservable';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the threads from a stream.
|
|
5
|
+
*
|
|
6
|
+
* @param streamId - The id of the stream to get the threads from.
|
|
7
|
+
* @param config - Configuration options for the observable.
|
|
8
|
+
* @returns The threads of the stream as a map from the message eventId to a thread.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useThreads: (streamId: string, config?: ObservableConfig.FromObservable<TimelinesMap>) => import("./useObservable").ObservableValue<TimelinesMap>;
|
|
11
|
+
//# sourceMappingURL=useThreads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThreads.d.ts","sourceRoot":"","sources":["../../src/useThreads.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,YAAY,EAAU,MAAM,iBAAiB,CAAA;AAE7D,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,iBAAiB,CAAA;AAGtE;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GACnB,UAAU,MAAM,EAChB,SAAS,gBAAgB,CAAC,cAAc,CAAC,YAAY,CAAC,4DAMzD,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type TimelineEvent } from '@towns-labs/sdk';
|
|
2
|
+
import { type ObservableConfig } from './useObservable';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the timeline events from a stream.
|
|
5
|
+
*
|
|
6
|
+
* You can use the `useTimeline` hook to get the timeline events from a channel stream, dm stream or group dm stream
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { useTimeline } from '@towns-labs/react-sdk'
|
|
11
|
+
* import { RiverTimelineEvent } from '@towns-labs/sdk'
|
|
12
|
+
*
|
|
13
|
+
* const { data: events } = useTimeline(streamId)
|
|
14
|
+
*
|
|
15
|
+
* // You can filter the events by their kind
|
|
16
|
+
* const messages = events.filter((event) => event.content?.kind === RiverTimelineEvent.ChannelMessage)
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param streamId - The id of the stream to get the timeline events from.
|
|
20
|
+
* @param config - Configuration options for the observable.
|
|
21
|
+
* @returns The timeline events of the stream as an observable.
|
|
22
|
+
*/
|
|
23
|
+
export declare const useTimeline: (streamId: string, config?: ObservableConfig.FromObservable<TimelineEvent[]>) => import("./useObservable").ObservableValue<TimelineEvent[]>;
|
|
24
|
+
//# sourceMappingURL=useTimeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTimeline.d.ts","sourceRoot":"","sources":["../../src/useTimeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,aAAa,EAAU,MAAM,iBAAiB,CAAA;AAEnE,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,iBAAiB,CAAA;AAItE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,WAAW,GACpB,UAAU,MAAM,EAChB,SAAS,gBAAgB,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,+DAM5D,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Observable, SyncAgent } from '@towns-labs/sdk';
|
|
2
|
+
import { type ObservableConfig } from './useObservable';
|
|
3
|
+
type SyncSelector = SyncAgent['observables'];
|
|
4
|
+
/**
|
|
5
|
+
* Hook to get an observable from the sync agent.
|
|
6
|
+
*
|
|
7
|
+
* An alternative of our premade hooks, allowing the creation of custom abstractions.
|
|
8
|
+
* @param selector - A selector function to get a observable from the sync agent.
|
|
9
|
+
* @param config - Configuration options for the observable.
|
|
10
|
+
* @returns The data from the selected observable.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useTowns<T>(selector: (sync: SyncSelector) => Observable<T>, config?: ObservableConfig.FromData<T>): import("./useObservable").ObservableValue<T extends import("@towns-labs/sdk").PersistedModel<infer UnwrappedData> ? UnwrappedData : T>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=useTowns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTowns.d.ts","sourceRoot":"","sources":["../../src/useTowns.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,iBAAiB,CAAA;AAGtE,KAAK,YAAY,GAAG,SAAS,CAAC,aAAa,CAAC,CAAA;AAE5C;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACtB,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,UAAU,CAAC,CAAC,CAAC,EAC/C,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,0IAIxC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AuthStatus } from '@towns-labs/sdk';
|
|
2
|
+
import type { ObservableConfig } from './useObservable';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the auth status of the user connection with the Towns network.
|
|
5
|
+
* @param config - Configuration options for the observable.
|
|
6
|
+
* @returns An object containing the current AuthStatus status and boolean flags for each possible status.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useTownsAuthStatus: (config?: ObservableConfig.FromObservable<AuthStatus>) => {
|
|
9
|
+
/** The current AuthStatus of the user connection with the Towns network. */
|
|
10
|
+
status: AuthStatus;
|
|
11
|
+
/** Whether the user connection with the Towns network is initializing. */
|
|
12
|
+
isInitializing: boolean;
|
|
13
|
+
/** Whether the user connection with the Towns network is evaluating credentials. */
|
|
14
|
+
isEvaluatingCredentials: boolean;
|
|
15
|
+
/** Whether the user connection with the Towns network is credentialed. */
|
|
16
|
+
isCredentialed: boolean;
|
|
17
|
+
/** Whether the user connection with the Towns network is connecting to Towns. */
|
|
18
|
+
isConnectingToTowns: boolean;
|
|
19
|
+
/** Whether the user connection with the Towns network is connected to Towns. */
|
|
20
|
+
isConnectedToTowns: boolean;
|
|
21
|
+
/** Whether the user connection with the Towns network is disconnected. */
|
|
22
|
+
isDisconnected: boolean;
|
|
23
|
+
/** Whether the user connection with the Towns network is in an error state. */
|
|
24
|
+
isError: boolean;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=useTownsAuthStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTownsAuthStatus.d.ts","sourceRoot":"","sources":["../../src/useTownsAuthStatus.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEvD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,gBAAgB,CAAC,cAAc,CAAC,UAAU,CAAC;IAG/E,4EAA4E;;IAE5E,0EAA0E;;IAE1E,oFAAoF;;IAEpF,0EAA0E;;IAE1E,iFAAiF;;IAEjF,gFAAgF;;IAEhF,0EAA0E;;IAE1E,+EAA+E;;CAGtF,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Dms } from '@towns-labs/sdk';
|
|
2
|
+
import type { ObservableConfig } from './useObservable';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the direct messages of the current user.
|
|
5
|
+
* @param config - Configuration options for the observable.
|
|
6
|
+
* @returns The list of all direct messages stream ids of the current user.
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* You can combine this hook with the `useDm`, `useMemberList` and `useMember` hooks to get all direct messages of the current user and render them, showing the name of the other user in the dm:
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { useDm, useMyMember, useMemberList, useMember } from '@towns-labs/react-sdk'
|
|
13
|
+
*
|
|
14
|
+
* const AllDms = () => {
|
|
15
|
+
* const { streamIds } = useUserDms()
|
|
16
|
+
* return <>{streamIds.map((streamId) => <Dm key={streamId} streamId={streamId} />)}</>
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* const Dm = ({ streamId }: { streamId: string }) => {
|
|
20
|
+
* const { data: dm } = useDm(streamId)
|
|
21
|
+
* const { userId: myUserId } = useMyMember(streamId)
|
|
22
|
+
* const { data: members } = useMemberList(streamId)
|
|
23
|
+
* const { userId, username, displayName } = useMember({
|
|
24
|
+
* streamId,
|
|
25
|
+
* // We find the other user in the dm by checking the userIds in the member list
|
|
26
|
+
* // and defaulting to the current user if we don't find one, since a user is able to send a dm to themselves
|
|
27
|
+
* userId: members.userIds.find((userId) => userId !== sync.userId) || sync.userId,
|
|
28
|
+
* })
|
|
29
|
+
* return <span>{userId === myUserId ? 'You' : displayName || username || userId}</span>
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare const useUserDms: (config?: ObservableConfig.FromObservable<Dms>) => {
|
|
34
|
+
error: Error | undefined;
|
|
35
|
+
status: "loading" | "loaded" | "error";
|
|
36
|
+
isLoading: boolean;
|
|
37
|
+
isError: boolean;
|
|
38
|
+
isLoaded: boolean;
|
|
39
|
+
streamIds: string[];
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=useUserDms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUserDms.d.ts","sourceRoot":"","sources":["../../src/useUserDms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,gBAAgB,CAAC,cAAc,CAAC,GAAG,CAAC;;;;;;;CAGvE,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Gdms } from '@towns-labs/sdk';
|
|
2
|
+
import type { ObservableConfig } from './useObservable';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the group dm streams of the current user.
|
|
5
|
+
* @param config - Configuration options for the observable.
|
|
6
|
+
* @returns The list of all group dm stream ids of the current user.
|
|
7
|
+
* @example
|
|
8
|
+
* You can combine this hook with the `useGdm` hook to get all group dm streams of the current user and render them:
|
|
9
|
+
*
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { useUserGdms, useGdm } from '@towns-labs/react-sdk'
|
|
12
|
+
*
|
|
13
|
+
* const AllGdms = () => {
|
|
14
|
+
* const { streamIds } = useUserGdms()
|
|
15
|
+
* return <>{streamIds.map((streamId) => <Gdm key={streamId} streamId={streamId} />)}</>
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* const Gdm = ({ streamId }: { streamId: string }) => {
|
|
19
|
+
* const { data: gdm } = useGdm(streamId)
|
|
20
|
+
* return <div>{gdm.metadata?.name || 'Unnamed Gdm'}</div>
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const useUserGdms: (config?: ObservableConfig.FromObservable<Gdms>) => {
|
|
25
|
+
error: Error | undefined;
|
|
26
|
+
status: "loading" | "loaded" | "error";
|
|
27
|
+
isLoading: boolean;
|
|
28
|
+
isError: boolean;
|
|
29
|
+
isLoaded: boolean;
|
|
30
|
+
streamIds: string[];
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=useUserGdms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUserGdms.d.ts","sourceRoot":"","sources":["../../src/useUserGdms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGvD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,gBAAgB,CAAC,cAAc,CAAC,IAAI,CAAC;;;;;;;CAGzE,CAAA"}
|