@seastart/srtc-web-sdk 0.0.9 → 0.1.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.
- package/package.json +1 -1
- package/srtc.d.mts +97 -16
- package/srtc.d.ts +97 -16
- package/srtc.js +1 -1
- package/srtc.mjs +1 -1
package/package.json
CHANGED
package/srtc.d.mts
CHANGED
|
@@ -10,12 +10,16 @@ declare abstract class BaseSRTC {
|
|
|
10
10
|
* 获取运行环境信息
|
|
11
11
|
* @returns
|
|
12
12
|
*/
|
|
13
|
-
getEnvInfo():
|
|
13
|
+
getEnvInfo(): any;
|
|
14
14
|
/**
|
|
15
15
|
* 频道事件通知回调
|
|
16
16
|
*/
|
|
17
17
|
onNotifyChannelEvent?: ((event: ChannelEvent) => void) | null;
|
|
18
|
-
constructor(initParams:
|
|
18
|
+
constructor(initParams: SdkInitParams);
|
|
19
|
+
/**
|
|
20
|
+
* 加入频道的version信息
|
|
21
|
+
*/
|
|
22
|
+
protected get joinVersion(): string;
|
|
19
23
|
/**
|
|
20
24
|
* 加入频道
|
|
21
25
|
* @param token 加入频道token
|
|
@@ -128,6 +132,35 @@ declare class CommonChannelEventType {
|
|
|
128
132
|
/** 流轨道停止,对应data为BaseTrack */
|
|
129
133
|
static readonly TRACK_ENDED = "track_ended";
|
|
130
134
|
}
|
|
135
|
+
declare class Logger {
|
|
136
|
+
constructor(dp?: string, dclt?: string);
|
|
137
|
+
setTarget(target: LogTarget): void;
|
|
138
|
+
setLevel(level: LogLevel): void;
|
|
139
|
+
debug(...args: any[]): void;
|
|
140
|
+
info(...args: any[]): void;
|
|
141
|
+
warn(...args: any[]): void;
|
|
142
|
+
error(...args: any[]): void;
|
|
143
|
+
}
|
|
144
|
+
declare class SdkError {
|
|
145
|
+
/** 错误码 */
|
|
146
|
+
code: number;
|
|
147
|
+
/** 错误详情 */
|
|
148
|
+
msg: string;
|
|
149
|
+
/** 获取前缀错误码 */
|
|
150
|
+
protected prefixCode(): string;
|
|
151
|
+
constructor(msg: string, code?: number);
|
|
152
|
+
/**
|
|
153
|
+
* 从err转化为sdkError
|
|
154
|
+
* @param err 原始error
|
|
155
|
+
* @returns
|
|
156
|
+
*/
|
|
157
|
+
static fromError(err: Error): SdkError;
|
|
158
|
+
toString(): string;
|
|
159
|
+
toJSON(): {
|
|
160
|
+
code: number;
|
|
161
|
+
msg: string;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
131
164
|
declare enum Codec {
|
|
132
165
|
/** 未知编码类型 */
|
|
133
166
|
Unknown = 0,
|
|
@@ -140,6 +173,23 @@ declare enum Codec {
|
|
|
140
173
|
/** OPUS编码 */
|
|
141
174
|
OPUS = 1398100047
|
|
142
175
|
}
|
|
176
|
+
declare function dateFormat(format: string, date?: Date): string;
|
|
177
|
+
declare function dct(t: string): any;
|
|
178
|
+
declare function genNonce(len?: number): string;
|
|
179
|
+
declare function getHostnameFromUrl(url: string): string;
|
|
180
|
+
declare function isObject(value: any): boolean;
|
|
181
|
+
declare function isString(value: any): boolean;
|
|
182
|
+
declare function isWxxcx(): boolean;
|
|
183
|
+
declare function propAssign<T>(target: T, income: T, assigner?: Record<keyof T, (value: any, old: any) => void>): PropChangeItem<keyof T>[];
|
|
184
|
+
declare function retry<T>(f: () => Promise<T>, opt: {
|
|
185
|
+
/** 首次执行失败后的最大重试次数,默认10次,<=0代表不限制次数 */
|
|
186
|
+
maxRetries?: number;
|
|
187
|
+
/** 第一次重试间隔(ms),默认500ms,之后会以 initialDelay * 2^n 进行重试 */
|
|
188
|
+
initialDelay?: number;
|
|
189
|
+
/** 每次重试前的回调,返回false则代表放弃重试,会返回canceled */
|
|
190
|
+
onRetry?: (attempt: number) => boolean | void;
|
|
191
|
+
}): retryCallback<T>;
|
|
192
|
+
declare function sleep(ms: number): Promise<void>;
|
|
143
193
|
/** 频道事件通知 */
|
|
144
194
|
export declare class ChannelEvent {
|
|
145
195
|
/** 事件类型 */
|
|
@@ -310,7 +360,9 @@ export declare class SRTC extends BaseSRTC {
|
|
|
310
360
|
* @returns
|
|
311
361
|
*/
|
|
312
362
|
getEnvInfo(): EnvWebInfo;
|
|
313
|
-
|
|
363
|
+
protected getStoredDeviceId(): string;
|
|
364
|
+
protected getDeviceType(): DeviceType;
|
|
365
|
+
constructor(initParams: SdkInitParams);
|
|
314
366
|
leave(): Promise<void>;
|
|
315
367
|
/**
|
|
316
368
|
* 获取设备列表
|
|
@@ -492,6 +544,23 @@ export declare enum TrackKind {
|
|
|
492
544
|
Video = "video",
|
|
493
545
|
Audio = "audio"
|
|
494
546
|
}
|
|
547
|
+
export declare namespace __INNER__ {
|
|
548
|
+
const BaseSRTC_I: typeof BaseSRTC;
|
|
549
|
+
const CommonChannelEventType_I: typeof CommonChannelEventType;
|
|
550
|
+
const isWxxcx_I: typeof isWxxcx;
|
|
551
|
+
const Logger_I: typeof Logger;
|
|
552
|
+
const SdkError_I: typeof SdkError;
|
|
553
|
+
const propAssign_I: typeof propAssign;
|
|
554
|
+
const isObject_I: typeof isObject;
|
|
555
|
+
const isString_I: typeof isString;
|
|
556
|
+
const sleep_I: typeof sleep;
|
|
557
|
+
const retry_I: typeof retry;
|
|
558
|
+
const dateFormat_I: typeof dateFormat;
|
|
559
|
+
const genNonce_I: typeof genNonce;
|
|
560
|
+
const getHostnameFromUrl_I: typeof getHostnameFromUrl;
|
|
561
|
+
const dct_I: typeof dct;
|
|
562
|
+
function hmac_I(msg: string, key: string): string;
|
|
563
|
+
}
|
|
495
564
|
/**
|
|
496
565
|
* 扬声器配置
|
|
497
566
|
*/
|
|
@@ -588,6 +657,8 @@ export interface CustomMsgData {
|
|
|
588
657
|
uid: string;
|
|
589
658
|
/** 频道名(如果非频道内自定义消息,为空) */
|
|
590
659
|
channel: string;
|
|
660
|
+
/** 是否私发 */
|
|
661
|
+
private: boolean;
|
|
591
662
|
}
|
|
592
663
|
/**
|
|
593
664
|
* 强制离开事件data
|
|
@@ -683,13 +754,6 @@ export interface EnvWebInfo extends Bowser$1.Parser.ParsedResult {
|
|
|
683
754
|
*/
|
|
684
755
|
devicePixelRatio: number;
|
|
685
756
|
}
|
|
686
|
-
/**
|
|
687
|
-
* 微信小程序环境详情
|
|
688
|
-
*/
|
|
689
|
-
export interface EnvWxInfo {
|
|
690
|
-
system: WechatMiniprogram.SystemInfo;
|
|
691
|
-
device: WechatMiniprogram.DeviceInfo;
|
|
692
|
-
}
|
|
693
757
|
/**
|
|
694
758
|
* 加入频道选项
|
|
695
759
|
*/
|
|
@@ -744,13 +808,15 @@ export interface MicPreset {
|
|
|
744
808
|
publish: AudioPublishOptions;
|
|
745
809
|
}
|
|
746
810
|
/**
|
|
747
|
-
*
|
|
811
|
+
* 属性更改项
|
|
748
812
|
*/
|
|
749
|
-
export interface
|
|
750
|
-
/**
|
|
751
|
-
|
|
752
|
-
/**
|
|
753
|
-
|
|
813
|
+
export interface PropChangeItem<T> {
|
|
814
|
+
/** 属性名 */
|
|
815
|
+
prop: T;
|
|
816
|
+
/** 更改后的值 */
|
|
817
|
+
value: any;
|
|
818
|
+
/** 更改前的值 */
|
|
819
|
+
old: any;
|
|
754
820
|
}
|
|
755
821
|
/**
|
|
756
822
|
* 屏幕采集配置
|
|
@@ -789,6 +855,15 @@ export interface ScreenPreset {
|
|
|
789
855
|
capture: ScreenCaptureOptions;
|
|
790
856
|
publish: VideoPublishOptions;
|
|
791
857
|
}
|
|
858
|
+
/**
|
|
859
|
+
* sdk构造参数
|
|
860
|
+
*/
|
|
861
|
+
export interface SdkInitParams {
|
|
862
|
+
/** 日志等级 */
|
|
863
|
+
logLevel?: LogLevel;
|
|
864
|
+
/** 日志目标 */
|
|
865
|
+
logTarget?: LogTarget;
|
|
866
|
+
}
|
|
792
867
|
/**
|
|
793
868
|
* 用户离开事件data
|
|
794
869
|
*/
|
|
@@ -826,6 +901,12 @@ export interface VideoPublishOptions {
|
|
|
826
901
|
props?: Record<string, any>;
|
|
827
902
|
simulcasts?: VideoPublishOptions[];
|
|
828
903
|
}
|
|
904
|
+
/**
|
|
905
|
+
* 重试执行器函数:直接调用开始执行,.cancel()取消重试,函数失败会返回maxretry或canceled
|
|
906
|
+
*/
|
|
907
|
+
export type retryCallback<T> = (() => Promise<T>) & {
|
|
908
|
+
cancel: () => void;
|
|
909
|
+
};
|
|
829
910
|
/**
|
|
830
911
|
* 频道信息
|
|
831
912
|
*/
|
package/srtc.d.ts
CHANGED
|
@@ -10,12 +10,16 @@ declare abstract class BaseSRTC {
|
|
|
10
10
|
* 获取运行环境信息
|
|
11
11
|
* @returns
|
|
12
12
|
*/
|
|
13
|
-
getEnvInfo():
|
|
13
|
+
getEnvInfo(): any;
|
|
14
14
|
/**
|
|
15
15
|
* 频道事件通知回调
|
|
16
16
|
*/
|
|
17
17
|
onNotifyChannelEvent?: ((event: ChannelEvent) => void) | null;
|
|
18
|
-
constructor(initParams:
|
|
18
|
+
constructor(initParams: SdkInitParams);
|
|
19
|
+
/**
|
|
20
|
+
* 加入频道的version信息
|
|
21
|
+
*/
|
|
22
|
+
protected get joinVersion(): string;
|
|
19
23
|
/**
|
|
20
24
|
* 加入频道
|
|
21
25
|
* @param token 加入频道token
|
|
@@ -128,6 +132,35 @@ declare class CommonChannelEventType {
|
|
|
128
132
|
/** 流轨道停止,对应data为BaseTrack */
|
|
129
133
|
static readonly TRACK_ENDED = "track_ended";
|
|
130
134
|
}
|
|
135
|
+
declare class Logger {
|
|
136
|
+
constructor(dp?: string, dclt?: string);
|
|
137
|
+
setTarget(target: LogTarget): void;
|
|
138
|
+
setLevel(level: LogLevel): void;
|
|
139
|
+
debug(...args: any[]): void;
|
|
140
|
+
info(...args: any[]): void;
|
|
141
|
+
warn(...args: any[]): void;
|
|
142
|
+
error(...args: any[]): void;
|
|
143
|
+
}
|
|
144
|
+
declare class SdkError {
|
|
145
|
+
/** 错误码 */
|
|
146
|
+
code: number;
|
|
147
|
+
/** 错误详情 */
|
|
148
|
+
msg: string;
|
|
149
|
+
/** 获取前缀错误码 */
|
|
150
|
+
protected prefixCode(): string;
|
|
151
|
+
constructor(msg: string, code?: number);
|
|
152
|
+
/**
|
|
153
|
+
* 从err转化为sdkError
|
|
154
|
+
* @param err 原始error
|
|
155
|
+
* @returns
|
|
156
|
+
*/
|
|
157
|
+
static fromError(err: Error): SdkError;
|
|
158
|
+
toString(): string;
|
|
159
|
+
toJSON(): {
|
|
160
|
+
code: number;
|
|
161
|
+
msg: string;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
131
164
|
declare enum Codec {
|
|
132
165
|
/** 未知编码类型 */
|
|
133
166
|
Unknown = 0,
|
|
@@ -140,6 +173,23 @@ declare enum Codec {
|
|
|
140
173
|
/** OPUS编码 */
|
|
141
174
|
OPUS = 1398100047
|
|
142
175
|
}
|
|
176
|
+
declare function dateFormat(format: string, date?: Date): string;
|
|
177
|
+
declare function dct(t: string): any;
|
|
178
|
+
declare function genNonce(len?: number): string;
|
|
179
|
+
declare function getHostnameFromUrl(url: string): string;
|
|
180
|
+
declare function isObject(value: any): boolean;
|
|
181
|
+
declare function isString(value: any): boolean;
|
|
182
|
+
declare function isWxxcx(): boolean;
|
|
183
|
+
declare function propAssign<T>(target: T, income: T, assigner?: Record<keyof T, (value: any, old: any) => void>): PropChangeItem<keyof T>[];
|
|
184
|
+
declare function retry<T>(f: () => Promise<T>, opt: {
|
|
185
|
+
/** 首次执行失败后的最大重试次数,默认10次,<=0代表不限制次数 */
|
|
186
|
+
maxRetries?: number;
|
|
187
|
+
/** 第一次重试间隔(ms),默认500ms,之后会以 initialDelay * 2^n 进行重试 */
|
|
188
|
+
initialDelay?: number;
|
|
189
|
+
/** 每次重试前的回调,返回false则代表放弃重试,会返回canceled */
|
|
190
|
+
onRetry?: (attempt: number) => boolean | void;
|
|
191
|
+
}): retryCallback<T>;
|
|
192
|
+
declare function sleep(ms: number): Promise<void>;
|
|
143
193
|
/** 频道事件通知 */
|
|
144
194
|
export declare class ChannelEvent {
|
|
145
195
|
/** 事件类型 */
|
|
@@ -310,7 +360,9 @@ export declare class SRTC extends BaseSRTC {
|
|
|
310
360
|
* @returns
|
|
311
361
|
*/
|
|
312
362
|
getEnvInfo(): EnvWebInfo;
|
|
313
|
-
|
|
363
|
+
protected getStoredDeviceId(): string;
|
|
364
|
+
protected getDeviceType(): DeviceType;
|
|
365
|
+
constructor(initParams: SdkInitParams);
|
|
314
366
|
leave(): Promise<void>;
|
|
315
367
|
/**
|
|
316
368
|
* 获取设备列表
|
|
@@ -492,6 +544,23 @@ export declare enum TrackKind {
|
|
|
492
544
|
Video = "video",
|
|
493
545
|
Audio = "audio"
|
|
494
546
|
}
|
|
547
|
+
export declare namespace __INNER__ {
|
|
548
|
+
const BaseSRTC_I: typeof BaseSRTC;
|
|
549
|
+
const CommonChannelEventType_I: typeof CommonChannelEventType;
|
|
550
|
+
const isWxxcx_I: typeof isWxxcx;
|
|
551
|
+
const Logger_I: typeof Logger;
|
|
552
|
+
const SdkError_I: typeof SdkError;
|
|
553
|
+
const propAssign_I: typeof propAssign;
|
|
554
|
+
const isObject_I: typeof isObject;
|
|
555
|
+
const isString_I: typeof isString;
|
|
556
|
+
const sleep_I: typeof sleep;
|
|
557
|
+
const retry_I: typeof retry;
|
|
558
|
+
const dateFormat_I: typeof dateFormat;
|
|
559
|
+
const genNonce_I: typeof genNonce;
|
|
560
|
+
const getHostnameFromUrl_I: typeof getHostnameFromUrl;
|
|
561
|
+
const dct_I: typeof dct;
|
|
562
|
+
function hmac_I(msg: string, key: string): string;
|
|
563
|
+
}
|
|
495
564
|
/**
|
|
496
565
|
* 扬声器配置
|
|
497
566
|
*/
|
|
@@ -588,6 +657,8 @@ export interface CustomMsgData {
|
|
|
588
657
|
uid: string;
|
|
589
658
|
/** 频道名(如果非频道内自定义消息,为空) */
|
|
590
659
|
channel: string;
|
|
660
|
+
/** 是否私发 */
|
|
661
|
+
private: boolean;
|
|
591
662
|
}
|
|
592
663
|
/**
|
|
593
664
|
* 强制离开事件data
|
|
@@ -683,13 +754,6 @@ export interface EnvWebInfo extends Bowser$1.Parser.ParsedResult {
|
|
|
683
754
|
*/
|
|
684
755
|
devicePixelRatio: number;
|
|
685
756
|
}
|
|
686
|
-
/**
|
|
687
|
-
* 微信小程序环境详情
|
|
688
|
-
*/
|
|
689
|
-
export interface EnvWxInfo {
|
|
690
|
-
system: WechatMiniprogram.SystemInfo;
|
|
691
|
-
device: WechatMiniprogram.DeviceInfo;
|
|
692
|
-
}
|
|
693
757
|
/**
|
|
694
758
|
* 加入频道选项
|
|
695
759
|
*/
|
|
@@ -744,13 +808,15 @@ export interface MicPreset {
|
|
|
744
808
|
publish: AudioPublishOptions;
|
|
745
809
|
}
|
|
746
810
|
/**
|
|
747
|
-
*
|
|
811
|
+
* 属性更改项
|
|
748
812
|
*/
|
|
749
|
-
export interface
|
|
750
|
-
/**
|
|
751
|
-
|
|
752
|
-
/**
|
|
753
|
-
|
|
813
|
+
export interface PropChangeItem<T> {
|
|
814
|
+
/** 属性名 */
|
|
815
|
+
prop: T;
|
|
816
|
+
/** 更改后的值 */
|
|
817
|
+
value: any;
|
|
818
|
+
/** 更改前的值 */
|
|
819
|
+
old: any;
|
|
754
820
|
}
|
|
755
821
|
/**
|
|
756
822
|
* 屏幕采集配置
|
|
@@ -789,6 +855,15 @@ export interface ScreenPreset {
|
|
|
789
855
|
capture: ScreenCaptureOptions;
|
|
790
856
|
publish: VideoPublishOptions;
|
|
791
857
|
}
|
|
858
|
+
/**
|
|
859
|
+
* sdk构造参数
|
|
860
|
+
*/
|
|
861
|
+
export interface SdkInitParams {
|
|
862
|
+
/** 日志等级 */
|
|
863
|
+
logLevel?: LogLevel;
|
|
864
|
+
/** 日志目标 */
|
|
865
|
+
logTarget?: LogTarget;
|
|
866
|
+
}
|
|
792
867
|
/**
|
|
793
868
|
* 用户离开事件data
|
|
794
869
|
*/
|
|
@@ -826,6 +901,12 @@ export interface VideoPublishOptions {
|
|
|
826
901
|
props?: Record<string, any>;
|
|
827
902
|
simulcasts?: VideoPublishOptions[];
|
|
828
903
|
}
|
|
904
|
+
/**
|
|
905
|
+
* 重试执行器函数:直接调用开始执行,.cancel()取消重试,函数失败会返回maxretry或canceled
|
|
906
|
+
*/
|
|
907
|
+
export type retryCallback<T> = (() => Promise<T>) & {
|
|
908
|
+
cancel: () => void;
|
|
909
|
+
};
|
|
829
910
|
/**
|
|
830
911
|
* 频道信息
|
|
831
912
|
*/
|