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.
@@ -4392,110 +4392,6 @@ var BaseSearchSourceSync = class extends BaseSearchSourceBase {
4392
4392
  }
4393
4393
  };
4394
4394
 
4395
- // src/search/SearchController.ts
4396
- var SearchController = class {
4397
- constructor({ config, sources } = {}) {
4398
- this.addSource = (source) => {
4399
- this.state.partialNext({
4400
- sources: [...this.sources, source]
4401
- });
4402
- };
4403
- this.getSource = (sourceType) => this.sources.find((s) => s.type === sourceType);
4404
- this.removeSource = (sourceType) => {
4405
- const newSources = this.sources.filter((s) => s.type !== sourceType);
4406
- if (newSources.length === this.sources.length) return;
4407
- this.state.partialNext({ sources: newSources });
4408
- };
4409
- this.activateSource = (sourceType) => {
4410
- const source = this.getSource(sourceType);
4411
- if (!source || source.isActive) return;
4412
- if (this.config.keepSingleActiveSource) {
4413
- this.sources.forEach((s) => {
4414
- if (s.type !== sourceType) {
4415
- s.deactivate();
4416
- }
4417
- });
4418
- }
4419
- source.activate();
4420
- this.state.partialNext({ sources: [...this.sources] });
4421
- };
4422
- this.deactivateSource = (sourceType) => {
4423
- const source = this.getSource(sourceType);
4424
- if (!source?.isActive) return;
4425
- if (this.activeSources.length === 1) return;
4426
- source.deactivate();
4427
- this.state.partialNext({ sources: [...this.sources] });
4428
- };
4429
- this.activate = () => {
4430
- if (!this.activeSources.length) {
4431
- const sourcesToActivate = this.config.keepSingleActiveSource ? this.sources.slice(0, 1) : this.sources;
4432
- sourcesToActivate.forEach((s) => s.activate());
4433
- }
4434
- if (this.isActive) return;
4435
- this.state.partialNext({ isActive: true });
4436
- };
4437
- this.search = async (searchQuery) => {
4438
- const searchedSources = this.activeSources;
4439
- this.state.partialNext({
4440
- searchQuery
4441
- });
4442
- await Promise.all(searchedSources.map((source) => source.search(searchQuery)));
4443
- };
4444
- this.cancelSearchQueries = () => {
4445
- this.activeSources.forEach((s) => s.cancelScheduledQuery());
4446
- };
4447
- this.clear = () => {
4448
- this.cancelSearchQueries();
4449
- this.sources.forEach(
4450
- (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4451
- );
4452
- this.state.next((current) => ({
4453
- ...current,
4454
- isActive: true,
4455
- queriesInProgress: [],
4456
- searchQuery: ""
4457
- }));
4458
- };
4459
- this.exit = () => {
4460
- this.cancelSearchQueries();
4461
- this.sources.forEach(
4462
- (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4463
- );
4464
- this.state.next((current) => ({
4465
- ...current,
4466
- isActive: false,
4467
- queriesInProgress: [],
4468
- searchQuery: ""
4469
- }));
4470
- };
4471
- this.state = new StateStore({
4472
- isActive: false,
4473
- searchQuery: "",
4474
- sources: sources ?? []
4475
- });
4476
- this._internalState = new StateStore({});
4477
- this.config = { keepSingleActiveSource: true, ...config };
4478
- }
4479
- get hasNext() {
4480
- return this.sources.some((source) => source.hasNext);
4481
- }
4482
- get sources() {
4483
- return this.state.getLatestValue().sources;
4484
- }
4485
- get activeSources() {
4486
- return this.state.getLatestValue().sources.filter((s) => s.isActive);
4487
- }
4488
- get isActive() {
4489
- return this.state.getLatestValue().isActive;
4490
- }
4491
- get searchQuery() {
4492
- return this.state.getLatestValue().searchQuery;
4493
- }
4494
- get searchSourceTypes() {
4495
- return this.sources.map((s) => s.type);
4496
- }
4497
- };
4498
-
4499
4395
  // src/pagination/BasePaginator.ts
4500
4396
  var DEFAULT_PAGINATION_OPTIONS = {
4501
4397
  debounceMs: 300,
@@ -4764,6 +4660,152 @@ var UserGroupPaginator = class extends BasePaginator {
4764
4660
  }
4765
4661
  };
4766
4662
 
4663
+ // src/search/ChannelMemberSearchSource.ts
4664
+ var ChannelMemberSearchSource = class extends BaseSearchSource {
4665
+ constructor(channel, options, filterBuilderOptions = {}) {
4666
+ super(options);
4667
+ this.type = "members";
4668
+ this.canExecuteQuery = (newSearchString) => {
4669
+ const hasNewSearchQuery = typeof newSearchString !== "undefined";
4670
+ return this.isActive && !this.isLoading && (this.hasNext || hasNewSearchQuery);
4671
+ };
4672
+ this.channel = channel;
4673
+ this.filterBuilder = new FilterBuilder({
4674
+ initialFilterConfig: {
4675
+ default: {
4676
+ enabled: true,
4677
+ generate: ({ searchQuery }) => searchQuery ? {
4678
+ $or: [
4679
+ { name: { $autocomplete: searchQuery } },
4680
+ { id: { $eq: searchQuery } }
4681
+ ]
4682
+ } : null
4683
+ }
4684
+ },
4685
+ ...filterBuilderOptions
4686
+ });
4687
+ }
4688
+ async query(searchQuery) {
4689
+ const filters = this.filterBuilder.buildFilters({
4690
+ baseFilters: this.filters,
4691
+ context: {
4692
+ searchQuery
4693
+ }
4694
+ });
4695
+ const sort = this.sort ?? [];
4696
+ const options = { ...this.searchOptions, limit: this.pageSize, offset: this.offset };
4697
+ const { members } = await this.channel.queryMembers(filters ?? {}, sort, options);
4698
+ return { items: members };
4699
+ }
4700
+ filterQueryResults(items) {
4701
+ return items;
4702
+ }
4703
+ };
4704
+
4705
+ // src/search/SearchController.ts
4706
+ var SearchController = class {
4707
+ constructor({ config, sources } = {}) {
4708
+ this.addSource = (source) => {
4709
+ this.state.partialNext({
4710
+ sources: [...this.sources, source]
4711
+ });
4712
+ };
4713
+ this.getSource = (sourceType) => this.sources.find((s) => s.type === sourceType);
4714
+ this.removeSource = (sourceType) => {
4715
+ const newSources = this.sources.filter((s) => s.type !== sourceType);
4716
+ if (newSources.length === this.sources.length) return;
4717
+ this.state.partialNext({ sources: newSources });
4718
+ };
4719
+ this.activateSource = (sourceType) => {
4720
+ const source = this.getSource(sourceType);
4721
+ if (!source || source.isActive) return;
4722
+ if (this.config.keepSingleActiveSource) {
4723
+ this.sources.forEach((s) => {
4724
+ if (s.type !== sourceType) {
4725
+ s.deactivate();
4726
+ }
4727
+ });
4728
+ }
4729
+ source.activate();
4730
+ this.state.partialNext({ sources: [...this.sources] });
4731
+ };
4732
+ this.deactivateSource = (sourceType) => {
4733
+ const source = this.getSource(sourceType);
4734
+ if (!source?.isActive) return;
4735
+ if (this.activeSources.length === 1) return;
4736
+ source.deactivate();
4737
+ this.state.partialNext({ sources: [...this.sources] });
4738
+ };
4739
+ this.activate = () => {
4740
+ if (!this.activeSources.length) {
4741
+ const sourcesToActivate = this.config.keepSingleActiveSource ? this.sources.slice(0, 1) : this.sources;
4742
+ sourcesToActivate.forEach((s) => s.activate());
4743
+ }
4744
+ if (this.isActive) return;
4745
+ this.state.partialNext({ isActive: true });
4746
+ };
4747
+ this.search = async (searchQuery) => {
4748
+ const searchedSources = this.activeSources;
4749
+ this.state.partialNext({
4750
+ searchQuery
4751
+ });
4752
+ await Promise.all(searchedSources.map((source) => source.search(searchQuery)));
4753
+ };
4754
+ this.cancelSearchQueries = () => {
4755
+ this.activeSources.forEach((s) => s.cancelScheduledQuery());
4756
+ };
4757
+ this.clear = () => {
4758
+ this.cancelSearchQueries();
4759
+ this.sources.forEach(
4760
+ (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4761
+ );
4762
+ this.state.next((current) => ({
4763
+ ...current,
4764
+ isActive: true,
4765
+ queriesInProgress: [],
4766
+ searchQuery: ""
4767
+ }));
4768
+ };
4769
+ this.exit = () => {
4770
+ this.cancelSearchQueries();
4771
+ this.sources.forEach(
4772
+ (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4773
+ );
4774
+ this.state.next((current) => ({
4775
+ ...current,
4776
+ isActive: false,
4777
+ queriesInProgress: [],
4778
+ searchQuery: ""
4779
+ }));
4780
+ };
4781
+ this.state = new StateStore({
4782
+ isActive: false,
4783
+ searchQuery: "",
4784
+ sources: sources ?? []
4785
+ });
4786
+ this._internalState = new StateStore({});
4787
+ this.config = { keepSingleActiveSource: true, ...config };
4788
+ }
4789
+ get hasNext() {
4790
+ return this.sources.some((source) => source.hasNext);
4791
+ }
4792
+ get sources() {
4793
+ return this.state.getLatestValue().sources;
4794
+ }
4795
+ get activeSources() {
4796
+ return this.state.getLatestValue().sources.filter((s) => s.isActive);
4797
+ }
4798
+ get isActive() {
4799
+ return this.state.getLatestValue().isActive;
4800
+ }
4801
+ get searchQuery() {
4802
+ return this.state.getLatestValue().searchQuery;
4803
+ }
4804
+ get searchSourceTypes() {
4805
+ return this.sources.map((s) => s.type);
4806
+ }
4807
+ };
4808
+
4767
4809
  // src/search/UserSearchSource.ts
4768
4810
  var UserSearchSource = class extends BaseSearchSource {
4769
4811
  constructor(client, options, filterBuilderOptions = {}) {
@@ -4870,7 +4912,7 @@ var MessageSearchSource = class extends BaseSearchSource {
4870
4912
  });
4871
4913
  }
4872
4914
  async query(searchQuery) {
4873
- if (!this.client.userID || !searchQuery || this.next === null) return { items: [] };
4915
+ if (!this.client.userID || this.next === null) return { items: [] };
4874
4916
  const channelFilters = this.messageSearchChannelFilterBuilder.buildFilters({
4875
4917
  baseFilters: {
4876
4918
  ...this.client.userID ? { members: { $in: [this.client.userID] } } : {},
@@ -16493,7 +16535,7 @@ var StreamChat = class _StreamChat {
16493
16535
  if (this.userAgent) {
16494
16536
  return this.userAgent;
16495
16537
  }
16496
- const version = "9.45.6";
16538
+ const version = "9.46.0";
16497
16539
  const clientBundle = "browser-esm";
16498
16540
  let userAgentString = "";
16499
16541
  if (this.sdkIdentifier) {
@@ -19109,6 +19151,7 @@ export {
19109
19151
  Channel,
19110
19152
  ChannelBatchUpdater,
19111
19153
  ChannelManager,
19154
+ ChannelMemberSearchSource,
19112
19155
  ChannelSearchSource,
19113
19156
  ChannelState,
19114
19157
  CheckSignature,