Skip to content

Commit

Permalink
chore(release): v4.0.0-beta.5
Browse files Browse the repository at this point in the history
  • Loading branch information
leeyeh committed Apr 15, 2018
1 parent d59d79f commit feac8a5
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 44 deletions.
55 changes: 46 additions & 9 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
<a name="4.0.0-beta.5"></a>

# [4.0.0-beta.5](https://github.com/leancloud/js-realtime-sdk/compare/v4.0.0-beta.4...v4.0.0-beta.5) (2018-04-13)

### Bug Fixes

* 修复了多个导致切换用户时连接状态异常的问题。

### Features

* 支持按照富媒体消息类型查询历史消息。`Conversation#queryMessages` 方法增加了 `type` 参数用于指定查询的消息的类型

<details>
<summary>示例</summary>

```js
// 限定查询图片消息
conversation
.queryMessage({
type: ImageMessage.TYPE,
})
.then(console.log)
.catch(console.error);
```

</details>

* 新增枚举 `Event`SDK 派发的事件的名称是全小写风格的字符串。当事件的名称由多个单词组成时,全小写风格的命名会很难辩识(例如 `unreadmessagescountupdate`)。SDK 现在提供了事件常量枚举 `Event`,你可以使用 `Event.UNREAD_MESSAGES_COUNT_UPDATE` 来代替 `unreadmessagescountupdate` 了。
* 引入了更加可靠的通知机制。在断线期间发生的 `INVITED``KICKED` 事件,现在会在断线重连成功后收到。

### BREAKING CHANGES

* 不再支持下列运行环境(SDK 应该仍能在这些环境下工作,但我们不再对其进行测试了):
* Chrome < 45
* iOS < 9.3

<a name="4.0.0-beta.4"></a>

# 4.0.0-beta.4 (2018-02-06)
Expand Down Expand Up @@ -144,8 +180,8 @@

* 初始化 `Realtime` 现在需要 `appKey` 参数。

<details>
<summary>示例</summary>
<details>
<summary>示例</summary>

```diff
const realtime = new Realtime({
Expand All @@ -154,12 +190,12 @@
});
```

</details>
</details>

* 现在所有异步 API 的异常都是以异步的方式抛出。我们还更新了 API 文档,标出了 API 的异步属性。

<details>
<summary>示例</summary>
<details>
<summary>示例</summary>

```javascript
// before
Expand All @@ -175,13 +211,13 @@
});
```

</details>
</details>

