stream-chat 9.45.6 → 9.47.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.
@@ -6,7 +6,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ try {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ } catch (e) {
12
+ throw mod = 0, e;
13
+ }
10
14
  };
11
15
  var __export = (target, all) => {
12
16
  for (var name in all)
@@ -74,6 +78,7 @@ __export(index_exports, {
74
78
  Channel: () => Channel,
75
79
  ChannelBatchUpdater: () => ChannelBatchUpdater,
76
80
  ChannelManager: () => ChannelManager,
81
+ ChannelMemberSearchSource: () => ChannelMemberSearchSource,
77
82
  ChannelSearchSource: () => ChannelSearchSource,
78
83
  ChannelState: () => ChannelState,
79
84
  CheckSignature: () => CheckSignature,
@@ -202,6 +207,7 @@ __export(index_exports, {
202
207
  extractPollEnrichedData: () => extractPollEnrichedData,
203
208
  formatMessage: () => formatMessage,
204
209
  generateFileName: () => generateFileName,
210
+ getAllowedMentionTypesFromCapabilities: () => getAllowedMentionTypesFromCapabilities,
205
211
  getAttachmentTypeFromMimeType: () => getAttachmentTypeFromMimeType,
206
212
  getCommandByName: () => getCommandByName,
207
213
  getCompleteCommandInString: () => getCompleteCommandInString,
@@ -4605,110 +4611,6 @@ var BaseSearchSourceSync = class extends BaseSearchSourceBase {
4605
4611
  }
4606
4612
  };
4607
4613
 
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
4614
  // src/pagination/BasePaginator.ts
4713
4615
  var DEFAULT_PAGINATION_OPTIONS = {
4714
4616
  debounceMs: 300,
@@ -4977,6 +4879,152 @@ var UserGroupPaginator = class extends BasePaginator {
4977
4879
  }
4978
4880
  };
4979
4881
 
4882
+ // src/search/ChannelMemberSearchSource.ts
4883
+ var ChannelMemberSearchSource = class extends BaseSearchSource {
4884
+ constructor(channel, options, filterBuilderOptions = {}) {
4885
+ super(options);
4886
+ this.type = "members";
4887
+ this.canExecuteQuery = (newSearchString) => {
4888
+ const hasNewSearchQuery = typeof newSearchString !== "undefined";
4889
+ return this.isActive && !this.isLoading && (this.hasNext || hasNewSearchQuery);
4890
+ };
4891
+ this.channel = channel;
4892
+ this.filterBuilder = new FilterBuilder({
4893
+ initialFilterConfig: {
4894
+ default: {
4895
+ enabled: true,
4896
+ generate: ({ searchQuery }) => searchQuery ? {
4897
+ $or: [
4898
+ { name: { $autocomplete: searchQuery } },
4899
+ { id: { $eq: searchQuery } }
4900
+ ]
4901
+ } : null
4902
+ }
4903
+ },
4904
+ ...filterBuilderOptions
4905
+ });
4906
+ }
4907
+ async query(searchQuery) {
4908
+ const filters = this.filterBuilder.buildFilters({
4909
+ baseFilters: this.filters,
4910
+ context: {
4911
+ searchQuery
4912
+ }
4913
+ });
4914
+ const sort = this.sort ?? [];
4915
+ const options = { ...this.searchOptions, limit: this.pageSize, offset: this.offset };
4916
+ const { members } = await this.channel.queryMembers(filters ?? {}, sort, options);
4917
+ return { items: members };
4918
+ }
4919
+ filterQueryResults(items) {
4920
+ return items;
4921
+ }
4922
+ };
4923
+
4924
+ // src/search/SearchController.ts
4925
+ var SearchController = class {
4926
+ constructor({ config, sources } = {}) {
4927
+ this.addSource = (source) => {
4928
+ this.state.partialNext({
4929
+ sources: [...this.sources, source]
4930
+ });
4931
+ };
4932
+ this.getSource = (sourceType) => this.sources.find((s) => s.type === sourceType);
4933
+ this.removeSource = (sourceType) => {
4934
+ const newSources = this.sources.filter((s) => s.type !== sourceType);
4935
+ if (newSources.length === this.sources.length) return;
4936
+ this.state.partialNext({ sources: newSources });
4937
+ };
4938
+ this.activateSource = (sourceType) => {
4939
+ const source = this.getSource(sourceType);
4940
+ if (!source || source.isActive) return;
4941
+ if (this.config.keepSingleActiveSource) {
4942
+ this.sources.forEach((s) => {
4943
+ if (s.type !== sourceType) {
4944
+ s.deactivate();
4945
+ }
4946
+ });
4947
+ }
4948
+ source.activate();
4949
+ this.state.partialNext({ sources: [...this.sources] });
4950
+ };
4951
+ this.deactivateSource = (sourceType) => {
4952
+ const source = this.getSource(sourceType);
4953
+ if (!source?.isActive) return;
4954
+ if (this.activeSources.length === 1) return;
4955
+ source.deactivate();
4956
+ this.state.partialNext({ sources: [...this.sources] });
4957
+ };
4958
+ this.activate = () => {
4959
+ if (!this.activeSources.length) {
4960
+ const sourcesToActivate = this.config.keepSingleActiveSource ? this.sources.slice(0, 1) : this.sources;
4961
+ sourcesToActivate.forEach((s) => s.activate());
4962
+ }
4963
+ if (this.isActive) return;
4964
+ this.state.partialNext({ isActive: true });
4965
+ };
4966
+ this.search = async (searchQuery) => {
4967
+ const searchedSources = this.activeSources;
4968
+ this.state.partialNext({
4969
+ searchQuery
4970
+ });
4971
+ await Promise.all(searchedSources.map((source) => source.search(searchQuery)));
4972
+ };
4973
+ this.cancelSearchQueries = () => {
4974
+ this.activeSources.forEach((s) => s.cancelScheduledQuery());
4975
+ };
4976
+ this.clear = () => {
4977
+ this.cancelSearchQueries();
4978
+ this.sources.forEach(
4979
+ (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4980
+ );
4981
+ this.state.next((current) => ({
4982
+ ...current,
4983
+ isActive: true,
4984
+ queriesInProgress: [],
4985
+ searchQuery: ""
4986
+ }));
4987
+ };
4988
+ this.exit = () => {
4989
+ this.cancelSearchQueries();
4990
+ this.sources.forEach(
4991
+ (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4992
+ );
4993
+ this.state.next((current) => ({
4994
+ ...current,
4995
+ isActive: false,
4996
+ queriesInProgress: [],
4997
+ searchQuery: ""
4998
+ }));
4999
+ };
5000
+ this.state = new StateStore({
5001
+ isActive: false,
5002
+ searchQuery: "",
5003
+ sources: sources ?? []
5004
+ });
5005
+ this._internalState = new StateStore({});
5006
+ this.config = { keepSingleActiveSource: true, ...config };
5007
+ }
5008
+ get hasNext() {
5009
+ return this.sources.some((source) => source.hasNext);
5010
+ }
5011
+ get sources() {
5012
+ return this.state.getLatestValue().sources;
5013
+ }
5014
+ get activeSources() {
5015
+ return this.state.getLatestValue().sources.filter((s) => s.isActive);
5016
+ }
5017
+ get isActive() {
5018
+ return this.state.getLatestValue().isActive;
5019
+ }
5020
+ get searchQuery() {
5021
+ return this.state.getLatestValue().searchQuery;
5022
+ }
5023
+ get searchSourceTypes() {
5024
+ return this.sources.map((s) => s.type);
5025
+ }
5026
+ };
5027
+
4980
5028
  // src/search/UserSearchSource.ts
4981
5029
  var UserSearchSource = class extends BaseSearchSource {
4982
5030
  constructor(client, options, filterBuilderOptions = {}) {
@@ -5083,7 +5131,7 @@ var MessageSearchSource = class extends BaseSearchSource {
5083
5131
  });
5084
5132
  }
5085
5133
  async query(searchQuery) {
5086
- if (!this.client.userID || !searchQuery || this.next === null) return { items: [] };
5134
+ if (!this.client.userID || this.next === null) return { items: [] };
5087
5135
  const channelFilters = this.messageSearchChannelFilterBuilder.buildFilters({
5088
5136
  baseFilters: {
5089
5137
  ...this.client.userID ? { members: { $in: [this.client.userID] } } : {},
@@ -6288,13 +6336,14 @@ var calculateLevenshtein = (query, name) => {
6288
6336
  }
6289
6337
  return matrix[name.length][query.length];
6290
6338
  };
6291
- var DEFAULT_ALLOWED_MENTION_TYPES = {
6292
- channel: true,
6293
- here: true,
6294
- role: true,
6339
+ var hasOwnCapability = (ownCapabilities, capability) => ownCapabilities?.includes(capability) ?? false;
6340
+ var getAllowedMentionTypesFromCapabilities = (ownCapabilities) => ({
6341
+ channel: hasOwnCapability(ownCapabilities, "notify-channel"),
6342
+ here: hasOwnCapability(ownCapabilities, "notify-here"),
6343
+ role: hasOwnCapability(ownCapabilities, "notify-role"),
6295
6344
  user: true,
6296
- user_group: true
6297
- };
6345
+ user_group: hasOwnCapability(ownCapabilities, "notify-group")
6346
+ });
6298
6347
  var decodeUserGroupCursor = (cursor) => {
6299
6348
  if (!cursor) return void 0;
6300
6349
  try {
@@ -6420,7 +6469,6 @@ var DEFAULT_SUGGESTION_FACTORY_MAPPERS = {
6420
6469
  var MentionsSearchSource = class extends BaseSearchSource {
6421
6470
  constructor(channel, options) {
6422
6471
  const {
6423
- allowedMentionTypes,
6424
6472
  mentionAllAppUsers,
6425
6473
  suggestionFactoryMappers,
6426
6474
  textComposerText,
@@ -6452,7 +6500,7 @@ var MentionsSearchSource = class extends BaseSearchSource {
6452
6500
  const finalQueryWord = normalizedQueryWords[normalizedQueryWords.length - 1];
6453
6501
  return fullMatchWords.every((queryWord) => normalizedValueWords.includes(queryWord)) && normalizedValueWords.some((valueWord) => valueWord.startsWith(finalQueryWord));
6454
6502
  };
6455
- this.isMentionTypeAllowed = (mentionType) => this.config.allowedMentionTypes?.[mentionType] ?? true;
6503
+ this.isMentionTypeAllowed = (mentionType) => getAllowedMentionTypesFromCapabilities(this.channel.data?.own_capabilities)[mentionType];
6456
6504
  this.mapMentionSuggestion = (mentionType, value, searchToken = this.searchQuery) => {
6457
6505
  const mapper = this.config.suggestionFactoryMappers?.[mentionType] ?? DEFAULT_SUGGESTION_FACTORY_MAPPERS[mentionType];
6458
6506
  return mapper(value, {
@@ -6636,10 +6684,6 @@ var MentionsSearchSource = class extends BaseSearchSource {
6636
6684
  this.client = channel.getClient();
6637
6685
  this.channel = channel;
6638
6686
  this.config = {
6639
- allowedMentionTypes: {
6640
- ...DEFAULT_ALLOWED_MENTION_TYPES,
6641
- ...allowedMentionTypes
6642
- },
6643
6687
  mentionAllAppUsers,
6644
6688
  suggestionFactoryMappers,
6645
6689
  textComposerText,
@@ -16706,7 +16750,7 @@ var StreamChat = class _StreamChat {
16706
16750
  if (this.userAgent) {
16707
16751
  return this.userAgent;
16708
16752
  }
16709
- const version = "9.45.6";
16753
+ const version = "9.47.0";
16710
16754
  const clientBundle = "browser-cjs";
16711
16755
  let userAgentString = "";
16712
16756
  if (this.sdkIdentifier) {