@stream-io/feeds-client 0.1.9 → 0.1.10

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 (38) hide show
  1. package/@react-bindings/hooks/search-state-hooks/index.ts +3 -0
  2. package/@react-bindings/index.ts +5 -0
  3. package/CHANGELOG.md +7 -0
  4. package/dist/@react-bindings/contexts/StreamSearchContext.d.ts +12 -0
  5. package/dist/@react-bindings/contexts/StreamSearchResultsContext.d.ts +12 -0
  6. package/dist/@react-bindings/hooks/search-state-hooks/index.d.ts +3 -0
  7. package/dist/@react-bindings/hooks/search-state-hooks/useSearchQuery.d.ts +4 -0
  8. package/dist/@react-bindings/hooks/search-state-hooks/useSearchResult.d.ts +8 -0
  9. package/dist/@react-bindings/hooks/search-state-hooks/useSearchSources.d.ts +4 -0
  10. package/dist/@react-bindings/index.d.ts +5 -0
  11. package/dist/@react-bindings/wrappers/StreamSearch.d.ts +12 -0
  12. package/dist/@react-bindings/wrappers/StreamSearchResults.d.ts +12 -0
  13. package/dist/index-react-bindings.browser.cjs +85 -16
  14. package/dist/index-react-bindings.browser.cjs.map +1 -1
  15. package/dist/index-react-bindings.browser.js +77 -17
  16. package/dist/index-react-bindings.browser.js.map +1 -1
  17. package/dist/index-react-bindings.node.cjs +85 -16
  18. package/dist/index-react-bindings.node.cjs.map +1 -1
  19. package/dist/index-react-bindings.node.js +77 -17
  20. package/dist/index-react-bindings.node.js.map +1 -1
  21. package/dist/index.browser.cjs +26 -125
  22. package/dist/index.browser.cjs.map +1 -1
  23. package/dist/index.browser.js +26 -125
  24. package/dist/index.browser.js.map +1 -1
  25. package/dist/index.node.cjs +26 -125
  26. package/dist/index.node.cjs.map +1 -1
  27. package/dist/index.node.js +26 -125
  28. package/dist/index.node.js.map +1 -1
  29. package/dist/src/common/BaseSearchSource.d.ts +3 -1
  30. package/dist/src/common/FeedSearchSource.d.ts +5 -1
  31. package/dist/src/common/SearchController.d.ts +2 -0
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +1 -1
  34. package/src/common/ActivitySearchSource.ts +5 -15
  35. package/src/common/BaseSearchSource.ts +9 -9
  36. package/src/common/FeedSearchSource.ts +20 -65
  37. package/src/common/SearchController.ts +2 -0
  38. package/src/common/UserSearchSource.ts +9 -61
