@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
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const reactBindings = require("@stream-io/state-store/react-bindings");
4
4
  const react = require("react");
5
- const feedsClient = require("../feeds-client-B9rwEWH3.js");
5
+ const feedsClient = require("../feeds-client-Xj6kDjVH.js");
6
6
  const jsxRuntime = require("react/jsx-runtime");
7
7
  const useCreateFeedsClient = ({
8
8
  apiKey,
@@ -10,9 +10,7 @@ const useCreateFeedsClient = ({
10
10
  userData,
11
11
  options
12
12
  }) => {
13
- const [client, setClient] = react.useState(
14
- () => new feedsClient.FeedsClient(apiKey, options)
15
- );
13
+ const [client, setClient] = react.useState(null);
16
14
  const [error, setError] = react.useState(null);
17
15
  const [cachedUserData, setCachedUserData] = react.useState(userData);
18
16
  const [cachedOptions] = react.useState(options);
@@ -48,18 +46,18 @@ const useFeedsClient = () => {
48
46
  };
49
47
  const useClientConnectedUser = () => {
50
48
  const client = useFeedsClient();
51
- const { user } = reactBindings.useStateStore(client?.state, selector$b) ?? {};
49
+ const { user } = reactBindings.useStateStore(client?.state, selector$d) ?? {};
52
50
  return user;
53
51
  };
54
- const selector$b = (nextState) => ({
52
+ const selector$d = (nextState) => ({
55
53
  user: nextState.connected_user
56
54
  });
57
55
  const useWsConnectionState = () => {
58
56
  const client = useFeedsClient();
59
- const { is_healthy } = reactBindings.useStateStore(client?.state, selector$a) ?? {};
57
+ const { is_healthy } = reactBindings.useStateStore(client?.state, selector$c) ?? {};
60
58
  return { is_healthy };
61
59
  };
62
- const selector$a = (nextState) => ({
60
+ const selector$c = (nextState) => ({
63
61
  is_healthy: nextState.is_ws_connection_healthy
64
62
  });
65
63
  const StreamFeedContext = react.createContext(void 0);
@@ -76,7 +74,7 @@ const useStableCallback = (callback) => {
76
74
  const useFeedActivities = (feedFromProps) => {
77
75
  const feedFromContext = useFeedContext();
78
76
  const feed = feedFromProps ?? feedFromContext;
79
- const data = reactBindings.useStateStore(feed?.state, selector$9);
77
+ const data = reactBindings.useStateStore(feed?.state, selector$b);
80
78
  const loadNextPage = useStableCallback(async () => {
81
79
  if (!feed || !data?.has_next_page || data?.is_loading) {
82
80
  return;
@@ -85,7 +83,7 @@ const useFeedActivities = (feedFromProps) => {
85
83
  });
86
84
  return react.useMemo(() => ({ ...data, loadNextPage }), [data, loadNextPage]);
87
85
  };
88
- const selector$9 = ({
86
+ const selector$b = ({
89
87
  is_loading_activities,
90
88
  next,
91
89
  activities = []
@@ -134,26 +132,23 @@ function useComments({
134
132
  }, [data, loadNextPage]);
135
133
  }
136
134
  const stableEmptyArray = [];
135
+ const selector$a = (currentState) => {
136
+ return {
137
+ feedOwnCapabilities: currentState.own_capabilities ?? stableEmptyArray
138
+ };
139
+ };
137
140
  const useOwnCapabilities = (feedFromProps) => {
138
141
  const client = useFeedsClient();
139
142
  const feedFromContext = useFeedContext();
140
- const feed = feedFromProps ?? feedFromContext;
141
- const fid = typeof feed === "string" ? feed : feed?.feed;
142
- const selector2 = react.useCallback(
143
- (currentState) => {
144
- if (!fid) {
145
- return { feedOwnCapabilities: stableEmptyArray };
146
- }
147
- return {
148
- feedOwnCapabilities: currentState.own_capabilities_by_fid[fid] ?? stableEmptyArray
149
- };
150
- },
151
- [fid]
152
- );
153
- const { feedOwnCapabilities = stableEmptyArray } = reactBindings.useStateStore(client?.state, selector2) ?? {};
143
+ let feed = feedFromProps ?? feedFromContext;
144
+ if (typeof feed === "string") {
145
+ const [groupId, id] = feed.split(":");
146
+ feed = groupId && id ? client?.feed(groupId, id) : void 0;
147
+ }
148
+ const { feedOwnCapabilities = stableEmptyArray } = reactBindings.useStateStore(feed?.state, selector$a) ?? {};
154
149
  return feedOwnCapabilities;
155
150
  };
156
- const selector$8 = ({
151
+ const selector$9 = ({
157
152
  follower_count,
158
153
  followers,
159
154
  followers_pagination
@@ -165,7 +160,7 @@ const selector$8 = ({
165
160
  function useFollowers(feedFromProps) {
166
161
  const feedFromContext = useFeedContext();
167
162
  const feed = feedFromProps ?? feedFromContext;
168
- const data = reactBindings.useStateStore(feed?.state, selector$8);
163
+ const data = reactBindings.useStateStore(feed?.state, selector$9);
169
164
  const loadNextPage = react.useCallback(
170
165
  (...options) => feed?.loadNextPageFollowers(...options),
171
166
  [feed]
@@ -185,7 +180,7 @@ function useFollowers(feedFromProps) {
185
180
  };
186
181
  }, [data, loadNextPage]);
187
182
  }
188
- const selector$7 = ({
183
+ const selector$8 = ({
189
184
  following_count,
190
185
  following,
191
186
  following_pagination
@@ -197,7 +192,7 @@ const selector$7 = ({
197
192
  function useFollowing(feedFromProps) {
198
193
  const feedFromContext = useFeedContext();
199
194
  const feed = feedFromProps ?? feedFromContext;
200
- const data = reactBindings.useStateStore(feed?.state, selector$7);
195
+ const data = reactBindings.useStateStore(feed?.state, selector$8);
201
196
  const loadNextPage = react.useCallback(
202
197
  (...options) => feed?.loadNextPageFollowing(...options),
203
198
  [feed]
@@ -220,9 +215,9 @@ function useFollowing(feedFromProps) {
220
215
  const useFeedMetadata = (feedFromProps) => {
221
216
  const feedFromContext = useFeedContext();
222
217
  const feed = feedFromProps ?? feedFromContext;
223
- return reactBindings.useStateStore(feed?.state, selector$6);
218
+ return reactBindings.useStateStore(feed?.state, selector$7);
224
219
  };
225
- const selector$6 = ({
220
+ const selector$7 = ({
226
221
  follower_count = 0,
227
222
  following_count = 0,
228
223
  created_by,
@@ -238,12 +233,12 @@ const selector$6 = ({
238
233
  const useOwnFollows = (feedFromProps) => {
239
234
  const feedFromContext = useFeedContext();
240
235
  const feed = feedFromProps ?? feedFromContext;
241
- return reactBindings.useStateStore(feed?.state, selector$5);
236
+ return reactBindings.useStateStore(feed?.state, selector$6);
242
237
  };
243
- const selector$5 = ({ own_follows }) => ({
238
+ const selector$6 = ({ own_follows }) => ({
244
239
  own_follows
245
240
  });
246
- const selector$4 = ({ notification_status }) => ({
241
+ const selector$5 = ({ notification_status }) => ({
247
242
  unread: notification_status?.unread ?? 0,
248
243
  unseen: notification_status?.unseen ?? 0,
249
244
  last_read_at: notification_status?.last_read_at,
@@ -254,9 +249,9 @@ const selector$4 = ({ notification_status }) => ({
254
249
  function useNotificationStatus(feedFromProps) {
255
250
  const feedFromContext = useFeedContext();
256
251
  const feed = feedFromProps ?? feedFromContext;
257
- return reactBindings.useStateStore(feed?.state, selector$4);
252
+ return reactBindings.useStateStore(feed?.state, selector$5);
258
253
  }
259
- const selector$3 = ({
254
+ const selector$4 = ({
260
255
  is_loading_activities,
261
256
  next,
262
257
  aggregated_activities = []
@@ -268,7 +263,7 @@ const selector$3 = ({
268
263
  function useAggregatedActivities(feedFromProps) {
269
264
  const feedFromContext = useFeedContext();
270
265
  const feed = feedFromProps ?? feedFromContext;
271
- const data = reactBindings.useStateStore(feed?.state, selector$3);
266
+ const data = reactBindings.useStateStore(feed?.state, selector$4);
272
267
  const loadNextPage = useStableCallback(async () => {
273
268
  if (!feed || !data?.has_next_page || data?.is_loading) {
274
269
  return;
@@ -369,6 +364,14 @@ function useActivityComments({
369
364
  };
370
365
  }, [data, loadNextPage]);
371
366
  }
367
+ const useOwnFollowings = (feedFromProps) => {
368
+ const feedFromContext = useFeedContext();
369
+ const feed = feedFromProps ?? feedFromContext;
370
+ return reactBindings.useStateStore(feed?.state, selector$3);
371
+ };
372
+ const selector$3 = ({ own_followings }) => ({
373
+ own_followings
374
+ });
372
375
  const StreamSearchResultsContext = react.createContext(void 0);
373
376
  const useSearchResultsContext = () => {
374
377
  return react.useContext(StreamSearchResultsContext);
@@ -466,6 +469,7 @@ exports.useIsAggregatedActivityRead = useIsAggregatedActivityRead;
466
469
  exports.useIsAggregatedActivitySeen = useIsAggregatedActivitySeen;
467
470
  exports.useNotificationStatus = useNotificationStatus;
468
471
  exports.useOwnCapabilities = useOwnCapabilities;
472
+ exports.useOwnFollowings = useOwnFollowings;
469
473
  exports.useOwnFollows = useOwnFollows;
470
474
  exports.useSearchContext = useSearchContext;
471
475
  exports.useSearchQuery = useSearchQuery;
@@ -1 +1 @@
1
- {"version":3,"file":"react-bindings.js","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":["useState","FeedsClient","useEffect","createContext","useContext","useStateStore","selector","useRef","useCallback","useMemo","isCommentResponse","checkHasAnotherPage"],"mappings":";;;;;;AAUO,MAAM,uBAAuB,CAAC;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AACJ,QAAM,CAAC,QAAQ,SAAS,IAAIA,MAAAA;AAAAA,IAC1B,MAAM,IAAIC,YAAAA,YAAY,QAAQ,OAAO;AAAA,EAAA;AAEvC,QAAM,CAAC,OAAO,QAAQ,I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AAM,cAAc,CAAC,EAAE,QAAQ,eAA2D;AAC/F,wCACG,mBAAmB,UAAnB,EAA4B,OAAO,QACjC,UACH;AAEJ;AAEA,YAAY,cAAc;ACAnB,MAAM,aAAa,CAAC;AAAA,EACzB;AAAA,EACA;AACF,MAA0C;AACxC,wCACG,kBAAkB,UAAlB,EAA2B,OAAO,MAChC,UACH;AAEJ;AAEA,WAAW,cAAc;ACXlB,MAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AACF,MAA4C;AAC1C,wCACG,oBAAoB,UAApB,EAA6B,OAAO,kBAClC,UACH;AAEJ;AAEA,aAAa,cAAc;ACXpB,MAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AACF,MAAmD;AACjD,wCACG,2BAA2B,UAA3B,EAAoC,OAAO,QACzC,UACH;AAEJ;AAEA,oBAAoB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"react-bindings.js","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":["useState","useEffect","FeedsClient","createContext","useContext","useStateStore","selector","useRef","useCallback","useMemo","isCommentResponse","checkHasAnotherPage"],"mappings":";;;;;;AAUO,MAAM,uBAAuB,CAAC;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AACJ,QAAM,CAAC,QAAQ,SAAS,IAAIA,MAAAA,SAA6B,IAAI;AAC7D,QAAM,CAAC,OAAO,QAAQ,IAAIA,MAAAA,SAAuB,IAAI;AACrD,QAAM,CAAC,gBAAgB,iBAAiB,IAAIA,MAAAA,SAAS,QAAQ;AAE7D,QAAM,CAAC,aAAa,IAAIA,MAAAA,SAAS,OAAO;AAExC,MAAI,OAAO;AACT,UAAM;AAAA,EACR;AAEA,MAAI,SAAS,OAAO,eAAe,IAAI;AACrC,sBAAkB,QAAQ;AAAA,EAC5B;AAEAC,QAAAA,UAAU,MAAM;AACd,UAAM,UAAU,IAAIC,wBAAY,QAAQ,aAAa;AAErD,UAAM,oBAAoB,QACvB,YAAY,gBAAgB,eAAe,EAC3C,KAAK,MAAM;AACV,eAAS,IAAI;AAAA,IACf,CAAC,EACA,MAAM,CAAC,QAAQ;AACd,eAAS,GAAG;AAAA,IACd,CA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1C,wCACG,oBAAoB,UAApB,EAA6B,OAAO,kBAClC,UACH;AAEJ;AAEA,aAAa,cAAc;ACXpB,MAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AACF,MAAmD;AACjD,wCACG,2BAA2B,UAA3B,EAAoC,OAAO,QACzC,UACH;AAEJ;AAEA,oBAAoB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/es/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import { StateStore } from "@stream-io/state-store";
2
2
  export * from "@stream-io/state-store";
3
- import { d as debounce } from "../feeds-client-BNhvggk2.mjs";
4
- import { A, C, a, F, S, b, c, n, m, k, g, e, h, f, j, i, o, r, s, u, l } from "../feeds-client-BNhvggk2.mjs";
3
+ import { d as debounce } from "../feeds-client-C-2_fdH1.mjs";
4
+ import { A, C, a, F, S, b, c, n, m, k, g, e, h, f, j, i, r, s, u, l } from "../feeds-client-C-2_fdH1.mjs";
5
5
  import { LogLevelEnum } from "@stream-io/logger";
6
+ const ownFeedFields = ["own_capabilities", "own_follows", "own_membership"];
6
7
  const ChannelOwnCapability = {
7
8
  BAN_CHANNEL_MEMBERS: "ban-channel-members",
8
9
  CAST_POLL_VOTE: "cast-poll-vote",
@@ -461,7 +462,7 @@ export {
461
462
  f as isReactionResponse,
462
463
  j as isVideoFile,
463
464
  i as isVoteAnswer,
464
- o as ownFeedFields,
465
+ ownFeedFields,
465
466
  r as replaceUniqueArrayMerge,
466
467
  s as shouldUpdateState,
467
468
  u as uniqueArrayMerge,