stream-chat 9.45.6 → 9.46.0

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.
@@ -74,6 +74,7 @@ __export(index_exports, {
74
74
  Channel: () => Channel,
75
75
  ChannelBatchUpdater: () => ChannelBatchUpdater,
76
76
  ChannelManager: () => ChannelManager,
77
+ ChannelMemberSearchSource: () => ChannelMemberSearchSource,
77
78
  ChannelSearchSource: () => ChannelSearchSource,
78
79
  ChannelState: () => ChannelState,
79
80
  CheckSignature: () => CheckSignature,
@@ -4605,110 +4606,6 @@ var BaseSearchSourceSync = class extends BaseSearchSourceBase {
4605
4606
  }
4606
4607
  };
4607
4608
 
4608
- // src/search/SearchController.ts
4609
- var SearchController = class {
4610
- constructor({ config, sources } = {}) {
4611
- this.addSource = (source) => {
4612
- this.state.partialNext({
4613
- sources: [...this.sources, source]
4614
- });
4615
- };
4616
- this.getSource = (sourceType) => this.sources.find((s) => s.type === sourceType);
4617
- this.removeSource = (sourceType) => {
4618
- const newSources = this.sources.filter((s) => s.type !== sourceType);
4619
- if (newSources.length === this.sources.length) return;
4620
- this.state.partialNext({ sources: newSources });
4621
- };
4622
- this.activateSource = (sourceType) => {
4623
- const source = this.getSource(sourceType);
4624
- if (!source || source.isActive) return;
4625
- if (this.config.keepSingleActiveSource) {
4626
- this.sources.forEach((s) => {
4627
- if (s.type !== sourceType) {
4628
- s.deactivate();
4629
- }
4630
- });
4631
- }
4632
- source.activate();
4633
- this.state.partialNext({ sources: [...this.sources] });
4634
- };
4635
- this.deactivateSource = (sourceType) => {
4636
- const source = this.getSource(sourceType);
4637
- if (!source?.isActive) return;
4638
- if (this.activeSources.length === 1) return;
4639
- source.deactivate();
4640
- this.state.partialNext({ sources: [...this.sources] });
4641
- };
4642
- this.activate = () => {
4643
- if (!this.activeSources.length) {
4644
- const sourcesToActivate = this.config.keepSingleActiveSource ? this.sources.slice(0, 1) : this.sources;
4645
- sourcesToActivate.forEach((s) => s.activate());
4646
- }
4647
- if (this.isActive) return;
4648
- this.state.partialNext({ isActive: true });
4649
- };
4650
- this.search = async (searchQuery) => {
4651
- const searchedSources = this.activeSources;
4652
- this.state.partialNext({
4653
- searchQuery
4654
- });
4655
- await Promise.all(searchedSources.map((source) => source.search(searchQuery)));
4656
- };
4657
- this.cancelSearchQueries = () => {
4658
- this.activeSources.forEach((s) => s.cancelScheduledQuery());
4659
- };
4660
- this.clear = () => {
4661
- this.cancelSearchQueries();
4662
- this.sources.forEach(
4663
- (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4664
- );
4665
- this.state.next((current) => ({
4666
- ...current,
4667
- isActive: true,
4668
- queriesInProgress: [],
4669
- searchQuery: ""
4670
- }));
4671
- };
4672
- this.exit = () => {
4673
- this.cancelSearchQueries();
4674
- this.sources.forEach(
4675
- (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4676
- );
4677
- this.state.next((current) => ({
4678
- ...current,
4679
- isActive: false,
4680
- queriesInProgress: [],
4681
- searchQuery: ""
4682
- }));
4683
- };
4684
- this.state = new StateStore({
4685
- isActive: false,
4686
- searchQuery: "",
4687
- sources: sources ?? []
4688
- });
4689
- this._internalState = new StateStore({});
4690
- this.config = { keepSingleActiveSource: true, ...config };
4691
- }
4692
- get hasNext() {
4693
- return this.sources.some((source) => source.hasNext);
4694
- }
4695
- get sources() {
4696
- return this.state.getLatestValue().sources;
4697
- }
4698
- get activeSources() {
4699
- return this.state.getLatestValue().sources.filter((s) => s.isActive);
4700
- }
4701
- get isActive() {
4702
- return this.state.getLatestValue().isActive;
4703
- }
4704
- get searchQuery() {
4705
- return this.state.getLatestValue().searchQuery;
4706
- }
4707
- get searchSourceTypes() {
4708
- return this.sources.map((s) => s.type);
4709
- }
4710
- };
4711
-
4712
4609
  // src/pagination/BasePaginator.ts
4713
4610
  var DEFAULT_PAGINATION_OPTIONS = {
4714
4611
  debounceMs: 300,
@@ -4977,6 +4874,152 @@ var UserGroupPaginator = class extends BasePaginator {
4977
4874
  }
4978
4875
  };
4979
4876
 
4877
+ // src/search/ChannelMemberSearchSource.ts
4878
+ var ChannelMemberSearchSource = class extends BaseSearchSource {
4879
+ constructor(channel, options, filterBuilderOptions = {}) {
4880
+ super(options);
4881
+ this.type = "members";
4882
+ this.canExecuteQuery = (newSearchString) => {
4883
+ const hasNewSearchQuery = typeof newSearchString !== "undefined";
4884
+ return this.isActive && !this.isLoading && (this.hasNext || hasNewSearchQuery);
4885
+ };
4886
+ this.channel = channel;
4887
+ this.filterBuilder = new FilterBuilder({
4888
+ initialFilterConfig: {
4889
+ default: {
4890
+ enabled: true,
4891
+ generate: ({ searchQuery }) => searchQuery ? {
4892
+ $or: [
4893
+ { name: { $autocomplete: searchQuery } },
4894
+ { id: { $eq: searchQuery } }
4895
+ ]
4896
+ } : null
4897
+ }
4898
+ },
4899
+ ...filterBuilderOptions
4900
+ });
4901
+ }
4902
+ async query(searchQuery) {
4903
+ const filters = this.filterBuilder.buildFilters({
4904
+ baseFilters: this.filters,
4905
+ context: {
4906
+ searchQuery
4907
+ }
4908
+ });
4909
+ const sort = this.sort ?? [];
4910
+ const options = { ...this.searchOptions, limit: this.pageSize, offset: this.offset };
4911
+ const { members } = await this.channel.queryMembers(filters ?? {}, sort, options);
4912
+ return { items: members };
4913
+ }
4914
+ filterQueryResults(items) {
4915
+ return items;
4916
+ }
4917
+ };
4918
+
4919
+ // src/search/SearchController.ts
4920
+ var SearchController = class {
4921
+ constructor({ config, sources } = {}) {
4922
+ this.addSource = (source) => {
4923
+ this.state.partialNext({
4924
+ sources: [...this.sources, source]
4925
+ });
4926
+ };
4927
+ this.getSource = (sourceType) => this.sources.find((s) => s.type === sourceType);
4928
+ this.removeSource = (sourceType) => {
4929
+ const newSources = this.sources.filter((s) => s.type !== sourceType);
4930
+ if (newSources.length === this.sources.length) return;
4931
+ this.state.partialNext({ sources: newSources });
4932
+ };
4933
+ this.activateSource = (sourceType) => {
4934
+ const source = this.getSource(sourceType);
4935
+ if (!source || source.isActive) return;
4936
+ if (this.config.keepSingleActiveSource) {
4937
+ this.sources.forEach((s) => {
4938
+ if (s.type !== sourceType) {
4939
+ s.deactivate();
4940
+ }
4941
+ });
4942
+ }
4943
+ source.activate();
4944
+ this.state.partialNext({ sources: [...this.sources] });
4945
+ };
4946
+ this.deactivateSource = (sourceType) => {
4947
+ const source = this.getSource(sourceType);
4948
+ if (!source?.isActive) return;
4949
+ if (this.activeSources.length === 1) return;
4950
+ source.deactivate();
4951
+ this.state.partialNext({ sources: [...this.sources] });
4952
+ };
4953
+ this.activate = () => {
4954
+ if (!this.activeSources.length) {
4955
+ const sourcesToActivate = this.config.keepSingleActiveSource ? this.sources.slice(0, 1) : this.sources;
4956
+ sourcesToActivate.forEach((s) => s.activate());
4957
+ }
4958
+ if (this.isActive) return;
4959
+ this.state.partialNext({ isActive: true });
4960
+ };
4961
+ this.search = async (searchQuery) => {
4962
+ const searchedSources = this.activeSources;
4963
+ this.state.partialNext({
4964
+ searchQuery
4965
+ });
4966
+ await Promise.all(searchedSources.map((source) => source.search(searchQuery)));
4967
+ };
4968
+ this.cancelSearchQueries = () => {
4969
+ this.activeSources.forEach((s) => s.cancelScheduledQuery());
4970
+ };
4971
+ this.clear = () => {
4972
+ this.cancelSearchQueries();
4973
+ this.sources.forEach(
4974
+ (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4975
+ );
4976
+ this.state.next((current) => ({
4977
+ ...current,
4978
+ isActive: true,
4979
+ queriesInProgress: [],
4980
+ searchQuery: ""
4981
+ }));
4982
+ };
4983
+ this.exit = () => {
4984
+ this.cancelSearchQueries();
4985
+ this.sources.forEach(
4986
+ (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4987
+ );
4988
+ this.state.next((current) => ({
4989
+ ...current,
4990
+ isActive: false,
4991
+ queriesInProgress: [],
4992
+ searchQuery: ""
4993
+ }));
4994
+ };
4995
+ this.state = new StateStore({
4996
+ isActive: false,
4997
+ searchQuery: "",
4998
+ sources: sources ?? []
4999
+ });
5000
+ this._internalState = new StateStore({});
5001
+ this.config = { keepSingleActiveSource: true, ...config };
5002
+ }
5003
+ get hasNext() {
5004
+ return this.sources.some((source) => source.hasNext);
5005
+ }
5006
+ get sources() {
5007
+ return this.state.getLatestValue().sources;
5008
+ }
5009
+ get activeSources() {
5010
+ return this.state.getLatestValue().sources.filter((s) => s.isActive);
5011
+ }
5012
+ get isActive() {
5013
+ return this.state.getLatestValue().isActive;
5014
+ }
5015
+ get searchQuery() {
5016
+ return this.state.getLatestValue().searchQuery;
5017
+ }
5018
+ get searchSourceTypes() {
5019
+ return this.sources.map((s) => s.type);
5020
+ }
5021
+ };
5022
+
4980
5023
  // src/search/UserSearchSource.ts
4981
5024
  var UserSearchSource = class extends BaseSearchSource {
4982
5025
  constructor(client, options, filterBuilderOptions = {}) {
@@ -5083,7 +5126,7 @@ var MessageSearchSource = class extends BaseSearchSource {
5083
5126
  });
5084
5127
  }
5085
5128
  async query(searchQuery) {
5086
- if (!this.client.userID || !searchQuery || this.next === null) return { items: [] };
5129
+ if (!this.client.userID || this.next === null) return { items: [] };
5087
5130
  const channelFilters = this.messageSearchChannelFilterBuilder.buildFilters({
5088
5131
  baseFilters: {
5089
5132
  ...this.client.userID ? { members: { $in: [this.client.userID] } } : {},
@@ -16706,7 +16749,7 @@ var StreamChat = class _StreamChat {
16706
16749
  if (this.userAgent) {
16707
16750
  return this.userAgent;
16708
16751
  }
16709
- const version = "9.45.6";
16752
+ const version = "9.46.0";
16710
16753
  const clientBundle = "browser-cjs";
16711
16754
  let userAgentString = "";
16712
16755
  if (this.sdkIdentifier) {