* 为了更好的隔离服务,我们为每个应用提供了独立的域名。对于小程序用户,请前往 [《小程序域名白名单配置》](https://leancloud.cn/docs/weapp-domains.html) 更新域名白名单。
* 移除了 v3 中被标记为废弃的 API,包括:

<details>
<summary>移除 API 列表</summary>
<details>
<summary>移除 API 列表</summary>

* `IMClient`
* `#markAllAsRead` 方法
Expand All @@ -194,10 +230,11 @@
* `ConversationQuery`
* `#withLastMessages` 方法
* `Message`

* `needReceipt``transient` 属性
* `#setNeedReceipt``#setTransient` 方法

</details>
</details>

### Features

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leancloud-realtime",
"version": "4.0.0-beta.4",
"version": "4.0.0-beta.5",
"description": "LeanCloud Realtime Message JavaScript SDK",
"main": "./dist/realtime.js",
"jsnext:main": "./src/index.js",
Expand Down
142 changes: 108 additions & 34 deletions realtime.d.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
declare module LeanCloudRealtime {
declare namespace LeanCloudRealtime {
interface AVUser {
getSessionToken(): string;
}

interface SignatureResult {
signature: string,
timestamp: number,
nonce: string,
signature: string;
timestamp: number;
nonce: string;
}
type SignatureFactoryResult = Promise<SignatureResult> | SignatureResult;

export class Realtime extends EventEmitter {
constructor(options: { appId: string, appKey: string, region?: string, pushOfflineMessages?: boolean, noBinary?: boolean, ssl?: boolean, server?: string|{RTMRouter: string, api: string}, RTMServers?: string|string[], plugins?: Array<Plugin> });
constructor(options: {
appId: string;
appKey: string;
region?: string;
pushOfflineMessages?: boolean;
noBinary?: boolean;
ssl?: boolean;
server?: string | { RTMRouter: string; api: string };
RTMServers?: string | string[];
plugins?: Array<Plugin>;
});
createIMClient(
client: string|AVUser,
client: string | AVUser,
options?: {
signatureFactory?: (clientId: string) => SignatureFactoryResult,
conversationSignatureFactory?: (clientId: string, conversationId: string, targetIds: string[], action: string) => SignatureFactoryResult,
blacklistSignatureFactory?: (clientId: string, conversationId: string, targetIds: string[], action: string) => SignatureFactoryResult,
tag?: string,
isReconnect?: boolean,
signatureFactory?: (clientId: string) => SignatureFactoryResult;
conversationSignatureFactory?: (
clientId: string,
conversationId: string,
targetIds: string[],
action: string
) => SignatureFactoryResult;
blacklistSignatureFactory?: (
clientId: string,
conversationId: string,
targetIds: string[],
action: string
) => SignatureFactoryResult;
tag?: string;
isReconnect?: boolean;
},
tag?: string,
tag?: string
): Promise<IMClient>;
static defineConversationProperty(prop: string, descriptor?: Object);
register(messageClass: AVMessage[]);
Expand All @@ -31,14 +51,28 @@ declare module LeanCloudRealtime {
class IMClient extends EventEmitter {
id: string;
close(): Promise<void>;
createConversation(options: { members?: string[], name?: string, transient?: boolean, unique?: boolean, [key: string]: any }): Promise<ConversationBase>;
createChatRoom(options: { name?: string, [key: string]: any }): Promise<ChatRoom>;
createTemporaryConversation(options: { members?: string[], ttl?: number }): Promise<TemporaryConversation>;
createConversation(options: {
members?: string[];
name?: string;
transient?: boolean;
unique?: boolean;
[key: string]: any;
}): Promise<ConversationBase>;
createChatRoom(options: {
name?: string;
[key: string]: any;
}): Promise<ChatRoom>;
createTemporaryConversation(options: {
members?: string[];
ttl?: number;
}): Promise<TemporaryConversation>;
getConversation(id: string, noCache?: boolean): Promise<ConversationBase>;
getQuery(): ConversationQuery<PresistentConversation>;
getServiceConversationQuery(): ConversationQuery<ServiceConversation>;
getChatRoomQuery(): ConversationQuery<ChatRoom>;
markAllAsRead(conversations: ConversationBase[]): Promise<Array<ConversationBase>>;
markAllAsRead(
conversations: ConversationBase[]
): Promise<Array<ConversationBase>>;
ping(clientIds: string[]): Promise<Array<string>>;
parseMessage(json: Object): Promise<AVMessage>;
parseConversation(json: Object): Promise<ConversationBase>;
Expand Down Expand Up @@ -74,8 +108,8 @@ declare module LeanCloudRealtime {
withMembers(peerIds: string[], includeSelf: boolean): this;
}
/**
* 对话
*/
* 对话
*/
class ConversationBase extends EventEmitter {
id: string;
lastMessage?: Message;
Expand All @@ -87,13 +121,46 @@ declare module LeanCloudRealtime {
readonly unreadMessagesMentioned: Boolean;
[key: string]: any;
// constructor();
createMessagesIterator(option: { limit?: number, beforeTime?: Date, beforeMessageId?: string });
createMessagesIterator(option: {
limit?: number;
beforeTime?: Date;
beforeMessageId?: string;
});
read(): Promise<this>;
fetchReceiptTimestamps(): Promise<this>;
queryMessages(options: { beforeTime?: Date, beforeMessageId?: string, afterTime?: Date, afterMessageId?: string, limit?: number, type: number }): Promise<Array<Message>>;
queryMessages(options: { startTime?: Date, startMessageId?: string, startClosed?: boolean, endTime?: Date, endMessageId?: string, endClosed?: boolean, limit?: number, type: number, direction?: MessageQueryDirection }): Promise<Array<Message>>;
send<T extends Message>(message: T, options?: { pushData?: Object, priority?: MessagePriority, receipt?: boolean, transient?: boolean, will?: boolean }): Promise<T>;
update<T extends Message>(message: MessagePointer, newMessage: T): Promise<T>;
queryMessages(options: {
beforeTime?: Date;
beforeMessageId?: string;
afterTime?: Date;
afterMessageId?: string;
limit?: number;
type: number;
}): Promise<Array<Message>>;
queryMessages(options: {
startTime?: Date;
startMessageId?: string;
startClosed?: boolean;
endTime?: Date;
endMessageId?: string;
endClosed?: boolean;
limit?: number;
type: number;
direction?: MessageQueryDirection;
}): Promise<Array<Message>>;
send<T extends Message>(
message: T,
options?: {
pushData?: Object;
priority?: MessagePriority;
receipt?: boolean;
transient?: boolean;
will?: boolean;
}
): Promise<T>;
update<T extends Message>(
message: MessagePointer,
newMessage: T
): Promise<T>;
recall(message: MessagePointer): Promise<RecalledMessage>;
count(): Promise<number>;
toJSON(): Object;
Expand Down Expand Up @@ -142,13 +209,20 @@ declare module LeanCloudRealtime {
remove(clientIds: string[]): Promise<PartiallySuccess>;
muteMembers(clientIds: string[]): Promise<PartiallySuccess>;
unmuteMembers(clientIds: string[]): Promise<PartiallySuccess>;
queryMutedMembers(options?: PagedQueryParams): Promise<PagedResults<string>>;
queryMutedMembers(
options?: PagedQueryParams
): Promise<PagedResults<string>>;
blockMembers(clientIds: string[]): Promise<PartiallySuccess>;
unblockMembers(clientIds: string[]): Promise<PartiallySuccess>;
queryBlockedMembers(options?: PagedQueryParams): Promise<PagedResults<string>>;
queryBlockedMembers(
options?: PagedQueryParams
): Promise<PagedResults<string>>;
getAllMemberInfo(): Promise<ConversationMemberInfo[]>;
getMemberInfo(memberId: string): Promise<ConversationMemberInfo>;
updateMemberRole(memberId: string, role: ConversationMemberRole): Promise<this>;
updateMemberRole(
memberId: string,
role: ConversationMemberRole
): Promise<this>;
}

export class Conversation extends PresistentConversation {}
Expand Down Expand Up @@ -176,7 +250,7 @@ declare module LeanCloudRealtime {
toJSON(): Object;
}

type MessagePointer = Message | {id: string, timestamp: Date|number};
type MessagePointer = Message | { id: string; timestamp: Date | number };

type Payload = Object | String | ArrayBuffer;

Expand Down Expand Up @@ -214,7 +288,7 @@ declare module LeanCloudRealtime {

// 富媒体消息
export class TypedMessage extends Message {
static type: number;
static TYPE: number;
attributes: Object;
text: string;
readonly summary: string;
Expand All @@ -239,10 +313,10 @@ declare module LeanCloudRealtime {
}

interface Middleware<T> {
(target: T): T
(target: T): T;
}
interface Decorator<T> {
(target: T): void
(target: T): void;
}

export interface Plugin {
Expand Down Expand Up @@ -300,7 +374,7 @@ declare module LeanCloudRealtime {
INVALID_MESSAGING_TARGET,
MESSAGE_REJECTED_BY_APP,
}

export enum Event {
DISCONNECT,
RECONNECT,
Expand All @@ -310,7 +384,7 @@ declare module LeanCloudRealtime {
ONLINE,

RECONNECT_ERROR,

INVITED,
KICKED,
MEMBERS_JOINED,
Expand Down Expand Up @@ -338,8 +412,8 @@ declare module LeanCloudRealtime {
INFO_UPDATED,
}

export function messageType(type: number): Function
export function messageField(fields: string[]): Function
export function messageType(type: number): Function;
export function messageField(fields: string[]): Function;
}

export = LeanCloudRealtime;

0 comments on commit feac8a5

Please sign in to comment.