@tencentcloud/trtc-cloud-wx 0.0.27 → 0.0.30-beta.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.
Files changed (57) hide show
  1. package/package.json +4 -45
  2. package/{dist/trtc-cloud-wx.js → trtc-cloud-wx.js} +573 -663
  3. package/.babelrc +0 -6
  4. package/.eslintrc.json +0 -129
  5. package/build/chokidar.js +0 -19
  6. package/build/clear.js +0 -24
  7. package/build/copy.js +0 -24
  8. package/build/copy_to_roomkit.js +0 -19
  9. package/dist/package.json +0 -15
  10. package/docs/API/TRTCCloud.html +0 -4353
  11. package/docs/API/index.html +0 -98
  12. package/docs/API/scripts/add-toc.js +0 -57
  13. package/docs/API/scripts/collapse.js +0 -20
  14. package/docs/API/scripts/highlight/highlight.min.js +0 -1282
  15. package/docs/API/scripts/highlight/highlightjs-line-numbers.min.js +0 -1
  16. package/docs/API/scripts/linenumber.js +0 -25
  17. package/docs/API/scripts/nav.js +0 -12
  18. package/docs/API/scripts/polyfill.js +0 -4
  19. package/docs/API/scripts/prettify/Apache-License-2.0.txt +0 -202
  20. package/docs/API/scripts/prettify/lang-css.js +0 -2
  21. package/docs/API/scripts/prettify/prettify.js +0 -28
  22. package/docs/API/scripts/search.js +0 -83
  23. package/docs/API/styles/font.css +0 -81
  24. package/docs/API/styles/fonts/JTURjIg1_i6t8kCHKm45_dJE3g3D_vx3rCubqg.woff2 +0 -0
  25. package/docs/API/styles/fonts/JTURjIg1_i6t8kCHKm45_dJE3gTD_vx3rCubqg.woff2 +0 -0
  26. package/docs/API/styles/fonts/JTURjIg1_i6t8kCHKm45_dJE3gbD_vx3rCubqg.woff2 +0 -0
  27. package/docs/API/styles/fonts/JTURjIg1_i6t8kCHKm45_dJE3gfD_vx3rCubqg.woff2 +0 -0
  28. package/docs/API/styles/fonts/JTURjIg1_i6t8kCHKm45_dJE3gnD_vx3rCs.woff2 +0 -0
  29. package/docs/API/styles/fonts/JTUSjIg1_i6t8kCHKm459W1hyyTh89ZNpQ.woff2 +0 -0
  30. package/docs/API/styles/fonts/JTUSjIg1_i6t8kCHKm459WRhyyTh89ZNpQ.woff2 +0 -0
  31. package/docs/API/styles/fonts/JTUSjIg1_i6t8kCHKm459WZhyyTh89ZNpQ.woff2 +0 -0
  32. package/docs/API/styles/fonts/JTUSjIg1_i6t8kCHKm459WdhyyTh89ZNpQ.woff2 +0 -0
  33. package/docs/API/styles/fonts/JTUSjIg1_i6t8kCHKm459WlhyyTh89Y.woff2 +0 -0
  34. package/docs/API/styles/highlight/highlight.min.css +0 -26
  35. package/docs/API/styles/highlight/rainbow.min.css +0 -1
  36. package/docs/API/styles/jsdoc.css +0 -684
  37. package/docs/API/styles/prettify.css +0 -79
  38. package/docs/API/styles/toc.css +0 -44
  39. package/docs/API/tutorial-00-guideline.html +0 -81
  40. package/docs/doc-src/home.md +0 -7
  41. package/docs/doc-src/tutorials/00-guideline.md +0 -1
  42. package/docs/doc-src/tutorials/tutorials.json +0 -5
  43. package/jsdoc.json +0 -43
  44. package/rollup.config.js +0 -19
  45. package/sdk_publish.bash +0 -5
  46. package/src/TaskMachine.ts +0 -368
  47. package/src/deviceAuthorize.ts +0 -75
  48. package/src/index.ts +0 -1091
  49. package/src/interface/index.ts +0 -44
  50. package/src/interface/types.ts +0 -88
  51. package/src/log/logger.ts +0 -103
  52. package/src/types.d.ts +0 -1
  53. package/src/utils/common.ts +0 -67
  54. package/src/utils/index.ts +0 -2
  55. package/src/utils/translate.ts +0 -125
  56. package/tsconfig.json +0 -15
  57. package/typedoc.json +0 -21
