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.
@@ -5,7 +5,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
8
+ try {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ } catch (e) {
11
+ throw mod = 0, e;
12
+ }
9
13
  };
10
14
  var __copyProps = (to, from, except, desc) => {
11
15
  if (from && typeof from === "object" || typeof from === "function") {
@@ -4392,110 +4396,6 @@ var BaseSearchSourceSync = class extends BaseSearchSourceBase {
4392
4396
  }
4393
4397
  };
4394
4398
 
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
4399
  // src/pagination/BasePaginator.ts
4500
4400
  var DEFAULT_PAGINATION_OPTIONS = {
4501
4401
  debounceMs: 300,
@@ -4764,6 +4664,152 @@ var UserGroupPaginator = class extends BasePaginator {
4764
4664
  }
4765
4665
  };
4766
4666
 
4667
+ // src/search/ChannelMemberSearchSource.ts
4668
+ var ChannelMemberSearchSource = class extends BaseSearchSource {
4669
+ constructor(channel, options, filterBuilderOptions = {}) {
4670
+ super(options);
4671
+ this.type = "members";
4672
+ this.canExecuteQuery = (newSearchString) => {
4673
+ const hasNewSearchQuery = typeof newSearchString !== "undefined";
4674
+ return this.isActive && !this.isLoading && (this.hasNext || hasNewSearchQuery);
4675
+ };
4676
+ this.channel = channel;
4677
+ this.filterBuilder = new FilterBuilder({
4678
+ initialFilterConfig: {
4679
+ default: {
4680
+ enabled: true,
4681
+ generate: ({ searchQuery }) => searchQuery ? {
4682
+ $or: [
4683
+ { name: { $autocomplete: searchQuery } },
4684
+ { id: { $eq: searchQuery } }
4685
+ ]
4686
+ } : null
4687
+ }
4688
+ },
4689
+ ...filterBuilderOptions
4690
+ });
4691
+ }
4692
+ async query(searchQuery) {
4693
+ const filters = this.filterBuilder.buildFilters({
4694
+ baseFilters: this.filters,
4695
+ context: {
4696
+ searchQuery
4697
+ }
4698
+ });
4699
+ const sort = this.sort ?? [];
4700
+ const options = { ...this.searchOptions, limit: this.pageSize, offset: this.offset };
4701
+ const { members } = await this.channel.queryMembers(filters ?? {}, sort, options);
4702
+ return { items: members };
4703
+ }
4704
+ filterQueryResults(items) {
4705
+ return items;
4706
+ }
4707
+ };
4708
+
4709
+ // src/search/SearchController.ts
4710
+ var SearchController = class {
4711
+ constructor({ config, sources } = {}) {
4712
+ this.addSource = (source) => {
4713
+ this.state.partialNext({
4714
+ sources: [...this.sources, source]
4715
+ });
4716
+ };
4717
+ this.getSource = (sourceType) => this.sources.find((s) => s.type === sourceType);
4718
+ this.removeSource = (sourceType) => {
4719
+ const newSources = this.sources.filter((s) => s.type !== sourceType);
4720
+ if (newSources.length === this.sources.length) return;
4721
+ this.state.partialNext({ sources: newSources });
4722
+ };
4723
+ this.activateSource = (sourceType) => {
4724
+ const source = this.getSource(sourceType);
4725
+ if (!source || source.isActive) return;
4726
+ if (this.config.keepSingleActiveSource) {
4727
+ this.sources.forEach((s) => {
4728
+ if (s.type !== sourceType) {
4729
+ s.deactivate();
4730
+ }
4731
+ });
4732
+ }
4733
+ source.activate();
4734
+ this.state.partialNext({ sources: [...this.sources] });
4735
+ };
4736
+ this.deactivateSource = (sourceType) => {
4737
+ const source = this.getSource(sourceType);
4738
+ if (!source?.isActive) return;
4739
+ if (this.activeSources.length === 1) return;
4740
+ source.deactivate();
4741
+ this.state.partialNext({ sources: [...this.sources] });
4742
+ };
4743
+ this.activate = () => {
4744
+ if (!this.activeSources.length) {
4745
+ const sourcesToActivate = this.config.keepSingleActiveSource ? this.sources.slice(0, 1) : this.sources;
4746
+ sourcesToActivate.forEach((s) => s.activate());
4747
+ }
4748
+ if (this.isActive) return;
4749
+ this.state.partialNext({ isActive: true });
4750
+ };
4751
+ this.search = async (searchQuery) => {
4752
+ const searchedSources = this.activeSources;
4753
+ this.state.partialNext({
4754
+ searchQuery
4755
+ });
4756
+ await Promise.all(searchedSources.map((source) => source.search(searchQuery)));
4757
+ };
4758
+ this.cancelSearchQueries = () => {
4759
+ this.activeSources.forEach((s) => s.cancelScheduledQuery());
4760
+ };
4761
+ this.clear = () => {
4762
+ this.cancelSearchQueries();
4763
+ this.sources.forEach(
4764
+ (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4765
+ );
4766
+ this.state.next((current) => ({
4767
+ ...current,
4768
+ isActive: true,
4769
+ queriesInProgress: [],
4770
+ searchQuery: ""
4771
+ }));
4772
+ };
4773
+ this.exit = () => {
4774
+ this.cancelSearchQueries();
4775
+ this.sources.forEach(
4776
+ (source) => source.state.next({ ...source.initialState, isActive: source.isActive })
4777
+ );
4778
+ this.state.next((current) => ({
4779
+ ...current,
4780
+ isActive: false,
4781
+ queriesInProgress: [],
4782
+ searchQuery: ""
4783
+ }));
4784
+ };
4785
+ this.state = new StateStore({
4786
+ isActive: false,
4787
+ searchQuery: "",
4788
+ sources: sources ?? []
4789
+ });
4790
+ this._internalState = new StateStore({});
4791
+ this.config = { keepSingleActiveSource: true, ...config };
4792
+ }
4793
+ get hasNext() {
4794
+ return this.sources.some((source) => source.hasNext);
4795
+ }
4796
+ get sources() {
4797
+ return this.state.getLatestValue().sources;
4798
+ }
4799
+ get activeSources() {
4800
+ return this.state.getLatestValue().sources.filter((s) => s.isActive);
4801
+ }
4802
+ get isActive() {
4803
+ return this.state.getLatestValue().isActive;
4804
+ }
4805
+ get searchQuery() {
4806
+ return this.state.getLatestValue().searchQuery;
4807
+ }
4808
+ get searchSourceTypes() {
4809
+ return this.sources.map((s) => s.type);
4810
+ }
4811
+ };
4812
+
4767
4813
  // src/search/UserSearchSource.ts
4768
4814
  var UserSearchSource = class extends BaseSearchSource {
4769
4815
  constructor(client, options, filterBuilderOptions = {}) {
@@ -4870,7 +4916,7 @@ var MessageSearchSource = class extends BaseSearchSource {
4870
4916
  });
4871
4917
  }
4872
4918
  async query(searchQuery) {
4873
- if (!this.client.userID || !searchQuery || this.next === null) return { items: [] };
4919
+ if (!this.client.userID || this.next === null) return { items: [] };
4874
4920
  const channelFilters = this.messageSearchChannelFilterBuilder.buildFilters({
4875
4921
  baseFilters: {
4876
4922
  ...this.client.userID ? { members: { $in: [this.client.userID] } } : {},
@@ -6075,13 +6121,14 @@ var calculateLevenshtein = (query, name) => {
6075
6121
  }
6076
6122
  return matrix[name.length][query.length];
6077
6123
  };
6078
- var DEFAULT_ALLOWED_MENTION_TYPES = {
6079
- channel: true,
6080
- here: true,
6081
- role: true,
6124
+ var hasOwnCapability = (ownCapabilities, capability) => ownCapabilities?.includes(capability) ?? false;
6125
+ var getAllowedMentionTypesFromCapabilities = (ownCapabilities) => ({
6126
+ channel: hasOwnCapability(ownCapabilities, "notify-channel"),
6127
+ here: hasOwnCapability(ownCapabilities, "notify-here"),
6128
+ role: hasOwnCapability(ownCapabilities, "notify-role"),
6082
6129
  user: true,
6083
- user_group: true
6084
- };
6130
+ user_group: hasOwnCapability(ownCapabilities, "notify-group")
6131
+ });
6085
6132
  var decodeUserGroupCursor = (cursor) => {
6086
6133
  if (!cursor) return void 0;
6087
6134
  try {
@@ -6207,7 +6254,6 @@ var DEFAULT_SUGGESTION_FACTORY_MAPPERS = {
6207
6254
  var MentionsSearchSource = class extends BaseSearchSource {
6208
6255
  constructor(channel, options) {
6209
6256
  const {
6210
- allowedMentionTypes,
6211
6257
  mentionAllAppUsers,
6212
6258
  suggestionFactoryMappers,
6213
6259
  textComposerText,
@@ -6239,7 +6285,7 @@ var MentionsSearchSource = class extends BaseSearchSource {
6239
6285
  const finalQueryWord = normalizedQueryWords[normalizedQueryWords.length - 1];
6240
6286
  return fullMatchWords.every((queryWord) => normalizedValueWords.includes(queryWord)) && normalizedValueWords.some((valueWord) => valueWord.startsWith(finalQueryWord));
6241
6287
  };
6242
- this.isMentionTypeAllowed = (mentionType) => this.config.allowedMentionTypes?.[mentionType] ?? true;
6288
+ this.isMentionTypeAllowed = (mentionType) => getAllowedMentionTypesFromCapabilities(this.channel.data?.own_capabilities)[mentionType];
6243
6289
  this.mapMentionSuggestion = (mentionType, value, searchToken = this.searchQuery) => {
6244
6290
  const mapper = this.config.suggestionFactoryMappers?.[mentionType] ?? DEFAULT_SUGGESTION_FACTORY_MAPPERS[mentionType];
6245
6291
  return mapper(value, {
@@ -6423,10 +6469,6 @@ var MentionsSearchSource = class extends BaseSearchSource {
6423
6469
  this.client = channel.getClient();
6424
6470
  this.channel = channel;
6425
6471
  this.config = {
6426
- allowedMentionTypes: {
6427
- ...DEFAULT_ALLOWED_MENTION_TYPES,
6428
- ...allowedMentionTypes
6429
- },
6430
6472
  mentionAllAppUsers,
6431
6473
  suggestionFactoryMappers,
6432
6474
  textComposerText,
@@ -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.47.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,
@@ -19237,6 +19280,7 @@ export {
19237
19280
  extractPollEnrichedData,
19238
19281
  formatMessage,
19239
19282
  generateFileName,
19283
+ getAllowedMentionTypesFromCapabilities,
19240
19284
  getAttachmentTypeFromMimeType,
19241
19285
  getCommandByName,
19242
19286
  getCompleteCommandInString,