@stream-io/feeds-client 0.3.32 → 0.3.34

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +3 -2
  3. package/dist/cjs/index.js +3 -2
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/react-bindings.js +40 -36
  6. package/dist/cjs/react-bindings.js.map +1 -1
  7. package/dist/es/index.mjs +4 -3
  8. package/dist/es/index.mjs.map +1 -1
  9. package/dist/es/react-bindings.mjs +40 -36
  10. package/dist/es/react-bindings.mjs.map +1 -1
  11. package/dist/{feeds-client-BNhvggk2.mjs → feeds-client-C-2_fdH1.mjs} +229 -209
  12. package/dist/feeds-client-C-2_fdH1.mjs.map +1 -0
  13. package/dist/{feeds-client-B9rwEWH3.js → feeds-client-Xj6kDjVH.js} +229 -209
  14. package/dist/feeds-client-Xj6kDjVH.js.map +1 -0
  15. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  16. package/dist/types/activity-with-state-updates/activity-with-state-updates.d.ts +4 -2
  17. package/dist/types/activity-with-state-updates/activity-with-state-updates.d.ts.map +1 -1
  18. package/dist/types/bindings/react/hooks/feed-state-hooks/index.d.ts +1 -0
  19. package/dist/types/bindings/react/hooks/feed-state-hooks/index.d.ts.map +1 -1
  20. package/dist/types/bindings/react/hooks/feed-state-hooks/useOwnCapabilities.d.ts.map +1 -1
  21. package/dist/types/bindings/react/hooks/feed-state-hooks/useOwnFollowings.d.ts +8 -0
  22. package/dist/types/bindings/react/hooks/feed-state-hooks/useOwnFollowings.d.ts.map +1 -0
  23. package/dist/types/bindings/react/hooks/useCreateFeedsClient.d.ts.map +1 -1
  24. package/dist/types/common/types.d.ts +1 -1
  25. package/dist/types/common/types.d.ts.map +1 -1
  26. package/dist/types/feed/event-handlers/activity/handle-activity-added.d.ts.map +1 -1
  27. package/dist/types/feed/event-handlers/activity/handle-activity-updated.d.ts.map +1 -1
  28. package/dist/types/feed/feed.d.ts +2 -1
  29. package/dist/types/feed/feed.d.ts.map +1 -1
  30. package/dist/types/feeds-client/active-activity.d.ts +2 -1
  31. package/dist/types/feeds-client/active-activity.d.ts.map +1 -1
  32. package/dist/types/feeds-client/feeds-client.d.ts +14 -12
  33. package/dist/types/feeds-client/feeds-client.d.ts.map +1 -1
  34. package/dist/types/utils/check-own-fields-equality.d.ts +2 -0
  35. package/dist/types/utils/check-own-fields-equality.d.ts.map +1 -1
  36. package/dist/types/utils/throttling/index.d.ts +1 -1
  37. package/dist/types/utils/throttling/index.d.ts.map +1 -1
  38. package/dist/types/utils/throttling/throttled-get-batched-own-fields.d.ts +14 -0
  39. package/dist/types/utils/throttling/throttled-get-batched-own-fields.d.ts.map +1 -0
  40. package/package.json +1 -1
  41. package/src/activity-with-state-updates/activity-with-state-updates.ts +17 -3
  42. package/src/bindings/react/hooks/feed-state-hooks/index.ts +1 -0
  43. package/src/bindings/react/hooks/feed-state-hooks/useOwnCapabilities.ts +14 -23
  44. package/src/bindings/react/hooks/feed-state-hooks/useOwnFollowings.ts +18 -0
  45. package/src/bindings/react/hooks/useCreateFeedsClient.ts +1 -3
  46. package/src/common/types.ts +1 -1
  47. package/src/feed/event-handlers/activity/handle-activity-added.ts +0 -6
  48. package/src/feed/event-handlers/activity/handle-activity-updated.ts +0 -4
  49. package/src/feed/feed.ts +53 -39
  50. package/src/feeds-client/active-activity.ts +8 -4
  51. package/src/feeds-client/feeds-client.ts +110 -114
  52. package/src/utils/check-own-fields-equality.ts +37 -10
  53. package/src/utils/throttling/index.ts +1 -1
  54. package/src/utils/throttling/{throttled-get-batched-own-capabilities.ts → throttled-get-batched-own-fields.ts} +10 -10
  55. package/dist/feeds-client-B9rwEWH3.js.map +0 -1
  56. package/dist/feeds-client-BNhvggk2.mjs.map +0 -1
  57. package/dist/types/utils/throttling/throttled-get-batched-own-capabilities.d.ts +0 -14
  58. package/dist/types/utils/throttling/throttled-get-batched-own-capabilities.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { useStateStore } from "@stream-io/state-store/react-bindings";
2
2
  export * from "@stream-io/state-store/react-bindings";
3
3
  import { useState, useEffect, createContext, useContext, useRef, useCallback, useMemo } from "react";