@@ -1,44 +0,0 @@
1
- import {
2
- TRTCRoleType,
3
- TRTCVideoFillMode,
4
- TRTCVideoMirrorType,
5
- TRTCVideoResolution,
6
- TRTCVideoResolutionMode,
7
- TRTCVideoRotation,
8
- } from './types'
9
-
10
- export interface TRTCParams {
11
- sdkAppId: number;
12
- userId: string;
13
- userSig: string;
14
- roomId: number;
15
- strRoomId?: string;
16
- role: TRTCRoleType;
17
- privateMapKey?: string;
18
- }
19
-
20
- export interface TRTCVideoEncParam {
21
- videoResolution: TRTCVideoResolution;
22
- resMode: TRTCVideoResolutionMode;
23
- videoFps: number;
24
- videoBitrate: number;
25
- minVideoBitrate: number;
26
- }
27
-
28
- export interface TRTCRenderParams {
29
- rotation: TRTCVideoRotation;
30
- fillMode: TRTCVideoFillMode;
31
- mirrorType: TRTCVideoMirrorType;
32
- }
33
-
34
- export interface TRTCVolumeInfo {
35
- userId: string;
36
- volume: number;
37
- }
38
-
39
- export interface AudioMusicParam {
40
- path: string;
41
- startTimeMS: number;
42
- endTimeMS: number;
43
- }
44
- export * from './types'
@@ -1,88 +0,0 @@
1
- export enum TRTCAppScene {
2
- // web
3
- // TRTCAppSceneVideoCall = 0,
4
- // TRTCAppSceneLIVE = 1,
5
- // TRTCAppSceneAudioCall = 2,
6
- // TRTCAppSceneVoiceChatRoom = 3,
7
-
8
- // miniprogram
9
- // TRTCAppSceneVideoCall = 'videocall',
10
- // TRTCAppSceneLIVE = 'live',
11
- // TRTCAppSceneAudioCall = 'audiocall',
12
- // TRTCAppSceneVoiceChatRoom = 'voicechatroom',
13
- TRTCAppSceneVideoCall = 0,
14
- TRTCAppSceneLIVE = 1, // live
15
- TRTCAppSceneAudioCall = 2,
16
- TRTCAppSceneVoiceChatRoom = 3,
17
- }
18
-
19
- export enum TRTCRoleType {
20
- TRTCRoleAnchor = 20,
21
- TRTCRoleAudience = 21,
22
- }
23
-
24
- export enum TRTCVideoStreamType {
25
- TRTCVideoStreamTypeBig = 0,
26
- TRTCVideoStreamTypeSmall = 1,
27
- TRTCVideoStreamTypeSub = 2, // aux
28
- }
29
-
30
- export enum TRTCVideoResolution {
31
- TRTCVideoResolution_120_120 = 1,
32
- TRTCVideoResolution_160_160 = 3,
33
- TRTCVideoResolution_270_270 = 5,
34
- TRTCVideoResolution_480_480 = 7,
35
- TRTCVideoResolution_160_120 = 50,
36
- TRTCVideoResolution_240_180 = 52,
37
- TRTCVideoResolution_280_210 = 54,
38
- TRTCVideoResolution_320_240 = 56,
39
- TRTCVideoResolution_400_300 = 58,
40
- TRTCVideoResolution_480_360 = 60,
41
- TRTCVideoResolution_640_480 = 62,
42
- TRTCVideoResolution_960_720 = 64,
43
- TRTCVideoResolution_160_90 = 100,
44
- TRTCVideoResolution_256_144 = 102,
45
- TRTCVideoResolution_320_180 = 104,
46
- TRTCVideoResolution_480_270 = 106,
47
- TRTCVideoResolution_640_360 = 108,
48
- TRTCVideoResolution_960_540 = 110,
49
- TRTCVideoResolution_1280_720 = 112,
50
- TRTCVideoResolution_1920_1080 = 114,
51
- }
52
-
53
- export enum TRTCVideoResolutionMode {
54
- TRTCVideoResolutionModeLandscape = 0,
55
- TRTCVideoResolutionModePortrait = 1,
56
- }
57
-
58
- export enum TRTCVideoRotation {
59
- TRTCVideoRotation0 = 0,
60
- TRTCVideoRotation90 = 1,
61
- TRTCVideoRotation180 = 2,
62
- TRTCVideoRotation270 = 3,
63
- }
64
-
65
- export enum TRTCVideoFillMode {
66
- TRTCVideoFillMode_Fill = 0,
67
- TRTCVideoFillMode_Fit = 1,
68
- }
69
-
70
- export enum TRTCVideoMirrorType {
71
- TRTCVideoMirrorType_Auto = 0,
72
- TRTCVideoMirrorType_Enable = 1,
73
- TRTCVideoMirrorType_Disable = 2,
74
- }
75
-
76
- export enum TRTCAudioQuality {
77
- /** 语音模式:采样率:16k;单声道;音频裸码率:16kbps;适合语音通话为主的场景,比如在线会议,语音通话。 */
78
- TRTCAudioQualitySpeech = 1,
79
- /** 标准模式(或者默认模式):采样率:48k;单声道;音频裸码率:50kbps;SDK 默认的音频质量,如无特殊需求推荐选择之。 */
80
- TRTCAudioQualityDefault = 2,
81
- /** 音乐模式:采样率:48k;双声道 + 全频带;音频裸码率:128kbps;适合需要高保真传输音乐的场景,比如K歌、音乐直播等。 */
82
- TRTCAudioQualityMusic = 3,
83
- }
84
-
85
- export enum TRTCBeautyStyle {
86
- TRTCBeautyStyleSmooth = 0,
87
- TRTCBeautyStyleNature = 1,
88
- }
package/src/log/logger.ts DELETED
@@ -1,103 +0,0 @@
1
- import Aegis from 'aegis-mp-sdk'
2
- import {formatTime} from '../utils/common'
3
-
4
-
5
- const aegis = new Aegis({
6
- id: 'iHWefAYqxoRsFYGQvR', // 项目ID,即上报id
7
- })
8
-
9
-
10
- const LOGLEVEL = {
11
- LOG: 0,
12
- INFO: 1,
13
- DEBUG: 2,
14
- WARN: 3,
15
- ERROR: 4, // 无日志记录级别,sdk将不打印任何日志
16
- NON_LOGGING: 5, // 无日志记录级别,sdk将不打印任何日志
17
- }
18
- export class Logger {
19
- private logLevel = 0
20
-
21
- private sdkAppId
22
-
23
- private userId
24
-
25
- private roomId
26
-
27
- private TAG_NAME = ''
28
-
29
- constructor(tagName?: string) {
30
- this.TAG_NAME = tagName || '[TRTCCloud-WX]'
31
- }
32
-
33
- private loggerInfo(...args: any): void {
34
- if (Number(this.sdkAppId) !== 1400188366 && Number(this.sdkAppId) !== 1400704311) return
35
- aegis.infoAll({
36
- msg: `sdkAppId=${this.sdkAppId}、roomId=${this.roomId}、userId=${this.userId}
37
- ${String(args)}`,
38
- ext1: this.sdkAppId,
39
- ext2: this.roomId,
40
- ext3: this.userId
41
- })
42
- }
43
-
44
- setInfo(params: {
45
- sdkAppId: number | string;
46
- userId: string;
47
- roomId: string | number;
48
- }): void {
49
- const {sdkAppId, userId, roomId} = params
50
- this.sdkAppId = sdkAppId
51
- this.userId = userId
52
- this.roomId = roomId
53
- }
54
-
55
- setLogLevel(level: number): void {
56
- this.logLevel = level
57
- }
58
-
59
- // 打印普通日志
60
- log(...args: any): void {
61
- if (this.logLevel === LOGLEVEL.LOG) {
62
- console.log(this.TAG_NAME, formatTime(), ...args)
63
- this.loggerInfo(this.TAG_NAME, formatTime(), ...args)
64
- }
65
- }
66
-
67
- info(...args: any): void {
68
- if (this.logLevel <= LOGLEVEL.INFO) {
69
- console.info(this.TAG_NAME, formatTime(), ...args)
70
- this.loggerInfo(this.TAG_NAME, formatTime(), ...args)
71
- }
72
- }
73
-
74
- // 打印告警日志
75
- warn(...args: any): void {
76
- // SDK 上报的相关事件
77
- if (this.logLevel <= LOGLEVEL.WARN) {
78
- console.warn(this.TAG_NAME, formatTime(), ...args)
79
- this.loggerInfo(this.TAG_NAME, formatTime(), ...args)
80
- }
81
- }
82
-
83
- // 打印错误日志
84
- error(...args: any): void {
85
- // 状态机内部错误信息
86
- if (this.logLevel <= LOGLEVEL.ERROR) {
87
- console.error(this.TAG_NAME, formatTime(), ...args)
88
- this.loggerInfo(this.TAG_NAME, formatTime(), ...args)
89
- }
90
- }
91
-
92
- debug(...args: any): void {
93
- // 状态机内部错误信息
94
- if (this.logLevel <= LOGLEVEL.DEBUG) {
95
- console.debug(this.TAG_NAME, formatTime(), ...args)
96
- this.loggerInfo(this.TAG_NAME, formatTime(), ...args)
97
- }
98
- }
99
- }
100
-
101
- export const logger = new Logger()
102
-
103
- export default logger
package/src/types.d.ts DELETED
@@ -1 +0,0 @@
1
- declare const wx: any
@@ -1,67 +0,0 @@
1
- export const uniqueFunc = (arr, uniId) => {
2
- const res = new Map()
3
- return arr.filter((item) => !res.has(item[uniId]) && res.set(item[uniId], 1))
4
- }
5
-
6
- export const isFunction = (param: any) => typeof param === 'function'
7
- export const isUndefined = (param: any) => typeof param === 'undefined'
8
- export const isString = (param: any) => typeof param === 'string'
9
- export const isNumber = (param: any) => typeof param === 'number'
10
- export const isBoolean = (param: any) => typeof param === 'boolean'
11
-
12
- /**
13
- * 安全执行 JSON.parse
14
- * @param data
15
- * @returns
16
- */
17
- export function safelyParse(data: string) {
18
- if (typeof data !== 'string') {
19
- return data
20
- }
21
- let result
22
- try {
23
- const tempData = JSON.parse(data)
24
- // 规避 JSON.parse('12345') 转化为 12345 的情况
25
- if (typeof tempData === 'object' && tempData) {
26
- result = tempData
27
- } else {
28
- result = data
29
- }
30
- } catch (error) {
31
- result = data
32
- }
33
- return result
34
- }
35
-
36
- export const formatTime = (): string => {
37
- const timestamp = new Date().getTime()
38
- const date = new Date(timestamp)
39
- // const year = date.getFullYear()
40
- // const month = date.getMonth() + 1
41
- // const day = date.getDate()
42
- let hour = date.getHours() as any
43
- let minute = date.getMinutes() as any
44
- let second = date.getSeconds() as any
45
- const millisecond = date.getMilliseconds()
46
- hour = hour < 10 ? `0${hour}` : hour
47
- minute = minute < 10 ? `0${minute}` : minute
48
- second = second < 10 ? `0${second}` : second
49
- return `${hour}:${minute}:${second}.${millisecond}`
50
- }
51
-
52
- export function debounce(func: (...args: any[]) => void, wait: number): (...args: any[]) => void {
53
- let timeout: ReturnType<typeof setTimeout> | null = null
54
-
55
- return (...args: any[]) => {
56
- // 清除上一次的定时器
57
- if (timeout) {
58
- clearTimeout(timeout)
59
- }
60
-
61
- // 设置一个新的定时器,在 wait 毫秒后执行原函数
62
- timeout = setTimeout(() => {
63
- func(...args)
64
- timeout = null
65
- }, wait)
66
- }
67
- }
@@ -1,2 +0,0 @@
1
- export * from './translate'
2
- export * from './common'
@@ -1,125 +0,0 @@
1
- import {
2
- TRTCAppScene,
3
- TRTCBeautyStyle,
4
- TRTCVideoFillMode,
5
- TRTCVideoMirrorType,
6
- TRTCVideoResolution,
7
- TRTCVideoResolutionMode,
8
- TRTCVideoRotation,
9
- TRTCVideoStreamType,
10
- } from '../interface'
11
-
12
- export const translateTRTCAppScene = (scene: TRTCAppScene): string => {
13
- switch (scene) {
14
- case 0:
15
- return 'videocall'
16
- case 1:
17
- return 'live'
18
- case 2:
19
- return 'audiocall'
20
- case 3:
21
- return 'voicechatroom'
22
- default:
23
- return ''
24
- }
25
- }
26
-
27
- export const translateTRTCVideoStreamType = (
28
- streamType: TRTCVideoStreamType
29
- ): string => {
30
- switch (streamType) {
31
- case 0:
32
- return 'main'
33
- case 1:
34
- return 'small'
35
- case 2:
36
- return 'aux'
37
- default:
38
- return ''
39
- }
40
- }
41
-
42
- export const translateTRTCStreamId = (
43
- userId: string,
44
- streamType: TRTCVideoStreamType
45
- ): string => `${userId}_${translateTRTCVideoStreamType(streamType)}`
46
-
47
- const TRTCVideoResolutionMap = {
48
- [TRTCVideoResolution.TRTCVideoResolution_120_120]: [120, 120],
49
- [TRTCVideoResolution.TRTCVideoResolution_160_160]: [160, 160],
50
- [TRTCVideoResolution.TRTCVideoResolution_270_270]: [270, 270],
51
- [TRTCVideoResolution.TRTCVideoResolution_480_480]: [480, 480],
52
- [TRTCVideoResolution.TRTCVideoResolution_160_120]: [160, 120],
53
- [TRTCVideoResolution.TRTCVideoResolution_240_180]: [240, 180],
54
- [TRTCVideoResolution.TRTCVideoResolution_280_210]: [280, 210],
55
- [TRTCVideoResolution.TRTCVideoResolution_320_240]: [320, 240],
56
- [TRTCVideoResolution.TRTCVideoResolution_400_300]: [400, 300],
57
- [TRTCVideoResolution.TRTCVideoResolution_480_360]: [480, 360],
58
- [TRTCVideoResolution.TRTCVideoResolution_640_480]: [640, 480],
59
- [TRTCVideoResolution.TRTCVideoResolution_960_720]: [960, 720],
60
- [TRTCVideoResolution.TRTCVideoResolution_160_90]: [160, 90],
61
- [TRTCVideoResolution.TRTCVideoResolution_256_144]: [256, 144],
62
- [TRTCVideoResolution.TRTCVideoResolution_320_180]: [320, 180],
63
- [TRTCVideoResolution.TRTCVideoResolution_480_270]: [480, 270],
64
- [TRTCVideoResolution.TRTCVideoResolution_640_360]: [640, 360],
65
- [TRTCVideoResolution.TRTCVideoResolution_960_540]: [960, 540],
66
- [TRTCVideoResolution.TRTCVideoResolution_1280_720]: [1280, 720],
67
- [TRTCVideoResolution.TRTCVideoResolution_1920_1080]: [1920, 1080],
68
- }
69
- export const translateTRTCVideoResolution = (
70
- resolution: TRTCVideoResolution
71
- ): Record<'videoWidth' | 'videoHeight', number> => {
72
- const [videoWidth = 0, videoHeight = 0] = TRTCVideoResolutionMap[resolution]
73
- return {videoWidth, videoHeight}
74
- }
75
-
76
- export const translateTRTCVideoResolutionMode = (
77
- resolutionMode: TRTCVideoResolutionMode
78
- ): string => {
79
- switch (resolutionMode) {
80
- case TRTCVideoResolutionMode.TRTCVideoResolutionModeLandscape:
81
- return 'horizontal'
82
- case TRTCVideoResolutionMode.TRTCVideoResolutionModePortrait:
83
- return 'vertical'
84
- default:
85
- return ''
86
- }
87
- }
88
-
89
- export const translateTRTCVideoRotation = (rotation: TRTCVideoRotation): string => {
90
- switch (rotation) {
91
- case TRTCVideoRotation.TRTCVideoRotation0:
92
- return 'vertical'
93
- case TRTCVideoRotation.TRTCVideoRotation90:
94
- return 'horizontal'
95
- default:
96
- return ''
97
- }
98
- }
99
-
100
- export const translateTRTCVideoMirrorType = (
101
- mirrorType: TRTCVideoMirrorType
102
- ): string => {
103
- switch (mirrorType) {
104
- case TRTCVideoMirrorType.TRTCVideoMirrorType_Auto:
105
- return 'auto'
106
- case TRTCVideoMirrorType.TRTCVideoMirrorType_Enable:
107
- return 'enable'
108
- case TRTCVideoMirrorType.TRTCVideoMirrorType_Disable:
109
- return 'disable'
110
- default:
111
- return ''
112
- }
113
- }
114
-
115
- const TRTCBeautyStyleMap = {
116
- [TRTCBeautyStyle.TRTCBeautyStyleSmooth]: 'smooth',
117
- [TRTCBeautyStyle.TRTCBeautyStyleNature]: 'nature'
118
- }
119
- export const translateBeautyStyle = (beautyStyle: TRTCBeautyStyle): string => TRTCBeautyStyleMap[beautyStyle]
120
-
121
- const TRTCVideoFillModeMap = {
122
- [TRTCVideoFillMode.TRTCVideoFillMode_Fill]: 'fillCrop',
123
- [TRTCVideoFillMode.TRTCVideoFillMode_Fit]: 'contain'
124
- }
125
- export const translateVideoFillMod = (videoFillMod: TRTCVideoFillMode): string => TRTCVideoFillModeMap[videoFillMod]
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2015",
4
- "esModuleInterop": true,
5
- "allowSyntheticDefaultImports": true,
6
- "moduleResolution": "node",
7
- "lib": ["dom", "ES2015", "ES2015.Promise"],
8
- "resolveJsonModule": true,
9
- "experimentalDecorators": true
10
- },
11
- "include": [
12
- "src"
13
- ],
14
- "exclude": ["node_moudles"]
15
- }
package/typedoc.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- // 输入选项 - 入口文件/文件夹
3
- "entryPoints": [
4
- "src/index.ts"
5
- ],
6
- // 输入选项 - 排除文件/文件夹
7
- "exclude": [
8
- "node_moudles",
9
- ],
10
- "tsconfig": "./tsconfig.json",
11
- "entryPointStrategy": "expand",
12
- // 输出选项 - 将软件包package.json中的版本version添加到项目名称中
13
- "includeVersion": true,
14
- // 输出选项 - 设置将在模板标题中使用的项目的名称。默认为package.json中的name
15
- "name": "TRTCCloud",
16
- // 输出选项 - 不在页面末尾打印TypeDoc链接
17
- "hideGenerator": true,
18
- // 输出选项 - 禁用描述代码位置
19
- "disableSources": true,
20
- "categoryOrder": ["Base", "房间", "视频", "*"]
21
- }