@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,36 @@
|
|
|
1
|
+
import { useTowns } from './useTowns';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to get the direct messages of the current user.
|
|
4
|
+
* @param config - Configuration options for the observable.
|
|
5
|
+
* @returns The list of all direct messages stream ids of the current user.
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* 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:
|
|
9
|
+
*
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { useDm, useMyMember, useMemberList, useMember } from '@towns-labs/react-sdk'
|
|
12
|
+
*
|
|
13
|
+
* const AllDms = () => {
|
|
14
|
+
* const { streamIds } = useUserDms()
|
|
15
|
+
* return <>{streamIds.map((streamId) => <Dm key={streamId} streamId={streamId} />)}</>
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* const Dm = ({ streamId }: { streamId: string }) => {
|
|
19
|
+
* const { data: dm } = useDm(streamId)
|
|
20
|
+
* const { userId: myUserId } = useMyMember(streamId)
|
|
21
|
+
* const { data: members } = useMemberList(streamId)
|
|
22
|
+
* const { userId, username, displayName } = useMember({
|
|
23
|
+
* streamId,
|
|
24
|
+
* // We find the other user in the dm by checking the userIds in the member list
|
|
25
|
+
* // and defaulting to the current user if we don't find one, since a user is able to send a dm to themselves
|
|
26
|
+
* userId: members.userIds.find((userId) => userId !== sync.userId) || sync.userId,
|
|
27
|
+
* })
|
|
28
|
+
* return <span>{userId === myUserId ? 'You' : displayName || username || userId}</span>
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export const useUserDms = (config) => {
|
|
33
|
+
const { data, ...rest } = useTowns((s) => s.dms, config);
|
|
34
|
+
return { streamIds: data.streamIds, ...rest };
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=useUserDms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUserDms.js","sourceRoot":"","sources":["../../src/useUserDms.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAA6C,EAAE,EAAE;IACxE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IACxD,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,EAAE,CAAA;AACjD,CAAC,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useTowns } from './useTowns';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to get the group dm streams of the current user.
|
|
4
|
+
* @param config - Configuration options for the observable.
|
|
5
|
+
* @returns The list of all group dm stream ids of the current user.
|
|
6
|
+
* @example
|
|
7
|
+
* You can combine this hook with the `useGdm` hook to get all group dm streams of the current user and render them:
|
|
8
|
+
*
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import { useUserGdms, useGdm } from '@towns-labs/react-sdk'
|
|
11
|
+
*
|
|
12
|
+
* const AllGdms = () => {
|
|
13
|
+
* const { streamIds } = useUserGdms()
|
|
14
|
+
* return <>{streamIds.map((streamId) => <Gdm key={streamId} streamId={streamId} />)}</>
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* const Gdm = ({ streamId }: { streamId: string }) => {
|
|
18
|
+
* const { data: gdm } = useGdm(streamId)
|
|
19
|
+
* return <div>{gdm.metadata?.name || 'Unnamed Gdm'}</div>
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export const useUserGdms = (config) => {
|
|
24
|
+
const { data, ...rest } = useTowns((s) => s.gdms, config);
|
|
25
|
+
return { streamIds: data.streamIds, ...rest };
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=useUserGdms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUserGdms.js","sourceRoot":"","sources":["../../src/useUserGdms.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAA8C,EAAE,EAAE;IAC1E,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACzD,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,EAAE,CAAA;AACjD,CAAC,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useTowns } from './useTowns';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to get the spaces of the current user.
|
|
4
|
+
* @param config - Configuration options for the observable.
|
|
5
|
+
* @returns The list of all space ids of the current user.
|
|
6
|
+
* @example
|
|
7
|
+
* You can combine this hook with the `useSpace` hook to get all spaces of the current user and render them:
|
|
8
|
+
*
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import { useUserSpaces, useSpace } from '@towns-labs/react-sdk'
|
|
11
|
+
*
|
|
12
|
+
* const AllSpaces = () => {
|
|
13
|
+
* const { spaceIds } = useUserSpaces()
|
|
14
|
+
* return <>{spaceIds.map((spaceId) => <Space key={spaceId} spaceId={spaceId} />)}</>
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* const Space = ({ spaceId }: { spaceId: string }) => {
|
|
18
|
+
* const { data: space } = useSpace(spaceId)
|
|
19
|
+
* return <div>{space.metadata?.name || 'Unnamed Space'}</div>
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export const useUserSpaces = (config) => {
|
|
24
|
+
const { data, ...rest } = useTowns((s) => s.spaces, config);
|
|
25
|
+
return { spaceIds: data.spaceIds, ...rest };
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=useUserSpaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUserSpaces.js","sourceRoot":"","sources":["../../src/useUserSpaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAgD,EAAE,EAAE;IAC9E,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3D,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAA;AAC/C,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isChannelStreamId, isDMChannelStreamId, isGDMChannelStreamId, isSpaceStreamId, spaceIdFromChannelId, } from '@towns-labs/sdk';
|
|
2
|
+
export const getRoom = (sync, streamId) => {
|
|
3
|
+
if (isChannelStreamId(streamId)) {
|
|
4
|
+
return sync.spaces.getSpace(spaceIdFromChannelId(streamId)).getChannel(streamId);
|
|
5
|
+
}
|
|
6
|
+
if (isGDMChannelStreamId(streamId)) {
|
|
7
|
+
return sync.gdms.getGdm(streamId);
|
|
8
|
+
}
|
|
9
|
+
if (isDMChannelStreamId(streamId)) {
|
|
10
|
+
return sync.dms.getDm(streamId);
|
|
11
|
+
}
|
|
12
|
+
if (isSpaceStreamId(streamId)) {
|
|
13
|
+
return sync.spaces.getSpace(streamId);
|
|
14
|
+
}
|
|
15
|
+
throw new Error('Invalid room type');
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,GACvB,MAAM,iBAAiB,CAAA;AAExB,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAe,EAAE,QAAgB,EAA8B,EAAE;IACrF,IAAI,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACpF,CAAC;IACD,IAAI,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACrC,CAAC;IACD,IAAI,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IACnC,CAAC;IACD,IAAI,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACzC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;AACxC,CAAC,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SyncAgent } from '@towns-labs/sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Provides the sync agent to all hooks usage that interacts with the Towns Protocol.
|
|
4
|
+
*
|
|
5
|
+
* - If you want to interact with the sync agent directly, you can use the `useSyncAgent` hook.
|
|
6
|
+
* - If you want to interact with the Towns Protocol using hooks provided by this SDK, you should wrap your App with this provider.
|
|
7
|
+
*
|
|
8
|
+
* You can pass an initial sync agent instance to the provider.
|
|
9
|
+
* This can be useful for persisting authentication.
|
|
10
|
+
*
|
|
11
|
+
* @param props - The props for the provider
|
|
12
|
+
* @returns The provider
|
|
13
|
+
*/
|
|
14
|
+
export declare const TownsSyncProvider: (props: {
|
|
15
|
+
/** A initial sync agent instance. Useful for persisting authentication. */
|
|
16
|
+
syncAgent?: SyncAgent;
|
|
17
|
+
config?: {
|
|
18
|
+
/** A callback function that is called when the bearer token expires. */
|
|
19
|
+
onTokenExpired?: () => void;
|
|
20
|
+
};
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
}) => import("react").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=TownsSyncProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TownsSyncProvider.d.ts","sourceRoot":"","sources":["../../src/TownsSyncProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAIhD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO;IACrC,2EAA2E;IAC3E,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,MAAM,CAAC,EAAE;QACL,wEAAwE;QACxE,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;KAC9B,CAAA;IACD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC7B,gCA6BA,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type SignerContext, SyncAgent, type SyncAgentConfig } from '@towns-labs/sdk';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
/**
|
|
4
|
+
* Sign and connect to Towns using a Signer and a random delegate wallet every time
|
|
5
|
+
* @param signer - The signer to use
|
|
6
|
+
* @param config - The configuration for the sync agent
|
|
7
|
+
* @returns The sync agent
|
|
8
|
+
*/
|
|
9
|
+
export declare const signAndConnect: (signer: ethers.Signer, config: Omit<SyncAgentConfig, "context">) => Promise<SyncAgent>;
|
|
10
|
+
/**
|
|
11
|
+
* Connect to Towns using a SignerContext
|
|
12
|
+
*
|
|
13
|
+
* Useful for server side code, allowing you to persist the signer context and use it to auth with Towns later
|
|
14
|
+
* @param signerContext - The signer context to use
|
|
15
|
+
* @param config - The configuration for the sync agent
|
|
16
|
+
* @returns The sync agent
|
|
17
|
+
*/
|
|
18
|
+
export declare const connectTowns: (signerContext: SignerContext, config: Omit<SyncAgentConfig, "context">) => Promise<SyncAgent>;
|
|
19
|
+
/**
|
|
20
|
+
* Connect to Towns using a Bearer Token
|
|
21
|
+
* Towns clients can use this to connect to Towns Protocol on behalf of a user
|
|
22
|
+
*
|
|
23
|
+
* Useful for server side code, allowing you to persist the signer context and use it to auth with Towns later
|
|
24
|
+
* @param token - The bearer token to use
|
|
25
|
+
* @param config - The configuration for the sync agent
|
|
26
|
+
* @returns The sync agent
|
|
27
|
+
*/
|
|
28
|
+
export declare const connectTownsWithBearerToken: (token: string, config: Omit<SyncAgentConfig, "context">) => Promise<SyncAgent>;
|
|
29
|
+
//# sourceMappingURL=connectTowns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectTowns.d.ts","sourceRoot":"","sources":["../../src/connectTowns.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,aAAa,EAClB,SAAS,EACT,KAAK,eAAe,EAGvB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAQ/B;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACvB,QAAQ,MAAM,CAAC,MAAM,EACrB,QAAQ,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,KACzC,OAAO,CAAC,SAAS,CAInB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GACrB,eAAe,aAAa,EAC5B,QAAQ,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,KACzC,OAAO,CAAC,SAAS,CAEnB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GACpC,OAAO,MAAM,EACb,QAAQ,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,KACzC,OAAO,CAAC,SAAS,CAGnB,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**************************************************************************
|
|
2
|
+
* This file is generated by running 🏕️ scripts/generate_sdk_index.sh 🏕️ *
|
|
3
|
+
**************************************************************************/
|
|
4
|
+
export * from './TownsSyncProvider';
|
|
5
|
+
export * from './connectTowns';
|
|
6
|
+
export * from './useAdminRedact';
|
|
7
|
+
export * from './useAgentConnection';
|
|
8
|
+
export * from './useChannel';
|
|
9
|
+
export * from './useCreateChannel';
|
|
10
|
+
export * from './useCreateDm';
|
|
11
|
+
export * from './useCreateGdm';
|
|
12
|
+
export * from './useCreateSpace';
|
|
13
|
+
export * from './useDm';
|
|
14
|
+
export * from './useGdm';
|
|
15
|
+
export * from './useJoinSpace';
|
|
16
|
+
export * from './useMember';
|
|
17
|
+
export * from './useMemberList';
|
|
18
|
+
export * from './useMyMember';
|
|
19
|
+
export * from './useObservable';
|
|
20
|
+
export * from './useReactions';
|
|
21
|
+
export * from './useRedact';
|
|
22
|
+
export * from './useScrollback';
|
|
23
|
+
export * from './useSendMessage';
|
|
24
|
+
export * from './useSendReaction';
|
|
25
|
+
export * from './useSpace';
|
|
26
|
+
export * from './useSyncAgent';
|
|
27
|
+
export * from './useThreads';
|
|
28
|
+
export * from './useTimeline';
|
|
29
|
+
export * from './useTowns';
|
|
30
|
+
export * from './useTownsAuthStatus';
|
|
31
|
+
export * from './useUserDms';
|
|
32
|
+
export * from './useUserGdms';
|
|
33
|
+
export * from './useUserSpaces';
|
|
34
|
+
export * from './utils';
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;4EAE4E;AAC5E,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,sBAAsB,CAAA;AACpC,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SyncAgent } from '@towns-labs/sdk';
|
|
2
|
+
type TownsSyncContextProps = {
|
|
3
|
+
syncAgent: SyncAgent | undefined;
|
|
4
|
+
setSyncAgent: (syncAgent: SyncAgent | undefined) => void;
|
|
5
|
+
config?: {
|
|
6
|
+
onTokenExpired?: () => void;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare const TownsSyncContext: import("react").Context<TownsSyncContextProps | undefined>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=TownsSyncContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TownsSyncContext.d.ts","sourceRoot":"","sources":["../../../src/internals/TownsSyncContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAG3C,KAAK,qBAAqB,GAAG;IACzB,SAAS,EAAE,SAAS,GAAG,SAAS,CAAA;IAChC,YAAY,EAAE,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAA;IACxD,MAAM,CAAC,EAAE;QACL,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;KAC9B,CAAA;CACJ,CAAA;AACD,eAAO,MAAM,gBAAgB,4DAA8D,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for an action.
|
|
3
|
+
* It can be used to configure the behavior of the useAction hook.
|
|
4
|
+
*/
|
|
5
|
+
export type ActionConfig<Action> = {
|
|
6
|
+
/** Callback function to be called when an error occurs while executing the action. */
|
|
7
|
+
onError?: (err: Error) => void;
|
|
8
|
+
/** Callback function to be called when the action is successful. */
|
|
9
|
+
onSuccess?: (data: ReturnOf<Action>) => void;
|
|
10
|
+
};
|
|
11
|
+
type MultipleParams<T> = T extends unknown[] ? T : [T];
|
|
12
|
+
type ActionFn<T> = T extends (...args: infer Args) => Promise<infer Return> ? (...args: Args) => Promise<Return> : never;
|
|
13
|
+
type ParamsOf<T> = Parameters<ActionFn<T>>;
|
|
14
|
+
type ReturnOf<T> = Awaited<ReturnType<ActionFn<T>>>;
|
|
15
|
+
/**
|
|
16
|
+
* Hook to create an action from a namespace.
|
|
17
|
+
* @internal
|
|
18
|
+
* @param namespace - The namespace to create the action from.
|
|
19
|
+
* @param fnName - The name of the action to create. Example: `Namespace.fnName`
|
|
20
|
+
* @param config - Configuration options for the action.
|
|
21
|
+
* @returns The action and its loading state.
|
|
22
|
+
*/
|
|
23
|
+
export declare const useAction: <Namespace, Key extends keyof Namespace, Fn extends Namespace[Key]>(namespace: Namespace | undefined, fnName: Key & string, config?: ActionConfig<Fn>) => {
|
|
24
|
+
/** The action to execute. */
|
|
25
|
+
action: (...args: MultipleParams<ParamsOf<Fn>>) => Promise<ReturnOf<Fn>>;
|
|
26
|
+
/** The data returned by the action. */
|
|
27
|
+
data: Awaited<ReturnType<ActionFn<Fn>>> | undefined;
|
|
28
|
+
/** The error that occurred while executing the action. */
|
|
29
|
+
error: Error | undefined;
|
|
30
|
+
/** Whether the action is pending. */
|
|
31
|
+
isPending: boolean;
|
|
32
|
+
/** Whether the action is successful. */
|
|
33
|
+
isSuccess: boolean;
|
|
34
|
+
/** Whether the action is in error. */
|
|
35
|
+
isError: boolean;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=useAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAction.d.ts","sourceRoot":"","sources":["../../../src/internals/useAction.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,MAAM,IAAI;IAC/B,sFAAsF;IACtF,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAA;IAC9B,oEAAoE;IACpE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,IAAI,CAAA;CAC/C,CAAA;AAED,KAAK,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAEtD,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,IAAI,KAAK,OAAO,CAAC,MAAM,MAAM,CAAC,GACrE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,GAClC,KAAK,CAAA;AAEX,KAAK,QAAQ,CAAC,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;AAC1C,KAAK,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAEnD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,SAAS,EAAE,GAAG,SAAS,MAAM,SAAS,EAAE,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EACvF,WAAW,SAAS,GAAG,SAAS,EAChC,QAAQ,GAAG,GAAG,MAAM,EACpB,SAAS,YAAY,CAAC,EAAE,CAAC;IAqCrB,6BAA6B;sBA9Bb,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAgCpE,uCAAuC;;IAEvC,0DAA0D;;IAE1D,qCAAqC;;IAErC,wCAAwC;;IAExC,sCAAsC;;CAG7C,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const useTownsSync: () => {
|
|
2
|
+
syncAgent: import("@towns-labs/sdk").SyncAgent | undefined;
|
|
3
|
+
setSyncAgent: (syncAgent: import("@towns-labs/sdk").SyncAgent | undefined) => void;
|
|
4
|
+
config?: {
|
|
5
|
+
onTokenExpired?: () => void;
|
|
6
|
+
};
|
|
7
|
+
} | undefined;
|
|
8
|
+
//# sourceMappingURL=useTownsSync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTownsSync.d.ts","sourceRoot":"","sources":["../../../src/internals/useTownsSync.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY;;;;sBACwE,CAAC;;aADpC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/internals/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErD,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,KAAG,KAAK,IAAI,cAAc,CAAC,CAAC,CAQ3F,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Channel } from '@towns-labs/sdk';
|
|
2
|
+
import { type ActionConfig } from './internals/useAction';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to redact any message in a channel if you're an admin.
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ### Redact a message
|
|
8
|
+
*
|
|
9
|
+
* You can use `adminRedact` to redact a message in a stream.
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { useAdminRedact } from '@towns-labs/react-sdk'
|
|
12
|
+
*
|
|
13
|
+
* const { adminRedact } = useAdminRedact(streamId)
|
|
14
|
+
* adminRedact({ 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 useAdminRedact: (streamId: string, config?: ActionConfig<Channel["adminRedact"]>) => {
|
|
31
|
+
data: {
|
|
32
|
+
eventId: string;
|
|
33
|
+
} | undefined;
|
|
34
|
+
error: Error | undefined;
|
|
35
|
+
isPending: boolean;
|
|
36
|
+
isSuccess: boolean;
|
|
37
|
+
isError: boolean;
|
|
38
|
+
adminRedact: (eventId: string) => Promise<{
|
|
39
|
+
eventId: string;
|
|
40
|
+
}>;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=useAdminRedact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAdminRedact.d.ts","sourceRoot":"","sources":["../../src/useAdminRedact.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAiB,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,uBAAuB,CAAA;AAIpE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,EAAE,SAAS,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;;;;;;;;;;;CAU7F,CAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { SyncAgentConfig } from '@towns-labs/sdk';
|
|
2
|
+
import type { ethers } from 'ethers';
|
|
3
|
+
type AgentConnectConfig = Omit<SyncAgentConfig, 'context' | 'onTokenExpired'>;
|
|
4
|
+
/**
|
|
5
|
+
* Hook for managing the connection to the sync agent
|
|
6
|
+
*
|
|
7
|
+
* @example You can connect the Sync Agent to Towns Protocol using a Bearer Token or using a Signer.
|
|
8
|
+
*
|
|
9
|
+
* ### Bearer Token
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { useAgentConnection } from '@towns-labs/react-sdk'
|
|
12
|
+
* import { townsEnv } from '@towns-labs/sdk'
|
|
13
|
+
* import { useState } from 'react'
|
|
14
|
+
*
|
|
15
|
+
* const townsConfig = townsEnv().makeTownsConfig('beta')
|
|
16
|
+
*
|
|
17
|
+
* const Login = () => {
|
|
18
|
+
* const { connectUsingBearerToken, isAgentConnecting, isAgentConnected } = useAgentConnection()
|
|
19
|
+
* const [bearerToken, setBearerToken] = useState('')
|
|
20
|
+
*
|
|
21
|
+
* return (
|
|
22
|
+
* <>
|
|
23
|
+
* <input value={bearerToken} onChange={(e) => setBearerToken(e.target.value)} />
|
|
24
|
+
* <button onClick={() => connectUsingBearerToken(bearerToken, { townsConfig })}>
|
|
25
|
+
* Login
|
|
26
|
+
* </button>
|
|
27
|
+
* {isAgentConnecting && <span>Connecting... ⏳</span>}
|
|
28
|
+
* {isAgentConnected && <span>Connected ✅</span>}
|
|
29
|
+
* </>
|
|
30
|
+
* )
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* ### Signer
|
|
35
|
+
*
|
|
36
|
+
* If you're using Wagmi and Viem, you can use the [`useEthersSigner`](https://wagmi.sh/react/guides/ethers#usage-1) hook to get an ethers.js v5 Signer from a Viem Wallet Client.
|
|
37
|
+
*
|
|
38
|
+
* ```tsx
|
|
39
|
+
* import { useAgentConnection } from '@towns-labs/react-sdk'
|
|
40
|
+
* import { townsEnv } from '@towns-labs/sdk'
|
|
41
|
+
* import { useEthersSigner } from './utils/viem-to-ethers'
|
|
42
|
+
*
|
|
43
|
+
* const townsConfig = townsEnv().makeTownsConfig('beta')
|
|
44
|
+
*
|
|
45
|
+
* const Login = () => {
|
|
46
|
+
* const { connect, isAgentConnecting, isAgentConnected } = useAgentConnection()
|
|
47
|
+
* const signer = useEthersSigner()
|
|
48
|
+
*
|
|
49
|
+
* return (
|
|
50
|
+
* <>
|
|
51
|
+
* <button onClick={async () => {
|
|
52
|
+
* if (!signer) {
|
|
53
|
+
* return
|
|
54
|
+
* }
|
|
55
|
+
* connect(signer, { townsConfig })
|
|
56
|
+
* }}>
|
|
57
|
+
* Login
|
|
58
|
+
* </button>
|
|
59
|
+
* {isAgentConnecting && <span>Connecting... ⏳</span>}
|
|
60
|
+
* {isAgentConnected && <span>Connected ✅</span>}
|
|
61
|
+
* </>
|
|
62
|
+
* )
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @returns The connection state and methods (connect, connectUsingBearerToken, disconnect)
|
|
67
|
+
*/
|
|
68
|
+
export declare const useAgentConnection: () => {
|
|
69
|
+
/** Connect to Towns Protocol using a Signer */
|
|
70
|
+
connect: (signer: ethers.Signer, config: AgentConnectConfig) => Promise<import("@towns-labs/sdk").SyncAgent | undefined>;
|
|
71
|
+
/** Connect to Towns Protocol using a Bearer Token */
|
|
72
|
+
connectUsingBearerToken: (bearerToken: string, config: AgentConnectConfig) => Promise<import("@towns-labs/sdk").SyncAgent | undefined>;
|
|
73
|
+
/** Disconnect from Towns Protocol */
|
|
74
|
+
disconnect: () => void | undefined;
|
|
75
|
+
/** Whether the agent is currently connecting */
|
|
76
|
+
isAgentConnecting: boolean;
|
|
77
|
+
/** Whether the agent is connected */
|
|
78
|
+
isAgentConnected: boolean;
|
|
79
|
+
/** The environment of the current connection (beta, omega, alpha, local_dev, etc.) */
|
|
80
|
+
env: string | undefined;
|
|
81
|
+
};
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=useAgentConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAgentConnection.d.ts","sourceRoot":"","sources":["../../src/useAgentConnection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAIpC,KAAK,kBAAkB,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,gBAAgB,CAAC,CAAA;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,eAAO,MAAM,kBAAkB;IAyDvB,+CAA+C;sBApDhC,MAAM,CAAC,MAAM,UAAU,kBAAkB;IAsDxD,qDAAqD;2CA9BjC,MAAM,UAAU,kBAAkB;IAgCtD,qCAAqC;;IAErC,gDAAgD;;IAEhD,qCAAqC;;IAErC,sFAAsF;;CAG7F,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Channel } from '@towns-labs/sdk';
|
|
2
|
+
import { type ObservableConfig } from './useObservable';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get data about a channel.
|
|
5
|
+
* You can use this hook to get channel metadata and if the user has joined the channel.
|
|
6
|
+
* @param spaceId - The id of the space the channel belongs to.
|
|
7
|
+
* @param channelId - The id of the channel to get data about.
|
|
8
|
+
* @param config - Configuration options for the observable.
|
|
9
|
+
* @returns The ChannelModel data.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useChannel: (spaceId: string, channelId: string, config?: ObservableConfig.FromObservable<Channel>) => import("./useObservable").ObservableValue<import("@towns-labs/sdk").ChannelModel>;
|
|
12
|
+
//# sourceMappingURL=useChannel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChannel.d.ts","sourceRoot":"","sources":["../../src/useChannel.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,iBAAiB,CAAA;AAEtE;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACnB,SAAS,MAAM,EACf,WAAW,MAAM,EACjB,SAAS,gBAAgB,CAAC,cAAc,CAAC,OAAO,CAAC,sFAQpD,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Space } from '@towns-labs/sdk';
|
|
2
|
+
import { type ActionConfig } from './internals/useAction';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to create a channel.
|
|
5
|
+
* @param config - Configuration options for the action.
|
|
6
|
+
* @returns The `createChannel` action and its loading state.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useCreateChannel: (spaceId: string, config?: ActionConfig<Space["createChannel"]>) => {
|
|
9
|
+
data: string | undefined;
|
|
10
|
+
error: Error | undefined;
|
|
11
|
+
isPending: boolean;
|
|
12
|
+
isSuccess: boolean;
|
|
13
|
+
isError: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Action to create a channel.
|
|
16
|
+
* @param name - The name of the channel to create.
|
|
17
|
+
* @param signer - The signer to use to create the channel.
|
|
18
|
+
*/
|
|
19
|
+
createChannel: (channelName: string, signer: import("ethers").Signer, opts?: {
|
|
20
|
+
topic?: string;
|
|
21
|
+
} | undefined) => Promise<string>;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=useCreateChannel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCreateChannel.d.ts","sourceRoot":"","sources":["../../src/useCreateChannel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,uBAAuB,CAAA;AAGpE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GACzB,SAAS,MAAM,EACf,SAAS,YAAY,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;;;;;;IAOzC;;;;OAIG;;;;CAIV,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Dms } from '@towns-labs/sdk';
|
|
2
|
+
import { type ActionConfig } from './internals/useAction';
|
|
3
|
+
/**
|
|
4
|
+
* A hook that allows you to create a new direct message (DM).
|
|
5
|
+
* @param config - The action config.
|
|
6
|
+
* @returns An object containing the `createDM` action and the rest of the action result.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useCreateDm: (config?: ActionConfig<Dms["createDM"]>) => {
|
|
9
|
+
data: {
|
|
10
|
+
streamId: string;
|
|
11
|
+
} | undefined;
|
|
12
|
+
error: Error | undefined;
|
|
13
|
+
isPending: boolean;
|
|
14
|
+
isSuccess: boolean;
|
|
15
|
+
isError: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new DM.
|
|
18
|
+
* @param userId - The `userId` of the user to create a DM with.
|
|
19
|
+
* @returns A promise that resolves to the result of the create operation.
|
|
20
|
+
*/
|
|
21
|
+
createDM: (userId: string, appAddress?: string | undefined, streamSettings?: {
|
|
22
|
+
disableMiniblockCreation: boolean;
|
|
23
|
+
lightStream: boolean;
|
|
24
|
+
} | undefined) => Promise<{
|
|
25
|
+
streamId: string;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=useCreateDm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCreateDm.d.ts","sourceRoot":"","sources":["../../src/useCreateDm.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,uBAAuB,CAAA;AAGpE;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;;;;;;;;IAK1D;;;;OAIG;;;;;;;CAIV,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Gdms } from '@towns-labs/sdk';
|
|
2
|
+
import { type ActionConfig } from './internals/useAction';
|
|
3
|
+
/**
|
|
4
|
+
* A hook that allows you to create a new group direct message (GDM).
|
|
5
|
+
* @param config - The action config.
|
|
6
|
+
* @returns An object containing the `createGDM` action and the rest of the action result.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useCreateGdm: (config?: ActionConfig<Gdms["createGDM"]>) => {
|
|
9
|
+
data: {
|
|
10
|
+
streamId: string;
|
|
11
|
+
} | undefined;
|
|
12
|
+
error: Error | undefined;
|
|
13
|
+
isPending: boolean;
|
|
14
|
+
isSuccess: boolean;
|
|
15
|
+
isError: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new GDM.
|
|
18
|
+
* @param userIds - The `userIds` of the users to invite to the GDM.
|
|
19
|
+
* @returns A promise that resolves to the result of the create operation.
|
|
20
|
+
*/
|
|
21
|
+
createGDM: (users: {
|
|
22
|
+
userId: string;
|
|
23
|
+
appAddress?: string;
|
|
24
|
+
}[], channelProperties?: import("@towns-labs/proto").EncryptedData | undefined, streamSettings?: {
|
|
25
|
+
disableMiniblockCreation: boolean;
|
|
26
|
+
lightStream: boolean;
|
|
27
|
+
} | undefined) => Promise<{
|
|
28
|
+
streamId: string;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=useCreateGdm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCreateGdm.d.ts","sourceRoot":"","sources":["../../src/useCreateGdm.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,uBAAuB,CAAA;AAGpE;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;;;;;;;;IAK7D;;;;OAIG;;;;;;;;;;CAIV,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Spaces } from '@towns-labs/sdk';
|
|
2
|
+
import { type ActionConfig } from './internals/useAction';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to create a space.
|
|
5
|
+
* @param config - Configuration options for the action.
|
|
6
|
+
* @returns The `createSpace` action and its loading state.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useCreateSpace: (config?: ActionConfig<Spaces["createSpace"]>) => {
|
|
9
|
+
data: {
|
|
10
|
+
spaceId: string;
|
|
11
|
+
defaultChannelId: string;
|
|
12
|
+
} | undefined;
|
|
13
|
+
error: Error | undefined;
|
|
14
|
+
isPending: boolean;
|
|
15
|
+
isSuccess: boolean;
|
|
16
|
+
isError: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Action to create a space.
|
|
19
|
+
* @param opts - Options for the create space action.
|
|
20
|
+
* @param signer - The signer used to create the space.
|
|
21
|
+
*/
|
|
22
|
+
createSpace: (params: Partial<Omit<import("@towns-labs/web3").CreateSpaceParams, "spaceName">> & {
|
|
23
|
+
spaceName: string;
|
|
24
|
+
}, signer: import("ethers").Signer) => Promise<{
|
|
25
|
+
spaceId: string;
|
|
26
|
+
defaultChannelId: string;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=useCreateSpace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCreateSpace.d.ts","sourceRoot":"","sources":["../../src/useCreateSpace.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,cAAc,GAAI,SAAQ,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,CAAM;;;;;;;;;IAKvE;;;;OAIG;;;;;;;CAIV,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DmModel } from '@towns-labs/sdk';
|
|
2
|
+
import { type ObservableConfig } from './useObservable';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the data of a DM.
|
|
5
|
+
* You can use this hook to get DM metadata and if the user has joined the DM.
|
|
6
|
+
* @param streamId - The id of the DM to get the data of.
|
|
7
|
+
* @param config - Configuration options for the observable.
|
|
8
|
+
* @returns The DmModel of the DM.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useDm: (streamId: string, config?: ObservableConfig.FromData<DmModel>) => import("./useObservable").ObservableValue<DmModel>;
|
|
11
|
+
//# sourceMappingURL=useDm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDm.d.ts","sourceRoot":"","sources":["../../src/useDm.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,iBAAiB,CAAA;AAEtE;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,UAAU,MAAM,EAAE,SAAS,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,uDAIlF,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GdmModel } from '@towns-labs/sdk';
|
|
2
|
+
import { type ObservableConfig } from './useObservable';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the data of a Group DM.
|
|
5
|
+
* You can use this hook to get Group DM metadata and if the user has joined the Group DM.
|
|
6
|
+
* @param streamId - The id of the Group DM to get the data of.
|
|
7
|
+
* @param config - Configuration options for the observable.
|
|
8
|
+
* @returns The GdmModel of the Group DM.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useGdm: (streamId: string, config?: ObservableConfig.FromData<GdmModel>) => import("./useObservable").ObservableValue<GdmModel>;
|
|
11
|
+
//# sourceMappingURL=useGdm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGdm.d.ts","sourceRoot":"","sources":["../../src/useGdm.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,iBAAiB,CAAA;AAEtE;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,GAAI,UAAU,MAAM,EAAE,SAAS,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,wDAIpF,CAAA"}
|