@hysc/meeting 1.6.18 → 1.6.20
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.
- package/esm/BMChat/BMChatVM.d.ts +24 -24
- package/esm/BMChat/BMMessageInfo.d.ts +27 -27
- package/esm/BMRoom/BMLiveVM.d.ts +35 -35
- package/esm/BMRoom/BMRoom.d.ts +5 -1
- package/esm/BMStream/BMSpeaker.d.ts +44 -44
- package/esm/BMStream/getHTMLMediaStreamOptions.d.ts +35 -35
- package/esm/bjy-common/function/execute.d.ts +9 -9
- package/esm/bjy-common/function/isNative.d.ts +1 -1
- package/esm/bjy-common/function/nextTick.d.ts +2 -2
- package/esm/bjy-common/function/toString.d.ts +1 -1
- package/esm/bjy-common/util/CustomEvent.d.ts +30 -30
- package/esm/bjy-common/util/Emitter.d.ts +57 -57
- package/esm/bjy-common/util/array.d.ts +96 -96
- package/esm/bjy-common/util/constant.d.ts +50 -50
- package/esm/bjy-common/util/is.d.ts +49 -49
- package/esm/bjy-common/util/keypath.d.ts +41 -41
- package/esm/bjy-common/util/logger.d.ts +42 -42
- package/esm/bjy-common/util/object.d.ts +83 -83
- package/esm/bjy-common/util/string.d.ts +102 -102
- package/esm/constants.d.ts +83 -83
- package/esm/index.js +1 -1
- package/esm/index.js.map +2 -2
- package/esm/util/emitter.d.ts +18 -18
- package/esm/util/roomUtils.d.ts +9 -9
- package/esm/util/util.d.ts +76 -76
- package/package.json +3 -3
- package/umd/BMChat/BMChatVM.d.ts +24 -0
- package/umd/BMChat/BMMessageInfo.d.ts +27 -0
- package/umd/BMRoom/BMLiveVM.d.ts +35 -0
- package/umd/BMRoom/BMRoom.d.ts +5 -1
- package/umd/BMStream/BMSpeaker.d.ts +44 -0
- package/umd/BMStream/getHTMLMediaStreamOptions.d.ts +35 -0
- package/umd/bjy-common/function/execute.d.ts +9 -0
- package/umd/bjy-common/function/isNative.d.ts +1 -0
- package/umd/bjy-common/function/nextTick.d.ts +2 -0
- package/umd/bjy-common/function/toString.d.ts +1 -0
- package/umd/bjy-common/util/CustomEvent.d.ts +30 -0
- package/umd/bjy-common/util/Emitter.d.ts +57 -0
- package/umd/bjy-common/util/array.d.ts +96 -0
- package/umd/bjy-common/util/constant.d.ts +50 -0
- package/umd/bjy-common/util/is.d.ts +49 -0
- package/umd/bjy-common/util/keypath.d.ts +41 -0
- package/umd/bjy-common/util/logger.d.ts +42 -0
- package/umd/bjy-common/util/object.d.ts +83 -0
- package/umd/bjy-common/util/string.d.ts +102 -0
- package/umd/constants.d.ts +83 -0
- package/umd/index.js +1 -1
- package/umd/util/emitter.d.ts +18 -0
- package/umd/util/roomUtils.d.ts +9 -0
- package/umd/util/util.d.ts +76 -0
package/esm/BMChat/BMChatVM.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import BoomCore from '@hysc/core/esm';
|
|
2
|
-
import BMMessageInfo from './BMMessageInfo';
|
|
3
|
-
import { BehaviorSubject, Subject } from "rxjs";
|
|
4
|
-
import BMUserVM from '../BMUser/BMUserVM';
|
|
5
|
-
import BMRoom from '../BMRoom/BMRoom';
|
|
6
|
-
export default class BMChatVM {
|
|
7
|
-
messageList: Array<BMMessageInfo>;
|
|
8
|
-
boomCore: BoomCore;
|
|
9
|
-
userVM: BMUserVM;
|
|
10
|
-
bmRoom: BMRoom;
|
|
11
|
-
messageListWatcher: BehaviorSubject<Array<BMMessageInfo>>;
|
|
12
|
-
hasDangerMessageWatcher: Subject<boolean>;
|
|
13
|
-
constructor(boomCore: BoomCore, userVM: BMUserVM, bmRoom: BMRoom);
|
|
14
|
-
/**
|
|
15
|
-
* 发送聊天消息
|
|
16
|
-
* @param talkMsg 聊天信息
|
|
17
|
-
*/
|
|
18
|
-
sendMessage(talkMsg: string, userId: string | undefined): Promise<void>;
|
|
19
|
-
addMessage(info: BMMessageInfo, isParticipantNotice: boolean): void;
|
|
20
|
-
/**
|
|
21
|
-
* 获取历史消息
|
|
22
|
-
*/
|
|
23
|
-
getHistoryMessage(): Promise<BMMessageInfo[]>;
|
|
24
|
-
}
|
|
1
|
+
import BoomCore from '@hysc/core/esm';
|
|
2
|
+
import BMMessageInfo from './BMMessageInfo';
|
|
3
|
+
import { BehaviorSubject, Subject } from "rxjs";
|
|
4
|
+
import BMUserVM from '../BMUser/BMUserVM';
|
|
5
|
+
import BMRoom from '../BMRoom/BMRoom';
|
|
6
|
+
export default class BMChatVM {
|
|
7
|
+
messageList: Array<BMMessageInfo>;
|
|
8
|
+
boomCore: BoomCore;
|
|
9
|
+
userVM: BMUserVM;
|
|
10
|
+
bmRoom: BMRoom;
|
|
11
|
+
messageListWatcher: BehaviorSubject<Array<BMMessageInfo>>;
|
|
12
|
+
hasDangerMessageWatcher: Subject<boolean>;
|
|
13
|
+
constructor(boomCore: BoomCore, userVM: BMUserVM, bmRoom: BMRoom);
|
|
14
|
+
/**
|
|
15
|
+
* 发送聊天消息
|
|
16
|
+
* @param talkMsg 聊天信息
|
|
17
|
+
*/
|
|
18
|
+
sendMessage(talkMsg: string, userId: string | undefined): Promise<void>;
|
|
19
|
+
addMessage(info: BMMessageInfo, isParticipantNotice: boolean): void;
|
|
20
|
+
/**
|
|
21
|
+
* 获取历史消息
|
|
22
|
+
*/
|
|
23
|
+
getHistoryMessage(): Promise<BMMessageInfo[]>;
|
|
24
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
interface IMessageInfo {
|
|
2
|
-
userId?: string;
|
|
3
|
-
message: string;
|
|
4
|
-
role?: string;
|
|
5
|
-
isLocal?: boolean;
|
|
6
|
-
avatar?: string;
|
|
7
|
-
nickName?: string;
|
|
8
|
-
sendTime?: number;
|
|
9
|
-
isMeetingNotice?: boolean;
|
|
10
|
-
to?: string | undefined;
|
|
11
|
-
isDanger?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export default class BMMessageInfo {
|
|
14
|
-
userId?: any;
|
|
15
|
-
message: string;
|
|
16
|
-
time: string;
|
|
17
|
-
timeStamp: number;
|
|
18
|
-
role?: string;
|
|
19
|
-
isLocal?: boolean;
|
|
20
|
-
avatar?: any;
|
|
21
|
-
nickName?: any;
|
|
22
|
-
isMeetingNotice: boolean;
|
|
23
|
-
to: string | undefined;
|
|
24
|
-
isDanger: boolean | undefined;
|
|
25
|
-
constructor(props: IMessageInfo);
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
1
|
+
interface IMessageInfo {
|
|
2
|
+
userId?: string;
|
|
3
|
+
message: string;
|
|
4
|
+
role?: string;
|
|
5
|
+
isLocal?: boolean;
|
|
6
|
+
avatar?: string;
|
|
7
|
+
nickName?: string;
|
|
8
|
+
sendTime?: number;
|
|
9
|
+
isMeetingNotice?: boolean;
|
|
10
|
+
to?: string | undefined;
|
|
11
|
+
isDanger?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export default class BMMessageInfo {
|
|
14
|
+
userId?: any;
|
|
15
|
+
message: string;
|
|
16
|
+
time: string;
|
|
17
|
+
timeStamp: number;
|
|
18
|
+
role?: string;
|
|
19
|
+
isLocal?: boolean;
|
|
20
|
+
avatar?: any;
|
|
21
|
+
nickName?: any;
|
|
22
|
+
isMeetingNotice: boolean;
|
|
23
|
+
to: string | undefined;
|
|
24
|
+
isDanger: boolean | undefined;
|
|
25
|
+
constructor(props: IMessageInfo);
|
|
26
|
+
}
|
|
27
|
+
export {};
|
package/esm/BMRoom/BMLiveVM.d.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @name: BMLiveVM.ts
|
|
3
|
-
* @author: yangliye
|
|
4
|
-
* @date: 2022-07-15 13:53
|
|
5
|
-
* @description:处理直播相关的流处理
|
|
6
|
-
* @update: 2022-07-15 13:53
|
|
7
|
-
*/
|
|
8
|
-
import BMRoom from "./BMRoom";
|
|
9
|
-
import BMStreamModel from "../BMStream/BMStreamModel";
|
|
10
|
-
declare class BMLiveVM {
|
|
11
|
-
private room;
|
|
12
|
-
constructor(room: BMRoom);
|
|
13
|
-
private get localBMUser();
|
|
14
|
-
private get localIsAudience();
|
|
15
|
-
/**
|
|
16
|
-
* 拉流处理
|
|
17
|
-
* @param bmStreamModel
|
|
18
|
-
*/
|
|
19
|
-
handlePull(bmStreamModel: BMStreamModel): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* 切换大小流处理
|
|
22
|
-
* @param bmStreamModel
|
|
23
|
-
*/
|
|
24
|
-
handleChangeStreamType(bmStreamModel: BMStreamModel): Promise<void>;
|
|
25
|
-
handlePlay(bmStreamModel: BMStreamModel, noPlayChanged: boolean): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* 处理观众端举手发言完了,然后在禁止发言,这个时候,没有必要在拉所有人的流,把除了混流的人的流都取消订阅,然后播放混流的声音
|
|
28
|
-
*/
|
|
29
|
-
handleAudienceDisable(): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* 观众允许发言,允许发言之后,要把所有的流都拉,然后混流静音
|
|
32
|
-
*/
|
|
33
|
-
handleAudienceEnable(): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
export default BMLiveVM;
|
|
1
|
+
/**
|
|
2
|
+
* @name: BMLiveVM.ts
|
|
3
|
+
* @author: yangliye
|
|
4
|
+
* @date: 2022-07-15 13:53
|
|
5
|
+
* @description:处理直播相关的流处理
|
|
6
|
+
* @update: 2022-07-15 13:53
|
|
7
|
+
*/
|
|
8
|
+
import BMRoom from "./BMRoom";
|
|
9
|
+
import BMStreamModel from "../BMStream/BMStreamModel";
|
|
10
|
+
declare class BMLiveVM {
|
|
11
|
+
private room;
|
|
12
|
+
constructor(room: BMRoom);
|
|
13
|
+
private get localBMUser();
|
|
14
|
+
private get localIsAudience();
|
|
15
|
+
/**
|
|
16
|
+
* 拉流处理
|
|
17
|
+
* @param bmStreamModel
|
|
18
|
+
*/
|
|
19
|
+
handlePull(bmStreamModel: BMStreamModel): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* 切换大小流处理
|
|
22
|
+
* @param bmStreamModel
|
|
23
|
+
*/
|
|
24
|
+
handleChangeStreamType(bmStreamModel: BMStreamModel): Promise<void>;
|
|
25
|
+
handlePlay(bmStreamModel: BMStreamModel, noPlayChanged: boolean): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* 处理观众端举手发言完了,然后在禁止发言,这个时候,没有必要在拉所有人的流,把除了混流的人的流都取消订阅,然后播放混流的声音
|
|
28
|
+
*/
|
|
29
|
+
handleAudienceDisable(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* 观众允许发言,允许发言之后,要把所有的流都拉,然后混流静音
|
|
32
|
+
*/
|
|
33
|
+
handleAudienceEnable(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export default BMLiveVM;
|
package/esm/BMRoom/BMRoom.d.ts
CHANGED
|
@@ -55,9 +55,13 @@ export default class BMRoom {
|
|
|
55
55
|
videoProfile: VideoProfile;
|
|
56
56
|
private audioProfile;
|
|
57
57
|
/**
|
|
58
|
-
* 断网重连要给端上事件响应,所有端上把流单独做处理的,需要在收到这个事件之后,重新处理所有的effect
|
|
58
|
+
* brtc断网重连要给端上事件响应,所有端上把流单独做处理的,需要在收到这个事件之后,重新处理所有的effect
|
|
59
59
|
*/
|
|
60
60
|
streamWSReconnectWatcher: Subject<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* bloud断网重连的时候的提示
|
|
63
|
+
*/
|
|
64
|
+
bloudWSReconnectWatcher: Subject<boolean>;
|
|
61
65
|
/**
|
|
62
66
|
* 会控底层相关处理, 比如是否取消自动拉流
|
|
63
67
|
*/
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import BMUser from '../BMUser/BMUser';
|
|
2
|
-
import { SingleStream } from '../type';
|
|
3
|
-
/**
|
|
4
|
-
* @name: BMSpeaker
|
|
5
|
-
* @author: liuxinghai
|
|
6
|
-
* @date: 2022-06-07 11:41
|
|
7
|
-
* @description:BMSpeaker
|
|
8
|
-
* 适配 brtc 流对象到 bloud 流对象接口,
|
|
9
|
-
* 用户辅助采用 bloud SpeakerDetector 做说话人检测
|
|
10
|
-
* @date: 2022-06-07 11:41
|
|
11
|
-
*/
|
|
12
|
-
export default class BMSpeaker {
|
|
13
|
-
private _user;
|
|
14
|
-
private _stream;
|
|
15
|
-
private _emitter;
|
|
16
|
-
constructor(user: BMUser, stream: SingleStream);
|
|
17
|
-
/**
|
|
18
|
-
* 获取对象 ID 标识,此处使用流 ID 标识
|
|
19
|
-
* @returns
|
|
20
|
-
*/
|
|
21
|
-
getID(): string;
|
|
22
|
-
/**
|
|
23
|
-
* 获取用户 BMUser 对象
|
|
24
|
-
* @returns
|
|
25
|
-
*/
|
|
26
|
-
getUser(): BMUser;
|
|
27
|
-
/**
|
|
28
|
-
* 监听事件
|
|
29
|
-
*
|
|
30
|
-
* @param type 事件类型
|
|
31
|
-
* @param fn 事件回调
|
|
32
|
-
* @return 实例本身 {@link Client}
|
|
33
|
-
*/
|
|
34
|
-
on(type: string, fn: Function): this;
|
|
35
|
-
/**
|
|
36
|
-
* 启动音频音量检测
|
|
37
|
-
*/
|
|
38
|
-
collectAudioLevel(): void;
|
|
39
|
-
private handleAudioLevel;
|
|
40
|
-
/**
|
|
41
|
-
* 关闭音频音量检测
|
|
42
|
-
*/
|
|
43
|
-
close(): void;
|
|
44
|
-
}
|
|
1
|
+
import BMUser from '../BMUser/BMUser';
|
|
2
|
+
import { SingleStream } from '../type';
|
|
3
|
+
/**
|
|
4
|
+
* @name: BMSpeaker
|
|
5
|
+
* @author: liuxinghai
|
|
6
|
+
* @date: 2022-06-07 11:41
|
|
7
|
+
* @description:BMSpeaker
|
|
8
|
+
* 适配 brtc 流对象到 bloud 流对象接口,
|
|
9
|
+
* 用户辅助采用 bloud SpeakerDetector 做说话人检测
|
|
10
|
+
* @date: 2022-06-07 11:41
|
|
11
|
+
*/
|
|
12
|
+
export default class BMSpeaker {
|
|
13
|
+
private _user;
|
|
14
|
+
private _stream;
|
|
15
|
+
private _emitter;
|
|
16
|
+
constructor(user: BMUser, stream: SingleStream);
|
|
17
|
+
/**
|
|
18
|
+
* 获取对象 ID 标识,此处使用流 ID 标识
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
getID(): string;
|
|
22
|
+
/**
|
|
23
|
+
* 获取用户 BMUser 对象
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
getUser(): BMUser;
|
|
27
|
+
/**
|
|
28
|
+
* 监听事件
|
|
29
|
+
*
|
|
30
|
+
* @param type 事件类型
|
|
31
|
+
* @param fn 事件回调
|
|
32
|
+
* @return 实例本身 {@link Client}
|
|
33
|
+
*/
|
|
34
|
+
on(type: string, fn: Function): this;
|
|
35
|
+
/**
|
|
36
|
+
* 启动音频音量检测
|
|
37
|
+
*/
|
|
38
|
+
collectAudioLevel(): void;
|
|
39
|
+
private handleAudioLevel;
|
|
40
|
+
/**
|
|
41
|
+
* 关闭音频音量检测
|
|
42
|
+
*/
|
|
43
|
+
close(): void;
|
|
44
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @name: getHTMLMediaStreamOptions
|
|
3
|
-
* @author: yangliye
|
|
4
|
-
* @date: 2022-09-15 14:58
|
|
5
|
-
* @description:getHTMLMediaStreamOptions
|
|
6
|
-
* @update: 2022-09-15 14:58
|
|
7
|
-
*/
|
|
8
|
-
interface Options {
|
|
9
|
-
videoElement: HTMLVideoElement;
|
|
10
|
-
}
|
|
11
|
-
export interface Result {
|
|
12
|
-
video: boolean;
|
|
13
|
-
audio: boolean;
|
|
14
|
-
videoSource: MediaStreamTrack;
|
|
15
|
-
audioSource: MediaStreamTrack;
|
|
16
|
-
width: number;
|
|
17
|
-
height: number;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* 获取video标签中的mediaStream
|
|
21
|
-
* @param opts
|
|
22
|
-
*/
|
|
23
|
-
export declare function getHTMLMediaStreamOptions(opts: Options): Result | null;
|
|
24
|
-
export declare function getMediaStreamInfo(mediaStream: MediaStream, videoInfo: {
|
|
25
|
-
width: number;
|
|
26
|
-
height: number;
|
|
27
|
-
}): {
|
|
28
|
-
video: boolean;
|
|
29
|
-
audio: boolean;
|
|
30
|
-
videoSource: MediaStreamTrack;
|
|
31
|
-
audioSource: MediaStreamTrack;
|
|
32
|
-
width: number;
|
|
33
|
-
height: number;
|
|
34
|
-
} | null;
|
|
35
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* @name: getHTMLMediaStreamOptions
|
|
3
|
+
* @author: yangliye
|
|
4
|
+
* @date: 2022-09-15 14:58
|
|
5
|
+
* @description:getHTMLMediaStreamOptions
|
|
6
|
+
* @update: 2022-09-15 14:58
|
|
7
|
+
*/
|
|
8
|
+
interface Options {
|
|
9
|
+
videoElement: HTMLVideoElement;
|
|
10
|
+
}
|
|
11
|
+
export interface Result {
|
|
12
|
+
video: boolean;
|
|
13
|
+
audio: boolean;
|
|
14
|
+
videoSource: MediaStreamTrack;
|
|
15
|
+
audioSource: MediaStreamTrack;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 获取video标签中的mediaStream
|
|
21
|
+
* @param opts
|
|
22
|
+
*/
|
|
23
|
+
export declare function getHTMLMediaStreamOptions(opts: Options): Result | null;
|
|
24
|
+
export declare function getMediaStreamInfo(mediaStream: MediaStream, videoInfo: {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
}): {
|
|
28
|
+
video: boolean;
|
|
29
|
+
audio: boolean;
|
|
30
|
+
videoSource: MediaStreamTrack;
|
|
31
|
+
audioSource: MediaStreamTrack;
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
} | null;
|
|
35
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 任性地执行一个函数,不管它有没有、是不是
|
|
3
|
-
*
|
|
4
|
-
* @param fn 调用的函数
|
|
5
|
-
* @param context 执行函数时的 this 指向
|
|
6
|
-
* @param args 调用函数的参数,多参数时传入数组
|
|
7
|
-
* @return 调用函数的返回值
|
|
8
|
-
*/
|
|
9
|
-
export default function (fn: any, context?: any, args?: any): any;
|
|
1
|
+
/**
|
|
2
|
+
* 任性地执行一个函数,不管它有没有、是不是
|
|
3
|
+
*
|
|
4
|
+
* @param fn 调用的函数
|
|
5
|
+
* @param context 执行函数时的 this 指向
|
|
6
|
+
* @param args 调用函数的参数,多参数时传入数组
|
|
7
|
+
* @return 调用函数的返回值
|
|
8
|
+
*/
|
|
9
|
+
export default function (fn: any, context?: any, args?: any): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function (target: any): boolean;
|
|
1
|
+
export default function (target: any): boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare let nextTick: Function;
|
|
2
|
-
export default nextTick;
|
|
1
|
+
declare let nextTick: Function;
|
|
2
|
+
export default nextTick;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function (target: any, defaultValue?: string): string;
|
|
1
|
+
export default function (target: any, defaultValue?: string): string;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { CustomEventInterface } from '../type/type';
|
|
2
|
-
export default class CustomEvent implements CustomEventInterface {
|
|
3
|
-
static PHASE_CURRENT: number;
|
|
4
|
-
static PHASE_UPWARD: number;
|
|
5
|
-
static PHASE_DOWNWARD: number;
|
|
6
|
-
type: string;
|
|
7
|
-
phase: number;
|
|
8
|
-
ns?: string;
|
|
9
|
-
target?: any;
|
|
10
|
-
originalEvent?: CustomEventInterface | Event;
|
|
11
|
-
isPrevented?: true;
|
|
12
|
-
isStoped?: true;
|
|
13
|
-
listener?: Function;
|
|
14
|
-
/**
|
|
15
|
-
* 构造函数
|
|
16
|
-
*
|
|
17
|
-
* 可以传事件名称,也可以传原生事件对象
|
|
18
|
-
*/
|
|
19
|
-
constructor(type: string, originalEvent?: CustomEventInterface | Event);
|
|
20
|
-
/**
|
|
21
|
-
* 阻止事件的默认行为
|
|
22
|
-
*/
|
|
23
|
-
preventDefault(): this;
|
|
24
|
-
/**
|
|
25
|
-
* 停止事件广播
|
|
26
|
-
*/
|
|
27
|
-
stopPropagation(): this;
|
|
28
|
-
prevent(): this;
|
|
29
|
-
stop(): this;
|
|
30
|
-
}
|
|
1
|
+
import { CustomEventInterface } from '../type/type';
|
|
2
|
+
export default class CustomEvent implements CustomEventInterface {
|
|
3
|
+
static PHASE_CURRENT: number;
|
|
4
|
+
static PHASE_UPWARD: number;
|
|
5
|
+
static PHASE_DOWNWARD: number;
|
|
6
|
+
type: string;
|
|
7
|
+
phase: number;
|
|
8
|
+
ns?: string;
|
|
9
|
+
target?: any;
|
|
10
|
+
originalEvent?: CustomEventInterface | Event;
|
|
11
|
+
isPrevented?: true;
|
|
12
|
+
isStoped?: true;
|
|
13
|
+
listener?: Function;
|
|
14
|
+
/**
|
|
15
|
+
* 构造函数
|
|
16
|
+
*
|
|
17
|
+
* 可以传事件名称,也可以传原生事件对象
|
|
18
|
+
*/
|
|
19
|
+
constructor(type: string, originalEvent?: CustomEventInterface | Event);
|
|
20
|
+
/**
|
|
21
|
+
* 阻止事件的默认行为
|
|
22
|
+
*/
|
|
23
|
+
preventDefault(): this;
|
|
24
|
+
/**
|
|
25
|
+
* 停止事件广播
|
|
26
|
+
*/
|
|
27
|
+
stopPropagation(): this;
|
|
28
|
+
prevent(): this;
|
|
29
|
+
stop(): this;
|
|
30
|
+
}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { NativeListener } from '../type/type';
|
|
2
|
-
import { EmitterOptions } from '../type/options';
|
|
3
|
-
declare type Namespace = {
|
|
4
|
-
type: string;
|
|
5
|
-
ns?: string;
|
|
6
|
-
};
|
|
7
|
-
export default class Emitter {
|
|
8
|
-
/**
|
|
9
|
-
* 是否开启命名空间
|
|
10
|
-
*/
|
|
11
|
-
ns: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* 已注册的事件监听
|
|
14
|
-
*/
|
|
15
|
-
listeners: Record<string, EmitterOptions[]>;
|
|
16
|
-
/**
|
|
17
|
-
* 原生事件监听,一个事件对应一个 listener
|
|
18
|
-
*/
|
|
19
|
-
nativeListeners?: Record<string, NativeListener>;
|
|
20
|
-
constructor(ns?: boolean);
|
|
21
|
-
/**
|
|
22
|
-
* 发射事件
|
|
23
|
-
*
|
|
24
|
-
* @param type 事件名称或命名空间
|
|
25
|
-
* @param args 事件处理函数的参数列表
|
|
26
|
-
* @param filter 自定义过滤器
|
|
27
|
-
*/
|
|
28
|
-
fire(type: string | Namespace, args: any[] | void, filter?: (namespace: Namespace, args: any[] | void, options: EmitterOptions) => boolean | void): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* 注册监听
|
|
31
|
-
*
|
|
32
|
-
* @param type
|
|
33
|
-
* @param listener
|
|
34
|
-
*/
|
|
35
|
-
on(type: string | Namespace, listener: Function | EmitterOptions): void;
|
|
36
|
-
/**
|
|
37
|
-
* 取消监听
|
|
38
|
-
*
|
|
39
|
-
* @param type
|
|
40
|
-
* @param listener
|
|
41
|
-
*/
|
|
42
|
-
off(type?: string | Namespace, listener?: Function): void;
|
|
43
|
-
/**
|
|
44
|
-
* 是否已监听某个事件
|
|
45
|
-
*
|
|
46
|
-
* @param type
|
|
47
|
-
* @param listener
|
|
48
|
-
*/
|
|
49
|
-
has(type: string | Namespace, listener?: Function): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* 把事件类型解析成命名空间格式
|
|
52
|
-
*
|
|
53
|
-
* @param type
|
|
54
|
-
*/
|
|
55
|
-
parse(type: string): Namespace;
|
|
56
|
-
}
|
|
57
|
-
export {};
|
|
1
|
+
import { NativeListener } from '../type/type';
|
|
2
|
+
import { EmitterOptions } from '../type/options';
|
|
3
|
+
declare type Namespace = {
|
|
4
|
+
type: string;
|
|
5
|
+
ns?: string;
|
|
6
|
+
};
|
|
7
|
+
export default class Emitter {
|
|
8
|
+
/**
|
|
9
|
+
* 是否开启命名空间
|
|
10
|
+
*/
|
|
11
|
+
ns: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 已注册的事件监听
|
|
14
|
+
*/
|
|
15
|
+
listeners: Record<string, EmitterOptions[]>;
|
|
16
|
+
/**
|
|
17
|
+
* 原生事件监听,一个事件对应一个 listener
|
|
18
|
+
*/
|
|
19
|
+
nativeListeners?: Record<string, NativeListener>;
|
|
20
|
+
constructor(ns?: boolean);
|
|
21
|
+
/**
|
|
22
|
+
* 发射事件
|
|
23
|
+
*
|
|
24
|
+
* @param type 事件名称或命名空间
|
|
25
|
+
* @param args 事件处理函数的参数列表
|
|
26
|
+
* @param filter 自定义过滤器
|
|
27
|
+
*/
|
|
28
|
+
fire(type: string | Namespace, args: any[] | void, filter?: (namespace: Namespace, args: any[] | void, options: EmitterOptions) => boolean | void): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* 注册监听
|
|
31
|
+
*
|
|
32
|
+
* @param type
|
|
33
|
+
* @param listener
|
|
34
|
+
*/
|
|
35
|
+
on(type: string | Namespace, listener: Function | EmitterOptions): void;
|
|
36
|
+
/**
|
|
37
|
+
* 取消监听
|
|
38
|
+
*
|
|
39
|
+
* @param type
|
|
40
|
+
* @param listener
|
|
41
|
+
*/
|
|
42
|
+
off(type?: string | Namespace, listener?: Function): void;
|
|
43
|
+
/**
|
|
44
|
+
* 是否已监听某个事件
|
|
45
|
+
*
|
|
46
|
+
* @param type
|
|
47
|
+
* @param listener
|
|
48
|
+
*/
|
|
49
|
+
has(type: string | Namespace, listener?: Function): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* 把事件类型解析成命名空间格式
|
|
52
|
+
*
|
|
53
|
+
* @param type
|
|
54
|
+
*/
|
|
55
|
+
parse(type: string): Namespace;
|
|
56
|
+
}
|
|
57
|
+
export {};
|