/* eslint no-dupe-class-members: 0 */ declare module 'tencentcloud-webar' { declare const isWebGLSupported: boolean type ModuleConfig = { beautify: boolean segmentation: boolean } type AuthConfig = { licenseKey: string appId: string authFunc: () => Promise<{ signature: string timestamp: number }> } type CameraConfig = { width: number // 拍摄画面宽度 height: number // 拍摄画面高度 mirror: boolean // 是否开启左右镜像 frameRate: number // 画面采集帧率 } type BeautifyOptions = { whiten?: number // 美白 0-1 dermabrasion?: number // 磨皮0-1 lift?: number // 瘦脸0-1 shave?: number // 削脸0-1 eye?: number // 大眼0-1 chin?: number // 下巴0-1 } type BackgroundOptions = { type: 'image' | 'blur' | 'transparent' src?: string } type LoadingConfig = { enable: boolean size?: number lineWidth?: number strokeColor?: number } type SdkConfig = { module?: ModuleConfig auth: AuthConfig camera?: CameraConfig input?: MediaStream | HTMLImageElement | String beautify?: BeautifyOptions background?: BackgroundOptions loading?: LoadingConfig } type EffectOptions = { id: string intensity?: number // 特效强度,默认1,范围0-1 filterIntensity?: number // 单独控制特效中的滤镜强度,默认取intensity,范围0-1 (0.1.18及以上版本支持) } type FilterInfo = { CoverUrl: string Name: string EffectId: string PresetType: 'sticker' | 'filter' } type SdkError = | 10000001 // 当前浏览器环境不兼容 建议用户使用 Chrome、Firefox、Safari、微信 | 10000002 // 当前渲染上下文丢失 | 10000003 // 渲染耗时长 考虑降低视频分辨率或屏蔽功能 | 10000005 // 输入源解析错误 | 10001101 // 设置特效出错 | 10001102 // 设置滤镜出错 | 10001103 // 特效强度参数不正确 | 10001201 // 调起用户摄像头失败 | 10001202 // 摄像头中断 | 20002001 // 缺少鉴权参数鉴权参数 | 20001001 // 鉴权失败 请确认是否创建 License,请确认签名是否正确 | 20001002 // 接口请求失败 回调会回传接口返回的数据,具体信息请参见 接口错误码 | 30000001 // 小程序 startRecord 失败 | 30000002 // 小程序 stopRecord 失败 class ArSdk { constructor(config: SdkConfig) once(event: 'created', cb: () => void) once(event: 'cameraReady', cb: () => void) once(event: 'ready', cb: () => void) once( event: 'error', cb: (error: { code: SdkError; message: string }) => void, ) on(event: 'created', cb: () => void) on(event: 'cameraReady', cb: () => void) on(event: 'ready', cb: () => void) on(event: 'error', cb: (error: { code: SdkError; message: string }) => void) // TODO: contains three params but not explained in documentation off(event: string, cb: () => void): void async getOutput(fps?: number): Promise setBeautify(options: BeautifyOptions) setEffect(effects: EffectOptions, callback?: () => void) setFilter(id: string, intensity: number, callback?: () => void) setBackground(options: BackgroundOptions) getEffectList(params: { PageNumber?: number PageSize?: number Name?: string Label?: string Type: 'Custom' | 'Preset' }) async getEffect(effectId: number): Promise async getCommonFilter(): Promise async updateInputStream(src: MediaStream) resetCore(input: MediaStream) disable() enable() async startRecord() async stopRecord(params: { useOriginAudio: boolean // 是否录制视频原声 musicPath: string // 背景音乐地址,useOriginAudio为false时生效 }) async takePhoto(): { data: Uint8Array width: number height: number } destroy() } }