@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.
- package/@react-bindings/hooks/search-state-hooks/index.ts +3 -0
- package/@react-bindings/index.ts +5 -0
- package/CHANGELOG.md +7 -0
- package/dist/@react-bindings/contexts/StreamSearchContext.d.ts +12 -0
- package/dist/@react-bindings/contexts/StreamSearchResultsContext.d.ts +12 -0
- package/dist/@react-bindings/hooks/search-state-hooks/index.d.ts +3 -0
- package/dist/@react-bindings/hooks/search-state-hooks/useSearchQuery.d.ts +4 -0
- package/dist/@react-bindings/hooks/search-state-hooks/useSearchResult.d.ts +8 -0
- package/dist/@react-bindings/hooks/search-state-hooks/useSearchSources.d.ts +4 -0
- package/dist/@react-bindings/index.d.ts +5 -0
- package/dist/@react-bindings/wrappers/StreamSearch.d.ts +12 -0
- package/dist/@react-bindings/wrappers/StreamSearchResults.d.ts +12 -0
- package/dist/index-react-bindings.browser.cjs +85 -16
- package/dist/index-react-bindings.browser.cjs.map +1 -1
- package/dist/index-react-bindings.browser.js +77 -17
- package/dist/index-react-bindings.browser.js.map +1 -1
- package/dist/index-react-bindings.node.cjs +85 -16
- package/dist/index-react-bindings.node.cjs.map +1 -1
- package/dist/index-react-bindings.node.js +77 -17
- package/dist/index-react-bindings.node.js.map +1 -1
- package/dist/index.browser.cjs +26 -125
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +26 -125
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +26 -125
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +26 -125
- package/dist/index.node.js.map +1 -1
- package/dist/src/common/BaseSearchSource.d.ts +3 -1
- package/dist/src/common/FeedSearchSource.d.ts +5 -1
- package/dist/src/common/SearchController.d.ts +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/ActivitySearchSource.ts +5 -15
- package/src/common/BaseSearchSource.ts +9 -9
- package/src/common/FeedSearchSource.ts +20 -65
- package/src/common/SearchController.ts +2 -0
- package/src/common/UserSearchSource.ts +9 -61
package/@react-bindings/index.ts
CHANGED
|
@@ -5,14 +5,19 @@ export * from './hooks/useCreateFeedsClient';
|
|
|
5
5
|
|
|
6
6
|
export * from './hooks/client-state-hooks';
|
|
7
7
|
export * from './hooks/feed-state-hooks';
|
|
8
|
+
export * from './hooks/search-state-hooks';
|
|
8
9
|
export * from './hooks/util';
|
|
9
10
|
|
|
10
11
|
// Contexts
|
|
11
12
|
|
|
12
13
|
export * from './contexts/StreamFeedsContext';
|
|
13
14
|
export * from './contexts/StreamFeedContext';
|
|
15
|
+
export * from './contexts/StreamSearchContext';
|
|
16
|
+
export * from './contexts/StreamSearchResultsContext';
|
|
14
17
|
|
|
15
18
|
// Wrappers
|
|
16
19
|
|
|
17
20
|
export * from './wrappers/StreamFeeds';
|
|
18
21
|
export * from './wrappers/StreamFeed';
|
|
22
|
+
export * from './wrappers/StreamSearch';
|
|
23
|
+
export * from './wrappers/StreamSearchResults';
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.1.10](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.1.9...@stream-io/feeds-client-0.1.10) (2025-07-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* search implementation and bindings ([#78](https://github.com/GetStream/stream-feeds-js/issues/78)) ([02d7dd1](https://github.com/GetStream/stream-feeds-js/commit/02d7dd1fd1f01df411e92db328106987c366e4d4))
|
|
11
|
+
|
|
5
12
|
## [0.1.9](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.1.8...@stream-io/feeds-client-0.1.9) (2025-07-28)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SearchController } from '../../src/common/SearchController';
|
|
2
|
+
export declare const StreamSearchContext: import("react").Context<SearchController | undefined>;
|
|
3
|
+
/**
|
|
4
|
+
* The props for the StreamSearchProvider component.
|
|
5
|
+
*/
|
|
6
|
+
export type StreamSearchContextProps = {
|
|
7
|
+
searchController: SearchController;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Hook to access the nearest SearchController instance.
|
|
11
|
+
*/
|
|
12
|
+
export declare const useSearchContext: () => SearchController | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SearchSource } from '../../src/common/BaseSearchSource';
|
|
2
|
+
export declare const StreamSearchResultsContext: import("react").Context<SearchSource<any> | undefined>;
|
|
3
|
+
/**
|
|
4
|
+
* The props for the StreamSearchResultsProvider component.
|
|
5
|
+
*/
|
|
6
|
+
export type StreamSearchResultsContextProps = {
|
|
7
|
+
source: SearchSource;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Hook to access the nearest SearchSource instance.
|
|
11
|
+
*/
|
|
12
|
+
export declare const useSearchResultsContext: () => SearchSource<any> | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SearchSource } from '../../../src/common/BaseSearchSource';
|
|
2
|
+
export declare const useSearchResult: (sourceFromProps?: SearchSource) => {
|
|
3
|
+
items: any[] | undefined;
|
|
4
|
+
error: Error | undefined;
|
|
5
|
+
isLoading: boolean | undefined;
|
|
6
|
+
hasNext: boolean | undefined;
|
|
7
|
+
loadMore: import("../internal").StableCallback<[], Promise<void>>;
|
|
8
|
+
};
|
|
@@ -2,8 +2,13 @@ export * from './hooks/useStateStore';
|
|
|
2
2
|
export * from './hooks/useCreateFeedsClient';
|
|
3
3
|
export * from './hooks/client-state-hooks';
|
|
4
4
|
export * from './hooks/feed-state-hooks';
|
|
5
|
+
export * from './hooks/search-state-hooks';
|
|
5
6
|
export * from './hooks/util';
|
|
6
7
|
export * from './contexts/StreamFeedsContext';
|
|
7
8
|
export * from './contexts/StreamFeedContext';
|
|
9
|
+
export * from './contexts/StreamSearchContext';
|
|
10
|
+
export * from './contexts/StreamSearchResultsContext';
|
|
8
11
|
export * from './wrappers/StreamFeeds';
|
|
9
12
|
export * from './wrappers/StreamFeed';
|
|
13
|
+
export * from './wrappers/StreamSearch';
|
|
14
|
+
export * from './wrappers/StreamSearchResults';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import type { SearchController } from '../../src/common/SearchController';
|
|
3
|
+
/**
|
|
4
|
+
* The props for the StreamSearch component. It accepts a `SearchController` instance.
|
|
5
|
+
*/
|
|
6
|
+
export type StreamSearchProps = {
|
|
7
|
+
searchController: SearchController | undefined;
|
|
8
|
+
};
|
|
9
|
+
export declare const StreamSearch: {
|
|
10
|
+
({ searchController, children, }: PropsWithChildren<StreamSearchProps>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import type { SearchSource } from '../../src/common/BaseSearchSource';
|
|
3
|
+
/**
|
|
4
|
+
* The props for the StreamSearchResults component. It accepts a `SearchSource` instance.
|
|
5
|
+
*/
|
|
6
|
+
export type StreamSearchResultsProps = {
|
|
7
|
+
source: SearchSource;
|
|
8
|
+
};
|
|
9
|
+
export declare const StreamSearchResults: {
|
|
10
|
+
({ source, children, }: PropsWithChildren<StreamSearchResultsProps>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
@@ -5729,10 +5729,10 @@ const useFeedsClient = () => {
|
|
|
5729
5729
|
*/
|
|
5730
5730
|
const useClientConnectedUser = () => {
|
|
5731
5731
|
const client = useFeedsClient();
|
|
5732
|
-
const { user } = useStateStore(client?.state, selector$
|
|
5732
|
+
const { user } = useStateStore(client?.state, selector$a) ?? {};
|
|
5733
5733
|
return user;
|
|
5734
5734
|
};
|
|
5735
|
-
const selector$
|
|
5735
|
+
const selector$a = (nextState) => ({
|
|
5736
5736
|
user: nextState.connected_user,
|
|
5737
5737
|
});
|
|
5738
5738
|
|
|
@@ -5741,10 +5741,10 @@ const selector$7 = (nextState) => ({
|
|
|
5741
5741
|
*/
|
|
5742
5742
|
const useWsConnectionState = () => {
|
|
5743
5743
|
const client = useFeedsClient();
|
|
5744
|
-
const { is_healthy } = useStateStore(client?.state, selector$
|
|
5744
|
+
const { is_healthy } = useStateStore(client?.state, selector$9) ?? {};
|
|
5745
5745
|
return { is_healthy };
|
|
5746
5746
|
};
|
|
5747
|
-
const selector$
|
|
5747
|
+
const selector$9 = (nextState) => ({
|
|
5748
5748
|
is_healthy: nextState.is_ws_connection_healthy,
|
|
5749
5749
|
});
|
|
5750
5750
|
|
|
@@ -5794,7 +5794,7 @@ const useStableCallback = (callback) => {
|
|
|
5794
5794
|
const useFeedActivities = (feedFromProps) => {
|
|
5795
5795
|
const feedFromContext = useFeedContext();
|
|
5796
5796
|
const feed = feedFromProps ?? feedFromContext;
|
|
5797
|
-
const data = useStateStore(feed?.state, selector$
|
|
5797
|
+
const data = useStateStore(feed?.state, selector$8);
|
|
5798
5798
|
const loadNextPage = useStableCallback(async () => {
|
|
5799
5799
|
if (!feed || !data?.has_next_page || data?.is_loading) {
|
|
5800
5800
|
return;
|
|
@@ -5803,7 +5803,7 @@ const useFeedActivities = (feedFromProps) => {
|
|
|
5803
5803
|
});
|
|
5804
5804
|
return react.useMemo(() => ({ ...data, loadNextPage }), [data, loadNextPage]);
|
|
5805
5805
|
};
|
|
5806
|
-
const selector$
|
|
5806
|
+
const selector$8 = ({ is_loading_activities, next, activities = [] }) => ({
|
|
5807
5807
|
is_loading: is_loading_activities,
|
|
5808
5808
|
has_next_page: typeof next !== 'undefined',
|
|
5809
5809
|
activities,
|
|
@@ -5876,13 +5876,13 @@ const FeedOwnCapability = {
|
|
|
5876
5876
|
};
|
|
5877
5877
|
|
|
5878
5878
|
const stableEmptyArray = [];
|
|
5879
|
-
const selector$
|
|
5879
|
+
const selector$7 = (currentState) => ({
|
|
5880
5880
|
oc: currentState.own_capabilities ?? stableEmptyArray,
|
|
5881
5881
|
});
|
|
5882
5882
|
const useOwnCapabilities = (feedFromProps) => {
|
|
5883
5883
|
const feedFromContext = useFeedContext();
|
|
5884
5884
|
const feed = feedFromProps ?? feedFromContext;
|
|
5885
|
-
const { oc = stableEmptyArray } = useStateStore(feed?.state, selector$
|
|
5885
|
+
const { oc = stableEmptyArray } = useStateStore(feed?.state, selector$7) ?? {};
|
|
5886
5886
|
return react.useMemo(() => ({
|
|
5887
5887
|
can_add_activity: oc.indexOf(FeedOwnCapability.ADD_ACTIVITY) > -1,
|
|
5888
5888
|
can_add_activity_reaction: oc.indexOf(FeedOwnCapability.ADD_ACTIVITY_REACTION) > -1,
|
|
@@ -5917,7 +5917,7 @@ const useOwnCapabilities = (feedFromProps) => {
|
|
|
5917
5917
|
}), [oc]);
|
|
5918
5918
|
};
|
|
5919
5919
|
|
|
5920
|
-
const selector$
|
|
5920
|
+
const selector$6 = ({ follower_count, followers, followers_pagination, }) => ({
|
|
5921
5921
|
follower_count,
|
|
5922
5922
|
followers,
|
|
5923
5923
|
followers_pagination,
|
|
@@ -5925,7 +5925,7 @@ const selector$3 = ({ follower_count, followers, followers_pagination, }) => ({
|
|
|
5925
5925
|
function useFollowers(feedFromProps) {
|
|
5926
5926
|
const feedFromContext = useFeedContext();
|
|
5927
5927
|
const feed = feedFromProps ?? feedFromContext;
|
|
5928
|
-
const data = useStateStore(feed?.state, selector$
|
|
5928
|
+
const data = useStateStore(feed?.state, selector$6);
|
|
5929
5929
|
const loadNextPage = react.useCallback((...options) => feed?.loadNextPageFollowers(...options), [feed]);
|
|
5930
5930
|
return react.useMemo(() => {
|
|
5931
5931
|
if (!data) {
|
|
@@ -5940,7 +5940,7 @@ function useFollowers(feedFromProps) {
|
|
|
5940
5940
|
}, [data, loadNextPage]);
|
|
5941
5941
|
}
|
|
5942
5942
|
|
|
5943
|
-
const selector$
|
|
5943
|
+
const selector$5 = ({ following_count, following, following_pagination, }) => ({
|
|
5944
5944
|
following_count,
|
|
5945
5945
|
following,
|
|
5946
5946
|
following_pagination,
|
|
@@ -5948,7 +5948,7 @@ const selector$2 = ({ following_count, following, following_pagination, }) => ({
|
|
|
5948
5948
|
function useFollowing(feedFromProps) {
|
|
5949
5949
|
const feedFromContext = useFeedContext();
|
|
5950
5950
|
const feed = feedFromProps ?? feedFromContext;
|
|
5951
|
-
const data = useStateStore(feed?.state, selector$
|
|
5951
|
+
const data = useStateStore(feed?.state, selector$5);
|
|
5952
5952
|
const loadNextPage = react.useCallback((...options) => feed?.loadNextPageFollowing(...options), [feed]);
|
|
5953
5953
|
return react.useMemo(() => {
|
|
5954
5954
|
if (!data) {
|
|
@@ -5970,9 +5970,9 @@ function useFollowing(feedFromProps) {
|
|
|
5970
5970
|
const useFeedMetadata = (feedFromProps) => {
|
|
5971
5971
|
const feedFromContext = useFeedContext();
|
|
5972
5972
|
const feed = feedFromProps ?? feedFromContext;
|
|
5973
|
-
return useStateStore(feed?.state, selector$
|
|
5973
|
+
return useStateStore(feed?.state, selector$4);
|
|
5974
5974
|
};
|
|
5975
|
-
const selector$
|
|
5975
|
+
const selector$4 = ({ follower_count = 0, following_count = 0, created_by, created_at, updated_at, }) => ({
|
|
5976
5976
|
created_by,
|
|
5977
5977
|
follower_count,
|
|
5978
5978
|
following_count,
|
|
@@ -5987,12 +5987,62 @@ const selector$1 = ({ follower_count = 0, following_count = 0, created_by, creat
|
|
|
5987
5987
|
const useOwnFollows = (feedFromProps) => {
|
|
5988
5988
|
const feedFromContext = useFeedContext();
|
|
5989
5989
|
const feed = feedFromProps ?? feedFromContext;
|
|
5990
|
-
return useStateStore(feed?.state, selector);
|
|
5990
|
+
return useStateStore(feed?.state, selector$3);
|
|
5991
5991
|
};
|
|
5992
|
-
const selector = ({ own_follows }) => ({
|
|
5992
|
+
const selector$3 = ({ own_follows }) => ({
|
|
5993
5993
|
own_follows,
|
|
5994
5994
|
});
|
|
5995
5995
|
|
|
5996
|
+
const StreamSearchResultsContext = react.createContext(undefined);
|
|
5997
|
+
/**
|
|
5998
|
+
* Hook to access the nearest SearchSource instance.
|
|
5999
|
+
*/
|
|
6000
|
+
const useSearchResultsContext = () => {
|
|
6001
|
+
return react.useContext(StreamSearchResultsContext);
|
|
6002
|
+
};
|
|
6003
|
+
|
|
6004
|
+
const useSearchResult = (sourceFromProps) => {
|
|
6005
|
+
const sourceFromContext = useSearchResultsContext();
|
|
6006
|
+
const source = sourceFromProps ?? sourceFromContext;
|
|
6007
|
+
const { items, error, isLoading, hasNext } = useStateStore(source?.state, selector$2) ?? {};
|
|
6008
|
+
const loadMore = useStableCallback(async () => {
|
|
6009
|
+
source?.search();
|
|
6010
|
+
});
|
|
6011
|
+
return react.useMemo(() => ({ items, error, isLoading, hasNext, loadMore }), [error, hasNext, isLoading, items, loadMore]);
|
|
6012
|
+
};
|
|
6013
|
+
const selector$2 = ({ items, isLoading, hasNext, lastQueryError, }) => ({
|
|
6014
|
+
items,
|
|
6015
|
+
isLoading,
|
|
6016
|
+
hasNext,
|
|
6017
|
+
error: lastQueryError,
|
|
6018
|
+
});
|
|
6019
|
+
|
|
6020
|
+
const StreamSearchContext = react.createContext(undefined);
|
|
6021
|
+
/**
|
|
6022
|
+
* Hook to access the nearest SearchController instance.
|
|
6023
|
+
*/
|
|
6024
|
+
const useSearchContext = () => {
|
|
6025
|
+
return react.useContext(StreamSearchContext);
|
|
6026
|
+
};
|
|
6027
|
+
|
|
6028
|
+
const useSearchQuery = (controllerFromProps) => {
|
|
6029
|
+
const controllerFromState = useSearchContext();
|
|
6030
|
+
const controller = controllerFromProps ?? controllerFromState;
|
|
6031
|
+
return useStateStore(controller?.state, selector$1);
|
|
6032
|
+
};
|
|
6033
|
+
const selector$1 = ({ searchQuery }) => ({
|
|
6034
|
+
searchQuery,
|
|
6035
|
+
});
|
|
6036
|
+
|
|
6037
|
+
const useSearchSources = (controllerFromProps) => {
|
|
6038
|
+
const controllerFromState = useSearchContext();
|
|
6039
|
+
const controller = controllerFromProps ?? controllerFromState;
|
|
6040
|
+
return useStateStore(controller?.state, selector);
|
|
6041
|
+
};
|
|
6042
|
+
const selector = ({ sources }) => ({
|
|
6043
|
+
sources,
|
|
6044
|
+
});
|
|
6045
|
+
|
|
5996
6046
|
/**
|
|
5997
6047
|
* A utility hook that takes in an entity and a reaction type, and creates reaction actions
|
|
5998
6048
|
* that can then be used on the UI. The entity can be either an ActivityResponse or a CommentResponse
|
|
@@ -6064,10 +6114,24 @@ const StreamFeed = ({ feed, children }) => {
|
|
|
6064
6114
|
};
|
|
6065
6115
|
StreamFeed.displayName = 'StreamFeed';
|
|
6066
6116
|
|
|
6117
|
+
const StreamSearch = ({ searchController, children, }) => {
|
|
6118
|
+
return (jsxRuntime.jsx(StreamSearchContext.Provider, { value: searchController, children: children }));
|
|
6119
|
+
};
|
|
6120
|
+
StreamSearch.displayName = 'StreamSearch';
|
|
6121
|
+
|
|
6122
|
+
const StreamSearchResults = ({ source, children, }) => {
|
|
6123
|
+
return (jsxRuntime.jsx(StreamSearchResultsContext.Provider, { value: source, children: children }));
|
|
6124
|
+
};
|
|
6125
|
+
StreamSearchResults.displayName = 'StreamSearchResults';
|
|
6126
|
+
|
|
6067
6127
|
exports.StreamFeed = StreamFeed;
|
|
6068
6128
|
exports.StreamFeedContext = StreamFeedContext;
|
|
6069
6129
|
exports.StreamFeeds = StreamFeeds;
|
|
6070
6130
|
exports.StreamFeedsContext = StreamFeedsContext;
|
|
6131
|
+
exports.StreamSearch = StreamSearch;
|
|
6132
|
+
exports.StreamSearchContext = StreamSearchContext;
|
|
6133
|
+
exports.StreamSearchResults = StreamSearchResults;
|
|
6134
|
+
exports.StreamSearchResultsContext = StreamSearchResultsContext;
|
|
6071
6135
|
exports.useBookmarkActions = useBookmarkActions;
|
|
6072
6136
|
exports.useClientConnectedUser = useClientConnectedUser;
|
|
6073
6137
|
exports.useComments = useComments;
|
|
@@ -6081,6 +6145,11 @@ exports.useFollowing = useFollowing;
|
|
|
6081
6145
|
exports.useOwnCapabilities = useOwnCapabilities;
|
|
6082
6146
|
exports.useOwnFollows = useOwnFollows;
|
|
6083
6147
|
exports.useReactionActions = useReactionActions;
|
|
6148
|
+
exports.useSearchContext = useSearchContext;
|
|
6149
|
+
exports.useSearchQuery = useSearchQuery;
|
|
6150
|
+
exports.useSearchResult = useSearchResult;
|
|
6151
|
+
exports.useSearchResultsContext = useSearchResultsContext;
|
|
6152
|
+
exports.useSearchSources = useSearchSources;
|
|
6084
6153
|
exports.useStateStore = useStateStore;
|
|
6085
6154
|
exports.useWsConnectionState = useWsConnectionState;
|
|
6086
6155
|
//# sourceMappingURL=index-react-bindings.browser.cjs.map
|