@tencentcloud/trtc-cloud-wx 0.0.28 → 0.0.30-beta.1
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 +4 -45
- package/{dist/trtc-cloud-wx.js → trtc-cloud-wx.js} +573 -663
- package/.babelrc +0 -6
- package/.eslintrc.json +0 -129
- package/build/chokidar.js +0 -19
- package/build/clear.js +0 -24
- package/build/copy.js +0 -24
- package/build/copy_to_roomkit.js +0 -19
- package/dist/package.json +0 -15
- package/docs/API/TRTCCloud.html +0 -4353
- package/docs/API/index.html +0 -98
- package/docs/API/scripts/add-toc.js +0 -57
- package/docs/API/scripts/collapse.js +0 -20
- package/docs/API/scripts/highlight/highlight.min.js +0 -1282
- package/docs/API/scripts/highlight/highlightjs-line-numbers.min.js +0 -1
- package/docs/API/scripts/linenumber.js +0 -25
- package/docs/API/scripts/nav.js +0 -12
- package/docs/API/scripts/polyfill.js +0 -4
- package/docs/API/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/API/scripts/prettify/lang-css.js +0 -2
- package/docs/API/scripts/prettify/prettify.js +0 -28
- package/docs/API/scripts/search.js +0 -83
- package/docs/API/styles/font.css +0 -81
- package/docs/API/styles/fonts/JTURjIg1_i6t8kCHKm45_dJE3g3D_vx3rCubqg.woff2 +0 -0
- package/docs/API/styles/fonts/JTURjIg1_i6t8kCHKm45_dJE3gTD_vx3rCubqg.woff2 +0 -0
- package/docs/API/styles/fonts/JTURjIg1_i6t8kCHKm45_dJE3gbD_vx3rCubqg.woff2 +0 -0
- package/docs/API/styles/fonts/JTURjIg1_i6t8kCHKm45_dJE3gfD_vx3rCubqg.woff2 +0 -0
- package/docs/API/styles/fonts/JTURjIg1_i6t8kCHKm45_dJE3gnD_vx3rCs.woff2 +0 -0
- package/docs/API/styles/fonts/JTUSjIg1_i6t8kCHKm459W1hyyTh89ZNpQ.woff2 +0 -0
- package/docs/API/styles/fonts/JTUSjIg1_i6t8kCHKm459WRhyyTh89ZNpQ.woff2 +0 -0
- package/docs/API/styles/fonts/JTUSjIg1_i6t8kCHKm459WZhyyTh89ZNpQ.woff2 +0 -0
- package/docs/API/styles/fonts/JTUSjIg1_i6t8kCHKm459WdhyyTh89ZNpQ.woff2 +0 -0
- package/docs/API/styles/fonts/JTUSjIg1_i6t8kCHKm459WlhyyTh89Y.woff2 +0 -0
- package/docs/API/styles/highlight/highlight.min.css +0 -26
- package/docs/API/styles/highlight/rainbow.min.css +0 -1
- package/docs/API/styles/jsdoc.css +0 -684
- package/docs/API/styles/prettify.css +0 -79
- package/docs/API/styles/toc.css +0 -44
- package/docs/API/tutorial-00-guideline.html +0 -81
- package/docs/doc-src/home.md +0 -7
- package/docs/doc-src/tutorials/00-guideline.md +0 -1
- package/docs/doc-src/tutorials/tutorials.json +0 -5
- package/jsdoc.json +0 -43
- package/rollup.config.js +0 -19
- package/sdk_publish.bash +0 -5
- package/src/TaskMachine.ts +0 -368
- package/src/deviceAuthorize.ts +0 -75
- package/src/index.ts +0 -1091
- package/src/interface/index.ts +0 -44
- package/src/interface/types.ts +0 -88
- package/src/log/logger.ts +0 -103
- package/src/types.d.ts +0 -1
- package/src/utils/common.ts +0 -67
- package/src/utils/index.ts +0 -2
- package/src/utils/translate.ts +0 -125
- package/tsconfig.json +0 -15
- package/typedoc.json +0 -21
package/src/deviceAuthorize.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {debounce} from './utils'
|
|
2
|
-
|
|
3
|
-
export enum DeviceScope {
|
|
4
|
-
RECORD = 'scope.record',
|
|
5
|
-
CAMERA = 'scope.camera'
|
|
6
|
-
}
|
|
7
|
-
export enum DeviceType {
|
|
8
|
-
MIC = 'mic',
|
|
9
|
-
CAMERA = 'camera'
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 获取设备权限,查看当前是否有麦克风以及摄像头权限
|
|
13
|
-
* @param {Object} params - 参数对象
|
|
14
|
-
* @param {Boolean} params.microphone 麦克风权限
|
|
15
|
-
* @param {Boolean} params.camera 摄像头权限
|
|
16
|
-
*/
|
|
17
|
-
async function deviceCheck(types: Array<DeviceType>): Promise<boolean> {
|
|
18
|
-
if (!types) return false
|
|
19
|
-
const microphone = types.includes(DeviceType.MIC)
|
|
20
|
-
const camera = types.includes(DeviceType.CAMERA)
|
|
21
|
-
try {
|
|
22
|
-
const res = await wx.getSetting()
|
|
23
|
-
const isMicrophone = res.authSetting[DeviceScope.RECORD]
|
|
24
|
-
const isCamera = res.authSetting[DeviceScope.CAMERA]
|
|
25
|
-
// 同时检查麦克风和摄像头权限
|
|
26
|
-
if (microphone && camera) {
|
|
27
|
-
return isMicrophone && isCamera
|
|
28
|
-
}
|
|
29
|
-
// 只检查麦克风权限
|
|
30
|
-
if (microphone) {
|
|
31
|
-
return isMicrophone
|
|
32
|
-
}
|
|
33
|
-
// 只检查摄像头权限
|
|
34
|
-
if (camera) {
|
|
35
|
-
return isCamera
|
|
36
|
-
}
|
|
37
|
-
return false
|
|
38
|
-
} catch (error) {
|
|
39
|
-
return false
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
function permissionPopup(): void {
|
|
45
|
-
wx.showModal({
|
|
46
|
-
title: '设备授权',
|
|
47
|
-
content: '使用音视频功能请对相应设备进行授权',
|
|
48
|
-
confirmText: '去设置',
|
|
49
|
-
success: (res) => {
|
|
50
|
-
if (res.confirm) {
|
|
51
|
-
wx.openSetting()
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
const debouncePermissionPopup = debounce(permissionPopup, 300)
|
|
57
|
-
export function deviceAuthorize(deviceType: DeviceType, scope: DeviceScope) {
|
|
58
|
-
return function (target: any, key: string, descriptor: PropertyDescriptor): PropertyDescriptor {
|
|
59
|
-
const originalMethod = descriptor.value
|
|
60
|
-
descriptor.value = async function (...args: any[]): Promise<any> {
|
|
61
|
-
if (!await deviceCheck([deviceType])) {
|
|
62
|
-
try {
|
|
63
|
-
await wx.authorize({scope})
|
|
64
|
-
} catch (error) {
|
|
65
|
-
debouncePermissionPopup()
|
|
66
|
-
throw new Error(error)
|
|
67
|
-
}
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
// eslint-disable-next-line consistent-return
|
|
71
|
-
return originalMethod.apply(this, args)
|
|
72
|
-
}
|
|
73
|
-
return descriptor
|
|
74
|
-
}
|
|
75
|
-
}
|