@@ -5727,10 +5727,10 @@ const useFeedsClient = () => {
5727
5727
  */
5728
5728
  const useClientConnectedUser = () => {
5729
5729
  const client = useFeedsClient();
5730
- const { user } = useStateStore(client?.state, selector$7) ?? {};
5730
+ const { user } = useStateStore(client?.state, selector$a) ?? {};
5731
5731
  return user;
5732
5732
  };
5733
- const selector$7 = (nextState) => ({
5733
+ const selector$a = (nextState) => ({
5734
5734
  user: nextState.connected_user,
5735
5735
  });
5736
5736
 
@@ -5739,10 +5739,10 @@ const selector$7 = (nextState) => ({
5739
5739
  */
5740
5740
  const useWsConnectionState = () => {
5741
5741
  const client = useFeedsClient();
5742
- const { is_healthy } = useStateStore(client?.state, selector$6) ?? {};
5742
+ const { is_healthy } = useStateStore(client?.state, selector$9) ?? {};
5743
5743
  return { is_healthy };
5744
5744
  };
5745
- const selector$6 = (nextState) => ({
5745
+ const selector$9 = (nextState) => ({
5746
5746
  is_healthy: nextState.is_ws_connection_healthy,
5747
5747
  });
5748
5748
 
@@ -5792,7 +5792,7 @@ const useStableCallback = (callback) => {
5792
5792
  const useFeedActivities = (feedFromProps) => {
5793
5793
  const feedFromContext = useFeedContext();
5794
5794
  const feed = feedFromProps ?? feedFromContext;
5795
- const data = useStateStore(feed?.state, selector$5);
5795
+ const data = useStateStore(feed?.state, selector$8);
5796
5796
  const loadNextPage = useStableCallback(async () => {
5797
5797
  if (!feed || !data?.has_next_page || data?.is_loading) {
5798
5798
  return;
@@ -5801,7 +5801,7 @@ const useFeedActivities = (feedFromProps) => {
5801
5801
  });
5802
5802
  return useMemo(() => ({ ...data, loadNextPage }), [data, loadNextPage]);
5803
5803
  };
5804
- const selector$5 = ({ is_loading_activities, next, activities = [] }) => ({
5804
+ const selector$8 = ({ is_loading_activities, next, activities = [] }) => ({
5805
5805
  is_loading: is_loading_activities,
5806
5806
  has_next_page: typeof next !== 'undefined',
5807
5807
  activities,
@@ -5874,13 +5874,13 @@ const FeedOwnCapability = {
5874
5874
  };
5875
5875
 
5876
5876
  const stableEmptyArray = [];
5877
- const selector$4 = (currentState) => ({
5877
+ const selector$7 = (currentState) => ({
5878
5878
  oc: currentState.own_capabilities ?? stableEmptyArray,
5879
5879
  });
5880
5880
  const useOwnCapabilities = (feedFromProps) => {
5881
5881
  const feedFromContext = useFeedContext();
5882
5882
  const feed = feedFromProps ?? feedFromContext;
5883
- const { oc = stableEmptyArray } = useStateStore(feed?.state, selector$4) ?? {};
5883
+ const { oc = stableEmptyArray } = useStateStore(feed?.state, selector$7) ?? {};
5884
5884
  return useMemo(() => ({
5885
5885
  can_add_activity: oc.indexOf(FeedOwnCapability.ADD_ACTIVITY) > -1,
5886
5886
  can_add_activity_reaction: oc.indexOf(FeedOwnCapability.ADD_ACTIVITY_REACTION) > -1,
@@ -5915,7 +5915,7 @@ const useOwnCapabilities = (feedFromProps) => {
5915
5915
  }), [oc]);
5916
5916
  };
5917
5917
 
5918
- const selector$3 = ({ follower_count, followers, followers_pagination, }) => ({
5918
+ const selector$6 = ({ follower_count, followers, followers_pagination, }) => ({
5919
5919
  follower_count,
5920
5920
  followers,
5921
5921
  followers_pagination,
@@ -5923,7 +5923,7 @@ const selector$3 = ({ follower_count, followers, followers_pagination, }) => ({
5923
5923
  function useFollowers(feedFromProps) {
5924
5924
  const feedFromContext = useFeedContext();
5925
5925
  const feed = feedFromProps ?? feedFromContext;
5926
- const data = useStateStore(feed?.state, selector$3);
5926
+ const data = useStateStore(feed?.state, selector$6);
5927
5927
  const loadNextPage = useCallback((...options) => feed?.loadNextPageFollowers(...options), [feed]);
5928
5928
  return useMemo(() => {
5929
5929
  if (!data) {
@@ -5938,7 +5938,7 @@ function useFollowers(feedFromProps) {
5938
5938
  }, [data, loadNextPage]);
5939
5939
  }
5940
5940
 
5941
- const selector$2 = ({ following_count, following, following_pagination, }) => ({
5941
+ const selector$5 = ({ following_count, following, following_pagination, }) => ({
5942
5942
  following_count,
5943
5943
  following,
5944
5944
  following_pagination,
@@ -5946,7 +5946,7 @@ const selector$2 = ({ following_count, following, following_pagination, }) => ({
5946
5946
  function useFollowing(feedFromProps) {
5947
5947
  const feedFromContext = useFeedContext();
5948
5948
  const feed = feedFromProps ?? feedFromContext;
5949
- const data = useStateStore(feed?.state, selector$2);
5949
+ const data = useStateStore(feed?.state, selector$5);
5950
5950
  const loadNextPage = useCallback((...options) => feed?.loadNextPageFollowing(...options), [feed]);
5951
5951
  return useMemo(() => {
5952
5952
  if (!data) {
@@ -5968,9 +5968,9 @@ function useFollowing(feedFromProps) {
5968
5968
  const useFeedMetadata = (feedFromProps) => {
5969
5969
  const feedFromContext = useFeedContext();
5970
5970
  const feed = feedFromProps ?? feedFromContext;
5971
- return useStateStore(feed?.state, selector$1);
5971
+ return useStateStore(feed?.state, selector$4);
5972
5972
  };
5973
- const selector$1 = ({ follower_count = 0, following_count = 0, created_by, created_at, updated_at, }) => ({
5973
+ const selector$4 = ({ follower_count = 0, following_count = 0, created_by, created_at, updated_at, }) => ({
5974
5974
  created_by,
5975
5975
  follower_count,
5976
5976
  following_count,
@@ -5985,12 +5985,62 @@ const selector$1 = ({ follower_count = 0, following_count = 0, created_by, creat
5985
5985
  const useOwnFollows = (feedFromProps) => {
5986
5986
  const feedFromContext = useFeedContext();
5987
5987
  const feed = feedFromProps ?? feedFromContext;
5988
- return useStateStore(feed?.state, selector);
5988
+ return useStateStore(feed?.state, selector$3);
5989
5989
  };
5990
- const selector = ({ own_follows }) => ({
5990
+ const selector$3 = ({ own_follows }) => ({
5991
5991
  own_follows,
5992
5992
  });
5993
5993
 
5994
+ const StreamSearchResultsContext = createContext(undefined);
5995
+ /**
5996
+ * Hook to access the nearest SearchSource instance.
5997
+ */
5998
+ const useSearchResultsContext = () => {
5999
+ return useContext(StreamSearchResultsContext);
6000
+ };
6001
+
6002
+ const useSearchResult = (sourceFromProps) => {
6003
+ const sourceFromContext = useSearchResultsContext();
6004
+ const source = sourceFromProps ?? sourceFromContext;
6005
+ const { items, error, isLoading, hasNext } = useStateStore(source?.state, selector$2) ?? {};
6006
+ const loadMore = useStableCallback(async () => {
6007
+ source?.search();
6008
+ });
6009
+ return useMemo(() => ({ items, error, isLoading, hasNext, loadMore }), [error, hasNext, isLoading, items, loadMore]);
6010
+ };
6011
+ const selector$2 = ({ items, isLoading, hasNext, lastQueryError, }) => ({
6012
+ items,
6013
+ isLoading,
6014
+ hasNext,
6015
+ error: lastQueryError,
6016
+ });
6017
+
6018
+ const StreamSearchContext = createContext(undefined);
6019
+ /**
6020
+ * Hook to access the nearest SearchController instance.
6021
+ */
6022
+ const useSearchContext = () => {
6023
+ return useContext(StreamSearchContext);
6024
+ };
6025
+
6026
+ const useSearchQuery = (controllerFromProps) => {
6027
+ const controllerFromState = useSearchContext();
6028
+ const controller = controllerFromProps ?? controllerFromState;
6029
+ return useStateStore(controller?.state, selector$1);
6030
+ };
6031
+ const selector$1 = ({ searchQuery }) => ({
6032
+ searchQuery,
6033
+ });
6034
+
6035
+ const useSearchSources = (controllerFromProps) => {
6036
+ const controllerFromState = useSearchContext();
6037
+ const controller = controllerFromProps ?? controllerFromState;
6038
+ return useStateStore(controller?.state, selector);
6039
+ };
6040
+ const selector = ({ sources }) => ({
6041
+ sources,
6042
+ });
6043
+
5994
6044
  /**
5995
6045
  * A utility hook that takes in an entity and a reaction type, and creates reaction actions
5996
6046
  * that can then be used on the UI. The entity can be either an ActivityResponse or a CommentResponse
@@ -6062,5 +6112,15 @@ const StreamFeed = ({ feed, children }) => {
6062
6112
  };
6063
6113
  StreamFeed.displayName = 'StreamFeed';
6064
6114
 
6065
- export { StreamFeed, StreamFeedContext, StreamFeeds, StreamFeedsContext, useBookmarkActions, useClientConnectedUser, useComments, useCreateFeedsClient, useFeedActivities, useFeedContext, useFeedMetadata, useFeedsClient, useFollowers, useFollowing, useOwnCapabilities, useOwnFollows, useReactionActions, useStateStore, useWsConnectionState };
6115
+ const StreamSearch = ({ searchController, children, }) => {
6116
+ return (jsx(StreamSearchContext.Provider, { value: searchController, children: children }));
6117
+ };
6118
+ StreamSearch.displayName = 'StreamSearch';
6119
+
6120
+ const StreamSearchResults = ({ source, children, }) => {
6121
+ return (jsx(StreamSearchResultsContext.Provider, { value: source, children: children }));
6122
+ };
6123
+ StreamSearchResults.displayName = 'StreamSearchResults';
6124
+
6125
+ export { StreamFeed, StreamFeedContext, StreamFeeds, StreamFeedsContext, StreamSearch, StreamSearchContext, StreamSearchResults, StreamSearchResultsContext, useBookmarkActions, useClientConnectedUser, useComments, useCreateFeedsClient, useFeedActivities, useFeedContext, useFeedMetadata, useFeedsClient, useFollowers, useFollowing, useOwnCapabilities, useOwnFollows, useReactionActions, useSearchContext, useSearchQuery, useSearchResult, useSearchResultsContext, useSearchSources, useStateStore, useWsConnectionState };
6066
6126
  //# sourceMappingURL=index-react-bindings.node.js.map