Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

stream-chat

Package Overview
Dependencies
Maintainers
15
Versions
296
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-chat - npm Package Compare versions

Comparing version 6.7.3 to 7.0.0-offline-support.0

25

dist/types/channel_state.d.ts

@@ -59,3 +59,9 @@ import { Channel } from './channel';

*/
addMessageSorted(newMessage: MessageResponse<StreamChatGenerics>, timestampChanged?: boolean, addIfDoesNotExist?: boolean, messageSetToAddToIfDoesNotExist?: MessageSetType): void;
addMessageSorted(newMessage: MessageResponse<StreamChatGenerics>, timestampChanged?: boolean, addIfDoesNotExist?: boolean, messageSetToAddToIfDoesNotExist?: MessageSetType): {
messageSet: {
isCurrent: boolean;
isLatest: boolean;
messages: FormatMessageResponse<StreamChatGenerics>[];
};
};
/**

@@ -79,3 +85,9 @@ * formatMessage - Takes the message object. Parses the dates, sets __html

*/
addMessagesSorted(newMessages: MessageResponse<StreamChatGenerics>[], timestampChanged?: boolean, initializing?: boolean, addIfDoesNotExist?: boolean, messageSetToAddToIfDoesNotExist?: MessageSetType): void;
addMessagesSorted(newMessages: MessageResponse<StreamChatGenerics>[], timestampChanged?: boolean, initializing?: boolean, addIfDoesNotExist?: boolean, messageSetToAddToIfDoesNotExist?: MessageSetType): {
messageSet: {
isCurrent: boolean;
isLatest: boolean;
messages: FormatMessageResponse<StreamChatGenerics>[];
};
};
/**

@@ -187,2 +199,11 @@ * addPinnedMessages - adds messages in pinnedMessages property

loadMessageIntoState(messageId: string | 'latest', parentMessageId?: string): Promise<void>;
/**
* findMessage - Finds a message inside the state
*
* @param {string} messageId The id of the message
* @param {string} parentMessageId The id of the parent message, if we want load a thread reply
*
* @return {ReturnType<ChannelState<StreamChatGenerics>['formatMessage']>} Returns the message, or undefined if the message wasn't found
*/
findMessage(messageId: string, parentMessageId?: string): FormatMessageResponse<StreamChatGenerics> | undefined;
private switchToMessageSet;

@@ -189,0 +210,0 @@ private areMessageSetsOverlap;

24

dist/types/channel.d.ts
/// <reference types="node" />
import { ChannelState } from './channel_state';
import { StreamChat } from './client';
import { APIResponse, BanUserOptions, ChannelAPIResponse, ChannelData, ChannelUpdateOptions, ChannelMemberAPIResponse, ChannelQueryOptions, ChannelResponse, DeleteChannelAPIResponse, Event, EventAPIResponse, EventHandler, EventTypes, FormatMessageResponse, GetMultipleMessagesAPIResponse, GetReactionsAPIResponse, GetRepliesAPIResponse, InviteOptions, MarkReadOptions, MemberSort, Message, MessageFilters, MessageResponse, MessageSetType, MuteChannelAPIResponse, PartialUpdateChannel, PartialUpdateChannelAPIResponse, QueryMembersOptions, Reaction, ReactionAPIResponse, SearchAPIResponse, SearchOptions, SendMessageAPIResponse, TruncateChannelAPIResponse, TruncateOptions, UpdateChannelAPIResponse, UserFilters, UserResponse, ExtendableGenerics, DefaultGenerics, PinnedMessagePaginationOptions, PinnedMessagesSort, MessagePaginationOptions, CreateCallOptions, CreateCallResponse } from './types';
import { APIResponse, BanUserOptions, ChannelAPIResponse, ChannelData, ChannelUpdateOptions, ChannelMemberAPIResponse, ChannelQueryOptions, ChannelResponse, DeleteChannelAPIResponse, Event, EventAPIResponse, EventHandler, EventTypes, FormatMessageResponse, GetMultipleMessagesAPIResponse, GetReactionsAPIResponse, GetRepliesAPIResponse, InviteOptions, MarkReadOptions, MemberSort, Message, MessageFilters, MessageResponse, MessageSetType, MuteChannelAPIResponse, PartialUpdateChannel, PartialUpdateChannelAPIResponse, QueryMembersOptions, Reaction, ReactionAPIResponse, SearchAPIResponse, SearchOptions, SendMessageAPIResponse, TruncateChannelAPIResponse, TruncateOptions, UpdateChannelAPIResponse, UserFilters, UserResponse, ExtendableGenerics, DefaultGenerics, PinnedMessagePaginationOptions, PinnedMessagesSort, MessagePaginationOptions, CreateCallOptions, CreateCallResponse, QueryChannelAPIResponse } from './types';
import { Role } from './permissions';