4
- import { F as FeedsClient, g as isCommentResponse, c as checkHasAnotherPage } from "../feeds-client-BNhvggk2.mjs";
4
+ import { F as FeedsClient, g as isCommentResponse, c as checkHasAnotherPage } from "../feeds-client-C-2_fdH1.mjs";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  const useCreateFeedsClient = ({
7
7
  apiKey,
@@ -9,9 +9,7 @@ const useCreateFeedsClient = ({
9
9
  userData,
10
10
  options
11
11
  }) => {
12
- const [client, setClient] = useState(
13
- () => new FeedsClient(apiKey, options)
14
- );
12
+ const [client, setClient] = useState(null);
15
13
  const [error, setError] = useState(null);
16
14
  const [cachedUserData, setCachedUserData] = useState(userData);
17
15
  const [cachedOptions] = useState(options);
@@ -47,18 +45,18 @@ const useFeedsClient = () => {
47
45
  };
48
46
  const useClientConnectedUser = () => {
49
47
  const client = useFeedsClient();
50
- const { user } = useStateStore(client?.state, selector$b) ?? {};
48
+ const { user } = useStateStore(client?.state, selector$d) ?? {};
51
49
  return user;
52
50
  };
53
- const selector$b = (nextState) => ({
51
+ const selector$d = (nextState) => ({
54
52
  user: nextState.connected_user
55
53
  });
56
54
  const useWsConnectionState = () => {
57
55
  const client = useFeedsClient();
58
- const { is_healthy } = useStateStore(client?.state, selector$a) ?? {};
56
+ const { is_healthy } = useStateStore(client?.state, selector$c) ?? {};
59
57
  return { is_healthy };
60
58
  };
61
- const selector$a = (nextState) => ({
59
+ const selector$c = (nextState) => ({
62
60
  is_healthy: nextState.is_ws_connection_healthy
63
61
  });
64
62
  const StreamFeedContext = createContext(void 0);
@@ -75,7 +73,7 @@ const useStableCallback = (callback) => {
75
73
  const useFeedActivities = (feedFromProps) => {
76
74
  const feedFromContext = useFeedContext();
77
75
  const feed = feedFromProps ?? feedFromContext;
78
- const data = useStateStore(feed?.state, selector$9);
76
+ const data = useStateStore(feed?.state, selector$b);
79
77
  const loadNextPage = useStableCallback(async () => {
80
78
  if (!feed || !data?.has_next_page || data?.is_loading) {
81
79
  return;
@@ -84,7 +82,7 @@ const useFeedActivities = (feedFromProps) => {
84
82
  });
85
83
  return useMemo(() => ({ ...data, loadNextPage }), [data, loadNextPage]);
86
84
  };
87
- const selector$9 = ({
85
+ const selector$b = ({
88
86
  is_loading_activities,
89
87
  next,
90
88
  activities = []
@@ -133,26 +131,23 @@ function useComments({
133
131
  }, [data, loadNextPage]);
134
132
  }
135
133
  const stableEmptyArray = [];
134
+ const selector$a = (currentState) => {
135
+ return {
136
+ feedOwnCapabilities: currentState.own_capabilities ?? stableEmptyArray
137
+ };
138
+ };
136
139
  const useOwnCapabilities = (feedFromProps) => {
137
140
  const client = useFeedsClient();
138
141
  const feedFromContext = useFeedContext();
139
- const feed = feedFromProps ?? feedFromContext;
140
- const fid = typeof feed === "string" ? feed : feed?.feed;
141
- const selector2 = useCallback(
142
- (currentState) => {
143
- if (!fid) {
144
- return { feedOwnCapabilities: stableEmptyArray };
145
- }
146
- return {
147
- feedOwnCapabilities: currentState.own_capabilities_by_fid[fid] ?? stableEmptyArray
148
- };
149
- },
150
- [fid]
151
- );
152
- const { feedOwnCapabilities = stableEmptyArray } = useStateStore(client?.state, selector2) ?? {};
142
+ let feed = feedFromProps ?? feedFromContext;
143
+ if (typeof feed === "string") {
144
+ const [groupId, id] = feed.split(":");
145
+ feed = groupId && id ? client?.feed(groupId, id) : void 0;
146
+ }
147
+ const { feedOwnCapabilities = stableEmptyArray } = useStateStore(feed?.state, selector$a) ?? {};
153
148
  return feedOwnCapabilities;
154
149
  };
155
- const selector$8 = ({
150
+ const selector$9 = ({
156
151
  follower_count,
157
152
  followers,
158
153
  followers_pagination
@@ -164,7 +159,7 @@ const selector$8 = ({
164
159
  function useFollowers(feedFromProps) {
165
160
  const feedFromContext = useFeedContext();
166
161
  const feed = feedFromProps ?? feedFromContext;
167
- const data = useStateStore(feed?.state, selector$8);
162
+ const data = useStateStore(feed?.state, selector$9);
168
163
  const loadNextPage = useCallback(
169
164
  (...options) => feed?.loadNextPageFollowers(...options),
170
165
  [feed]
@@ -184,7 +179,7 @@ function useFollowers(feedFromProps) {
184
179
  };
185
180
  }, [data, loadNextPage]);
186
181
  }
187
- const selector$7 = ({
182
+ const selector$8 = ({
188
183
  following_count,
189
184
  following,
190
185
  following_pagination
@@ -196,7 +191,7 @@ const selector$7 = ({
196
191
  function useFollowing(feedFromProps) {
197
192
  const feedFromContext = useFeedContext();
198
193
  const feed = feedFromProps ?? feedFromContext;
199
- const data = useStateStore(feed?.state, selector$7);
194
+ const data = useStateStore(feed?.state, selector$8);
200
195
  const loadNextPage = useCallback(
201
196
  (...options) => feed?.loadNextPageFollowing(...options),
202
197
  [feed]
@@ -219,9 +214,9 @@ function useFollowing(feedFromProps) {
219
214
  const useFeedMetadata = (feedFromProps) => {
220
215
  const feedFromContext = useFeedContext();
221
216
  const feed = feedFromProps ?? feedFromContext;
222
- return useStateStore(feed?.state, selector$6);
217
+ return useStateStore(feed?.state, selector$7);
223
218
  };
224
- const selector$6 = ({
219
+ const selector$7 = ({
225
220
  follower_count = 0,
226
221
  following_count = 0,
227
222
  created_by,
@@ -237,12 +232,12 @@ const selector$6 = ({
237
232
  const useOwnFollows = (feedFromProps) => {
238
233
  const feedFromContext = useFeedContext();
239
234
  const feed = feedFromProps ?? feedFromContext;
240
- return useStateStore(feed?.state, selector$5);
235
+ return useStateStore(feed?.state, selector$6);
241
236
  };
242
- const selector$5 = ({ own_follows }) => ({
237
+ const selector$6 = ({ own_follows }) => ({
243
238
  own_follows
244
239
  });
245
- const selector$4 = ({ notification_status }) => ({
240
+ const selector$5 = ({ notification_status }) => ({
246
241
  unread: notification_status?.unread ?? 0,
247
242
  unseen: notification_status?.unseen ?? 0,
248
243
  last_read_at: notification_status?.last_read_at,
@@ -253,9 +248,9 @@ const selector$4 = ({ notification_status }) => ({
253
248
  function useNotificationStatus(feedFromProps) {
254
249
  const feedFromContext = useFeedContext();
255
250
  const feed = feedFromProps ?? feedFromContext;
256
- return useStateStore(feed?.state, selector$4);
251
+ return useStateStore(feed?.state, selector$5);
257
252
  }
258
- const selector$3 = ({
253
+ const selector$4 = ({
259
254
  is_loading_activities,
260
255
  next,
261
256
  aggregated_activities = []
@@ -267,7 +262,7 @@ const selector$3 = ({
267
262
  function useAggregatedActivities(feedFromProps) {
268
263
  const feedFromContext = useFeedContext();
269
264
  const feed = feedFromProps ?? feedFromContext;
270
- const data = useStateStore(feed?.state, selector$3);
265
+ const data = useStateStore(feed?.state, selector$4);
271
266
  const loadNextPage = useStableCallback(async () => {
272
267
  if (!feed || !data?.has_next_page || data?.is_loading) {
273
268
  return;
@@ -368,6 +363,14 @@ function useActivityComments({
368
363
  };
369
364
  }, [data, loadNextPage]);
370
365
  }
366
+ const useOwnFollowings = (feedFromProps) => {
367
+ const feedFromContext = useFeedContext();
368
+ const feed = feedFromProps ?? feedFromContext;
369
+ return useStateStore(feed?.state, selector$3);
370
+ };
371
+ const selector$3 = ({ own_followings }) => ({
372
+ own_followings
373
+ });
371
374
  const StreamSearchResultsContext = createContext(void 0);
372
375
  const useSearchResultsContext = () => {
373
376
  return useContext(StreamSearchResultsContext);
@@ -466,6 +469,7 @@ export {
466
469
  useIsAggregatedActivitySeen,
467
470
  useNotificationStatus,
468
471
  useOwnCapabilities,
472
+ useOwnFollowings,
469
473
  useOwnFollows,
470
474
  useSearchContext,
471
475
  useSearchQuery,
@@ -1 +1 @@
1
- {"version":3,"file":"react-bindings.mjs","sources":["../../src/bindings/react/hooks/useCreateFeedsClient.ts","../../src/bindings/react/contexts/StreamFeedsContext.tsx","../../src/bindings/react/hooks/client-state-hooks/useClientConnectedUser.ts","../../src/bindings/react/hooks/client-state-hooks/useWsConnectionState.ts","../../src/bindings/react/contexts/StreamFeedContext.tsx","../../src/bindings/react/hooks/internal/useStableCallback.ts","../../src/bindings/react/hooks/feed-state-hooks/useFeedActivities.ts","../../src/bindings/react/hooks/feed-state-hooks/useComments.ts","../../src/bindings/react/hooks/feed-state-hooks/useOwnCapabilities.ts","../../src/bindings/react/hooks/feed-state-hooks/useFollowers.ts","../../src/bindings/react/hooks/feed-state-hooks/useFollowing.ts","../../src/bindings/react/hooks/feed-state-hooks/useFeedMetadata.ts","../../src/bindings/react/hooks/feed-state-hooks/useOwnFollows.ts","../../src/bindings/react/hooks/feed-state-hooks/useNotificationStatus.ts","../../src/bindings/react/hooks/feed-state-hooks/useAggregatedActivities.ts","../../src/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivityRead.ts","../../src/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivitySeen.ts","../../src/bindings/react/hooks/feed-state-hooks/useActivityComments.ts","../../src/bindings/react/contexts/StreamSearchResultsContext.tsx","../../src/bindings/react/hooks/search-state-hooks/useSearchResult.ts","../../src/bindings/react/contexts/StreamSearchContext.tsx","../../src/bindings/react/hooks/search-state-hooks/useSearchQuery.ts","../../src/bindings/react/hooks/search-state-hooks/useSearchSources.ts","../../src/bindings/react/wrappers/StreamFeeds.tsx","../../src/bindings/react/wrappers/StreamFeed.tsx","../../src/bindings/react/wrappers/StreamSearch.tsx","../../src/bindings/react/wrappers/StreamSearchResults.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { FeedsClient } from '../../../feeds-client';\nimport type { TokenOrProvider } from '../../../types';\nimport type { UserRequest } from '../../../gen/models';\nimport type { FeedsClientOptions } from '../../../common/types';\n\n/**\n * A React hook to create, connect and return an instance of `FeedsClient`.\n */\nexport const useCreateFeedsClient = ({\n apiKey,\n tokenOrProvider,\n userData,\n options,\n}: {\n apiKey: string;\n tokenOrProvider: TokenOrProvider;\n userData: UserRequest;\n options?: FeedsClientOptions;\n}) => {\n const [client, setClient] = useState<FeedsClient | null>(\n () => new FeedsClient(apiKey, options),\n );\n const [error, setError] = useState<Error | null>(null);\n const [cachedUserData, setCachedUserData] = useState(userData);\n\n const [cachedOptions] = useState(options);\n\n if (error) {\n throw error;\n }\n\n if (userData.id !== cachedUserData.id) {\n setCachedUserData(userData);\n }\n\n useEffect(() => {\n const _client = new FeedsClient(apiKey, cachedOptions);\n\n const connectionPromise = _client\n .connectUser(cachedUserData, tokenOrProvider)\n .then(() => {\n setError(null);\n })\n .catch((err) => {\n setError(err);\n });\n\n setClient(_client);\n\n return () => {\n setClient(null);\n connectionPromise\n .then(() => {\n setError(null);\n return _client.disconnectUser();\n })\n .catch((err) => {\n setError(err);\n });\n };\n }, [apiKey, cachedUserData, cachedOptions, tokenOrProvider]);\n\n return client;\n};\n","import { createContext, useContext } from 'react';\n\nimport type { FeedsClient } from '../../../feeds-client';\n\nexport const StreamFeedsContext = createContext<FeedsClient | undefined>(undefined);\n\n/**\n * The props for the StreamFeedsProvider component.\n */\nexport type StreamFeedsContextProps = {\n /**\n * The client instance to provide to the component tree.\n */\n client: FeedsClient;\n};\n\n/**\n * Hook to access the nearest FeedsClient instance.\n */\nexport const useFeedsClient = () => {\n return useContext(StreamFeedsContext);\n};\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedsClient } from '../../contexts/StreamFeedsContext';\nimport type { FeedsClientState } from '../../../../feeds-client';\n\n/**\n * A React hook that returns the currently connected user on a `FeedsClient` instance and null otherwise.\n */\nexport const useClientConnectedUser = () => {\n const client = useFeedsClient();\n\n const { user } = useStateStore(client?.state, selector) ?? {};\n\n return user;\n};\n\nconst selector = (nextState: FeedsClientState) => ({\n user: nextState.connected_user,\n});\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedsClient } from '../../contexts/StreamFeedsContext';\nimport type { FeedsClientState } from '../../../../feeds-client';\n\n/**\n * A React hook that returns the websocket connection state of `FeedsClient`.\n */\nexport const useWsConnectionState = () => {\n const client = useFeedsClient();\n\n const { is_healthy } = useStateStore(client?.state, selector) ?? {}\n\n return { is_healthy };\n};\n\nconst selector = (nextState: FeedsClientState) => ({\n is_healthy: nextState.is_ws_connection_healthy,\n});\n","import { createContext, useContext } from 'react';\n\nimport type { Feed } from '../../../feed';\n\nexport const StreamFeedContext = createContext<Feed | undefined>(undefined);\n\n/**\n * The props for the StreamFeedProvider component.\n */\nexport type StreamFeedContextProps = {\n feed: Feed;\n};\n\n/**\n * Hook to access the nearest Feed instance.\n */\nexport const useFeedContext = () => {\n return useContext(StreamFeedContext);\n};\n","import { useCallback, useRef } from 'react';\n\nexport type StableCallback<A extends unknown[], R> = (...args: A) => R;\n\n/**\n * A utility hook implementing a stable callback. It takes in an unstable method that\n * is supposed to be invoked somewhere deeper in the DOM tree without making it\n * change its reference every time the parent component rerenders. It will also return\n * the value of the callback if it does return one.\n * A common use-case would be having a function whose invocation depends on state\n * somewhere high up in the DOM tree and wanting to use the same function deeper\n * down, for example in a leaf node and simply using useCallback results in\n * cascading dependency hell. If we wrap it in useStableCallback, we would be able\n * to:\n * - Use the same function as a dependency of another hook (since it is stable)\n * - Still invoke it and get the latest state\n *\n * **Caveats:**\n * - Never wrap a function that is supposed to return a React.ReactElement in\n * useStableCallback, since React will not know that the DOM needs to be updated\n * whenever the callback value changes (for example, renderItem from FlatList must\n * never be wrapped in this hook)\n * - Always prefer using a standard useCallback/stable function wherever possible\n * (the purpose of useStableCallback is to bridge the gap between top level contexts\n * and cascading rereders in downstream components - **not** as an escape hatch)\n * @param callback - the callback we want to stabilize\n */\nexport const useStableCallback = <A extends unknown[], R>(\n callback: StableCallback<A, R>,\n): StableCallback<A, R> => {\n const ref = useRef(callback);\n ref.current = callback;\n\n return useCallback<StableCallback<A, R>>((...args) => {\n return ref.current(...args);\n }, []);\n};\n","import { useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { useStableCallback } from '../internal';\nimport type { Feed, FeedState } from '../../../../feed';\n\n/**\n * A React hook that returns a reactive object containing the current activities,\n * loading state and whether there is a next page to paginate to or not.\n */\nexport const useFeedActivities = (feedFromProps?: Feed) => {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const data = useStateStore(feed?.state, selector);\n\n const loadNextPage = useStableCallback(async () => {\n if (!feed || !data?.has_next_page || data?.is_loading) {\n return;\n }\n\n await feed.getNextPage();\n });\n\n return useMemo(() => ({ ...data, loadNextPage }), [data, loadNextPage]);\n};\n\nconst selector = ({\n is_loading_activities,\n next,\n activities = [],\n}: FeedState) => ({\n is_loading: is_loading_activities,\n has_next_page: typeof next !== 'undefined',\n activities,\n});\n","import { useCallback, useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { checkHasAnotherPage, isCommentResponse } from '../../../../utils';\nimport type { ActivityResponse, CommentResponse } from '../../../../gen/models';\nimport type { Feed, FeedState } from '../../../../feed';\nimport type { CommentParent } from '../../../../types';\n\ntype UseCommentsReturnType<T extends ActivityResponse | CommentResponse> = {\n comments: NonNullable<\n FeedState['comments_by_entity_id'][T['id']]\n >['comments'];\n comments_pagination: NonNullable<\n FeedState['comments_by_entity_id'][T['id']]\n >['pagination'];\n has_next_page: boolean;\n is_loading_next_page: boolean;\n loadNextPage: (\n request?: T extends CommentResponse\n ? Parameters<Feed['loadNextPageCommentReplies']>[1]\n : Parameters<Feed['loadNextPageActivityComments']>[1],\n ) => Promise<void>;\n};\n\n/**\n * @deprecated Use `useActivityComments` instead.\n * @param\n */\nexport function useComments<T extends CommentParent>(_: {\n feed: Feed;\n parent: T;\n}): UseCommentsReturnType<T>;\nexport function useComments<T extends CommentParent>(_: {\n feed?: Feed;\n parent: T;\n}): UseCommentsReturnType<T> | undefined;\nexport function useComments<T extends CommentParent>({\n feed: feedFromProps,\n parent,\n}: {\n feed?: Feed;\n /**\n * The parent (activity or comment) for which to fetch comments.\n */\n parent: T;\n}) {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const selector = useCallback(\n (state: FeedState) => ({\n comments: state.comments_by_entity_id?.[parent.id]?.comments,\n comments_pagination: state.comments_by_entity_id?.[parent.id]?.pagination,\n }),\n [parent.id],\n );\n\n const data = useStateStore(feed?.state, selector);\n\n const loadNextPage = useMemo<\n UseCommentsReturnType<T>['loadNextPage'] | undefined\n >(() => {\n if (!feed) return undefined;\n\n return (request) => {\n if (isCommentResponse(parent)) {\n return feed.loadNextPageCommentReplies(parent, request);\n } else {\n return feed.loadNextPageActivityComments(parent, request);\n }\n };\n }, [feed, parent]);\n\n return useMemo(() => {\n if (!data) {\n return undefined;\n }\n\n return {\n ...data,\n has_next_page: checkHasAnotherPage(\n data.comments,\n data.comments_pagination?.next,\n ),\n is_loading_next_page:\n data?.comments_pagination?.loading_next_page ?? false,\n loadNextPage,\n };\n }, [data, loadNextPage]);\n}\n","import { useCallback } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { useFeedsClient } from '../../contexts/StreamFeedsContext';\nimport type { Feed } from '../../../../feed';\nimport type { FeedOwnCapability } from '../../../../gen/models';\nimport type { FeedsClientState } from '../../../../feeds-client';\n\nconst stableEmptyArray: readonly FeedOwnCapability[] = [];\n\nexport const useOwnCapabilities = (feedFromProps?: Feed | string) => {\n const client = useFeedsClient();\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n const fid = typeof feed === 'string' ? feed : feed?.feed;\n\n const selector = useCallback(\n (currentState: FeedsClientState) => {\n if (!fid) {\n return { feedOwnCapabilities: stableEmptyArray };\n }\n\n return {\n feedOwnCapabilities:\n currentState.own_capabilities_by_fid[fid] ?? stableEmptyArray,\n };\n },\n [fid],\n );\n\n const { feedOwnCapabilities = stableEmptyArray } =\n useStateStore(client?.state, selector) ?? {};\n\n // console.log('GETTING CAPA: ', feed?.feed, feedOwnCapabilities);\n\n return feedOwnCapabilities;\n};\n","import { useCallback, useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport type { Feed, FeedState } from '../../../../feed';\nimport { checkHasAnotherPage } from '../../../../utils';\n\nconst selector = ({\n follower_count,\n followers,\n followers_pagination,\n}: FeedState) => ({\n follower_count,\n followers,\n followers_pagination,\n});\n\ntype UseFollowersReturnType = ReturnType<typeof selector> & {\n is_loading_next_page: boolean;\n has_next_page: boolean;\n loadNextPage: (\n ...options: Parameters<Feed['loadNextPageFollowers']>\n ) => Promise<void>;\n};\n\nexport function useFollowers(feed: Feed): UseFollowersReturnType;\nexport function useFollowers(feed?: Feed): UseFollowersReturnType | undefined;\nexport function useFollowers(feedFromProps?: Feed) {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const data = useStateStore(feed?.state, selector);\n\n const loadNextPage = useCallback(\n (...options: Parameters<Feed['loadNextPageFollowers']>) =>\n feed?.loadNextPageFollowers(...options),\n [feed],\n );\n\n return useMemo(() => {\n if (!data) {\n return undefined;\n }\n\n return {\n ...data,\n is_loading_next_page:\n data.followers_pagination?.loading_next_page ?? false,\n has_next_page: checkHasAnotherPage(\n data.followers,\n data.followers_pagination?.next,\n ),\n loadNextPage,\n };\n }, [data, loadNextPage]);\n}\n","import { useCallback, useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { checkHasAnotherPage } from '../../../../utils';\nimport type { Feed, FeedState } from '../../../../feed';\n\nconst selector = ({\n following_count,\n following,\n following_pagination,\n}: FeedState) => ({\n following_count,\n following,\n following_pagination,\n});\n\ntype UseFollowingReturnType = ReturnType<typeof selector> & {\n is_loading_next_page: boolean;\n has_next_page: boolean;\n loadNextPage: (\n ...options: Parameters<Feed['loadNextPageFollowers']>\n ) => Promise<void>;\n};\n\nexport function useFollowing(feed: Feed): UseFollowingReturnType;\nexport function useFollowing(feed?: Feed): UseFollowingReturnType | undefined;\nexport function useFollowing(feedFromProps?: Feed) {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const data = useStateStore(feed?.state, selector);\n\n const loadNextPage = useCallback(\n (...options: Parameters<Feed['loadNextPageFollowing']>) =>\n feed?.loadNextPageFollowing(...options),\n [feed],\n );\n\n return useMemo(() => {\n if (!data) {\n return undefined;\n }\n\n return {\n ...data,\n is_loading_next_page:\n data.following_pagination?.loading_next_page ?? false,\n has_next_page: checkHasAnotherPage(\n data.following,\n data.following_pagination?.next,\n ),\n loadNextPage,\n };\n }, [data, loadNextPage]);\n}\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport type { Feed, FeedState } from '../../../../feed';\n\n/**\n * A React hook that returns a reactive object containing some often used\n * metadata for a feed.\n */\nexport const useFeedMetadata = (feedFromProps?: Feed) => {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n return useStateStore(feed?.state, selector);\n};\n\nconst selector = ({\n follower_count = 0,\n following_count = 0,\n created_by,\n created_at,\n updated_at,\n}: FeedState) => ({\n created_by,\n follower_count,\n following_count,\n created_at,\n updated_at,\n});\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport type { Feed, FeedState } from '../../../../feed';\n\n/**\n * A React hook that returns a reactive array of feeds that the current user\n * owns and are following the respective feed that we are observing.\n */\nexport const useOwnFollows = (feedFromProps?: Feed) => {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n return useStateStore(feed?.state, selector);\n};\n\nconst selector = ({ own_follows }: FeedState) => ({\n own_follows,\n});\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport type { Feed, FeedState } from '../../../../feed';\nimport type { NotificationStatusResponse } from '../../../../gen/models';\n\nconst selector = ({ notification_status }: FeedState) =>\n ({\n unread: notification_status?.unread ?? 0,\n unseen: notification_status?.unseen ?? 0,\n last_read_at: notification_status?.last_read_at,\n last_seen_at: notification_status?.last_seen_at,\n read_activities: notification_status?.read_activities,\n seen_activities: notification_status?.seen_activities,\n }) satisfies NotificationStatusResponse;\n\ntype UseNotificationStatusReturnType = ReturnType<typeof selector>;\n\nexport function useNotificationStatus(\n feed: Feed,\n): UseNotificationStatusReturnType;\nexport function useNotificationStatus(\n feed?: Feed,\n): UseNotificationStatusReturnType | undefined;\nexport function useNotificationStatus(feedFromProps?: Feed) {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n return useStateStore(feed?.state, selector);\n}\n","import { useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { useStableCallback } from '../internal';\nimport type { Feed, FeedState } from '../../../../feed';\n\nconst selector = ({\n is_loading_activities,\n next,\n aggregated_activities = [],\n}: FeedState) => ({\n is_loading: is_loading_activities,\n has_next_page: typeof next !== 'undefined',\n aggregated_activities,\n});\n\ntype UseAggregatedActivitiesReturnType = ReturnType<typeof selector> & {\n loadNextPage: () => Promise<void>;\n};\n\n/**\n * A React hook that returns a reactive object containing the current aggregated activities,\n * loading state and whether there is a next page to paginate to or not.\n */\nexport function useAggregatedActivities(\n feedFromProps: Feed,\n): UseAggregatedActivitiesReturnType;\nexport function useAggregatedActivities(\n feedFromProps?: Feed,\n): UseAggregatedActivitiesReturnType | undefined;\nexport function useAggregatedActivities(feedFromProps?: Feed) {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const data = useStateStore(feed?.state, selector);\n\n const loadNextPage = useStableCallback(async () => {\n if (!feed || !data?.has_next_page || data?.is_loading) {\n return;\n }\n\n await feed.getNextPage();\n });\n\n return useMemo(\n () => (data ? { ...data, loadNextPage } : undefined),\n [data, loadNextPage],\n );\n}\n","import { useMemo } from 'react';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { useNotificationStatus } from './useNotificationStatus';\nimport type { Feed } from '../../../../feed';\nimport type { AggregatedActivityResponse } from '../../../../gen/models';\n\nexport const useIsAggregatedActivityRead = ({\n feed: feedFromProps,\n aggregatedActivity,\n}: {\n feed?: Feed;\n aggregatedActivity: AggregatedActivityResponse;\n}) => {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const { read_activities: readActivities, last_read_at: lastReadAt } =\n useNotificationStatus(feed) ?? {};\n\n const group = aggregatedActivity.group;\n\n return useMemo(\n () =>\n (lastReadAt &&\n aggregatedActivity.updated_at.getTime() <= lastReadAt.getTime()) ||\n (readActivities ?? []).includes(group),\n [lastReadAt, aggregatedActivity.updated_at, readActivities, group],\n );\n};\n","import { useMemo } from 'react';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { useNotificationStatus } from './useNotificationStatus';\nimport type { Feed } from '../../../../feed';\nimport type { AggregatedActivityResponse } from '../../../../gen/models';\n\nexport const useIsAggregatedActivitySeen = ({\n feed: feedFromProps,\n aggregatedActivity,\n}: {\n feed?: Feed;\n aggregatedActivity: AggregatedActivityResponse;\n}) => {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const { seen_activities: seenActivities, last_seen_at: lastSeenAt } =\n useNotificationStatus(feed) ?? {};\n\n const group = aggregatedActivity.group;\n\n return useMemo(\n () =>\n (lastSeenAt &&\n aggregatedActivity.updated_at.getTime() < lastSeenAt.getTime()) ||\n (seenActivities ?? []).includes(group),\n [lastSeenAt, aggregatedActivity.updated_at, seenActivities, group],\n );\n};\n","import { useCallback, useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\nimport type { StateStore } from '@stream-io/state-store';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { checkHasAnotherPage } from '../../../../utils';\nimport type { Feed, FeedState } from '../../../../feed';\nimport type { ActivityState, ActivityWithStateUpdates } from '../../../../activity-with-state-updates/activity-with-state-updates';\nimport type { ActivityResponse, CommentResponse } from '../../../../gen/models';\n\nconst canLoadComments = (\n feedOrActivity: Feed | ActivityResponse | ActivityWithStateUpdates,\n): feedOrActivity is ActivityWithStateUpdates | Feed => {\n return (\n 'loadNextPageCommentReplies' in feedOrActivity &&\n 'loadNextPageActivityComments' in feedOrActivity\n );\n};\n\ntype UseCommentsReturnType<T extends ActivityResponse | CommentResponse> = {\n comments: NonNullable<\n FeedState['comments_by_entity_id'][T['id']]\n >['comments'];\n comments_pagination: NonNullable<\n FeedState['comments_by_entity_id'][T['id']]\n >['pagination'];\n has_next_page: boolean;\n is_loading_next_page: boolean;\n loadNextPage: (\n request?: T extends CommentResponse\n ? Parameters<Feed['loadNextPageCommentReplies']>[1]\n : Parameters<Feed['loadNextPageActivityComments']>[1],\n ) => Promise<void>;\n};\n\nexport function useActivityComments({\n feed: feedFromProps,\n parentComment,\n activity,\n}: {\n feed?: Feed;\n parentComment?: CommentResponse;\n activity?: ActivityResponse | ActivityWithStateUpdates;\n}) {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n const feedOrActivity = feed ?? activity;\n\n if (!feedOrActivity) {\n throw new Error('Feed or activity is required');\n }\n\n if (!canLoadComments(feedOrActivity)) {\n throw new Error('Feed or activity does not support loading comments');\n }\n\n if (!(activity || parentComment)) {\n throw new Error('Activity or parent comment is required');\n }\n\n const entityId = parentComment?.id ?? activity?.id ?? '';\n const selector = useCallback(\n (state: FeedState | ActivityState) => ({\n comments: state.comments_by_entity_id?.[entityId]?.comments,\n comments_pagination: state.comments_by_entity_id?.[entityId]?.pagination,\n }),\n [entityId],\n );\n\n const data = useStateStore(\n feedOrActivity.state as StateStore<FeedState | ActivityState>,\n selector,\n );\n\n const loadNextPage = useCallback<\n UseCommentsReturnType<ActivityResponse | CommentResponse>['loadNextPage']\n >(\n (request) => {\n if (parentComment) {\n return feedOrActivity.loadNextPageCommentReplies(\n parentComment,\n request,\n );\n } else {\n if (activity && canLoadComments(activity)) {\n return activity.loadNextPageActivityComments(request);\n } else if (feed) {\n return feed.loadNextPageActivityComments(activity?.id ?? '', request);\n } else {\n throw new Error('Activity or feed is required');\n }\n }\n },\n [feedOrActivity, feed, parentComment, activity],\n );\n\n return useMemo(() => {\n return {\n ...data,\n has_next_page: checkHasAnotherPage(\n data.comments,\n data.comments_pagination?.next,\n ),\n is_loading_next_page:\n data?.comments_pagination?.loading_next_page ?? false,\n loadNextPage,\n };\n }, [data, loadNextPage]);\n}\n","import { createContext, useContext } from 'react';\n\nimport type { SearchSource } from '../../../common/search';\n\nexport const StreamSearchResultsContext = createContext<\n SearchSource | undefined\n>(undefined);\n\n/**\n * The props for the StreamSearchResultsProvider component.\n */\nexport type StreamSearchResultsContextProps = {\n source: SearchSource;\n};\n\n/**\n * Hook to access the nearest SearchSource instance.\n */\nexport const useSearchResultsContext = () => {\n return useContext(StreamSearchResultsContext);\n};\n","import { useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useSearchResultsContext } from '../../contexts/StreamSearchResultsContext';\nimport { useStableCallback } from '../internal';\nimport type { SearchSourceState } from '../../../../common/types';\nimport type { SearchSource } from '../../../../common/search';\n\nexport const useSearchResult = (sourceFromProps?: SearchSource) => {\n const sourceFromContext = useSearchResultsContext();\n const source = sourceFromProps ?? sourceFromContext;\n\n const { items, error, isLoading, hasNext } =\n useStateStore(source?.state, selector) ?? {};\n\n const loadMore = useStableCallback(async () => {\n if (hasNext) {\n source?.search();\n }\n });\n\n return useMemo(\n () => ({ items, error, isLoading, hasNext, loadMore }),\n [error, hasNext, isLoading, items, loadMore],\n );\n};\n\nconst selector = ({\n items,\n isLoading,\n hasNext,\n lastQueryError,\n}: SearchSourceState) => ({\n items,\n isLoading,\n hasNext,\n error: lastQueryError,\n});\n","import { createContext, useContext } from 'react';\n\nimport type { SearchController } from '../../../common/search';\n\nexport const StreamSearchContext = createContext<SearchController | undefined>(undefined);\n\n/**\n * The props for the StreamSearchProvider component.\n */\nexport type StreamSearchContextProps = {\n searchController: SearchController;\n};\n\n/**\n * Hook to access the nearest SearchController instance.\n */\nexport const useSearchContext = () => {\n return useContext(StreamSearchContext);\n};\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport type {\n SearchController,\n SearchControllerState,\n} from '../../../../common/search';\nimport { useSearchContext } from '../../contexts/StreamSearchContext';\n\nexport const useSearchQuery = (controllerFromProps?: SearchController) => {\n const controllerFromState = useSearchContext();\n const controller = controllerFromProps ?? controllerFromState;\n\n return useStateStore(controller?.state, selector);\n};\n\nconst selector = ({ searchQuery }: SearchControllerState) => ({\n searchQuery,\n});\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useSearchContext } from '../../contexts/StreamSearchContext';\nimport type { SearchController, SearchControllerState } from '../../../../common/search';\n\nexport const useSearchSources = (controllerFromProps?: SearchController) => {\n const controllerFromState = useSearchContext();\n const controller = controllerFromProps ?? controllerFromState;\n\n return useStateStore(controller?.state, selector);\n};\n\nconst selector = ({ sources }: SearchControllerState) => ({\n sources,\n});\n","import type { PropsWithChildren } from 'react';\nimport { StreamFeedsContext } from '../contexts/StreamFeedsContext';\nimport type { StreamFeedsContextProps } from '../contexts/StreamFeedsContext';\n\nexport const StreamFeeds = ({ client, children }: PropsWithChildren<StreamFeedsContextProps>) => {\n return (\n <StreamFeedsContext.Provider value={client}>\n {children}\n </StreamFeedsContext.Provider>\n );\n};\n\nStreamFeeds.displayName = 'StreamFeeds';\n","import type { PropsWithChildren } from 'react';\n\nimport { StreamFeedContext } from '../contexts/StreamFeedContext';\nimport type { Feed } from '../../../feed';\n\n/**\n * The props for the StreamFeed component. It accepts a `Feed` instance.\n */\nexport type StreamFeedProps = {\n feed: Feed;\n};\n\nexport const StreamFeed = ({\n feed,\n children,\n}: PropsWithChildren<StreamFeedProps>) => {\n return (\n <StreamFeedContext.Provider value={feed}>\n {children}\n </StreamFeedContext.Provider>\n );\n};\n\nStreamFeed.displayName = 'StreamFeed';\n","import type { PropsWithChildren } from 'react';\n\nimport { StreamSearchContext } from '../contexts/StreamSearchContext';\nimport type { SearchController } from '../../../common/search';\n\n/**\n * The props for the StreamSearch component. It accepts a `SearchController` instance.\n */\nexport type StreamSearchProps = {\n searchController: SearchController | undefined;\n};\n\nexport const StreamSearch = ({\n searchController,\n children,\n}: PropsWithChildren<StreamSearchProps>) => {\n return (\n <StreamSearchContext.Provider value={searchController}>\n {children}\n </StreamSearchContext.Provider>\n );\n};\n\nStreamSearch.displayName = 'StreamSearch';\n","import type { PropsWithChildren } from 'react';\n\nimport { StreamSearchResultsContext } from '../contexts/StreamSearchResultsContext';\nimport type { SearchSource } from '../../../common/search';\n\n/**\n * The props for the StreamSearchResults component. It accepts a `SearchSource` instance.\n */\nexport type StreamSearchResultsProps = {\n source: SearchSource;\n};\n\nexport const StreamSearchResults = ({\n source,\n children,\n}: PropsWithChildren<StreamSearchResultsProps>) => {\n return (\n <StreamSearchResultsContext.Provider value={source}>\n {children}\n </StreamSearchResultsContext.Provider>\n );\n};\n\nStreamSearchResults.displayName = 'StreamSearchResults';\n"],"names":["selector"],"mappings":";;;;;AAUO,MAAM,uBAAuB,CAAC;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AACJ,QAAM,CAAC,QAAQ,SAAS,IAAI;AAAA,IAC1B,MAAM,IAAI,YAAY,QAAQ,OAAO;AAAA,EAAA;AAEvC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,IAAI;AACrD,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,QAAQ;AAE7D,QAAM,CAAC,aAAa,IAAI,SAAS,OAAO;AAExC,MAAI,OAAO;AACT,UAAM;AAAA,EACR;AAEA,MAAI,SAAS,OAAO,eAAe,IAAI;AACrC,sBAAkB,QAAQ;AAAA,EAC5B;AAEA,YAAU,MAAM;AACd,UAAM,UAAU,IAAI,YAAY,QAAQ,aAAa;AAErD,UAAM,oBAAoB,QACvB,YAAY,gBAAgB,eAAe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AAO;AACT;ACjCO,MAAM,sBAAsB,cAA4C,MAAS;AAYjF,MAAM,mBAAmB,MAAM;AACpC,SAAO,WAAW,mBAAmB;AACvC;ACVO,MAAM,iBAAiB,CAAC,wBAA2C;AACxE,QAAM,sBAAsB,iBAAA;AAC5B,QAAM,aAAa,uBAAuB;AAE1C,SAAO,cAAc,YAAY,OAAOA,UAAQ;AAClD;AAEA,MAAMA,aAAW,CAAC,EAAE,mBAA0C;AAAA,EAC5D;AACF;ACZO,MAAM,mBAAmB,CAAC,wBAA2C;AAC1E,QAAM,sBAAsB,iBAAA;AAC5B,QAAM,aAAa,uBAAuB;AAE1C,SAAO,cAAc,YAAY,OAAO,QAAQ;AAClD;AAEA,MAAM,WAAW,CAAC,EAAE,eAAsC;AAAA,EACxD;AACF;ACVO,MAAM,cAAc,CAAC,EAAE,QAAQ,eAA2D;AAC/F,6BACG,mBAAmB,UAAnB,EAA4B,OAAO,QACjC,UACH;AAEJ;AAEA,YAAY,cAAc;ACAnB,MAAM,aAAa,CAAC;AAAA,EACzB;AAAA,EACA;AACF,MAA0C;AACxC,6BACG,kBAAkB,UAAlB,EAA2B,OAAO,MAChC,UACH;AAEJ;AAEA,WAAW,cAAc;ACXlB,MAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AACF,MAA4C;AAC1C,6BACG,oBAAoB,UAApB,EAA6B,OAAO,kBAClC,UACH;AAEJ;AAEA,aAAa,cAAc;ACXpB,MAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AACF,MAAmD;AACjD,6BACG,2BAA2B,UAA3B,EAAoC,OAAO,QACzC,UACH;AAEJ;AAEA,oBAAoB,cAAc;"}
1
+ {"version":3,"file":"react-bindings.mjs","sources":["../../src/bindings/react/hooks/useCreateFeedsClient.ts","../../src/bindings/react/contexts/StreamFeedsContext.tsx","../../src/bindings/react/hooks/client-state-hooks/useClientConnectedUser.ts","../../src/bindings/react/hooks/client-state-hooks/useWsConnectionState.ts","../../src/bindings/react/contexts/StreamFeedContext.tsx","../../src/bindings/react/hooks/internal/useStableCallback.ts","../../src/bindings/react/hooks/feed-state-hooks/useFeedActivities.ts","../../src/bindings/react/hooks/feed-state-hooks/useComments.ts","../../src/bindings/react/hooks/feed-state-hooks/useOwnCapabilities.ts","../../src/bindings/react/hooks/feed-state-hooks/useFollowers.ts","../../src/bindings/react/hooks/feed-state-hooks/useFollowing.ts","../../src/bindings/react/hooks/feed-state-hooks/useFeedMetadata.ts","../../src/bindings/react/hooks/feed-state-hooks/useOwnFollows.ts","../../src/bindings/react/hooks/feed-state-hooks/useNotificationStatus.ts","../../src/bindings/react/hooks/feed-state-hooks/useAggregatedActivities.ts","../../src/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivityRead.ts","../../src/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivitySeen.ts","../../src/bindings/react/hooks/feed-state-hooks/useActivityComments.ts","../../src/bindings/react/hooks/feed-state-hooks/useOwnFollowings.ts","../../src/bindings/react/contexts/StreamSearchResultsContext.tsx","../../src/bindings/react/hooks/search-state-hooks/useSearchResult.ts","../../src/bindings/react/contexts/StreamSearchContext.tsx","../../src/bindings/react/hooks/search-state-hooks/useSearchQuery.ts","../../src/bindings/react/hooks/search-state-hooks/useSearchSources.ts","../../src/bindings/react/wrappers/StreamFeeds.tsx","../../src/bindings/react/wrappers/StreamFeed.tsx","../../src/bindings/react/wrappers/StreamSearch.tsx","../../src/bindings/react/wrappers/StreamSearchResults.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { FeedsClient } from '../../../feeds-client';\nimport type { TokenOrProvider } from '../../../types';\nimport type { UserRequest } from '../../../gen/models';\nimport type { FeedsClientOptions } from '../../../common/types';\n\n/**\n * A React hook to create, connect and return an instance of `FeedsClient`.\n */\nexport const useCreateFeedsClient = ({\n apiKey,\n tokenOrProvider,\n userData,\n options,\n}: {\n apiKey: string;\n tokenOrProvider: TokenOrProvider;\n userData: UserRequest;\n options?: FeedsClientOptions;\n}) => {\n const [client, setClient] = useState<FeedsClient | null>(null);\n const [error, setError] = useState<Error | null>(null);\n const [cachedUserData, setCachedUserData] = useState(userData);\n\n const [cachedOptions] = useState(options);\n\n if (error) {\n throw error;\n }\n\n if (userData.id !== cachedUserData.id) {\n setCachedUserData(userData);\n }\n\n useEffect(() => {\n const _client = new FeedsClient(apiKey, cachedOptions);\n\n const connectionPromise = _client\n .connectUser(cachedUserData, tokenOrProvider)\n .then(() => {\n setError(null);\n })\n .catch((err) => {\n setError(err);\n });\n\n setClient(_client);\n\n return () => {\n setClient(null);\n connectionPromise\n .then(() => {\n setError(null);\n return _client.disconnectUser();\n })\n .catch((err) => {\n setError(err);\n });\n };\n }, [apiKey, cachedUserData, cachedOptions, tokenOrProvider]);\n\n return client;\n};\n","import { createContext, useContext } from 'react';\n\nimport type { FeedsClient } from '../../../feeds-client';\n\nexport const StreamFeedsContext = createContext<FeedsClient | undefined>(undefined);\n\n/**\n * The props for the StreamFeedsProvider component.\n */\nexport type StreamFeedsContextProps = {\n /**\n * The client instance to provide to the component tree.\n */\n client: FeedsClient;\n};\n\n/**\n * Hook to access the nearest FeedsClient instance.\n */\nexport const useFeedsClient = () => {\n return useContext(StreamFeedsContext);\n};\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedsClient } from '../../contexts/StreamFeedsContext';\nimport type { FeedsClientState } from '../../../../feeds-client';\n\n/**\n * A React hook that returns the currently connected user on a `FeedsClient` instance and null otherwise.\n */\nexport const useClientConnectedUser = () => {\n const client = useFeedsClient();\n\n const { user } = useStateStore(client?.state, selector) ?? {};\n\n return user;\n};\n\nconst selector = (nextState: FeedsClientState) => ({\n user: nextState.connected_user,\n});\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedsClient } from '../../contexts/StreamFeedsContext';\nimport type { FeedsClientState } from '../../../../feeds-client';\n\n/**\n * A React hook that returns the websocket connection state of `FeedsClient`.\n */\nexport const useWsConnectionState = () => {\n const client = useFeedsClient();\n\n const { is_healthy } = useStateStore(client?.state, selector) ?? {}\n\n return { is_healthy };\n};\n\nconst selector = (nextState: FeedsClientState) => ({\n is_healthy: nextState.is_ws_connection_healthy,\n});\n","import { createContext, useContext } from 'react';\n\nimport type { Feed } from '../../../feed';\n\nexport const StreamFeedContext = createContext<Feed | undefined>(undefined);\n\n/**\n * The props for the StreamFeedProvider component.\n */\nexport type StreamFeedContextProps = {\n feed: Feed;\n};\n\n/**\n * Hook to access the nearest Feed instance.\n */\nexport const useFeedContext = () => {\n return useContext(StreamFeedContext);\n};\n","import { useCallback, useRef } from 'react';\n\nexport type StableCallback<A extends unknown[], R> = (...args: A) => R;\n\n/**\n * A utility hook implementing a stable callback. It takes in an unstable method that\n * is supposed to be invoked somewhere deeper in the DOM tree without making it\n * change its reference every time the parent component rerenders. It will also return\n * the value of the callback if it does return one.\n * A common use-case would be having a function whose invocation depends on state\n * somewhere high up in the DOM tree and wanting to use the same function deeper\n * down, for example in a leaf node and simply using useCallback results in\n * cascading dependency hell. If we wrap it in useStableCallback, we would be able\n * to:\n * - Use the same function as a dependency of another hook (since it is stable)\n * - Still invoke it and get the latest state\n *\n * **Caveats:**\n * - Never wrap a function that is supposed to return a React.ReactElement in\n * useStableCallback, since React will not know that the DOM needs to be updated\n * whenever the callback value changes (for example, renderItem from FlatList must\n * never be wrapped in this hook)\n * - Always prefer using a standard useCallback/stable function wherever possible\n * (the purpose of useStableCallback is to bridge the gap between top level contexts\n * and cascading rereders in downstream components - **not** as an escape hatch)\n * @param callback - the callback we want to stabilize\n */\nexport const useStableCallback = <A extends unknown[], R>(\n callback: StableCallback<A, R>,\n): StableCallback<A, R> => {\n const ref = useRef(callback);\n ref.current = callback;\n\n return useCallback<StableCallback<A, R>>((...args) => {\n return ref.current(...args);\n }, []);\n};\n","import { useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { useStableCallback } from '../internal';\nimport type { Feed, FeedState } from '../../../../feed';\n\n/**\n * A React hook that returns a reactive object containing the current activities,\n * loading state and whether there is a next page to paginate to or not.\n */\nexport const useFeedActivities = (feedFromProps?: Feed) => {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const data = useStateStore(feed?.state, selector);\n\n const loadNextPage = useStableCallback(async () => {\n if (!feed || !data?.has_next_page || data?.is_loading) {\n return;\n }\n\n await feed.getNextPage();\n });\n\n return useMemo(() => ({ ...data, loadNextPage }), [data, loadNextPage]);\n};\n\nconst selector = ({\n is_loading_activities,\n next,\n activities = [],\n}: FeedState) => ({\n is_loading: is_loading_activities,\n has_next_page: typeof next !== 'undefined',\n activities,\n});\n","import { useCallback, useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { checkHasAnotherPage, isCommentResponse } from '../../../../utils';\nimport type { ActivityResponse, CommentResponse } from '../../../../gen/models';\nimport type { Feed, FeedState } from '../../../../feed';\nimport type { CommentParent } from '../../../../types';\n\ntype UseCommentsReturnType<T extends ActivityResponse | CommentResponse> = {\n comments: NonNullable<\n FeedState['comments_by_entity_id'][T['id']]\n >['comments'];\n comments_pagination: NonNullable<\n FeedState['comments_by_entity_id'][T['id']]\n >['pagination'];\n has_next_page: boolean;\n is_loading_next_page: boolean;\n loadNextPage: (\n request?: T extends CommentResponse\n ? Parameters<Feed['loadNextPageCommentReplies']>[1]\n : Parameters<Feed['loadNextPageActivityComments']>[1],\n ) => Promise<void>;\n};\n\n/**\n * @deprecated Use `useActivityComments` instead.\n * @param\n */\nexport function useComments<T extends CommentParent>(_: {\n feed: Feed;\n parent: T;\n}): UseCommentsReturnType<T>;\nexport function useComments<T extends CommentParent>(_: {\n feed?: Feed;\n parent: T;\n}): UseCommentsReturnType<T> | undefined;\nexport function useComments<T extends CommentParent>({\n feed: feedFromProps,\n parent,\n}: {\n feed?: Feed;\n /**\n * The parent (activity or comment) for which to fetch comments.\n */\n parent: T;\n}) {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const selector = useCallback(\n (state: FeedState) => ({\n comments: state.comments_by_entity_id?.[parent.id]?.comments,\n comments_pagination: state.comments_by_entity_id?.[parent.id]?.pagination,\n }),\n [parent.id],\n );\n\n const data = useStateStore(feed?.state, selector);\n\n const loadNextPage = useMemo<\n UseCommentsReturnType<T>['loadNextPage'] | undefined\n >(() => {\n if (!feed) return undefined;\n\n return (request) => {\n if (isCommentResponse(parent)) {\n return feed.loadNextPageCommentReplies(parent, request);\n } else {\n return feed.loadNextPageActivityComments(parent, request);\n }\n };\n }, [feed, parent]);\n\n return useMemo(() => {\n if (!data) {\n return undefined;\n }\n\n return {\n ...data,\n has_next_page: checkHasAnotherPage(\n data.comments,\n data.comments_pagination?.next,\n ),\n is_loading_next_page:\n data?.comments_pagination?.loading_next_page ?? false,\n loadNextPage,\n };\n }, [data, loadNextPage]);\n}\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport type { Feed, FeedState } from '../../../../feed';\nimport type { FeedOwnCapability } from '../../../../gen/models';\nimport { useFeedsClient } from '../../contexts/StreamFeedsContext';\n\nconst stableEmptyArray: readonly FeedOwnCapability[] = [];\n\nconst selector = (currentState: FeedState) => {\n return {\n feedOwnCapabilities: currentState.own_capabilities ?? stableEmptyArray,\n };\n};\n\nexport const useOwnCapabilities = (feedFromProps?: Feed | string) => {\n const client = useFeedsClient();\n const feedFromContext = useFeedContext();\n let feed = feedFromProps ?? feedFromContext;\n if (typeof feed === 'string') {\n const [groupId, id] = feed.split(':');\n feed = groupId && id ? client?.feed(groupId, id) : undefined;\n }\n\n const { feedOwnCapabilities = stableEmptyArray } =\n useStateStore(feed?.state, selector) ?? {};\n\n return feedOwnCapabilities;\n};\n","import { useCallback, useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport type { Feed, FeedState } from '../../../../feed';\nimport { checkHasAnotherPage } from '../../../../utils';\n\nconst selector = ({\n follower_count,\n followers,\n followers_pagination,\n}: FeedState) => ({\n follower_count,\n followers,\n followers_pagination,\n});\n\ntype UseFollowersReturnType = ReturnType<typeof selector> & {\n is_loading_next_page: boolean;\n has_next_page: boolean;\n loadNextPage: (\n ...options: Parameters<Feed['loadNextPageFollowers']>\n ) => Promise<void>;\n};\n\nexport function useFollowers(feed: Feed): UseFollowersReturnType;\nexport function useFollowers(feed?: Feed): UseFollowersReturnType | undefined;\nexport function useFollowers(feedFromProps?: Feed) {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const data = useStateStore(feed?.state, selector);\n\n const loadNextPage = useCallback(\n (...options: Parameters<Feed['loadNextPageFollowers']>) =>\n feed?.loadNextPageFollowers(...options),\n [feed],\n );\n\n return useMemo(() => {\n if (!data) {\n return undefined;\n }\n\n return {\n ...data,\n is_loading_next_page:\n data.followers_pagination?.loading_next_page ?? false,\n has_next_page: checkHasAnotherPage(\n data.followers,\n data.followers_pagination?.next,\n ),\n loadNextPage,\n };\n }, [data, loadNextPage]);\n}\n","import { useCallback, useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { checkHasAnotherPage } from '../../../../utils';\nimport type { Feed, FeedState } from '../../../../feed';\n\nconst selector = ({\n following_count,\n following,\n following_pagination,\n}: FeedState) => ({\n following_count,\n following,\n following_pagination,\n});\n\ntype UseFollowingReturnType = ReturnType<typeof selector> & {\n is_loading_next_page: boolean;\n has_next_page: boolean;\n loadNextPage: (\n ...options: Parameters<Feed['loadNextPageFollowers']>\n ) => Promise<void>;\n};\n\nexport function useFollowing(feed: Feed): UseFollowingReturnType;\nexport function useFollowing(feed?: Feed): UseFollowingReturnType | undefined;\nexport function useFollowing(feedFromProps?: Feed) {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const data = useStateStore(feed?.state, selector);\n\n const loadNextPage = useCallback(\n (...options: Parameters<Feed['loadNextPageFollowing']>) =>\n feed?.loadNextPageFollowing(...options),\n [feed],\n );\n\n return useMemo(() => {\n if (!data) {\n return undefined;\n }\n\n return {\n ...data,\n is_loading_next_page:\n data.following_pagination?.loading_next_page ?? false,\n has_next_page: checkHasAnotherPage(\n data.following,\n data.following_pagination?.next,\n ),\n loadNextPage,\n };\n }, [data, loadNextPage]);\n}\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport type { Feed, FeedState } from '../../../../feed';\n\n/**\n * A React hook that returns a reactive object containing some often used\n * metadata for a feed.\n */\nexport const useFeedMetadata = (feedFromProps?: Feed) => {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n return useStateStore(feed?.state, selector);\n};\n\nconst selector = ({\n follower_count = 0,\n following_count = 0,\n created_by,\n created_at,\n updated_at,\n}: FeedState) => ({\n created_by,\n follower_count,\n following_count,\n created_at,\n updated_at,\n});\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport type { Feed, FeedState } from '../../../../feed';\n\n/**\n * A React hook that returns a reactive array of feeds that the current user\n * owns and are following the respective feed that we are observing.\n */\nexport const useOwnFollows = (feedFromProps?: Feed) => {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n return useStateStore(feed?.state, selector);\n};\n\nconst selector = ({ own_follows }: FeedState) => ({\n own_follows,\n});\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport type { Feed, FeedState } from '../../../../feed';\nimport type { NotificationStatusResponse } from '../../../../gen/models';\n\nconst selector = ({ notification_status }: FeedState) =>\n ({\n unread: notification_status?.unread ?? 0,\n unseen: notification_status?.unseen ?? 0,\n last_read_at: notification_status?.last_read_at,\n last_seen_at: notification_status?.last_seen_at,\n read_activities: notification_status?.read_activities,\n seen_activities: notification_status?.seen_activities,\n }) satisfies NotificationStatusResponse;\n\ntype UseNotificationStatusReturnType = ReturnType<typeof selector>;\n\nexport function useNotificationStatus(\n feed: Feed,\n): UseNotificationStatusReturnType;\nexport function useNotificationStatus(\n feed?: Feed,\n): UseNotificationStatusReturnType | undefined;\nexport function useNotificationStatus(feedFromProps?: Feed) {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n return useStateStore(feed?.state, selector);\n}\n","import { useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { useStableCallback } from '../internal';\nimport type { Feed, FeedState } from '../../../../feed';\n\nconst selector = ({\n is_loading_activities,\n next,\n aggregated_activities = [],\n}: FeedState) => ({\n is_loading: is_loading_activities,\n has_next_page: typeof next !== 'undefined',\n aggregated_activities,\n});\n\ntype UseAggregatedActivitiesReturnType = ReturnType<typeof selector> & {\n loadNextPage: () => Promise<void>;\n};\n\n/**\n * A React hook that returns a reactive object containing the current aggregated activities,\n * loading state and whether there is a next page to paginate to or not.\n */\nexport function useAggregatedActivities(\n feedFromProps: Feed,\n): UseAggregatedActivitiesReturnType;\nexport function useAggregatedActivities(\n feedFromProps?: Feed,\n): UseAggregatedActivitiesReturnType | undefined;\nexport function useAggregatedActivities(feedFromProps?: Feed) {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const data = useStateStore(feed?.state, selector);\n\n const loadNextPage = useStableCallback(async () => {\n if (!feed || !data?.has_next_page || data?.is_loading) {\n return;\n }\n\n await feed.getNextPage();\n });\n\n return useMemo(\n () => (data ? { ...data, loadNextPage } : undefined),\n [data, loadNextPage],\n );\n}\n","import { useMemo } from 'react';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { useNotificationStatus } from './useNotificationStatus';\nimport type { Feed } from '../../../../feed';\nimport type { AggregatedActivityResponse } from '../../../../gen/models';\n\nexport const useIsAggregatedActivityRead = ({\n feed: feedFromProps,\n aggregatedActivity,\n}: {\n feed?: Feed;\n aggregatedActivity: AggregatedActivityResponse;\n}) => {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const { read_activities: readActivities, last_read_at: lastReadAt } =\n useNotificationStatus(feed) ?? {};\n\n const group = aggregatedActivity.group;\n\n return useMemo(\n () =>\n (lastReadAt &&\n aggregatedActivity.updated_at.getTime() <= lastReadAt.getTime()) ||\n (readActivities ?? []).includes(group),\n [lastReadAt, aggregatedActivity.updated_at, readActivities, group],\n );\n};\n","import { useMemo } from 'react';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { useNotificationStatus } from './useNotificationStatus';\nimport type { Feed } from '../../../../feed';\nimport type { AggregatedActivityResponse } from '../../../../gen/models';\n\nexport const useIsAggregatedActivitySeen = ({\n feed: feedFromProps,\n aggregatedActivity,\n}: {\n feed?: Feed;\n aggregatedActivity: AggregatedActivityResponse;\n}) => {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n const { seen_activities: seenActivities, last_seen_at: lastSeenAt } =\n useNotificationStatus(feed) ?? {};\n\n const group = aggregatedActivity.group;\n\n return useMemo(\n () =>\n (lastSeenAt &&\n aggregatedActivity.updated_at.getTime() < lastSeenAt.getTime()) ||\n (seenActivities ?? []).includes(group),\n [lastSeenAt, aggregatedActivity.updated_at, seenActivities, group],\n );\n};\n","import { useCallback, useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\nimport type { StateStore } from '@stream-io/state-store';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport { checkHasAnotherPage } from '../../../../utils';\nimport type { Feed, FeedState } from '../../../../feed';\nimport type { ActivityState, ActivityWithStateUpdates } from '../../../../activity-with-state-updates/activity-with-state-updates';\nimport type { ActivityResponse, CommentResponse } from '../../../../gen/models';\n\nconst canLoadComments = (\n feedOrActivity: Feed | ActivityResponse | ActivityWithStateUpdates,\n): feedOrActivity is ActivityWithStateUpdates | Feed => {\n return (\n 'loadNextPageCommentReplies' in feedOrActivity &&\n 'loadNextPageActivityComments' in feedOrActivity\n );\n};\n\ntype UseCommentsReturnType<T extends ActivityResponse | CommentResponse> = {\n comments: NonNullable<\n FeedState['comments_by_entity_id'][T['id']]\n >['comments'];\n comments_pagination: NonNullable<\n FeedState['comments_by_entity_id'][T['id']]\n >['pagination'];\n has_next_page: boolean;\n is_loading_next_page: boolean;\n loadNextPage: (\n request?: T extends CommentResponse\n ? Parameters<Feed['loadNextPageCommentReplies']>[1]\n : Parameters<Feed['loadNextPageActivityComments']>[1],\n ) => Promise<void>;\n};\n\nexport function useActivityComments({\n feed: feedFromProps,\n parentComment,\n activity,\n}: {\n feed?: Feed;\n parentComment?: CommentResponse;\n activity?: ActivityResponse | ActivityWithStateUpdates;\n}) {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n const feedOrActivity = feed ?? activity;\n\n if (!feedOrActivity) {\n throw new Error('Feed or activity is required');\n }\n\n if (!canLoadComments(feedOrActivity)) {\n throw new Error('Feed or activity does not support loading comments');\n }\n\n if (!(activity || parentComment)) {\n throw new Error('Activity or parent comment is required');\n }\n\n const entityId = parentComment?.id ?? activity?.id ?? '';\n const selector = useCallback(\n (state: FeedState | ActivityState) => ({\n comments: state.comments_by_entity_id?.[entityId]?.comments,\n comments_pagination: state.comments_by_entity_id?.[entityId]?.pagination,\n }),\n [entityId],\n );\n\n const data = useStateStore(\n feedOrActivity.state as StateStore<FeedState | ActivityState>,\n selector,\n );\n\n const loadNextPage = useCallback<\n UseCommentsReturnType<ActivityResponse | CommentResponse>['loadNextPage']\n >(\n (request) => {\n if (parentComment) {\n return feedOrActivity.loadNextPageCommentReplies(\n parentComment,\n request,\n );\n } else {\n if (activity && canLoadComments(activity)) {\n return activity.loadNextPageActivityComments(request);\n } else if (feed) {\n return feed.loadNextPageActivityComments(activity?.id ?? '', request);\n } else {\n throw new Error('Activity or feed is required');\n }\n }\n },\n [feedOrActivity, feed, parentComment, activity],\n );\n\n return useMemo(() => {\n return {\n ...data,\n has_next_page: checkHasAnotherPage(\n data.comments,\n data.comments_pagination?.next,\n ),\n is_loading_next_page:\n data?.comments_pagination?.loading_next_page ?? false,\n loadNextPage,\n };\n }, [data, loadNextPage]);\n}\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useFeedContext } from '../../contexts/StreamFeedContext';\nimport type { Feed, FeedState } from '../../../../feed';\n\n/**\n * A React hook that returns a reactive array of feeds that the feeds's owner is following and is owned by the current user.\n */\nexport const useOwnFollowings = (feedFromProps?: Feed) => {\n const feedFromContext = useFeedContext();\n const feed = feedFromProps ?? feedFromContext;\n\n return useStateStore(feed?.state, selector);\n};\n\nconst selector = ({ own_followings }: FeedState) => ({\n own_followings,\n});\n","import { createContext, useContext } from 'react';\n\nimport type { SearchSource } from '../../../common/search';\n\nexport const StreamSearchResultsContext = createContext<\n SearchSource | undefined\n>(undefined);\n\n/**\n * The props for the StreamSearchResultsProvider component.\n */\nexport type StreamSearchResultsContextProps = {\n source: SearchSource;\n};\n\n/**\n * Hook to access the nearest SearchSource instance.\n */\nexport const useSearchResultsContext = () => {\n return useContext(StreamSearchResultsContext);\n};\n","import { useMemo } from 'react';\nimport { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useSearchResultsContext } from '../../contexts/StreamSearchResultsContext';\nimport { useStableCallback } from '../internal';\nimport type { SearchSourceState } from '../../../../common/types';\nimport type { SearchSource } from '../../../../common/search';\n\nexport const useSearchResult = (sourceFromProps?: SearchSource) => {\n const sourceFromContext = useSearchResultsContext();\n const source = sourceFromProps ?? sourceFromContext;\n\n const { items, error, isLoading, hasNext } =\n useStateStore(source?.state, selector) ?? {};\n\n const loadMore = useStableCallback(async () => {\n if (hasNext) {\n source?.search();\n }\n });\n\n return useMemo(\n () => ({ items, error, isLoading, hasNext, loadMore }),\n [error, hasNext, isLoading, items, loadMore],\n );\n};\n\nconst selector = ({\n items,\n isLoading,\n hasNext,\n lastQueryError,\n}: SearchSourceState) => ({\n items,\n isLoading,\n hasNext,\n error: lastQueryError,\n});\n","import { createContext, useContext } from 'react';\n\nimport type { SearchController } from '../../../common/search';\n\nexport const StreamSearchContext = createContext<SearchController | undefined>(undefined);\n\n/**\n * The props for the StreamSearchProvider component.\n */\nexport type StreamSearchContextProps = {\n searchController: SearchController;\n};\n\n/**\n * Hook to access the nearest SearchController instance.\n */\nexport const useSearchContext = () => {\n return useContext(StreamSearchContext);\n};\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport type {\n SearchController,\n SearchControllerState,\n} from '../../../../common/search';\nimport { useSearchContext } from '../../contexts/StreamSearchContext';\n\nexport const useSearchQuery = (controllerFromProps?: SearchController) => {\n const controllerFromState = useSearchContext();\n const controller = controllerFromProps ?? controllerFromState;\n\n return useStateStore(controller?.state, selector);\n};\n\nconst selector = ({ searchQuery }: SearchControllerState) => ({\n searchQuery,\n});\n","import { useStateStore } from '@stream-io/state-store/react-bindings';\n\nimport { useSearchContext } from '../../contexts/StreamSearchContext';\nimport type { SearchController, SearchControllerState } from '../../../../common/search';\n\nexport const useSearchSources = (controllerFromProps?: SearchController) => {\n const controllerFromState = useSearchContext();\n const controller = controllerFromProps ?? controllerFromState;\n\n return useStateStore(controller?.state, selector);\n};\n\nconst selector = ({ sources }: SearchControllerState) => ({\n sources,\n});\n","import type { PropsWithChildren } from 'react';\nimport { StreamFeedsContext } from '../contexts/StreamFeedsContext';\nimport type { StreamFeedsContextProps } from '../contexts/StreamFeedsContext';\n\nexport const StreamFeeds = ({ client, children }: PropsWithChildren<StreamFeedsContextProps>) => {\n return (\n <StreamFeedsContext.Provider value={client}>\n {children}\n </StreamFeedsContext.Provider>\n );\n};\n\nStreamFeeds.displayName = 'StreamFeeds';\n","import type { PropsWithChildren } from 'react';\n\nimport { StreamFeedContext } from '../contexts/StreamFeedContext';\nimport type { Feed } from '../../../feed';\n\n/**\n * The props for the StreamFeed component. It accepts a `Feed` instance.\n */\nexport type StreamFeedProps = {\n feed: Feed;\n};\n\nexport const StreamFeed = ({\n feed,\n children,\n}: PropsWithChildren<StreamFeedProps>) => {\n return (\n <StreamFeedContext.Provider value={feed}>\n {children}\n </StreamFeedContext.Provider>\n );\n};\n\nStreamFeed.displayName = 'StreamFeed';\n","import type { PropsWithChildren } from 'react';\n\nimport { StreamSearchContext } from '../contexts/StreamSearchContext';\nimport type { SearchController } from '../../../common/search';\n\n/**\n * The props for the StreamSearch component. It accepts a `SearchController` instance.\n */\nexport type StreamSearchProps = {\n searchController: SearchController | undefined;\n};\n\nexport const StreamSearch = ({\n searchController,\n children,\n}: PropsWithChildren<StreamSearchProps>) => {\n return (\n <StreamSearchContext.Provider value={searchController}>\n {children}\n </StreamSearchContext.Provider>\n );\n};\n\nStreamSearch.displayName = 'StreamSearch';\n","import type { PropsWithChildren } from 'react';\n\nimport { StreamSearchResultsContext } from '../contexts/StreamSearchResultsContext';\nimport type { SearchSource } from '../../../common/search';\n\n/**\n * The props for the StreamSearchResults component. It accepts a `SearchSource` instance.\n */\nexport type StreamSearchResultsProps = {\n source: SearchSource;\n};\n\nexport const StreamSearchResults = ({\n source,\n children,\n}: PropsWithChildren<StreamSearchResultsProps>) => {\n return (\n <StreamSearchResultsContext.Provider value={source}>\n {children}\n </StreamSearchResultsContext.Provider>\n );\n};\n\nStreamSearchResults.displayName = 'StreamSearchResults';\n"],"names":["selector"],"mappings":";;;;;AAUO,MAAM,uBAAuB,CAAC;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AACJ,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA6B,IAAI;AAC7D,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,IAAI;AACrD,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,QAAQ;AAE7D,QAAM,CAAC,aAAa,IAAI,SA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