@@ -21,2 +21,3 @@ /**

initialized: boolean;
staticState: boolean;
lastKeyStroke?: Date;

@@ -326,5 +327,5 @@ lastTypingEvent: Date | null;

*
* @return {Promise<ChannelAPIResponse<StreamChatGenerics>>} The server response
* @return {Promise<QueryChannelAPIResponse<StreamChatGenerics>>} The server response
*/
watch(options?: ChannelQueryOptions<StreamChatGenerics>): Promise<ChannelAPIResponse<StreamChatGenerics>>;
watch(options?: ChannelQueryOptions<StreamChatGenerics>): Promise<QueryChannelAPIResponse<StreamChatGenerics>>;
/**

@@ -403,5 +404,5 @@ * stopWatching - Stops watching the channel

*
* @return {Promise<ChannelAPIResponse<StreamChatGenerics>>} The Server Response
* @return {Promise<QueryChannelAPIResponse<StreamChatGenerics>>} The Server Response
*/
create: () => Promise<ChannelAPIResponse<StreamChatGenerics>>;
create: () => Promise<QueryChannelAPIResponse<StreamChatGenerics>>;
/**

@@ -413,5 +414,5 @@ * query - Query the API, get messages, members or other channel fields

*
* @return {Promise<ChannelAPIResponse<StreamChatGenerics>>} Returns a query response
* @return {Promise<QueryChannelAPIResponse<StreamChatGenerics>>} Returns a query response
*/
query(options: ChannelQueryOptions<StreamChatGenerics>, messageSetToAddToIfDoesNotExist?: MessageSetType): Promise<ChannelAPIResponse<StreamChatGenerics>>;
query(options: ChannelQueryOptions<StreamChatGenerics>, messageSetToAddToIfDoesNotExist?: MessageSetType): Promise<QueryChannelAPIResponse<StreamChatGenerics>>;
/**

@@ -501,5 +502,12 @@ * banUser - Bans a user from a channel

_checkInitialized(): void;
_initializeState(state: ChannelAPIResponse<StreamChatGenerics>, messageSetToAddToIfDoesNotExist?: MessageSetType): void;
_initializeState(state: ChannelAPIResponse<StreamChatGenerics>, messageSetToAddToIfDoesNotExist?: MessageSetType): {
messageSet: {
isCurrent: boolean;
isLatest: boolean;
messages: FormatMessageResponse<StreamChatGenerics>[];
};
};
_extendEventWithOwnReactions(event: Event<StreamChatGenerics>): void;
_disconnect(): void;
}
//# sourceMappingURL=channel.d.ts.map

@@ -18,2 +18,3 @@ /// <reference types="node" />

anonymous: boolean;
persistUserOnConnectionFailure?: boolean;
axiosInstance: AxiosInstance;

@@ -431,2 +432,3 @@ baseURL?: string;

queryChannels(filterConditions: ChannelFilters<StreamChatGenerics>, sort?: ChannelSort<StreamChatGenerics>, options?: ChannelOptions, stateOptions?: ChannelStateOptions): Promise<Channel<StreamChatGenerics>[]>;
hydrateActiveChannels(channelsFromApi?: ChannelAPIResponse<StreamChatGenerics>[], stateOptions?: ChannelStateOptions): Channel<StreamChatGenerics>[];
/**

@@ -850,2 +852,3 @@ * search - Query messages

} & {
type: import("./types").MessageLabel;
args?: string | undefined;

@@ -880,3 +883,2 @@ channel?: import("./types").ChannelResponse<StreamChatGenerics> | undefined;

thread_participants?: UserResponse<StreamChatGenerics>[] | undefined;
type?: import("./types").MessageLabel | undefined;
updated_at?: string | undefined;

@@ -883,0 +885,0 @@ } & {

@@ -43,2 +43,3 @@ export declare const EVENT_MAP: {

'user.watching.stop': boolean;
'channels.queried': boolean;
'connection.changed': boolean;

@@ -45,0 +46,0 @@ 'connection.recovered': boolean;

{
"name": "stream-chat",
"version": "6.7.3",
"version": "7.0.0-offline-support.0",
"description": "JS SDK for the Stream Chat API",

@@ -129,4 +129,3 @@ "author": "GetStream",

"preversion": "yarn && yarn lint && yarn test-unit",
"version": "git add yarn.lock",
"postversion": "git push && git push --tags && npm publish"
"version": "git add yarn.lock"
},

@@ -133,0 +132,0 @@ "husky": {

@@ -244,2 +244,6 @@ import { Channel } from './channel';

}
return {
messageSet: this.messageSets[targetMessageSetIndex],
};
}

@@ -698,2 +702,26 @@

/**
* findMessage - Finds a message inside the state
*
* @param {string} messageId The id of the message
* @param {string} parentMessageId The id of the parent message, if we want load a thread reply
*
* @return {ReturnType<ChannelState<StreamChatGenerics>['formatMessage']>} Returns the message, or undefined if the message wasn't found
*/
findMessage(messageId: string, parentMessageId?: string) {
if (parentMessageId) {
const messages = this.threads[parentMessageId];
if (!messages) {
return undefined;
}
return messages.find((m) => m.id === messageId);
}
const messageSetIndex = this.findMessageSetIndex({ id: messageId });
if (messageSetIndex === -1) {
return undefined;
}
return this.messageSets[messageSetIndex].messages.find((m) => m.id === messageId);
}
private switchToMessageSet(index: number) {

@@ -700,0 +728,0 @@ const currentMessages = this.messageSets.find((s) => s.isCurrent);

@@ -55,2 +55,3 @@ import { ChannelState } from './channel_state';

CreateCallResponse,
QueryChannelAPIResponse,
} from './types';

@@ -72,2 +73,3 @@ import { Role } from './permissions';

initialized: boolean;
staticState: boolean;
lastKeyStroke?: Date;

@@ -116,2 +118,3 @@ lastTypingEvent: Date | null;

this.initialized = false;
this.staticState = true;
this.lastTypingEvent = null;

@@ -728,3 +731,3 @@ this.isTyping = false;

*
* @return {Promise<ChannelAPIResponse<StreamChatGenerics>>} The server response
* @return {Promise<QueryChannelAPIResponse<StreamChatGenerics>>} The server response
*/

@@ -928,3 +931,3 @@ async watch(options?: ChannelQueryOptions<StreamChatGenerics>) {

*
* @return {Promise<ChannelAPIResponse<StreamChatGenerics>>} The Server Response
* @return {Promise<QueryChannelAPIResponse<StreamChatGenerics>>} The Server Response
*/

@@ -946,3 +949,3 @@ create = async () => {

*
* @return {Promise<ChannelAPIResponse<StreamChatGenerics>>} Returns a query response
* @return {Promise<QueryChannelAPIResponse<StreamChatGenerics>>} Returns a query response
*/

@@ -961,3 +964,3 @@ async query(

const state = await this.getClient().post<ChannelAPIResponse<StreamChatGenerics>>(queryURL + '/query', {
const state = await this.getClient().post<QueryChannelAPIResponse<StreamChatGenerics>>(queryURL + '/query', {
data: this._data,

@@ -994,4 +997,11 @@ state: true,

// add any messages to our channel state
this._initializeState(state, messageSetToAddToIfDoesNotExist);
const { messageSet } = this._initializeState(state, messageSetToAddToIfDoesNotExist);
this.getClient().dispatchEvent({
type: 'channels.queried',
queriedChannels: {
channels: [state],
isLatestMessageSet: messageSet.isLatest,
},
});
return state;

@@ -1222,2 +1232,3 @@ }

if (event.message) {
this._extendEventWithOwnReactions(event);
if (event.hard_delete) channelState.removeMessage(event.message);

@@ -1260,2 +1271,3 @@ else channelState.addMessageSorted(event.message, false, false);

if (event.message) {
this._extendEventWithOwnReactions(event);
channelState.addMessageSorted(event.message, false, false);

@@ -1280,3 +1292,4 @@ if (event.message.pinned) {

channelState.pinnedMessages.forEach(({ id, created_at: createdAt }) => {
if (truncatedAt > +createdAt) channelState.removePinnedMessage({ id });
if (truncatedAt > +createdAt)
channelState.removePinnedMessage({ id } as MessageResponse<StreamChatGenerics>);
});

@@ -1378,3 +1391,3 @@ } else {

_checkInitialized() {
if (!this.initialized && !this.getClient()._isUsingServerAuth()) {
if (!this.initialized && !this.staticState && !this.getClient()._isUsingServerAuth()) {
throw Error(

@@ -1408,3 +1421,4 @@ `Channel ${this.cid} hasn't been initialized yet. Make sure to call .watch() and wait for it to resolve`,

}
this.state.addMessagesSorted(messages, false, true, true, messageSetToAddToIfDoesNotExist);
const { messageSet } = this.state.addMessagesSorted(messages, false, true, true, messageSetToAddToIfDoesNotExist);
if (!this.state.pinnedMessages) {

@@ -1461,4 +1475,18 @@ this.state.pinnedMessages = [];

}
return {
messageSet,
};
}
_extendEventWithOwnReactions(event: Event<StreamChatGenerics>) {
if (!event.message) {
return;
}
const message = this.state.findMessage(event.message.id, event.message.parent_id);
if (message) {
event.message.own_reactions = message.own_reactions;
}
}
_disconnect() {

@@ -1465,0 +1493,0 @@ this._client.logger('info', `channel:disconnect() - Disconnecting the channel ${this.cid}`, {

@@ -256,3 +256,3 @@ import WebSocket from 'isomorphic-ws';

async _connect() {
if (this.isConnecting || this.isDisconnected) return; // simply ignore _connect if it's currently trying to connect
if (this.isConnecting || (this.isDisconnected && this.client.options.enableWSFallback)) return; // simply ignore _connect if it's currently trying to connect
this.isConnecting = true;

@@ -333,3 +333,3 @@ this.requestID = randomId();

if (this.isDisconnected) {
if (this.isDisconnected && this.client.options.enableWSFallback) {
this._log('_reconnect() - Abort (3) since disconnect() is called');

@@ -336,0 +336,0 @@ return;

@@ -45,2 +45,3 @@ export const EVENT_MAP = {

// local events
'channels.queried': true,
'connection.changed': true,

@@ -47,0 +48,0 @@ 'connection.recovered': true,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc